Changeset 165484 in webkit


Ignore:
Timestamp:
Mar 12, 2014 11:15:06 AM (10 years ago)
Author:
Simon Fraser
Message:

Change scrollOffsetForFixedPosition() to do LayoutUnit math
https://bugs.webkit.org/show_bug.cgi?id=129981

Reviewed by Beth Dakin.

Source/WebCore:

FrameView::scrollOffsetForFixedPosition() returned an IntSize,
but to allow subpixel scroll offsets, we need it to return a LayoutSize.

Fix code that calls this to use more LayoutUnit math.

This progresses fixed background images on zoom, which cam now be subpixel
positioned.

  • WebCore.exp.in:
  • page/FrameView.cpp:

(WebCore::FrameView::viewportConstrainedVisibleContentRect):
(WebCore::FrameView::scrollOffsetForFixedPosition):

  • page/FrameView.h:
  • page/scrolling/AsyncScrollingCoordinator.cpp:

(WebCore::AsyncScrollingCoordinator::updateScrollPositionAfterAsyncScroll):

  • platform/ScrollableArea.cpp:

(WebCore::ScrollableArea::constrainScrollPositionForOverhang):

  • platform/ScrollableArea.h:
  • rendering/RenderBoxModelObject.cpp:

(WebCore::RenderBoxModelObject::calculateBackgroundImageGeometry):

  • rendering/RenderLayer.cpp:

(WebCore::RenderLayer::calculateClipRects):

  • rendering/RenderLayerBacking.cpp:

(WebCore::RenderLayerBacking::updateGraphicsLayerGeometry):

  • rendering/RenderLayerCompositor.cpp:

(WebCore::RenderLayerCompositor::updateScrollLayerPosition):

LayoutTests:

FrameView::scrollOffsetForFixedPosition() returned an IntSize,
but to allow subpixel scroll offsets, we need it to return a LayoutSize.

Update test results for the progression.

  • platform/mac-wk2/tiled-drawing/fixed-background/fixed-body-background-zoomed-expected.png:
  • platform/mac-wk2/tiled-drawing/fixed-background/fixed-body-background-zoomed-expected.txt:
Location:
trunk
Files:
15 edited

Legend:

