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

Unified Diff: third_party/WebKit/Source/core/layout/ScrollAnchorTest.cpp

Issue 2417683002: Disable scroll anchoring when in printing mode (Closed)
Patch Set: Add comment Created 4 years, 2 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 side-by-side diff with in-line comments
Download patch
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 60e58d7a6f792814e153818b217b46b0f6abb112..9586d14c85969996b3e39b97a83f433529731ea8 100644
--- a/third_party/WebKit/Source/core/layout/ScrollAnchorTest.cpp
+++ b/third_party/WebKit/Source/core/layout/ScrollAnchorTest.cpp
@@ -8,6 +8,7 @@
#include "core/frame/VisualViewport.h"
#include "core/layout/LayoutBox.h"
#include "core/layout/LayoutTestHelper.h"
+#include "core/page/PrintContext.h"
#include "core/paint/PaintLayerScrollableArea.h"
#include "platform/testing/HistogramTester.h"
@@ -841,6 +842,24 @@ TEST_F(ScrollAnchorTest, NonDefaultRootScroller) {
EXPECT_EQ(nullptr, scrollAnchor(layoutViewport()).anchorObject());
}
+// This test verifies that scroll anchoring is disabled when the document is in
+// printing mode.
+TEST_F(ScrollAnchorTest, AnchoringDisabledForPrinting) {
+ setBodyInnerHTML(
+ "<style> body { height: 1000px } div { height: 100px } </style>"
+ "<div id='block1'>abc</div>"
+ "<div id='block2'>def</div>");
+
+ ScrollableArea* viewport = layoutViewport();
+ scrollLayoutViewport(ScrollOffset(0, 150));
+
+ // This will trigger printing and layout.
+ PrintContext::numberOfPages(document().frame(), FloatSize(500, 500));
+
+ EXPECT_EQ(150, viewport->scrollOffsetInt().height());
+ EXPECT_EQ(nullptr, scrollAnchor(viewport).anchorObject());
+}
+
class ScrollAnchorCornerTest : public ScrollAnchorTest {
protected:
void checkCorner(Corner corner,
« no previous file with comments | « third_party/WebKit/Source/core/frame/LocalFrame.cpp ('k') | third_party/WebKit/Source/core/paint/PaintLayerScrollableArea.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698