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

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

Issue 2643903002: Fix viewport unit sizes when printing. (Closed)
Patch Set: Fix comment Created 3 years, 11 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 | third_party/WebKit/Source/web/tests/WebViewTest.cpp » ('j') | 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 8dca0e8f9700cd8ca2a3826cac3351acb2f3da67..256f0ac5fd6d8da1ba0e2613eac580b877468bf2 100644
--- a/third_party/WebKit/Source/core/frame/FrameView.cpp
+++ b/third_party/WebKit/Source/core/frame/FrameView.cpp
@@ -1358,37 +1358,32 @@ IntRect FrameView::computeVisibleArea() {
FloatSize FrameView::viewportSizeForViewportUnits() const {
float zoom = frame().pageZoomFactor();
- if (m_frame->settings() &&
- !RuntimeEnabledFeatures::inertTopControlsEnabled()) {
- FloatSize viewportSize;
-
- LayoutViewItem layoutViewItem = this->layoutViewItem();
- if (layoutViewItem.isNull())
- return viewportSize;
-
- viewportSize.setWidth(layoutViewItem.viewWidth(IncludeScrollbars) / zoom);
- viewportSize.setHeight(layoutViewItem.viewHeight(IncludeScrollbars) / zoom);
- return viewportSize;
- }
+ FloatSize layoutSize;
- FloatSize size(layoutSize(IncludeScrollbars));
-
- // We use the layoutSize rather than frameRect to calculate viewport units
- // so that we get correct results on mobile where the page is laid out into
- // a rect that may be larger than the viewport (e.g. the 980px fallback
- // width for desktop pages). Since the layout height is statically set to
- // be the viewport with browser controls showing, we add the browser controls
- // height, compensating for page scale as well, since we want to use the
- // viewport with browser controls hidden for vh (to match Safari).
- BrowserControls& browserControls = m_frame->host()->browserControls();
- int viewportWidth = m_frame->host()->visualViewport().size().width();
- if (m_frame->isMainFrame() && size.width() && viewportWidth) {
- float pageScaleAtLayoutWidth = viewportWidth / size.width();
- size.expand(0, browserControls.height() / pageScaleAtLayoutWidth);
+ LayoutViewItem layoutViewItem = this->layoutViewItem();
+ if (layoutViewItem.isNull())
+ return layoutSize;
+
+ layoutSize.setWidth(layoutViewItem.viewWidth(IncludeScrollbars) / zoom);
+ layoutSize.setHeight(layoutViewItem.viewHeight(IncludeScrollbars) / zoom);
+
+ if (RuntimeEnabledFeatures::inertTopControlsEnabled()) {
+ // We use the layoutSize rather than frameRect to calculate viewport units
+ // so that we get correct results on mobile where the page is laid out into
+ // a rect that may be larger than the viewport (e.g. the 980px fallback
+ // width for desktop pages). Since the layout height is statically set to
+ // be the viewport with browser controls showing, we add the browser
+ // controls height, compensating for page scale as well, since we want to
+ // use the viewport with browser controls hidden for vh (to match Safari).
+ BrowserControls& browserControls = m_frame->host()->browserControls();
+ int viewportWidth = m_frame->host()->visualViewport().size().width();
+ if (m_frame->isMainFrame() && layoutSize.width() && viewportWidth) {
+ float pageScaleAtLayoutWidth = viewportWidth / layoutSize.width();
+ layoutSize.expand(0, browserControls.height() / pageScaleAtLayoutWidth);
+ }
}
- size.scale(1 / zoom);
- return size;
+ return layoutSize;
}
DocumentLifecycle& FrameView::lifecycle() const {
« no previous file with comments | « no previous file | third_party/WebKit/Source/web/tests/WebViewTest.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698