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

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

Issue 2769353002: Only create sticky position constraints for constrained sticky position. (Closed)
Patch Set: Set dependent patch. Created 3 years, 9 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
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 2075455464a254e8ad6aab65699330b30d5f2476..0001d9c90b14bcf3cadb4d33c634c714cf74f57e 100644
--- a/third_party/WebKit/Source/core/layout/LayoutBoxModelObjectTest.cpp
+++ b/third_party/WebKit/Source/core/layout/LayoutBoxModelObjectTest.cpp
@@ -339,11 +339,18 @@ TEST_F(LayoutBoxModelObjectTest, StickyPositionConstraintInvalidation) {
TEST_F(LayoutBoxModelObjectTest,
StickyPositionFindsCorrectStickyBoxShiftingAncestor) {
setBodyInnerHTML(
- "<style>#stickyOuterDiv { position: sticky; }"
- "#stickyOuterInline { position: sticky; display: inline; }"
- "#stickyInnerInline { position: sticky; display: inline; }</style>"
- "<div id='stickyOuterDiv'><div id='stickyOuterInline'>"
- "<div id='stickyInnerInline'></div></div></div>");
+ "<style>#stickyOuterDiv { position: sticky; top: 0;}"
+ "#stickyOuterInline { position: sticky; top: 0; display: inline; }"
+ "#unanchoredSticky { position: sticky; display: inline; }"
+ "#stickyInnerInline { position: sticky; top: 0; display: inline; "
+ "}</style>"
+ "<div id='stickyOuterDiv'>"
+ " <div id='stickyOuterInline'>"
+ " <div id='unanchoredSticky'>"
+ " <div id='stickyInnerInline'></div>"
+ " </div>"
+ " </div>"
+ "</div>");
LayoutBoxModelObject* stickyOuterDiv =
toLayoutBoxModelObject(getLayoutObjectByElementId("stickyOuterDiv"));
@@ -386,12 +393,19 @@ TEST_F(LayoutBoxModelObjectTest,
// We make the scroller itself sticky in order to check that elements do not
// detect it as their containing-block shifting ancestor.
setBodyInnerHTML(
- "<style>#scroller { overflow-y: scroll; position: sticky; }"
- "#stickyParent { position: sticky; }"
- "#stickyChild { position: sticky; }"
- "#stickyNestedChild { position: sticky; }</style>"
- "<div id='scroller'><div id='stickyParent'><div id='stickyChild'></div>"
- "<div><div id='stickyNestedChild'></div></div></div></div>");
+ "<style>#scroller { overflow-y: scroll; position: sticky; top: 0;}"
+ "#stickyParent { position: sticky; top: 0;}"
+ "#stickyChild { position: sticky; top: 0;}"
+ "#unanchoredSticky { position: sticky; }"
+ "#stickyNestedChild { position: sticky; top: 0;}</style>"
+ "<div id='scroller'>"
+ " <div id='stickyParent'>"
+ " <div id='unanchoredSticky'>"
+ " <div id='stickyChild'></div>"
+ " <div><div id='stickyNestedChild'></div></div>"
+ " </div>"
+ " </div>"
+ "</div>");
LayoutBoxModelObject* scroller =
toLayoutBoxModelObject(getLayoutObjectByElementId("scroller"));
@@ -418,7 +432,8 @@ TEST_F(LayoutBoxModelObjectTest,
.nearestStickyBoxShiftingContainingBlock());
// Both inner children should detect the parent <div> as their
- // containing-block shifting ancestor.
+ // containing-block shifting ancestor. They skip past unanchored sticky
+ // because it will never have a non-zero offset.
EXPECT_EQ(stickyParent,
constraintsMap.at(stickyChild->layer())
.nearestStickyBoxShiftingContainingBlock());
@@ -435,8 +450,8 @@ TEST_F(LayoutBoxModelObjectTest,
TEST_F(LayoutBoxModelObjectTest,
StickyPositionFindsCorrectContainingBlockShiftingAncestorRoot) {
setBodyInnerHTML(
- "<style>#stickyParent { position: sticky; }"
- "#stickyGrandchild { position: sticky; }</style>"
+ "<style>#stickyParent { position: sticky; top: 0;}"
+ "#stickyGrandchild { position: sticky; top: 0;}</style>"
"<div id='stickyParent'><div><div id='stickyGrandchild'></div></div>"
"</div>");
@@ -468,8 +483,8 @@ TEST_F(LayoutBoxModelObjectTest,
StickyPositionFindsCorrectContainingBlockShiftingAncestorTable) {
setBodyInnerHTML(
"<style>#scroller { overflow-y: scroll; }"
- "#stickyOuter { position: sticky; }"
- "#stickyTh { position: sticky; }</style>"
+ "#stickyOuter { position: sticky; top: 0;}"
+ "#stickyTh { position: sticky; top: 0;}</style>"
"<div id='scroller'><div id='stickyOuter'><table><thead><tr>"
"<th id='stickyTh'></th></tr></thead></table></div></div>");
@@ -843,10 +858,18 @@ TEST_F(LayoutBoxModelObjectTest, StickyPositionNestedInlineElements) {
"<style>#scroller { width: 100px; height: 100px; overflow-y: scroll; }"
"#paddingBefore { height: 50px; }"
"#outerInline { display: inline; position: sticky; top: 0; }"
+ "#unanchoredSticky { position: sticky; display: inline; }"
"#innerInline { display: inline; position: sticky; top: 25px; }"
"#paddingAfter { height: 200px; }</style>"
- "<div id='scroller'><div id='paddingBefore'></div><div id='outerInline'>"
- "<div id='innerInline'></div></div><div id='paddingAfter'></div></div>");
+ "<div id='scroller'>"
+ " <div id='paddingBefore'></div>"
+ " <div id='outerInline'>"
+ " <div id='unanchoredSticky'>"
+ " <div id='innerInline'></div>"
+ " </div>"
+ " </div>"
+ " <div id='paddingAfter'></div>"
+ "</div>");
LayoutBoxModelObject* outerInline =
toLayoutBoxModelObject(getLayoutObjectByElementId("outerInline"));

Powered by Google App Engine
This is Rietveld 408576698