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

Side by Side Diff: third_party/WebKit/Source/core/frame/FrameView.cpp

Issue 2563783003: Avoid division-by-zero when visual viewport width is 0. (Closed)
Patch Set: Created 4 years 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 1335 matching lines...) Expand 10 before | Expand all | Expand 10 after
1346 FloatSize size(layoutSize(IncludeScrollbars)); 1346 FloatSize size(layoutSize(IncludeScrollbars));
1347 1347
1348 // We use the layoutSize rather than frameRect to calculate viewport units 1348 // We use the layoutSize rather than frameRect to calculate viewport units
1349 // so that we get correct results on mobile where the page is laid out into 1349 // so that we get correct results on mobile where the page is laid out into
1350 // a rect that may be larger than the viewport (e.g. the 980px fallback 1350 // a rect that may be larger than the viewport (e.g. the 980px fallback
1351 // width for desktop pages). Since the layout height is statically set to 1351 // width for desktop pages). Since the layout height is statically set to
1352 // be the viewport with browser controls showing, we add the browser controls 1352 // be the viewport with browser controls showing, we add the browser controls
1353 // height, compensating for page scale as well, since we want to use the 1353 // height, compensating for page scale as well, since we want to use the
1354 // viewport with browser controls hidden for vh (to match Safari). 1354 // viewport with browser controls hidden for vh (to match Safari).
1355 BrowserControls& browserControls = m_frame->host()->browserControls(); 1355 BrowserControls& browserControls = m_frame->host()->browserControls();
1356 if (m_frame->isMainFrame() && size.width()) { 1356 if (m_frame->isMainFrame() && size.width() &&
1357 m_frame->host()->visualViewport().size().width()) {
rune 2016/12/09 15:27:50 I should probably check the pageScaleAtLayoutWidth
bokan 2016/12/09 16:48:55 Visual Viewport size should never be 0, do you kno
1357 float pageScaleAtLayoutWidth = 1358 float pageScaleAtLayoutWidth =
1358 m_frame->host()->visualViewport().size().width() / size.width(); 1359 m_frame->host()->visualViewport().size().width() / size.width();
1359 size.expand(0, browserControls.height() / pageScaleAtLayoutWidth); 1360 size.expand(0, browserControls.height() / pageScaleAtLayoutWidth);
1360 } 1361 }
1361 1362
1362 size.scale(1 / zoom); 1363 size.scale(1 / zoom);
1363 return size; 1364 return size;
1364 } 1365 }
1365 1366
1366 DocumentLifecycle& FrameView::lifecycle() const { 1367 DocumentLifecycle& FrameView::lifecycle() const {
(...skipping 3308 matching lines...) Expand 10 before | Expand all | Expand 10 after
4675 DCHECK(m_frame->isMainFrame()); 4676 DCHECK(m_frame->isMainFrame());
4676 return m_initialViewportSize.width(); 4677 return m_initialViewportSize.width();
4677 } 4678 }
4678 4679
4679 int FrameView::initialViewportHeight() const { 4680 int FrameView::initialViewportHeight() const {
4680 DCHECK(m_frame->isMainFrame()); 4681 DCHECK(m_frame->isMainFrame());
4681 return m_initialViewportSize.height(); 4682 return m_initialViewportSize.height();
4682 } 4683 }
4683 4684
4684 } // namespace blink 4685 } // 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