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 821027 0de750341ae0976719225cf00096a903cab058d4
parent 821026 d90f7b5dd3f7761d26cdfc4fbfccec864ade33a5
child 821028 d4f597023ba54ab0082d5df77101fd89a8e3cbd7
push id116994
push userbmo:kmadan@mozilla.com
push dateFri, 20 Jul 2018 19:32:49 +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 into the frame's parent (i.e., the layout
+        // viewport).
+        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)) {