Title: [165484] trunk
Revision
165484
Author
[email protected]
Date
2014-03-12 11:15:06 -0700 (Wed, 12 Mar 2014)

Log 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:

Modified Paths

Diff

Modified: trunk/LayoutTests/ChangeLog (165483 => 165484)


--- trunk/LayoutTests/ChangeLog	2014-03-12 18:10:35 UTC (rev 165483)
+++ trunk/LayoutTests/ChangeLog	2014-03-12 18:15:06 UTC (rev 165484)
@@ -1,3 +1,18 @@
+2014-03-12  Simon Fraser  <[email protected]>
+
+        Change scrollOffsetForFixedPosition() to do LayoutUnit math
+        https://bugs.webkit.org/show_bug.cgi?id=129981
+
+        Reviewed by Beth Dakin.
+
+        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:
+
 2014-03-12  Gavin Barraclough  <[email protected]>
 
         Reduce memory use for static property maps

Modified: trunk/LayoutTests/platform/mac-wk2/tiled-drawing/fixed-background/fixed-body-background-zoomed-expected.png


(Binary files differ)

Modified: trunk/LayoutTests/platform/mac-wk2/tiled-drawing/fixed-background/fixed-body-background-zoomed-expected.txt (165483 => 165484)


--- trunk/LayoutTests/platform/mac-wk2/tiled-drawing/fixed-background/fixed-body-background-zoomed-expected.txt	2014-03-12 18:10:35 UTC (rev 165483)
+++ trunk/LayoutTests/platform/mac-wk2/tiled-drawing/fixed-background/fixed-body-background-zoomed-expected.txt	2014-03-12 18:15:06 UTC (rev 165484)
@@ -7,7 +7,7 @@
       (transform [2.30 0.00 0.00 0.00] [0.00 2.30 0.00 0.00] [0.00 0.00 1.00 0.00] [0.00 0.00 0.00 1.00])
       (children 2
         (GraphicsLayer
-          (position 0.00 154.00)
+          (position 0.00 154.25)
           (anchor 0.00 0.00)
           (bounds 785.00 585.00)
           (contentsOpaque 1)

Modified: trunk/Source/WebCore/ChangeLog (165483 => 165484)


--- trunk/Source/WebCore/ChangeLog	2014-03-12 18:10:35 UTC (rev 165483)
+++ trunk/Source/WebCore/ChangeLog	2014-03-12 18:15:06 UTC (rev 165484)
@@ -1,3 +1,37 @@
+2014-03-12  Simon Fraser  <[email protected]>
+
+        Change scrollOffsetForFixedPosition() to do LayoutUnit math
+        https://bugs.webkit.org/show_bug.cgi?id=129981
+
+        Reviewed by Beth Dakin.
+
+        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):
+
 2014-03-12  Gavin Barraclough  <[email protected]>
 
         Reduce memory use for static property maps

Modified: trunk/Source/WebCore/WebCore.exp.in (165483 => 165484)


--- trunk/Source/WebCore/WebCore.exp.in	2014-03-12 18:10:35 UTC (rev 165483)
+++ trunk/Source/WebCore/WebCore.exp.in	2014-03-12 18:15:06 UTC (rev 165484)
@@ -405,7 +405,7 @@
 __ZN7WebCore14ScrollableArea27notifyScrollPositionChangedERKNS_8IntPointE
 __ZN7WebCore14ScrollableArea28setScrollOffsetFromInternalsERKNS_8IntPointE
 __ZN7WebCore14ScrollableArea30scrollToOffsetWithoutAnimationERKNS_10FloatPointE
-__ZN7WebCore14ScrollableArea34constrainScrollPositionForOverhangERKNS_7IntRectERKNS_7IntSizeERKNS_8IntPointES9_ii
+__ZN7WebCore14ScrollableArea34constrainScrollPositionForOverhangERKNS_10LayoutRectERKNS_10LayoutSizeERKNS_11LayoutPointES9_ii
 __ZN7WebCore14ScrollableArea6scrollENS_15ScrollDirectionENS_17ScrollGranularityEf
 __ZN7WebCore14ScrollableAreaC2Ev
 __ZN7WebCore14ScrollableAreaD2Ev

Modified: trunk/Source/WebCore/page/FrameView.cpp (165483 => 165484)


--- trunk/Source/WebCore/page/FrameView.cpp	2014-03-12 18:10:35 UTC (rev 165483)
+++ trunk/Source/WebCore/page/FrameView.cpp	2014-03-12 18:15:06 UTC (rev 165484)
@@ -1538,6 +1538,7 @@
         return customFixedPositionLayoutRect();
 #endif
     LayoutRect viewportRect = visibleContentRect();
+
     viewportRect.setLocation(toLayoutPoint(scrollOffsetForFixedPosition()));
     return viewportRect;
 }
