Bug 1224994 part.5 Implement TSFTextStore::IsComposingInContent() to check if the focused editor has composition r=m_kato
authorMasayuki Nakano <masayuki@d-toybox.com>
Wed, 29 Jun 2016 17:39:59 +0900
changeset 303675 e29577344d51c00c59d24c6e7066d359160b1e14
parent 303674 08af14bb5e38c5723398431cf2c061ea3edd5add
child 303676 ce51850dddc6e6ac484ea4adeedb3ac99b8fed89
push id79141
push usercbook@mozilla.com
push dateTue, 05 Jul 2016 14:07:42 +0000
treeherdermozilla-inbound@f08c54971dd1 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersm_kato
bugs1224994
milestone50.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 1224994 part.5 Implement TSFTextStore::IsComposingInContent() to check if the focused editor has composition r=m_kato MozReview-Commit-ID: 2bmGeaxUpUU
widget/TextEventDispatcher.h
widget/windows/TSFTextStore.cpp
widget/windows/TSFTextStore.h
--- a/widget/TextEventDispatcher.h
+++ b/widget/TextEventDispatcher.h
@@ -89,16 +89,25 @@ public:
 
   /**
    * IsComposing() returns true after calling StartComposition() and before
    * calling CommitComposition().
    */
   bool IsComposing() const { return mIsComposing; }
 
   /**
+   * IsInNativeInputTransaction() returns true if native IME handler began a
+   * transaction and it's not finished yet.
+   */
+  bool IsInNativeInputTransaction() const
+  {
+    return mInputTransactionType == eNativeInputTransaction;
+  }
+
+  /**
    * IsDispatchingEvent() returns true while this instance dispatching an event.
    */
   bool IsDispatchingEvent() const { return mDispatchingEvent > 0; }
 
   /**
    * GetPseudoIMEContext() returns pseudo native IME context if there is an
    * input transaction whose type is not for native event handler.
    * Otherwise, returns nullptr.
--- a/widget/windows/TSFTextStore.cpp
+++ b/widget/windows/TSFTextStore.cpp
@@ -1972,16 +1972,28 @@ TSFTextStore::GetSelection(ULONG ulIndex
   }
   *pSelection = currentSel.ACP();
   *pcFetched = 1;
   MOZ_LOG(sTextStoreLog, LogLevel::Info,
          ("TSF: 0x%p   TSFTextStore::GetSelection() succeeded", this));
   return S_OK;
 }
 
+bool
+TSFTextStore::IsComposingInContent() const
+{
+  if (!mDispatcher) {
+    return false;
+  }
+  if (!mDispatcher->IsInNativeInputTransaction()) {
+    return false;
+  }
+  return mDispatcher->IsComposing();
+}
+
 TSFTextStore::Content&
 TSFTextStore::ContentForTSFRef()
 {
   // This should be called when the document is locked or the content hasn't
   // been abandoned yet.
   if (NS_WARN_IF(!IsReadLocked() && !mContentForTSF.IsInitialized())) {
     MOZ_LOG(sTextStoreLog, LogLevel::Error,
            ("TSF: 0x%p   TSFTextStore::ContentForTSFRef(), FAILED, due to "
--- a/widget/windows/TSFTextStore.h
+++ b/widget/windows/TSFTextStore.h
@@ -402,16 +402,24 @@ protected:
   // While the document is locked, we cannot dispatch any events which cause
   // DOM events since the DOM events' handlers may modify the locked document.
   // However, even while the document is locked, TSF may queries us.
   // For that, TSFTextStore modifies mComposition even while the document is
   // locked.  With mComposition, query methods can returns the text content
   // information.
   Composition mComposition;
 
+  /**
+   * IsComposingInContent() returns true if there is a composition in the
+   * focused editor and it's caused by native IME (either TIP of TSF or IME of
+   * IMM).  I.e., returns true between eCompositionStart and
+   * eCompositionCommit(AsIs).
+   */
+  bool IsComposingInContent() const;
+
   class Selection
   {
   public:
     Selection() : mDirty(true) {}
 
     bool IsDirty() const { return mDirty; };
     void MarkDirty() { mDirty = true; }