| 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 543 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 554 ScrollableArea* viewport = layoutViewport(); | 554 ScrollableArea* viewport = layoutViewport(); |
| 555 | 555 |
| 556 scrollLayoutViewport(DoubleSize(0, 200)); | 556 scrollLayoutViewport(DoubleSize(0, 200)); |
| 557 setHeight(document().getElementById("float"), 600); | 557 setHeight(document().getElementById("float"), 600); |
| 558 | 558 |
| 559 EXPECT_EQ(200, viewport->scrollPosition().y()); | 559 EXPECT_EQ(200, viewport->scrollPosition().y()); |
| 560 EXPECT_EQ(document().getElementById("float")->layoutObject(), | 560 EXPECT_EQ(document().getElementById("float")->layoutObject(), |
| 561 scrollAnchor(viewport).anchorObject()); | 561 scrollAnchor(viewport).anchorObject()); |
| 562 } | 562 } |
| 563 | 563 |
| 564 TEST_F(ScrollAnchorTest, FlexboxDelayedClampingAlsoDelaysAdjustment) |
| 565 { |
| 566 setBodyInnerHTML( |
| 567 "<style>" |
| 568 " html { overflow: hidden; }" |
| 569 " body {" |
| 570 " position: absolute; display: flex;" |
| 571 " top: 0; bottom: 0; margin: 0;" |
| 572 " }" |
| 573 " #scroller { overflow: auto; }" |
| 574 " #spacer { width: 600px; height: 1200px; }" |
| 575 " #before { height: 50px; }" |
| 576 " #anchor {" |
| 577 " width: 100px; height: 100px;" |
| 578 " background-color: #8f8;" |
| 579 " }" |
| 580 "</style>" |
| 581 "<div id='scroller'>" |
| 582 " <div id='spacer'>" |
| 583 " <div id='before'></div>" |
| 584 " <div id='anchor'></div>" |
| 585 " </div>" |
| 586 "</div>"); |
| 587 |
| 588 Element* scroller = document().getElementById("scroller"); |
| 589 scroller->setScrollTop(100); |
| 590 |
| 591 setHeight(document().getElementById("before"), 100); |
| 592 EXPECT_EQ(150, scrollerForElement(scroller)->scrollPosition().y()); |
| 593 } |
| 594 |
| 564 // Test then an element and its children are not selected as the anchor when | 595 // Test then an element and its children are not selected as the anchor when |
| 565 // it has the overflow-anchor property set to none. | 596 // it has the overflow-anchor property set to none. |
| 566 TEST_F(ScrollAnchorTest, OptOutElement) | 597 TEST_F(ScrollAnchorTest, OptOutElement) |
| 567 { | 598 { |
| 568 setBodyInnerHTML( | 599 setBodyInnerHTML( |
| 569 "<style>" | 600 "<style>" |
| 570 " body { height: 1000px }" | 601 " body { height: 1000px }" |
| 571 " .div {" | 602 " .div {" |
| 572 " height: 100px; width: 100px;" | 603 " height: 100px; width: 100px;" |
| 573 " border: 1px solid gray; background-color: #afa;" | 604 " border: 1px solid gray; background-color: #afa;" |
| (...skipping 191 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 765 " #a { width: 400px; height: 300px; }" | 796 " #a { width: 400px; height: 300px; }" |
| 766 " .change { width: 100px; }" | 797 " .change { width: 100px; }" |
| 767 "</style>" | 798 "</style>" |
| 768 "<div id='changer'></div>" | 799 "<div id='changer'></div>" |
| 769 "<div id='a'></div>"); | 800 "<div id='a'></div>"); |
| 770 | 801 |
| 771 checkCorner(Corner::TopRight, DoublePoint(-20, 20), DoubleSize(-100, 0)); | 802 checkCorner(Corner::TopRight, DoublePoint(-20, 20), DoubleSize(-100, 0)); |
| 772 } | 803 } |
| 773 | 804 |
| 774 } | 805 } |
| OLD | NEW |