Title: [271788] trunk
Revision
271788
Author
[email protected]
Date
2021-01-25 01:45:47 -0800 (Mon, 25 Jan 2021)

Log Message

scroll-padding should affect paging operations
https://bugs.webkit.org/show_bug.cgi?id=219074
<rdar://problem/71747786>

Patch by Martin Robinson <[email protected]> on 2021-01-25
Reviewed by Simon Fraser.

Source/WebCore:

Have scroll-padding affect the amount of the scrollable area that moves during
paging operations. This is the behavior specified in the scroll snap specification
and allows scrollable areas with partially obscured areas to properly page through
their content.

See https://drafts.csswg.org/css-scroll-snap-1/#propdef-scroll-padding.

Tests: css3/scroll-snap/scroll-padding-mainframe-paging.html
       css3/scroll-snap/scroll-padding-overflow-paging.html

* page/FrameView.cpp:
(WebCore::FrameView::updateScrollbarSteps): Added this override method which
properly sets page steps. Only FrameView has access to the document.
* page/FrameView.h:
* platform/ScrollView.cpp:
(WebCore::ScrollView::updateScrollbars): Added this helper method, which is
virtual so that FrameView can override it.
(WebCore::ScrollView::updateScrollbarSteps): Use the helper method to actually
set the scrollbar steps.
* platform/ScrollView.h: Add new method declarations.
* rendering/RenderBox.cpp:
(WebCore::RenderBox::scrollPaddingForViewportRect): Add this new helper which
gets the scroll-padding for a box.
* rendering/RenderBox.h: Add new helper.
* rendering/RenderLayer.cpp:
(WebCore::expandScrollRectToVisibleTargetRectToIncludeScrollPadding): Use the new
RenderBox helper.
(WebCore::RenderLayer::updateScrollbarsAfterLayout): Use the new updateScrollbarSteps helper.
(WebCore::RenderLayer::updateScrollbarSteps): Added this helper so that RenderLayerModelObject
can update steps when necessary.
* rendering/RenderLayer.h: Added new declarations.
* rendering/RenderLayerModelObject.cpp:
(WebCore::RenderLayerModelObject::styleDidChange): Update steps on FrameViews and RenderLayers
when the style change dictates it.

LayoutTests:

* css3/scroll-snap/scroll-padding-mainframe-paging-expected.txt: Added.
* css3/scroll-snap/scroll-padding-mainframe-paging.html: Added.
* css3/scroll-snap/scroll-padding-overflow-paging-expected.txt: Added.
* css3/scroll-snap/scroll-padding-overflow-paging.html: Added.
* platform/ios-wk2/TestExpectations: Skip failing tests.
* platform/mac-wk1/TestExpectations: Skip failing tests.

Modified Paths

Added Paths

Diff

Modified: trunk/LayoutTests/ChangeLog (271787 => 271788)


--- trunk/LayoutTests/ChangeLog	2021-01-25 08:33:14 UTC (rev 271787)
+++ trunk/LayoutTests/ChangeLog	2021-01-25 09:45:47 UTC (rev 271788)
@@ -1,3 +1,18 @@
+2021-01-25  Martin Robinson  <[email protected]>
+
+        scroll-padding should affect paging operations
+        https://bugs.webkit.org/show_bug.cgi?id=219074
+        <rdar://problem/71747786>
+
+        Reviewed by Simon Fraser.
+
+        * css3/scroll-snap/scroll-padding-mainframe-paging-expected.txt: Added.
+        * css3/scroll-snap/scroll-padding-mainframe-paging.html: Added.
+        * css3/scroll-snap/scroll-padding-overflow-paging-expected.txt: Added.
+        * css3/scroll-snap/scroll-padding-overflow-paging.html: Added.
+        * platform/ios-wk2/TestExpectations: Skip failing tests.
+        * platform/mac-wk1/TestExpectations: Skip failing tests.
+
 2021-01-25  Carlos Garcia Campos  <[email protected]>
 
         Null Ptr Deref @ WebCore::ReplaceSelectionCommand::doApply

