Chromium Code Reviews| 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 #include <string> | 9 #include <string> |
| 10 #include <utility> | 10 #include <utility> |
| (...skipping 658 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 669 frame->printEnd(); | 669 frame->printEnd(); |
| 670 } | 670 } |
| 671 ComputeWebKitPrintParamsInDesiredDpi(print_params, &web_print_params_); | 671 ComputeWebKitPrintParamsInDesiredDpi(print_params, &web_print_params_); |
| 672 } | 672 } |
| 673 | 673 |
| 674 PrepareFrameAndViewForPrint::~PrepareFrameAndViewForPrint() { | 674 PrepareFrameAndViewForPrint::~PrepareFrameAndViewForPrint() { |
| 675 FinishPrinting(); | 675 FinishPrinting(); |
| 676 } | 676 } |
| 677 | 677 |
| 678 void PrepareFrameAndViewForPrint::ResizeForPrinting() { | 678 void PrepareFrameAndViewForPrint::ResizeForPrinting() { |
| 679 // Layout page according to printer page size. Since WebKit shrinks the | 679 // Layout page according to printer page size. Since WebKit shrinks the |
|
eae
2016/03/23 21:16:56
This comment needs updating. Would also be great i
| |
| 680 // size of the page automatically (from 125% to 200%) we trick it to | 680 // size of the page automatically (from 125% to 200%) we trick it to |
| 681 // think the page is 125% larger so the size of the page is correct for | 681 // think the page is 125% larger so the size of the page is correct for |
| 682 // minimum (default) scaling. | 682 // minimum (default) scaling. |
| 683 // This is important for sites that try to fill the page. | 683 // This is important for sites that try to fill the page. |
| 684 // The 1.25 value is |printingMinimumShrinkFactor|. | 684 // The 1.33 value is |printingMinimumShrinkFactor|. |
| 685 gfx::Size print_layout_size(web_print_params_.printContentArea.width, | 685 gfx::Size print_layout_size(web_print_params_.printContentArea.width, |
| 686 web_print_params_.printContentArea.height); | 686 web_print_params_.printContentArea.height); |
| 687 print_layout_size.set_height( | 687 print_layout_size.set_height( |
| 688 static_cast<int>(static_cast<double>(print_layout_size.height()) * 1.25)); | 688 static_cast<int>(static_cast<double>(print_layout_size.height()) * 1.33)); |
|
eae
2016/03/23 21:16:56
How about making this a constant and using it both
| |
| 689 | 689 |
| 690 if (!frame()) | 690 if (!frame()) |
| 691 return; | 691 return; |
| 692 blink::WebView* web_view = frame_.view(); | 692 blink::WebView* web_view = frame_.view(); |
| 693 // Backup size and offset. | 693 // Backup size and offset. |
| 694 if (blink::WebFrame* web_frame = web_view->mainFrame()) | 694 if (blink::WebFrame* web_frame = web_view->mainFrame()) |
| 695 prev_scroll_offset_ = web_frame->scrollOffset(); | 695 prev_scroll_offset_ = web_frame->scrollOffset(); |
| 696 prev_view_size_ = web_view->size(); | 696 prev_view_size_ = web_view->size(); |
| 697 | 697 |
| 698 web_view->resize(print_layout_size); | 698 web_view->resize(print_layout_size); |
| (...skipping 1079 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1778 | 1778 |
| 1779 MetafileSkiaWrapper::SetMetafileOnCanvas(*canvas, metafile); | 1779 MetafileSkiaWrapper::SetMetafileOnCanvas(*canvas, metafile); |
| 1780 | 1780 |
| 1781 #if defined(ENABLE_PRINT_PREVIEW) | 1781 #if defined(ENABLE_PRINT_PREVIEW) |
| 1782 if (params.params.display_header_footer) { | 1782 if (params.params.display_header_footer) { |
| 1783 // TODO(thestig): Figure out why Linux needs this. The value may be | 1783 // TODO(thestig): Figure out why Linux needs this. The value may be |
| 1784 // |printingMinimumShrinkFactor|. | 1784 // |printingMinimumShrinkFactor|. |
| 1785 #if defined(OS_WIN) | 1785 #if defined(OS_WIN) |
| 1786 const float fudge_factor = 1; | 1786 const float fudge_factor = 1; |
| 1787 #else | 1787 #else |
| 1788 const float fudge_factor = 1.25; | 1788 const float fudge_factor = 1.33; |
| 1789 #endif | 1789 #endif |
| 1790 // |page_number| is 0-based, so 1 is added. | 1790 // |page_number| is 0-based, so 1 is added. |
| 1791 PrintHeaderAndFooter(canvas, params.page_number + 1, | 1791 PrintHeaderAndFooter(canvas, params.page_number + 1, |
| 1792 print_preview_context_.total_page_count(), *frame, | 1792 print_preview_context_.total_page_count(), *frame, |
| 1793 scale_factor / fudge_factor, page_layout_in_points, | 1793 scale_factor / fudge_factor, page_layout_in_points, |
| 1794 params.params); | 1794 params.params); |
| 1795 } | 1795 } |
| 1796 #endif // defined(ENABLE_PRINT_PREVIEW) | 1796 #endif // defined(ENABLE_PRINT_PREVIEW) |
| 1797 | 1797 |
| 1798 float webkit_scale_factor = | 1798 float webkit_scale_factor = |
| (...skipping 439 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 2238 blink::WebConsoleMessage::LevelWarning, message)); | 2238 blink::WebConsoleMessage::LevelWarning, message)); |
| 2239 return false; | 2239 return false; |
| 2240 } | 2240 } |
| 2241 | 2241 |
| 2242 void PrintWebViewHelper::ScriptingThrottler::Reset() { | 2242 void PrintWebViewHelper::ScriptingThrottler::Reset() { |
| 2243 // Reset counter on successful print. | 2243 // Reset counter on successful print. |
| 2244 count_ = 0; | 2244 count_ = 0; |
| 2245 } | 2245 } |
| 2246 | 2246 |
| 2247 } // namespace printing | 2247 } // namespace printing |
| OLD | NEW |