Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(229)

Side by Side Diff: third_party/WebKit/Source/core/layout/ScrollAnchorTest.cpp

Issue 2662443003: Fix treatment of layout overflow rect in ScrollAnchor bounds computation. (Closed)
Patch Set: Created 3 years, 10 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « third_party/WebKit/Source/core/layout/ScrollAnchor.cpp ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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 557 matching lines...) Expand 10 before | Expand all | Expand 10 after
568 ScrollableArea* viewport = layoutViewport(); 568 ScrollableArea* viewport = layoutViewport();
569 569
570 scrollLayoutViewport(ScrollOffset(0, 200)); 570 scrollLayoutViewport(ScrollOffset(0, 200));
571 setHeight(document().getElementById("changer"), 200); 571 setHeight(document().getElementById("changer"), 200);
572 572
573 EXPECT_EQ(300, viewport->scrollOffsetInt().height()); 573 EXPECT_EQ(300, viewport->scrollOffsetInt().height());
574 EXPECT_EQ(document().getElementById("bottom")->layoutObject(), 574 EXPECT_EQ(document().getElementById("bottom")->layoutObject(),
575 scrollAnchor(viewport).anchorObject()); 575 scrollAnchor(viewport).anchorObject());
576 } 576 }
577 577
578 // Test that we account for the origin of the layout overflow rect when
579 // computing bounds for possible descent.
580 TEST_P(ScrollAnchorTest, NegativeLayoutOverflow) {
581 setBodyInnerHTML(
582 "<style>"
583 " body { height: 1200px; }"
584 " #header { position: relative; height: 100px; }"
585 " #evil { position: relative; "
586 " top: -900px; height: 1000px; width: 100px; }"
587 " #changer { height: 100px; }"
588 " #anchor { height: 100px; background-color: green }"
589 "</style>"
590 "<div id='header'>"
591 " <div id='evil'></div>"
592 "</div>"
593 "<div id='changer'></div>"
594 "<div id='anchor'></div>");
595
596 ScrollableArea* viewport = layoutViewport();
597
598 scrollLayoutViewport(ScrollOffset(0, 250));
599 setHeight(document().getElementById("changer"), 200);
600 EXPECT_EQ(350, viewport->scrollOffsetInt().height());
601 }
602
578 // Test that we descend into zero-height containers that have floating content. 603 // Test that we descend into zero-height containers that have floating content.
579 TEST_P(ScrollAnchorTest, DescendsIntoContainerWithFloat) { 604 TEST_P(ScrollAnchorTest, DescendsIntoContainerWithFloat) {
580 setBodyInnerHTML( 605 setBodyInnerHTML(
581 "<style>" 606 "<style>"
582 " body { height: 1000; }" 607 " body { height: 1000; }"
583 " #outer { width: 300px; }" 608 " #outer { width: 300px; }"
584 " #outer:after { content: ' '; clear:both; display: table; }" 609 " #outer:after { content: ' '; clear:both; display: table; }"
585 " #float {" 610 " #float {"
586 " float: left; background-color: #ccc;" 611 " float: left; background-color: #ccc;"
587 " height: 500px; width: 100%;" 612 " height: 500px; width: 100%;"
(...skipping 526 matching lines...) Expand 10 before | Expand all | Expand 10 after
1114 1139
1115 scrollLayoutViewport(ScrollOffset(-50, 0)); 1140 scrollLayoutViewport(ScrollOffset(-50, 0));
1116 1141
1117 a->setAttribute(HTMLNames::styleAttr, "width: 200px"); 1142 a->setAttribute(HTMLNames::styleAttr, "width: 200px");
1118 b->setAttribute(HTMLNames::styleAttr, "height: 150px"); 1143 b->setAttribute(HTMLNames::styleAttr, "height: 150px");
1119 update(); 1144 update();
1120 EXPECT_EQ(ScrollOffset(-100, 150), viewport->getScrollOffset()); 1145 EXPECT_EQ(ScrollOffset(-100, 150), viewport->getScrollOffset());
1121 EXPECT_EQ(c->layoutObject(), scrollAnchor(viewport).anchorObject()); 1146 EXPECT_EQ(c->layoutObject(), scrollAnchor(viewport).anchorObject());
1122 } 1147 }
1123 } 1148 }
OLDNEW
« no previous file with comments | « third_party/WebKit/Source/core/layout/ScrollAnchor.cpp ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698