Added: trunk/LayoutTests/css3/scroll-snap/scroll-padding-mainframe-paging-expected.txt (0 => 271788)


--- trunk/LayoutTests/css3/scroll-snap/scroll-padding-mainframe-paging-expected.txt	                        (rev 0)
+++ trunk/LayoutTests/css3/scroll-snap/scroll-padding-mainframe-paging-expected.txt	2021-01-25 09:45:47 UTC (rev 271788)
@@ -0,0 +1,11 @@
+PASS paging moved body
+PASS paging moved padded body
+PASS document.scrollingElement.scrollTop is within 1 of 535.6837606837607
+PASS paging moved padded body
+PASS document.scrollingElement.scrollTop is within 1 of 535.6837606837607
+PASS paging moved padded body
+PASS document.scrollingElement.scrollTop is within 2 of 526.3675213675214
+PASS successfullyParsed is true
+
+TEST COMPLETE
+

Added: trunk/LayoutTests/css3/scroll-snap/scroll-padding-mainframe-paging.html (0 => 271788)


--- trunk/LayoutTests/css3/scroll-snap/scroll-padding-mainframe-paging.html	                        (rev 0)
+++ trunk/LayoutTests/css3/scroll-snap/scroll-padding-mainframe-paging.html	2021-01-25 09:45:47 UTC (rev 271788)
@@ -0,0 +1,78 @@
+<!DOCTYPE html>
+<html>
+    <head>
+        <style>
+        body {
+            margin: 0;
+        }
+
+        .box {
+            width: 100vw;
+            height: 100vh;
+        }
+        </style>
+        <script src=""
+        <script src=""
+        <script>
+        window.jsTestIsAsync = true;
+
+        async function runTests()
+        {
+            try {
+                await UIHelper.keyDown("pageDown");
+
+                expectTrue(document.scrollingElement.scrollTop != 0, "paging moved body");
+                let defaultPagePosition = document.scrollingElement.scrollTop;
+                let viewportHeight = document.scrollingElement.clientHeight;
+                let pageProportion = document.scrollingElement.scrollTop / viewportHeight;
+
+                document.scrollingElement.scrollTop = 0;
+                document.documentElement.style.scrollPaddingTop = "10px";
+                await UIHelper.keyDown("pageDown");
+
+                let expected = (viewportHeight - 10) * pageProportion;
+                expectTrue(document.scrollingElement.scrollTop != 0, "paging moved padded body");
+                shouldBeCloseTo("document.scrollingElement.scrollTop", expected, 1);
+
+                document.scrollingElement.scrollTop = 0;
+                document.documentElement.style.scrollPaddingTop = "0px";
+                document.documentElement.style.scrollPaddingBottom = "10px";
+                await UIHelper.keyDown("pageDown");
+
+                expectTrue(document.scrollingElement.scrollTop != 0, "paging moved padded body");
+                shouldBeCloseTo("document.scrollingElement.scrollTop", expected, 1);
+
+                document.scrollingElement.scrollTop = 0;
+                document.documentElement.style.scrollPaddingTop = "10px";
+                document.documentElement.style.scrollPaddingBottom = "10px";
+                await UIHelper.keyDown("pageDown");
+
+                expected = (viewportHeight - 20) * pageProportion;
+                expectTrue(document.scrollingElement.scrollTop != 0, "paging moved padded body");
+                shouldBeCloseTo("document.scrollingElement.scrollTop", expected, 2);
+            } catch (e) {
+                console.log(e);
+            } finally {
+                finishJSTest();
+            }
+        }
+
+        function onLoad()
+        {
+            if (window.eventSender) {
+                runTests();
+            } else {
+                var console = document.getElementById('console');
+                console.innerText = "This test cannot be run manually."
+            }
+        }
+        </script>
+    </head>
+    <body _onload_="onLoad();">
+        <div class="box" style="background: green;"><div id="console"></div></div>
+        <div class="box" style="background: red;"></div>
+        <div class="box" style="background: pink;"></div>
+        <div class="box" style="background: yellow;"></div>
+        <div class="box" style="background: orange;"></div>
+    </body>
+</html>

