Bug 1544218 - part 2: Make APZCCallbackHelper::GetRootContentDocumentPresShellForContent() return mozilla::PresShell directly r=kats
authorMasayuki Nakano <masayuki@d-toybox.com>
Tue, 16 Apr 2019 04:33:52 +0000
changeset 469610 06908f47b337
parent 469609 2a5c7852f148
child 469611 359c63f6aa5e
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 2: Make APZCCallbackHelper::GetRootContentDocumentPresShellForContent() return mozilla::PresShell directly r=kats Differential Revision: https://phabricator.services.mozilla.com/D27472
dom/base/nsDOMWindowUtils.cpp
gfx/layers/apz/util/APZCCallbackHelper.cpp
gfx/layers/apz/util/APZCCallbackHelper.h
gfx/layers/apz/util/ChromeProcessController.cpp
layout/base/nsLayoutUtils.cpp
--- a/dom/base/nsDOMWindowUtils.cpp
+++ b/dom/base/nsDOMWindowUtils.cpp
@@ -2455,29 +2455,30 @@ nsDOMWindowUtils::ZoomToFocusedInput() {
     return NS_OK;
   }
 
   nsIContent* content = fm->GetFocusedElement();
   if (!content) {
     return NS_OK;
   }
 
-  nsIPresShell* shell =
+  RefPtr<PresShell> presShell =
       APZCCallbackHelper::GetRootContentDocumentPresShellForContent(content);
