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

Side by Side Diff: third_party/WebKit/Source/core/page/PrintContextTest.cpp

Issue 1506053004: Revert of Fix incorrect sign in scroll and content box offset in absoluteToLocalPoint. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 5 years 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/compositing/CompositedLayerMappingTest.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 2014 The Chromium Authors. All rights reserved. 1 // Copyright 2014 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 "config.h" 5 #include "config.h"
6 #include "core/page/PrintContext.h" 6 #include "core/page/PrintContext.h"
7 7
8 #include "core/dom/Document.h" 8 #include "core/dom/Document.h"
9 9
10 #include "core/frame/FrameView.h" 10 #include "core/frame/FrameView.h"
11 #include "core/html/HTMLElement.h" 11 #include "core/html/HTMLElement.h"
12 #include "core/html/HTMLIFrameElement.h"
12 #include "core/layout/LayoutTestHelper.h" 13 #include "core/layout/LayoutTestHelper.h"
13 #include "core/layout/LayoutView.h" 14 #include "core/layout/LayoutView.h"
15 #include "core/loader/EmptyClients.h"
14 #include "core/paint/PaintLayer.h" 16 #include "core/paint/PaintLayer.h"
15 #include "core/paint/PaintLayerPainter.h" 17 #include "core/paint/PaintLayerPainter.h"
16 #include "core/testing/DummyPageHolder.h" 18 #include "core/testing/DummyPageHolder.h"
17 #include "platform/graphics/GraphicsContext.h" 19 #include "platform/graphics/GraphicsContext.h"
18 #include "platform/graphics/paint/SkPictureBuilder.h" 20 #include "platform/graphics/paint/SkPictureBuilder.h"
19 #include "platform/scroll/ScrollbarTheme.h" 21 #include "platform/scroll/ScrollbarTheme.h"
20 #include "platform/testing/SkiaForCoreTesting.h" 22 #include "platform/testing/SkiaForCoreTesting.h"
21 #include "platform/text/TextStream.h" 23 #include "platform/text/TextStream.h"
22 #include "testing/gtest/include/gtest/gtest.h" 24 #include "testing/gtest/include/gtest/gtest.h"
23 25
(...skipping 222 matching lines...) Expand 10 before | Expand all | Expand 10 after
246 } 248 }
247 249
248 TEST_F(PrintContextFrameTest, WithSubframe) 250 TEST_F(PrintContextFrameTest, WithSubframe)
249 { 251 {
250 MockCanvas canvas; 252 MockCanvas canvas;
251 document().setBaseURLOverride(KURL(ParsedURLString, "http://a.com/")); 253 document().setBaseURLOverride(KURL(ParsedURLString, "http://a.com/"));
252 setBodyInnerHTML("<style>::-webkit-scrollbar { display: none }</style>" 254 setBodyInnerHTML("<style>::-webkit-scrollbar { display: none }</style>"
253 "<iframe id='frame' src='http://b.com/' width='500' height='500'" 255 "<iframe id='frame' src='http://b.com/' width='500' height='500'"
254 " style='border-width: 5px; margin: 5px; position: absolute; top: 90px; left: 90px'></iframe>"); 256 " style='border-width: 5px; margin: 5px; position: absolute; top: 90px; left: 90px'></iframe>");
255 257
256 setupChildIframe("frame", absoluteBlockHtmlForLink(50, 60, 70, 80, "#fragmen t") 258 HTMLIFrameElement& iframe = *toHTMLIFrameElement(document().getElementById(" frame"));
259 OwnPtrWillBeRawPtr<FrameLoaderClient> frameLoaderClient = FrameLoaderClientW ithParent::create(document().frame());
260 RefPtrWillBePersistent<LocalFrame> subframe = LocalFrame::create(frameLoader Client.get(), document().frame()->host(), &iframe);
261 subframe->setView(FrameView::create(subframe.get(), IntSize(500, 500)));
262 subframe->init();
263 static_cast<SingleChildFrameLoaderClient*>(document().frame()->client())->se tChild(subframe.get());
264 document().frame()->host()->incrementSubframeCount();
265
266 Document& frameDocument = *iframe.contentDocument();
267 frameDocument.setBaseURLOverride(KURL(ParsedURLString, "http://b.com/"));
268 frameDocument.body()->setInnerHTML(absoluteBlockHtmlForLink(50, 60, 70, 80, "#fragment")
257 + absoluteBlockHtmlForLink(150, 160, 170, 180, "http://www.google.com") 269 + absoluteBlockHtmlForLink(150, 160, 170, 180, "http://www.google.com")
258 + absoluteBlockHtmlForLink(250, 260, 270, 280, "http://www.google.com#fr agment")); 270 + absoluteBlockHtmlForLink(250, 260, 270, 280, "http://www.google.com#fr agment"),
271 ASSERT_NO_EXCEPTION);
259 272
260 printSinglePage(canvas); 273 printSinglePage(canvas);
261 274
262 const Vector<MockCanvas::Operation>& operations = canvas.recordedOperations( ); 275 const Vector<MockCanvas::Operation>& operations = canvas.recordedOperations( );
263 ASSERT_EQ(2u, operations.size()); 276 ASSERT_EQ(2u, operations.size());
264 EXPECT_EQ(MockCanvas::DrawRect, operations[0].type); 277 EXPECT_EQ(MockCanvas::DrawRect, operations[0].type);
265 EXPECT_SKRECT_EQ(250, 260, 170, 180, operations[0].rect); 278 EXPECT_SKRECT_EQ(250, 260, 170, 180, operations[0].rect);
266 EXPECT_EQ(MockCanvas::DrawRect, operations[1].type); 279 EXPECT_EQ(MockCanvas::DrawRect, operations[1].type);
267 EXPECT_SKRECT_EQ(350, 360, 270, 280, operations[1].rect); 280 EXPECT_SKRECT_EQ(350, 360, 270, 280, operations[1].rect);
281
282 subframe->detach(FrameDetachType::Remove);
283 static_cast<SingleChildFrameLoaderClient*>(document().frame()->client())->se tChild(nullptr);
284 document().frame()->host()->decrementSubframeCount();
268 } 285 }
269 286
270 TEST_F(PrintContextFrameTest, WithScrolledSubframe) 287 TEST_F(PrintContextFrameTest, WithScrolledSubframe)
271 { 288 {
272 MockCanvas canvas; 289 MockCanvas canvas;
273 document().setBaseURLOverride(KURL(ParsedURLString, "http://a.com/")); 290 document().setBaseURLOverride(KURL(ParsedURLString, "http://a.com/"));
274 setBodyInnerHTML("<style>::-webkit-scrollbar { display: none }</style>" 291 setBodyInnerHTML("<style>::-webkit-scrollbar { display: none }</style>"
275 "<iframe id='frame' src='http://b.com/' width='500' height='500'" 292 "<iframe id='frame' src='http://b.com/' width='500' height='500'"
276 " style='border-width: 5px; margin: 5px; position: absolute; top: 90px; left: 90px'></iframe>"); 293 " style='border-width: 5px; margin: 5px; position: absolute; top: 90px; left: 90px'></iframe>");
277 294
278 Document& frameDocument = setupChildIframe("frame", absoluteBlockHtmlForLink (10, 10, 20, 20, "http://invisible.com") 295 HTMLIFrameElement& iframe = *toHTMLIFrameElement(document().getElementById(" frame"));
296 OwnPtrWillBeRawPtr<FrameLoaderClient> frameLoaderClient = FrameLoaderClientW ithParent::create(document().frame());
297 RefPtrWillBePersistent<LocalFrame> subframe = LocalFrame::create(frameLoader Client.get(), document().frame()->host(), &iframe);
298 subframe->setView(FrameView::create(subframe.get(), IntSize(500, 500)));
299 subframe->init();
300 static_cast<SingleChildFrameLoaderClient*>(document().frame()->client())->se tChild(subframe.get());
301 document().frame()->host()->incrementSubframeCount();
302
303 Document& frameDocument = *iframe.contentDocument();
304 frameDocument.setBaseURLOverride(KURL(ParsedURLString, "http://b.com/"));
305 frameDocument.body()->setInnerHTML(
306 absoluteBlockHtmlForLink(10, 10, 20, 20, "http://invisible.com")
279 + absoluteBlockHtmlForLink(50, 60, 70, 80, "http://partly.visible.com") 307 + absoluteBlockHtmlForLink(50, 60, 70, 80, "http://partly.visible.com")
280 + absoluteBlockHtmlForLink(150, 160, 170, 180, "http://www.google.com") 308 + absoluteBlockHtmlForLink(150, 160, 170, 180, "http://www.google.com")
281 + absoluteBlockHtmlForLink(250, 260, 270, 280, "http://www.google.com#fr agment") 309 + absoluteBlockHtmlForLink(250, 260, 270, 280, "http://www.google.com#fr agment")
282 + absoluteBlockHtmlForLink(850, 860, 70, 80, "http://another.invisible.c om")); 310 + absoluteBlockHtmlForLink(850, 860, 70, 80, "http://another.invisible.c om"),
283 311 ASSERT_NO_EXCEPTION);
284 frameDocument.domWindow()->scrollTo(100, 100); 312 iframe.contentWindow()->scrollTo(100, 100);
285 313
286 printSinglePage(canvas); 314 printSinglePage(canvas);
287 315
288 const Vector<MockCanvas::Operation>& operations = canvas.recordedOperations( ); 316 const Vector<MockCanvas::Operation>& operations = canvas.recordedOperations( );
289 ASSERT_EQ(3u, operations.size()); 317 ASSERT_EQ(3u, operations.size());
290 EXPECT_EQ(MockCanvas::DrawRect, operations[0].type); 318 EXPECT_EQ(MockCanvas::DrawRect, operations[0].type);
291 EXPECT_SKRECT_EQ(50, 60, 70, 80, operations[0].rect); // FIXME: the rect sho uld be clipped. 319 EXPECT_SKRECT_EQ(50, 60, 70, 80, operations[0].rect); // FIXME: the rect sho uld be clipped.
292 EXPECT_EQ(MockCanvas::DrawRect, operations[1].type); 320 EXPECT_EQ(MockCanvas::DrawRect, operations[1].type);
293 EXPECT_SKRECT_EQ(150, 160, 170, 180, operations[1].rect); 321 EXPECT_SKRECT_EQ(150, 160, 170, 180, operations[1].rect);
294 EXPECT_EQ(MockCanvas::DrawRect, operations[2].type); 322 EXPECT_EQ(MockCanvas::DrawRect, operations[2].type);
295 EXPECT_SKRECT_EQ(250, 260, 270, 280, operations[2].rect); 323 EXPECT_SKRECT_EQ(250, 260, 270, 280, operations[2].rect);
324
325 subframe->detach(FrameDetachType::Remove);
326 static_cast<SingleChildFrameLoaderClient*>(document().frame()->client())->se tChild(nullptr);
327 document().frame()->host()->decrementSubframeCount();
296 } 328 }
297 329
298 } // namespace blink 330 } // namespace blink
OLDNEW
« no previous file with comments | « third_party/WebKit/Source/core/layout/compositing/CompositedLayerMappingTest.cpp ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698