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

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

Issue 2387883002: Use float for scroll offset. (Closed)
Patch Set: tweaks and docs Created 4 years, 2 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 unified diff | Download patch
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 1624 matching lines...) Expand 10 before | Expand all | Expand 10 after
1635 if (!layoutViewItem.isNull() && layoutViewItem.needsLayout()) 1635 if (!layoutViewItem.isNull() && layoutViewItem.needsLayout())
1636 layout(); 1636 layout();
1637 else 1637 else
1638 scrollToFragmentAnchor(); 1638 scrollToFragmentAnchor();
1639 } 1639 }
1640 1640
1641 void FrameView::clearFragmentAnchor() { 1641 void FrameView::clearFragmentAnchor() {
1642 m_fragmentAnchor = nullptr; 1642 m_fragmentAnchor = nullptr;
1643 } 1643 }
1644 1644
1645 void FrameView::setScrollPosition(const DoublePoint& scrollPoint,
1646 ScrollType scrollType,
1647 ScrollBehavior scrollBehavior) {
1648 DoublePoint newScrollPosition = clampScrollPosition(scrollPoint);
1649 if (newScrollPosition == scrollPositionDouble())
1650 return;
1651
1652 if (scrollBehavior == ScrollBehaviorAuto)
1653 scrollBehavior = scrollBehaviorStyle();
1654
1655 ScrollableArea::setScrollPosition(newScrollPosition, scrollType,
1656 scrollBehavior);
1657 }
1658
1659 void FrameView::didUpdateElasticOverscroll() { 1645 void FrameView::didUpdateElasticOverscroll() {
1660 Page* page = frame().page(); 1646 Page* page = frame().page();
1661 if (!page) 1647 if (!page)
1662 return; 1648 return;
1663 FloatSize elasticOverscroll = page->chromeClient().elasticOverscroll(); 1649 FloatSize elasticOverscroll = page->chromeClient().elasticOverscroll();
1664 if (m_horizontalScrollbar) { 1650 if (m_horizontalScrollbar) {
1665 float delta = 1651 float delta =
1666 elasticOverscroll.width() - m_horizontalScrollbar->elasticOverscroll(); 1652 elasticOverscroll.width() - m_horizontalScrollbar->elasticOverscroll();
1667 if (delta != 0) { 1653 if (delta != 0) {
1668 m_horizontalScrollbar->setElasticOverscroll(elasticOverscroll.width()); 1654 m_horizontalScrollbar->setElasticOverscroll(elasticOverscroll.width());
(...skipping 24 matching lines...) Expand all
1693 1679
1694 setLayoutSizeInternal(size); 1680 setLayoutSizeInternal(size);
1695 } 1681 }
1696 1682
1697 void FrameView::didScrollTimerFired(TimerBase*) { 1683 void FrameView::didScrollTimerFired(TimerBase*) {
1698 if (m_frame->document() && !m_frame->document()->layoutViewItem().isNull()) 1684 if (m_frame->document() && !m_frame->document()->layoutViewItem().isNull())
1699 m_frame->document()->fetcher()->updateAllImageResourcePriorities(); 1685 m_frame->document()->fetcher()->updateAllImageResourcePriorities();
1700 } 1686 }
1701 1687
1702 void FrameView::updateLayersAndCompositingAfterScrollIfNeeded( 1688 void FrameView::updateLayersAndCompositingAfterScrollIfNeeded(
1703 const DoubleSize& scrollDelta) { 1689 const ScrollOffset& scrollDelta) {
1704 // Nothing to do after scrolling if there are no fixed position elements. 1690 // Nothing to do after scrolling if there are no fixed position elements.
1705 if (!hasViewportConstrainedObjects()) 1691 if (!hasViewportConstrainedObjects())
1706 return; 1692 return;
1707 1693
1708 // Update sticky position objects which are stuck to the viewport. 1694 // Update sticky position objects which are stuck to the viewport.
1709 for (const auto& viewportConstrainedObject : *m_viewportConstrainedObjects) { 1695 for (const auto& viewportConstrainedObject : *m_viewportConstrainedObjects) {
1710 LayoutObject* layoutObject = viewportConstrainedObject; 1696 LayoutObject* layoutObject = viewportConstrainedObject;
1711 PaintLayer* layer = toLayoutBoxModelObject(layoutObject)->layer(); 1697 PaintLayer* layer = toLayoutBoxModelObject(layoutObject)->layer();
1712 if (layoutObject->style()->position() == StickyPosition) { 1698 if (layoutObject->style()->position() == StickyPosition) {
1713 // TODO(skobes): Resolve circular dependency between scroll offset and 1699 // TODO(skobes): Resolve circular dependency between scroll offset and
(...skipping 1354 matching lines...) Expand 10 before | Expand all | Expand 10 after
3068 overflow); // This is how we clip in case we overflow again. 3054 overflow); // This is how we clip in case we overflow again.
3069 } 3055 }
3070 } 3056 }
3071 3057
3072 adjustViewSizeAndLayout(); 3058 adjustViewSizeAndLayout();
3073 } 3059 }
3074 3060
3075 IntRect FrameView::convertFromLayoutObject( 3061 IntRect FrameView::convertFromLayoutObject(
3076 const LayoutObject& layoutObject, 3062 const LayoutObject& layoutObject,
3077 const IntRect& layoutObjectRect) const { 3063 const IntRect& layoutObjectRect) const {
3078 IntRect rect = pixelSnappedIntRect(enclosingLayoutRect( 3064 // Convert from page ("absolute") to FrameView coordinates.
3065 LayoutRect rect = enclosingLayoutRect(
3079 layoutObject.localToAbsoluteQuad(FloatRect(layoutObjectRect)) 3066 layoutObject.localToAbsoluteQuad(FloatRect(layoutObjectRect))
3080 .boundingBox())); 3067 .boundingBox());
3081 3068 rect.move(LayoutSize(-scrollOffset()));
3082 // Convert from page ("absolute") to FrameView coordinates. 3069 return pixelSnappedIntRect(rect);
3083 rect.moveBy(-scrollPosition());
3084
3085 return rect;
3086 } 3070 }
3087 3071
3088 IntRect FrameView::convertToLayoutObject(const LayoutObject& layoutObject, 3072 IntRect FrameView::convertToLayoutObject(const LayoutObject& layoutObject,
3089 const IntRect& frameRect) const { 3073 const IntRect& frameRect) const {
3090 IntRect rectInContent = frameToContents(frameRect); 3074 IntRect rectInContent = frameToContents(frameRect);
3091 3075
3092 // Convert from FrameView coords into page ("absolute") coordinates. 3076 // Convert from FrameView coords into page ("absolute") coordinates.
3093 rectInContent.moveBy(scrollPosition()); 3077 rectInContent.move(scrollOffsetInt());
3094 3078
3095 // FIXME: we don't have a way to map an absolute rect down to a local quad, so just 3079 // FIXME: we don't have a way to map an absolute rect down to a local quad, so just
3096 // move the rect for now. 3080 // move the rect for now.
3097 rectInContent.setLocation(roundedIntPoint( 3081 rectInContent.setLocation(roundedIntPoint(
3098 layoutObject.absoluteToLocal(rectInContent.location(), UseTransforms))); 3082 layoutObject.absoluteToLocal(rectInContent.location(), UseTransforms)));
3099 return rectInContent; 3083 return rectInContent;
3100 } 3084 }
3101 3085
3102 IntPoint FrameView::convertFromLayoutObject( 3086 IntPoint FrameView::convertFromLayoutObject(
3103 const LayoutObject& layoutObject, 3087 const LayoutObject& layoutObject,
3104 const IntPoint& layoutObjectPoint) const { 3088 const IntPoint& layoutObjectPoint) const {
3105 IntPoint point = roundedIntPoint( 3089 IntPoint point = roundedIntPoint(
3106 layoutObject.localToAbsolute(layoutObjectPoint, UseTransforms)); 3090 layoutObject.localToAbsolute(layoutObjectPoint, UseTransforms));
3107 3091
3108 // Convert from page ("absolute") to FrameView coordinates. 3092 // Convert from page ("absolute") to FrameView coordinates.
3109 point.moveBy(-scrollPosition()); 3093 point.move(-scrollOffsetInt());
3110 return point; 3094 return point;
3111 } 3095 }
3112 3096
3113 IntPoint FrameView::convertToLayoutObject(const LayoutObject& layoutObject, 3097 IntPoint FrameView::convertToLayoutObject(const LayoutObject& layoutObject,
3114 const IntPoint& framePoint) const { 3098 const IntPoint& framePoint) const {
3115 IntPoint point = framePoint; 3099 IntPoint point = framePoint;
3116 3100
3117 // Convert from FrameView coords into page ("absolute") coordinates. 3101 // Convert from FrameView coords into page ("absolute") coordinates.
3118 point += IntSize(scrollX(), scrollY()); 3102 point += IntSize(scrollX(), scrollY());
3119 3103
(...skipping 260 matching lines...) Expand 10 before | Expand all | Expand 10 after
3380 3364
3381 void FrameView::didAddScrollbar(Scrollbar& scrollbar, 3365 void FrameView::didAddScrollbar(Scrollbar& scrollbar,
3382 ScrollbarOrientation orientation) { 3366 ScrollbarOrientation orientation) {
3383 ScrollableArea::didAddScrollbar(scrollbar, orientation); 3367 ScrollableArea::didAddScrollbar(scrollbar, orientation);
3384 } 3368 }
3385 3369
3386 void FrameView::setTopControlsViewportAdjustment(float adjustment) { 3370 void FrameView::setTopControlsViewportAdjustment(float adjustment) {
3387 m_topControlsViewportAdjustment = adjustment; 3371 m_topControlsViewportAdjustment = adjustment;
3388 } 3372 }
3389 3373
3390 IntPoint FrameView::maximumScrollPosition() const { 3374 IntSize FrameView::maximumScrollOffsetInt() const {
3391 // Make the same calculation as in CC's LayerImpl::MaxScrollOffset() 3375 // Make the same calculation as in CC's LayerImpl::MaxScrollOffset()
3392 // FIXME: We probably shouldn't be storing the bounds in a float. crbug.com/42 2331. 3376 // FIXME: We probably shouldn't be storing the bounds in a float. crbug.com/42 2331.
3393 IntSize visibleSize = 3377 IntSize visibleSize =
3394 visibleContentSize(ExcludeScrollbars) + topControlsSize(); 3378 visibleContentSize(ExcludeScrollbars) + topControlsSize();
3395 IntSize contentBounds = contentsSize(); 3379 IntSize contentBounds = contentsSize();
3396 IntPoint maximumPosition = -scrollOrigin() + (contentBounds - visibleSize); 3380 IntSize maximumOffset =
3397 return maximumPosition.expandedTo(minimumScrollPosition()); 3381 toIntSize(-scrollOrigin() + (contentBounds - visibleSize));
3382 return maximumOffset.expandedTo(minimumScrollOffsetInt());
3398 } 3383 }
3399 3384
3400 void FrameView::addChild(Widget* child) { 3385 void FrameView::addChild(Widget* child) {
3401 ASSERT(child != this && !child->parent()); 3386 ASSERT(child != this && !child->parent());
3402 child->setParent(this); 3387 child->setParent(this);
3403 m_children.add(child); 3388 m_children.add(child);
3404 } 3389 }
3405 3390
3406 void FrameView::setHasHorizontalScrollbar(bool hasBar) { 3391 void FrameView::setHasHorizontalScrollbar(bool hasBar) {
3407 if (m_frame->settings() && m_frame->settings()->hideScrollbars()) 3392 if (m_frame->settings() && m_frame->settings()->hideScrollbars())
(...skipping 96 matching lines...) Expand 10 before | Expand all | Expand 10 after
3504 3489
3505 IntSize FrameView::visibleContentSize( 3490 IntSize FrameView::visibleContentSize(
3506 IncludeScrollbarsInRect scrollbarInclusion) const { 3491 IncludeScrollbarsInRect scrollbarInclusion) const {
3507 return scrollbarInclusion == ExcludeScrollbars 3492 return scrollbarInclusion == ExcludeScrollbars
3508 ? excludeScrollbars(frameRect().size()) 3493 ? excludeScrollbars(frameRect().size())
3509 : frameRect().size(); 3494 : frameRect().size();
3510 } 3495 }
3511 3496
3512 IntRect FrameView::visibleContentRect( 3497 IntRect FrameView::visibleContentRect(
3513 IncludeScrollbarsInRect scrollbarInclusion) const { 3498 IncludeScrollbarsInRect scrollbarInclusion) const {
3514 return IntRect(flooredIntPoint(m_scrollPosition), 3499 return IntRect(IntPoint(flooredIntSize(m_scrollOffset)),
3515 visibleContentSize(scrollbarInclusion)); 3500 visibleContentSize(scrollbarInclusion));
3516 } 3501 }
3517 3502
3518 IntSize FrameView::contentsSize() const { 3503 IntSize FrameView::contentsSize() const {
3519 return m_contentsSize; 3504 return m_contentsSize;
3520 } 3505 }
3521 3506
3522 void FrameView::clipPaintRect(FloatRect* paintRect) const { 3507 void FrameView::clipPaintRect(FloatRect* paintRect) const {
3523 // Paint the whole rect if "mainFrameClipsContent" is false, meaning that 3508 // Paint the whole rect if "mainFrameClipsContent" is false, meaning that
3524 // WebPreferences::record_whole_document is true. 3509 // WebPreferences::record_whole_document is true.
3525 if (!m_frame->settings()->mainFrameClipsContent()) 3510 if (!m_frame->settings()->mainFrameClipsContent())
3526 return; 3511 return;
3527 3512
3528 paintRect->intersect( 3513 paintRect->intersect(
3529 page()->chromeClient().visibleContentRectForPainting().value_or( 3514 page()->chromeClient().visibleContentRectForPainting().value_or(
3530 visibleContentRect())); 3515 visibleContentRect()));
3531 } 3516 }
3532 3517
3533 IntPoint FrameView::minimumScrollPosition() const { 3518 IntSize FrameView::minimumScrollOffsetInt() const {
3534 return IntPoint(-scrollOrigin().x(), -scrollOrigin().y()); 3519 return IntSize(-scrollOrigin().x(), -scrollOrigin().y());
3535 } 3520 }
3536 3521
3537 void FrameView::adjustScrollbarOpacity() { 3522 void FrameView::adjustScrollbarOpacity() {
3538 if (m_horizontalScrollbar && layerForHorizontalScrollbar()) { 3523 if (m_horizontalScrollbar && layerForHorizontalScrollbar()) {
3539 bool isOpaqueScrollbar = !m_horizontalScrollbar->isOverlayScrollbar(); 3524 bool isOpaqueScrollbar = !m_horizontalScrollbar->isOverlayScrollbar();
3540 layerForHorizontalScrollbar()->setContentsOpaque(isOpaqueScrollbar); 3525 layerForHorizontalScrollbar()->setContentsOpaque(isOpaqueScrollbar);
3541 } 3526 }
3542 if (m_verticalScrollbar && layerForVerticalScrollbar()) { 3527 if (m_verticalScrollbar && layerForVerticalScrollbar()) {
3543 bool isOpaqueScrollbar = !m_verticalScrollbar->isOverlayScrollbar(); 3528 bool isOpaqueScrollbar = !m_verticalScrollbar->isOverlayScrollbar();
3544 layerForVerticalScrollbar()->setContentsOpaque(isOpaqueScrollbar); 3529 layerForVerticalScrollbar()->setContentsOpaque(isOpaqueScrollbar);
(...skipping 10 matching lines...) Expand all
3555 if (!scrollbar) { 3540 if (!scrollbar) {
3556 IntSize scrollSize = m_contentsSize - visibleContentRect().size(); 3541 IntSize scrollSize = m_contentsSize - visibleContentRect().size();
3557 scrollSize.clampNegativeToZero(); 3542 scrollSize.clampNegativeToZero();
3558 return orientation == HorizontalScrollbar ? scrollSize.width() 3543 return orientation == HorizontalScrollbar ? scrollSize.width()
3559 : scrollSize.height(); 3544 : scrollSize.height();
3560 } 3545 }
3561 3546
3562 return scrollbar->totalSize() - scrollbar->visibleSize(); 3547 return scrollbar->totalSize() - scrollbar->visibleSize();
3563 } 3548 }
3564 3549
3565 void FrameView::setScrollOffset(const DoublePoint& offset, 3550 void FrameView::updateScrollOffset(const ScrollOffset& offset,
3566 ScrollType scrollType) { 3551 ScrollType scrollType) {
3567 DoublePoint oldPosition = m_scrollPosition; 3552 ScrollOffset scrollDelta = offset - m_scrollOffset;
3568 DoubleSize scrollDelta = offset - oldPosition;
3569 if (scrollDelta.isZero()) 3553 if (scrollDelta.isZero())
3570 return; 3554 return;
3571 3555
3572 if (RuntimeEnabledFeatures::rootLayerScrollingEnabled()) { 3556 if (RuntimeEnabledFeatures::rootLayerScrollingEnabled()) {
3573 // Don't scroll the FrameView! 3557 // Don't scroll the FrameView!
3574 ASSERT_NOT_REACHED(); 3558 ASSERT_NOT_REACHED();
3575 } 3559 }
3576 3560
3577 m_scrollPosition = offset; 3561 m_scrollOffset = offset;
3578 3562
3579 if (!scrollbarsSuppressed()) 3563 if (!scrollbarsSuppressed())
3580 m_pendingScrollDelta += scrollDelta; 3564 m_pendingScrollDelta += scrollDelta;
3581 3565
3582 clearFragmentAnchor(); 3566 clearFragmentAnchor();
3583 updateLayersAndCompositingAfterScrollIfNeeded(scrollDelta); 3567 updateLayersAndCompositingAfterScrollIfNeeded(scrollDelta);
3584 3568
3585 Document* document = m_frame->document(); 3569 Document* document = m_frame->document();
3586 document->enqueueScrollEventForNode(document); 3570 document->enqueueScrollEventForNode(document);
3587 3571
(...skipping 235 matching lines...) Expand 10 before | Expand all | Expand 10 after
3823 void FrameView::updateScrollbars() { 3807 void FrameView::updateScrollbars() {
3824 m_needsScrollbarsUpdate = false; 3808 m_needsScrollbarsUpdate = false;
3825 3809
3826 if (RuntimeEnabledFeatures::rootLayerScrollingEnabled()) 3810 if (RuntimeEnabledFeatures::rootLayerScrollingEnabled())
3827 return; 3811 return;
3828 3812
3829 // Avoid drawing two sets of scrollbars when visual viewport is enabled. 3813 // Avoid drawing two sets of scrollbars when visual viewport is enabled.
3830 if (visualViewportSuppliesScrollbars()) { 3814 if (visualViewportSuppliesScrollbars()) {
3831 setHasHorizontalScrollbar(false); 3815 setHasHorizontalScrollbar(false);
3832 setHasVerticalScrollbar(false); 3816 setHasVerticalScrollbar(false);
3833 adjustScrollPositionFromUpdateScrollbars(); 3817 adjustScrollOffsetFromUpdateScrollbars();
3834 return; 3818 return;
3835 } 3819 }
3836 3820
3837 if (m_inUpdateScrollbars) 3821 if (m_inUpdateScrollbars)
3838 return; 3822 return;
3839 InUpdateScrollbarsScope inUpdateScrollbarsScope(this); 3823 InUpdateScrollbarsScope inUpdateScrollbarsScope(this);
3840 3824
3841 bool scrollbarExistenceChanged = false; 3825 bool scrollbarExistenceChanged = false;
3842 3826
3843 if (needsScrollbarReconstruction()) { 3827 if (needsScrollbarReconstruction()) {
(...skipping 14 matching lines...) Expand all
3858 3842
3859 updateScrollbarGeometry(); 3843 updateScrollbarGeometry();
3860 3844
3861 if (scrollbarExistenceChanged) { 3845 if (scrollbarExistenceChanged) {
3862 // FIXME: Is frameRectsChanged really necessary here? Have any frame rects c hanged? 3846 // FIXME: Is frameRectsChanged really necessary here? Have any frame rects c hanged?
3863 frameRectsChanged(); 3847 frameRectsChanged();
3864 positionScrollbarLayers(); 3848 positionScrollbarLayers();
3865 updateScrollCorner(); 3849 updateScrollCorner();
3866 } 3850 }
3867 3851
3868 adjustScrollPositionFromUpdateScrollbars(); 3852 adjustScrollOffsetFromUpdateScrollbars();
3869 } 3853 }
3870 3854
3871 void FrameView::adjustScrollPositionFromUpdateScrollbars() { 3855 void FrameView::adjustScrollOffsetFromUpdateScrollbars() {
3872 DoublePoint clamped = clampScrollPosition(scrollPositionDouble()); 3856 ScrollOffset clamped = clampScrollOffset(scrollOffset());
3873 // Restore before clamping because clamping clears the scroll anchor. 3857 // Restore before clamping because clamping clears the scroll anchor.
3874 // TODO(ymalik): This same logic exists in PaintLayerScrollableArea. 3858 // TODO(ymalik): This same logic exists in PaintLayerScrollableArea.
3875 // Remove when root-layer-scrolls is enabled. 3859 // Remove when root-layer-scrolls is enabled.
3876 if (clamped != scrollPositionDouble() && shouldPerformScrollAnchoring()) { 3860 if (clamped != scrollOffset() && shouldPerformScrollAnchoring()) {
3877 m_scrollAnchor.restore(); 3861 m_scrollAnchor.restore();
3878 clamped = clampScrollPosition(scrollPositionDouble()); 3862 clamped = clampScrollOffset(scrollOffset());
3879 } 3863 }
3880 if (clamped != scrollPositionDouble() || scrollOriginChanged()) { 3864 if (clamped != scrollOffset() || scrollOriginChanged()) {
3881 ScrollableArea::setScrollPosition(clamped, ProgrammaticScroll); 3865 ScrollableArea::setScrollOffset(clamped, ProgrammaticScroll);
3882 resetScrollOriginChanged(); 3866 resetScrollOriginChanged();
3883 } 3867 }
3884 } 3868 }
3885 3869
3886 void FrameView::scrollContentsIfNeeded() { 3870 void FrameView::scrollContentsIfNeeded() {
3887 if (m_pendingScrollDelta.isZero()) 3871 if (m_pendingScrollDelta.isZero())
3888 return; 3872 return;
3889 DoubleSize scrollDelta = m_pendingScrollDelta; 3873 ScrollOffset scrollDelta = m_pendingScrollDelta;
3890 m_pendingScrollDelta = DoubleSize(); 3874 m_pendingScrollDelta = ScrollOffset();
3891 // FIXME: Change scrollContents() to take DoubleSize. crbug.com/414283. 3875 // FIXME: Change scrollContents() to take DoubleSize. crbug.com/414283.
3892 scrollContents(flooredIntSize(scrollDelta)); 3876 scrollContents(flooredIntSize(scrollDelta));
3893 } 3877 }
3894 3878
3895 void FrameView::scrollContents(const IntSize& scrollDelta) { 3879 void FrameView::scrollContents(const IntSize& scrollDelta) {
3896 HostWindow* window = getHostWindow(); 3880 HostWindow* window = getHostWindow();
3897 if (!window) 3881 if (!window)
3898 return; 3882 return;
3899 3883
3900 TRACE_EVENT0("blink", "FrameView::scrollContents"); 3884 TRACE_EVENT0("blink", "FrameView::scrollContents");
3901 3885
3902 if (!scrollContentsFastPath(-scrollDelta)) 3886 if (!scrollContentsFastPath(-scrollDelta))
3903 scrollContentsSlowPath(); 3887 scrollContentsSlowPath();
3904 3888
3905 // This call will move children with native widgets (plugins) and invalidate t hem as well. 3889 // This call will move children with native widgets (plugins) and invalidate t hem as well.
3906 frameRectsChanged(); 3890 frameRectsChanged();
3907 } 3891 }
3908 3892
3909 IntPoint FrameView::contentsToFrame(const IntPoint& pointInContentSpace) const { 3893 IntPoint FrameView::contentsToFrame(const IntPoint& pointInContentSpace) const {
3910 return pointInContentSpace - scrollOffset(); 3894 return pointInContentSpace - scrollOffsetInt();
3911 } 3895 }
3912 3896
3913 IntRect FrameView::contentsToFrame(const IntRect& rectInContentSpace) const { 3897 IntRect FrameView::contentsToFrame(const IntRect& rectInContentSpace) const {
3914 return IntRect(contentsToFrame(rectInContentSpace.location()), 3898 return IntRect(contentsToFrame(rectInContentSpace.location()),
3915 rectInContentSpace.size()); 3899 rectInContentSpace.size());
3916 } 3900 }
3917 3901
3918 FloatPoint FrameView::frameToContents(const FloatPoint& pointInFrame) const { 3902 FloatPoint FrameView::frameToContents(const FloatPoint& pointInFrame) const {
3919 return pointInFrame + scrollOffset(); 3903 return pointInFrame + scrollOffset();
3920 } 3904 }
3921 3905
3922 IntPoint FrameView::frameToContents(const IntPoint& pointInFrame) const { 3906 IntPoint FrameView::frameToContents(const IntPoint& pointInFrame) const {
3923 return pointInFrame + scrollOffset(); 3907 return pointInFrame + scrollOffsetInt();
3924 } 3908 }
3925 3909
3926 IntRect FrameView::frameToContents(const IntRect& rectInFrame) const { 3910 IntRect FrameView::frameToContents(const IntRect& rectInFrame) const {
3927 return IntRect(frameToContents(rectInFrame.location()), rectInFrame.size()); 3911 return IntRect(frameToContents(rectInFrame.location()), rectInFrame.size());
3928 } 3912 }
3929 3913
3930 IntPoint FrameView::rootFrameToContents(const IntPoint& rootFramePoint) const { 3914 IntPoint FrameView::rootFrameToContents(const IntPoint& rootFramePoint) const {
3931 IntPoint framePoint = convertFromRootFrame(rootFramePoint); 3915 IntPoint framePoint = convertFromRootFrame(rootFramePoint);
3932 return frameToContents(framePoint); 3916 return frameToContents(framePoint);
3933 } 3917 }
(...skipping 166 matching lines...) Expand 10 before | Expand all | Expand 10 after
4100 return this; 4084 return this;
4101 } 4085 }
4102 4086
4103 LayoutRect FrameView::scrollIntoView(const LayoutRect& rectInContent, 4087 LayoutRect FrameView::scrollIntoView(const LayoutRect& rectInContent,
4104 const ScrollAlignment& alignX, 4088 const ScrollAlignment& alignX,
4105 const ScrollAlignment& alignY, 4089 const ScrollAlignment& alignY,
4106 ScrollType scrollType) { 4090 ScrollType scrollType) {
4107 LayoutRect viewRect(visibleContentRect()); 4091 LayoutRect viewRect(visibleContentRect());
4108 LayoutRect exposeRect = 4092 LayoutRect exposeRect =
4109 ScrollAlignment::getRectToExpose(viewRect, rectInContent, alignX, alignY); 4093 ScrollAlignment::getRectToExpose(viewRect, rectInContent, alignX, alignY);
4110 if (exposeRect != viewRect) 4094 if (exposeRect != viewRect) {
4111 setScrollPosition(DoublePoint(exposeRect.x(), exposeRect.y()), scrollType); 4095 setScrollOffset(
4096 ScrollOffset(exposeRect.x().toFloat(), exposeRect.y().toFloat()),
4097 scrollType);
4098 }
4112 4099
4113 // Scrolling the FrameView cannot change the input rect's location relative to the document. 4100 // Scrolling the FrameView cannot change the input rect's location relative to the document.
4114 return rectInContent; 4101 return rectInContent;
4115 } 4102 }
4116 4103
4117 IntRect FrameView::scrollCornerRect() const { 4104 IntRect FrameView::scrollCornerRect() const {
4118 IntRect cornerRect; 4105 IntRect cornerRect;
4119 4106
4120 if (hasOverlayScrollbars()) 4107 if (hasOverlayScrollbars())
4121 return cornerRect; 4108 return cornerRect;
(...skipping 394 matching lines...) Expand 10 before | Expand all | Expand 10 after
4516 } 4503 }
4517 4504
4518 bool FrameView::canThrottleRendering() const { 4505 bool FrameView::canThrottleRendering() const {
4519 if (!RuntimeEnabledFeatures::renderingPipelineThrottlingEnabled()) 4506 if (!RuntimeEnabledFeatures::renderingPipelineThrottlingEnabled())
4520 return false; 4507 return false;
4521 return m_subtreeThrottled || 4508 return m_subtreeThrottled ||
4522 (m_hiddenForThrottling && m_crossOriginForThrottling); 4509 (m_hiddenForThrottling && m_crossOriginForThrottling);
4523 } 4510 }
4524 4511
4525 } // namespace blink 4512 } // namespace blink
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698