Unmodified
Added
Removed
  • trunk/LayoutTests/ChangeLog

    r165482 r165484  
     12014-03-12  Simon Fraser  <simon.fraser@apple.com>
     2
     3        Change scrollOffsetForFixedPosition() to do LayoutUnit math
     4        https://bugs.webkit.org/show_bug.cgi?id=129981
     5
     6        Reviewed by Beth Dakin.
     7
     8        FrameView::scrollOffsetForFixedPosition() returned an IntSize,
     9        but to allow subpixel scroll offsets, we need it to return a LayoutSize.
     10
     11        Update test results for the progression.
     12
     13        * platform/mac-wk2/tiled-drawing/fixed-background/fixed-body-background-zoomed-expected.png:
     14        * platform/mac-wk2/tiled-drawing/fixed-background/fixed-body-background-zoomed-expected.txt:
     15
    1162014-03-12  Gavin Barraclough  <barraclough@apple.com>
    217
  • trunk/LayoutTests/platform/mac-wk2/tiled-drawing/fixed-background/fixed-body-background-zoomed-expected.txt

    r156749 r165484  
    88      (children 2
    99        (GraphicsLayer
    10           (position 0.00 154.00)
     10          (position 0.00 154.25)
    1111          (anchor 0.00 0.00)
    1212          (bounds 785.00 585.00)
  • trunk/Source/WebCore/ChangeLog

    r165482 r165484  
     12014-03-12  Simon Fraser  <simon.fraser@apple.com>
     2
     3        Change scrollOffsetForFixedPosition() to do LayoutUnit math
     4        https://bugs.webkit.org/show_bug.cgi?id=129981
     5
     6        Reviewed by Beth Dakin.
     7
     8        FrameView::scrollOffsetForFixedPosition() returned an IntSize,
     9        but to allow subpixel scroll offsets, we need it to return a LayoutSize.
     10       
     11        Fix code that calls this to use more LayoutUnit math.
     12       
     13        This progresses fixed background images on zoom, which cam now be subpixel
     14        positioned.
     15
     16        * WebCore.exp.in:
     17        * page/FrameView.cpp:
     18        (WebCore::FrameView::viewportConstrainedVisibleContentRect):
     19        (WebCore::FrameView::scrollOffsetForFixedPosition):
     20        * page/FrameView.h:
     21        * page/scrolling/AsyncScrollingCoordinator.cpp:
     22        (WebCore::AsyncScrollingCoordinator::updateScrollPositionAfterAsyncScroll):
     23        * platform/ScrollableArea.cpp:
     24        (WebCore::ScrollableArea::constrainScrollPositionForOverhang):
     25        * platform/ScrollableArea.h:
     26        * rendering/RenderBoxModelObject.cpp:
     27        (WebCore::RenderBoxModelObject::calculateBackgroundImageGeometry):
     28        * rendering/RenderLayer.cpp:
     29        (WebCore::RenderLayer::calculateClipRects):
     30        * rendering/RenderLayerBacking.cpp:
     31        (WebCore::RenderLayerBacking::updateGraphicsLayerGeometry):
     32        * rendering/RenderLayerCompositor.cpp:
     33        (WebCore::RenderLayerCompositor::updateScrollLayerPosition):
     34
    1352014-03-12  Gavin Barraclough  <barraclough@apple.com>
    236
  • trunk/Source/WebCore/WebCore.exp.in

    r165479 r165484  
    406406__ZN7WebCore14ScrollableArea28setScrollOffsetFromInternalsERKNS_8IntPointE
    407407__ZN7WebCore14ScrollableArea30scrollToOffsetWithoutAnimationERKNS_10FloatPointE
    408 __ZN7WebCore14ScrollableArea34constrainScrollPositionForOverhangERKNS_7IntRectERKNS_7IntSizeERKNS_8IntPointES9_ii
     408__ZN7WebCore14ScrollableArea34constrainScrollPositionForOverhangERKNS_10LayoutRectERKNS_10LayoutSizeERKNS_11LayoutPointES9_ii
    409409__ZN7WebCore14ScrollableArea6scrollENS_15ScrollDirectionENS_17ScrollGranularityEf
    410410__ZN7WebCore14ScrollableAreaC2Ev
  • trunk/Source/WebCore/page/FrameView.cpp

    r165396 r165484  
    15391539#endif
    15401540    LayoutRect viewportRect = visibleContentRect();
     1541
    15411542    viewportRect.setLocation(toLayoutPoint(scrollOffsetForFixedPosition()));
    15421543    return viewportRect;
     
    15551556}
    15561557
    1557 IntSize FrameView::scrollOffsetForFixedPosition(const IntRect& visibleContentRect, const IntSize& totalContentsSize, const IntPoint& scrollPosition, const IntPoint& scrollOrigin, float frameScaleFactor, bool fixedElementsLayoutRelativeToFrame, ScrollBehaviorForFixedElements behaviorForFixed, int headerHeight, int footerHeight)
    1558 {
    1559     IntPoint position;
     1558LayoutSize FrameView::scrollOffsetForFixedPosition(const LayoutRect& visibleContentRect, const LayoutSize& totalContentsSize, const LayoutPoint& scrollPosition, const LayoutPoint& scrollOrigin, float frameScaleFactor, bool fixedElementsLayoutRelativeToFrame, ScrollBehaviorForFixedElements behaviorForFixed, int headerHeight, int footerHeight)
     1559{
     1560    LayoutPoint position;
    15601561    if (behaviorForFixed == StickToDocumentBounds)
    15611562        position = ScrollableArea::constrainScrollPositionForOverhang(visibleContentRect, totalContentsSize, scrollPosition, scrollOrigin, headerHeight, footerHeight);
     
    15651566    }
    15661567
    1567     IntSize maxSize = totalContentsSize - visibleContentRect.size();
     1568    LayoutSize maxSize = totalContentsSize - visibleContentRect.size();
    15681569
    15691570    float dragFactorX = (fixedElementsLayoutRelativeToFrame || !maxSize.width()) ? 1 : (totalContentsSize.width() - visibleContentRect.width() * frameScaleFactor) / maxSize.width();
    15701571    float dragFactorY = (fixedElementsLayoutRelativeToFrame || !maxSize.height()) ? 1 : (totalContentsSize.height() - visibleContentRect.height() * frameScaleFactor) / maxSize.height();
    15711572
    1572     return IntSize(position.x() * dragFactorX / frameScaleFactor, position.y() * dragFactorY / frameScaleFactor);
    1573 }
    1574 
    1575 IntSize FrameView::scrollOffsetForFixedPosition() const
     1573    return LayoutSize(position.x() * dragFactorX / frameScaleFactor, position.y() * dragFactorY / frameScaleFactor);
     1574}
     1575
     1576LayoutSize FrameView::scrollOffsetForFixedPosition() const
    15761577{
    15771578    IntRect visibleContentRect = this->visibleContentRect();
  • trunk/Source/WebCore/page/FrameView.h

    r165094 r165484  
    263263    // Functions for querying the current scrolled position, negating the effects of overhang
    264264    // and adjusting for page scale.
    265     IntSize scrollOffsetForFixedPosition() const;
     265    LayoutSize scrollOffsetForFixedPosition() const;
    266266    // Static function can be called from another thread.
    267     static IntSize scrollOffsetForFixedPosition(const IntRect& visibleContentRect, const IntSize& totalContentsSize, const IntPoint& scrollPosition, const IntPoint& scrollOrigin, float frameScaleFactor, bool fixedElementsLayoutRelativeToFrame, ScrollBehaviorForFixedElements, int headerHeight, int footerHeight);
     267    static LayoutSize scrollOffsetForFixedPosition(const LayoutRect& visibleContentRect, const LayoutSize& totalContentsSize, const LayoutPoint& scrollPosition, const LayoutPoint& scrollOrigin, float frameScaleFactor, bool fixedElementsLayoutRelativeToFrame, ScrollBehaviorForFixedElements, int headerHeight, int footerHeight);
    268268
    269269    bool fixedElementsLayoutRelativeToFrame() const;
  • trunk/Source/WebCore/page/scrolling/AsyncScrollingCoordinator.cpp

    r165349 r165484  
    213213            GraphicsLayer* headerLayer = headerLayerForFrameView(frameView);
    214214            GraphicsLayer* footerLayer = footerLayerForFrameView(frameView);
    215             IntSize scrollOffsetForFixed = frameView->scrollOffsetForFixedPosition();
     215            LayoutSize scrollOffsetForFixed = frameView->scrollOffsetForFixedPosition();
    216216
    217217            if (programmaticScroll || scrollingLayerPositionAction == SetScrollingLayerPosition) {
    218218                scrollLayer->setPosition(-frameView->scrollPosition());
    219219                if (counterScrollingLayer)
    220                     counterScrollingLayer->setPosition(IntPoint(scrollOffsetForFixed));
     220                    counterScrollingLayer->setPosition(toLayoutPoint(scrollOffsetForFixed));
    221221                if (headerLayer)
    222222                    headerLayer->setPosition(FloatPoint(scrollOffsetForFixed.width(), 0));
     
    226226                scrollLayer->syncPosition(-frameView->scrollPosition());
    227227                if (counterScrollingLayer)
    228                     counterScrollingLayer->syncPosition(IntPoint(scrollOffsetForFixed));
     228                    counterScrollingLayer->syncPosition(toLayoutPoint(scrollOffsetForFixed));
    229229                if (headerLayer)
    230230                    headerLayer->syncPosition(FloatPoint(scrollOffsetForFixed.width(), 0));
  • trunk/Source/WebCore/page/scrolling/ios/ScrollingTreeScrollingNodeIOS.mm

    r165348 r165484  
    137137    ScrollBehaviorForFixedElements behaviorForFixed = scrollBehaviorForFixedElements();
    138138    FloatPoint scrollOffset = position - toIntSize(scrollOrigin());
    139     // FIXME: scrollOffsetForFixedPosition() needs to do float math.
     139
    140140    FloatSize scrollOffsetForFixedChildren = FrameView::scrollOffsetForFixedPosition(enclosingIntRect(viewportConstrainedObjectRect()), totalContentsSize(), flooredIntPoint(scrollOffset), scrollOrigin(), frameScaleFactor(), false, behaviorForFixed, headerHeight(), footerHeight());
    141141    if (m_counterScrollingLayer)
  • trunk/Source/WebCore/page/scrolling/mac/ScrollingTreeScrollingNodeMac.mm

    r165233 r165484  
    344344    ScrollBehaviorForFixedElements behaviorForFixed = scrollBehaviorForFixedElements();
    345345    FloatPoint scrollOffset = position - toFloatSize(scrollOrigin());
    346     // FIXME: scrollOffsetForFixedPosition() needs to do float math.
     346
    347347    FloatSize scrollOffsetForFixedChildren = FrameView::scrollOffsetForFixedPosition(enclosingIntRect(viewportConstrainedObjectRect()), totalContentsSize(), flooredIntPoint(scrollOffset), scrollOrigin(), frameScaleFactor(), false, behaviorForFixed, headerHeight(), footerHeight());
    348348    if (m_counterScrollingLayer)
  • trunk/Source/WebCore/platform/ScrollableArea.cpp

    r163975 r165484  
    3636#include "GraphicsLayer.h"
    3737#include "FloatPoint.h"
     38#include "LayoutRect.h"
    3839#include "PlatformWheelEvent.h"
    3940#include "ScrollAnimator.h"
     
    478479}
    479480
    480 IntPoint ScrollableArea::constrainScrollPositionForOverhang(const IntRect& visibleContentRect, const IntSize& totalContentsSize, const IntPoint& scrollPosition, const IntPoint& scrollOrigin, int headerHeight, int footerHeight)
     481LayoutPoint ScrollableArea::constrainScrollPositionForOverhang(const LayoutRect& visibleContentRect, const LayoutSize& totalContentsSize, const LayoutPoint& scrollPosition, const LayoutPoint& scrollOrigin, int headerHeight, int footerHeight)
    481482{
    482483    // The viewport rect that we're scrolling shouldn't be larger than our document.
    483     IntSize idealScrollRectSize(std::min(visibleContentRect.width(), totalContentsSize.width()), std::min(visibleContentRect.height(), totalContentsSize.height()));
     484    LayoutSize idealScrollRectSize(std::min(visibleContentRect.width(), totalContentsSize.width()), std::min(visibleContentRect.height(), totalContentsSize.height()));
    484485   
    485     IntRect scrollRect(scrollPosition + scrollOrigin - IntSize(0, headerHeight), idealScrollRectSize);
    486     IntRect documentRect(IntPoint(), IntSize(totalContentsSize.width(), totalContentsSize.height() - headerHeight - footerHeight));
     486    LayoutRect scrollRect(scrollPosition + scrollOrigin - LayoutSize(0, headerHeight), idealScrollRectSize);
     487    LayoutRect documentRect(LayoutPoint(), LayoutSize(totalContentsSize.width(), totalContentsSize.height() - headerHeight - footerHeight));
    487488
    488489    // Use intersection to constrain our ideal scroll rect by the document rect.
     
    501502    }
    502503
    503     return scrollRect.location() - toIntSize(scrollOrigin);
    504 }
    505 
    506 IntPoint ScrollableArea::constrainScrollPositionForOverhang(const IntPoint& scrollPosition)
     504    return scrollRect.location() - toLayoutSize(scrollOrigin);
     505}
     506
     507LayoutPoint ScrollableArea::constrainScrollPositionForOverhang(const LayoutPoint& scrollPosition)
    507508{
    508509    return constrainScrollPositionForOverhang(visibleContentRect(), totalContentsSize(), scrollPosition, scrollOrigin(), headerHeight(), footerHeight());
  • trunk/Source/WebCore/platform/ScrollableArea.h

    r163975 r165484  
    3434class FloatPoint;
    3535class GraphicsContext;
     36class LayoutPoint;
     37class LayoutSize;
    3638class PlatformTouchEvent;
    3739class PlatformWheelEvent;
     
    201203    void setScrollOffsetFromInternals(const IntPoint&);
    202204
    203     static IntPoint constrainScrollPositionForOverhang(const IntRect& visibleContentRect, const IntSize& totalContentsSize, const IntPoint& scrollPosition, const IntPoint& scrollOrigin, int headerHeight, int footetHeight);
    204     IntPoint constrainScrollPositionForOverhang(const IntPoint& scrollPosition);
     205    static LayoutPoint constrainScrollPositionForOverhang(const LayoutRect& visibleContentRect, const LayoutSize& totalContentsSize, const LayoutPoint& scrollPosition, const LayoutPoint& scrollOrigin, int headerHeight, int footetHeight);
     206    LayoutPoint constrainScrollPositionForOverhang(const LayoutPoint& scrollPosition);
    205207
    206208    // Computes the double value for the scrollbar's current position and the current overhang amount.
  • trunk/Source/WebCore/rendering/RenderBoxModelObject.cpp

    r165065 r165484  
    11121112        geometry.setHasNonLocalGeometry();
    11131113
    1114         IntRect viewportRect = pixelSnappedIntRect(view().viewRect());
     1114        LayoutRect viewportRect = view().viewRect();
    11151115        if (fixedBackgroundPaintsInLocalCoordinates())
    1116             viewportRect.setLocation(IntPoint());
     1116            viewportRect.setLocation(LayoutPoint());
    11171117        else
    1118             viewportRect.setLocation(IntPoint(view().frameView().scrollOffsetForFixedPosition()));
     1118            viewportRect.setLocation(toLayoutPoint(view().frameView().scrollOffsetForFixedPosition()));
    11191119
    11201120        if (paintContainer) {
    1121             IntPoint absoluteContainerOffset = roundedIntPoint(paintContainer->localToAbsolute(FloatPoint()));
     1121            LayoutPoint absoluteContainerOffset = roundedLayoutPoint(paintContainer->localToAbsolute(FloatPoint()));
    11221122            viewportRect.moveBy(-absoluteContainerOffset);
    11231123        }
  • trunk/Source/WebCore/rendering/RenderLayerBacking.cpp

    r165354 r165484  
    900900        if (backgroundLayerPaintsFixedRootBackground()) {
    901901            const FrameView& frameView = renderer().view().frameView();
    902             backgroundPosition = IntPoint(frameView.scrollOffsetForFixedPosition());
     902            backgroundPosition = toLayoutPoint(frameView.scrollOffsetForFixedPosition());
    903903            backgroundSize = frameView.visibleContentRect().size();
    904904        }
  • trunk/Source/WebCore/rendering/RenderLayerCompositor.cpp

    r165124 r165484  
    15111511
    15121512    if (GraphicsLayer* fixedBackgroundLayer = fixedRootBackgroundLayer())
    1513         fixedBackgroundLayer->setPosition(IntPoint(frameView.scrollOffsetForFixedPosition()));
     1513        fixedBackgroundLayer->setPosition(toLayoutPoint(frameView.scrollOffsetForFixedPosition()));
    15141514}
    15151515
Note: See TracChangeset for help on using the changeset viewer.