| 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 546 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 557 } | 557 } |
| 558 | 558 |
| 559 if (auto layoutViewItem = this->layoutViewItem()) | 559 if (auto layoutViewItem = this->layoutViewItem()) |
| 560 layoutViewItem.setMayNeedPaintInvalidation(); | 560 layoutViewItem.setMayNeedPaintInvalidation(); |
| 561 | 561 |
| 562 if (frameSizeChanged) { | 562 if (frameSizeChanged) { |
| 563 viewportSizeChanged(newRect.width() != oldRect.width(), | 563 viewportSizeChanged(newRect.width() != oldRect.width(), |
| 564 newRect.height() != oldRect.height()); | 564 newRect.height() != oldRect.height()); |
| 565 | 565 |
| 566 if (m_frame->isMainFrame()) | 566 if (m_frame->isMainFrame()) |
| 567 m_frame->host()->visualViewport().mainFrameDidChangeSize(); | 567 m_frame->page()->visualViewport().mainFrameDidChangeSize(); |
| 568 | 568 |
| 569 frame().loader().restoreScrollPositionAndViewState(); | 569 frame().loader().restoreScrollPositionAndViewState(); |
| 570 } | 570 } |
| 571 } | 571 } |
| 572 | 572 |
| 573 Page* FrameView::page() const { | 573 Page* FrameView::page() const { |
| 574 return frame().page(); | 574 return frame().page(); |
| 575 } | 575 } |
| 576 | 576 |
| 577 LayoutView* FrameView::layoutView() const { | 577 LayoutView* FrameView::layoutView() const { |
| (...skipping 842 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1420 BrowserControls& browserControls = m_frame->page()->browserControls(); | 1420 BrowserControls& browserControls = m_frame->page()->browserControls(); |
| 1421 if (RuntimeEnabledFeatures::inertTopControlsEnabled() && | 1421 if (RuntimeEnabledFeatures::inertTopControlsEnabled() && |
| 1422 browserControls.permittedState() != WebBrowserControlsHidden) { | 1422 browserControls.permittedState() != WebBrowserControlsHidden) { |
| 1423 // We use the layoutSize rather than frameRect to calculate viewport units | 1423 // We use the layoutSize rather than frameRect to calculate viewport units |
| 1424 // so that we get correct results on mobile where the page is laid out into | 1424 // so that we get correct results on mobile where the page is laid out into |
| 1425 // a rect that may be larger than the viewport (e.g. the 980px fallback | 1425 // a rect that may be larger than the viewport (e.g. the 980px fallback |
| 1426 // width for desktop pages). Since the layout height is statically set to | 1426 // width for desktop pages). Since the layout height is statically set to |
| 1427 // be the viewport with browser controls showing, we add the browser | 1427 // be the viewport with browser controls showing, we add the browser |
| 1428 // controls height, compensating for page scale as well, since we want to | 1428 // controls height, compensating for page scale as well, since we want to |
| 1429 // use the viewport with browser controls hidden for vh (to match Safari). | 1429 // use the viewport with browser controls hidden for vh (to match Safari). |
| 1430 int viewportWidth = m_frame->host()->visualViewport().size().width(); | 1430 int viewportWidth = m_frame->page()->visualViewport().size().width(); |
| 1431 if (m_frame->isMainFrame() && layoutSize.width() && viewportWidth) { | 1431 if (m_frame->isMainFrame() && layoutSize.width() && viewportWidth) { |
| 1432 float pageScaleAtLayoutWidth = viewportWidth / layoutSize.width(); | 1432 float pageScaleAtLayoutWidth = viewportWidth / layoutSize.width(); |
| 1433 layoutSize.expand(0, browserControls.height() / pageScaleAtLayoutWidth); | 1433 layoutSize.expand(0, browserControls.height() / pageScaleAtLayoutWidth); |
| 1434 } | 1434 } |
| 1435 } | 1435 } |
| 1436 | 1436 |
| 1437 return layoutSize; | 1437 return layoutSize; |
| 1438 } | 1438 } |
| 1439 | 1439 |
| 1440 FloatSize FrameView::viewportSizeForMediaQueries() const { | 1440 FloatSize FrameView::viewportSizeForMediaQueries() const { |
| (...skipping 1166 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2607 float contentScaleFactor) { | 2607 float contentScaleFactor) { |
| 2608 m_inputEventsOffsetForEmulation = offset; | 2608 m_inputEventsOffsetForEmulation = offset; |
| 2609 m_inputEventsScaleFactorForEmulation = contentScaleFactor; | 2609 m_inputEventsScaleFactorForEmulation = contentScaleFactor; |
| 2610 } | 2610 } |
| 2611 | 2611 |
| 2612 IntSize FrameView::inputEventsOffsetForEmulation() const { | 2612 IntSize FrameView::inputEventsOffsetForEmulation() const { |
| 2613 return m_inputEventsOffsetForEmulation; | 2613 return m_inputEventsOffsetForEmulation; |
| 2614 } | 2614 } |
| 2615 | 2615 |
| 2616 float FrameView::inputEventsScaleFactor() const { | 2616 float FrameView::inputEventsScaleFactor() const { |
| 2617 float pageScale = m_frame->host()->visualViewport().scale(); | 2617 float pageScale = m_frame->page()->visualViewport().scale(); |
| 2618 return pageScale * m_inputEventsScaleFactorForEmulation; | 2618 return pageScale * m_inputEventsScaleFactorForEmulation; |
| 2619 } | 2619 } |
| 2620 | 2620 |
| 2621 bool FrameView::scrollbarsCanBeActive() const { | 2621 bool FrameView::scrollbarsCanBeActive() const { |
| 2622 if (m_frame->view() != this) | 2622 if (m_frame->view() != this) |
| 2623 return false; | 2623 return false; |
| 2624 | 2624 |
| 2625 return !!m_frame->document(); | 2625 return !!m_frame->document(); |
| 2626 } | 2626 } |
| 2627 | 2627 |
| (...skipping 124 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2752 page->chromeClient().annotatedRegionsChanged(); | 2752 page->chromeClient().annotatedRegionsChanged(); |
| 2753 } | 2753 } |
| 2754 | 2754 |
| 2755 void FrameView::didAttachDocument() { | 2755 void FrameView::didAttachDocument() { |
| 2756 FrameHost* frameHost = m_frame->host(); | 2756 FrameHost* frameHost = m_frame->host(); |
| 2757 DCHECK(frameHost); | 2757 DCHECK(frameHost); |
| 2758 | 2758 |
| 2759 DCHECK(m_frame->document()); | 2759 DCHECK(m_frame->document()); |
| 2760 | 2760 |
| 2761 if (m_frame->isMainFrame()) { | 2761 if (m_frame->isMainFrame()) { |
| 2762 ScrollableArea& visualViewport = frameHost->visualViewport(); | 2762 ScrollableArea& visualViewport = m_frame->page()->visualViewport(); |
| 2763 ScrollableArea* layoutViewport = layoutViewportScrollableArea(); | 2763 ScrollableArea* layoutViewport = layoutViewportScrollableArea(); |
| 2764 DCHECK(layoutViewport); | 2764 DCHECK(layoutViewport); |
| 2765 | 2765 |
| 2766 RootFrameViewport* rootFrameViewport = | 2766 RootFrameViewport* rootFrameViewport = |
| 2767 RootFrameViewport::create(visualViewport, *layoutViewport); | 2767 RootFrameViewport::create(visualViewport, *layoutViewport); |
| 2768 m_viewportScrollableArea = rootFrameViewport; | 2768 m_viewportScrollableArea = rootFrameViewport; |
| 2769 | 2769 |
| 2770 frameHost->globalRootScrollerController().initializeViewportScrollCallback( | 2770 frameHost->globalRootScrollerController().initializeViewportScrollCallback( |
| 2771 *rootFrameViewport); | 2771 *rootFrameViewport); |
| 2772 } | 2772 } |
| (...skipping 1598 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 4371 } | 4371 } |
| 4372 | 4372 |
| 4373 FloatPoint FrameView::rootFrameToContents( | 4373 FloatPoint FrameView::rootFrameToContents( |
| 4374 const FloatPoint& pointInRootFrame) const { | 4374 const FloatPoint& pointInRootFrame) const { |
| 4375 FloatPoint framePoint = convertFromRootFrame(pointInRootFrame); | 4375 FloatPoint framePoint = convertFromRootFrame(pointInRootFrame); |
| 4376 return frameToContents(framePoint); | 4376 return frameToContents(framePoint); |
| 4377 } | 4377 } |
| 4378 | 4378 |
| 4379 IntRect FrameView::viewportToContents(const IntRect& rectInViewport) const { | 4379 IntRect FrameView::viewportToContents(const IntRect& rectInViewport) const { |
| 4380 IntRect rectInRootFrame = | 4380 IntRect rectInRootFrame = |
| 4381 m_frame->host()->visualViewport().viewportToRootFrame(rectInViewport); | 4381 m_frame->page()->visualViewport().viewportToRootFrame(rectInViewport); |
| 4382 IntRect frameRect = convertFromRootFrame(rectInRootFrame); | 4382 IntRect frameRect = convertFromRootFrame(rectInRootFrame); |
| 4383 return frameToContents(frameRect); | 4383 return frameToContents(frameRect); |
| 4384 } | 4384 } |
| 4385 | 4385 |
| 4386 IntPoint FrameView::viewportToContents(const IntPoint& pointInViewport) const { | 4386 IntPoint FrameView::viewportToContents(const IntPoint& pointInViewport) const { |
| 4387 IntPoint pointInRootFrame = | 4387 IntPoint pointInRootFrame = |
| 4388 m_frame->host()->visualViewport().viewportToRootFrame(pointInViewport); | 4388 m_frame->page()->visualViewport().viewportToRootFrame(pointInViewport); |
| 4389 IntPoint pointInFrame = convertFromRootFrame(pointInRootFrame); | 4389 IntPoint pointInFrame = convertFromRootFrame(pointInRootFrame); |
| 4390 return frameToContents(pointInFrame); | 4390 return frameToContents(pointInFrame); |
| 4391 } | 4391 } |
| 4392 | 4392 |
| 4393 IntRect FrameView::contentsToViewport(const IntRect& rectInContents) const { | 4393 IntRect FrameView::contentsToViewport(const IntRect& rectInContents) const { |
| 4394 IntRect rectInFrame = contentsToFrame(rectInContents); | 4394 IntRect rectInFrame = contentsToFrame(rectInContents); |
| 4395 IntRect rectInRootFrame = convertToRootFrame(rectInFrame); | 4395 IntRect rectInRootFrame = convertToRootFrame(rectInFrame); |
| 4396 return m_frame->host()->visualViewport().rootFrameToViewport(rectInRootFrame); | 4396 return m_frame->page()->visualViewport().rootFrameToViewport(rectInRootFrame); |
| 4397 } | 4397 } |
| 4398 | 4398 |
| 4399 IntPoint FrameView::contentsToViewport(const IntPoint& pointInContents) const { | 4399 IntPoint FrameView::contentsToViewport(const IntPoint& pointInContents) const { |
| 4400 IntPoint pointInFrame = contentsToFrame(pointInContents); | 4400 IntPoint pointInFrame = contentsToFrame(pointInContents); |
| 4401 IntPoint pointInRootFrame = convertToRootFrame(pointInFrame); | 4401 IntPoint pointInRootFrame = convertToRootFrame(pointInFrame); |
| 4402 return m_frame->host()->visualViewport().rootFrameToViewport( | 4402 return m_frame->page()->visualViewport().rootFrameToViewport( |
| 4403 pointInRootFrame); | 4403 pointInRootFrame); |
| 4404 } | 4404 } |
| 4405 | 4405 |
| 4406 IntRect FrameView::contentsToScreen(const IntRect& rect) const { | 4406 IntRect FrameView::contentsToScreen(const IntRect& rect) const { |
| 4407 HostWindow* window = getHostWindow(); | 4407 HostWindow* window = getHostWindow(); |
| 4408 if (!window) | 4408 if (!window) |
| 4409 return IntRect(); | 4409 return IntRect(); |
| 4410 return window->viewportToScreen(contentsToViewport(rect), this); | 4410 return window->viewportToScreen(contentsToViewport(rect), this); |
| 4411 } | 4411 } |
| 4412 | 4412 |
| 4413 IntPoint FrameView::soonToBeRemovedUnscaledViewportToContents( | 4413 IntPoint FrameView::soonToBeRemovedUnscaledViewportToContents( |
| 4414 const IntPoint& pointInViewport) const { | 4414 const IntPoint& pointInViewport) const { |
| 4415 IntPoint pointInRootFrame = flooredIntPoint( | 4415 IntPoint pointInRootFrame = flooredIntPoint( |
| 4416 m_frame->host()->visualViewport().viewportCSSPixelsToRootFrame( | 4416 m_frame->page()->visualViewport().viewportCSSPixelsToRootFrame( |
| 4417 pointInViewport)); | 4417 pointInViewport)); |
| 4418 IntPoint pointInThisFrame = convertFromRootFrame(pointInRootFrame); | 4418 IntPoint pointInThisFrame = convertFromRootFrame(pointInRootFrame); |
| 4419 return frameToContents(pointInThisFrame); | 4419 return frameToContents(pointInThisFrame); |
| 4420 } | 4420 } |
| 4421 | 4421 |
| 4422 Scrollbar* FrameView::scrollbarAtFramePoint(const IntPoint& pointInFrame) { | 4422 Scrollbar* FrameView::scrollbarAtFramePoint(const IntPoint& pointInFrame) { |
| 4423 if (horizontalScrollbar() && | 4423 if (horizontalScrollbar() && |
| 4424 horizontalScrollbar()->shouldParticipateInHitTesting() && | 4424 horizontalScrollbar()->shouldParticipateInHitTesting() && |
| 4425 horizontalScrollbar()->frameRect().contains(pointInFrame)) | 4425 horizontalScrollbar()->frameRect().contains(pointInFrame)) |
| 4426 return horizontalScrollbar(); | 4426 return horizontalScrollbar(); |
| (...skipping 834 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 5261 void FrameView::setAnimationHost( | 5261 void FrameView::setAnimationHost( |
| 5262 std::unique_ptr<CompositorAnimationHost> host) { | 5262 std::unique_ptr<CompositorAnimationHost> host) { |
| 5263 m_animationHost = std::move(host); | 5263 m_animationHost = std::move(host); |
| 5264 } | 5264 } |
| 5265 | 5265 |
| 5266 LayoutUnit FrameView::caretWidth() const { | 5266 LayoutUnit FrameView::caretWidth() const { |
| 5267 return LayoutUnit(getHostWindow()->windowToViewportScalar(1)); | 5267 return LayoutUnit(getHostWindow()->windowToViewportScalar(1)); |
| 5268 } | 5268 } |
| 5269 | 5269 |
| 5270 } // namespace blink | 5270 } // namespace blink |
| OLD | NEW |