Bug 1466208 - part 45: Rename `aFrame` of `HandleEvent()` to `aFrameForPresShell` r=smaug
authorMasayuki Nakano <masayuki@d-toybox.com>
Wed, 13 Mar 2019 10:32:36 +0000
changeset 521698 4be0480f48d3
parent 521697 3a8323264398
child 521699 17c3b29f3b07
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 45: Rename `aFrame` of `HandleEvent()` to `aFrameForPresShell` r=smaug Now, other methods taking `aFrame` of `HandleEvent()` names the argument as `aFrameForPresShell`. So, `HandleEvent()`'s `aFrame` should also be renamed. This patch renames it and adds MOZ_CAN_RUN_SCRIPT and comment to `nsIPresShell::HandleEvent()`. This is the final patch for bug 1466208. Differential Revision: https://phabricator.services.mozilla.com/D22463
layout/base/PresShell.cpp
layout/base/PresShell.h
--- a/layout/base/PresShell.cpp
+++ b/layout/base/PresShell.cpp
@@ -6434,26 +6434,27 @@ PresShell* PresShell::GetShellForTouchEv
       break;
     }
     default:
       break;
   }
   return shell;
 }
 
-nsresult PresShell::HandleEvent(nsIFrame* aFrame, WidgetGUIEvent* aGUIEvent,
+nsresult PresShell::HandleEvent(nsIFrame* aFrameForPresShell,
+                                WidgetGUIEvent* aGUIEvent,
                                 bool aDontRetargetEvents,
                                 nsEventStatus* aEventStatus) {
   MOZ_ASSERT(aGUIEvent);
   EventHandler eventHandler(*this);
-  return eventHandler.HandleEvent(aFrame, aGUIEvent, aDontRetargetEvents,
-                                  aEventStatus);
-}
-
-nsresult PresShell::EventHandler::HandleEvent(nsIFrame* aFrame,
+  return eventHandler.HandleEvent(aFrameForPresShell, aGUIEvent,
+                                  aDontRetargetEvents, aEventStatus);
+}
+
+nsresult PresShell::EventHandler::HandleEvent(nsIFrame* aFrameForPresShell,
                                               WidgetGUIEvent* aGUIEvent,
                                               bool aDontRetargetEvents,
                                               nsEventStatus* aEventStatus) {
   MOZ_ASSERT(aEventStatus);
 
 #ifdef MOZ_TASK_TRACER
   Maybe<AutoSourceEvent> taskTracerEvent;
   if (MOZ_UNLIKELY(IsStartLogging())) {
@@ -6467,17 +6468,17 @@ nsresult PresShell::EventHandler::Handle
       type = SourceEventType::Mouse;
     } else if (aGUIEvent->AsKeyboardEvent()) {
       type = SourceEventType::Key;
     }
     taskTracerEvent.emplace(type);
   }
 #endif
 
-  NS_ASSERTION(aFrame, "aFrame should be not null");
+  NS_ASSERTION(aFrameForPresShell, "aFrameForPresShell should be not null");
 
   // Update the latest focus sequence number with this new sequence number;
   // the next transasction that gets sent to the compositor will carry this over
   if (mPresShell->mAPZFocusSequenceNumber < aGUIEvent->mFocusSequenceNumber) {
     mPresShell->mAPZFocusSequenceNumber = aGUIEvent->mFocusSequenceNumber;
   }
 
   if (mPresShell->IsDestroying() ||
@@ -6498,36 +6499,36 @@ nsresult PresShell::EventHandler::Handle
     // Nobody cannot handle the event for now.
     return NS_OK;
   }
 
   if (!aDontRetargetEvents) {
     // If aGUIEvent should be handled in another PresShell, we should call its
     // HandleEvent() and do nothing here.
     nsresult rv = NS_OK;
-    if (MaybeHandleEventWithAnotherPresShell(aFrame, aGUIEvent, aEventStatus,
-                                             &rv)) {
+    if (MaybeHandleEventWithAnotherPresShell(aFrameForPresShell, aGUIEvent,
+                                             aEventStatus, &rv)) {
       // Handled by another PresShell or nobody can handle the event.
       return rv;
     }
   }
 
   if (MaybeDiscardOrDelayKeyboardEvent(aGUIEvent)) {
     // The event is discarded or put into the delayed event queue.
     return NS_OK;
   }
 
   if (aGUIEvent->IsUsingCoordinates()) {
-    return HandleEventUsingCoordinates(aFrame, aGUIEvent, aEventStatus,
-                                       aDontRetargetEvents);
+    return HandleEventUsingCoordinates(aFrameForPresShell, aGUIEvent,
+                                       aEventStatus, aDontRetargetEvents);
   }
 
   // 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 (!aFrameForPresShell) {
     if (!NS_EVENT_NEEDS_FRAME(aGUIEvent)) {
       mPresShell->mCurrentEventFrame = nullptr;
       // XXX Shouldn't we create AutoCurrentEventInfoSetter instance for this
       //     call even if we set the target to nullptr.
       return HandleEventWithCurrentEventInfo(aGUIEvent, aEventStatus, true, nullptr);
     }
 
     if (aGUIEvent->HasKeyEventMessage()) {
@@ -6538,17 +6539,18 @@ nsresult PresShell::EventHandler::Handle
 
     return NS_OK;
   }
 
   if (aGUIEvent->IsTargetedAtFocusedContent()) {
     return HandleEventAtFocusedContent(aGUIEvent, aEventStatus);
   }
 
-  return HandleEventWithFrameForPresShell(aFrame, aGUIEvent, aEventStatus);
+  return HandleEventWithFrameForPresShell(aFrameForPresShell, aGUIEvent,
+                                          aEventStatus);
 }
 
 nsresult PresShell::EventHandler::HandleEventUsingCoordinates(
     nsIFrame* aFrameForPresShell, WidgetGUIEvent* aGUIEvent,
     nsEventStatus* aEventStatus, bool aDontRetargetEvents) {
   MOZ_ASSERT(aGUIEvent);
   MOZ_ASSERT(aGUIEvent->IsUsingCoordinates());
   MOZ_ASSERT(aEventStatus);
--- a/layout/base/PresShell.h
+++ b/layout/base/PresShell.h
@@ -173,17 +173,17 @@ class PresShell final : public nsIPresSh
   float GetCumulativeNonRootScaleResolution() override;
   void SetRestoreResolution(float aResolution,
                             LayoutDeviceIntSize aDisplaySize) override;
 
   // nsIViewObserver interface
 
   void Paint(nsView* aViewToPaint, const nsRegion& aDirtyRegion,
              uint32_t aFlags) override;
-  MOZ_CAN_RUN_SCRIPT nsresult HandleEvent(nsIFrame* aFrame,
+  MOZ_CAN_RUN_SCRIPT nsresult HandleEvent(nsIFrame* aFrameForPresShell,
                                           WidgetGUIEvent* aEvent,
                                           bool aDontRetargetEvents,
                                           nsEventStatus* aEventStatus) override;
   nsresult HandleDOMEventWithTarget(nsIContent* aTargetContent,
                                     WidgetEvent* aEvent,
                                     nsEventStatus* aStatus) override;
   nsresult HandleDOMEventWithTarget(nsIContent* aTargetContent,
                                     dom::Event* aEvent,
@@ -508,29 +508,33 @@ class PresShell final : public nsIPresSh
 
     /**
      * 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.  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 aFrameForPresShell        The frame for PresShell.  If PresShell
+     *                                  has root frame, it should be set.
+     *                                  Otherwise, a frame which contains the
+     *                                  PresShell should be set instead.  I.e.,
+     *                                  in the latter case, the frame is in
+     *                                  a parent document.
      * @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
      *                                  different PresShell.
      * @param aEventStatus              [in/out] EventStatus of aGUIEvent.
      */
     MOZ_CAN_RUN_SCRIPT
-    nsresult HandleEvent(nsIFrame* aFrame, WidgetGUIEvent* aGUIEvent,
-                         bool aDontRetargetEvents, nsEventStatus* aEventStatus);
+    nsresult HandleEvent(nsIFrame* aFrameForPresShell,
+                         WidgetGUIEvent* aGUIEvent, bool aDontRetargetEvents,
+                         nsEventStatus* aEventStatus);
 
     /**
      * HandleEventWithTarget() tries to dispatch aEvent on aContent after
      * setting current event target content to aNewEventContent and current
      * event frame to aNewEventFrame temporarily.  Note that this supports
      * WidgetEvent, not WidgetGUIEvent.  So, you can dispatch a simple event
      * with this.
      *
@@ -573,17 +577,19 @@ class PresShell final : public nsIPresSh
         nsIPresShell* aPresShell);
     static already_AddRefed<nsIURI> GetDocumentURIToCompareWithBlacklist(
         PresShell& aPresShell);
 
     /**
      * HandleEventUsingCoordinates() handles aGUIEvent whose
      * IsUsingCoordinates() returns true with the following helper methods.
      *
-     * @param aFrameForPresShell        The frame for mPresShell.
+     * @param aFrameForPresShell        The frame for PresShell.  See
+     *                                  explanation of HandleEvent() for the
+     *                                  details.
      * @param aGUIEvent                 The handling event.  Make sure that
      *                                  its IsUsingCoordinates() returns true.
      * @param aEventStatus              The status of aGUIEvent.
      * @param aDontRetargetEvents       true if we've already retarget document.
      *                                  Otherwise, false.
      */
     MOZ_CAN_RUN_SCRIPT
     nsresult HandleEventUsingCoordinates(nsIFrame* aFrameForPresShell,
@@ -704,18 +710,19 @@ class PresShell final : public nsIPresSh
     bool ComputeEventTargetFrameAndPresShellAtEventPoint(
         nsIFrame* aRootFrameToHandleEvent, WidgetGUIEvent* aGUIEvent,
         EventTargetData* aEventTargetData);
 
     /**
      * DispatchPrecedingPointerEvent() dispatches preceding pointer event for
      * aGUIEvent if Pointer Events is enabled.
      *
-     * @param aFrameForPresShell        Set aFrame of HandleEvent() which
-     *                                  called this method.
+     * @param aFrameForPresShell        The frame for PresShell.  See
+     *                                  explanation of HandleEvent() for the
+     *                                  details.
      * @param aGUIEvent                 The handled event.
      * @param aPointerCapturingContent  The content which is capturing pointer
      *                                  events if there is.  Otherwise, nullptr.
      * @param aDontRetargetEvents       Set aDontRetargetEvents of
      *                                  HandleEvent() which called this method.
      * @param aEventTargetData          [in/out] Event target data of
      *                                  aGUIEvent.  If pointer event listeners
      *                                  change the DOM tree or reframe the
@@ -757,44 +764,44 @@ class PresShell final : public nsIPresSh
      * @return                          true if caller can keep handling
      *                                  aGUIEvent.
      */
     bool GetRetargetEventDocument(WidgetGUIEvent* aGUIEvent,
                                   Document** aRetargetEventDocument);
 
     /**
      * GetFrameForHandlingEventWith() returns a frame which should be used as
-     * aFrame of HandleEvent().  See @return for the detail.
+     * aFrameForPresShell of HandleEvent().  See @return for the details.
      *
      * @param aGUIEvent                 Handling event.
      * @param aRetargetDocument         Document which aGUIEvent should be
      *                                  fired on.  Typically, should be result
      *                                  of GetRetargetEventDocument().
-     * @param aFrameForPresShell        The frame if we need to handle the
-     *                                  event with current instance.  I.e.,
-     *                                  typically, caller sets aFrame of
-     *                                  HandleEvent().
+     * @param aFrameForPresShell        The frame for PresShell.  See
+     *                                  explanation of HandleEvent() for the
+     *                                  details.
      * @return                          nullptr if caller should stop handling
      *                                  the event.
      *                                  aFrameForPresShell if caller should
      *                                  keep handling the event by itself.
      *                                  Otherwise, caller should handle it with
      *                                  another PresShell which is result of
      *                                  nsIFrame::PresContext()->GetPresShell().
      */
     nsIFrame* GetFrameForHandlingEventWith(WidgetGUIEvent* aGUIEvent,
                                            Document* aRetargetDocument,
                                            nsIFrame* aFrameForPresShell);
 
     /**
      * MaybeHandleEventWithAnotherPresShell() may handle aGUIEvent with another
      * PresShell.
      *
-     * @param aFrameForPresShell        Set aFrame of HandleEvent() which called
-     *                                  this method.
+     * @param aFrameForPresShell        The frame for PresShell.  See
+     *                                  explanation of HandleEvent() for the
+     *                                  details.
      * @param aGUIEvent                 Handling event.
      * @param aEventStatus              [in/out] EventStatus of aGUIEvent.
      * @param aRv                       [out] Returns error if this gets an
      *                                  error handling the event.
      * @return                          false if caller needs to keep handling
      *                                  the event by itself.
      *                                  true if caller shouldn't keep handling
      *                                  the event.  Note that when no PresShell
@@ -850,33 +857,36 @@ class PresShell final : public nsIPresSh
     bool MaybeDiscardOrDelayMouseEvent(nsIFrame* aFrameToHandleEvent,
                                        WidgetGUIEvent* aGUIEvent);
 
     /**
      * MaybeFlushThrottledStyles() tries to flush pending animation.  If it's
      * flushed and then aFrameForPresShell is destroyed, returns new frame
      * which contains mPresShell.
      *
-     * @param aFrameForPresShell        The frame for mPresShell.  This can be
-     *                                  nullptr.
+     * @param aFrameForPresShell        The frame for PresShell.  See
+     *                                  explanation of HandleEvent() for the
+     *                                  details.  This can be nullptr.
      * @return                          Maybe new frame for mPresShell.
      *                                  If aFrameForPresShell is not nullptr
      *                                  and hasn't been destroyed, returns
      *                                  aFrameForPresShell as-is.
      */
     MOZ_CAN_RUN_SCRIPT
     nsIFrame* MaybeFlushThrottledStyles(nsIFrame* aFrameForPresShell);
 
     /**
      * ComputeRootFrameToHandleEvent() returns root frame to handle the event.
      * For example, if there is a popup, this returns the popup frame.
      * If there is capturing content and it's in a scrolled frame, returns
      * the scrolled frame.
      *
-     * @param aFrameForPresShell                The frame for mPresShell.
+     * @param aFrameForPresShell                The frame for PresShell.  See
+     *                                          explanation of HandleEvent() for
+     *                                          the details.
      * @param aGUIEvent                         The handling event.
      * @param aCapturingContent                 Capturing content if there is.
      *                                          nullptr, otherwise.
      * @param aIsCapturingContentIgnored        [out] true if aCapturingContent
      *                                          is not nullptr but it should be
      *                                          ignored to handle the event.
      * @param aIsCaptureRetargeted              [out] true if aCapturingContent
      *                                          is not nullptr but it's
@@ -937,18 +947,19 @@ class PresShell final : public nsIPresSh
         nsIFrame* aRootFrameToHandleEvent, nsIContent* aCapturingContent,
         bool* aIsCapturingContentIgnored, bool* aIsCaptureRetargeted);
 
     /**
      * HandleEventWithPointerCapturingContentWithoutItsFrame() handles
      * aGUIEvent with aPointerCapturingContent when it does not have primary
      * frame.
      *
-     * @param aFrameForPresShell        The frame for mPresShell.  Typically,
-     *                                  aFrame of HandleEvent().
+     * @param aFrameForPresShell        The frame for PresShell.  See
+     *                                  explanation of HandleEvent() for the
+     *                                  details.
      * @param aGUIEvent                 The handling event.
      * @param aPointerCapturingContent  Current pointer capturing content.
      *                                  Must not be nullptr.
      * @param aEventStatus              [in/out] The event status of aGUIEvent.
      * @return                          Basically, result of
      *                                  HandeEventWithTraget().
      */
     MOZ_CAN_RUN_SCRIPT