-  if (!shell) {
+  if (!presShell) {
     return NS_OK;
   }
 
-  nsIScrollableFrame* rootScrollFrame = shell->GetRootScrollFrameAsScrollable();
+  nsIScrollableFrame* rootScrollFrame =
+      presShell->GetRootScrollFrameAsScrollable();
   if (!rootScrollFrame) {
     return NS_OK;
   }
 
   nsIFrame* currentFrame = content->GetPrimaryFrame();
-  nsIFrame* rootFrame = shell->GetRootFrame();
+  nsIFrame* rootFrame = presShell->GetRootFrame();
   nsIFrame* scrolledFrame = rootScrollFrame->GetScrolledFrame();
   bool isFixedPos = true;
 
   while (currentFrame) {
     if (currentFrame == rootFrame) {
       break;
     }
     if (currentFrame == scrolledFrame) {
@@ -2490,17 +2491,17 @@ nsDOMWindowUtils::ZoomToFocusedInput() {
 
   if (isFixedPos) {
     // We didn't find the scrolledFrame in our parent frames so this content
     // must be fixed position. Zooming into fixed position content doesn't make
     // sense so just return with out panning and zooming.
     return NS_OK;
   }
 
-  Document* document = shell->GetDocument();
+  Document* document = presShell->GetDocument();
   if (!document) {
     return NS_OK;
   }
 
   uint32_t presShellId;
   ScrollableLayerGuid::ViewID viewId;
   if (APZCCallbackHelper::GetOrCreateScrollIdentifiers(
           document->GetDocumentElement(), &presShellId, &viewId)) {
@@ -2510,17 +2511,17 @@ nsDOMWindowUtils::ZoomToFocusedInput() {
     } else {
       flags |= layers::ONLY_ZOOM_TO_DEFAULT_SCALE;
     }
 
     // The content may be inside a scrollable subframe inside a non-scrollable
     // root content document. In this scenario, we want to ensure that the
     // main-thread side knows to scroll the content into view before we get
     // the bounding content rect and ask APZ to adjust the visual viewport.
-    shell->ScrollContentIntoView(
+    presShell->ScrollContentIntoView(
         content,
         nsIPresShell::ScrollAxis(nsIPresShell::SCROLL_MINIMUM,
                                  nsIPresShell::SCROLL_IF_NOT_VISIBLE),
         nsIPresShell::ScrollAxis(nsIPresShell::SCROLL_MINIMUM,
                                  nsIPresShell::SCROLL_IF_NOT_VISIBLE),
         nsIPresShell::SCROLL_OVERFLOW_HIDDEN);
 
     CSSRect bounds =
--- a/gfx/layers/apz/util/APZCCallbackHelper.cpp
+++ b/gfx/layers/apz/util/APZCCallbackHelper.cpp
@@ -332,17 +332,17 @@ void APZCCallbackHelper::UpdateRootFrame
       return;
     }
 
     // The pres shell resolution is updated by the the async zoom since the
     // last paint.
     presShellResolution =
         aRequest.GetPresShellResolution() * aRequest.GetAsyncZoom().scale;
     presShell->SetResolutionAndScaleTo(presShellResolution,
-                                   nsIPresShell::ChangeOrigin::eApz);
+                                       nsIPresShell::ChangeOrigin::eApz);
   }
 
   // Do this as late as possible since scrolling can flush layout. It also
   // adjusts the display port margins, so do it before we set those.
   ScreenMargin displayPortMargins = ScrollFrame(content, aRequest);
 
   SetDisplayPortMargins(presShell, content, displayPortMargins,
                         aRequest.CalculateCompositedSizeInCssPixels());
@@ -438,17 +438,17 @@ nsPresContext* APZCCallbackHelper::GetPr
   }
   PresShell* presShell = doc->GetPresShell();
   if (!presShell) {
     return nullptr;
   }
   return presShell->GetPresContext();
 }
 
-nsIPresShell* APZCCallbackHelper::GetRootContentDocumentPresShellForContent(
+PresShell* APZCCallbackHelper::GetRootContentDocumentPresShellForContent(
     nsIContent* aContent) {
   nsPresContext* context = GetPresContextForContent(aContent);
   if (!context) {
     return nullptr;
   }
   context = context->GetToplevelContentDocumentPresContext();
   if (!context) {
     return nullptr;
@@ -501,19 +501,19 @@ CSSPoint APZCCallbackHelper::ApplyCallba
   // 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
   // from scroll frames outside the RCD would already have this
   // resolution applied, but we don't have such scroll frames in
   // practice.)
   float nonRootResolution = 1.0f;
-  if (nsIPresShell* shell =
+  if (PresShell* presShell =
           GetRootContentDocumentPresShellForContent(content)) {
-    nonRootResolution = shell->GetCumulativeNonRootScaleResolution();
+    nonRootResolution = presShell->GetCumulativeNonRootScaleResolution();
   }
   // Now apply the callback-transform. This is only approximately correct,
   // see the comment on GetCumulativeApzCallbackTransform for details.
   CSSPoint transform = nsLayoutUtils::GetCumulativeApzCallbackTransform(
       content->GetPrimaryFrame());
   return input + transform * nonRootResolution;
 }
 
--- a/gfx/layers/apz/util/APZCCallbackHelper.h
+++ b/gfx/layers/apz/util/APZCCallbackHelper.h
@@ -91,17 +91,17 @@ class APZCCallbackHelper {
      given presShell. */
   static void InitializeRootDisplayport(nsIPresShell* 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 nsIPresShell* GetRootContentDocumentPresShellForContent(
+  static PresShell* GetRootContentDocumentPresShellForContent(
       nsIContent* aContent);
 
   /* Apply an "input transform" to the given |aInput| and return the transformed
      value. The input transform applied is the one for the content element
      corresponding to |aGuid|; this is populated in a previous call to
      UpdateCallbackTransform. See that method's documentations for details. This
      method additionally adjusts |aInput| by inversely scaling by the provided
      pres shell resolution, to cancel out a compositor-side transform (added in
--- a/gfx/layers/apz/util/ChromeProcessController.cpp
+++ b/gfx/layers/apz/util/ChromeProcessController.cpp
@@ -114,19 +114,19 @@ dom::Document* ChromeProcessController::
 }
 
 dom::Document* ChromeProcessController::GetRootContentDocument(
     const ScrollableLayerGuid::ViewID& aScrollId) const {
   nsIContent* content = nsLayoutUtils::FindContentFor(aScrollId);
   if (!content) {
     return nullptr;
   }
-  nsIPresShell* presShell =
-      APZCCallbackHelper::GetRootContentDocumentPresShellForContent(content);
-  if (presShell) {
+  if (PresShell* presShell =
+          APZCCallbackHelper::GetRootContentDocumentPresShellForContent(
+              content)) {
     return presShell->GetDocument();
   }
   return nullptr;
 }
 
 void ChromeProcessController::HandleDoubleTap(
     const mozilla::CSSPoint& aPoint, Modifiers aModifiers,
     const ScrollableLayerGuid& aGuid) {
--- a/layout/base/nsLayoutUtils.cpp
+++ b/layout/base/nsLayoutUtils.cpp
@@ -1018,23 +1018,23 @@ static bool HasVisibleAnonymousContents(
 }
 
 bool nsLayoutUtils::ShouldDisableApzForElement(nsIContent* aContent) {
   if (!aContent) {
     return false;
   }
 
   Document* doc = aContent->GetComposedDoc();
-  nsIPresShell* rootShell =
-      APZCCallbackHelper::GetRootContentDocumentPresShellForContent(aContent);
-  if (rootShell) {
-    if (Document* rootDoc = rootShell->GetDocument()) {
+  if (PresShell* rootPresShell =
+          APZCCallbackHelper::GetRootContentDocumentPresShellForContent(
+              aContent)) {
+    if (Document* rootDoc = rootPresShell->GetDocument()) {
       nsIContent* rootContent =
-          rootShell->GetRootScrollFrame()
-              ? rootShell->GetRootScrollFrame()->GetContent()
+          rootPresShell->GetRootScrollFrame()
+              ? rootPresShell->GetRootScrollFrame()->GetContent()
               : rootDoc->GetDocumentElement();
       // For the AccessibleCaret: disable APZ on any scrollable subframes that
       // are not the root scrollframe of a document, if the document has any
       // visible anonymous contents.
       // If we find this is triggering in too many scenarios then we might
       // want to tighten this check further. The main use cases for which we
       // want to disable APZ as of this writing are listed in bug 1316318.
       if (aContent != rootContent && HasVisibleAnonymousContents(rootDoc)) {