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 256952 8ad9b87bac4da23ff549ecb2d2b602341f769f40
parent 256951 009c9c7d9c942a35c41b8aa649f345331a213b79
child 256953 e0a8c1d52ab9e0fa0bf133350e096b9400d8e0fd
push id14551
push userphilringnalda@gmail.com
push dateSun, 09 Aug 2015 02:42:06 +0000
treeherderfx-team@55d2b7e1e99b [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewerssmaug
bugs1186799
milestone42.0a1
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);