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 817028 908a1909b70407c5f8d465bd71a2b642ace33954
parent 817027 0f78a428db171a50183c0a8cc98ec453d68432b7
child 817029 64981ea067a1631dc06303c995c4971063daa051
child 817945 075b1fd26320355aabc677e9a8c648ee8580c99b
child 817968 98843a4345e763aaa9571348b49f474146c3a964
child 817992 9c849fe3da347a73853e97db2b2a5abf44de8d0a
child 817995 f683d2c71d5dcffdd0695d2693b00e9a9d6dae46
push id115934
push userbmo:kmadan@mozilla.com
push dateWed, 11 Jul 2018 21:10:29 +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 be inaccurately 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 {
+        if (!ps->IsScrollPositionClampingScrollPortSizeSet()) {
           dirtyRectRelativeToDirtyFrame =
             nsRect(nsPoint(0, 0), aFrame->GetParent()->GetSize());
           visible = dirtyRectRelativeToDirtyFrame;
-#endif
         }
       }
+#endif
+
       *aOutDirtyRect = dirtyRectRelativeToDirtyFrame - aFrame->GetPosition();
       visible -= aFrame->GetPosition();
 
       nsRect overflowRect = aFrame->GetVisualOverflowRect();
 
       if (aFrame->IsTransformed() &&
           mozilla::EffectCompositor::HasAnimationsForCompositor(aFrame,
                                                                 eCSSProperty_transform)) {