| Index: third_party/WebKit/Source/core/layout/ScrollAnchorTest.cpp
|
| diff --git a/third_party/WebKit/Source/core/layout/ScrollAnchorTest.cpp b/third_party/WebKit/Source/core/layout/ScrollAnchorTest.cpp
|
| index ffc3a95832c3946005e99bc5e0fb735b72ede5d2..3f2d730240abfeb1b8ddf97cccf688c4f0395ac9 100644
|
| --- a/third_party/WebKit/Source/core/layout/ScrollAnchorTest.cpp
|
| +++ b/third_party/WebKit/Source/core/layout/ScrollAnchorTest.cpp
|
| @@ -256,7 +256,9 @@ TEST_F(ScrollAnchorTest, ExcludeFixedPosition)
|
| scrollAnchor(layoutViewport()).anchorObject());
|
| }
|
|
|
| -TEST_F(ScrollAnchorTest, ExcludeAbsolutePosition)
|
| +// This test verifies that position:absolute elements that stick to the viewport
|
| +// are not selected as anchors.
|
| +TEST_F(ScrollAnchorTest, ExcludeAbsolutePositionThatSticksToViewport)
|
| {
|
| setBodyInnerHTML(
|
| "<style>"
|
| @@ -265,7 +267,7 @@ TEST_F(ScrollAnchorTest, ExcludeAbsolutePosition)
|
| " #space { height: 1000px; }"
|
| " #abs {"
|
| " position: absolute; background-color: red;"
|
| - " left: 200px; top: 100px; width: 100px; height: 100px;"
|
| + " width: 100px; height: 100px;"
|
| " }"
|
| " #rel {"
|
| " position: relative; background-color: green;"
|
| @@ -296,6 +298,71 @@ TEST_F(ScrollAnchorTest, ExcludeAbsolutePosition)
|
| EXPECT_EQ(absPos->layoutObject(), scrollAnchor(scroller).anchorObject());
|
| }
|
|
|
| +// This test verifies that position:absolute elements with top/right/bottom/left
|
| +// set are not selected as anchors.
|
| +TEST_F(ScrollAnchorTest, ExcludeOffsettedAbsolutePosition)
|
| +{
|
| + setBodyInnerHTML(
|
| + "<style>"
|
| + " body { margin: 0; }"
|
| + " #scroller { overflow: scroll; width: 500px; height: 400px; position:relative; }"
|
| + " #space { height: 1000px; }"
|
| + " #abs {"
|
| + " position: absolute; background-color: red;"
|
| + " width: 100px; height: 100px;"
|
| + " }"
|
| + " #rel {"
|
| + " position: relative; background-color: green;"
|
| + " left: 50px; top: 100px; width: 100px; height: 75px;"
|
| + " }"
|
| + " .top { top: 10px }"
|
| + " .left { left: 10px }"
|
| + " .right { right: 10px }"
|
| + " .bottom { bottom: 10px }"
|
| + "</style>"
|
| + "<div id='scroller'><div id='space'>"
|
| + " <div id='abs'></div>"
|
| + " <div id='rel'></div>"
|
| + "</div></div>");
|
| +
|
| + Element* scrollerElement = document().getElementById("scroller");
|
| + ScrollableArea* scroller = scrollerForElement(scrollerElement);
|
| + Element* relPos = document().getElementById("rel");
|
| + Element* absPos = document().getElementById("abs");
|
| +
|
| + scroller->scrollBy(DoubleSize(0, 25), UserScroll);
|
| + setHeight(relPos, 100);
|
| + // Pick absolute anchor.
|
| + EXPECT_EQ(absPos->layoutObject(), scrollAnchor(scroller).anchorObject());
|
| +
|
| + absPos->setAttribute(HTMLNames::classAttr, "top");
|
| + scroller->scrollBy(DoubleSize(0, 25), UserScroll);
|
| + setHeight(relPos, 125);
|
| + // Don't pick absolute anchor since top is set.
|
| + EXPECT_EQ(relPos->layoutObject(), scrollAnchor(scroller).anchorObject());
|
| +
|
| + absPos->removeAttribute(HTMLNames::classAttr);
|
| + absPos->setAttribute(HTMLNames::classAttr, "right");
|
| + scroller->scrollBy(DoubleSize(0, 25), UserScroll);
|
| + setHeight(relPos, 150);
|
| + // Don't pick absolute anchor since right is set.
|
| + EXPECT_EQ(relPos->layoutObject(), scrollAnchor(scroller).anchorObject());
|
| +
|
| + absPos->removeAttribute(HTMLNames::classAttr);
|
| + absPos->setAttribute(HTMLNames::classAttr, "bottom");
|
| + scroller->scrollBy(DoubleSize(0, 25), UserScroll);
|
| + setHeight(relPos, 175);
|
| + // Don't pick absolute anchor since bottom is set.
|
| + EXPECT_EQ(relPos->layoutObject(), scrollAnchor(scroller).anchorObject());
|
| +
|
| + absPos->removeAttribute(HTMLNames::classAttr);
|
| + absPos->setAttribute(HTMLNames::classAttr, "left");
|
| + scroller->scrollBy(DoubleSize(0, 25), UserScroll);
|
| + setHeight(relPos, 200);
|
| + // Don't pick absolute anchor since left is set.
|
| + EXPECT_EQ(relPos->layoutObject(), scrollAnchor(scroller).anchorObject());
|
| +}
|
| +
|
| // Test that we descend into zero-height containers that have overflowing content.
|
| TEST_F(ScrollAnchorTest, DescendsIntoContainerWithOverflow)
|
| {
|
|
|