| OLD | NEW |
| 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 1320 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1331 | 1331 |
| 1332 us.intersect(parentRect); | 1332 us.intersect(parentRect); |
| 1333 } | 1333 } |
| 1334 | 1334 |
| 1335 return us; | 1335 return us; |
| 1336 } | 1336 } |
| 1337 | 1337 |
| 1338 FloatSize FrameView::viewportSizeForViewportUnits() const { | 1338 FloatSize FrameView::viewportSizeForViewportUnits() const { |
| 1339 float zoom = frame().pageZoomFactor(); | 1339 float zoom = frame().pageZoomFactor(); |
| 1340 | 1340 |
| 1341 if (m_frame->settings() && | 1341 FloatSize layoutSize; |
| 1342 !RuntimeEnabledFeatures::inertTopControlsEnabled()) { | |
| 1343 FloatSize viewportSize; | |
| 1344 | 1342 |
| 1345 LayoutViewItem layoutViewItem = this->layoutViewItem(); | 1343 LayoutViewItem layoutViewItem = this->layoutViewItem(); |
| 1346 if (layoutViewItem.isNull()) | 1344 if (layoutViewItem.isNull()) |
| 1347 return viewportSize; | 1345 return layoutSize; |
| 1348 | 1346 |
| 1349 viewportSize.setWidth(layoutViewItem.viewWidth(IncludeScrollbars) / zoom); | 1347 layoutSize.setWidth(layoutViewItem.viewWidth(IncludeScrollbars) / zoom); |
| 1350 viewportSize.setHeight(layoutViewItem.viewHeight(IncludeScrollbars) / zoom); | 1348 layoutSize.setHeight(layoutViewItem.viewHeight(IncludeScrollbars) / zoom); |
| 1351 return viewportSize; | 1349 |
| 1350 if (RuntimeEnabledFeatures::inertTopControlsEnabled()) { |
| 1351 // We use the layoutSize rather than frameRect to calculate viewport units |
| 1352 // so that we get correct results on mobile where the page is laid out into |
| 1353 // a rect that may be larger than the viewport (e.g. the 980px fallback |
| 1354 // width for desktop pages). Since the layout height is statically set to |
| 1355 // be the viewport with browser controls showing, we add the browser |
| 1356 // controls height, compensating for page scale as well, since we want to |
| 1357 // use the viewport with browser controls hidden for vh (to match Safari). |
| 1358 BrowserControls& browserControls = m_frame->host()->browserControls(); |
| 1359 int viewportWidth = m_frame->host()->visualViewport().size().width(); |
| 1360 if (m_frame->isMainFrame() && layoutSize.width() && viewportWidth) { |
| 1361 float pageScaleAtLayoutWidth = viewportWidth / layoutSize.width(); |
| 1362 layoutSize.expand(0, browserControls.height() / pageScaleAtLayoutWidth); |
| 1363 } |
| 1352 } | 1364 } |
| 1353 | 1365 |
| 1354 FloatSize size(layoutSize(IncludeScrollbars)); | 1366 return layoutSize; |
| 1355 | |
| 1356 // We use the layoutSize rather than frameRect to calculate viewport units | |
| 1357 // so that we get correct results on mobile where the page is laid out into | |
| 1358 // a rect that may be larger than the viewport (e.g. the 980px fallback | |
| 1359 // width for desktop pages). Since the layout height is statically set to | |
| 1360 // be the viewport with browser controls showing, we add the browser controls | |
| 1361 // height, compensating for page scale as well, since we want to use the | |
| 1362 // viewport with browser controls hidden for vh (to match Safari). | |
| 1363 BrowserControls& browserControls = m_frame->host()->browserControls(); | |
| 1364 int viewportWidth = m_frame->host()->visualViewport().size().width(); | |
| 1365 if (m_frame->isMainFrame() && size.width() && viewportWidth) { | |
| 1366 float pageScaleAtLayoutWidth = viewportWidth / size.width(); | |
| 1367 size.expand(0, browserControls.height() / pageScaleAtLayoutWidth); | |
| 1368 } | |
| 1369 | |
| 1370 size.scale(1 / zoom); | |
| 1371 return size; | |
| 1372 } | 1367 } |
| 1373 | 1368 |
| 1374 DocumentLifecycle& FrameView::lifecycle() const { | 1369 DocumentLifecycle& FrameView::lifecycle() const { |
| 1375 return m_frame->document()->lifecycle(); | 1370 return m_frame->document()->lifecycle(); |
| 1376 } | 1371 } |
| 1377 | 1372 |
| 1378 LayoutReplaced* FrameView::embeddedReplacedContent() const { | 1373 LayoutReplaced* FrameView::embeddedReplacedContent() const { |
| 1379 LayoutViewItem layoutViewItem = this->layoutViewItem(); | 1374 LayoutViewItem layoutViewItem = this->layoutViewItem(); |
| 1380 if (layoutViewItem.isNull()) | 1375 if (layoutViewItem.isNull()) |
| 1381 return nullptr; | 1376 return nullptr; |
| (...skipping 3244 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 4626 DCHECK(m_frame->isMainFrame()); | 4621 DCHECK(m_frame->isMainFrame()); |
| 4627 return m_initialViewportSize.width(); | 4622 return m_initialViewportSize.width(); |
| 4628 } | 4623 } |
| 4629 | 4624 |
| 4630 int FrameView::initialViewportHeight() const { | 4625 int FrameView::initialViewportHeight() const { |
| 4631 DCHECK(m_frame->isMainFrame()); | 4626 DCHECK(m_frame->isMainFrame()); |
| 4632 return m_initialViewportSize.height(); | 4627 return m_initialViewportSize.height(); |
| 4633 } | 4628 } |
| 4634 | 4629 |
| 4635 } // namespace blink | 4630 } // namespace blink |
| OLD | NEW |