Added: trunk/LayoutTests/css3/scroll-snap/scroll-padding-overflow-paging-expected.txt (0 => 271788)


--- trunk/LayoutTests/css3/scroll-snap/scroll-padding-overflow-paging-expected.txt	                        (rev 0)
+++ trunk/LayoutTests/css3/scroll-snap/scroll-padding-overflow-paging-expected.txt	2021-01-25 09:45:47 UTC (rev 271788)
@@ -0,0 +1,11 @@
+PASS paging moved container
+PASS paging moved padded container
+PASS container.scrollTop is within 1 of 140
+PASS paging moved padded container
+PASS container.scrollTop is within 1 of 140
+PASS paging moved padded container
+PASS container.scrollTop is within 1 of 132
+PASS successfullyParsed is true
+
+TEST COMPLETE
+

Added: trunk/LayoutTests/css3/scroll-snap/scroll-padding-overflow-paging.html (0 => 271788)


--- trunk/LayoutTests/css3/scroll-snap/scroll-padding-overflow-paging.html	                        (rev 0)
+++ trunk/LayoutTests/css3/scroll-snap/scroll-padding-overflow-paging.html	2021-01-25 09:45:47 UTC (rev 271788)
@@ -0,0 +1,89 @@
+<!DOCTYPE html>
+<html>
+    <head>
+        <style>
+        .box {
+            width: 200px;
+            height: 200px;
+        }
+
+        .gallery {
+            overflow: scroll;
+        }
+        </style>
+        <script src=""
+        <script src=""
+        <script>
+        window.jsTestIsAsync = true;
+
+        function clickOnElement(targetElement) {
+            var clientRect = targetElement.getBoundingClientRect();
+            eventSender.mouseMoveTo(clientRect.x + 5, clientRect.y + 5);
+            eventSender.mouseDown();
+        }
+
+        async function runTests()
+        {
+            try {
+                var container = document.getElementById("container");
+
+                clickOnElement(container);
+                await UIHelper.keyDown("pageDown");
+
+                expectTrue(container.scrollTop != 0, "paging moved container");
+                let defaultPagePosition = container.scrollTop;
+                let pageProportion = container.scrollTop / container.clientHeight;
+
+                container.scrollTop = 0;
+                container.style.scrollPaddingTop = "10px";
+                await UIHelper.keyDown("pageDown");
+
+                let expected = (container.clientHeight - 10) * pageProportion;
+                expectTrue(container.scrollTop != 0, "paging moved padded container");
+                shouldBeCloseTo("container.scrollTop", expected, 1);
+
+                container.scrollTop = 0;
+                container.style.scrollPaddingTop = "0px";
+                container.style.scrollPaddingBottom = "10px";
+                await UIHelper.keyDown("pageDown");
+
+                expectTrue(container.scrollTop != 0, "paging moved padded container");
+                shouldBeCloseTo("container.scrollTop", expected, 1);
+
+                container.scrollTop = 0;
+                container.style.scrollPaddingTop = "10px";
+                container.style.scrollPaddingBottom = "10px";
+                await UIHelper.keyDown("pageDown");
+
+                expected = (container.clientHeight - 20) * pageProportion;
+                expectTrue(container.scrollTop != 0, "paging moved padded container");
+                shouldBeCloseTo("container.scrollTop", expected, 1);
+            } catch (e) {
+                console.log(e);
+            } finally {
+                finishJSTest();
+            }
+        }
+
+        function onLoad()
+        {
+            if (window.eventSender) {
+                runTests();
+            } else {
+                var console = document.getElementById('console');
+                console.innerText = "This test cannot be run manually."
+            }
+        }
+        </script>
+    </head>
+    <body _onload_="onLoad();">
+        <div id="console"></div>
+        <div id="container" class="box" style="overflow: scroll;">
+            <div class="box" style="background: green;"></div>
+            <div class="box" style="background: red;"></div>
+            <div class="box" style="background: pink;"></div>
+            <div class="box" style="background: yellow;"></div>
+            <div class="box" style="background: orange;"></div>
+        </div>
+    </body>
+</html>

