Bug 1656421 - Use the viewport frame size for the clip rect if there is no root scroll frame. r=botond
authorHiroyuki Ikezoe <hikezoe.birchill@mozilla.com>
Fri, 31 Jul 2020 18:15:32 +0000
changeset 542972 0ffbb586b294704076249db41ee65d3afca720a1
parent 542971 97978347256f99d5cfd04f59a88c79f08187f220
child 542973 0b3c19b8b7f9f918d53e5aef276d272ffb319cd4
push id37657
push usernerli@mozilla.com
push dateSat, 01 Aug 2020 09:48:10 +0000
treeherdermozilla-central@750bc4c5c4ad [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersbotond
bugs1656421
milestone81.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 1656421 - Use the viewport frame size for the clip rect if there is no root scroll frame. r=botond Differential Revision: https://phabricator.services.mozilla.com/D85548
gfx/layers/AnimationInfo.cpp
--- a/gfx/layers/AnimationInfo.cpp
+++ b/gfx/layers/AnimationInfo.cpp
@@ -686,37 +686,45 @@ GetClipRectAndTransformForPartialPrerend
     scrollFrame = nsLayoutUtils::GetNearestScrollableFrame(
         aFrame->GetParent(), nsLayoutUtils::SCROLLABLE_SAME_DOC |
                                  nsLayoutUtils::SCROLLABLE_INCLUDE_HIDDEN);
     if (!scrollFrame) {
       // If there is no suitable scrollable frame in the same document, use the
       // root one.
       scrollFrame = aFrame->PresShell()->GetRootScrollFrameAsScrollable();
     }
-    aClipFrame = do_QueryFrame(scrollFrame);
+    if (scrollFrame) {
+      aClipFrame = do_QueryFrame(scrollFrame);
+    } else {
+      // If there is no root scroll frame, use the viewport frame.
+      aClipFrame = aFrame->PresShell()->GetRootFrame();
+    }
   } else {
     scrollFrame = do_QueryFrame(aClipFrame);
   }
 
-  MOZ_ASSERT(scrollFrame);
   MOZ_ASSERT(aClipFrame);
 
   gfx::Matrix4x4 transformInClip =
       nsLayoutUtils::GetTransformToAncestor(RelativeTo{aFrame->GetParent()},
                                             RelativeTo{aClipFrame})
           .GetMatrix();
-  transformInClip.PostTranslate(
-      LayoutDevicePoint::FromAppUnits(scrollFrame->GetScrollPosition(),
-                                      aDevPixelsToAppUnits)
-          .ToUnknownPoint());
+  if (scrollFrame) {
+    transformInClip.PostTranslate(
+        LayoutDevicePoint::FromAppUnits(scrollFrame->GetScrollPosition(),
+                                        aDevPixelsToAppUnits)
+            .ToUnknownPoint());
+  }
 
   // We don't necessarily use nsLayoutUtils::CalculateCompositionSizeForFrame
   // since this is a case where we don't use APZ at all.
   return std::make_pair(
-      LayoutDeviceRect::FromAppUnits(scrollFrame->GetScrollPortRect(),
+      LayoutDeviceRect::FromAppUnits(scrollFrame
+                                         ? scrollFrame->GetScrollPortRect()
+                                         : aClipFrame->GetRectRelativeToSelf(),
                                      aDevPixelsToAppUnits) *
           LayoutDeviceToLayerScale2D() * LayerToParentLayerScale(),
       transformInClip);
 }
 
 static PartialPrerenderData GetPartialPrerenderData(
     const nsIFrame* aFrame, const nsDisplayItem* aItem) {
   const nsRect& partialPrerenderedRect = aItem->GetUntransformedPaintRect();