| 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 #include <stddef.h> | 7 #include <stddef.h> |
| 8 #include <stdint.h> | 8 #include <stdint.h> |
| 9 | 9 |
| 10 #include <algorithm> | 10 #include <algorithm> |
| (...skipping 555 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 566 #if BUILDFLAG(ENABLE_PRINT_PREVIEW) | 566 #if BUILDFLAG(ENABLE_PRINT_PREVIEW) |
| 567 // static - Not anonymous so that platform implementations can use it. | 567 // static - Not anonymous so that platform implementations can use it. |
| 568 void PrintWebViewHelper::PrintHeaderAndFooter( | 568 void PrintWebViewHelper::PrintHeaderAndFooter( |
| 569 blink::WebCanvas* canvas, | 569 blink::WebCanvas* canvas, |
| 570 int page_number, | 570 int page_number, |
| 571 int total_pages, | 571 int total_pages, |
| 572 const blink::WebFrame& source_frame, | 572 const blink::WebFrame& source_frame, |
| 573 float webkit_scale_factor, | 573 float webkit_scale_factor, |
| 574 const PageSizeMargins& page_layout, | 574 const PageSizeMargins& page_layout, |
| 575 const PrintMsg_Print_Params& params) { | 575 const PrintMsg_Print_Params& params) { |
| 576 SkAutoCanvasRestore auto_restore(canvas, true); | 576 cc::PaintCanvasAutoRestore auto_restore(canvas, true); |
| 577 canvas->scale(1 / webkit_scale_factor, 1 / webkit_scale_factor); | 577 canvas->scale(1 / webkit_scale_factor, 1 / webkit_scale_factor); |
| 578 | 578 |
| 579 blink::WebSize page_size(page_layout.margin_left + page_layout.margin_right + | 579 blink::WebSize page_size(page_layout.margin_left + page_layout.margin_right + |
| 580 page_layout.content_width, | 580 page_layout.content_width, |
| 581 page_layout.margin_top + page_layout.margin_bottom + | 581 page_layout.margin_top + page_layout.margin_bottom + |
| 582 page_layout.content_height); | 582 page_layout.content_height); |
| 583 | 583 |
| 584 blink::WebView* web_view = | 584 blink::WebView* web_view = |
| 585 blink::WebView::create(nullptr, blink::WebPageVisibilityStateVisible); | 585 blink::WebView::create(nullptr, blink::WebPageVisibilityStateVisible); |
| 586 web_view->settings()->setJavaScriptEnabled(true); | 586 web_view->settings()->setJavaScriptEnabled(true); |
| (...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 623 } | 623 } |
| 624 #endif // BUILDFLAG(ENABLE_PRINT_PREVIEW) | 624 #endif // BUILDFLAG(ENABLE_PRINT_PREVIEW) |
| 625 | 625 |
| 626 // static - Not anonymous so that platform implementations can use it. | 626 // static - Not anonymous so that platform implementations can use it. |
| 627 float PrintWebViewHelper::RenderPageContent(blink::WebFrame* frame, | 627 float PrintWebViewHelper::RenderPageContent(blink::WebFrame* frame, |
| 628 int page_number, | 628 int page_number, |
| 629 const gfx::Rect& canvas_area, | 629 const gfx::Rect& canvas_area, |
| 630 const gfx::Rect& content_area, | 630 const gfx::Rect& content_area, |
| 631 double scale_factor, | 631 double scale_factor, |
| 632 blink::WebCanvas* canvas) { | 632 blink::WebCanvas* canvas) { |
| 633 SkAutoCanvasRestore auto_restore(canvas, true); | 633 cc::PaintCanvasAutoRestore auto_restore(canvas, true); |
| 634 canvas->translate((content_area.x() - canvas_area.x()) / scale_factor, | 634 canvas->translate((content_area.x() - canvas_area.x()) / scale_factor, |
| 635 (content_area.y() - canvas_area.y()) / scale_factor); | 635 (content_area.y() - canvas_area.y()) / scale_factor); |
| 636 return frame->printPage(page_number, canvas); | 636 return frame->printPage(page_number, canvas); |
| 637 } | 637 } |
| 638 | 638 |
| 639 // Class that calls the Begin and End print functions on the frame and changes | 639 // Class that calls the Begin and End print functions on the frame and changes |
| 640 // the size of the view temporarily to support full page printing.. | 640 // the size of the view temporarily to support full page printing.. |
| 641 class PrepareFrameAndViewForPrint : public blink::WebViewClient, | 641 class PrepareFrameAndViewForPrint : public blink::WebViewClient, |
| 642 public blink::WebFrameClient { | 642 public blink::WebFrameClient { |
| 643 public: | 643 public: |
| (...skipping 1724 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2368 blink::WebConsoleMessage::LevelWarning, message)); | 2368 blink::WebConsoleMessage::LevelWarning, message)); |
| 2369 return false; | 2369 return false; |
| 2370 } | 2370 } |
| 2371 | 2371 |
| 2372 void PrintWebViewHelper::ScriptingThrottler::Reset() { | 2372 void PrintWebViewHelper::ScriptingThrottler::Reset() { |
| 2373 // Reset counter on successful print. | 2373 // Reset counter on successful print. |
| 2374 count_ = 0; | 2374 count_ = 0; |
| 2375 } | 2375 } |
| 2376 | 2376 |
| 2377 } // namespace printing | 2377 } // namespace printing |
| OLD | NEW |