Modified: trunk/LayoutTests/platform/ios-wk2/TestExpectations (271787 => 271788)


--- trunk/LayoutTests/platform/ios-wk2/TestExpectations	2021-01-25 08:33:14 UTC (rev 271787)
+++ trunk/LayoutTests/platform/ios-wk2/TestExpectations	2021-01-25 09:45:47 UTC (rev 271788)
@@ -134,6 +134,8 @@
 scrollbars/corner-resizer-window-inactive.html [ ImageOnlyFailure ]
 scrollbars/scrolling-by-page-on-keyboard-spacebar.html [ Failure ]
 scrollbars/scrollbars-on-positioned-content.html [ Failure ]
+css3/scroll-snap/scroll-padding-mainframe-paging.html [ Failure ]
+css3/scroll-snap/scroll-padding-overflow-paging.html [ Failure ]
 
 # SVG tests that time out (these require EventSender)
 svg/animations/animVal-basics.html

Modified: trunk/LayoutTests/platform/mac-wk1/TestExpectations (271787 => 271788)


--- trunk/LayoutTests/platform/mac-wk1/TestExpectations	2021-01-25 08:33:14 UTC (rev 271787)
+++ trunk/LayoutTests/platform/mac-wk1/TestExpectations	2021-01-25 09:45:47 UTC (rev 271788)
@@ -448,8 +448,9 @@
 imported/w3c/web-platform-tests/cookies/secure/set-from-wss.https.sub.html [ Failure ]
 imported/w3c/web-platform-tests/cookies/secure/set-from-ws.sub.html [ Failure ]
 
-# WebKit1 frames use native scrollbars causing this reference test to fail.
+# WebKit1 frames use native scrollbars causing these tests to fail.
 imported/w3c/web-platform-tests/css/css-scroll-snap/scroll-target-padding-001.html [ ImageOnlyFailure ]
+css3/scroll-snap/scroll-padding-mainframe-paging.html [ Failure ]
 
 ### END OF (2) Failures without bug reports
 ########################################

Modified: trunk/Source/WebCore/ChangeLog (271787 => 271788)


--- trunk/Source/WebCore/ChangeLog	2021-01-25 08:33:14 UTC (rev 271787)
+++ trunk/Source/WebCore/ChangeLog	2021-01-25 09:45:47 UTC (rev 271788)
@@ -1,3 +1,46 @@
+2021-01-25  Martin Robinson  <[email protected]>
+
+        scroll-padding should affect paging operations
+        https://bugs.webkit.org/show_bug.cgi?id=219074
+        <rdar://problem/71747786>
+
+        Reviewed by Simon Fraser.
+
+        Have scroll-padding affect the amount of the scrollable area that moves during
+        paging operations. This is the behavior specified in the scroll snap specification
+        and allows scrollable areas with partially obscured areas to properly page through
+        their content.
+
+        See https://drafts.csswg.org/css-scroll-snap-1/#propdef-scroll-padding.
+
+        Tests: css3/scroll-snap/scroll-padding-mainframe-paging.html
+               css3/scroll-snap/scroll-padding-overflow-paging.html
+
+        * page/FrameView.cpp:
+        (WebCore::FrameView::updateScrollbarSteps): Added this override method which
+        properly sets page steps. Only FrameView has access to the document.
+        * page/FrameView.h:
+        * platform/ScrollView.cpp:
+        (WebCore::ScrollView::updateScrollbars): Added this helper method, which is
+        virtual so that FrameView can override it.
+        (WebCore::ScrollView::updateScrollbarSteps): Use the helper method to actually
+        set the scrollbar steps.
+        * platform/ScrollView.h: Add new method declarations.
+        * rendering/RenderBox.cpp:
+        (WebCore::RenderBox::scrollPaddingForViewportRect): Add this new helper which
+        gets the scroll-padding for a box.
+        * rendering/RenderBox.h: Add new helper.
+        * rendering/RenderLayer.cpp:
+        (WebCore::expandScrollRectToVisibleTargetRectToIncludeScrollPadding): Use the new
+        RenderBox helper.
+        (WebCore::RenderLayer::updateScrollbarsAfterLayout): Use the new updateScrollbarSteps helper.
+        (WebCore::RenderLayer::updateScrollbarSteps): Added this helper so that RenderLayerModelObject
+        can update steps when necessary.
+        * rendering/RenderLayer.h: Added new declarations.
+        * rendering/RenderLayerModelObject.cpp:
+        (WebCore::RenderLayerModelObject::styleDidChange): Update steps on FrameViews and RenderLayers
+        when the style change dictates it.
+
 2021-01-25  Carlos Garcia Campos  <[email protected]>
 
         Null Ptr Deref @ WebCore::ReplaceSelectionCommand::doApply