@@ -1554,9 +1555,9 @@
 #endif
 }
 
-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)
+LayoutSize FrameView::scrollOffsetForFixedPosition(const LayoutRect& visibleContentRect, const LayoutSize& totalContentsSize, const LayoutPoint& scrollPosition, const LayoutPoint& scrollOrigin, float frameScaleFactor, bool fixedElementsLayoutRelativeToFrame, ScrollBehaviorForFixedElements behaviorForFixed, int headerHeight, int footerHeight)
 {
-    IntPoint position;
+    LayoutPoint position;
     if (behaviorForFixed == StickToDocumentBounds)
         position = ScrollableArea::constrainScrollPositionForOverhang(visibleContentRect, totalContentsSize, scrollPosition, scrollOrigin, headerHeight, footerHeight);
     else {
@@ -1564,15 +1565,15 @@
         position.setY(position.y() - headerHeight);
     }
 
-    IntSize maxSize = totalContentsSize - visibleContentRect.size();
+    LayoutSize maxSize = totalContentsSize - visibleContentRect.size();
 
     float dragFactorX = (fixedElementsLayoutRelativeToFrame || !maxSize.width()) ? 1 : (totalContentsSize.width() - visibleContentRect.width() * frameScaleFactor) / maxSize.width();
     float dragFactorY = (fixedElementsLayoutRelativeToFrame || !maxSize.height()) ? 1 : (totalContentsSize.height() - visibleContentRect.height() * frameScaleFactor) / maxSize.height();
 
-    return IntSize(position.x() * dragFactorX / frameScaleFactor, position.y() * dragFactorY / frameScaleFactor);
+    return LayoutSize(position.x() * dragFactorX / frameScaleFactor, position.y() * dragFactorY / frameScaleFactor);
 }
 
