Bug 805767 part.2 Implement nsIWidget::GetIMEUpdatePreference() on Windows for TSF r=emk
authorMasayuki Nakano <masayuki@d-toybox.com>
Tue, 13 Nov 2012 22:04:45 +0900
changeset 113079 1f4c0a90aa2c39370dde7951d89f31b4eb63f5ec
parent 113078 cc77a4ed08bdb8e4c1753aeb62eeda3e501ada78
child 113080 246c565c9da975309db53bbf2aa3e67eb74d7366
push id17931
push usermasayuki@d-toybox.com
push dateTue, 13 Nov 2012 13:04:59 +0000
treeherdermozilla-inbound@246c565c9da9 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersemk
bugs805767
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 805767 part.2 Implement nsIWidget::GetIMEUpdatePreference() on Windows for TSF r=emk
widget/windows/nsTextStore.cpp
widget/windows/nsTextStore.h
widget/windows/nsWindow.cpp
widget/windows/nsWindow.h
--- a/widget/windows/nsTextStore.cpp
+++ b/widget/windows/nsTextStore.cpp
@@ -2559,16 +2559,29 @@ nsTextStore::OnFocusChange(bool aFocus,
     HRESULT hr = sTsfThreadMgr->SetFocus(sTsfTextStore->mDocumentMgr);
     NS_ENSURE_TRUE(SUCCEEDED(hr), NS_ERROR_FAILURE);
   } else {
     sTsfTextStore->Destroy();
   }
   return NS_OK;
 }
 
+// static
+nsIMEUpdatePreference
+nsTextStore::GetIMEUpdatePreference()
+{
+  bool hasFocus = false;
+  if (sTsfThreadMgr && sTsfTextStore && sTsfTextStore->mDocumentMgr) {
+    nsRefPtr<ITfDocumentMgr> docMgr;
+    sTsfThreadMgr->GetFocus(getter_AddRefs(docMgr));
+    hasFocus = (docMgr == sTsfTextStore->mDocumentMgr);
+  }
+  return nsIMEUpdatePreference(hasFocus, false);
+}
+
 nsresult
 nsTextStore::OnTextChangeInternal(uint32_t aStart,
                                   uint32_t aOldEnd,
                                   uint32_t aNewEnd)
 {
   PR_LOG(sTextStoreLog, PR_LOG_DEBUG,
          ("TSF: 0x%p nsTextStore::OnTextChangeInternal(aStart=%lu, "
           "aOldEnd=%lu, aNewEnd=%lu), mLock=%s, mSink=0x%p, mSinkMask=%s, "
--- a/widget/windows/nsTextStore.h
+++ b/widget/windows/nsTextStore.h
@@ -119,16 +119,18 @@ public:
   }
 
   static nsresult OnSelectionChange(void)
   {
     if (!sTsfTextStore) return NS_OK;
     return sTsfTextStore->OnSelectionChangeInternal();
   }
 
+  static nsIMEUpdatePreference GetIMEUpdatePreference();
+
   static void CompositionTimerCallbackFunc(nsITimer *aTimer, void *aClosure)
   {
     nsTextStore *ts = static_cast<nsTextStore*>(aClosure);
     ts->OnCompositionTimer();
   }
 
   // Returns the address of the pointer so that the TSF automatic test can
   // replace the system object with a custom implementation for testing.
--- a/widget/windows/nsWindow.cpp
+++ b/widget/windows/nsWindow.cpp
@@ -7416,16 +7416,23 @@ nsWindow::OnIMETextChange(uint32_t aStar
   return nsTextStore::OnTextChange(aStart, aOldEnd, aNewEnd);
 }
 
 NS_IMETHODIMP
 nsWindow::OnIMESelectionChange(void)
 {
   return nsTextStore::OnSelectionChange();
 }
+
+nsIMEUpdatePreference
+nsWindow::GetIMEUpdatePreference()
+{
+  return nsTextStore::GetIMEUpdatePreference();
+}
+
 #endif //NS_ENABLE_TSF
 
 bool nsWindow::AssociateDefaultIMC(bool aAssociate)
 {
   nsIMEContext IMEContext(mWnd);
 
   if (aAssociate) {
     BOOL ret = ::ImmAssociateContextEx(mWnd, NULL, IACE_DEFAULT);
--- a/widget/windows/nsWindow.h
+++ b/widget/windows/nsWindow.h
@@ -171,16 +171,17 @@ public:
   virtual void            SetTransparencyMode(nsTransparencyMode aMode);
   virtual nsTransparencyMode GetTransparencyMode();
   virtual void            UpdateOpaqueRegion(const nsIntRegion& aOpaqueRegion);
 #endif // MOZ_XUL
 #ifdef NS_ENABLE_TSF
   NS_IMETHOD              OnIMEFocusChange(bool aFocus);
   NS_IMETHOD              OnIMETextChange(uint32_t aStart, uint32_t aOldEnd, uint32_t aNewEnd);
   NS_IMETHOD              OnIMESelectionChange(void);
+  virtual nsIMEUpdatePreference GetIMEUpdatePreference();
 #endif // NS_ENABLE_TSF
   NS_IMETHOD              GetNonClientMargins(nsIntMargin &margins);
   NS_IMETHOD              SetNonClientMargins(nsIntMargin &margins);
   void                    SetDrawsInTitlebar(bool aState);
 
   /**
    * Event helpers
    */