Bug 1466208 - part 44: Rename PresShell::EventHandler::HandleEventInternal() to HandleEventWithCurrentEventInfo() r=smaug
authorMasayuki Nakano <masayuki@d-toybox.com>
Tue, 12 Mar 2019 04:25:13 +0000
changeset 521501 88a92eb3865e6482155111c684ba56bf73612ee3
parent 521500 d08e73bddc51022e6465f10d45dd205d4d6ecd67
child 521502 214ce4ef682ae8e113c3f5604770f05fb2fbb231
push id10867
push userdvarga@mozilla.com
push dateThu, 14 Mar 2019 15:20:45 +0000
treeherdermozilla-beta@abad13547875 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewerssmaug
bugs1466208
milestone67.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 1466208 - part 44: Rename PresShell::EventHandler::HandleEventInternal() to HandleEventWithCurrentEventInfo() r=smaug In my understanding, `PresShell::EventHandler::HandleEvent()` may redirect the event to another class or PresShell first. Otherwise, it computes event target and sets current event info of mPresShell to it. Then, calls `HandleEventInternal()` to dispatch the event. Then, `HandleEventInternal()` may handle the event before dispatch, and/or prepare to dispatch, then, finally dispatches the event and finalize the state of mPresShell and the event. Therefore, `HandleEventInternal()` actually handles the event, but the word, "internal" is not explicitly explain its different points from `HandleEvent()`. Therefore, I think that `HandleEventWithCurrentEventInfo()` is better name since `HandleEvent()` considers the current event info. Differential Revision: https://phabricator.services.mozilla.com/D22462
layout/base/PresShell.cpp
layout/base/PresShell.h
--- a/layout/base/PresShell.cpp
+++ b/layout/base/PresShell.cpp
@@ -6521,18 +6521,20 @@ nsresult PresShell::EventHandler::Handle
   }
 
   // Activation events need to be dispatched even if no frame was found, since
   // we don't want the focus to be out of sync.
   if (!aFrame) {
     if (!NS_EVENT_NEEDS_FRAME(aGUIEvent)) {
       mPresShell->mCurrentEventFrame = nullptr;
       nsCOMPtr<nsIContent> overrideClickTarget;  // Required due to bug  1506439
-      return HandleEventInternal(aGUIEvent, aEventStatus, true,
-                                 overrideClickTarget);
+      // XXX Shouldn't we create AutoCurrentEventInfoSetter instance for this
+      //     call even if we set the target to nullptr.
+      return HandleEventWithCurrentEventInfo(aGUIEvent, aEventStatus, true,
+                                             overrideClickTarget);
     }
 
     if (aGUIEvent->HasKeyEventMessage()) {
       // Keypress events in new blank tabs should not be completely thrown away.
       // Retarget them -- the parent chrome shell might make use of them.
       return RetargetEventToParent(aGUIEvent, aEventStatus);
     }
 
@@ -6702,17 +6704,17 @@ nsresult PresShell::EventHandler::Handle
 
   // Handle the event in the correct shell.
   // We pass the subshell's root frame as the frame to start from. This is
   // the only correct alternative; if the event was captured then it
   // must have been captured by us or some ancestor shell and we
   // now ask the subshell to dispatch it normally.
   EventHandler eventHandler(*eventTargetData.mPresShell);
   AutoCurrentEventInfoSetter eventInfoSetter(eventHandler, eventTargetData);
-  nsresult rv = eventHandler.HandleEventInternal(
+  nsresult rv = eventHandler.HandleEventWithCurrentEventInfo(
       aGUIEvent, aEventStatus, true, eventTargetData.mOverrideClickTarget);
 #ifdef DEBUG
   eventTargetData.mPresShell->ShowEventTargetDebug();
 #endif
   return rv;
 }
 
 bool PresShell::EventHandler::MaybeFlushPendingNotifications(
@@ -7442,18 +7444,18 @@ nsresult PresShell::EventHandler::Handle
   mPresShell->mCurrentEventContent = eventTargetElement;
   if (!mPresShell->GetCurrentEventContent() ||
       !mPresShell->GetCurrentEventFrame() ||
       InZombieDocument(mPresShell->mCurrentEventContent)) {
     return RetargetEventToParent(aGUIEvent, aEventStatus);
   }
 
   nsCOMPtr<nsIContent> overrideClickTarget;  // Required due to bug  1506439
-  nsresult rv =
-      HandleEventInternal(aGUIEvent, aEventStatus, true, overrideClickTarget);
+  nsresult rv = HandleEventWithCurrentEventInfo(aGUIEvent, aEventStatus, true,
+                                                overrideClickTarget);
 
 #ifdef DEBUG
   mPresShell->ShowEventTargetDebug();
 #endif
 
   return rv;
 }
 
@@ -7548,18 +7550,18 @@ nsresult PresShell::EventHandler::Handle
   MOZ_ASSERT(aEventStatus);
 
   AutoCurrentEventInfoSetter eventInfoSetter(*this, aFrameForPresShell,
                                              nullptr);
 
   nsresult rv = NS_OK;
   if (mPresShell->GetCurrentEventFrame()) {
     nsCOMPtr<nsIContent> overrideClickTarget;  // Required due to bug  1506439
-    rv =
-        HandleEventInternal(aGUIEvent, aEventStatus, true, overrideClickTarget);
+    rv = HandleEventWithCurrentEventInfo(aGUIEvent, aEventStatus, true,
+                                         overrideClickTarget);
   }
 
 #ifdef DEBUG
   mPresShell->ShowEventTargetDebug();
 #endif
 
   return rv;
 }
