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

Side by Side Diff: android_webview/renderer/print_web_view_helper.cc

Issue 704813002: PdfMetafileSkia gives out a SkCanvas, not a SkBaseDevice. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: rebase Created 6 years, 1 month 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
« no previous file with comments | « no previous file | android_webview/renderer/print_web_view_helper_linux.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2013 The Chromium Authors. All rights reserved. 1 // Copyright 2013 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 // TODO(sgurun) copied from chrome/renderer. Remove after crbug.com/322276 5 // TODO(sgurun) copied from chrome/renderer. Remove after crbug.com/322276
6 6
7 #include "android_webview/renderer/print_web_view_helper.h" 7 #include "android_webview/renderer/print_web_view_helper.h"
8 8
9 #include <string> 9 #include <string>
10 10
11 #include "android_webview/common/print_messages.h" 11 #include "android_webview/common/print_messages.h"
12 #include "base/auto_reset.h" 12 #include "base/auto_reset.h"
13 #include "base/command_line.h" 13 #include "base/command_line.h"
14 #include "base/json/json_writer.h" 14 #include "base/json/json_writer.h"
15 #include "base/logging.h" 15 #include "base/logging.h"
16 #include "base/message_loop/message_loop.h" 16 #include "base/message_loop/message_loop.h"
17 #include "base/metrics/histogram.h" 17 #include "base/metrics/histogram.h"
18 #include "base/process/process_handle.h" 18 #include "base/process/process_handle.h"
19 #include "base/strings/string_number_conversions.h" 19 #include "base/strings/string_number_conversions.h"
20 #include "base/strings/stringprintf.h" 20 #include "base/strings/stringprintf.h"
21 #include "base/strings/utf_string_conversions.h" 21 #include "base/strings/utf_string_conversions.h"
22 #include "content/public/common/web_preferences.h" 22 #include "content/public/common/web_preferences.h"
23 #include "content/public/renderer/render_thread.h" 23 #include "content/public/renderer/render_thread.h"
24 #include "content/public/renderer/render_view.h" 24 #include "content/public/renderer/render_view.h"
25 #include "net/base/escape.h" 25 #include "net/base/escape.h"
26 #include "printing/pdf_metafile_skia.h" 26 #include "printing/pdf_metafile_skia.h"
27 #include "printing/units.h" 27 #include "printing/units.h"
28 #include "skia/ext/vector_platform_device_skia.h"
29 #include "third_party/WebKit/public/platform/WebSize.h" 28 #include "third_party/WebKit/public/platform/WebSize.h"
30 #include "third_party/WebKit/public/platform/WebURLRequest.h" 29 #include "third_party/WebKit/public/platform/WebURLRequest.h"
31 #include "third_party/WebKit/public/web/WebConsoleMessage.h" 30 #include "third_party/WebKit/public/web/WebConsoleMessage.h"
32 #include "third_party/WebKit/public/web/WebDocument.h" 31 #include "third_party/WebKit/public/web/WebDocument.h"
33 #include "third_party/WebKit/public/web/WebElement.h" 32 #include "third_party/WebKit/public/web/WebElement.h"
34 #include "third_party/WebKit/public/web/WebFrameClient.h" 33 #include "third_party/WebKit/public/web/WebFrameClient.h"
35 #include "third_party/WebKit/public/web/WebLocalFrame.h" 34 #include "third_party/WebKit/public/web/WebLocalFrame.h"
36 #include "third_party/WebKit/public/web/WebPlugin.h" 35 #include "third_party/WebKit/public/web/WebPlugin.h"
37 #include "third_party/WebKit/public/web/WebPluginDocument.h" 36 #include "third_party/WebKit/public/web/WebPluginDocument.h"
38 #include "third_party/WebKit/public/web/WebPrintParams.h" 37 #include "third_party/WebKit/public/web/WebPrintParams.h"
(...skipping 380 matching lines...) Expand 10 before | Expand all | Expand 10 after
419 void PrintWebViewHelper::PrintHeaderAndFooter( 418 void PrintWebViewHelper::PrintHeaderAndFooter(
420 blink::WebCanvas* canvas, 419 blink::WebCanvas* canvas,
421 int page_number, 420 int page_number,
422 int total_pages, 421 int total_pages,
423 float webkit_scale_factor, 422 float webkit_scale_factor,
424 const PageSizeMargins& page_layout, 423 const PageSizeMargins& page_layout,
425 const base::DictionaryValue& header_footer_info, 424 const base::DictionaryValue& header_footer_info,
426 const PrintMsg_Print_Params& params) { 425 const PrintMsg_Print_Params& params) {
427 #if 0 426 #if 0
428 // TODO(sgurun) android_webview hack 427 // TODO(sgurun) android_webview hack
429 skia::VectorPlatformDeviceSkia* device =
430 static_cast<skia::VectorPlatformDeviceSkia*>(canvas->getTopDevice());
431 device->setDrawingArea(SkPDFDevice::kMargin_DrawingArea);
432
433 SkAutoCanvasRestore auto_restore(canvas, true); 428 SkAutoCanvasRestore auto_restore(canvas, true);
434 canvas->scale(1 / webkit_scale_factor, 1 / webkit_scale_factor); 429 canvas->scale(1 / webkit_scale_factor, 1 / webkit_scale_factor);
435 430
436 blink::WebSize page_size(page_layout.margin_left + page_layout.margin_right + 431 blink::WebSize page_size(page_layout.margin_left + page_layout.margin_right +
437 page_layout.content_width, 432 page_layout.content_width,
438 page_layout.margin_top + page_layout.margin_bottom + 433 page_layout.margin_top + page_layout.margin_bottom +
439 page_layout.content_height); 434 page_layout.content_height);
440 435
441 blink::WebView* web_view = blink::WebView::create(NULL); 436 blink::WebView* web_view = blink::WebView::create(NULL);
442 web_view->settings()->setJavaScriptEnabled(true); 437 web_view->settings()->setJavaScriptEnabled(true);
(...skipping 18 matching lines...) Expand all
461 456
462 blink::WebPrintParams webkit_params(page_size); 457 blink::WebPrintParams webkit_params(page_size);
463 webkit_params.printerDPI = GetDPI(&params); 458 webkit_params.printerDPI = GetDPI(&params);
464 459
465 frame->printBegin(webkit_params, WebKit::WebNode(), NULL); 460 frame->printBegin(webkit_params, WebKit::WebNode(), NULL);
466 frame->printPage(0, canvas); 461 frame->printPage(0, canvas);
467 frame->printEnd(); 462 frame->printEnd();
468 463
469 web_view->close(); 464 web_view->close();
470 frame->close(); 465 frame->close();
471
472 device->setDrawingArea(SkPDFDevice::kContent_DrawingArea);
473 #endif 466 #endif
474 } 467 }
475 468
476 // static - Not anonymous so that platform implementations can use it. 469 // static - Not anonymous so that platform implementations can use it.
477 float PrintWebViewHelper::RenderPageContent(blink::WebFrame* frame, 470 float PrintWebViewHelper::RenderPageContent(blink::WebFrame* frame,
478 int page_number, 471 int page_number,
479 const gfx::Rect& canvas_area, 472 const gfx::Rect& canvas_area,
480 const gfx::Rect& content_area, 473 const gfx::Rect& content_area,
481 double scale_factor, 474 double scale_factor,
482 blink::WebCanvas* canvas) { 475 blink::WebCanvas* canvas) {
(...skipping 1532 matching lines...) Expand 10 before | Expand all | Expand 10 after
2015 } 2008 }
2016 2009
2017 void PrintWebViewHelper::PrintPreviewContext::ClearContext() { 2010 void PrintWebViewHelper::PrintPreviewContext::ClearContext() {
2018 prep_frame_view_.reset(); 2011 prep_frame_view_.reset();
2019 metafile_.reset(); 2012 metafile_.reset();
2020 pages_to_render_.clear(); 2013 pages_to_render_.clear();
2021 error_ = PREVIEW_ERROR_NONE; 2014 error_ = PREVIEW_ERROR_NONE;
2022 } 2015 }
2023 2016
2024 } // namespace printing 2017 } // namespace printing
OLDNEW
« no previous file with comments | « no previous file | android_webview/renderer/print_web_view_helper_linux.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698