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

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

Issue 2667793002: 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 1835 matching lines...) Expand 10 before | Expand all | Expand 10 after
1846 ComputePageLayoutInPointsForCss(frame, params.page_number, params.params, 1846 ComputePageLayoutInPointsForCss(frame, params.page_number, params.params,
1847 ignore_css_margins_, &css_scale_factor, 1847 ignore_css_margins_, &css_scale_factor,
1848 &page_layout_in_points); 1848 &page_layout_in_points);
1849 gfx::Size page_size; 1849 gfx::Size page_size;
1850 gfx::Rect content_area; 1850 gfx::Rect content_area;
1851 GetPageSizeAndContentAreaFromPageLayout(page_layout_in_points, &page_size, 1851 GetPageSizeAndContentAreaFromPageLayout(page_layout_in_points, &page_size,
1852 &content_area); 1852 &content_area);
1853 int dpi = static_cast<int>(params.params.dpi); 1853 int dpi = static_cast<int>(params.params.dpi);
1854 // Calculate the actual page size and content area in dpi. 1854 // Calculate the actual page size and content area in dpi.
1855 if (page_size_in_dpi) { 1855 if (page_size_in_dpi) {
1856 // Windows uses this for the actual page size. We have scaled page size
1857 // to get blink to reflow the page, so scale it back to the real size
1858 // before returning it.
1856 *page_size_in_dpi = 1859 *page_size_in_dpi =
1857 gfx::Size(static_cast<int>(ConvertUnitDouble(page_size.width(), 1860 gfx::Size(static_cast<int>(ConvertUnitDouble(page_size.width(),
1858 kPointsPerInch, dpi)), 1861 kPointsPerInch, dpi) *
1862 css_scale_factor),
1859 static_cast<int>(ConvertUnitDouble(page_size.height(), 1863 static_cast<int>(ConvertUnitDouble(page_size.height(),
1860 kPointsPerInch, dpi))); 1864 kPointsPerInch, dpi) *
1865 css_scale_factor));
1861 } 1866 }
1862 1867
1863 if (content_area_in_dpi) { 1868 if (content_area_in_dpi) {
1864 // Output PDF matches paper size and should be printer edge to edge. 1869 // Output PDF matches paper size and should be printer edge to edge.
1865 *content_area_in_dpi = 1870 *content_area_in_dpi =
1866 gfx::Rect(0, 0, page_size_in_dpi->width(), page_size_in_dpi->height()); 1871 gfx::Rect(0, 0, page_size_in_dpi->width(), page_size_in_dpi->height());
1867 } 1872 }
1868 1873
1869 gfx::Rect canvas_area = 1874 gfx::Rect canvas_area =
1870 params.params.display_header_footer ? gfx::Rect(page_size) : content_area; 1875 params.params.display_header_footer ? gfx::Rect(page_size) : content_area;
(...skipping 478 matching lines...) Expand 10 before | Expand all | Expand 10 after
2349 blink::WebConsoleMessage::LevelWarning, message)); 2354 blink::WebConsoleMessage::LevelWarning, message));
2350 return false; 2355 return false;
2351 } 2356 }
2352 2357
2353 void PrintWebViewHelper::ScriptingThrottler::Reset() { 2358 void PrintWebViewHelper::ScriptingThrottler::Reset() {
2354 // Reset counter on successful print. 2359 // Reset counter on successful print.
2355 count_ = 0; 2360 count_ = 0;
2356 } 2361 }
2357 2362
2358 } // namespace printing 2363 } // 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