mirror of
https://gitlab.winehq.org/wine/wine-gecko.git
synced 2024-09-13 09:24:08 -07: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
4a049f8136
commit
bc41125f3f
@ -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,9 +134,11 @@ public:
|
||||
|
||||
static void CommitComposition(bool aDiscard)
|
||||
{
|
||||
NS_ENSURE_TRUE_VOID(sEnabledTextStore);
|
||||
NS_ASSERTION(IsInTSFMode(), "Not in TSF mode, shouldn't be called");
|
||||
if (sEnabledTextStore) {
|
||||
sEnabledTextStore->CommitCompositionInternal(aDiscard);
|
||||
}
|
||||
}
|
||||
|
||||
static void SetInputContext(nsWindowBase* aWidget,
|
||||
const InputContext& aContext,
|
||||
@ -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,9 +199,9 @@ public:
|
||||
return sMessagePump;
|
||||
}
|
||||
|
||||
static void* GetTextStore()
|
||||
static void* GetThreadManager()
|
||||
{
|
||||
return static_cast<void*>(sEnabledTextStore);
|
||||
return static_cast<void*>(sTsfThreadMgr);
|
||||
}
|
||||
|
||||
static bool ThinksHavingFocus()
|
||||
|
@ -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