Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(209)

Side by Side Diff: components/printing/renderer/print_web_view_helper.cc

Issue 2674913004: Fix windows margin scaling bug (Closed)
Patch Set: Created 3 years, 10 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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 1834 matching lines...) Expand 10 before | Expand all | Expand 10 after
1845 ComputePageLayoutInPointsForCss(frame, params.page_number, params.params, 1845 ComputePageLayoutInPointsForCss(frame, params.page_number, params.params,
1846 ignore_css_margins_, &css_scale_factor, 1846 ignore_css_margins_, &css_scale_factor,
1847 &page_layout_in_points); 1847 &page_layout_in_points);
1848 gfx::Size page_size; 1848 gfx::Size page_size;
1849 gfx::Rect content_area; 1849 gfx::Rect content_area;
1850 GetPageSizeAndContentAreaFromPageLayout(page_layout_in_points, &page_size, 1850 GetPageSizeAndContentAreaFromPageLayout(page_layout_in_points, &page_size,
1851 &content_area); 1851 &content_area);
1852 int dpi = static_cast<int>(params.params.dpi); 1852 int dpi = static_cast<int>(params.params.dpi);
1853 // Calculate the actual page size and content area in dpi. 1853 // Calculate the actual page size and content area in dpi.
1854 if (page_size_in_dpi) { 1854 if (page_size_in_dpi) {
1855 // Windows uses this for the actual page size. We have scaled page size
1856 // to get blink to reflow the page, so scale it back to the real size
1857 // before returning it.
1855 *page_size_in_dpi = 1858 *page_size_in_dpi =
1856 gfx::Size(static_cast<int>(ConvertUnitDouble(page_size.width(), 1859 gfx::Size(static_cast<int>(ConvertUnitDouble(page_size.width(),
1857 kPointsPerInch, dpi)), 1860 kPointsPerInch, dpi) *
1861 css_scale_factor),
1858 static_cast<int>(ConvertUnitDouble(page_size.height(), 1862 static_cast<int>(ConvertUnitDouble(page_size.height(),
1859 kPointsPerInch, dpi))); 1863 kPointsPerInch, dpi) *
1864 css_scale_factor));
1860 } 1865 }
1861 1866
1862 if (content_area_in_dpi) { 1867 if (content_area_in_dpi) {
1863 // Output PDF matches paper size and should be printer edge to edge. 1868 // Output PDF matches paper size and should be printer edge to edge.
1864 *content_area_in_dpi = 1869 *content_area_in_dpi =
1865 gfx::Rect(0, 0, page_size_in_dpi->width(), page_size_in_dpi->height()); 1870 gfx::Rect(0, 0, page_size_in_dpi->width(), page_size_in_dpi->height());
1866 } 1871 }
1867 1872
1868 gfx::Rect canvas_area = 1873 gfx::Rect canvas_area =
1869 params.params.display_header_footer ? gfx::Rect(page_size) : content_area; 1874 params.params.display_header_footer ? gfx::Rect(page_size) : content_area;
(...skipping 478 matching lines...) Expand 10 before | Expand all | Expand 10 after
2348 blink::WebConsoleMessage::LevelWarning, message)); 2353 blink::WebConsoleMessage::LevelWarning, message));
2349 return false; 2354 return false;
2350 } 2355 }
2351 2356
2352 void PrintWebViewHelper::ScriptingThrottler::Reset() { 2357 void PrintWebViewHelper::ScriptingThrottler::Reset() {
2353 // Reset counter on successful print. 2358 // Reset counter on successful print.
2354 count_ = 0; 2359 count_ = 0;
2355 } 2360 }
2356 2361
2357 } // namespace printing 2362 } // namespace printing
OLDNEW
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698