Bug 1533617 part 1. Improve MOZ_CAN_RUN_SCRIPT annotations around synth mouse events. r=emilio
authorBoris Zbarsky <bzbarsky@mit.edu>
Mon, 11 Mar 2019 14:58:04 +0000
changeset 521384 7aefe7888eab
parent 521383 e37e74e923b9
child 521385 dc5ced18861d
push id10866
push usernerli@mozilla.com
push dateTue, 12 Mar 2019 18:59:09 +0000
treeherdermozilla-beta@445c24a51727 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersemilio
bugs1533617
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 1533617 part 1. Improve MOZ_CAN_RUN_SCRIPT annotations around synth mouse events. r=emilio Differential Revision: https://phabricator.services.mozilla.com/D22835
dom/base/nsDOMWindowUtils.h
layout/base/PresShell.cpp
layout/base/PresShell.h
layout/base/nsIPresShell.h
layout/base/nsRefreshDriver.h
view/nsView.h
view/nsViewManager.h
--- a/dom/base/nsDOMWindowUtils.h
+++ b/dom/base/nsDOMWindowUtils.h
@@ -87,16 +87,17 @@ class nsDOMWindowUtils final : public ns
   MOZ_CAN_RUN_SCRIPT_BOUNDARY
   NS_IMETHOD SendMouseEventCommon(
       const nsAString& aType, float aX, float aY, int32_t aButton,
       int32_t aClickCount, int32_t aModifiers, bool aIgnoreRootScrollFrame,
       float aPressure, unsigned short aInputSourceArg, uint32_t aIdentifier,
       bool aToWindow, bool* aPreventDefault, bool aIsDOMEventSynthesized,
       bool aIsWidgetEventSynthesized, int32_t aButtons);
 
+  MOZ_CAN_RUN_SCRIPT_BOUNDARY
   NS_IMETHOD SendTouchEventCommon(const nsAString& aType,
                                   uint32_t* aIdentifiers, int32_t* aXs,
                                   int32_t* aYs, uint32_t* aRxs, uint32_t* aRys,
                                   float* aRotationAngles, float* aForces,
                                   uint32_t aCount, int32_t aModifiers,
                                   bool aIgnoreRootScrollFrame, bool aToWindow,
                                   bool* aPreventDefault);
 };
