Bug 801989 part.4 Set InputContext::mNativeIMEContext on Mac r=smichaud
authorMasayuki Nakano <masayuki@d-toybox.com>
Sat, 27 Oct 2012 08:35:21 +0900
changeset 111585 80bb0b88086f6b271abb014e57fe2d3920e094cb
parent 111584 6e748a6c7216b23ffe9122abc6627b185e373547
child 111586 d7da33982b8afa502a0951b34af9f74556d1a525
push id23756
push userryanvm@gmail.com
push dateSat, 27 Oct 2012 20:39:25 +0000
treeherdermozilla-central@c5428231b6f7 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewerssmichaud
bugs801989
milestone19.0a1
first release with
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
last release without
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
Bug 801989 part.4 Set InputContext::mNativeIMEContext on Mac r=smichaud
widget/cocoa/nsChildView.mm
widget/cocoa/nsCocoaWindow.h
--- a/widget/cocoa/nsChildView.mm
+++ b/widget/cocoa/nsChildView.mm
@@ -1608,16 +1608,23 @@ nsChildView::GetInputContext()
           mTextInputHandler->IsIMEOpened() ? IMEState::OPEN : IMEState::CLOSED;
         break;
       }
       // If mTextInputHandler is null, set CLOSED instead...
     default:
       mInputContext.mIMEState.mOpen = IMEState::CLOSED;
       break;
   }
+  mInputContext.mNativeIMEContext = [mView inputContext];
+  // If input context isn't available on this widget, we should set |this|
+  // instead of nullptr since nullptr means that the platform has only one
+  // context per process.
+  if (!mInputContext.mNativeIMEContext) {
+    mInputContext.mNativeIMEContext = this;
+  }
   return mInputContext;
 }
 
 // Destruct and don't commit the IME composition string.
 NS_IMETHODIMP nsChildView::CancelIMEComposition()
 {
   NS_ENSURE_TRUE(mTextInputHandler, NS_ERROR_NOT_AVAILABLE);
   mTextInputHandler->CancelIMEComposition();
--- a/widget/cocoa/nsCocoaWindow.h
+++ b/widget/cocoa/nsCocoaWindow.h
@@ -289,16 +289,26 @@ public:
     NS_IMETHOD ResetInputState();
     NS_IMETHOD_(void) SetInputContext(const InputContext& aContext,
                                       const InputContextAction& aAction)
     {
       mInputContext = aContext;
     }
     NS_IMETHOD_(InputContext) GetInputContext()
     {
+      NSView* view = mWindow ? [mWindow contentView] : nil;
+      if (view) {
+        mInputContext.mNativeIMEContext = [view inputContext];
+      }
+      // If inputContext isn't available on this window, returns this window's
+      // pointer since nullptr means the platform has only one context per
+      // process.
+      if (!mInputContext.mNativeIMEContext) {
+        mInputContext.mNativeIMEContext = this;
+      }
       return mInputContext;
     }
     NS_IMETHOD BeginSecureKeyboardInput();
     NS_IMETHOD EndSecureKeyboardInput();
 
     void SetPopupWindowLevel();
 
     bool IsChildInFailingLeftClickThrough(NSView *aChild);