| OLD | NEW |
| 1 // Copyright 2015 The Chromium Authors. All rights reserved. | 1 // Copyright 2015 The Chromium Authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 #include "core/layout/ScrollAnchor.h" | 5 #include "core/layout/ScrollAnchor.h" |
| 6 | 6 |
| 7 #include "core/dom/ClientRect.h" | 7 #include "core/dom/ClientRect.h" |
| 8 #include "core/frame/VisualViewport.h" | 8 #include "core/frame/VisualViewport.h" |
| 9 #include "core/layout/LayoutBox.h" | 9 #include "core/layout/LayoutBox.h" |
| 10 #include "core/layout/LayoutTestHelper.h" | 10 #include "core/layout/LayoutTestHelper.h" |
| (...skipping 529 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 540 scrollerElement->setAttribute(HTMLNames::styleAttr, "position: relative"); | 540 scrollerElement->setAttribute(HTMLNames::styleAttr, "position: relative"); |
| 541 update(); | 541 update(); |
| 542 scroller->scrollBy(ScrollOffset(0, 25), UserScroll); | 542 scroller->scrollBy(ScrollOffset(0, 25), UserScroll); |
| 543 setHeight(document().getElementById("a"), 125); | 543 setHeight(document().getElementById("a"), 125); |
| 544 | 544 |
| 545 // When the scroller is position:relative, the anchor may be | 545 // When the scroller is position:relative, the anchor may be |
| 546 // position:absolute. | 546 // position:absolute. |
| 547 EXPECT_EQ(absPos->layoutObject(), scrollAnchor(scroller).anchorObject()); | 547 EXPECT_EQ(absPos->layoutObject(), scrollAnchor(scroller).anchorObject()); |
| 548 } | 548 } |
| 549 | 549 |
| 550 TEST_P(ScrollAnchorTest, DescendsIntoAbsPosWithOffscreenStaticParent) { |
| 551 setBodyInnerHTML( |
| 552 "<style>" |
| 553 " body, html { height: 0; }" |
| 554 " #abs {" |
| 555 " position: absolute;" |
| 556 " left: 50px;" |
| 557 " top: 50px;" |
| 558 " height: 1200px;" |
| 559 " padding: 50px;" |
| 560 " border: 5px solid gray;" |
| 561 " }" |
| 562 " #anchor {" |
| 563 " background-color: #afa;" |
| 564 " width: 100px;" |
| 565 " height: 100px;" |
| 566 " }" |
| 567 "</style>" |
| 568 "<div id='abs'>" |
| 569 " <div id='changer'></div>" |
| 570 " <div id='anchor'></div>" |
| 571 "</div>"); |
| 572 |
| 573 scrollLayoutViewport(ScrollOffset(0, 120)); |
| 574 setHeight(document().getElementById("changer"), 100); |
| 575 EXPECT_EQ(220, layoutViewport()->scrollOffsetInt().height()); |
| 576 } |
| 577 |
| 550 // Test that we descend into zero-height containers that have overflowing | 578 // Test that we descend into zero-height containers that have overflowing |
| 551 // content. | 579 // content. |
| 552 TEST_P(ScrollAnchorTest, DescendsIntoContainerWithOverflow) { | 580 TEST_P(ScrollAnchorTest, DescendsIntoContainerWithOverflow) { |
| 553 setBodyInnerHTML( | 581 setBodyInnerHTML( |
| 554 "<style>" | 582 "<style>" |
| 555 " body { height: 1000; }" | 583 " body { height: 1000; }" |
| 556 " #outer { width: 300px; }" | 584 " #outer { width: 300px; }" |
| 557 " #zeroheight { height: 0px; }" | 585 " #zeroheight { height: 0px; }" |
| 558 " #changer { height: 100px; background-color: red; }" | 586 " #changer { height: 100px; background-color: red; }" |
| 559 " #bottom { margin-top: 600px; }" | 587 " #bottom { margin-top: 600px; }" |
| (...skipping 579 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1139 | 1167 |
| 1140 scrollLayoutViewport(ScrollOffset(-50, 0)); | 1168 scrollLayoutViewport(ScrollOffset(-50, 0)); |
| 1141 | 1169 |
| 1142 a->setAttribute(HTMLNames::styleAttr, "width: 200px"); | 1170 a->setAttribute(HTMLNames::styleAttr, "width: 200px"); |
| 1143 b->setAttribute(HTMLNames::styleAttr, "height: 150px"); | 1171 b->setAttribute(HTMLNames::styleAttr, "height: 150px"); |
| 1144 update(); | 1172 update(); |
| 1145 EXPECT_EQ(ScrollOffset(-100, 150), viewport->getScrollOffset()); | 1173 EXPECT_EQ(ScrollOffset(-100, 150), viewport->getScrollOffset()); |
| 1146 EXPECT_EQ(c->layoutObject(), scrollAnchor(viewport).anchorObject()); | 1174 EXPECT_EQ(c->layoutObject(), scrollAnchor(viewport).anchorObject()); |
| 1147 } | 1175 } |
| 1148 } | 1176 } |
| OLD | NEW |