--- a/layout/base/PresShell.cpp
+++ b/layout/base/PresShell.cpp
@@ -3669,17 +3669,18 @@ void PresShell::ScheduleViewManagerFlush
 }
 
 void nsIPresShell::DispatchSynthMouseMove(WidgetGUIEvent* aEvent) {
   AUTO_PROFILER_TRACING_DOCSHELL("Paint", "DispatchSynthMouseMove", GRAPHICS,
                                  mPresContext->GetDocShell());
   nsEventStatus status = nsEventStatus_eIgnore;
   nsView* targetView = nsView::GetViewFor(aEvent->mWidget);
   if (!targetView) return;
-  targetView->GetViewManager()->DispatchEvent(aEvent, targetView, &status);
+  RefPtr<nsViewManager> viewManager = targetView->GetViewManager();
+  viewManager->DispatchEvent(aEvent, targetView, &status);
 }
 
 void PresShell::ClearMouseCaptureOnView(nsView* aView) {
   if (gCaptureInfo.mContent) {
     if (aView) {
       // if a view was specified, ensure that the captured content is within
       // this view.
       nsIFrame* frame = gCaptureInfo.mContent->GetPrimaryFrame();
--- a/layout/base/PresShell.h
+++ b/layout/base/PresShell.h
@@ -470,28 +470,29 @@ class PresShell final : public nsIPresSh
 
     void Revoke() {
       if (mPresShell) {
         mPresShell->GetPresContext()->RefreshDriver()->RemoveRefreshObserver(
             this, FlushType::Display);
         mPresShell = nullptr;
       }
     }
+    MOZ_CAN_RUN_SCRIPT
     void WillRefresh(TimeStamp aTime) override {
       if (mPresShell) {
         RefPtr<PresShell> shell = mPresShell;
         shell->ProcessSynthMouseMoveEvent(mFromScroll);
       }
     }
 
    private:
     PresShell* mPresShell;
     bool mFromScroll;
   };
-  void ProcessSynthMouseMoveEvent(bool aFromScroll);
+  MOZ_CAN_RUN_SCRIPT void ProcessSynthMouseMoveEvent(bool aFromScroll);
 
   void QueryIsActive();
   nsresult UpdateImageLockingState();
 
   already_AddRefed<nsIPresShell> GetParentPresShellForEventHandling();
 
   /**
    * EventHandler is implementation of nsIPresShell::HandleEvent().
--- a/layout/base/nsIPresShell.h
+++ b/layout/base/nsIPresShell.h
@@ -1446,16 +1446,17 @@ class nsIPresShell : public nsStubDocume
     PAINT_LAYERS = 0x01,
     /* Composite layers to the window. */
     PAINT_COMPOSITE = 0x02,
     /* Sync-decode images. */
     PAINT_SYNC_DECODE_IMAGES = 0x04
   };
   virtual void Paint(nsView* aViewToPaint, const nsRegion& aDirtyRegion,
                      uint32_t aFlags) = 0;
+  MOZ_CAN_RUN_SCRIPT
   virtual nsresult HandleEvent(nsIFrame* aFrame,
                                mozilla::WidgetGUIEvent* aEvent,
                                bool aDontRetargetEvents,
                                nsEventStatus* aEventStatus) = 0;
   virtual bool ShouldIgnoreInvalidation() = 0;
   /**
    * Notify that we're going to call Paint with PAINT_LAYERS
    * on the pres shell for a widget (which might not be this one, since
@@ -1484,16 +1485,17 @@ class nsIPresShell : public nsStubDocume
    * @param aType PAINT_DELAYED_COMPRESS : Schedule a paint to be executed after
    * a delay, and put FrameLayerBuilder in 'compressed' mode that avoids short
    * cut optimizations.
    */
   enum PaintType { PAINT_DEFAULT, PAINT_DELAYED_COMPRESS };
   virtual void ScheduleViewManagerFlush(PaintType aType = PAINT_DEFAULT) = 0;
   virtual void ClearMouseCaptureOnView(nsView* aView) = 0;
   virtual bool IsVisible() = 0;
+  MOZ_CAN_RUN_SCRIPT
   void DispatchSynthMouseMove(mozilla::WidgetGUIEvent* aEvent);
 
   /* Temporarily ignore the Displayport for better paint performance. We
    * trigger a repaint once suppression is disabled. Without that
    * the displayport may get left at the suppressed size for an extended
    * period of time and result in unnecessary checkerboarding (see bug
    * 1255054). */
   virtual void SuppressDisplayport(bool aEnabled) = 0;
--- a/layout/base/nsRefreshDriver.h
+++ b/layout/base/nsRefreshDriver.h
@@ -61,17 +61,17 @@ class nsARefreshObserver {
   // AddRef and Release signatures that match nsISupports.  Implementors
   // must implement reference counting, and those that do implement
   // nsISupports will already have methods with the correct signature.
   //
   // The refresh driver does NOT hold references to refresh observers
   // except while it is notifying them.
   NS_INLINE_DECL_PURE_VIRTUAL_REFCOUNTING
 
-  virtual void WillRefresh(mozilla::TimeStamp aTime) = 0;
+  MOZ_CAN_RUN_SCRIPT virtual void WillRefresh(mozilla::TimeStamp aTime) = 0;
 };
 
 /**
  * An abstract base class to be implemented by callers wanting to be notified
  * when the observing refresh driver updated mMostRecentRefresh due to active
  * timer changes. Callers must ensure an observer is removed before it is
  * destroyed.
  */
@@ -442,16 +442,17 @@ class nsRefreshDriver final : public moz
     RequestTable mEntries;
   };
   typedef nsClassHashtable<nsUint32HashKey, ImageStartData> ImageStartTable;
 
   void RunFullscreenSteps();
   void DispatchAnimationEvents();
   void RunFrameRequestCallbacks(mozilla::TimeStamp aNowTime);
   void UpdateIntersectionObservations();
