| OLD | NEW |
| 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 "core/page/PrintContext.h" | 5 #include "core/page/PrintContext.h" |
| 6 | 6 |
| 7 #include "core/dom/Document.h" | 7 #include "core/dom/Document.h" |
| 8 #include "core/frame/FrameView.h" | 8 #include "core/frame/FrameView.h" |
| 9 #include "core/html/HTMLElement.h" | 9 #include "core/html/HTMLElement.h" |
| 10 #include "core/layout/LayoutTestHelper.h" | 10 #include "core/layout/LayoutTestHelper.h" |
| (...skipping 283 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 294 "<img style='width: 200px; height: 100px'>")); | 294 "<img style='width: 200px; height: 100px'>")); |
| 295 printSinglePage(canvas); | 295 printSinglePage(canvas); |
| 296 | 296 |
| 297 const Vector<MockCanvas::Operation>& operations = canvas.recordedOperations(); | 297 const Vector<MockCanvas::Operation>& operations = canvas.recordedOperations(); |
| 298 ASSERT_EQ(1u, operations.size()); | 298 ASSERT_EQ(1u, operations.size()); |
| 299 EXPECT_EQ(MockCanvas::DrawRect, operations[0].type); | 299 EXPECT_EQ(MockCanvas::DrawRect, operations[0].type); |
| 300 EXPECT_SKRECT_EQ(50, 60, 200, 100, operations[0].rect); | 300 EXPECT_SKRECT_EQ(50, 60, 200, 100, operations[0].rect); |
| 301 } | 301 } |
| 302 | 302 |
| 303 TEST_F(PrintContextFrameTest, WithSubframe) { | 303 TEST_F(PrintContextFrameTest, WithSubframe) { |
| 304 MockCanvas canvas; | |
| 305 document().setBaseURLOverride(KURL(ParsedURLString, "http://a.com/")); | 304 document().setBaseURLOverride(KURL(ParsedURLString, "http://a.com/")); |
| 306 setBodyInnerHTML( | 305 setBodyInnerHTML( |
| 307 "<style>::-webkit-scrollbar { display: none }</style>" | 306 "<style>::-webkit-scrollbar { display: none }</style>" |
| 308 "<iframe id='frame' src='http://b.com/' width='500' height='500'" | 307 "<iframe src='http://b.com/' width='500' height='500'" |
| 309 " style='border-width: 5px; margin: 5px; position: absolute; top: 90px; " | 308 " style='border-width: 5px; margin: 5px; position: absolute; top: 90px; " |
| 310 "left: 90px'></iframe>"); | 309 "left: 90px'></iframe>"); |
| 310 setChildFrameHTML( |
| 311 absoluteBlockHtmlForLink(50, 60, 70, 80, "#fragment") + |
| 312 absoluteBlockHtmlForLink(150, 160, 170, 180, "http://www.google.com") + |
| 313 absoluteBlockHtmlForLink(250, 260, 270, 280, |
| 314 "http://www.google.com#fragment")); |
| 311 | 315 |
| 312 setupChildIframe( | 316 MockCanvas canvas; |
| 313 "frame", absoluteBlockHtmlForLink(50, 60, 70, 80, "#fragment") + | |
| 314 absoluteBlockHtmlForLink(150, 160, 170, 180, | |
| 315 "http://www.google.com") + | |
| 316 absoluteBlockHtmlForLink(250, 260, 270, 280, | |
| 317 "http://www.google.com#fragment")); | |
| 318 | |
| 319 printSinglePage(canvas); | 317 printSinglePage(canvas); |
| 320 | 318 |
| 321 const Vector<MockCanvas::Operation>& operations = canvas.recordedOperations(); | 319 const Vector<MockCanvas::Operation>& operations = canvas.recordedOperations(); |
| 322 ASSERT_EQ(2u, operations.size()); | 320 ASSERT_EQ(2u, operations.size()); |
| 323 EXPECT_EQ(MockCanvas::DrawRect, operations[0].type); | 321 EXPECT_EQ(MockCanvas::DrawRect, operations[0].type); |
| 324 EXPECT_SKRECT_EQ(250, 260, 170, 180, operations[0].rect); | 322 EXPECT_SKRECT_EQ(250, 260, 170, 180, operations[0].rect); |
| 325 EXPECT_EQ(MockCanvas::DrawRect, operations[1].type); | 323 EXPECT_EQ(MockCanvas::DrawRect, operations[1].type); |
| 326 EXPECT_SKRECT_EQ(350, 360, 270, 280, operations[1].rect); | 324 EXPECT_SKRECT_EQ(350, 360, 270, 280, operations[1].rect); |
| 327 } | 325 } |
| 328 | 326 |
| 329 TEST_F(PrintContextFrameTest, WithScrolledSubframe) { | 327 TEST_F(PrintContextFrameTest, WithScrolledSubframe) { |
| 330 MockCanvas canvas; | |
| 331 document().setBaseURLOverride(KURL(ParsedURLString, "http://a.com/")); | 328 document().setBaseURLOverride(KURL(ParsedURLString, "http://a.com/")); |
| 332 setBodyInnerHTML( | 329 setBodyInnerHTML( |
| 333 "<style>::-webkit-scrollbar { display: none }</style>" | 330 "<style>::-webkit-scrollbar { display: none }</style>" |
| 334 "<iframe id='frame' src='http://b.com/' width='500' height='500'" | 331 "<iframe src='http://b.com/' width='500' height='500'" |
| 335 " style='border-width: 5px; margin: 5px; position: absolute; top: 90px; " | 332 " style='border-width: 5px; margin: 5px; position: absolute; top: 90px; " |
| 336 "left: 90px'></iframe>"); | 333 "left: 90px'></iframe>"); |
| 334 setChildFrameHTML( |
| 335 absoluteBlockHtmlForLink(10, 10, 20, 20, "http://invisible.com") + |
| 336 absoluteBlockHtmlForLink(50, 60, 70, 80, "http://partly.visible.com") + |
| 337 absoluteBlockHtmlForLink(150, 160, 170, 180, "http://www.google.com") + |
| 338 absoluteBlockHtmlForLink(250, 260, 270, 280, |
| 339 "http://www.google.com#fragment") + |
| 340 absoluteBlockHtmlForLink(850, 860, 70, 80, |
| 341 "http://another.invisible.com")); |
| 337 | 342 |
| 338 Document& frameDocument = setupChildIframe( | 343 childDocument().domWindow()->scrollTo(100, 100); |
| 339 "frame", | |
| 340 absoluteBlockHtmlForLink(10, 10, 20, 20, "http://invisible.com") + | |
| 341 absoluteBlockHtmlForLink(50, 60, 70, 80, | |
| 342 "http://partly.visible.com") + | |
| 343 absoluteBlockHtmlForLink(150, 160, 170, 180, | |
| 344 "http://www.google.com") + | |
| 345 absoluteBlockHtmlForLink(250, 260, 270, 280, | |
| 346 "http://www.google.com#fragment") + | |
| 347 absoluteBlockHtmlForLink(850, 860, 70, 80, | |
| 348 "http://another.invisible.com")); | |
| 349 | 344 |
| 350 frameDocument.domWindow()->scrollTo(100, 100); | 345 MockCanvas canvas; |
| 351 | |
| 352 printSinglePage(canvas); | 346 printSinglePage(canvas); |
| 353 | 347 |
| 354 const Vector<MockCanvas::Operation>& operations = canvas.recordedOperations(); | 348 const Vector<MockCanvas::Operation>& operations = canvas.recordedOperations(); |
| 355 ASSERT_EQ(3u, operations.size()); | 349 ASSERT_EQ(3u, operations.size()); |
| 356 EXPECT_EQ(MockCanvas::DrawRect, operations[0].type); | 350 EXPECT_EQ(MockCanvas::DrawRect, operations[0].type); |
| 357 EXPECT_SKRECT_EQ(50, 60, 70, 80, | 351 EXPECT_SKRECT_EQ(50, 60, 70, 80, |
| 358 operations[0].rect); // FIXME: the rect should be clipped. | 352 operations[0].rect); // FIXME: the rect should be clipped. |
| 359 EXPECT_EQ(MockCanvas::DrawRect, operations[1].type); | 353 EXPECT_EQ(MockCanvas::DrawRect, operations[1].type); |
| 360 EXPECT_SKRECT_EQ(150, 160, 170, 180, operations[1].rect); | 354 EXPECT_SKRECT_EQ(150, 160, 170, 180, operations[1].rect); |
| 361 EXPECT_EQ(MockCanvas::DrawRect, operations[2].type); | 355 EXPECT_EQ(MockCanvas::DrawRect, operations[2].type); |
| 362 EXPECT_SKRECT_EQ(250, 260, 270, 280, operations[2].rect); | 356 EXPECT_SKRECT_EQ(250, 260, 270, 280, operations[2].rect); |
| 363 } | 357 } |
| 364 | 358 |
| 365 } // namespace blink | 359 } // namespace blink |
| OLD | NEW |