-IntSize FrameView::scrollOffsetForFixedPosition() const
+LayoutSize FrameView::scrollOffsetForFixedPosition() const
 {
     IntRect visibleContentRect = this->visibleContentRect();
     IntSize totalContentsSize = this->totalContentsSize();

Modified: trunk/Source/WebCore/page/FrameView.h (165483 => 165484)


--- trunk/Source/WebCore/page/FrameView.h	2014-03-12 18:10:35 UTC (rev 165483)
+++ trunk/Source/WebCore/page/FrameView.h	2014-03-12 18:15:06 UTC (rev 165484)
@@ -262,9 +262,9 @@
 
     // Functions for querying the current scrolled position, negating the effects of overhang
     // and adjusting for page scale.
-    IntSize scrollOffsetForFixedPosition() const;
+    LayoutSize scrollOffsetForFixedPosition() const;
     // Static function can be called from another thread.
-    static IntSize scrollOffsetForFixedPosition(const IntRect& visibleContentRect, const IntSize& totalContentsSize, const IntPoint& scrollPosition, const IntPoint& scrollOrigin, float frameScaleFactor, bool fixedElementsLayoutRelativeToFrame, ScrollBehaviorForFixedElements, int headerHeight, int footerHeight);
+    static LayoutSize scrollOffsetForFixedPosition(const LayoutRect& visibleContentRect, const LayoutSize& totalContentsSize, const LayoutPoint& scrollPosition, const LayoutPoint& scrollOrigin, float frameScaleFactor, bool fixedElementsLayoutRelativeToFrame, ScrollBehaviorForFixedElements, int headerHeight, int footerHeight);
 
     bool fixedElementsLayoutRelativeToFrame() const;
 

Modified: trunk/Source/WebCore/page/scrolling/AsyncScrollingCoordinator.cpp (165483 => 165484)


--- trunk/Source/WebCore/page/scrolling/AsyncScrollingCoordinator.cpp	2014-03-12 18:10:35 UTC (rev 165483)
+++ trunk/Source/WebCore/page/scrolling/AsyncScrollingCoordinator.cpp	2014-03-12 18:15:06 UTC (rev 165484)
@@ -212,12 +212,12 @@
             GraphicsLayer* counterScrollingLayer = counterScrollingLayerForFrameView(frameView);
             GraphicsLayer* headerLayer = headerLayerForFrameView(frameView);
             GraphicsLayer* footerLayer = footerLayerForFrameView(frameView);
-            IntSize scrollOffsetForFixed = frameView->scrollOffsetForFixedPosition();
+            LayoutSize scrollOffsetForFixed = frameView->scrollOffsetForFixedPosition();
 
             if (programmaticScroll || scrollingLayerPositionAction == SetScrollingLayerPosition) {
                 scrollLayer->setPosition(-frameView->scrollPosition());
                 if (counterScrollingLayer)
-                    counterScrollingLayer->setPosition(IntPoint(scrollOffsetForFixed));
+                    counterScrollingLayer->setPosition(toLayoutPoint(scrollOffsetForFixed));
                 if (headerLayer)
                     headerLayer->setPosition(FloatPoint(scrollOffsetForFixed.width(), 0));
                 if (footerLayer)
@@ -225,7 +225,7 @@
             } else {
                 scrollLayer->syncPosition(-frameView->scrollPosition());
                 if (counterScrollingLayer)
-                    counterScrollingLayer->syncPosition(IntPoint(scrollOffsetForFixed));
+                    counterScrollingLayer->syncPosition(toLayoutPoint(scrollOffsetForFixed));
                 if (headerLayer)
                     headerLayer->syncPosition(FloatPoint(scrollOffsetForFixed.width(), 0));
                 if (footerLayer)

Modified: trunk/Source/WebCore/page/scrolling/ios/ScrollingTreeScrollingNodeIOS.mm (165483 => 165484)


--- trunk/Source/WebCore/page/scrolling/ios/ScrollingTreeScrollingNodeIOS.mm	2014-03-12 18:10:35 UTC (rev 165483)
+++ trunk/Source/WebCore/page/scrolling/ios/ScrollingTreeScrollingNodeIOS.mm	2014-03-12 18:15:06 UTC (rev 165484)
@@ -136,7 +136,7 @@
 
     ScrollBehaviorForFixedElements behaviorForFixed = scrollBehaviorForFixedElements();
     FloatPoint scrollOffset = position - toIntSize(scrollOrigin());
-    // FIXME: scrollOffsetForFixedPosition() needs to do float math.
+
     FloatSize scrollOffsetForFixedChildren = FrameView::scrollOffsetForFixedPosition(enclosingIntRect(viewportConstrainedObjectRect()), totalContentsSize(), flooredIntPoint(scrollOffset), scrollOrigin(), frameScaleFactor(), false, behaviorForFixed, headerHeight(), footerHeight());
     if (m_counterScrollingLayer)
         m_counterScrollingLayer.get().position = FloatPoint(scrollOffsetForFixedChildren);

Modified: trunk/Source/WebCore/page/scrolling/mac/ScrollingTreeScrollingNodeMac.mm (165483 => 165484)


--- trunk/Source/WebCore/page/scrolling/mac/ScrollingTreeScrollingNodeMac.mm	2014-03-12 18:10:35 UTC (rev 165483)
+++ trunk/Source/WebCore/page/scrolling/mac/ScrollingTreeScrollingNodeMac.mm	2014-03-12 18:15:06 UTC (rev 165484)
@@ -343,7 +343,7 @@
 
     ScrollBehaviorForFixedElements behaviorForFixed = scrollBehaviorForFixedElements();
     FloatPoint scrollOffset = position - toFloatSize(scrollOrigin());
-    // FIXME: scrollOffsetForFixedPosition() needs to do float math.
+
     FloatSize scrollOffsetForFixedChildren = FrameView::scrollOffsetForFixedPosition(enclosingIntRect(viewportConstrainedObjectRect()), totalContentsSize(), flooredIntPoint(scrollOffset), scrollOrigin(), frameScaleFactor(), false, behaviorForFixed, headerHeight(), footerHeight());
     if (m_counterScrollingLayer)
         m_counterScrollingLayer.get().position = FloatPoint(scrollOffsetForFixedChildren);

Modified: trunk/Source/WebCore/platform/ScrollableArea.cpp (165483 => 165484)


--- trunk/Source/WebCore/platform/ScrollableArea.cpp	2014-03-12 18:10:35 UTC (rev 165483)
+++ trunk/Source/WebCore/platform/ScrollableArea.cpp	2014-03-12 18:15:06 UTC (rev 165484)
@@ -35,6 +35,7 @@
 #include "GraphicsContext.h"
 #include "GraphicsLayer.h"
 #include "FloatPoint.h"
+#include "LayoutRect.h"
 #include "PlatformWheelEvent.h"
 #include "ScrollAnimator.h"
 #include "ScrollbarTheme.h"
@@ -477,13 +478,13 @@
                    std::max(0, visibleHeight() + horizontalScrollbarHeight));
 }
 
