Bug 1280344 - Use first continuation's normal position in computing sticky scroll ranges for APZ. r=dholbert, a=gchang
authorCorey Ford <corey@coreyford.name>
Tue, 12 Jul 2016 12:36:31 -0400
changeset 339942 ec66f083c0b90eb4ca5d974a109c01c46c2881cc
parent 339941 51e43fba7dffed21b0356a91de88d86d8ecfcae0
child 339943 6bc76a1b5dbb1b7ee5b68aeb5d759633221e55e0
push id6249
push userjlund@mozilla.com
push dateMon, 01 Aug 2016 13:59:36 +0000
treeherdermozilla-beta@bad9d4f5bf7e [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersdholbert, gchang
bugs1280344
milestone49.0a2
Bug 1280344 - Use first continuation's normal position in computing sticky scroll ranges for APZ. r=dholbert, a=gchang MozReview-Commit-ID: L0wRgCvb8h8
layout/generic/StickyScrollContainer.cpp
layout/reftests/position-sticky/inline-4-ref.html
layout/reftests/position-sticky/inline-4.html
layout/reftests/position-sticky/reftest.list
--- a/layout/generic/StickyScrollContainer.cpp
+++ b/layout/generic/StickyScrollContainer.cpp
@@ -269,30 +269,30 @@ StickyScrollContainer::ComputePosition(n
 
   return position;
 }
 
 void
 StickyScrollContainer::GetScrollRanges(nsIFrame* aFrame, nsRect* aOuter,
                                        nsRect* aInner) const
 {
-  // We need to use the first in flow; ComputeStickyLimits requires
-  // this, at the very least because its call to
-  // nsLayoutUtils::GetAllInFlowRectsUnion requires it.
+  // We need to use the first in flow; continuation frames should not move
+  // relative to each other and should get identical scroll ranges.
+  // Also, ComputeStickyLimits requires this.
   nsIFrame *firstCont =
     nsLayoutUtils::FirstContinuationOrIBSplitSibling(aFrame);
 
   nsRect stick;
   nsRect contain;
   ComputeStickyLimits(firstCont, &stick, &contain);
 
   aOuter->SetRect(nscoord_MIN/2, nscoord_MIN/2, nscoord_MAX, nscoord_MAX);
   aInner->SetRect(nscoord_MIN/2, nscoord_MIN/2, nscoord_MAX, nscoord_MAX);
 
-  const nsPoint normalPosition = aFrame->GetNormalPosition();
+  const nsPoint normalPosition = firstCont->GetNormalPosition();
 
   // Bottom and top
   if (stick.YMost() != nscoord_MAX/2) {
     aOuter->SetTopEdge(contain.y - stick.YMost());
     aInner->SetTopEdge(normalPosition.y - stick.YMost());
   }
 
   if (stick.y != nscoord_MIN/2) {
new file mode 100644
--- /dev/null
+++ b/layout/reftests/position-sticky/inline-4-ref.html
@@ -0,0 +1,45 @@
+<!DOCTYPE html>
+<!-- Any copyright is dedicated to the Public Domain.
+   - http://creativecommons.org/publicdomain/zero/1.0/ -->
+<html>
+  <head>
+    <link rel="author" title="Corey Ford" href="mailto:corey@coreyford.name">
+    <link rel="stylesheet" type="text/css" href="ahem.css">
+    <style>
+      #scroller {
+        margin-top: 100px;
+        height: 200px;
+        width: 500px;
+        overflow: hidden;
+      }
+      #container {
+        background: pink;
+        position: relative;
+        margin: 50px;
+        height: 400px;
+        margin-bottom: 1000px;
+      }
+      #sticky {
+        position: sticky;
+        left: 0px;
+        top: 75px;
+        outline: 1px dotted purple;
+        font: 10px/1 Ahem;
+      }
+    </style>
+  </head>
+  <body>
+    <div id="scroller">
+      <div id="container">
+        <span id="sticky">
+          First line<br>
+          Second line<br>
+          Third line<br>
+        </span>
+      </div>
+    </div>
+    <script>
+      document.getElementById("scroller").scrollTop = 30;
+    </script>
+  </body>
+</html>
new file mode 100644
--- /dev/null
+++ b/layout/reftests/position-sticky/inline-4.html
@@ -0,0 +1,48 @@
+<!DOCTYPE html>
+<!-- Any copyright is dedicated to the Public Domain.
+   - http://creativecommons.org/publicdomain/zero/1.0/ -->
+<html reftest-async-scroll>
+  <head>
+    <title>CSS Test: Sticky Positioning - inline, async scrolling</title>
+    <link rel="author" title="Corey Ford" href="mailto:corey@coreyford.name">
+    <link rel="match" href="inline-4-ref.html">
+    <meta name="assert" content="Sticky positioning on inline elements should keep continuations aligned during async scrolling">
+    <link rel="stylesheet" type="text/css" href="ahem.css">
+    <style>
+      #scroller {
+        margin-top: 100px;
+        height: 200px;
+        width: 500px;
+        overflow: hidden;
+      }
+      #container {
+        background: pink;
+        position: relative;
+        margin: 50px;
+        height: 400px;
+        margin-bottom: 1000px;
+      }
+      #sticky {
+        position: sticky;
+        left: 0px;
+        top: 75px;
+        outline: 1px dotted purple;
+        font: 10px/1 Ahem;
+      }
+    </style>
+  </head>
+  <body>
+    <div id="scroller"
+         reftest-displayport-x="0" reftest-displayport-y="0"
+         reftest-displayport-w="500" reftest-displayport-h="300"
+         reftest-async-scroll-y="30">
+      <div id="container">
+        <span id="sticky">
+          First line<br>
+          Second line<br>
+          Third line<br>
+        </span>
+      </div>
+    </div>
+  </body>
+</html>
--- a/layout/reftests/position-sticky/reftest.list
+++ b/layout/reftests/position-sticky/reftest.list
@@ -35,16 +35,17 @@ fuzzy-if(Android,2,3) == stacking-contex
 == left-right-3.html left-right-3-ref.html
 fuzzy-if(Android,4,810) == containing-block-1.html containing-block-1-ref.html
 == overconstrained-1.html overconstrained-1-ref.html
 == overconstrained-2.html overconstrained-2-ref.html
 == overconstrained-3.html overconstrained-3-ref.html
 == inline-1.html inline-1-ref.html
 == inline-2.html inline-2-ref.html
 fuzzy-if(OSX==1006||OSX==1007,64,100) fuzzy-if(OSX>=1008,99,210) == inline-3.html inline-3-ref.html
