| 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 1644 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1655 if (!layoutViewItem.isNull() && layoutViewItem.needsLayout()) | 1655 if (!layoutViewItem.isNull() && layoutViewItem.needsLayout()) |
| 1656 layout(); | 1656 layout(); |
| 1657 else | 1657 else |
| 1658 scrollToFragmentAnchor(); | 1658 scrollToFragmentAnchor(); |
| 1659 } | 1659 } |
| 1660 | 1660 |
| 1661 void FrameView::clearFragmentAnchor() { | 1661 void FrameView::clearFragmentAnchor() { |
| 1662 m_fragmentAnchor = nullptr; | 1662 m_fragmentAnchor = nullptr; |
| 1663 } | 1663 } |
| 1664 | 1664 |
| 1665 void FrameView::setScrollPosition(const DoublePoint& scrollPoint, | |
| 1666 ScrollType scrollType, | |
| 1667 ScrollBehavior scrollBehavior) { | |
| 1668 DoublePoint newScrollPosition = clampScrollPosition(scrollPoint); | |
| 1669 if (newScrollPosition == scrollPositionDouble()) | |
| 1670 return; | |
| 1671 | |
| 1672 if (scrollBehavior == ScrollBehaviorAuto) | |
| 1673 scrollBehavior = scrollBehaviorStyle(); | |
| 1674 | |
| 1675 ScrollableArea::setScrollPosition(newScrollPosition, scrollType, | |
| 1676 scrollBehavior); | |
| 1677 } | |
| 1678 | |
| 1679 void FrameView::didUpdateElasticOverscroll() { | 1665 void FrameView::didUpdateElasticOverscroll() { |
| 1680 Page* page = frame().page(); | 1666 Page* page = frame().page(); |
| 1681 if (!page) | 1667 if (!page) |
| 1682 return; | 1668 return; |
| 1683 FloatSize elasticOverscroll = page->chromeClient().elasticOverscroll(); | 1669 FloatSize elasticOverscroll = page->chromeClient().elasticOverscroll(); |
| 1684 if (m_horizontalScrollbar) { | 1670 if (m_horizontalScrollbar) { |
| 1685 float delta = | 1671 float delta = |
| 1686 elasticOverscroll.width() - m_horizontalScrollbar->elasticOverscroll(); | 1672 elasticOverscroll.width() - m_horizontalScrollbar->elasticOverscroll(); |
| 1687 if (delta != 0) { | 1673 if (delta != 0) { |
| 1688 m_horizontalScrollbar->setElasticOverscroll(elasticOverscroll.width()); | 1674 m_horizontalScrollbar->setElasticOverscroll(elasticOverscroll.width()); |
| (...skipping 24 matching lines...) Expand all Loading... |
| 1713 | 1699 |
| 1714 setLayoutSizeInternal(size); | 1700 setLayoutSizeInternal(size); |
| 1715 } | 1701 } |
| 1716 | 1702 |
| 1717 void FrameView::didScrollTimerFired(TimerBase*) { | 1703 void FrameView::didScrollTimerFired(TimerBase*) { |
| 1718 if (m_frame->document() && !m_frame->document()->layoutViewItem().isNull()) | 1704 if (m_frame->document() && !m_frame->document()->layoutViewItem().isNull()) |
| 1719 m_frame->document()->fetcher()->updateAllImageResourcePriorities(); | 1705 m_frame->document()->fetcher()->updateAllImageResourcePriorities(); |
| 1720 } | 1706 } |
| 1721 | 1707 |
| 1722 void FrameView::updateLayersAndCompositingAfterScrollIfNeeded( | 1708 void FrameView::updateLayersAndCompositingAfterScrollIfNeeded( |
| 1723 const DoubleSize& scrollDelta) { | 1709 const ScrollOffset& scrollDelta) { |
| 1724 // Nothing to do after scrolling if there are no fixed position elements. | 1710 // Nothing to do after scrolling if there are no fixed position elements. |
| 1725 if (!hasViewportConstrainedObjects()) | 1711 if (!hasViewportConstrainedObjects()) |
| 1726 return; | 1712 return; |
| 1727 | 1713 |
| 1728 // Update sticky position objects which are stuck to the viewport. | 1714 // Update sticky position objects which are stuck to the viewport. |
| 1729 for (const auto& viewportConstrainedObject : *m_viewportConstrainedObjects) { | 1715 for (const auto& viewportConstrainedObject : *m_viewportConstrainedObjects) { |
| 1730 LayoutObject* layoutObject = viewportConstrainedObject; | 1716 LayoutObject* layoutObject = viewportConstrainedObject; |
| 1731 PaintLayer* layer = toLayoutBoxModelObject(layoutObject)->layer(); | 1717 PaintLayer* layer = toLayoutBoxModelObject(layoutObject)->layer(); |
| 1732 if (layoutObject->style()->position() == StickyPosition) { | 1718 if (layoutObject->style()->position() == StickyPosition) { |
| 1733 // TODO(skobes): Resolve circular dependency between scroll offset and | 1719 // TODO(skobes): Resolve circular dependency between scroll offset and |
| (...skipping 1380 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 3114 overflow); // This is how we clip in case we overflow again. | 3100 overflow); // This is how we clip in case we overflow again. |
| 3115 } | 3101 } |
| 3116 } | 3102 } |
| 3117 | 3103 |
| 3118 adjustViewSizeAndLayout(); | 3104 adjustViewSizeAndLayout(); |
| 3119 } | 3105 } |
| 3120 | 3106 |
| 3121 IntRect FrameView::convertFromLayoutObject( | 3107 IntRect FrameView::convertFromLayoutObject( |
| 3122 const LayoutObject& layoutObject, | 3108 const LayoutObject& layoutObject, |
| 3123 const IntRect& layoutObjectRect) const { | 3109 const IntRect& layoutObjectRect) const { |
| 3124 IntRect rect = pixelSnappedIntRect(enclosingLayoutRect( | 3110 // Convert from page ("absolute") to FrameView coordinates. |
| 3111 LayoutRect rect = enclosingLayoutRect( |
| 3125 layoutObject.localToAbsoluteQuad(FloatRect(layoutObjectRect)) | 3112 layoutObject.localToAbsoluteQuad(FloatRect(layoutObjectRect)) |
| 3126 .boundingBox())); | 3113 .boundingBox()); |
| 3127 | 3114 rect.move(LayoutSize(-scrollOffset())); |
| 3128 // Convert from page ("absolute") to FrameView coordinates. | 3115 return pixelSnappedIntRect(rect); |
| 3129 rect.moveBy(-scrollPosition()); | |
| 3130 | |
| 3131 return rect; | |
| 3132 } | 3116 } |
| 3133 | 3117 |
| 3134 IntRect FrameView::convertToLayoutObject(const LayoutObject& layoutObject, | 3118 IntRect FrameView::convertToLayoutObject(const LayoutObject& layoutObject, |
| 3135 const IntRect& frameRect) const { | 3119 const IntRect& frameRect) const { |
| 3136 IntRect rectInContent = frameToContents(frameRect); | 3120 IntRect rectInContent = frameToContents(frameRect); |
| 3137 | 3121 |
| 3138 // Convert from FrameView coords into page ("absolute") coordinates. | 3122 // Convert from FrameView coords into page ("absolute") coordinates. |
| 3139 rectInContent.moveBy(scrollPosition()); | 3123 rectInContent.move(scrollOffsetInt()); |
| 3140 | 3124 |
| 3141 // FIXME: we don't have a way to map an absolute rect down to a local quad, so | 3125 // FIXME: we don't have a way to map an absolute rect down to a local quad, so |
| 3142 // just move the rect for now. | 3126 // just move the rect for now. |
| 3143 rectInContent.setLocation(roundedIntPoint( | 3127 rectInContent.setLocation(roundedIntPoint( |
| 3144 layoutObject.absoluteToLocal(rectInContent.location(), UseTransforms))); | 3128 layoutObject.absoluteToLocal(rectInContent.location(), UseTransforms))); |
| 3145 return rectInContent; | 3129 return rectInContent; |
| 3146 } | 3130 } |
| 3147 | 3131 |
| 3148 IntPoint FrameView::convertFromLayoutObject( | 3132 IntPoint FrameView::convertFromLayoutObject( |
| 3149 const LayoutObject& layoutObject, | 3133 const LayoutObject& layoutObject, |
| 3150 const IntPoint& layoutObjectPoint) const { | 3134 const IntPoint& layoutObjectPoint) const { |
| 3151 IntPoint point = roundedIntPoint( | 3135 IntPoint point = roundedIntPoint( |
| 3152 layoutObject.localToAbsolute(layoutObjectPoint, UseTransforms)); | 3136 layoutObject.localToAbsolute(layoutObjectPoint, UseTransforms)); |
| 3153 | 3137 |
| 3154 // Convert from page ("absolute") to FrameView coordinates. | 3138 // Convert from page ("absolute") to FrameView coordinates. |
| 3155 point.moveBy(-scrollPosition()); | 3139 point.move(-scrollOffsetInt()); |
| 3156 return point; | 3140 return point; |
| 3157 } | 3141 } |
| 3158 | 3142 |
| 3159 IntPoint FrameView::convertToLayoutObject(const LayoutObject& layoutObject, | 3143 IntPoint FrameView::convertToLayoutObject(const LayoutObject& layoutObject, |
| 3160 const IntPoint& framePoint) const { | 3144 const IntPoint& framePoint) const { |
| 3161 IntPoint point = framePoint; | 3145 IntPoint point = framePoint; |
| 3162 | 3146 |
| 3163 // Convert from FrameView coords into page ("absolute") coordinates. | 3147 // Convert from FrameView coords into page ("absolute") coordinates. |
| 3164 point += IntSize(scrollX(), scrollY()); | 3148 point += IntSize(scrollX(), scrollY()); |
| 3165 | 3149 |
| (...skipping 260 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 3426 | 3410 |
| 3427 void FrameView::didAddScrollbar(Scrollbar& scrollbar, | 3411 void FrameView::didAddScrollbar(Scrollbar& scrollbar, |
| 3428 ScrollbarOrientation orientation) { | 3412 ScrollbarOrientation orientation) { |
| 3429 ScrollableArea::didAddScrollbar(scrollbar, orientation); | 3413 ScrollableArea::didAddScrollbar(scrollbar, orientation); |
| 3430 } | 3414 } |
| 3431 | 3415 |
| 3432 void FrameView::setTopControlsViewportAdjustment(float adjustment) { | 3416 void FrameView::setTopControlsViewportAdjustment(float adjustment) { |
| 3433 m_topControlsViewportAdjustment = adjustment; | 3417 m_topControlsViewportAdjustment = adjustment; |
| 3434 } | 3418 } |
| 3435 | 3419 |
| 3436 IntPoint FrameView::maximumScrollPosition() const { | 3420 IntSize FrameView::maximumScrollOffsetInt() const { |
| 3437 // Make the same calculation as in CC's LayerImpl::MaxScrollOffset() | 3421 // Make the same calculation as in CC's LayerImpl::MaxScrollOffset() |
| 3438 // FIXME: We probably shouldn't be storing the bounds in a float. | 3422 // FIXME: We probably shouldn't be storing the bounds in a float. |
| 3439 // crbug.com/422331. | 3423 // crbug.com/422331. |
| 3440 IntSize visibleSize = | 3424 IntSize visibleSize = |
| 3441 visibleContentSize(ExcludeScrollbars) + topControlsSize(); | 3425 visibleContentSize(ExcludeScrollbars) + topControlsSize(); |
| 3442 IntSize contentBounds = contentsSize(); | 3426 IntSize contentBounds = contentsSize(); |
| 3443 IntPoint maximumPosition = -scrollOrigin() + (contentBounds - visibleSize); | 3427 IntSize maximumOffset = |
| 3444 return maximumPosition.expandedTo(minimumScrollPosition()); | 3428 toIntSize(-scrollOrigin() + (contentBounds - visibleSize)); |
| 3429 return maximumOffset.expandedTo(minimumScrollOffsetInt()); |
| 3445 } | 3430 } |
| 3446 | 3431 |
| 3447 void FrameView::addChild(Widget* child) { | 3432 void FrameView::addChild(Widget* child) { |
| 3448 ASSERT(child != this && !child->parent()); | 3433 ASSERT(child != this && !child->parent()); |
| 3449 child->setParent(this); | 3434 child->setParent(this); |
| 3450 m_children.add(child); | 3435 m_children.add(child); |
| 3451 } | 3436 } |
| 3452 | 3437 |
| 3453 void FrameView::setHasHorizontalScrollbar(bool hasBar) { | 3438 void FrameView::setHasHorizontalScrollbar(bool hasBar) { |
| 3454 if (hasBar == !!m_horizontalScrollbar) | 3439 if (hasBar == !!m_horizontalScrollbar) |
| (...skipping 90 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 3545 | 3530 |
| 3546 IntSize FrameView::visibleContentSize( | 3531 IntSize FrameView::visibleContentSize( |
| 3547 IncludeScrollbarsInRect scrollbarInclusion) const { | 3532 IncludeScrollbarsInRect scrollbarInclusion) const { |
| 3548 return scrollbarInclusion == ExcludeScrollbars | 3533 return scrollbarInclusion == ExcludeScrollbars |
| 3549 ? excludeScrollbars(frameRect().size()) | 3534 ? excludeScrollbars(frameRect().size()) |
| 3550 : frameRect().size(); | 3535 : frameRect().size(); |
| 3551 } | 3536 } |
| 3552 | 3537 |
| 3553 IntRect FrameView::visibleContentRect( | 3538 IntRect FrameView::visibleContentRect( |
| 3554 IncludeScrollbarsInRect scrollbarInclusion) const { | 3539 IncludeScrollbarsInRect scrollbarInclusion) const { |
| 3555 return IntRect(flooredIntPoint(m_scrollPosition), | 3540 return IntRect(IntPoint(flooredIntSize(m_scrollOffset)), |
| 3556 visibleContentSize(scrollbarInclusion)); | 3541 visibleContentSize(scrollbarInclusion)); |
| 3557 } | 3542 } |
| 3558 | 3543 |
| 3559 IntSize FrameView::contentsSize() const { | 3544 IntSize FrameView::contentsSize() const { |
| 3560 return m_contentsSize; | 3545 return m_contentsSize; |
| 3561 } | 3546 } |
| 3562 | 3547 |
| 3563 void FrameView::clipPaintRect(FloatRect* paintRect) const { | 3548 void FrameView::clipPaintRect(FloatRect* paintRect) const { |
| 3564 // Paint the whole rect if "mainFrameClipsContent" is false, meaning that | 3549 // Paint the whole rect if "mainFrameClipsContent" is false, meaning that |
| 3565 // WebPreferences::record_whole_document is true. | 3550 // WebPreferences::record_whole_document is true. |
| 3566 if (!m_frame->settings()->mainFrameClipsContent()) | 3551 if (!m_frame->settings()->mainFrameClipsContent()) |
| 3567 return; | 3552 return; |
| 3568 | 3553 |
| 3569 paintRect->intersect( | 3554 paintRect->intersect( |
| 3570 page()->chromeClient().visibleContentRectForPainting().value_or( | 3555 page()->chromeClient().visibleContentRectForPainting().value_or( |
| 3571 visibleContentRect())); | 3556 visibleContentRect())); |
| 3572 } | 3557 } |
| 3573 | 3558 |
| 3574 IntPoint FrameView::minimumScrollPosition() const { | 3559 IntSize FrameView::minimumScrollOffsetInt() const { |
| 3575 return IntPoint(-scrollOrigin().x(), -scrollOrigin().y()); | 3560 return IntSize(-scrollOrigin().x(), -scrollOrigin().y()); |
| 3576 } | 3561 } |
| 3577 | 3562 |
| 3578 void FrameView::adjustScrollbarOpacity() { | 3563 void FrameView::adjustScrollbarOpacity() { |
| 3579 if (m_horizontalScrollbar && layerForHorizontalScrollbar()) { | 3564 if (m_horizontalScrollbar && layerForHorizontalScrollbar()) { |
| 3580 bool isOpaqueScrollbar = !m_horizontalScrollbar->isOverlayScrollbar(); | 3565 bool isOpaqueScrollbar = !m_horizontalScrollbar->isOverlayScrollbar(); |
| 3581 layerForHorizontalScrollbar()->setContentsOpaque(isOpaqueScrollbar); | 3566 layerForHorizontalScrollbar()->setContentsOpaque(isOpaqueScrollbar); |
| 3582 } | 3567 } |
| 3583 if (m_verticalScrollbar && layerForVerticalScrollbar()) { | 3568 if (m_verticalScrollbar && layerForVerticalScrollbar()) { |
| 3584 bool isOpaqueScrollbar = !m_verticalScrollbar->isOverlayScrollbar(); | 3569 bool isOpaqueScrollbar = !m_verticalScrollbar->isOverlayScrollbar(); |
| 3585 layerForVerticalScrollbar()->setContentsOpaque(isOpaqueScrollbar); | 3570 layerForVerticalScrollbar()->setContentsOpaque(isOpaqueScrollbar); |
| (...skipping 10 matching lines...) Expand all Loading... |
| 3596 if (!scrollbar) { | 3581 if (!scrollbar) { |
| 3597 IntSize scrollSize = m_contentsSize - visibleContentRect().size(); | 3582 IntSize scrollSize = m_contentsSize - visibleContentRect().size(); |
| 3598 scrollSize.clampNegativeToZero(); | 3583 scrollSize.clampNegativeToZero(); |
| 3599 return orientation == HorizontalScrollbar ? scrollSize.width() | 3584 return orientation == HorizontalScrollbar ? scrollSize.width() |
| 3600 : scrollSize.height(); | 3585 : scrollSize.height(); |
| 3601 } | 3586 } |
| 3602 | 3587 |
| 3603 return scrollbar->totalSize() - scrollbar->visibleSize(); | 3588 return scrollbar->totalSize() - scrollbar->visibleSize(); |
| 3604 } | 3589 } |
| 3605 | 3590 |
| 3606 void FrameView::setScrollOffset(const DoublePoint& offset, | 3591 void FrameView::updateScrollOffset(const ScrollOffset& offset, |
| 3607 ScrollType scrollType) { | 3592 ScrollType scrollType) { |
| 3608 DoublePoint oldPosition = m_scrollPosition; | 3593 ScrollOffset scrollDelta = offset - m_scrollOffset; |
| 3609 DoubleSize scrollDelta = offset - oldPosition; | |
| 3610 if (scrollDelta.isZero()) | 3594 if (scrollDelta.isZero()) |
| 3611 return; | 3595 return; |
| 3612 | 3596 |
| 3613 if (RuntimeEnabledFeatures::rootLayerScrollingEnabled()) { | 3597 if (RuntimeEnabledFeatures::rootLayerScrollingEnabled()) { |
| 3614 // Don't scroll the FrameView! | 3598 // Don't scroll the FrameView! |
| 3615 ASSERT_NOT_REACHED(); | 3599 ASSERT_NOT_REACHED(); |
| 3616 } | 3600 } |
| 3617 | 3601 |
| 3618 m_scrollPosition = offset; | 3602 m_scrollOffset = offset; |
| 3619 | 3603 |
| 3620 if (!scrollbarsSuppressed()) | 3604 if (!scrollbarsSuppressed()) |
| 3621 m_pendingScrollDelta += scrollDelta; | 3605 m_pendingScrollDelta += scrollDelta; |
| 3622 | 3606 |
| 3623 clearFragmentAnchor(); | 3607 clearFragmentAnchor(); |
| 3624 updateLayersAndCompositingAfterScrollIfNeeded(scrollDelta); | 3608 updateLayersAndCompositingAfterScrollIfNeeded(scrollDelta); |
| 3625 | 3609 |
| 3626 Document* document = m_frame->document(); | 3610 Document* document = m_frame->document(); |
| 3627 document->enqueueScrollEventForNode(document); | 3611 document->enqueueScrollEventForNode(document); |
| 3628 | 3612 |
| (...skipping 242 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 3871 void FrameView::updateScrollbars() { | 3855 void FrameView::updateScrollbars() { |
| 3872 m_needsScrollbarsUpdate = false; | 3856 m_needsScrollbarsUpdate = false; |
| 3873 | 3857 |
| 3874 if (RuntimeEnabledFeatures::rootLayerScrollingEnabled()) | 3858 if (RuntimeEnabledFeatures::rootLayerScrollingEnabled()) |
| 3875 return; | 3859 return; |
| 3876 | 3860 |
| 3877 // Avoid drawing two sets of scrollbars when visual viewport is enabled. | 3861 // Avoid drawing two sets of scrollbars when visual viewport is enabled. |
| 3878 if (visualViewportSuppliesScrollbars()) { | 3862 if (visualViewportSuppliesScrollbars()) { |
| 3879 setHasHorizontalScrollbar(false); | 3863 setHasHorizontalScrollbar(false); |
| 3880 setHasVerticalScrollbar(false); | 3864 setHasVerticalScrollbar(false); |
| 3881 adjustScrollPositionFromUpdateScrollbars(); | 3865 adjustScrollOffsetFromUpdateScrollbars(); |
| 3882 return; | 3866 return; |
| 3883 } | 3867 } |
| 3884 | 3868 |
| 3885 if (m_inUpdateScrollbars) | 3869 if (m_inUpdateScrollbars) |
| 3886 return; | 3870 return; |
| 3887 InUpdateScrollbarsScope inUpdateScrollbarsScope(this); | 3871 InUpdateScrollbarsScope inUpdateScrollbarsScope(this); |
| 3888 | 3872 |
| 3889 bool scrollbarExistenceChanged = false; | 3873 bool scrollbarExistenceChanged = false; |
| 3890 | 3874 |
| 3891 if (needsScrollbarReconstruction()) { | 3875 if (needsScrollbarReconstruction()) { |
| (...skipping 15 matching lines...) Expand all Loading... |
| 3907 updateScrollbarGeometry(); | 3891 updateScrollbarGeometry(); |
| 3908 | 3892 |
| 3909 if (scrollbarExistenceChanged) { | 3893 if (scrollbarExistenceChanged) { |
| 3910 // FIXME: Is frameRectsChanged really necessary here? Have any frame rects | 3894 // FIXME: Is frameRectsChanged really necessary here? Have any frame rects |
| 3911 // changed? | 3895 // changed? |
| 3912 frameRectsChanged(); | 3896 frameRectsChanged(); |
| 3913 positionScrollbarLayers(); | 3897 positionScrollbarLayers(); |
| 3914 updateScrollCorner(); | 3898 updateScrollCorner(); |
| 3915 } | 3899 } |
| 3916 | 3900 |
| 3917 adjustScrollPositionFromUpdateScrollbars(); | 3901 adjustScrollOffsetFromUpdateScrollbars(); |
| 3918 } | 3902 } |
| 3919 | 3903 |
| 3920 void FrameView::adjustScrollPositionFromUpdateScrollbars() { | 3904 void FrameView::adjustScrollOffsetFromUpdateScrollbars() { |
| 3921 DoublePoint clamped = clampScrollPosition(scrollPositionDouble()); | 3905 ScrollOffset clamped = clampScrollOffset(scrollOffset()); |
| 3922 // Restore before clamping because clamping clears the scroll anchor. | 3906 // Restore before clamping because clamping clears the scroll anchor. |
| 3923 // TODO(ymalik): This same logic exists in PaintLayerScrollableArea. | 3907 // TODO(ymalik): This same logic exists in PaintLayerScrollableArea. |
| 3924 // Remove when root-layer-scrolls is enabled. | 3908 // Remove when root-layer-scrolls is enabled. |
| 3925 if (clamped != scrollPositionDouble() && shouldPerformScrollAnchoring()) { | 3909 if (clamped != scrollOffset() && shouldPerformScrollAnchoring()) { |
| 3926 m_scrollAnchor.restore(); | 3910 m_scrollAnchor.restore(); |
| 3927 clamped = clampScrollPosition(scrollPositionDouble()); | 3911 clamped = clampScrollOffset(scrollOffset()); |
| 3928 } | 3912 } |
| 3929 if (clamped != scrollPositionDouble() || scrollOriginChanged()) { | 3913 if (clamped != scrollOffset() || scrollOriginChanged()) { |
| 3930 ScrollableArea::setScrollPosition(clamped, ProgrammaticScroll); | 3914 ScrollableArea::setScrollOffset(clamped, ProgrammaticScroll); |
| 3931 resetScrollOriginChanged(); | 3915 resetScrollOriginChanged(); |
| 3932 } | 3916 } |
| 3933 } | 3917 } |
| 3934 | 3918 |
| 3935 void FrameView::scrollContentsIfNeeded() { | 3919 void FrameView::scrollContentsIfNeeded() { |
| 3936 if (m_pendingScrollDelta.isZero()) | 3920 if (m_pendingScrollDelta.isZero()) |
| 3937 return; | 3921 return; |
| 3938 DoubleSize scrollDelta = m_pendingScrollDelta; | 3922 ScrollOffset scrollDelta = m_pendingScrollDelta; |
| 3939 m_pendingScrollDelta = DoubleSize(); | 3923 m_pendingScrollDelta = ScrollOffset(); |
| 3940 // FIXME: Change scrollContents() to take DoubleSize. crbug.com/414283. | 3924 // FIXME: Change scrollContents() to take DoubleSize. crbug.com/414283. |
| 3941 scrollContents(flooredIntSize(scrollDelta)); | 3925 scrollContents(flooredIntSize(scrollDelta)); |
| 3942 } | 3926 } |
| 3943 | 3927 |
| 3944 void FrameView::scrollContents(const IntSize& scrollDelta) { | 3928 void FrameView::scrollContents(const IntSize& scrollDelta) { |
| 3945 HostWindow* window = getHostWindow(); | 3929 HostWindow* window = getHostWindow(); |
| 3946 if (!window) | 3930 if (!window) |
| 3947 return; | 3931 return; |
| 3948 | 3932 |
| 3949 TRACE_EVENT0("blink", "FrameView::scrollContents"); | 3933 TRACE_EVENT0("blink", "FrameView::scrollContents"); |
| 3950 | 3934 |
| 3951 if (!scrollContentsFastPath(-scrollDelta)) | 3935 if (!scrollContentsFastPath(-scrollDelta)) |
| 3952 scrollContentsSlowPath(); | 3936 scrollContentsSlowPath(); |
| 3953 | 3937 |
| 3954 // This call will move children with native widgets (plugins) and invalidate | 3938 // This call will move children with native widgets (plugins) and invalidate |
| 3955 // them as well. | 3939 // them as well. |
| 3956 frameRectsChanged(); | 3940 frameRectsChanged(); |
| 3957 } | 3941 } |
| 3958 | 3942 |
| 3959 IntPoint FrameView::contentsToFrame(const IntPoint& pointInContentSpace) const { | 3943 IntPoint FrameView::contentsToFrame(const IntPoint& pointInContentSpace) const { |
| 3960 return pointInContentSpace - scrollOffset(); | 3944 return pointInContentSpace - scrollOffsetInt(); |
| 3961 } | 3945 } |
| 3962 | 3946 |
| 3963 IntRect FrameView::contentsToFrame(const IntRect& rectInContentSpace) const { | 3947 IntRect FrameView::contentsToFrame(const IntRect& rectInContentSpace) const { |
| 3964 return IntRect(contentsToFrame(rectInContentSpace.location()), | 3948 return IntRect(contentsToFrame(rectInContentSpace.location()), |
| 3965 rectInContentSpace.size()); | 3949 rectInContentSpace.size()); |
| 3966 } | 3950 } |
| 3967 | 3951 |
| 3968 FloatPoint FrameView::frameToContents(const FloatPoint& pointInFrame) const { | 3952 FloatPoint FrameView::frameToContents(const FloatPoint& pointInFrame) const { |
| 3969 return pointInFrame + scrollOffset(); | 3953 return pointInFrame + scrollOffset(); |
| 3970 } | 3954 } |
| 3971 | 3955 |
| 3972 IntPoint FrameView::frameToContents(const IntPoint& pointInFrame) const { | 3956 IntPoint FrameView::frameToContents(const IntPoint& pointInFrame) const { |
| 3973 return pointInFrame + scrollOffset(); | 3957 return pointInFrame + scrollOffsetInt(); |
| 3974 } | 3958 } |
| 3975 | 3959 |
| 3976 IntRect FrameView::frameToContents(const IntRect& rectInFrame) const { | 3960 IntRect FrameView::frameToContents(const IntRect& rectInFrame) const { |
| 3977 return IntRect(frameToContents(rectInFrame.location()), rectInFrame.size()); | 3961 return IntRect(frameToContents(rectInFrame.location()), rectInFrame.size()); |
| 3978 } | 3962 } |
| 3979 | 3963 |
| 3980 IntPoint FrameView::rootFrameToContents(const IntPoint& rootFramePoint) const { | 3964 IntPoint FrameView::rootFrameToContents(const IntPoint& rootFramePoint) const { |
| 3981 IntPoint framePoint = convertFromRootFrame(rootFramePoint); | 3965 IntPoint framePoint = convertFromRootFrame(rootFramePoint); |
| 3982 return frameToContents(framePoint); | 3966 return frameToContents(framePoint); |
| 3983 } | 3967 } |
| (...skipping 166 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 4150 return this; | 4134 return this; |
| 4151 } | 4135 } |
| 4152 | 4136 |
| 4153 LayoutRect FrameView::scrollIntoView(const LayoutRect& rectInContent, | 4137 LayoutRect FrameView::scrollIntoView(const LayoutRect& rectInContent, |
| 4154 const ScrollAlignment& alignX, | 4138 const ScrollAlignment& alignX, |
| 4155 const ScrollAlignment& alignY, | 4139 const ScrollAlignment& alignY, |
| 4156 ScrollType scrollType) { | 4140 ScrollType scrollType) { |
| 4157 LayoutRect viewRect(visibleContentRect()); | 4141 LayoutRect viewRect(visibleContentRect()); |
| 4158 LayoutRect exposeRect = | 4142 LayoutRect exposeRect = |
| 4159 ScrollAlignment::getRectToExpose(viewRect, rectInContent, alignX, alignY); | 4143 ScrollAlignment::getRectToExpose(viewRect, rectInContent, alignX, alignY); |
| 4160 if (exposeRect != viewRect) | 4144 if (exposeRect != viewRect) { |
| 4161 setScrollPosition(DoublePoint(exposeRect.x(), exposeRect.y()), scrollType); | 4145 setScrollOffset( |
| 4146 ScrollOffset(exposeRect.x().toFloat(), exposeRect.y().toFloat()), |
| 4147 scrollType); |
| 4148 } |
| 4162 | 4149 |
| 4163 // Scrolling the FrameView cannot change the input rect's location relative to | 4150 // Scrolling the FrameView cannot change the input rect's location relative to |
| 4164 // the document. | 4151 // the document. |
| 4165 return rectInContent; | 4152 return rectInContent; |
| 4166 } | 4153 } |
| 4167 | 4154 |
| 4168 IntRect FrameView::scrollCornerRect() const { | 4155 IntRect FrameView::scrollCornerRect() const { |
| 4169 IntRect cornerRect; | 4156 IntRect cornerRect; |
| 4170 | 4157 |
| 4171 if (hasOverlayScrollbars()) | 4158 if (hasOverlayScrollbars()) |
| (...skipping 398 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 4570 } | 4557 } |
| 4571 | 4558 |
| 4572 bool FrameView::canThrottleRendering() const { | 4559 bool FrameView::canThrottleRendering() const { |
| 4573 if (!RuntimeEnabledFeatures::renderingPipelineThrottlingEnabled()) | 4560 if (!RuntimeEnabledFeatures::renderingPipelineThrottlingEnabled()) |
| 4574 return false; | 4561 return false; |
| 4575 return m_subtreeThrottled || | 4562 return m_subtreeThrottled || |
| 4576 (m_hiddenForThrottling && m_crossOriginForThrottling); | 4563 (m_hiddenForThrottling && m_crossOriginForThrottling); |
| 4577 } | 4564 } |
| 4578 | 4565 |
| 4579 } // namespace blink | 4566 } // namespace blink |
| OLD | NEW |