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 "chrome/renderer/printing/print_web_view_helper.h" | 5 #include "chrome/renderer/printing/print_web_view_helper.h" |
6 | 6 |
7 #include <string> | 7 #include <string> |
8 | 8 |
9 #include "base/auto_reset.h" | 9 #include "base/auto_reset.h" |
10 #include "base/command_line.h" | 10 #include "base/command_line.h" |
(...skipping 515 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
526 #endif // defined(ENABLE_PRINT_PREVIEW) | 526 #endif // defined(ENABLE_PRINT_PREVIEW) |
527 | 527 |
528 // static - Not anonymous so that platform implementations can use it. | 528 // static - Not anonymous so that platform implementations can use it. |
529 float PrintWebViewHelper::RenderPageContent(blink::WebFrame* frame, | 529 float PrintWebViewHelper::RenderPageContent(blink::WebFrame* frame, |
530 int page_number, | 530 int page_number, |
531 const gfx::Rect& canvas_area, | 531 const gfx::Rect& canvas_area, |
532 const gfx::Rect& content_area, | 532 const gfx::Rect& content_area, |
533 double scale_factor, | 533 double scale_factor, |
534 blink::WebCanvas* canvas) { | 534 blink::WebCanvas* canvas) { |
535 SkAutoCanvasRestore auto_restore(canvas, true); | 535 SkAutoCanvasRestore auto_restore(canvas, true); |
536 if (content_area != canvas_area) { | 536 canvas->translate((content_area.x() - canvas_area.x()) / scale_factor, |
537 canvas->translate((content_area.x() - canvas_area.x()) / scale_factor, | 537 (content_area.y() - canvas_area.y()) / scale_factor); |
538 (content_area.y() - canvas_area.y()) / scale_factor); | |
539 SkRect clip_rect( | |
540 SkRect::MakeXYWH(content_area.origin().x() / scale_factor, | |
541 content_area.origin().y() / scale_factor, | |
542 content_area.size().width() / scale_factor, | |
543 content_area.size().height() / scale_factor)); | |
544 SkIRect clip_int_rect; | |
545 clip_rect.roundOut(&clip_int_rect); | |
546 SkRegion clip_region(clip_int_rect); | |
547 canvas->setClipRegion(clip_region); | |
548 } | |
549 return frame->printPage(page_number, canvas); | 538 return frame->printPage(page_number, canvas); |
550 } | 539 } |
551 | 540 |
552 // Class that calls the Begin and End print functions on the frame and changes | 541 // Class that calls the Begin and End print functions on the frame and changes |
553 // the size of the view temporarily to support full page printing.. | 542 // the size of the view temporarily to support full page printing.. |
554 class PrepareFrameAndViewForPrint : public blink::WebViewClient, | 543 class PrepareFrameAndViewForPrint : public blink::WebViewClient, |
555 public blink::WebFrameClient { | 544 public blink::WebFrameClient { |
556 public: | 545 public: |
557 PrepareFrameAndViewForPrint(const PrintMsg_Print_Params& params, | 546 PrepareFrameAndViewForPrint(const PrintMsg_Print_Params& params, |
558 blink::WebLocalFrame* frame, | 547 blink::WebLocalFrame* frame, |
(...skipping 1496 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2055 blink::WebConsoleMessage::LevelWarning, message)); | 2044 blink::WebConsoleMessage::LevelWarning, message)); |
2056 return false; | 2045 return false; |
2057 } | 2046 } |
2058 | 2047 |
2059 void PrintWebViewHelper::ScriptingThrottler::Reset() { | 2048 void PrintWebViewHelper::ScriptingThrottler::Reset() { |
2060 // Reset counter on successful print. | 2049 // Reset counter on successful print. |
2061 count_ = 0; | 2050 count_ = 0; |
2062 } | 2051 } |
2063 | 2052 |
2064 } // namespace printing | 2053 } // namespace printing |
OLD | NEW |