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 if (content_area.origin() != canvas_area.origin()) { |
reed1
2014/12/22 20:41:24
If you like, you can skip this test and always cal
hal.canary
2014/12/23 15:19:14
Done.
| |
537 canvas->translate((content_area.x() - canvas_area.x()) / scale_factor, | 537 canvas->translate((content_area.x() - canvas_area.x()) / scale_factor, |
538 (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 } | 539 } |
549 return frame->printPage(page_number, canvas); | 540 return frame->printPage(page_number, canvas); |
550 } | 541 } |
551 | 542 |
552 // Class that calls the Begin and End print functions on the frame and changes | 543 // 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.. | 544 // the size of the view temporarily to support full page printing.. |
554 class PrepareFrameAndViewForPrint : public blink::WebViewClient, | 545 class PrepareFrameAndViewForPrint : public blink::WebViewClient, |
555 public blink::WebFrameClient { | 546 public blink::WebFrameClient { |
556 public: | 547 public: |
557 PrepareFrameAndViewForPrint(const PrintMsg_Print_Params& params, | 548 PrepareFrameAndViewForPrint(const PrintMsg_Print_Params& params, |
(...skipping 1497 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
2055 blink::WebConsoleMessage::LevelWarning, message)); | 2046 blink::WebConsoleMessage::LevelWarning, message)); |
2056 return false; | 2047 return false; |
2057 } | 2048 } |
2058 | 2049 |
2059 void PrintWebViewHelper::ScriptingThrottler::Reset() { | 2050 void PrintWebViewHelper::ScriptingThrottler::Reset() { |
2060 // Reset counter on successful print. | 2051 // Reset counter on successful print. |
2061 count_ = 0; | 2052 count_ = 0; |
2062 } | 2053 } |
2063 | 2054 |
2064 } // namespace printing | 2055 } // namespace printing |
OLD | NEW |