Bug 1304620 part.5 ContentCacheInParent should store the latest composition start offset with mCompositionStartInChild r=m_kato
authorMasayuki Nakano <masayuki@d-toybox.com>
Wed, 12 Oct 2016 21:52:01 +0900
changeset 362885 d3cf438132337bcc7f615859863271a95f746a28
parent 362884 aa2c12432274f8926ffbc3b35502eedf176034b1
child 362886 64cd7d87e78cf2e4b919aad10fb9f4962834b004
push id1369
push userjlorenzo@mozilla.com
push dateMon, 27 Feb 2017 14:59:41 +0000
treeherdermozilla-release@d75a1dba431f [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
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 1304620 part.5 ContentCacheInParent should store the latest composition start offset with mCompositionStartInChild r=m_kato When ContentCacheInParent receives eCompositionStart, it temporarily sets mCompositionStart to selection start offset. However, if there is a composition in the remote process, the selection start is caret position in the composition string. Therefore, it's not useful information. Instead, the composition start offset should be used because around there are a lot of information. For that, ContentCacheInParent should always store compostion start offset in the remote process with mCompositionStartInChild even if mWidgetHasComposition is false. And when it receives eCompositionStart, mCompositionStart should be set to mCompositionStartInChild. MozReview-Commit-ID: DksPNEsi6Ec
--- a/widget/ContentCache.cpp
+++ b/widget/ContentCache.cpp
@@ -505,16 +505,17 @@ ContentCacheInChild::SetSelection(nsIWid
  * mozilla::ContentCacheInParent
   : ContentCache()
   , mCommitStringByRequest(nullptr)
   , mPendingEventsNeedingAck(0)
+  , mCompositionStartInChild(UINT32_MAX)
   , mPendingCompositionCount(0)
   , mWidgetHasComposition(false)
 ContentCacheInParent::AssignContent(const ContentCache& aOther,
                                     nsIWidget* aWidget,
@@ -534,16 +535,17 @@ ContentCacheInParent::AssignContent(cons
   if (mWidgetHasComposition && mPendingCompositionCount == 1) {
     IMEStateManager::MaybeStartOffsetUpdatedInChild(aWidget, mCompositionStart);
   // When the widget has composition, we should set mCompositionStart to
   // *current* composition start offset.  Note that, in strictly speaking,
   // widget should not use WidgetQueryContentEvent if there are some pending
   // compositions (i.e., when mPendingCompositionCount is 2 or more).
+  mCompositionStartInChild = aOther.mCompositionStart;
   if (mWidgetHasComposition) {
     if (aOther.mCompositionStart != UINT32_MAX) {
       mCompositionStart = aOther.mCompositionStart;
     } else {
       mCompositionStart = mSelection.StartOffset();
       NS_WARNING_ASSERTION(mCompositionStart != UINT32_MAX,
                            "mCompositionStart shouldn't be invalid offset when "
                            "the widget has composition");
@@ -1086,16 +1088,22 @@ ContentCacheInParent::OnCompositionEvent
   // We must be able to simulate the selection because
   // we might not receive selection updates in time
   if (!mWidgetHasComposition) {
     if (aEvent.mWidget && aEvent.mWidget->PluginHasFocus()) {
       // If focus is on plugin, we cannot get selection range
       mCompositionStart = 0;
+    } else if (mCompositionStartInChild != UINT32_MAX) {
+      // If there is pending composition in the remote process, let's use
+      // its start offset temporarily because this stores a lot of information
+      // around it and the user must look around there, so, showing some UI
+      // around it must make sense.
+      mCompositionStart = mCompositionStartInChild;
     } else {
       mCompositionStart = mSelection.StartOffset();
     MOZ_ASSERT(aEvent.mMessage == eCompositionStart);
     MOZ_RELEASE_ASSERT(mPendingCompositionCount < UINT8_MAX);
--- a/widget/ContentCache.h
+++ b/widget/ContentCache.h
@@ -409,16 +409,19 @@ private:
   // This is not nullptr only while the instance is requesting IME to
   // composition.  Then, data value of dispatched composition events should
   // be stored into the instance.
   nsAString* mCommitStringByRequest;
   // mPendingEventsNeedingAck is increased before sending a composition event or
   // a selection event and decreased after they are received in the child
   // process.
   uint32_t mPendingEventsNeedingAck;
+  // mCompositionStartInChild stores current composition start offset in the
+  // remote process.
+  uint32_t mCompositionStartInChild;
   // mPendingCompositionCount is number of compositions which started in widget
   // but not yet handled in the child process.
   uint8_t mPendingCompositionCount;
   // mWidgetHasComposition is true when the widget in this process thinks that
   // IME has composition.  So, this is set to true when eCompositionStart is
   // dispatched and set to false when eCompositionCommit(AsIs) is dispatched.
   bool mWidgetHasComposition;