Bug 1478776 - Part 8: Add an event flag for dispatching to system group only. r=smaug
authorJan Henning <jh+bugzilla@buttercookie.de>
Thu, 20 Dec 2018 21:35:39 +0000
changeset 451699 767281b6922eda01f577939b69f988ab6efc9866
parent 451698 6f2e2faa3321fb36ac285310855c4bd3e25e8657
child 451700 4d4e9b8110451b9393b44078e32d1c36b7c31968
push id35251
push userccoroiu@mozilla.com
push dateFri, 21 Dec 2018 21:54:30 +0000
treeherdermozilla-central@74101900e7d4 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewerssmaug
bugs1478776
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 1478776 - Part 8: Add an event flag for dispatching to system group only. r=smaug The semantics of the VisualViewport resize/scroll events aren't quite what is needed for internal browser usage, so we need a separate set of events that can be used e.g. by the session store. To avoid future web compatibility issues, that event should be kept internal, however none of the existing options to achieve that are suitable: - mNoContentDispatch can actually end up being dispatched to content after all and as per its comment preferably shouldn't be used any more for new features - mOnlySystemGroupDispatchInContent would work perfectly, except that it shouldn't be used for frequent events, which the resize/scroll events arguably are - mOnlyChromeDispatch doesn't work for the Desktop session store's content script, plus it might have the same performance problems as mOnlySystemGroupDispatchInContent Therefore, I propose to introduce a new mOnlySystemGroupDispatch event flag, which skips the comparatively expensive IsCurrentTargetChrome() check and relies only on the event listener having been registered in the system group. Differential Revision: https://phabricator.services.mozilla.com/D14045
dom/events/EventDispatcher.cpp
widget/BasicEvents.h
--- a/dom/events/EventDispatcher.cpp
+++ b/dom/events/EventDispatcher.cpp
@@ -325,16 +325,20 @@ class EventTargetChainItem {
    */
   void HandleEvent(EventChainPostVisitor& aVisitor, ELMCreationDetector& aCd) {
     if (WantsWillHandleEvent()) {
       mTarget->WillHandleEvent(aVisitor);
     }
     if (aVisitor.mEvent->PropagationStopped()) {
       return;
     }
+    if (aVisitor.mEvent->mFlags.mOnlySystemGroupDispatch &&
+        !aVisitor.mEvent->mFlags.mInSystemGroup) {
+      return;
+    }
     if (aVisitor.mEvent->mFlags.mOnlySystemGroupDispatchInContent &&
         !aVisitor.mEvent->mFlags.mInSystemGroup && !IsCurrentTargetChrome()) {
       return;
     }
     if (!mManager) {
       if (!MayHaveListenerManager() && !aCd.MayHaveNewListenerManager()) {
         return;
       }
--- a/widget/BasicEvents.h
+++ b/widget/BasicEvents.h
@@ -126,16 +126,19 @@ struct BaseEventFlags {
   // MarkAsReservedByChrome().
   bool mIsReservedByChrome : 1;
   // If mOnlySystemGroupDispatchInContent is true, event listeners added to
   // the default group for non-chrome EventTarget won't be called.
   // Be aware, if this is true, EventDispatcher needs to check if each event
   // listener is added to chrome node, so, don't set this to true for the
   // events which are fired a lot of times like eMouseMove.
   bool mOnlySystemGroupDispatchInContent : 1;
+  // If mOnlySystemGroupDispatch is true, the event will be dispatched only to
+  // event listeners added in the system group.
+  bool mOnlySystemGroupDispatch : 1;
   // The event's action will be handled by APZ. The main thread should not
   // perform its associated action.
   bool mHandledByAPZ : 1;
   // True if the event is currently being handled by an event listener that
   // was registered as a passive listener.
   bool mInPassiveListener : 1;
   // If mComposed is true, the event fired by nodes in shadow DOM can cross the
   // boundary of shadow DOM and light DOM.