+  MOZ_CAN_RUN_SCRIPT_BOUNDARY
   void Tick(mozilla::VsyncId aId, mozilla::TimeStamp aNowTime);
 
   enum EnsureTimerStartedFlags {
     eNone = 0,
     eForceAdjustTimer = 1 << 0,
     eAllowTimeToGoBackwards = 1 << 1,
     eNeverAdjustTimer = 1 << 2,
   };
--- a/view/nsView.h
+++ b/view/nsView.h
@@ -10,16 +10,17 @@
 #include "nsRect.h"
 #include "nsPoint.h"
 #include "nsRegion.h"
 #include "nsCRT.h"
 #include "nsCOMPtr.h"
 #include "nsWidgetInitData.h"  // for nsWindowType
 #include "nsIWidgetListener.h"
 #include "Units.h"
+#include "mozilla/Attributes.h"
 #include "mozilla/EventForwards.h"
 
 class nsViewManager;
 class nsIWidget;
 class nsIFrame;
 
 // Enumerated type to indicate the visibility of a layer.
 // hide - the layer is not shown.
@@ -389,16 +390,17 @@ class nsView final : public nsIWidgetLis
                            LayoutDeviceIntRegion aRegion) override;
   virtual void DidPaintWindow() override;
   virtual void DidCompositeWindow(
       mozilla::layers::TransactionId aTransactionId,
       const mozilla::TimeStamp& aCompositeStart,
       const mozilla::TimeStamp& aCompositeEnd) override;
   virtual void RequestRepaint() override;
   virtual bool ShouldNotBeVisible() override;
+  MOZ_CAN_RUN_SCRIPT_BOUNDARY
   virtual nsEventStatus HandleEvent(mozilla::WidgetGUIEvent* aEvent,
                                     bool aUseAttachedEvents) override;
 
   virtual ~nsView();
 
   nsPoint GetOffsetTo(const nsView* aOther, const int32_t aAPD) const;
   nsIWidget* GetNearestWidget(nsPoint* aOffset, const int32_t aAPD) const;
 
--- a/view/nsViewManager.h
+++ b/view/nsViewManager.h
@@ -8,16 +8,17 @@
 
 #include "nscore.h"
 #include "nsView.h"
 #include "nsCOMPtr.h"
 #include "nsCRT.h"
 #include "nsTArray.h"
 #include "nsDeviceContext.h"
 #include "nsTArray.h"
+#include "mozilla/Attributes.h"
 #include "mozilla/EventForwards.h"
 
 class nsIWidget;
 struct nsRect;
 class nsRegion;
 class nsDeviceContext;
 class nsIPresShell;
 
@@ -120,16 +121,17 @@ class nsViewManager final {
   /**
    * Called to dispatch an event to the appropriate view. Often called
    * as a result of receiving a mouse or keyboard event from the widget
    * event system.
    * @param aEvent event to dispatch
    * @param aViewTarget dispatch the event to this view
    * @param aStatus event handling status
    */
+  MOZ_CAN_RUN_SCRIPT
   void DispatchEvent(mozilla::WidgetGUIEvent* aEvent, nsView* aViewTarget,
                      nsEventStatus* aStatus);
 
   /**
    * Given a parent view, insert another view as its child.
    * aSibling and aAbove control the "document order" for the insertion.
    * If aSibling is null, the view is inserted at the end of the document order
    * if aAfter is true, otherwise it is inserted at the beginning.