| 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 515 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 526 " </div>" | 526 " </div>" |
| 527 "</div>"); | 527 "</div>"); |
| 528 | 528 |
| 529 Element* scroller = document().getElementById("scroller"); | 529 Element* scroller = document().getElementById("scroller"); |
| 530 scroller->setScrollTop(100); | 530 scroller->setScrollTop(100); |
| 531 | 531 |
| 532 setHeight(document().getElementById("before"), 100); | 532 setHeight(document().getElementById("before"), 100); |
| 533 EXPECT_EQ(150, scrollerForElement(scroller)->scrollPosition().y()); | 533 EXPECT_EQ(150, scrollerForElement(scroller)->scrollPosition().y()); |
| 534 } | 534 } |
| 535 | 535 |
| 536 TEST_F(ScrollAnchorTest, FlexboxDelayedAdjustmentRespectsSANACLAP) |
| 537 { |
| 538 setBodyInnerHTML( |
| 539 "<style>" |
| 540 " html { overflow: hidden; }" |
| 541 " body {" |
| 542 " position: absolute; display: flex;" |
| 543 " top: 0; bottom: 0; margin: 0;" |
| 544 " }" |
| 545 " #scroller { overflow: auto; }" |
| 546 " #spacer { width: 600px; height: 1200px; }" |
| 547 " #anchor {" |
| 548 " position: relative; top: 50px;" |
| 549 " width: 100px; height: 100px;" |
| 550 " background-color: #8f8;" |
| 551 " }" |
| 552 "</style>" |
| 553 "<div id='scroller'>" |
| 554 " <div id='spacer'>" |
| 555 " <div id='anchor'></div>" |
| 556 " </div>" |
| 557 "</div>"); |
| 558 |
| 559 Element* scroller = document().getElementById("scroller"); |
| 560 scroller->setScrollTop(100); |
| 561 |
| 562 document().getElementById("spacer")->setAttribute( |
| 563 HTMLNames::styleAttr, "margin-top: 50px"); |
| 564 update(); |
| 565 EXPECT_EQ(100, scrollerForElement(scroller)->scrollPosition().y()); |
| 566 } |
| 567 |
| 536 // Test then an element and its children are not selected as the anchor when | 568 // Test then an element and its children are not selected as the anchor when |
| 537 // it has the overflow-anchor property set to none. | 569 // it has the overflow-anchor property set to none. |
| 538 TEST_F(ScrollAnchorTest, OptOutElement) | 570 TEST_F(ScrollAnchorTest, OptOutElement) |
| 539 { | 571 { |
| 540 setBodyInnerHTML( | 572 setBodyInnerHTML( |
| 541 "<style>" | 573 "<style>" |
| 542 " body { height: 1000px }" | 574 " body { height: 1000px }" |
| 543 " .div {" | 575 " .div {" |
| 544 " height: 100px; width: 100px;" | 576 " height: 100px; width: 100px;" |
| 545 " border: 1px solid gray; background-color: #afa;" | 577 " border: 1px solid gray; background-color: #afa;" |
| (...skipping 251 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 797 " #a { width: 400px; height: 300px; }" | 829 " #a { width: 400px; height: 300px; }" |
| 798 " .change { width: 100px; }" | 830 " .change { width: 100px; }" |
| 799 "</style>" | 831 "</style>" |
| 800 "<div id='changer'></div>" | 832 "<div id='changer'></div>" |
| 801 "<div id='a'></div>"); | 833 "<div id='a'></div>"); |
| 802 | 834 |
| 803 checkCorner(Corner::TopRight, DoublePoint(-20, 20), DoubleSize(-100, 0)); | 835 checkCorner(Corner::TopRight, DoublePoint(-20, 20), DoubleSize(-100, 0)); |
| 804 } | 836 } |
| 805 | 837 |
| 806 } | 838 } |
| OLD | NEW |