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

Unified Diff: third_party/WebKit/Source/core/frame/FrameView.cpp

Issue 2806643002: PrintBrowser: Pick page size based on the default language. (Closed)
Patch Set: Post great-rename rebase Created 3 years, 8 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: third_party/WebKit/Source/core/frame/FrameView.cpp
diff --git a/third_party/WebKit/Source/core/frame/FrameView.cpp b/third_party/WebKit/Source/core/frame/FrameView.cpp
index a7254f82cf1954e4841113cd7d203798305245b5..5b69f11c476be8f4a7e43dd9875ecc1823af61d3 100644
--- a/third_party/WebKit/Source/core/frame/FrameView.cpp
+++ b/third_party/WebKit/Source/core/frame/FrameView.cpp
@@ -106,6 +106,7 @@
#include "core/svg/SVGSVGElement.h"
#include "platform/Histogram.h"
#include "platform/HostWindow.h"
+#include "platform/Language.h"
#include "platform/RuntimeEnabledFeatures.h"
#include "platform/ScriptForbiddenScope.h"
#include "platform/WebFrameScheduler.h"
@@ -145,11 +146,17 @@
} \
} while (false)
-namespace blink {
+namespace {
+
+// Page dimensions in pixels at 72 DPI.
+constexpr int kA4PortraitPageWidth = 595;
+constexpr int kA4PortraitPageHeight = 842;
+constexpr int kLetterPortraitPageWidth = 612;
+constexpr int kLetterPortraitPageHeight = 792;
-// A4 Portrait dimensions in pixels
-const int kA4PortraitPageWidth = 595;
-const int kA4PortraitPageHeight = 842;
+} // namespace
+
+namespace blink {
using namespace HTMLNames;
@@ -2991,10 +2998,13 @@ void FrameView::SetupPrintContext() {
print_context_ = new PrintContext(frame_);
if (frame_->GetSettings())
frame_->GetSettings()->SetShouldPrintBackgrounds(true);
- FloatRect page_rect(0, 0, kA4PortraitPageWidth, kA4PortraitPageHeight);
+ bool is_us = DefaultLanguage() == "en-US";
+ int width = is_us ? kLetterPortraitPageWidth : kA4PortraitPageWidth;
+ int height = is_us ? kLetterPortraitPageHeight : kA4PortraitPageHeight;
+ FloatRect page_rect(0, 0, width, height);
print_context_->begin(page_rect.Width(), page_rect.Height());
- float height;
- print_context_->ComputePageRects(page_rect, 0, 0, 1.0, height);
+ float dummy_height;
+ print_context_->ComputePageRects(page_rect, 0, 0, 1.0, dummy_height);
DispatchEventsForPrintingOnAllFrames();
}
« 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