Bug 1082425 - Commit composition string before changing focus by long tap. r=masayuki
authorTing-Yu Lin <tlin@mozilla.com>
Wed, 25 Nov 2015 05:16:00 +0800
changeset 308454 3c0f581dc05bf9ddb823b1d380dcc05e69004cc6
parent 308453 7e18014be68d9e13760b2814862745911caf49a5
child 308455 590126cc607b4e478ba2ead595ca1f4ccca34bc1
push id5513
push userraliiev@mozilla.com
push dateMon, 25 Jan 2016 13:55:34 +0000
treeherdermozilla-beta@5ee97dd05b5c [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersmasayuki
bugs1082425
milestone45.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 1082425 - Commit composition string before changing focus by long tap. r=masayuki This also prevents that long tapping to select word while composing corrupts the editable data on B2G.
layout/base/AccessibleCaretManager.cpp
--- a/layout/base/AccessibleCaretManager.cpp
+++ b/layout/base/AccessibleCaretManager.cpp
@@ -8,16 +8,17 @@
 
 #include "AccessibleCaret.h"
 #include "AccessibleCaretEventHub.h"
 #include "AccessibleCaretLogger.h"
 #include "mozilla/AsyncEventDispatcher.h"
 #include "mozilla/dom/Element.h"
 #include "mozilla/dom/Selection.h"
 #include "mozilla/dom/TreeWalker.h"
+#include "mozilla/IMEStateManager.h"
 #include "nsCaret.h"
 #include "nsContentUtils.h"
 #include "nsFocusManager.h"
 #include "nsFrame.h"
 #include "nsFrameSelection.h"
 #include "nsGenericHTMLElement.h"
 
 namespace mozilla {
@@ -427,16 +428,21 @@ AccessibleCaretManager::SelectWordOrShor
   AC_LOG("%s: %s %s selectable.", __FUNCTION__, ptFrame->ListTag().get(),
          selectable ? "is" : "is NOT");
 #endif
 
   if (!selectable) {
     return NS_ERROR_FAILURE;
   }
 
+  // Commit the composition string of the old editable focus element (if there
+  // is any) before changing the focus.
+  IMEStateManager::NotifyIME(widget::REQUEST_TO_COMMIT_COMPOSITION,
+                             mPresShell->GetPresContext());
+
   // ptFrame is selectable. Now change the focus.
   ChangeFocusToOrClearOldFocus(focusableFrame);
 
   // Then try select a word under point.
   nsPoint ptInFrame = aPoint;
   nsLayoutUtils::TransformPoint(rootFrame, ptFrame, ptInFrame);
 
   nsresult rv = SelectWord(ptFrame, ptInFrame);