| 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_canvas.h" | |
| 16 #include "third_party/WebKit/public/platform/WebCanvas.h" | 15 #include "third_party/WebKit/public/platform/WebCanvas.h" |
| 17 #include "third_party/WebKit/public/web/WebLocalFrame.h" | 16 #include "third_party/WebKit/public/web/WebLocalFrame.h" |
| 17 #include "third_party/skia/include/core/SkCanvas.h" |
| 18 | 18 |
| 19 namespace printing { | 19 namespace printing { |
| 20 | 20 |
| 21 #if defined(ENABLE_BASIC_PRINTING) | 21 #if defined(ENABLE_BASIC_PRINTING) |
| 22 bool PrintWebViewHelper::PrintPagesNative(blink::WebFrame* frame, | 22 bool PrintWebViewHelper::PrintPagesNative(blink::WebFrame* frame, |
| 23 int page_count) { | 23 int page_count) { |
| 24 const PrintMsg_PrintPages_Params& params = *print_pages_params_; | 24 const PrintMsg_PrintPages_Params& params = *print_pages_params_; |
| 25 const PrintMsg_Print_Params& print_params = params.params; | 25 const PrintMsg_Print_Params& print_params = params.params; |
| 26 | 26 |
| 27 std::vector<int> printed_pages = GetPrintedPages(params, page_count); | 27 std::vector<int> printed_pages = GetPrintedPages(params, page_count); |
| (...skipping 103 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 131 &content_area); | 131 &content_area); |
| 132 if (content_rect) | 132 if (content_rect) |
| 133 *content_rect = content_area; | 133 *content_rect = content_area; |
| 134 | 134 |
| 135 scale_factor *= webkit_shrink_factor; | 135 scale_factor *= webkit_shrink_factor; |
| 136 | 136 |
| 137 gfx::Rect canvas_area = | 137 gfx::Rect canvas_area = |
| 138 params.display_header_footer ? gfx::Rect(*page_size) : content_area; | 138 params.display_header_footer ? gfx::Rect(*page_size) : content_area; |
| 139 | 139 |
| 140 { | 140 { |
| 141 skia::PlatformCanvas* canvas = metafile->GetVectorCanvasForNewPage( | 141 SkCanvas* canvas = metafile->GetVectorCanvasForNewPage( |
| 142 *page_size, canvas_area, scale_factor); | 142 *page_size, canvas_area, scale_factor); |
| 143 if (!canvas) | 143 if (!canvas) |
| 144 return; | 144 return; |
| 145 | 145 |
| 146 MetafileSkiaWrapper::SetMetafileOnCanvas(*canvas, metafile); | 146 MetafileSkiaWrapper::SetMetafileOnCanvas(*canvas, metafile); |
| 147 skia::SetIsPreviewMetafile(*canvas, is_preview); | 147 skia::SetIsPreviewMetafile(*canvas, is_preview); |
| 148 #if defined(ENABLE_PRINT_PREVIEW) | 148 #if defined(ENABLE_PRINT_PREVIEW) |
| 149 if (params.display_header_footer) { | 149 if (params.display_header_footer) { |
| 150 PrintHeaderAndFooter(static_cast<blink::WebCanvas*>(canvas), | 150 PrintHeaderAndFooter(static_cast<blink::WebCanvas*>(canvas), |
| 151 page_number + 1, | 151 page_number + 1, |
| 152 print_preview_context_.total_page_count(), *frame, | 152 print_preview_context_.total_page_count(), *frame, |
| 153 scale_factor, page_layout_in_points, params); | 153 scale_factor, page_layout_in_points, params); |
| 154 } | 154 } |
| 155 #endif // defined(ENABLE_PRINT_PREVIEW) | 155 #endif // defined(ENABLE_PRINT_PREVIEW) |
| 156 RenderPageContent(frame, page_number, canvas_area, content_area, | 156 RenderPageContent(frame, page_number, canvas_area, content_area, |
| 157 scale_factor, static_cast<blink::WebCanvas*>(canvas)); | 157 scale_factor, static_cast<blink::WebCanvas*>(canvas)); |
| 158 } | 158 } |
| 159 | 159 |
| 160 // Done printing. Close the device context to retrieve the compiled metafile. | 160 // Done printing. Close the device context to retrieve the compiled metafile. |
| 161 metafile->FinishPage(); | 161 metafile->FinishPage(); |
| 162 } | 162 } |
| 163 | 163 |
| 164 } // namespace printing | 164 } // namespace printing |
| OLD | NEW |