-IntPoint ScrollableArea::constrainScrollPositionForOverhang(const IntRect& visibleContentRect, const IntSize& totalContentsSize, const IntPoint& scrollPosition, const IntPoint& scrollOrigin, int headerHeight, int footerHeight)
+LayoutPoint ScrollableArea::constrainScrollPositionForOverhang(const LayoutRect& visibleContentRect, const LayoutSize& totalContentsSize, const LayoutPoint& scrollPosition, const LayoutPoint& scrollOrigin, int headerHeight, int footerHeight)
 {
     // The viewport rect that we're scrolling shouldn't be larger than our document.
-    IntSize idealScrollRectSize(std::min(visibleContentRect.width(), totalContentsSize.width()), std::min(visibleContentRect.height(), totalContentsSize.height()));
+    LayoutSize idealScrollRectSize(std::min(visibleContentRect.width(), totalContentsSize.width()), std::min(visibleContentRect.height(), totalContentsSize.height()));
     
-    IntRect scrollRect(scrollPosition + scrollOrigin - IntSize(0, headerHeight), idealScrollRectSize);
-    IntRect documentRect(IntPoint(), IntSize(totalContentsSize.width(), totalContentsSize.height() - headerHeight - footerHeight));
+    LayoutRect scrollRect(scrollPosition + scrollOrigin - LayoutSize(0, headerHeight), idealScrollRectSize);
+    LayoutRect documentRect(LayoutPoint(), LayoutSize(totalContentsSize.width(), totalContentsSize.height() - headerHeight - footerHeight));
 
     // Use intersection to constrain our ideal scroll rect by the document rect.
     scrollRect.intersect(documentRect);
@@ -500,10 +501,10 @@
             scrollRect.move(0, -(idealScrollRectSize.height() - scrollRect.height()));
     }
 
-    return scrollRect.location() - toIntSize(scrollOrigin);
+    return scrollRect.location() - toLayoutSize(scrollOrigin);
 }
 
-IntPoint ScrollableArea::constrainScrollPositionForOverhang(const IntPoint& scrollPosition)
+LayoutPoint ScrollableArea::constrainScrollPositionForOverhang(const LayoutPoint& scrollPosition)
 {
     return constrainScrollPositionForOverhang(visibleContentRect(), totalContentsSize(), scrollPosition, scrollOrigin(), headerHeight(), footerHeight());
 }

Modified: trunk/Source/WebCore/platform/ScrollableArea.h (165483 => 165484)


--- trunk/Source/WebCore/platform/ScrollableArea.h	2014-03-12 18:10:35 UTC (rev 165483)
+++ trunk/Source/WebCore/platform/ScrollableArea.h	2014-03-12 18:15:06 UTC (rev 165484)
@@ -33,6 +33,8 @@
 
 class FloatPoint;
 class GraphicsContext;
+class LayoutPoint;
+class LayoutSize;
 class PlatformTouchEvent;
 class PlatformWheelEvent;
 class ScrollAnimator;
@@ -200,8 +202,8 @@
     // NOTE: Only called from Internals for testing.
     void setScrollOffsetFromInternals(const IntPoint&);
 
