Bug 1186799 part.1 nsHTMLEditorEventListener should commit composition when it receives unacceptable mousedown event r=smaug
authorMasayuki Nakano <masayuki@d-toybox.com>
Sat, 08 Aug 2015 09:23:04 +0900
changeset 288553 8ad9b87bac4da23ff549ecb2d2b602341f769f40
parent 288552 009c9c7d9c942a35c41b8aa649f345331a213b79
child 288554 e0a8c1d52ab9e0fa0bf133350e096b9400d8e0fd
push id5067
push userraliiev@mozilla.com
push dateMon, 21 Sep 2015 14:04:52 +0000
treeherdermozilla-beta@14221ffe5b2f [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewerssmaug
bugs1186799
milestone42.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 1186799 part.1 nsHTMLEditorEventListener should commit composition when it receives unacceptable mousedown event r=smaug
editor/libeditor/nsEditorEventListener.cpp
editor/libeditor/nsHTMLEditorEventListener.cpp
--- a/editor/libeditor/nsEditorEventListener.cpp
+++ b/editor/libeditor/nsEditorEventListener.cpp
@@ -778,16 +778,18 @@ nsEditorEventListener::NotifyIMEOfMouseB
   return IMEStateManager::OnMouseButtonEventInEditor(presContext,
                                                      GetFocusedRootContent(),
                                                      aMouseEvent);
 }
 
 nsresult
 nsEditorEventListener::MouseDown(nsIDOMMouseEvent* aMouseEvent)
 {
+  // FYI: This may be called by nsHTMLEditorEventListener::MouseDown() even
+  //      when the event is not acceptable for committing composition.
   mEditor->ForceCompositionEnd();
   return NS_OK;
 }
 
 nsresult
 nsEditorEventListener::HandleText(nsIDOMEvent* aTextEvent)
 {
   if (!mEditor->IsAcceptableInputEvent(aTextEvent)) {
--- a/editor/libeditor/nsHTMLEditorEventListener.cpp
+++ b/editor/libeditor/nsHTMLEditorEventListener.cpp
@@ -76,17 +76,21 @@ nsHTMLEditorEventListener::MouseUp(nsIDO
 
 nsresult
 nsHTMLEditorEventListener::MouseDown(nsIDOMMouseEvent* aMouseEvent)
 {
   nsHTMLEditor* htmlEditor = GetHTMLEditor();
   // Contenteditable should disregard mousedowns outside it.
   // IsAcceptableInputEvent() checks it for a mouse event.
   if (!htmlEditor->IsAcceptableInputEvent(aMouseEvent)) {
-    return NS_OK;
+    // If it's not acceptable mousedown event (including when mousedown event
+    // is fired outside of the active editing host), we need to commit
+    // composition because it will be change the selection to the clicked
+    // point.  Then, we won't be able to commit the composition.
+    return nsEditorEventListener::MouseDown(aMouseEvent);
   }
 
   // Detect only "context menu" click
   // XXX This should be easier to do!
   // But eDOMEvents_contextmenu and NS_CONTEXTMENU is not exposed in any event
   // interface :-(
   int16_t buttonNumber;
   nsresult rv = aMouseEvent->GetButton(&buttonNumber);