| 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 "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 #include "core/frame/FrameHost.h" | 9 #include "core/frame/FrameHost.h" |
| 10 #include "core/frame/FrameView.h" | 10 #include "core/frame/FrameView.h" |
| (...skipping 13 matching lines...) Expand all Loading... |
| 24 | 24 |
| 25 namespace blink { | 25 namespace blink { |
| 26 | 26 |
| 27 const int kPageWidth = 800; | 27 const int kPageWidth = 800; |
| 28 const int kPageHeight = 600; | 28 const int kPageHeight = 600; |
| 29 | 29 |
| 30 class MockPrintContext : public PrintContext { | 30 class MockPrintContext : public PrintContext { |
| 31 public: | 31 public: |
| 32 MockPrintContext(LocalFrame* frame) : PrintContext(frame) { } | 32 MockPrintContext(LocalFrame* frame) : PrintContext(frame) { } |
| 33 | 33 |
| 34 void outputLinkedDestinations(GraphicsContext& context, const IntRect& pageR
ect) | 34 void outputLinkedDestinations(SkCanvas* canvas, const IntRect& pageRect) |
| 35 { | 35 { |
| 36 PrintContext::outputLinkedDestinations(context, pageRect); | 36 PrintContext::outputLinkedDestinations(canvas, pageRect); |
| 37 } | 37 } |
| 38 }; | 38 }; |
| 39 | 39 |
| 40 class MockCanvas : public SkCanvas { | 40 class MockCanvas : public SkCanvas { |
| 41 public: | 41 public: |
| 42 enum OperationType { | 42 enum OperationType { |
| 43 DrawRect, | 43 DrawRect, |
| 44 DrawPoint | 44 DrawPoint |
| 45 }; | 45 }; |
| 46 | 46 |
| (...skipping 49 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 96 IntRect pageRect(0, 0, kPageWidth, kPageHeight); | 96 IntRect pageRect(0, 0, kPageWidth, kPageHeight); |
| 97 document().view()->updateLayoutAndStyleForPainting(); | 97 document().view()->updateLayoutAndStyleForPainting(); |
| 98 document().setPrinting(true); | 98 document().setPrinting(true); |
| 99 SkPictureBuilder pictureBuilder(pageRect); | 99 SkPictureBuilder pictureBuilder(pageRect); |
| 100 GraphicsContext& context = pictureBuilder.context(); | 100 GraphicsContext& context = pictureBuilder.context(); |
| 101 context.setPrinting(true); | 101 context.setPrinting(true); |
| 102 DeprecatedPaintLayer& rootLayer = *document().view()->layoutView()->laye
r(); | 102 DeprecatedPaintLayer& rootLayer = *document().view()->layoutView()->laye
r(); |
| 103 DeprecatedPaintLayerPaintingInfo paintingInfo(&rootLayer, LayoutRect(pag
eRect), PaintBehaviorNormal, LayoutSize()); | 103 DeprecatedPaintLayerPaintingInfo paintingInfo(&rootLayer, LayoutRect(pag
eRect), PaintBehaviorNormal, LayoutSize()); |
| 104 DeprecatedPaintLayerPainter(rootLayer).paintLayerContents(&context, pain
tingInfo, PaintLayerPaintingCompositingAllPhases); | 104 DeprecatedPaintLayerPainter(rootLayer).paintLayerContents(&context, pain
tingInfo, PaintLayerPaintingCompositingAllPhases); |
| 105 printContext().begin(kPageWidth, kPageHeight); | 105 printContext().begin(kPageWidth, kPageHeight); |
| 106 printContext().outputLinkedDestinations(context, pageRect); | |
| 107 printContext().end(); | 106 printContext().end(); |
| 108 pictureBuilder.endRecording()->playback(&canvas); | 107 pictureBuilder.endRecording()->playback(&canvas); |
| 108 printContext().outputLinkedDestinations(&canvas, pageRect); |
| 109 document().setPrinting(false); | 109 document().setPrinting(false); |
| 110 } | 110 } |
| 111 | 111 |
| 112 static String absoluteBlockHtmlForLink(int x, int y, int width, int height,
const char* url, const char* children = nullptr) | 112 static String absoluteBlockHtmlForLink(int x, int y, int width, int height,
const char* url, const char* children = nullptr) |
| 113 { | 113 { |
| 114 TextStream ts; | 114 TextStream ts; |
| 115 ts << "<a style='position: absolute; left: " << x << "px; top: " << y <<
"px; width: " << width << "px; height: " << height | 115 ts << "<a style='position: absolute; left: " << x << "px; top: " << y <<
"px; width: " << width << "px; height: " << height |
| 116 << "px' href='" << url << "'>" << (children ? children : url) << "</
a>"; | 116 << "px' href='" << url << "'>" << (children ? children : url) << "</
a>"; |
| 117 return ts.release(); | 117 return ts.release(); |
| 118 } | 118 } |
| (...skipping 250 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 369 EXPECT_SKRECT_EQ(150, 160, 170, 180, operations[1].rect); | 369 EXPECT_SKRECT_EQ(150, 160, 170, 180, operations[1].rect); |
| 370 EXPECT_EQ(MockCanvas::DrawRect, operations[2].type); | 370 EXPECT_EQ(MockCanvas::DrawRect, operations[2].type); |
| 371 EXPECT_SKRECT_EQ(250, 260, 270, 280, operations[2].rect); | 371 EXPECT_SKRECT_EQ(250, 260, 270, 280, operations[2].rect); |
| 372 | 372 |
| 373 subframe->detach(); | 373 subframe->detach(); |
| 374 static_cast<SingleChildFrameLoaderClient*>(document().frame()->client())->se
tChild(nullptr); | 374 static_cast<SingleChildFrameLoaderClient*>(document().frame()->client())->se
tChild(nullptr); |
| 375 document().frame()->host()->decrementSubframeCount(); | 375 document().frame()->host()->decrementSubframeCount(); |
| 376 } | 376 } |
| 377 | 377 |
| 378 } // namespace blink | 378 } // namespace blink |
| OLD | NEW |