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

Side by Side Diff: components/printing/renderer/print_web_view_helper_mac.mm

Issue 2686033005: Move metafile printing code from platform canvas to PaintCanvas (Closed)
Patch Set: Fix missing build_config include Created 3 years, 10 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 unified diff | Download patch
OLDNEW
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/features/features.h" 13 #include "printing/features/features.h"
14 #include "printing/metafile_skia_wrapper.h" 14 #include "printing/metafile_skia_wrapper.h"
15 #include "printing/page_size_margins.h" 15 #include "printing/page_size_margins.h"
16 #include "third_party/WebKit/public/platform/WebCanvas.h" 16 #include "third_party/WebKit/public/platform/WebCanvas.h"
17 #include "third_party/WebKit/public/web/WebLocalFrame.h" 17 #include "third_party/WebKit/public/web/WebLocalFrame.h"
18 #include "third_party/skia/include/core/SkCanvas.h"
19 18
20 namespace printing { 19 namespace printing {
21 20
22 #if BUILDFLAG(ENABLE_BASIC_PRINTING) 21 #if BUILDFLAG(ENABLE_BASIC_PRINTING)
23 bool PrintWebViewHelper::PrintPagesNative(blink::WebLocalFrame* frame, 22 bool PrintWebViewHelper::PrintPagesNative(blink::WebLocalFrame* frame,
24 int page_count) { 23 int page_count) {
25 const PrintMsg_PrintPages_Params& params = *print_pages_params_; 24 const PrintMsg_PrintPages_Params& params = *print_pages_params_;
26 const PrintMsg_Print_Params& print_params = params.params; 25 const PrintMsg_Print_Params& print_params = params.params;
27 26
28 std::vector<int> printed_pages = GetPrintedPages(params, page_count); 27 std::vector<int> printed_pages = GetPrintedPages(params, page_count);
(...skipping 99 matching lines...) Expand 10 before | Expand all | Expand 10 after
128 &content_area); 127 &content_area);
129 if (content_rect) 128 if (content_rect)
130 *content_rect = content_area; 129 *content_rect = content_area;
131 130
132 scale_factor *= webkit_shrink_factor; 131 scale_factor *= webkit_shrink_factor;
133 132
134 gfx::Rect canvas_area = 133 gfx::Rect canvas_area =
135 params.display_header_footer ? gfx::Rect(*page_size) : content_area; 134 params.display_header_footer ? gfx::Rect(*page_size) : content_area;
136 135
137 { 136 {
138 SkCanvas* canvas = metafile->GetVectorCanvasForNewPage( 137 cc::PaintCanvas* canvas = metafile->GetVectorCanvasForNewPage(
139 *page_size, canvas_area, scale_factor); 138 *page_size, canvas_area, scale_factor);
140 if (!canvas) 139 if (!canvas)
141 return; 140 return;
142 141
143 MetafileSkiaWrapper::SetMetafileOnCanvas(*canvas, metafile); 142 MetafileSkiaWrapper::SetMetafileOnCanvas(canvas, metafile);
144 skia::SetIsPreviewMetafile(*canvas, is_preview); 143 cc::SetIsPreviewMetafile(canvas, is_preview);
145 #if BUILDFLAG(ENABLE_PRINT_PREVIEW) 144 #if BUILDFLAG(ENABLE_PRINT_PREVIEW)
146 if (params.display_header_footer) { 145 if (params.display_header_footer) {
147 PrintHeaderAndFooter(static_cast<blink::WebCanvas*>(canvas), 146 PrintHeaderAndFooter(static_cast<blink::WebCanvas*>(canvas),
148 page_number + 1, 147 page_number + 1,
149 print_preview_context_.total_page_count(), *frame, 148 print_preview_context_.total_page_count(), *frame,
150 scale_factor, page_layout_in_points, params); 149 scale_factor, page_layout_in_points, params);
151 } 150 }
152 #endif // BUILDFLAG(ENABLE_PRINT_PREVIEW) 151 #endif // BUILDFLAG(ENABLE_PRINT_PREVIEW)
153 RenderPageContent(frame, page_number, canvas_area, content_area, 152 RenderPageContent(frame, page_number, canvas_area, content_area,
154 scale_factor, static_cast<blink::WebCanvas*>(canvas)); 153 scale_factor, static_cast<blink::WebCanvas*>(canvas));
155 } 154 }
156 155
157 // Done printing. Close the device context to retrieve the compiled metafile. 156 // Done printing. Close the device context to retrieve the compiled metafile.
158 metafile->FinishPage(); 157 metafile->FinishPage();
159 } 158 }
160 159
161 } // namespace printing 160 } // namespace printing
OLDNEW
« no previous file with comments | « components/printing/renderer/print_web_view_helper.cc ('k') | content/renderer/pepper/pepper_plugin_instance_impl.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698