OLD | NEW |
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 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 "components/printing/renderer/print_web_view_helper.h" | 5 #include "components/printing/renderer/print_web_view_helper.h" |
6 | 6 |
7 #import <AppKit/AppKit.h> | 7 #import <AppKit/AppKit.h> |
8 | 8 |
9 #include "base/logging.h" | 9 #include "base/logging.h" |
10 #include "base/mac/scoped_nsautorelease_pool.h" | 10 #include "base/mac/scoped_nsautorelease_pool.h" |
11 #include "base/metrics/histogram.h" | 11 #include "base/metrics/histogram.h" |
12 #include "components/printing/common/print_messages.h" | 12 #include "components/printing/common/print_messages.h" |
13 #include "printing/metafile_skia_wrapper.h" | 13 #include "printing/metafile_skia_wrapper.h" |
14 #include "printing/page_size_margins.h" | 14 #include "printing/page_size_margins.h" |
15 #include "skia/ext/platform_device.h" | 15 #include "skia/ext/platform_device.h" |
16 #include "skia/ext/vector_canvas.h" | |
17 #include "third_party/WebKit/public/platform/WebCanvas.h" | 16 #include "third_party/WebKit/public/platform/WebCanvas.h" |
18 #include "third_party/WebKit/public/web/WebLocalFrame.h" | 17 #include "third_party/WebKit/public/web/WebLocalFrame.h" |
19 | 18 |
20 namespace printing { | 19 namespace printing { |
21 | 20 |
22 using blink::WebFrame; | 21 using blink::WebFrame; |
23 | 22 |
24 void PrintWebViewHelper::PrintPageInternal( | 23 void PrintWebViewHelper::PrintPageInternal( |
25 const PrintMsg_PrintPage_Params& params, | 24 const PrintMsg_PrintPage_Params& params, |
26 WebFrame* frame) { | 25 WebFrame* frame) { |
(...skipping 84 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
111 &content_area); | 110 &content_area); |
112 if (content_rect) | 111 if (content_rect) |
113 *content_rect = content_area; | 112 *content_rect = content_area; |
114 | 113 |
115 scale_factor *= webkit_shrink_factor; | 114 scale_factor *= webkit_shrink_factor; |
116 | 115 |
117 gfx::Rect canvas_area = | 116 gfx::Rect canvas_area = |
118 params.display_header_footer ? gfx::Rect(*page_size) : content_area; | 117 params.display_header_footer ? gfx::Rect(*page_size) : content_area; |
119 | 118 |
120 { | 119 { |
121 skia::VectorCanvas* canvas = metafile->GetVectorCanvasForNewPage( | 120 skia::PlatformCanvas* canvas = metafile->GetVectorCanvasForNewPage( |
122 *page_size, canvas_area, scale_factor); | 121 *page_size, canvas_area, scale_factor); |
123 if (!canvas) | 122 if (!canvas) |
124 return; | 123 return; |
125 | 124 |
126 MetafileSkiaWrapper::SetMetafileOnCanvas(*canvas, metafile); | 125 MetafileSkiaWrapper::SetMetafileOnCanvas(*canvas, metafile); |
127 skia::SetIsDraftMode(*canvas, is_print_ready_metafile_sent_); | 126 skia::SetIsDraftMode(*canvas, is_print_ready_metafile_sent_); |
128 skia::SetIsPreviewMetafile(*canvas, is_preview); | 127 skia::SetIsPreviewMetafile(*canvas, is_preview); |
129 #if defined(ENABLE_PRINT_PREVIEW) | 128 #if defined(ENABLE_PRINT_PREVIEW) |
130 if (params.display_header_footer) { | 129 if (params.display_header_footer) { |
131 PrintHeaderAndFooter(static_cast<blink::WebCanvas*>(canvas), | 130 PrintHeaderAndFooter(static_cast<blink::WebCanvas*>(canvas), |
132 page_number + 1, | 131 page_number + 1, |
133 print_preview_context_.total_page_count(), *frame, | 132 print_preview_context_.total_page_count(), *frame, |
134 scale_factor, page_layout_in_points, params); | 133 scale_factor, page_layout_in_points, params); |
135 } | 134 } |
136 #endif // defined(ENABLE_PRINT_PREVIEW) | 135 #endif // defined(ENABLE_PRINT_PREVIEW) |
137 RenderPageContent(frame, page_number, canvas_area, content_area, | 136 RenderPageContent(frame, page_number, canvas_area, content_area, |
138 scale_factor, static_cast<blink::WebCanvas*>(canvas)); | 137 scale_factor, static_cast<blink::WebCanvas*>(canvas)); |
139 } | 138 } |
140 | 139 |
141 // Done printing. Close the device context to retrieve the compiled metafile. | 140 // Done printing. Close the device context to retrieve the compiled metafile. |
142 metafile->FinishPage(); | 141 metafile->FinishPage(); |
143 } | 142 } |
144 | 143 |
145 } // namespace printing | 144 } // namespace printing |
OLD | NEW |