Bug 1544218 - part 4: Make remaining APZC code use mozilla::PresShell directly rather than nsIPresShell r=kats
authorMasayuki Nakano <masayuki@d-toybox.com>
Tue, 16 Apr 2019 04:33:57 +0000
changeset 469612 fe7c0d7c09e5
parent 469611 359c63f6aa5e
child 469613 fe4a28a68cfc
push id35876
push useropoprus@mozilla.com
push dateTue, 16 Apr 2019 09:47:48 +0000
treeherdermozilla-central@fe4a28a68cfc [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewerskats
bugs1544218
milestone68.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 1544218 - part 4: Make remaining APZC code use mozilla::PresShell directly rather than nsIPresShell r=kats Differential Revision: https://phabricator.services.mozilla.com/D27474
gfx/layers/apz/util/APZCCallbackHelper.cpp
gfx/layers/apz/util/APZCCallbackHelper.h
--- a/gfx/layers/apz/util/APZCCallbackHelper.cpp
+++ b/gfx/layers/apz/util/APZCCallbackHelper.cpp
@@ -246,18 +246,17 @@ static ScreenMargin ScrollFrame(nsIConte
     aContent->SetProperty(nsGkAtoms::apzCallbackTransform,
                           new CSSPoint(scrollDelta),
                           nsINode::DeleteProperty<CSSPoint>);
   }
 
   return displayPortMargins;
 }
 
