Bug 1465616 - Use layout viewport size to compute visible rect for fixed position elements. r?mstange draft
authorKashav Madan <kmadan@mozilla.com>
Wed, 04 Jul 2018 16:10:04 -0400
changeset 821683 e1fa98f2ff7dff2e8d5a205baa04e9bfb5931b73
parent 821571 f2cb1432e20715d8305a2f4faeb48cd11f671f86
child 821684 d0a0d491895d94c0843490e38c53eb353ae7d692
push id117170
push userbmo:kmadan@mozilla.com
push dateMon, 23 Jul 2018 20:02:59 +0000
reviewersmstange
bugs1465616
milestone63.0a1
Bug 1465616 - Use layout viewport size to compute visible rect for fixed position elements. r?mstange Since fixed position elements are now scrollable, we need to ensure that they're drawn using the layout viewport size instead of only the SPC-SPS, since otherwise they'd appear to be clipped when scrolled. MozReview-Commit-ID: 4p3pWnwluvz
layout/painting/nsDisplayList.h
--- a/layout/painting/nsDisplayList.h
+++ b/layout/painting/nsDisplayList.h
@@ -1457,34 +1457,28 @@ public:
     static nsRect ComputeVisibleRectForFrame(nsDisplayListBuilder* aBuilder,
                                              nsIFrame* aFrame,
                                              const nsRect& aVisibleRect,
                                              const nsRect& aDirtyRect,
                                              nsRect* aOutDirtyRect) {
       nsRect visible = aVisibleRect;
       nsRect dirtyRectRelativeToDirtyFrame = aDirtyRect;
 
+#ifdef MOZ_WIDGET_ANDROID
       if (nsLayoutUtils::IsFixedPosFrameInDisplayPort(aFrame) &&
           aBuilder->IsPaintingToWindow()) {
-        // position: fixed items are reflowed into and only drawn inside the
-        // viewport, or the scroll position clamping scrollport size, if one is
-        // set.
-        nsIPresShell* ps = aFrame->PresShell();
-        if (ps->IsScrollPositionClampingScrollPortSizeSet()) {
-          dirtyRectRelativeToDirtyFrame =
-            nsRect(nsPoint(0, 0), ps->GetScrollPositionClampingScrollPortSize());
-          visible = dirtyRectRelativeToDirtyFrame;
-#ifdef MOZ_WIDGET_ANDROID
-        } else {
-          dirtyRectRelativeToDirtyFrame =
-            nsRect(nsPoint(0, 0), aFrame->GetParent()->GetSize());
-          visible = dirtyRectRelativeToDirtyFrame;
+        // To ensure position:fixed elements are visible when being async
+        // scrolled, paint them at their parent frame's size, i.e. the layout
+        // viewport size.
+        dirtyRectRelativeToDirtyFrame =
+          nsRect(nsPoint(0, 0), aFrame->GetParent()->GetSize());
+        visible = dirtyRectRelativeToDirtyFrame;
+      }
 #endif
-        }
-      }
+
       *aOutDirtyRect = dirtyRectRelativeToDirtyFrame - aFrame->GetPosition();
       visible -= aFrame->GetPosition();
 
       nsRect overflowRect = aFrame->GetVisualOverflowRect();
 
       if (aFrame->IsTransformed() &&
           mozilla::EffectCompositor::HasAnimationsForCompositor(aFrame,
                                                                 eCSSProperty_transform)) {