| 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 547 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 558 | 558 |
| 559 blink::WebView* FrameReference::view() { | 559 blink::WebView* FrameReference::view() { |
| 560 return view_; | 560 return view_; |
| 561 } | 561 } |
| 562 | 562 |
| 563 // static - Not anonymous so that platform implementations can use it. | 563 // static - Not anonymous so that platform implementations can use it. |
| 564 void PrintWebViewHelper::PrintHeaderAndFooter( | 564 void PrintWebViewHelper::PrintHeaderAndFooter( |
| 565 blink::WebCanvas* canvas, | 565 blink::WebCanvas* canvas, |
| 566 int page_number, | 566 int page_number, |
| 567 int total_pages, | 567 int total_pages, |
| 568 const blink::WebFrame& source_frame, | 568 const blink::WebLocalFrame& source_frame, |
| 569 float webkit_scale_factor, | 569 float webkit_scale_factor, |
| 570 const PageSizeMargins& page_layout, | 570 const PageSizeMargins& page_layout, |
| 571 const PrintMsg_Print_Params& params) { | 571 const PrintMsg_Print_Params& params) { |
| 572 cc::PaintCanvasAutoRestore auto_restore(canvas, true); | 572 cc::PaintCanvasAutoRestore auto_restore(canvas, true); |
| 573 canvas->scale(1 / webkit_scale_factor, 1 / webkit_scale_factor); | 573 canvas->scale(1 / webkit_scale_factor, 1 / webkit_scale_factor); |
| 574 | 574 |
| 575 blink::WebSize page_size(page_layout.margin_left + page_layout.margin_right + | 575 blink::WebSize page_size(page_layout.margin_left + page_layout.margin_right + |
| 576 page_layout.content_width, | 576 page_layout.content_width, |
| 577 page_layout.margin_top + page_layout.margin_bottom + | 577 page_layout.margin_top + page_layout.margin_bottom + |
| 578 page_layout.content_height); | 578 page_layout.content_height); |
| (...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 613 webkit_params.printer_dpi = GetDPI(¶ms); | 613 webkit_params.printer_dpi = GetDPI(¶ms); |
| 614 | 614 |
| 615 frame->PrintBegin(webkit_params); | 615 frame->PrintBegin(webkit_params); |
| 616 frame->PrintPage(0, canvas); | 616 frame->PrintPage(0, canvas); |
| 617 frame->PrintEnd(); | 617 frame->PrintEnd(); |
| 618 | 618 |
| 619 web_view->Close(); | 619 web_view->Close(); |
| 620 } | 620 } |
| 621 | 621 |
| 622 // static - Not anonymous so that platform implementations can use it. | 622 // static - Not anonymous so that platform implementations can use it. |
| 623 float PrintWebViewHelper::RenderPageContent(blink::WebFrame* frame, | 623 float PrintWebViewHelper::RenderPageContent(blink::WebLocalFrame* frame, |
| 624 int page_number, | 624 int page_number, |
| 625 const gfx::Rect& canvas_area, | 625 const gfx::Rect& canvas_area, |
| 626 const gfx::Rect& content_area, | 626 const gfx::Rect& content_area, |
| 627 double scale_factor, | 627 double scale_factor, |
| 628 blink::WebCanvas* canvas) { | 628 blink::WebCanvas* canvas) { |
| 629 cc::PaintCanvasAutoRestore auto_restore(canvas, true); | 629 cc::PaintCanvasAutoRestore auto_restore(canvas, true); |
| 630 canvas->translate((content_area.x() - canvas_area.x()) / scale_factor, | 630 canvas->translate((content_area.x() - canvas_area.x()) / scale_factor, |
| 631 (content_area.y() - canvas_area.y()) / scale_factor); | 631 (content_area.y() - canvas_area.y()) / scale_factor); |
| 632 return frame->PrintPage(page_number, canvas); | 632 return frame->PrintPage(page_number, canvas); |
| 633 } | 633 } |
| (...skipping 1745 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2379 blink::WebConsoleMessage::kLevelWarning, message)); | 2379 blink::WebConsoleMessage::kLevelWarning, message)); |
| 2380 return false; | 2380 return false; |
| 2381 } | 2381 } |
| 2382 | 2382 |
| 2383 void PrintWebViewHelper::ScriptingThrottler::Reset() { | 2383 void PrintWebViewHelper::ScriptingThrottler::Reset() { |
| 2384 // Reset counter on successful print. | 2384 // Reset counter on successful print. |
| 2385 count_ = 0; | 2385 count_ = 0; |
| 2386 } | 2386 } |
| 2387 | 2387 |
| 2388 } // namespace printing | 2388 } // namespace printing |
| OLD | NEW |