-static void SetDisplayPortMargins(nsIPresShell* aPresShell,
-                                  nsIContent* aContent,
+static void SetDisplayPortMargins(PresShell* aPresShell, nsIContent* aContent,
                                   ScreenMargin aDisplayPortMargins,
                                   CSSSize aDisplayPortBase) {
   if (!aContent) {
     return;
   }
 
   bool hadDisplayPort = nsLayoutUtils::HasDisplayPort(aContent);
   nsLayoutUtils::SetDisplayPortMargins(aContent, aPresShell,
@@ -377,17 +376,17 @@ bool APZCCallbackHelper::GetOrCreateScro
   *aViewIdOut = nsLayoutUtils::FindOrCreateIDFor(aContent);
   if (PresShell* presShell = GetPresShell(aContent)) {
     *aPresShellIdOut = presShell->GetPresShellId();
     return true;
   }
   return false;
 }
 
-void APZCCallbackHelper::InitializeRootDisplayport(nsIPresShell* aPresShell) {
+void APZCCallbackHelper::InitializeRootDisplayport(PresShell* aPresShell) {
   // Create a view-id and set a zero-margin displayport for the root element
   // of the root document in the chrome process. This ensures that the scroll
   // frame for this element gets an APZC, which in turn ensures that all content
   // in the chrome processes is covered by an APZC.
   // The displayport is zero-margin because this element is generally not
   // actually scrollable (if it is, APZC will set proper margins when it's
   // scrolled).
   if (!aPresShell) {
@@ -451,17 +450,17 @@ PresShell* APZCCallbackHelper::GetRootCo
   }
   context = context->GetToplevelContentDocumentPresContext();
   if (!context) {
     return nullptr;
   }
   return context->PresShell();
 }
 
-static nsIPresShell* GetRootDocumentPresShell(nsIContent* aContent) {
+static PresShell* GetRootDocumentPresShell(nsIContent* aContent) {
   dom::Document* doc = aContent->GetComposedDoc();
   if (!doc) {
     return nullptr;
   }
   PresShell* presShell = doc->GetPresShell();
   if (!presShell) {
     return nullptr;
   }
@@ -487,18 +486,18 @@ CSSPoint APZCCallbackHelper::ApplyCallba
     return input;
   }
 
   // First, scale inversely by the root content document's pres shell
   // resolution to cancel the scale-to-resolution transform that the
   // compositor adds to the layer with the pres shell resolution. The points
   // sent to Gecko by APZ don't have this transform unapplied (unlike other
   // compositor-side transforms) because APZ doesn't know about it.
-  if (nsIPresShell* shell = GetRootDocumentPresShell(content)) {
-    input = input / shell->GetResolution();
+  if (PresShell* presShell = GetRootDocumentPresShell(content)) {
+    input = input / presShell->GetResolution();
   }
 
   // This represents any resolution on the Root Content Document (RCD)
   // that's not on the Root Document (RD). That is, on platforms where
   // RCD == RD, it's 1, and on platforms where RCD != RD, it's the RCD
   // resolution. 'input' has this resolution applied, but the scroll
   // delta retrieved below do not, so we need to apply them to the
   // delta before adding the delta to 'input'. (Technically, deltas
@@ -625,19 +624,19 @@ static dom::Element* GetDisplayportEleme
   MOZ_ASSERT(content->IsElement());  // roc says this must be true
   return content->AsElement();
 }
 
 static dom::Element* GetRootDocumentElementFor(nsIWidget* aWidget) {
   // This returns the root element that ChromeProcessController sets the
   // displayport on during initialization.
   if (nsView* view = nsView::GetViewFor(aWidget)) {
-    if (nsIPresShell* shell = view->GetPresShell()) {
-      MOZ_ASSERT(shell->GetDocument());
-      return shell->GetDocument()->GetDocumentElement();
+    if (PresShell* presShell = view->GetPresShell()) {
+      MOZ_ASSERT(presShell->GetDocument());
+      return presShell->GetDocument()->GetDocumentElement();
     }
   }
   return nullptr;
 }
 
 static nsIFrame* UpdateRootFrameForTouchTargetDocument(nsIFrame* aRootFrame) {
 #if defined(MOZ_WIDGET_ANDROID)
   // Re-target so that the hit test is performed relative to the frame for the
@@ -738,19 +737,19 @@ static bool PrepareForSetTargetAPZCNotif
   nsIFrame* frame = do_QueryFrame(scrollAncestor);
   nsLayoutUtils::SetZeroMarginDisplayPortOnAsyncScrollableAncestors(
       frame, nsLayoutUtils::RepaintMode::Repaint);
 
   return true;
 }
 
 static void SendLayersDependentApzcTargetConfirmation(
-    nsIPresShell* aShell, uint64_t aInputBlockId,
+    PresShell* aPresShell, uint64_t aInputBlockId,
     const nsTArray<SLGuidAndRenderRoot>& aTargets) {
-  LayerManager* lm = aShell->GetLayerManager();
+  LayerManager* lm = aPresShell->GetLayerManager();
   if (!lm) {
     return;
   }
 
   if (WebRenderLayerManager* wrlm = lm->AsWebRenderLayerManager()) {
     if (WebRenderBridgeChild* wrbc = wrlm->WrBridge()) {
       wrbc->SendSetConfirmedTargetAPZC(aInputBlockId, aTargets);
     }
@@ -768,17 +767,17 @@ static void SendLayersDependentApzcTarge
   }
 
   shadow->SendSetConfirmedTargetAPZC(aInputBlockId, aTargets);
 }
 
 }  // namespace
 
 DisplayportSetListener::DisplayportSetListener(
-    nsIWidget* aWidget, nsIPresShell* aPresShell, const uint64_t& aInputBlockId,
+    nsIWidget* aWidget, PresShell* aPresShell, const uint64_t& aInputBlockId,
     const nsTArray<SLGuidAndRenderRoot>& aTargets)
     : mWidget(aWidget),
       mPresShell(aPresShell),
       mInputBlockId(aInputBlockId),
       mTargets(aTargets) {}
 
 DisplayportSetListener::~DisplayportSetListener() {}
 
@@ -908,26 +907,26 @@ void APZCCallbackHelper::NotifyMozMouseS
   if (!ownerDoc) {
     return;
   }
 
   nsContentUtils::DispatchTrustedEvent(ownerDoc, targetContent, aEvent,
                                        CanBubble::eYes, Cancelable::eYes);
 }
 
-void APZCCallbackHelper::NotifyFlushComplete(nsIPresShell* aShell) {
+void APZCCallbackHelper::NotifyFlushComplete(PresShell* aPresShell) {
   MOZ_ASSERT(NS_IsMainThread());
   // In some cases, flushing the APZ state to the main thread doesn't actually
   // trigger a flush and repaint (this is an intentional optimization - the
   // stuff visible to the user is still correct). However, reftests update their
   // snapshot based on invalidation events that are emitted during paints,
   // so we ensure that we kick off a paint when an APZ flush is done. Note that
   // only chrome/testing code can trigger this behaviour.
-  if (aShell && aShell->GetRootFrame()) {
-    aShell->GetRootFrame()->SchedulePaint(nsIFrame::PAINT_DEFAULT, false);
+  if (aPresShell && aPresShell->GetRootFrame()) {
+    aPresShell->GetRootFrame()->SchedulePaint(nsIFrame::PAINT_DEFAULT, false);
   }
 
   nsCOMPtr<nsIObserverService> observerService =
       mozilla::services::GetObserverService();
   MOZ_ASSERT(observerService);
   observerService->NotifyObservers(nullptr, "apz-repaints-flushed", nullptr);
 }
 
--- a/gfx/layers/apz/util/APZCCallbackHelper.h
+++ b/gfx/layers/apz/util/APZCCallbackHelper.h
@@ -13,17 +13,16 @@
 #include "mozilla/layers/MatrixMessage.h"
 #include "mozilla/layers/RepaintRequest.h"
 #include "nsIDOMWindowUtils.h"
 #include "nsRefreshDriver.h"
 
 #include <functional>
 
 class nsIContent;
-class nsIPresShell;
 class nsIScrollableFrame;
 class nsIWidget;
 template <class T>
 struct already_AddRefed;
 template <class T>
 class nsCOMPtr;
 
 namespace mozilla {
@@ -33,26 +32,26 @@ class PresShell;
 namespace layers {
 
 typedef std::function<void(uint64_t, const nsTArray<TouchBehaviorFlags>&)>
     SetAllowedTouchBehaviorCallback;
 
 /* Refer to documentation on SendSetTargetAPZCNotification for this class */
 class DisplayportSetListener : public nsAPostRefreshObserver {
  public:
-  DisplayportSetListener(nsIWidget* aWidget, nsIPresShell* aPresShell,
+  DisplayportSetListener(nsIWidget* aWidget, PresShell* aPresShell,
                          const uint64_t& aInputBlockId,
                          const nsTArray<SLGuidAndRenderRoot>& aTargets);
   virtual ~DisplayportSetListener();
   bool Register();
   void DidRefresh() override;
 
  private:
   RefPtr<nsIWidget> mWidget;
-  RefPtr<nsIPresShell> mPresShell;
+  RefPtr<PresShell> mPresShell;
   uint64_t mInputBlockId;
   nsTArray<SLGuidAndRenderRoot> mTargets;
 };
 
 /* This class contains some helper methods that facilitate implementing the
    GeckoContentController callback interface required by the
    AsyncPanZoomController. Since different platforms need to implement this
    interface in similar-but- not-quite-the-same ways, this utility class
@@ -84,17 +83,17 @@ class APZCCallbackHelper {
    * The pres shell ID should generally already exist; if it doesn't for some
    * reason, false is returned. */
   static bool GetOrCreateScrollIdentifiers(
       nsIContent* aContent, uint32_t* aPresShellIdOut,
       ScrollableLayerGuid::ViewID* aViewIdOut);
 
   /* Initialize a zero-margin displayport on the root document element of the
      given presShell. */
-  static void InitializeRootDisplayport(nsIPresShell* aPresShell);
+  static void InitializeRootDisplayport(PresShell* aPresShell);
 
   /* Get the pres context associated with the document enclosing |aContent|. */
   static nsPresContext* GetPresContextForContent(nsIContent* aContent);
 
   /* Get the pres shell associated with the root content document enclosing
    * |aContent|. */
   static PresShell* GetRootContentDocumentPresShellForContent(
       nsIContent* aContent);
@@ -178,17 +177,17 @@ class APZCCallbackHelper {
       const WidgetTouchEvent& aEvent, uint64_t aInputBlockId,
       const SetAllowedTouchBehaviorCallback& aCallback);
 
   /* Notify content of a mouse scroll testing event. */
   static void NotifyMozMouseScrollEvent(
       const ScrollableLayerGuid::ViewID& aScrollId, const nsString& aEvent);
 
   /* Notify content that the repaint flush is complete. */
-  static void NotifyFlushComplete(nsIPresShell* aShell);
+  static void NotifyFlushComplete(PresShell* aPresShell);
 
   static void NotifyAsyncScrollbarDragInitiated(
       uint64_t aDragBlockId, const ScrollableLayerGuid::ViewID& aScrollId,
       ScrollDirection aDirection);
   static void NotifyAsyncScrollbarDragRejected(
       const ScrollableLayerGuid::ViewID& aScrollId);
   static void NotifyAsyncAutoscrollRejected(
       const ScrollableLayerGuid::ViewID& aScrollId);