Modified: trunk/Source/WebCore/page/FrameView.cpp (271787 => 271788)


--- trunk/Source/WebCore/page/FrameView.cpp	2021-01-25 08:33:14 UTC (rev 271787)
+++ trunk/Source/WebCore/page/FrameView.cpp	2021-01-25 09:45:47 UTC (rev 271788)
@@ -5544,6 +5544,28 @@
     return frame().frameScaleFactor();
 }
 
+void FrameView::updateScrollbarSteps()
+{
+    auto* documentElement = frame().document() ? frame().document()->documentElement() : nullptr;
+    auto* renderer = documentElement ? documentElement->renderBox() : nullptr;
+    if (!renderer) {
+        ScrollView::updateScrollbarSteps();
+        return;
+    }
+
+    LayoutRect paddedViewRect(LayoutPoint(), visibleSize());
+    paddedViewRect.contract(renderer->scrollPaddingForViewportRect(paddedViewRect));
+
+    if (horizontalScrollbar()) {
+        int pageStep = Scrollbar::pageStep(paddedViewRect.width());
+        horizontalScrollbar()->setSteps(Scrollbar::pixelsPerLineStep(), pageStep);
+
+    }
+    if (verticalScrollbar()) {
+        int pageStep = Scrollbar::pageStep(paddedViewRect.height());
+        verticalScrollbar()->setSteps(Scrollbar::pixelsPerLineStep(), pageStep);
+    }
+}
 } // namespace WebCore
 
 #undef PAGE_ID

Modified: trunk/Source/WebCore/page/FrameView.h (271787 => 271788)


--- trunk/Source/WebCore/page/FrameView.h	2021-01-25 08:33:14 UTC (rev 271787)
+++ trunk/Source/WebCore/page/FrameView.h	2021-01-25 09:45:47 UTC (rev 271788)
@@ -680,6 +680,9 @@
 
     String debugDescription() const final;
 
+    // ScrollView
+    void updateScrollbarSteps() override;
+
 private:
     explicit FrameView(Frame&);
 

Modified: trunk/Source/WebCore/platform/ScrollView.cpp (271787 => 271788)


