Bug 1531470 - Use nsLayoutUtils::GetNearestScrollableFrame with SAME_DOC and INCLUDE_HIDDEN flags to get position:sticky target scrollable frame. r=kats
authorHiroyuki Ikezoe <hikezoe@mozilla.com>
Sun, 03 Mar 2019 00:33:55 +0000
changeset 520052 4f78b47f52b2f138e472b6fd54b83b4b8031a967
parent 520051 16ebe5e32775afa93eec29766332c8e1e04e62c6
child 520053 a920a704ff6bf2811f717be3c437239b6257046b
push id10862
push userffxbld-merge
push dateMon, 11 Mar 2019 13:01:11 +0000
treeherdermozilla-beta@a2e7f5c935da [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewerskats
bugs1531470
milestone67.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 1531470 - Use nsLayoutUtils::GetNearestScrollableFrame with SAME_DOC and INCLUDE_HIDDEN flags to get position:sticky target scrollable frame. r=kats Differential Revision: https://phabricator.services.mozilla.com/D21835
layout/painting/nsDisplayList.cpp
--- a/layout/painting/nsDisplayList.cpp
+++ b/layout/painting/nsDisplayList.cpp
@@ -1822,30 +1822,24 @@ const nsIFrame* nsDisplayListBuilder::Fi
 }
 
 // Sticky frames are active if their nearest scrollable frame is also active.
 static bool IsStickyFrameActive(nsDisplayListBuilder* aBuilder,
                                 nsIFrame* aFrame, nsIFrame* aParent) {
   MOZ_ASSERT(aFrame->StyleDisplay()->mPosition == NS_STYLE_POSITION_STICKY);
 
   // Find the nearest scrollframe.
-  nsIFrame* cursor = aFrame;
-  nsIFrame* parent = aParent;
-  if (!parent) {
-    parent = nsLayoutUtils::GetCrossDocParentFrame(aFrame);
-  }
-  while (!parent->IsScrollFrame()) {
-    cursor = parent;
-    if ((parent = nsLayoutUtils::GetCrossDocParentFrame(cursor)) == nullptr) {
-      return false;
-    }
-  }
-
-  nsIScrollableFrame* sf = do_QueryFrame(parent);
-  return sf->IsScrollingActive(aBuilder) && sf->GetScrolledFrame() == cursor;
+  nsIScrollableFrame* sf = nsLayoutUtils::GetNearestScrollableFrame(
+      aFrame->GetParent(), nsLayoutUtils::SCROLLABLE_SAME_DOC |
+                               nsLayoutUtils::SCROLLABLE_INCLUDE_HIDDEN);
+  if (!sf) {
+    return false;
+  }
+
+  return sf->IsScrollingActive(aBuilder);
 }
 
 nsDisplayListBuilder::AGRState nsDisplayListBuilder::IsAnimatedGeometryRoot(
     nsIFrame* aFrame, bool& aIsAsync, nsIFrame** aParent) {
   // We can return once we know that this frame is an AGR, and we're either
   // async, or sure that none of the later conditions might make us async.
   // The exception to this is when IsPaintingToWindow() == false.
   aIsAsync = false;