Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(464)

Unified Diff: third_party/WebKit/Source/core/layout/LayoutBoxModelObjectTest.cpp

Issue 2683313003: Always invalidate sticky constraints on the ancestor overflow layer (Closed)
Patch Set: Indentation. Created 3 years, 10 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « third_party/WebKit/Source/core/layout/LayoutBoxModelObject.cpp ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: third_party/WebKit/Source/core/layout/LayoutBoxModelObjectTest.cpp
diff --git a/third_party/WebKit/Source/core/layout/LayoutBoxModelObjectTest.cpp b/third_party/WebKit/Source/core/layout/LayoutBoxModelObjectTest.cpp
index 919cb0458813e41c08e2561f129705a85d80747d..ca16f0c6be9a2f1ec16ff0bf5dd4f3dcc545b033 100644
--- a/third_party/WebKit/Source/core/layout/LayoutBoxModelObjectTest.cpp
+++ b/third_party/WebKit/Source/core/layout/LayoutBoxModelObjectTest.cpp
@@ -4,6 +4,8 @@
#include "core/layout/LayoutBoxModelObject.h"
+#include "core/dom/DOMTokenList.h"
+#include "core/dom/DocumentLifecycle.h"
#include "core/html/HTMLElement.h"
#include "core/layout/ImageQualityController.h"
#include "core/layout/LayoutTestHelper.h"
@@ -278,4 +280,52 @@ TEST_F(LayoutBoxModelObjectTest, StickyPositionTableContainers) {
enclosingIntRect(getScrollContainerRelativeStickyBoxRect(constraints)));
}
+// Tests that when a non-layer changes size it invalidates the constraints for
+// sticky position elements within the same scroller.
+TEST_F(LayoutBoxModelObjectTest, StickyPositionConstraintInvalidation) {
+ setBodyInnerHTML(
+ "<style>"
+ "#scroller { overflow: auto; display: flex; width: 200px; }"
+ "#target { width: 50px; }"
+ "#sticky { position: sticky; top: 0; }"
+ ".container { width: 100px; margin-left: auto; margin-right: auto; }"
+ ".hide { display: none; }"
+ "</style>"
+ "<div id='scroller'>"
+ " <div style='flex: 1'>"
+ " <div class='container'><div id='sticky'></div>"
+ " </div>"
+ "</div>"
+ "<div class='spacer' id='target'></div>"
+ "</div>");
+ LayoutBoxModelObject* scroller =
+ toLayoutBoxModelObject(getLayoutObjectByElementId("scroller"));
+ PaintLayerScrollableArea* scrollableArea = scroller->getScrollableArea();
+ LayoutBoxModelObject* sticky =
+ toLayoutBoxModelObject(getLayoutObjectByElementId("sticky"));
+ LayoutBoxModelObject* target =
+ toLayoutBoxModelObject(getLayoutObjectByElementId("target"));
+ EXPECT_TRUE(scrollableArea->stickyConstraintsMap().contains(sticky->layer()));
+ EXPECT_EQ(25.f,
+ getScrollContainerRelativeStickyBoxRect(
+ scrollableArea->stickyConstraintsMap().get(sticky->layer()))
+ .location()
+ .x());
+ toHTMLElement(target->node())->classList().add("hide", ASSERT_NO_EXCEPTION);
+ document().view()->updateLifecycleToLayoutClean();
+ // Layout should invalidate the sticky constraints of the sticky element and
+ // mark it as needing a compositing inputs update.
+ EXPECT_FALSE(
+ scrollableArea->stickyConstraintsMap().contains(sticky->layer()));
+ EXPECT_TRUE(sticky->layer()->needsCompositingInputsUpdate());
+
+ // After updating compositing inputs we should have the updated position.
+ document().view()->updateAllLifecyclePhases();
+ EXPECT_EQ(50.f,
+ getScrollContainerRelativeStickyBoxRect(
+ scrollableArea->stickyConstraintsMap().get(sticky->layer()))
+ .location()
+ .x());
+}
+
} // namespace blink
« no previous file with comments | « third_party/WebKit/Source/core/layout/LayoutBoxModelObject.cpp ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698