Bug 1450055 - Part 1. Add focus event to system group to initialize editor. r=masayuki
authorMakoto Kato <m_kato@ga2.so-net.ne.jp>
Tue, 08 Jan 2019 14:51:41 +0900
changeset 510113 5c4619332810e4b9595ead4df95dd1ddbfee2acc
parent 510112 e9bc92a2ff289ce8171b7acc921a4b4ebe8fce0b
child 510114 85fda059ef060d64b39848b3897e313e1e9b4900
push id10547
push userffxbld-merge
push dateMon, 21 Jan 2019 13:03:58 +0000
treeherdermozilla-beta@24ec1916bffe [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersmasayuki
bugs1450055
milestone66.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 1450055 - Part 1. Add focus event to system group to initialize editor. r=masayuki Editor initializes selection and input context (via IMEStateManager) on focus event. But if content script calls stopImmediatePropagation on focus event, editor cannot initialize these since editor cannot receive focus event. It means that Android widget doesn't open virtual keyboard since GeckoEditableSupport::SetInputContext isn't called. Also, Firefox desktop doesn't show caret in this situation since selection isn't initialized in editor. So the event listener of focus and blur event should use system group. Differential Revision: https://phabricator.services.mozilla.com/D15921
editor/libeditor/EditorEventListener.cpp
--- a/editor/libeditor/EditorEventListener.cpp
+++ b/editor/libeditor/EditorEventListener.cpp
@@ -164,25 +164,22 @@ nsresult EditorEventListener::InstallToE
   //     However, if we do so, all click handlers in any frames and frontend
   //     code need to check if it's editable.  It makes easier create new bugs.
   elmP->AddEventListenerByType(this, NS_LITERAL_STRING("mousedown"),
                                TrustedEventsAtCapture());
   elmP->AddEventListenerByType(this, NS_LITERAL_STRING("mouseup"),
                                TrustedEventsAtCapture());
   elmP->AddEventListenerByType(this, NS_LITERAL_STRING("click"),
                                TrustedEventsAtCapture());
-  // Focus event doesn't bubble so adding the listener to capturing phase.
-  // XXX Should we listen focus/blur events of system group too? Or should
-  //     editor notified focus/blur of the element from nsFocusManager
-  //     directly?  Because if the event propagation is stopped by JS,
-  //     editor cannot initialize selection as expected.
+  // Focus event doesn't bubble so adding the listener to capturing phase as
+  // system event group.
   elmP->AddEventListenerByType(this, NS_LITERAL_STRING("blur"),
-                               TrustedEventsAtCapture());
+                               TrustedEventsAtSystemGroupCapture());
   elmP->AddEventListenerByType(this, NS_LITERAL_STRING("focus"),
-                               TrustedEventsAtCapture());
+                               TrustedEventsAtSystemGroupCapture());
   elmP->AddEventListenerByType(this, NS_LITERAL_STRING("text"),
                                TrustedEventsAtSystemGroupBubble());
   elmP->AddEventListenerByType(this, NS_LITERAL_STRING("compositionstart"),
                                TrustedEventsAtSystemGroupBubble());
   elmP->AddEventListenerByType(this, NS_LITERAL_STRING("compositionend"),
                                TrustedEventsAtSystemGroupBubble());
 
   return NS_OK;
@@ -238,19 +235,19 @@ void EditorEventListener::UninstallFromE
                                   TrustedEventsAtSystemGroupBubble());
   elmP->RemoveEventListenerByType(this, NS_LITERAL_STRING("mousedown"),
                                   TrustedEventsAtCapture());
   elmP->RemoveEventListenerByType(this, NS_LITERAL_STRING("mouseup"),
                                   TrustedEventsAtCapture());
   elmP->RemoveEventListenerByType(this, NS_LITERAL_STRING("click"),
                                   TrustedEventsAtCapture());
   elmP->RemoveEventListenerByType(this, NS_LITERAL_STRING("blur"),
-                                  TrustedEventsAtCapture());
+                                  TrustedEventsAtSystemGroupCapture());
   elmP->RemoveEventListenerByType(this, NS_LITERAL_STRING("focus"),
-                                  TrustedEventsAtCapture());
+                                  TrustedEventsAtSystemGroupCapture());
   elmP->RemoveEventListenerByType(this, NS_LITERAL_STRING("text"),
                                   TrustedEventsAtSystemGroupBubble());
   elmP->RemoveEventListenerByType(this, NS_LITERAL_STRING("compositionstart"),
                                   TrustedEventsAtSystemGroupBubble());
   elmP->RemoveEventListenerByType(this, NS_LITERAL_STRING("compositionend"),
                                   TrustedEventsAtSystemGroupBubble());
 }