@@ -7621,22 +7623,22 @@ nsresult PresShell::EventHandler::Handle
   }
 #endif
   NS_ENSURE_STATE(!aNewEventContent ||
                   aNewEventContent->GetComposedDoc() == GetDocument());
   AutoPointerEventTargetUpdater updater(mPresShell, aEvent, aNewEventFrame,
                                         aTargetContent);
   AutoCurrentEventInfoSetter eventInfoSetter(*this, aNewEventFrame,
                                              aNewEventContent);
-  nsresult rv =
-      HandleEventInternal(aEvent, aEventStatus, false, aOverrideClickTarget);
+  nsresult rv = HandleEventWithCurrentEventInfo(aEvent, aEventStatus, false,
+                                                aOverrideClickTarget);
   return rv;
 }
 
-nsresult PresShell::EventHandler::HandleEventInternal(
+nsresult PresShell::EventHandler::HandleEventWithCurrentEventInfo(
     WidgetEvent* aEvent, nsEventStatus* aEventStatus,
     bool aIsHandlingNativeEvent, nsIContent* aOverrideClickTarget) {
   MOZ_ASSERT(aEvent);
   MOZ_ASSERT(aEventStatus);
 
   RefPtr<EventStateManager> manager = GetPresContext()->EventStateManager();
 
   // If we cannot handle the event with mPresShell because of no target,
--- a/layout/base/PresShell.h
+++ b/layout/base/PresShell.h
@@ -504,17 +504,19 @@ class PresShell final : public nsIPresSh
     explicit EventHandler(PresShell& aPresShell)
         : mPresShell(aPresShell), mCurrentEventInfoSetter(nullptr) {}
     explicit EventHandler(RefPtr<PresShell>&& aPresShell)
         : mPresShell(aPresShell.forget()), mCurrentEventInfoSetter(nullptr) {}
 
     /**
      * HandleEvent() may dispatch aGUIEvent.  This may redirect the event to
      * another PresShell, or the event may be handled by other classes like
-     * AccessibleCaretEventHub, or discarded.
+     * AccessibleCaretEventHub, or discarded.  Otherwise, this sets current
+     * event info of mPresShell and calls HandleEventWithCurrentEventInfo()
+     * to dispatch the event into the DOM tree.
      *
      * @param aFrame                    aFrame of nsIPresShell::HandleEvent().
      *                                  (Perhaps, should be root frame of
      *                                  PresShell.)
      * @param aGUIEvent                 Event to be handled.
      * @param aDontRetargetEvents       true if this shouldn't redirect the
      *                                  event to different PresShell.
      *                                  false if this can redirect the event to
@@ -1010,18 +1012,18 @@ class PresShell final : public nsIPresSh
     nsresult HandleRetargetedEvent(WidgetGUIEvent* aGUIEvent,
                                    nsEventStatus* aEventStatus,
                                    nsIContent* aTarget) {
       AutoCurrentEventInfoSetter eventInfoSetter(*this, nullptr, aTarget);
       if (!mPresShell->GetCurrentEventFrame()) {
         return NS_OK;
       }
       nsCOMPtr<nsIContent> overrideClickTarget;
-      return HandleEventInternal(aGUIEvent, aEventStatus, true,
-                                 overrideClickTarget);
+      return HandleEventWithCurrentEventInfo(aGUIEvent, aEventStatus, true,
+                                             overrideClickTarget);
     }
 
     /**
      * HandleEventWithFrameForPresShell() handles aGUIEvent with the frame
      * for mPresShell.
      *
      * @param aFrameForPresShell        The frame for mPresShell.
      * @param aGUIEvent                 The handling event.  It shouldn't be
@@ -1030,31 +1032,31 @@ class PresShell final : public nsIPresSh
      * @param aEventStatus              [in/out] The status of aGUIEvent.
      */
     MOZ_CAN_RUN_SCRIPT
     nsresult HandleEventWithFrameForPresShell(nsIFrame* aFrameForPresShell,
                                               WidgetGUIEvent* aGUIEvent,
                                               nsEventStatus* aEventStatus);
 
     /**
-     * XXX Needs better name.
-     * HandleEventInternal() dispatches aEvent into the DOM tree and
-     * notify EventStateManager of that.
+     * HandleEventWithCurrentEventInfo() prepares to dispatch aEvent into the
+     * DOM, dispatches aEvent into the DOM with using current event info of
+     * mPresShell and notifies EventStateManager of that.
      *
      * @param aEvent                    Event to be dispatched.
      * @param aEventStatus              [in/out] EventStatus of aEvent.
      * @param aIsHandlingNativeEvent    true if aGUIEvent represents a native
      *                                  event.
      * @param aOverrideClickTarget      Override click event target.
      */
     MOZ_CAN_RUN_SCRIPT
-    nsresult HandleEventInternal(WidgetEvent* aEvent,
-                                 nsEventStatus* aEventStatus,
-                                 bool aIsHandlingNativeEvent,
-                                 nsIContent* aOverrideClickTarget);
+    nsresult HandleEventWithCurrentEventInfo(WidgetEvent* aEvent,
+                                             nsEventStatus* aEventStatus,
+                                             bool aIsHandlingNativeEvent,
+                                             nsIContent* aOverrideClickTarget);
 
     /**
      * HandlingTimeAccumulator() may accumulate handling time of telemetry
      * for each type of events.
      */
     class MOZ_STACK_CLASS HandlingTimeAccumulator final {
      public:
       HandlingTimeAccumulator() = delete;