-    static IntPoint constrainScrollPositionForOverhang(const IntRect& visibleContentRect, const IntSize& totalContentsSize, const IntPoint& scrollPosition, const IntPoint& scrollOrigin, int headerHeight, int footetHeight);
-    IntPoint constrainScrollPositionForOverhang(const IntPoint& scrollPosition);
+    static LayoutPoint constrainScrollPositionForOverhang(const LayoutRect& visibleContentRect, const LayoutSize& totalContentsSize, const LayoutPoint& scrollPosition, const LayoutPoint& scrollOrigin, int headerHeight, int footetHeight);
+    LayoutPoint constrainScrollPositionForOverhang(const LayoutPoint& scrollPosition);
 
     // Computes the double value for the scrollbar's current position and the current overhang amount.
     // This function is static so that it can be called from the main thread or the scrolling thread.

Modified: trunk/Source/WebCore/rendering/RenderBoxModelObject.cpp (165483 => 165484)


--- trunk/Source/WebCore/rendering/RenderBoxModelObject.cpp	2014-03-12 18:10:35 UTC (rev 165483)
+++ trunk/Source/WebCore/rendering/RenderBoxModelObject.cpp	2014-03-12 18:15:06 UTC (rev 165484)
@@ -1111,14 +1111,14 @@
     } else {
         geometry.setHasNonLocalGeometry();
 
-        IntRect viewportRect = pixelSnappedIntRect(view().viewRect());
+        LayoutRect viewportRect = view().viewRect();
         if (fixedBackgroundPaintsInLocalCoordinates())
-            viewportRect.setLocation(IntPoint());
+            viewportRect.setLocation(LayoutPoint());
         else
-            viewportRect.setLocation(IntPoint(view().frameView().scrollOffsetForFixedPosition()));
+            viewportRect.setLocation(toLayoutPoint(view().frameView().scrollOffsetForFixedPosition()));
 
         if (paintContainer) {
-            IntPoint absoluteContainerOffset = roundedIntPoint(paintContainer->localToAbsolute(FloatPoint()));
+            LayoutPoint absoluteContainerOffset = roundedLayoutPoint(paintContainer->localToAbsolute(FloatPoint()));
             viewportRect.moveBy(-absoluteContainerOffset);
         }
 

Modified: trunk/Source/WebCore/rendering/RenderLayerBacking.cpp (165483 => 165484)


--- trunk/Source/WebCore/rendering/RenderLayerBacking.cpp	2014-03-12 18:10:35 UTC (rev 165483)
+++ trunk/Source/WebCore/rendering/RenderLayerBacking.cpp	2014-03-12 18:15:06 UTC (rev 165484)
@@ -899,7 +899,7 @@
         FloatSize backgroundSize = contentsSize;
         if (backgroundLayerPaintsFixedRootBackground()) {
             const FrameView& frameView = renderer().view().frameView();
-            backgroundPosition = IntPoint(frameView.scrollOffsetForFixedPosition());
+            backgroundPosition = toLayoutPoint(frameView.scrollOffsetForFixedPosition());
             backgroundSize = frameView.visibleContentRect().size();
         }
         m_backgroundLayer->setPosition(backgroundPosition);

Modified: trunk/Source/WebCore/rendering/RenderLayerCompositor.cpp (165483 => 165484)


--- trunk/Source/WebCore/rendering/RenderLayerCompositor.cpp	2014-03-12 18:10:35 UTC (rev 165483)
+++ trunk/Source/WebCore/rendering/RenderLayerCompositor.cpp	2014-03-12 18:15:06 UTC (rev 165484)
@@ -1510,7 +1510,7 @@
     m_scrollLayer->setPosition(FloatPoint(-scrollPosition.x(), -scrollPosition.y()));
 
     if (GraphicsLayer* fixedBackgroundLayer = fixedRootBackgroundLayer())
-        fixedBackgroundLayer->setPosition(IntPoint(frameView.scrollOffsetForFixedPosition()));
+        fixedBackgroundLayer->setPosition(toLayoutPoint(frameView.scrollOffsetForFixedPosition()));
 }
 
 void RenderLayerCompositor::frameViewDidScroll()
_______________________________________________
webkit-changes mailing list
[email protected]
https://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to