--- trunk/Source/WebCore/platform/ScrollView.cpp	2021-01-25 08:33:14 UTC (rev 271787)
+++ trunk/Source/WebCore/platform/ScrollView.cpp	2021-01-25 09:45:47 UTC (rev 271788)
@@ -731,7 +731,6 @@
 
     if (m_horizontalScrollbar) {
         int clientWidth = visibleWidth();
-        int pageStep = Scrollbar::pageStep(clientWidth);
         IntRect oldRect(m_horizontalScrollbar->frameRect());
         IntRect hBarRect(shouldPlaceBlockDirectionScrollbarOnLeft() && m_verticalScrollbar ? m_verticalScrollbar->occupiedWidth() : 0,
             height() - m_horizontalScrollbar->height(),
@@ -744,7 +743,6 @@
         if (m_scrollbarsSuppressed)
             m_horizontalScrollbar->setSuppressInvalidation(true);
         m_horizontalScrollbar->setEnabled(contentsWidth() > clientWidth);
-        m_horizontalScrollbar->setSteps(Scrollbar::pixelsPerLineStep(), pageStep);
         m_horizontalScrollbar->setProportion(clientWidth, contentsWidth());
         if (m_scrollbarsSuppressed)
             m_horizontalScrollbar->setSuppressInvalidation(false); 
@@ -752,7 +750,6 @@
 
     if (m_verticalScrollbar) {
         int clientHeight = visibleHeight();
-        int pageStep = Scrollbar::pageStep(clientHeight);
         IntRect oldRect(m_verticalScrollbar->frameRect());
         IntRect vBarRect(shouldPlaceBlockDirectionScrollbarOnLeft() ? 0 : width() - m_verticalScrollbar->width(),
             topContentInset(),
@@ -765,12 +762,13 @@
         if (m_scrollbarsSuppressed)
             m_verticalScrollbar->setSuppressInvalidation(true);
         m_verticalScrollbar->setEnabled(totalContentsSize().height() > clientHeight);
-        m_verticalScrollbar->setSteps(Scrollbar::pixelsPerLineStep(), pageStep);
         m_verticalScrollbar->setProportion(clientHeight, totalContentsSize().height());
         if (m_scrollbarsSuppressed)
             m_verticalScrollbar->setSuppressInvalidation(false);
     }
 
+    updateScrollbarSteps();
+
     if (hasHorizontalScrollbar != newHasHorizontalScrollbar || hasVerticalScrollbar != newHasVerticalScrollbar) {
         // FIXME: Is frameRectsChanged really necessary here? Have any frame rects changed?
         frameRectsChanged();
@@ -791,6 +789,14 @@
     m_inUpdateScrollbars = false;
 }
 
+void ScrollView::updateScrollbarSteps()
+{
+    if (m_horizontalScrollbar)
+        m_horizontalScrollbar->setSteps(Scrollbar::pixelsPerLineStep(), Scrollbar::pageStep(visibleWidth()));
+    if (m_verticalScrollbar)
+        m_verticalScrollbar->setSteps(Scrollbar::pixelsPerLineStep(), Scrollbar::pageStep(visibleHeight()));
+}
+
 const int panIconSizeLength = 16;
 
 IntRect ScrollView::rectToCopyOnScroll() const

Modified: trunk/Source/WebCore/platform/ScrollView.h (271787 => 271788)


--- trunk/Source/WebCore/platform/ScrollView.h	2021-01-25 08:33:14 UTC (rev 271787)
+++ trunk/Source/WebCore/platform/ScrollView.h	2021-01-25 09:45:47 UTC (rev 271788)
@@ -397,6 +397,7 @@
     bool allowsUnclampedScrollPosition() const { return m_allowsUnclampedScrollPosition; }
 
     bool managesScrollbars() const;
+    virtual void updateScrollbarSteps();
 
 protected:
     ScrollView();

Modified: trunk/Source/WebCore/rendering/RenderBox.cpp (271787 => 271788)


--- trunk/Source/WebCore/rendering/RenderBox.cpp	2021-01-25 08:33:14 UTC (rev 271787)
+++ trunk/Source/WebCore/rendering/RenderBox.cpp	2021-01-25 09:45:47 UTC (rev 271788)
@@ -5162,4 +5162,12 @@
     return anchorRect;
 }
 
+LayoutBoxExtent RenderBox::scrollPaddingForViewportRect(const LayoutRect& viewportRect)
+{
+    const auto& padding = style().scrollPadding();
+    return LayoutBoxExtent(
+        valueForLength(padding.top(), viewportRect.height()), valueForLength(padding.right(), viewportRect.width()),
+        valueForLength(padding.bottom(), viewportRect.height()), valueForLength(padding.left(), viewportRect.width()));
+}
+
 } // namespace WebCore

Modified: trunk/Source/WebCore/rendering/RenderBox.h (271787 => 271788)


--- trunk/Source/WebCore/rendering/RenderBox.h	2021-01-25 08:33:14 UTC (rev 271787)
+++ trunk/Source/WebCore/rendering/RenderBox.h	2021-01-25 09:45:47 UTC (rev 271788)
@@ -495,6 +495,8 @@
     bool hasScrollableOverflowX() const { return scrollsOverflowX() && hasHorizontalOverflow(); }
     bool hasScrollableOverflowY() const { return scrollsOverflowY() && hasVerticalOverflow(); }
 
+    LayoutBoxExtent scrollPaddingForViewportRect(const LayoutRect& viewportRect);
+
     bool usesCompositedScrolling() const;
     
     bool percentageLogicalHeightIsResolvable() const;

Modified: trunk/Source/WebCore/rendering/RenderLayer.cpp (271787 => 271788)


--- trunk/Source/WebCore/rendering/RenderLayer.cpp	2021-01-25 08:33:14 UTC (rev 271787)
+++ trunk/Source/WebCore/rendering/RenderLayer.cpp	2021-01-25 09:45:47 UTC (rev 271788)
@@ -650,11 +650,7 @@
     // scroll-padding applies to the scroll container, but expand the rectangle that we want to expose in order
     // simulate padding the scroll container. This rectangle is passed up the tree of scrolling elements to
     // ensure that the padding on this scroll container is maintained.
-    const auto& scrollPadding = renderBox->style().scrollPadding();
-    LayoutBoxExtent scrollPaddingExtents(
-        valueForLength(scrollPadding.top(), viewRect.height()), valueForLength(scrollPadding.right(), viewRect.width()),
-        valueForLength(scrollPadding.bottom(), viewRect.height()), valueForLength(scrollPadding.left(), viewRect.width()));
-    targetRect.expand(scrollPaddingExtents);
+    targetRect.expand(renderBox->scrollPaddingForViewportRect(viewRect));
 }
 
 bool RenderLayer::shouldBeNormalFlowOnly() const