+skip-if(!asyncPan) == inline-4.html inline-4-ref.html
 fails == column-contain-1a.html column-contain-1-ref.html
 == column-contain-1b.html column-contain-1-ref.html
 == column-contain-2.html column-contain-2-ref.html
 == block-in-inline-1.html block-in-inline-1-ref.html
 fuzzy-if(winWidget&&!layersGPUAccelerated,116,440) fuzzy-if(Android,8,1533) skip-if((B2G&&browserIsRemote)||Mulet) fuzzy-if(cocoaWidget,1,1) fuzzy-if(skiaContent,1,22) == block-in-inline-2.html block-in-inline-2-ref.html # Initial mulet triage: parity with B2G/B2G Desktop
 fuzzy-if(winWidget&&!layersGPUAccelerated,116,320) fuzzy-if(Android,8,630) fuzzy-if(OSX>=1008,1,11) skip-if((B2G&&browserIsRemote)||Mulet) fuzzy-if(skiaContent,1,124) == block-in-inline-3.html block-in-inline-3-ref.html # Initial mulet triage: parity with B2G/B2G Desktop
 == block-in-inline-continuations.html block-in-inline-continuations-ref.html
 fuzzy-if(winWidget&&!layersGPUAccelerated,102,111) == inner-table-1.html inner-table-1-ref.html