mirror of
https://github.com/mozilla/gecko-dev.git
synced 2024-12-02 01:48:05 +00:00
Bug 1052343 part.2 Don't assume that there is nsTextStore instance even during in TSF mode r=emk
This commit is contained in:
parent
0678bd0d40
commit
5b3a4cc71f
@ -289,7 +289,7 @@ IMEHandler::SetInputContext(nsWindow* aWindow,
|
||||
if (sIsInTSFMode) {
|
||||
nsTextStore::SetInputContext(aWindow, aInputContext, aAction);
|
||||
if (IsTSFAvailable()) {
|
||||
aInputContext.mNativeIMEContext = nsTextStore::GetTextStore();
|
||||
aInputContext.mNativeIMEContext = nsTextStore::GetThreadManager();
|
||||
if (sIsIMMEnabled) {
|
||||
// Associate IME context for IMM-IMEs.
|
||||
AssociateIMEContext(aWindow, enable);
|
||||
@ -354,7 +354,7 @@ IMEHandler::InitInputContext(nsWindow* aWindow, InputContext& aInputContext)
|
||||
nsTextStore::SetInputContext(aWindow, aInputContext,
|
||||
InputContextAction(InputContextAction::CAUSE_UNKNOWN,
|
||||
InputContextAction::GOT_FOCUS));
|
||||
aInputContext.mNativeIMEContext = nsTextStore::GetTextStore();
|
||||
aInputContext.mNativeIMEContext = nsTextStore::GetThreadManager();
|
||||
MOZ_ASSERT(aInputContext.mNativeIMEContext);
|
||||
// IME context isn't necessary in pure TSF mode.
|
||||
if (!sIsIMMEnabled) {
|
||||
|
@ -3669,7 +3669,7 @@ nsTextStore::OnFocusChange(bool aGotFocus,
|
||||
sTsfThreadMgr, sEnabledTextStore));
|
||||
|
||||
// no change notifications if TSF is disabled
|
||||
NS_ENSURE_TRUE(sTsfThreadMgr && sEnabledTextStore, NS_ERROR_NOT_AVAILABLE);
|
||||
NS_ENSURE_TRUE(IsInTSFMode(), NS_ERROR_NOT_AVAILABLE);
|
||||
|
||||
nsRefPtr<ITfDocumentMgr> prevFocusedDocumentMgr;
|
||||
if (aGotFocus && aIMEState.IsEditable()) {
|
||||
@ -4208,12 +4208,17 @@ nsTextStore::SetInputContext(nsWindowBase* aWidget,
|
||||
PR_LOG(sTextStoreLog, PR_LOG_DEBUG,
|
||||
("TSF: nsTextStore::SetInputContext(aWidget=%p, "
|
||||
"aContext.mIMEState.mEnabled=%s, aAction.mFocusChange=%s), "
|
||||
"ThinksHavingFocus()=%s",
|
||||
"sEnabledTextStore=0x%p, ThinksHavingFocus()=%s",
|
||||
aWidget, GetIMEEnabledName(aContext.mIMEState.mEnabled),
|
||||
GetFocusChangeName(aAction.mFocusChange),
|
||||
GetFocusChangeName(aAction.mFocusChange), sEnabledTextStore,
|
||||
GetBoolName(ThinksHavingFocus())));
|
||||
|
||||
NS_ENSURE_TRUE_VOID(sEnabledTextStore);
|
||||
NS_ENSURE_TRUE_VOID(IsInTSFMode());
|
||||
|
||||
if (!sEnabledTextStore) {
|
||||
return;
|
||||
}
|
||||
|
||||
sEnabledTextStore->SetInputScope(aContext.mHTMLInputType);
|
||||
|
||||
if (aAction.mFocusChange != InputContextAction::FOCUS_NOT_CHANGED) {
|
||||
|
@ -134,8 +134,10 @@ public:
|
||||
|
||||
static void CommitComposition(bool aDiscard)
|
||||
{
|
||||
NS_ENSURE_TRUE_VOID(sEnabledTextStore);
|
||||
sEnabledTextStore->CommitCompositionInternal(aDiscard);
|
||||
NS_ASSERTION(IsInTSFMode(), "Not in TSF mode, shouldn't be called");
|
||||
if (sEnabledTextStore) {
|
||||
sEnabledTextStore->CommitCompositionInternal(aDiscard);
|
||||
}
|
||||
}
|
||||
|
||||
static void SetInputContext(nsWindowBase* aWidget,
|
||||
@ -147,28 +149,30 @@ public:
|
||||
const IMEState& aIMEState);
|
||||
static nsresult OnTextChange(const IMENotification& aIMENotification)
|
||||
{
|
||||
NS_ENSURE_TRUE(sEnabledTextStore, NS_ERROR_NOT_AVAILABLE);
|
||||
return sEnabledTextStore->OnTextChangeInternal(aIMENotification);
|
||||
NS_ASSERTION(IsInTSFMode(), "Not in TSF mode, shouldn't be called");
|
||||
return sEnabledTextStore ?
|
||||
sEnabledTextStore->OnTextChangeInternal(aIMENotification) : NS_OK;
|
||||
}
|
||||
|
||||
static nsresult OnSelectionChange(void)
|
||||
{
|
||||
NS_ENSURE_TRUE(sEnabledTextStore, NS_ERROR_NOT_AVAILABLE);
|
||||
return sEnabledTextStore->OnSelectionChangeInternal();
|
||||
NS_ASSERTION(IsInTSFMode(), "Not in TSF mode, shouldn't be called");
|
||||
return sEnabledTextStore ?
|
||||
sEnabledTextStore->OnSelectionChangeInternal() : NS_OK;
|
||||
}
|
||||
|
||||
static nsresult OnLayoutChange()
|
||||
{
|
||||
NS_ENSURE_TRUE(sEnabledTextStore, NS_ERROR_NOT_AVAILABLE);
|
||||
return sEnabledTextStore->OnLayoutChangeInternal();
|
||||
NS_ASSERTION(IsInTSFMode(), "Not in TSF mode, shouldn't be called");
|
||||
return sEnabledTextStore ?
|
||||
sEnabledTextStore->OnLayoutChangeInternal() : NS_OK;
|
||||
}
|
||||
|
||||
static nsresult OnMouseButtonEvent(const IMENotification& aIMENotification)
|
||||
{
|
||||
if (NS_WARN_IF(!sEnabledTextStore)) {
|
||||
return NS_ERROR_NOT_AVAILABLE;
|
||||
}
|
||||
return sEnabledTextStore->OnMouseButtonEventInternal(aIMENotification);
|
||||
NS_ASSERTION(IsInTSFMode(), "Not in TSF mode, shouldn't be called");
|
||||
return sEnabledTextStore ?
|
||||
sEnabledTextStore->OnMouseButtonEventInternal(aIMENotification) : NS_OK;
|
||||
}
|
||||
|
||||
static nsIMEUpdatePreference GetIMEUpdatePreference();
|
||||
@ -195,32 +199,32 @@ public:
|
||||
return sMessagePump;
|
||||
}
|
||||
|
||||
static void* GetTextStore()
|
||||
static void* GetThreadManager()
|
||||
{
|
||||
return static_cast<void*>(sEnabledTextStore);
|
||||
return static_cast<void*>(sTsfThreadMgr);
|
||||
}
|
||||
|
||||
static bool ThinksHavingFocus()
|
||||
static bool ThinksHavingFocus()
|
||||
{
|
||||
return (sEnabledTextStore && sEnabledTextStore->mContext);
|
||||
}
|
||||
|
||||
static bool IsInTSFMode()
|
||||
static bool IsInTSFMode()
|
||||
{
|
||||
return sTsfThreadMgr != nullptr;
|
||||
}
|
||||
|
||||
static bool IsComposing()
|
||||
static bool IsComposing()
|
||||
{
|
||||
return (sEnabledTextStore && sEnabledTextStore->mComposition.IsComposing());
|
||||
}
|
||||
|
||||
static bool IsComposingOn(nsWindowBase* aWidget)
|
||||
static bool IsComposingOn(nsWindowBase* aWidget)
|
||||
{
|
||||
return (IsComposing() && sEnabledTextStore->mWidget == aWidget);
|
||||
}
|
||||
|
||||
static bool IsIMM_IME()
|
||||
static bool IsIMM_IME()
|
||||
{
|
||||
if (!sEnabledTextStore ||
|
||||
!sEnabledTextStore->EnsureInitActiveTIPKeyboard()) {
|
||||
@ -229,7 +233,7 @@ public:
|
||||
return sEnabledTextStore->mIsIMM_IME;
|
||||
}
|
||||
|
||||
static bool IsIMM_IME(HKL aHKL)
|
||||
static bool IsIMM_IME(HKL aHKL)
|
||||
{
|
||||
return (::ImmGetIMEFileNameW(aHKL, nullptr, 0) > 0);
|
||||
}
|
||||
|
@ -1542,6 +1542,7 @@ NS_IMETHODIMP_(void)
|
||||
MetroWidget::SetInputContext(const InputContext& aContext,
|
||||
const InputContextAction& aAction)
|
||||
{
|
||||
// XXX This should set mInputContext.mNativeIMEContext properly
|
||||
mInputContext = aContext;
|
||||
nsTextStore::SetInputContext(this, mInputContext, aAction);
|
||||
bool enable = (mInputContext.mIMEState.mEnabled == IMEState::ENABLED ||
|
||||
|
Loading…
Reference in New Issue
Block a user