@@ -2887,6 +2883,12 @@
         m_scrollableArea->updateScrollInfoAfterLayout();
 }
 
+void RenderLayer::updateScrollbarSteps()
+{
+    if (m_scrollableArea)
+        m_scrollableArea->updateScrollbarSteps();
+}
+
 bool RenderLayer::canUseCompositedScrolling() const
 {
     if (m_scrollableArea)

Modified: trunk/Source/WebCore/rendering/RenderLayer.h (271787 => 271788)


--- trunk/Source/WebCore/rendering/RenderLayer.h	2021-01-25 08:33:14 UTC (rev 271787)
+++ trunk/Source/WebCore/rendering/RenderLayer.h	2021-01-25 09:45:47 UTC (rev 271788)
@@ -477,6 +477,7 @@
     IntSize offsetFromResizeCorner(const IntPoint& localPoint) const;
 
     void updateScrollInfoAfterLayout();
+    void updateScrollbarSteps();
 
     void autoscroll(const IntPoint&);
 

Modified: trunk/Source/WebCore/rendering/RenderLayerModelObject.cpp (271787 => 271788)


--- trunk/Source/WebCore/rendering/RenderLayerModelObject.cpp	2021-01-25 08:33:14 UTC (rev 271787)
+++ trunk/Source/WebCore/rendering/RenderLayerModelObject.cpp	2021-01-25 09:45:47 UTC (rev 271788)
@@ -172,8 +172,16 @@
             view().frameView().removeViewportConstrainedObject(*this);
     }
 
+    const RenderStyle& newStyle = style();
+    if (oldStyle && oldStyle->scrollPadding() != newStyle.scrollPadding()) {
+        if (isDocumentElementRenderer()) {
+            FrameView& frameView = view().frameView();
+            frameView.updateScrollbarSteps();
+        } else if (RenderLayer* renderLayer = layer())
+            renderLayer->updateScrollbarSteps();
+    }
+
 #if ENABLE(CSS_SCROLL_SNAP)
