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

Side by Side 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 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 /* 1 /*
2 * Copyright (C) 1998, 1999 Torben Weis <weis@kde.org> 2 * Copyright (C) 1998, 1999 Torben Weis <weis@kde.org>
3 * 1999 Lars Knoll <knoll@kde.org> 3 * 1999 Lars Knoll <knoll@kde.org>
4 * 1999 Antti Koivisto <koivisto@kde.org> 4 * 1999 Antti Koivisto <koivisto@kde.org>
5 * 2000 Dirk Mueller <mueller@kde.org> 5 * 2000 Dirk Mueller <mueller@kde.org>
6 * Copyright (C) 2004, 2005, 2006, 2007, 2008 Apple Inc. All rights reserved. 6 * Copyright (C) 2004, 2005, 2006, 2007, 2008 Apple Inc. All rights reserved.
7 * (C) 2006 Graham Dennis (graham.dennis@gmail.com) 7 * (C) 2006 Graham Dennis (graham.dennis@gmail.com)
8 * (C) 2006 Alexey Proskuryakov (ap@nypop.com) 8 * (C) 2006 Alexey Proskuryakov (ap@nypop.com)
9 * Copyright (C) 2009 Google Inc. All rights reserved. 9 * Copyright (C) 2009 Google Inc. All rights reserved.
10 * 10 *
(...skipping 88 matching lines...) Expand 10 before | Expand all | Expand 10 after
99 #include "core/paint/PaintLayer.h" 99 #include "core/paint/PaintLayer.h"
100 #include "core/paint/PaintTiming.h" 100 #include "core/paint/PaintTiming.h"
101 #include "core/paint/PrePaintTreeWalk.h" 101 #include "core/paint/PrePaintTreeWalk.h"
102 #include "core/plugins/PluginView.h" 102 #include "core/plugins/PluginView.h"
103 #include "core/probe/CoreProbes.h" 103 #include "core/probe/CoreProbes.h"
104 #include "core/style/ComputedStyle.h" 104 #include "core/style/ComputedStyle.h"
105 #include "core/svg/SVGDocumentExtensions.h" 105 #include "core/svg/SVGDocumentExtensions.h"
106 #include "core/svg/SVGSVGElement.h" 106 #include "core/svg/SVGSVGElement.h"
107 #include "platform/Histogram.h" 107 #include "platform/Histogram.h"
108 #include "platform/HostWindow.h" 108 #include "platform/HostWindow.h"
109 #include "platform/Language.h"
109 #include "platform/RuntimeEnabledFeatures.h" 110 #include "platform/RuntimeEnabledFeatures.h"
110 #include "platform/ScriptForbiddenScope.h" 111 #include "platform/ScriptForbiddenScope.h"
111 #include "platform/WebFrameScheduler.h" 112 #include "platform/WebFrameScheduler.h"
112 #include "platform/fonts/FontCache.h" 113 #include "platform/fonts/FontCache.h"
113 #include "platform/geometry/DoubleRect.h" 114 #include "platform/geometry/DoubleRect.h"
114 #include "platform/geometry/FloatRect.h" 115 #include "platform/geometry/FloatRect.h"
115 #include "platform/geometry/LayoutRect.h" 116 #include "platform/geometry/LayoutRect.h"
116 #include "platform/geometry/TransformState.h" 117 #include "platform/geometry/TransformState.h"
117 #include "platform/graphics/GraphicsContext.h" 118 #include "platform/graphics/GraphicsContext.h"
118 #include "platform/graphics/GraphicsLayer.h" 119 #include "platform/graphics/GraphicsLayer.h"
(...skipping 19 matching lines...) Expand all
138 // false, program will crash if DCHECK_IS_ON() or return false from the current 139 // false, program will crash if DCHECK_IS_ON() or return false from the current
139 // function. 140 // function.
140 #define CHECK_FOR_DIRTY_LAYOUT(arg) \ 141 #define CHECK_FOR_DIRTY_LAYOUT(arg) \
141 do { \ 142 do { \
142 if (!(arg)) { \ 143 if (!(arg)) { \
143 NOTREACHED(); \ 144 NOTREACHED(); \
144 return false; \ 145 return false; \
145 } \ 146 } \
146 } while (false) 147 } while (false)
147 148
149 namespace {
150
151 // Page dimensions in pixels at 72 DPI.
152 constexpr int kA4PortraitPageWidth = 595;
153 constexpr int kA4PortraitPageHeight = 842;
154 constexpr int kLetterPortraitPageWidth = 612;
155 constexpr int kLetterPortraitPageHeight = 792;
156
157 } // namespace
158
148 namespace blink { 159 namespace blink {
149 160
150 // A4 Portrait dimensions in pixels
151 const int kA4PortraitPageWidth = 595;
152 const int kA4PortraitPageHeight = 842;
153
154 using namespace HTMLNames; 161 using namespace HTMLNames;
155 162
156 // The maximum number of updatePlugins iterations that should be done before 163 // The maximum number of updatePlugins iterations that should be done before
157 // returning. 164 // returning.
158 static const unsigned kMaxUpdatePluginsIterations = 2; 165 static const unsigned kMaxUpdatePluginsIterations = 2;
159 static const double kResourcePriorityUpdateDelayAfterScroll = 0.250; 166 static const double kResourcePriorityUpdateDelayAfterScroll = 0.250;
160 167
161 static bool g_initial_track_all_paint_invalidations = false; 168 static bool g_initial_track_all_paint_invalidations = false;
162 169
163 FrameView::FrameView(LocalFrame& frame) 170 FrameView::FrameView(LocalFrame& frame)
(...skipping 2820 matching lines...) Expand 10 before | Expand all | Expand 10 after
2984 } 2991 }
2985 } 2992 }
2986 2993
2987 void FrameView::SetupPrintContext() { 2994 void FrameView::SetupPrintContext() {
2988 if (frame_->GetDocument()->Printing()) 2995 if (frame_->GetDocument()->Printing())
2989 return; 2996 return;
2990 if (!print_context_) 2997 if (!print_context_)
2991 print_context_ = new PrintContext(frame_); 2998 print_context_ = new PrintContext(frame_);
2992 if (frame_->GetSettings()) 2999 if (frame_->GetSettings())
2993 frame_->GetSettings()->SetShouldPrintBackgrounds(true); 3000 frame_->GetSettings()->SetShouldPrintBackgrounds(true);
2994 FloatRect page_rect(0, 0, kA4PortraitPageWidth, kA4PortraitPageHeight); 3001 bool is_us = DefaultLanguage() == "en-US";
3002 int width = is_us ? kLetterPortraitPageWidth : kA4PortraitPageWidth;
3003 int height = is_us ? kLetterPortraitPageHeight : kA4PortraitPageHeight;
3004 FloatRect page_rect(0, 0, width, height);
2995 print_context_->begin(page_rect.Width(), page_rect.Height()); 3005 print_context_->begin(page_rect.Width(), page_rect.Height());
2996 float height; 3006 float dummy_height;
2997 print_context_->ComputePageRects(page_rect, 0, 0, 1.0, height); 3007 print_context_->ComputePageRects(page_rect, 0, 0, 1.0, dummy_height);
2998 DispatchEventsForPrintingOnAllFrames(); 3008 DispatchEventsForPrintingOnAllFrames();
2999 } 3009 }
3000 3010
3001 void FrameView::ClearPrintContext() { 3011 void FrameView::ClearPrintContext() {
3002 if (!print_context_) 3012 if (!print_context_)
3003 return; 3013 return;
3004 print_context_->end(); 3014 print_context_->end();
3005 print_context_.Clear(); 3015 print_context_.Clear();
3006 } 3016 }
3007 3017
(...skipping 2323 matching lines...) Expand 10 before | Expand all | Expand 10 after
5331 void FrameView::SetAnimationHost( 5341 void FrameView::SetAnimationHost(
5332 std::unique_ptr<CompositorAnimationHost> host) { 5342 std::unique_ptr<CompositorAnimationHost> host) {
5333 animation_host_ = std::move(host); 5343 animation_host_ = std::move(host);
5334 } 5344 }
5335 5345
5336 LayoutUnit FrameView::CaretWidth() const { 5346 LayoutUnit FrameView::CaretWidth() const {
5337 return LayoutUnit(GetHostWindow()->WindowToViewportScalar(1)); 5347 return LayoutUnit(GetHostWindow()->WindowToViewportScalar(1));
5338 } 5348 }
5339 5349
5340 } // namespace blink 5350 } // namespace blink
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