| 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 194ae5e604e12b76cd094bed82b273253e8e7973..300be36e9f4c51d1f250a77ea0fe72a5a1df4c1f 100644
|
| --- a/third_party/WebKit/Source/core/layout/ScrollAnchorTest.cpp
|
| +++ b/third_party/WebKit/Source/core/layout/ScrollAnchorTest.cpp
|
| @@ -246,26 +246,49 @@ TEST_F(ScrollAnchorTest, ExcludeAbsolutePosition)
|
| EXPECT_EQ(absPos->layoutObject(), scrollAnchor(scroller).anchorObject());
|
| }
|
|
|
| +// See crbug.com/600891 for context as to why we don't adjust the scroll offset
|
| +// if the anchor node changes.
|
| +TEST_F(ScrollAnchorTest, NoAdjustmentIfAnchorChanged)
|
| +{
|
| + setBodyInnerHTML(
|
| + "<style>"
|
| + " body { height: 2000px; }"
|
| + " #beforeAnchor {"
|
| + " height: 300px; background-color: #fcc;"
|
| + " }"
|
| + " #anchor {"
|
| + " background-color: #afa; height: 200px; border: 1px solid gray;"
|
| + " }"
|
| + "</style>"
|
| + "<div id=beforeAnchor></div>"
|
| + "<div id=anchor></div>");
|
| +
|
| + // Bring div that will be anchored into view and change it's height.
|
| + scrollLayoutViewport(DoubleSize(0, 350));
|
| + setHeight(document().getElementById("anchor"), 300);
|
| + // No adjustment should be made.
|
| + EXPECT_EQ(DoublePoint(0, 350), layoutViewport()->scrollPositionDouble());
|
| +}
|
| +
|
| class ScrollAnchorCornerTest : public ScrollAnchorTest {
|
| protected:
|
| - void checkCorner(const AtomicString& id, Corner corner, DoublePoint startPos, DoubleSize expectedAdjustment)
|
| + void checkCorner(const AtomicString& expectedAnchorId, Corner corner, DoublePoint startPos, DoubleSize expectedAdjustment)
|
| {
|
| ScrollableArea* viewport = layoutViewport();
|
| - Element* element = document().getElementById(id);
|
| -
|
| + Element* changingElement = document().getElementById("changer");
|
| viewport->setScrollPosition(startPos, UserScroll);
|
| - element->setAttribute(HTMLNames::classAttr, "big");
|
| - update();
|
| +
|
| + setHeight(changingElement, 200);
|
|
|
| DoublePoint endPos = startPos;
|
| endPos.move(expectedAdjustment);
|
|
|
| EXPECT_EQ(endPos, viewport->scrollPositionDouble());
|
| - EXPECT_EQ(element->layoutObject(), scrollAnchor(viewport).anchorObject());
|
| + EXPECT_EQ(document().getElementById(expectedAnchorId)->layoutObject(),
|
| + scrollAnchor(viewport).anchorObject());
|
| EXPECT_EQ(corner, scrollAnchor(viewport).corner());
|
|
|
| - element->removeAttribute(HTMLNames::classAttr);
|
| - update();
|
| + setHeight(changingElement, 0);
|
| }
|
| };
|
|
|
| @@ -273,8 +296,8 @@ TEST_F(ScrollAnchorCornerTest, Corners)
|
| {
|
| setBodyInnerHTML(
|
| "<style>"
|
| - " body {"
|
| - " position: absolute; border: 10px solid #ccc;"
|
| + " #container {"
|
| + " position: relative; border: 1px solid black;"
|
| " width: 1220px; height: 920px;"
|
| " }"
|
| " #a, #b, #c, #d {"
|
| @@ -285,17 +308,19 @@ TEST_F(ScrollAnchorCornerTest, Corners)
|
| " #a, #c { left: 0; }"
|
| " #b, #d { right: 0; }"
|
| " #c, #d { bottom: 0; }"
|
| - " .big { width: 800px !important; height: 600px !important }"
|
| "</style>"
|
| - "<div id=a></div>"
|
| - "<div id=b></div>"
|
| - "<div id=c></div>"
|
| - "<div id=d></div>");
|
| -
|
| - checkCorner("a", Corner::BottomRight, DoublePoint(20, 20), DoubleSize(+400, +300));
|
| - checkCorner("b", Corner::BottomLeft, DoublePoint(420, 20), DoubleSize(-400, +300));
|
| - checkCorner("c", Corner::TopRight, DoublePoint(20, 320), DoubleSize(+400, -300));
|
| - checkCorner("d", Corner::TopLeft, DoublePoint(420, 320), DoubleSize(-400, -300));
|
| + "<div id=changer></div>"
|
| + "<div id=container>"
|
| + " <div id=a></div>"
|
| + " <div id=b></div>"
|
| + " <div id=c></div>"
|
| + " <div id=d></div>"
|
| + "</div>");
|
| +
|
| + checkCorner("a", Corner::BottomRight, DoublePoint(20, 20), DoubleSize(0, 200));
|
| + checkCorner("b", Corner::BottomLeft, DoublePoint(420, 20), DoubleSize(0, 200));
|
| + checkCorner("c", Corner::TopRight, DoublePoint(20, 320), DoubleSize(0, 200));
|
| + checkCorner("d", Corner::TopLeft, DoublePoint(420, 320), DoubleSize(0, 200));
|
| }
|
|
|
| }
|
|
|