-    const RenderStyle& newStyle = style();
     if (oldStyle && scrollSnapContainerRequiresUpdateForStyleUpdate(*oldStyle, newStyle)) {
         if (RenderLayer* renderLayer = layer()) {
             auto* scrollableLayer = renderLayer->ensureLayerScrollableArea();

Modified: trunk/Source/WebCore/rendering/RenderLayerScrollableArea.cpp (271787 => 271788)


--- trunk/Source/WebCore/rendering/RenderLayerScrollableArea.cpp	2021-01-25 08:33:14 UTC (rev 271787)
+++ trunk/Source/WebCore/rendering/RenderLayerScrollableArea.cpp	2021-01-25 09:45:47 UTC (rev 271788)
@@ -1118,23 +1118,37 @@
             downcast<RenderFlexibleBox>(parent)->clearCachedMainSizeForChild(*m_layer.renderBox());
     }
 
-    // Set up the range (and page step/line step).
+    // Set up the range.
+    if (m_hBar)
+        m_hBar->setProportion(roundToInt(box->clientWidth()), m_scrollWidth);
+    if (m_vBar)
+        m_vBar->setProportion(roundToInt(box->clientHeight()), m_scrollHeight);
+
+    updateScrollbarSteps();
+
+    updateScrollableAreaSet(hasScrollableHorizontalOverflow() || hasScrollableVerticalOverflow());
+}
+
+void RenderLayerScrollableArea::updateScrollbarSteps()
+{
+    RenderBox* box = m_layer.renderBox();
+    ASSERT(box);
+
+    LayoutRect paddedLayerBounds(0_lu, 0_lu, box->clientWidth(), box->clientHeight());
+    paddedLayerBounds.contract(box->scrollPaddingForViewportRect(paddedLayerBounds));
+
+    // Set up the  page step/line step.
     if (m_hBar) {
-        int clientWidth = roundToInt(box->clientWidth());
-        int pageStep = Scrollbar::pageStep(clientWidth);
+        int pageStep = Scrollbar::pageStep(roundToInt(paddedLayerBounds.width()));
         m_hBar->setSteps(Scrollbar::pixelsPerLineStep(), pageStep);
-        m_hBar->setProportion(clientWidth, m_scrollWidth);
     }
     if (m_vBar) {
-        int clientHeight = roundToInt(box->clientHeight());
-        int pageStep = Scrollbar::pageStep(clientHeight);
+        int pageStep = Scrollbar::pageStep(roundToInt(paddedLayerBounds.height()));
         m_vBar->setSteps(Scrollbar::pixelsPerLineStep(), pageStep);
-        m_vBar->setProportion(clientHeight, m_scrollHeight);
     }
-
-    updateScrollableAreaSet(hasScrollableHorizontalOverflow() || hasScrollableVerticalOverflow());
 }
 
+
 // This is called from layout code (before updateLayerPositions).
 void RenderLayerScrollableArea::updateScrollInfoAfterLayout()
 {

Modified: trunk/Source/WebCore/rendering/RenderLayerScrollableArea.h (271787 => 271788)


--- trunk/Source/WebCore/rendering/RenderLayerScrollableArea.h	2021-01-25 08:33:14 UTC (rev 271787)
+++ trunk/Source/WebCore/rendering/RenderLayerScrollableArea.h	2021-01-25 09:45:47 UTC (rev 271788)
@@ -125,6 +125,7 @@
     void paintOverlayScrollbars(GraphicsContext&, const LayoutRect& damageRect, OptionSet<PaintBehavior>, RenderObject* subtreePaintRoot = nullptr);
 
     void updateScrollInfoAfterLayout();
+    void updateScrollbarSteps();
 
     bool scroll(ScrollDirection, ScrollGranularity, float multiplier = 1);
 
_______________________________________________
webkit-changes mailing list
[email protected]
https://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to