diff --git a/dom/base/test/chrome/window_nsITextInputProcessor.xul b/dom/base/test/chrome/window_nsITextInputProcessor.xul index e7efc44669b9..674bb348b1d9 100644 --- a/dom/base/test/chrome/window_nsITextInputProcessor.xul +++ b/dom/base/test/chrome/window_nsITextInputProcessor.xul @@ -157,7 +157,9 @@ function runBeginInputTransactionMethodTests() // Let's confirm that the composing string is NOT committed by above tests. TIP1.commitComposition(); is(input.value, composingStr, - description + "TIP1.commitString() without specifying commit string should be committed with the last composing string"); + description + "TIP1.commitString() without specifying commit string should commit current composition with the last composing string"); + ok(!TIP1.hasComposition, + description + "TIP1.commitString() without specifying commit string should've end composition"); ok(TIP1.beginInputTransaction(window, simpleCallback), description + "TIP1.beginInputTransaction() should succeed because there is no composition #2"); diff --git a/widget/nsBaseWidget.cpp b/widget/nsBaseWidget.cpp index 1f517e1bdbac..be13838ee956 100644 --- a/widget/nsBaseWidget.cpp +++ b/widget/nsBaseWidget.cpp @@ -1933,6 +1933,22 @@ nsBaseWidget::EnsureTextEventDispatcher() mTextEventDispatcher = new TextEventDispatcher(this); } +nsIWidget::NativeIMEContext +nsBaseWidget::GetNativeIMEContext() +{ + if (mTextEventDispatcher && mTextEventDispatcher->GetPseudoIMEContext()) { + // If we already have a TextEventDispatcher and it's working with + // a TextInputProcessor, we need to return pseudo IME context since + // TextCompositionArray::IndexOf(nsIWidget*) should return a composition + // on the pseudo IME context in such case. + NativeIMEContext pseudoIMEContext; + pseudoIMEContext.InitWithRawNativeIMEContext( + mTextEventDispatcher->GetPseudoIMEContext()); + return pseudoIMEContext; + } + return NativeIMEContext(this); +} + nsIWidget::TextEventDispatcher* nsBaseWidget::GetTextEventDispatcher() { @@ -2441,12 +2457,6 @@ nsBaseWidget::DefaultFillScrollCapture(DrawTarget* aSnapshotDrawTarget) } #endif -nsIWidget::NativeIMEContext -nsIWidget::GetNativeIMEContext() -{ - return NativeIMEContext(this); -} - const IMENotificationRequests& nsIWidget::IMENotificationRequestsRef() { diff --git a/widget/nsBaseWidget.h b/widget/nsBaseWidget.h index 606a5f336707..d9ebdb8bf2a1 100644 --- a/widget/nsBaseWidget.h +++ b/widget/nsBaseWidget.h @@ -298,6 +298,7 @@ public: virtual void SetAttachedWidgetListener(nsIWidgetListener* aListener) override; virtual nsIWidgetListener* GetPreviouslyAttachedWidgetListener() override; virtual void SetPreviouslyAttachedWidgetListener(nsIWidgetListener* aListener) override; + virtual NativeIMEContext GetNativeIMEContext() override; TextEventDispatcher* GetTextEventDispatcher() final; virtual TextEventDispatcherListener* GetNativeTextEventDispatcherListener() override; diff --git a/widget/nsIWidget.h b/widget/nsIWidget.h index 03deae03070b..f8e2631dff74 100644 --- a/widget/nsIWidget.h +++ b/widget/nsIWidget.h @@ -1851,7 +1851,7 @@ public: * NS_RAW_NATIVE_IME_CONTEXT, the result is unique even if in a remote * process. */ - virtual NativeIMEContext GetNativeIMEContext(); + virtual NativeIMEContext GetNativeIMEContext() = 0; /* * Given a WidgetKeyboardEvent, this method synthesizes a corresponding