Title: [270023] trunk
Revision
270023
Author
[email protected]
Date
2020-11-19 05:59:56 -0800 (Thu, 19 Nov 2020)

Log Message

Make scroll-padding independent of scroll-snap and have it affect scrollIntoView
https://bugs.webkit.org/show_bug.cgi?id=219073

Reviewed by Simon Fraser.

LayoutTests/imported/w3c:

* web-platform-tests/css/cssom-view/scrollIntoView-scrollPadding-expected.txt: Updated to reflect newly passing test.

Source/WebCore:

The scroll-padding CSS property is now available even when scroll-snap is not
enabled at compile-time. Also make scroll-snap affect positioning during
scrollIntoView operations.

* Sources.txt: Remove ScrollSnapPoints.cpp, because it is no longer necessary.
* WebCore.xcodeproj/project.pbxproj: Ditto.
* css/CSSComputedStyleDeclaration.cpp: Enable scroll-padding and scroll-padding-* unconditionally.
(WebCore::ComputedStyleExtractor::valueForPropertyInStyle): Ditto.
* css/CSSProperties.json: Ditto.
* css/StyleProperties.cpp: Ditto.
(WebCore::StyleProperties::getPropertyValue const): Ditto.
(WebCore::StyleProperties::asText const): Ditto.
* css/parser/CSSPropertyParser.cpp: Ditto.
(WebCore::CSSPropertyParser::parseSingleValue): Ditto.
(WebCore::CSSPropertyParser::parseShorthand): Ditto.
* rendering/RenderLayer.cpp: Ditto.
(WebCore::expandScrollRectToVisibleTargetRectToIncludeScrollPadding): Added this helper
function which expands the target rectangle to include scroll padding from the container.
This creates the affect that the container has a padding rectangle.
(WebCore::RenderLayer::scrollRectToVisible): Now expand target rectangle to include
scroll container padding. Also put some code into a lambda to simplify things.
* rendering/RenderLayerModelObject.cpp: Ditto.
(WebCore::scrollSnapContainerRequiresUpdateForStyleUpdate): Ditto.
* rendering/style/RenderStyle.cpp: Ditto.
(WebCore::RenderStyle::scrollPadding const): Ditto.
(WebCore::RenderStyle::setScrollPaddingTop): Ditto.
(WebCore::RenderStyle::setScrollPaddingBottom): Ditto.
(WebCore::RenderStyle::setScrollPaddingLeft): Ditto.
(WebCore::RenderStyle::setScrollPaddingRight): Ditto.
(WebCore::RenderStyle::initialScrollSnapType): Ditto.
(WebCore::RenderStyle::initialScrollSnapAlign): Ditto.
(WebCore::RenderStyle::scrollSnapType const): Ditto.
(WebCore::RenderStyle::scrollSnapAlign const): Ditto.
(WebCore::RenderStyle::setScrollSnapType): Ditto.
* rendering/style/RenderStyle.h: Ditto.
(WebCore::RenderStyle::initialScrollPadding): Ditto.
* rendering/style/StyleRareNonInheritedData.cpp: Have scroll-padding related properties
be stored directly on StyleRareNonInheritedData.
(WebCore::StyleRareNonInheritedData::StyleRareNonInheritedData):
(WebCore::StyleRareNonInheritedData::operator== const):
* rendering/style/StyleRareNonInheritedData.h: Ditto.
* rendering/style/StyleScrollSnapPoints.cpp: Removed.
* rendering/style/StyleScrollSnapPoints.h:

LayoutTests:

* TestExpectations: Mark some tests as passing.
* platform/mac-wk1/TestExpectations: Mark one test as failing due to WebKit1 scrollbars.

Modified Paths

Removed Paths

Diff

Modified: trunk/LayoutTests/ChangeLog (270022 => 270023)


--- trunk/LayoutTests/ChangeLog	2020-11-19 13:55:40 UTC (rev 270022)
+++ trunk/LayoutTests/ChangeLog	2020-11-19 13:59:56 UTC (rev 270023)
@@ -1,3 +1,13 @@
+2020-11-19  Martin Robinson  <[email protected]>
+
+        Make scroll-padding independent of scroll-snap and have it affect scrollIntoView
+        https://bugs.webkit.org/show_bug.cgi?id=219073
+
+        Reviewed by Simon Fraser.
+
+        * TestExpectations: Mark some tests as passing.
+        * platform/mac-wk1/TestExpectations: Mark one test as failing due to WebKit1 scrollbars.
+
 2020-11-17  Sergio Villar Senin  <[email protected]>
 
         Nullptr crash in RenderObject::parent

Modified: trunk/LayoutTests/TestExpectations (270022 => 270023)


--- trunk/LayoutTests/TestExpectations	2020-11-19 13:55:40 UTC (rev 270022)
+++ trunk/LayoutTests/TestExpectations	2020-11-19 13:59:56 UTC (rev 270023)
@@ -4568,9 +4568,6 @@
 imported/w3c/web-platform-tests/css/css-scroll-snap/scroll-target-align-003.html [ ImageOnlyFailure ]
 webkit.org/b/218325 imported/w3c/web-platform-tests/css/css-scroll-snap/scroll-target-margin-001.html [ Pass ImageOnlyFailure ]
 webkit.org/b/218325 imported/w3c/web-platform-tests/css/css-scroll-snap/scroll-target-margin-003.html [ Pass ImageOnlyFailure ]
-imported/w3c/web-platform-tests/css/css-scroll-snap/scroll-target-padding-001.html [ ImageOnlyFailure ]
-imported/w3c/web-platform-tests/css/css-scroll-snap/scroll-target-padding-002.html [ ImageOnlyFailure ]
-imported/w3c/web-platform-tests/css/css-scroll-snap/scroll-target-padding-003.html [ ImageOnlyFailure ]
 imported/w3c/web-platform-tests/css/css-scroll-snap/scroll-target-snap-001.html [ ImageOnlyFailure ]
 imported/w3c/web-platform-tests/css/css-scroll-snap/scroll-target-snap-002.html [ ImageOnlyFailure ]
 imported/w3c/web-platform-tests/css/css-scroll-snap/scroll-target-snap-003.html [ ImageOnlyFailure ]

Modified: trunk/LayoutTests/imported/w3c/ChangeLog (270022 => 270023)


--- trunk/LayoutTests/imported/w3c/ChangeLog	2020-11-19 13:55:40 UTC (rev 270022)
+++ trunk/LayoutTests/imported/w3c/ChangeLog	2020-11-19 13:59:56 UTC (rev 270023)
@@ -1,3 +1,12 @@
+2020-11-19  Martin Robinson  <[email protected]>
+
+        Make scroll-padding independent of scroll-snap and have it affect scrollIntoView
+        https://bugs.webkit.org/show_bug.cgi?id=219073
+
+        Reviewed by Simon Fraser.
+
+        * web-platform-tests/css/cssom-view/scrollIntoView-scrollPadding-expected.txt: Updated to reflect newly passing test.
+
 2020-11-19  Chris Lord  <[email protected]>
 
         Update WPT OffscreenCanvas text tests

Modified: trunk/LayoutTests/imported/w3c/web-platform-tests/css/cssom-view/scrollIntoView-scrollPadding-expected.txt (270022 => 270023)


--- trunk/LayoutTests/imported/w3c/web-platform-tests/css/cssom-view/scrollIntoView-scrollPadding-expected.txt	2020-11-19 13:55:40 UTC (rev 270022)
+++ trunk/LayoutTests/imported/w3c/web-platform-tests/css/cssom-view/scrollIntoView-scrollPadding-expected.txt	2020-11-19 13:59:56 UTC (rev 270023)
@@ -1,5 +1,5 @@
 
-FAIL scrollIntoView({block: "center", inline: "center"}) assert_approx_equals: scrollX expected 153.5 +/- 0.5 but got 158
-FAIL scrollIntoView({block: "start", inline: "start"}) assert_approx_equals: scrollX expected 184 +/- 0.5 but got 200
-FAIL scrollIntoView({block: "end", inline: "end"}) assert_approx_equals: scrollX expected 123 +/- 0.5 but got 115
+PASS scrollIntoView({block: "center", inline: "center"})
+PASS scrollIntoView({block: "start", inline: "start"})
+PASS scrollIntoView({block: "end", inline: "end"})
 

Modified: trunk/LayoutTests/platform/mac-wk1/TestExpectations (270022 => 270023)


--- trunk/LayoutTests/platform/mac-wk1/TestExpectations	2020-11-19 13:55:40 UTC (rev 270022)
+++ trunk/LayoutTests/platform/mac-wk1/TestExpectations	2020-11-19 13:59:56 UTC (rev 270023)
@@ -445,6 +445,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.
+imported/w3c/web-platform-tests/css/css-scroll-snap/scroll-target-padding-001.html [ ImageOnlyFailure ]
+
 ### END OF (2) Failures without bug reports
 ########################################
 

Modified: trunk/Source/WebCore/ChangeLog (270022 => 270023)


--- trunk/Source/WebCore/ChangeLog	2020-11-19 13:55:40 UTC (rev 270022)
+++ trunk/Source/WebCore/ChangeLog	2020-11-19 13:59:56 UTC (rev 270023)
@@ -1,3 +1,54 @@
+2020-11-19  Martin Robinson  <[email protected]>
+
+        Make scroll-padding independent of scroll-snap and have it affect scrollIntoView
+        https://bugs.webkit.org/show_bug.cgi?id=219073
+
+        Reviewed by Simon Fraser.
+
+        The scroll-padding CSS property is now available even when scroll-snap is not
+        enabled at compile-time. Also make scroll-snap affect positioning during
+        scrollIntoView operations.
+
+        * Sources.txt: Remove ScrollSnapPoints.cpp, because it is no longer necessary.
+        * WebCore.xcodeproj/project.pbxproj: Ditto.
+        * css/CSSComputedStyleDeclaration.cpp: Enable scroll-padding and scroll-padding-* unconditionally.
+        (WebCore::ComputedStyleExtractor::valueForPropertyInStyle): Ditto.
+        * css/CSSProperties.json: Ditto.
+        * css/StyleProperties.cpp: Ditto.
+        (WebCore::StyleProperties::getPropertyValue const): Ditto.
+        (WebCore::StyleProperties::asText const): Ditto.
+        * css/parser/CSSPropertyParser.cpp: Ditto.
+        (WebCore::CSSPropertyParser::parseSingleValue): Ditto.
+        (WebCore::CSSPropertyParser::parseShorthand): Ditto.
+        * rendering/RenderLayer.cpp: Ditto.
+        (WebCore::expandScrollRectToVisibleTargetRectToIncludeScrollPadding): Added this helper
+        function which expands the target rectangle to include scroll padding from the container.
+        This creates the affect that the container has a padding rectangle.
+        (WebCore::RenderLayer::scrollRectToVisible): Now expand target rectangle to include
+        scroll container padding. Also put some code into a lambda to simplify things.
+        * rendering/RenderLayerModelObject.cpp: Ditto.
+        (WebCore::scrollSnapContainerRequiresUpdateForStyleUpdate): Ditto.
+        * rendering/style/RenderStyle.cpp: Ditto.
+        (WebCore::RenderStyle::scrollPadding const): Ditto.
+        (WebCore::RenderStyle::setScrollPaddingTop): Ditto.
+        (WebCore::RenderStyle::setScrollPaddingBottom): Ditto.
+        (WebCore::RenderStyle::setScrollPaddingLeft): Ditto.
+        (WebCore::RenderStyle::setScrollPaddingRight): Ditto.
+        (WebCore::RenderStyle::initialScrollSnapType): Ditto.
+        (WebCore::RenderStyle::initialScrollSnapAlign): Ditto.
+        (WebCore::RenderStyle::scrollSnapType const): Ditto.
+        (WebCore::RenderStyle::scrollSnapAlign const): Ditto.
+        (WebCore::RenderStyle::setScrollSnapType): Ditto.
+        * rendering/style/RenderStyle.h: Ditto.
+        (WebCore::RenderStyle::initialScrollPadding): Ditto.
+        * rendering/style/StyleRareNonInheritedData.cpp: Have scroll-padding related properties
+        be stored directly on StyleRareNonInheritedData.
+        (WebCore::StyleRareNonInheritedData::StyleRareNonInheritedData):
+        (WebCore::StyleRareNonInheritedData::operator== const):
+        * rendering/style/StyleRareNonInheritedData.h: Ditto.
+        * rendering/style/StyleScrollSnapPoints.cpp: Removed.
+        * rendering/style/StyleScrollSnapPoints.h:
+
 2020-11-19  Carlos Garcia Campos  <[email protected]>
 
         [GStreamer] GStreamerRegistryScanner cleanups and improvements

Modified: trunk/Source/WebCore/Sources.txt (270022 => 270023)


--- trunk/Source/WebCore/Sources.txt	2020-11-19 13:55:40 UTC (rev 270022)
+++ trunk/Source/WebCore/Sources.txt	2020-11-19 13:59:56 UTC (rev 270023)
@@ -2323,7 +2323,6 @@
 rendering/style/StyleMultiImage.cpp
 rendering/style/StyleRareInheritedData.cpp
 rendering/style/StyleRareNonInheritedData.cpp
-rendering/style/StyleScrollSnapPoints.cpp
 rendering/style/StyleSelfAlignmentData.cpp
 rendering/style/StyleSurroundData.cpp
 rendering/style/StyleTransformData.cpp

Modified: trunk/Source/WebCore/WebCore.xcodeproj/project.pbxproj (270022 => 270023)


--- trunk/Source/WebCore/WebCore.xcodeproj/project.pbxproj	2020-11-19 13:55:40 UTC (rev 270022)
+++ trunk/Source/WebCore/WebCore.xcodeproj/project.pbxproj	2020-11-19 13:59:56 UTC (rev 270023)
@@ -16459,7 +16459,6 @@
 		F478755319983AFF0024A287 /* ScrollSnapAnimatorState.mm */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.objcpp; path = ScrollSnapAnimatorState.mm; sourceTree = "<group>"; };
 		F47A09CF20A939F600240FAE /* DisabledAdaptations.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = DisabledAdaptations.h; sourceTree = "<group>"; };
 		F47A09D420A9DD0400240FAE /* DisabledAdaptations.cpp */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.cpp.cpp; path = DisabledAdaptations.cpp; sourceTree = "<group>"; };
-		F47A5E3A195B8C8A00483100 /* StyleScrollSnapPoints.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = StyleScrollSnapPoints.cpp; sourceTree = "<group>"; };
 		F47A5E3B195B8C8A00483100 /* StyleScrollSnapPoints.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = StyleScrollSnapPoints.h; sourceTree = "<group>"; };
 		F47A633C1FF6FD500081B3CC /* PromisedAttachmentInfo.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = PromisedAttachmentInfo.h; sourceTree = "<group>"; };
 		F47AD2382193499A0051DD0B /* InsertNestedListCommand.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = InsertNestedListCommand.h; sourceTree = "<group>"; };
@@ -26990,7 +26989,6 @@
 				BC2272BA0E82EAAE00E7F975 /* StyleRareNonInheritedData.cpp */,
 				BC2272BB0E82EAAE00E7F975 /* StyleRareNonInheritedData.h */,
 				BC2272860E82E70700E7F975 /* StyleReflection.h */,
-				F47A5E3A195B8C8A00483100 /* StyleScrollSnapPoints.cpp */,
 				F47A5E3B195B8C8A00483100 /* StyleScrollSnapPoints.h */,
 				7199B94F2552103E00494A57 /* StyleSelfAlignmentData.cpp */,
 				9D63800F1AF16E160031A15C /* StyleSelfAlignmentData.h */,

Modified: trunk/Source/WebCore/css/CSSComputedStyleDeclaration.cpp (270022 => 270023)


--- trunk/Source/WebCore/css/CSSComputedStyleDeclaration.cpp	2020-11-19 13:55:40 UTC (rev 270022)
+++ trunk/Source/WebCore/css/CSSComputedStyleDeclaration.cpp	2020-11-19 13:59:56 UTC (rev 270023)
@@ -3809,7 +3809,6 @@
             return zoomAdjustedPixelValueForLength(style.scrollMarginRight(), style);
         case CSSPropertyScrollMarginLeft:
             return zoomAdjustedPixelValueForLength(style.scrollMarginLeft(), style);
-#if ENABLE(CSS_SCROLL_SNAP)
         case CSSPropertyScrollPadding:
             return getCSSPropertyValuesFor4SidesShorthand(scrollPaddingShorthand());
         case CSSPropertyScrollPaddingBottom:
@@ -3820,6 +3819,7 @@
             return zoomAdjustedPixelValueForLength(style.scrollPaddingRight(), style);
         case CSSPropertyScrollPaddingLeft:
             return zoomAdjustedPixelValueForLength(style.scrollPaddingLeft(), style);
+#if ENABLE(CSS_SCROLL_SNAP)
         case CSSPropertyScrollSnapType:
             return valueForScrollSnapType(style.scrollSnapType());
         case CSSPropertyScrollSnapAlign:

Modified: trunk/Source/WebCore/css/CSSProperties.json (270022 => 270023)


--- trunk/Source/WebCore/css/CSSProperties.json	2020-11-19 13:55:40 UTC (rev 270022)
+++ trunk/Source/WebCore/css/CSSProperties.json	2020-11-19 13:59:56 UTC (rev 270023)
@@ -6629,7 +6629,6 @@
         },
         "scroll-padding": {
             "codegen-properties": {
-                "enable-if": "ENABLE_CSS_SCROLL_SNAP",
                 "longhands": [
                     "scroll-padding-top",
                     "scroll-padding-right",
@@ -6644,7 +6643,6 @@
         },
         "scroll-padding-bottom": {
             "codegen-properties": {
-                "enable-if": "ENABLE_CSS_SCROLL_SNAP",
                 "initial": "initialScrollPadding",
                 "converter": "Length"
             },
@@ -6655,7 +6653,6 @@
         },
         "scroll-padding-left": {
             "codegen-properties": {
-                "enable-if": "ENABLE_CSS_SCROLL_SNAP",
                 "initial": "initialScrollPadding",
                 "converter": "Length"
             },
@@ -6666,7 +6663,6 @@
         },
         "scroll-padding-right": {
             "codegen-properties": {
-                "enable-if": "ENABLE_CSS_SCROLL_SNAP",
                 "initial": "initialScrollPadding",
                 "converter": "Length"
             },
@@ -6677,7 +6673,6 @@
         },
         "scroll-padding-top": {
             "codegen-properties": {
-                "enable-if": "ENABLE_CSS_SCROLL_SNAP",
                 "initial": "initialScrollPadding",
                 "converter": "Length"
             },
@@ -6688,7 +6683,6 @@
         },
         "scroll-padding-inline-start": {
             "codegen-properties": {
-                "enable-if": "ENABLE_CSS_SCROLL_SNAP",
                 "skip-codegen": true
             },
             "status": {
@@ -6701,7 +6695,6 @@
         },
         "scroll-padding-block-start": {
             "codegen-properties": {
-                "enable-if": "ENABLE_CSS_SCROLL_SNAP",
                 "skip-codegen": true
             },
             "status": {
@@ -6714,7 +6707,6 @@
         },
         "scroll-padding-inline-end": {
             "codegen-properties": {
-                "enable-if": "ENABLE_CSS_SCROLL_SNAP",
                 "skip-codegen": true
             },
             "status": {
@@ -6727,7 +6719,6 @@
         },
         "scroll-padding-block-end": {
             "codegen-properties": {
-                "enable-if": "ENABLE_CSS_SCROLL_SNAP",
                 "skip-codegen": true
             },
             "status": {
@@ -6744,7 +6735,6 @@
                     "scroll-padding-block-start",
                     "scroll-padding-block-end"
                 ],
-                "enable-if": "ENABLE_CSS_SCROLL_SNAP",
                 "skip-codegen": true
             },
             "status": {
@@ -6761,7 +6751,6 @@
                     "scroll-padding-inline-start",
                     "scroll-padding-inline-end"
                 ],
-                "enable-if": "ENABLE_CSS_SCROLL_SNAP",
                 "skip-codegen": true
             },
             "status": {

Modified: trunk/Source/WebCore/css/StyleProperties.cpp (270022 => 270023)


--- trunk/Source/WebCore/css/StyleProperties.cpp	2020-11-19 13:55:40 UTC (rev 270022)
+++ trunk/Source/WebCore/css/StyleProperties.cpp	2020-11-19 13:59:56 UTC (rev 270023)
@@ -287,10 +287,8 @@
         return get2Values(gapShorthand());
     case CSSPropertyScrollMargin:
         return get4Values(scrollMarginShorthand());
-#if ENABLE(CSS_SCROLL_SNAP)
     case CSSPropertyScrollPadding:
         return get4Values(scrollPaddingShorthand());
-#endif
     default:
         return String();
     }
@@ -1174,7 +1172,6 @@
             case CSSPropertyScrollMarginLeft:
                 shorthandPropertyID = CSSPropertyScrollMargin;
                 break;
-#if ENABLE(CSS_SCROLL_SNAP)
             case CSSPropertyScrollPaddingTop:
             case CSSPropertyScrollPaddingRight:
             case CSSPropertyScrollPaddingBottom:
@@ -1181,7 +1178,6 @@
             case CSSPropertyScrollPaddingLeft:
                 shorthandPropertyID = CSSPropertyScrollPadding;
                 break;
-#endif
             case CSSPropertyTransitionProperty:
             case CSSPropertyTransitionDuration:
             case CSSPropertyTransitionTimingFunction:

Modified: trunk/Source/WebCore/css/parser/CSSPropertyParser.cpp (270022 => 270023)


--- trunk/Source/WebCore/css/parser/CSSPropertyParser.cpp	2020-11-19 13:55:40 UTC (rev 270022)
+++ trunk/Source/WebCore/css/parser/CSSPropertyParser.cpp	2020-11-19 13:59:56 UTC (rev 270023)
@@ -4134,12 +4134,12 @@
     case CSSPropertyScrollMarginRight:
     case CSSPropertyScrollMarginTop:
         return consumeLength(m_range, m_context.mode, ValueRangeAll);
-#if ENABLE(CSS_SCROLL_SNAP)
     case CSSPropertyScrollPaddingBottom:
     case CSSPropertyScrollPaddingLeft:
     case CSSPropertyScrollPaddingRight:
     case CSSPropertyScrollPaddingTop:
         return consumeLengthOrPercent(m_range, m_context.mode, ValueRangeAll);
+#if ENABLE(CSS_SCROLL_SNAP)
     case CSSPropertyScrollSnapAlign:
         return consumeScrollSnapAlign(m_range);
     case CSSPropertyScrollSnapType:
@@ -5816,10 +5816,8 @@
         return consume2ValueShorthand(paddingInlineShorthand(), important);
     case CSSPropertyScrollMargin:
         return consume4ValueShorthand(scrollMarginShorthand(), important);
-#if ENABLE(CSS_SCROLL_SNAP)
     case CSSPropertyScrollPadding:
         return consume4ValueShorthand(scrollPaddingShorthand(), important);
-#endif
     case CSSPropertyWebkitTextEmphasis:
         return consumeShorthandGreedily(webkitTextEmphasisShorthand(), important);
     case CSSPropertyOutline:

Modified: trunk/Source/WebCore/rendering/RenderLayer.cpp (270022 => 270023)


--- trunk/Source/WebCore/rendering/RenderLayer.cpp	2020-11-19 13:55:40 UTC (rev 270022)
+++ trunk/Source/WebCore/rendering/RenderLayer.cpp	2020-11-19 13:59:56 UTC (rev 270023)
@@ -598,6 +598,20 @@
         || (renderer.style().willChange() && renderer.style().willChange()->canCreateStackingContext());
 }
 
+static void expandScrollRectToVisibleTargetRectToIncludeScrollPadding(RenderBox* renderBox, const LayoutRect& viewRect, LayoutRect& targetRect)
+{
+    if (!renderBox)
+        return;
+    // 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);
+}
+
 bool RenderLayer::shouldBeNormalFlowOnly() const
 {
     if (canCreateStackingContext(*this))
@@ -2810,8 +2824,14 @@
     LayoutRect newRect = absoluteRect;
     FrameView& frameView = renderer().view().frameView();
     auto* parentLayer = enclosingContainingBlockLayer(*this, CrossFrameBoundaries::No);
-    bool autoscrollNotInProgress = !renderer().frame().eventHandler().autoscrollInProgress();
 
+    auto shouldUseAnimatedScroll = [this](Element* element, ScrollBehavior behavior)
+    {
+        bool useAnimatedScrolling = !renderer().frame().eventHandler().autoscrollInProgress()
+            && element && useSmoothScrolling(behavior, element);
+        return useAnimatedScrolling ? AnimatedScroll::Yes : AnimatedScroll::No;
+    };
+
     if (allowsCurrentScroll()) {
         // Don't scroll to reveal an overflow layer that is restricted by the -webkit-line-clamp property.
         // This will prevent us from revealing text hidden by the slider in Safari RSS.
@@ -2829,14 +2849,13 @@
             localExposeRect.moveBy(LayoutPoint(-verticalScrollbarWidth(), 0));
         }
         LayoutRect layerBounds(0_lu, 0_lu, box->clientWidth(), box->clientHeight());
+        expandScrollRectToVisibleTargetRectToIncludeScrollPadding(box, layerBounds, localExposeRect);
         LayoutRect revealRect = getRectToExpose(layerBounds, localExposeRect, insideFixed, options.alignX, options.alignY);
 
         ScrollOffset clampedScrollOffset = clampScrollOffset(scrollOffset() + toIntSize(roundedIntRect(revealRect).location()));
         if (clampedScrollOffset != scrollOffset() || currentScrollBehaviorStatus() != ScrollBehaviorStatus::NotInAnimation) {
             ScrollOffset oldScrollOffset = scrollOffset();
-            AnimatedScroll animated = AnimatedScroll::No;
-            if (autoscrollNotInProgress && useSmoothScrolling(options.behavior, box->element()))
-                animated = AnimatedScroll::Yes;
+            auto animated = shouldUseAnimatedScroll(box->element(), options.behavior);
             setScrollPosition(scrollPositionFromOffset(clampedScrollOffset), ScrollType::Programmatic, ScrollClamping::Clamped, animated);
             IntSize scrollOffsetDifference = clampedScrollOffset - oldScrollOffset;
             localExposeRect.move(-scrollOffsetDifference);
@@ -2856,18 +2875,19 @@
                 ScriptDisallowedScope::InMainThread scriptDisallowedScope;
 
                 LayoutRect viewRect = frameView.visibleContentRect(LegacyIOSDocumentVisibleRect);
-                LayoutRect exposeRect = getRectToExpose(viewRect, absoluteRect, insideFixed, options.alignX, options.alignY);
 
+                auto* element = ownerElement->contentDocument() ? ownerElement->contentDocument()->documentElement() : nullptr;
+                RenderBox* renderer = element ? element->renderBox() : nullptr;
+                expandScrollRectToVisibleTargetRectToIncludeScrollPadding(renderer, viewRect, newRect);
+
+                LayoutRect exposeRect = getRectToExpose(viewRect, newRect, insideFixed, options.alignX, options.alignY);
+
                 IntPoint scrollPosition(roundedIntPoint(exposeRect.location()));
                 // Adjust offsets if they're outside of the allowable range.
                 scrollPosition = scrollPosition.constrainedBetween(IntPoint(), IntPoint(frameView.contentsSize()));
                 // FIXME: Should we use contentDocument()->scrollingElement()?
                 // See https://bugs.webkit.org/show_bug.cgi?id=205059
-                AnimatedScroll animated = AnimatedScroll::No;
-                if (autoscrollNotInProgress
-                    && ownerElement->contentDocument()
-                    && useSmoothScrolling(options.behavior, ownerElement->contentDocument()->documentElement()))
-                    animated = AnimatedScroll::Yes;
+                auto animated = shouldUseAnimatedScroll(element, options.behavior);
                 frameView.setScrollPosition(scrollPosition, ScrollClamping::Clamped, animated);
 
                 if (options.shouldAllowCrossOriginScrolling == ShouldAllowCrossOriginScrolling::Yes || frameView.safeToPropagateScrollToParent()) {
@@ -2904,6 +2924,10 @@
             LayoutRect targetRect = absoluteRect;
             targetRect.move(0, frameView.headerHeight());
 
+            auto* element = frameView.frame().document() ? frameView.frame().document()->documentElement() : nullptr;
+            RenderBox* renderer = element ? element->renderBox() : nullptr;
+            expandScrollRectToVisibleTargetRectToIncludeScrollPadding(renderer, viewRect, targetRect);
+
             LayoutRect revealRect = getRectToExpose(viewRect, targetRect, insideFixed, options.alignX, options.alignY);
             // Avoid scrolling to the rounded value of revealRect.location() if we don't actually need to scroll
             if (revealRect != viewRect) {
@@ -2910,9 +2934,7 @@
                 ScrollOffset clampedScrollPosition = roundedIntPoint(revealRect.location()).constrainedBetween(minScrollPosition, maxScrollPosition);
                 // FIXME: Should we use document()->scrollingElement()?
                 // See https://bugs.webkit.org/show_bug.cgi?id=205059
-                AnimatedScroll animated = AnimatedScroll::No;
-                if (autoscrollNotInProgress && useSmoothScrolling(options.behavior, renderer().document().documentElement()))
-                    animated = AnimatedScroll::Yes;
+                auto animated = shouldUseAnimatedScroll(element, options.behavior);
                 frameView.setScrollPosition(clampedScrollPosition, ScrollClamping::Clamped, animated);
             }
 

Modified: trunk/Source/WebCore/rendering/RenderLayerModelObject.cpp (270022 => 270023)


--- trunk/Source/WebCore/rendering/RenderLayerModelObject.cpp	2020-11-19 13:55:40 UTC (rev 270022)
+++ trunk/Source/WebCore/rendering/RenderLayerModelObject.cpp	2020-11-19 13:59:56 UTC (rev 270023)
@@ -122,7 +122,7 @@
 #if ENABLE(CSS_SCROLL_SNAP)
 static bool scrollSnapContainerRequiresUpdateForStyleUpdate(const RenderStyle& oldStyle, const RenderStyle& newStyle)
 {
-    return oldStyle.scrollSnapPort() != newStyle.scrollSnapPort();
+    return oldStyle.scrollPadding() != newStyle.scrollPadding() || oldStyle.scrollSnapType() != newStyle.scrollSnapType();
 }
 #endif
 

Modified: trunk/Source/WebCore/rendering/style/RenderStyle.cpp (270022 => 270023)


--- trunk/Source/WebCore/rendering/style/RenderStyle.cpp	2020-11-19 13:55:40 UTC (rev 270022)
+++ trunk/Source/WebCore/rendering/style/RenderStyle.cpp	2020-11-19 13:59:56 UTC (rev 270023)
@@ -2439,83 +2439,77 @@
     SET_VAR(m_rareNonInheritedData, scrollMargin.right(), WTFMove(length));
 }
 
-#if ENABLE(CSS_SCROLL_SNAP)
-
-ScrollSnapType RenderStyle::initialScrollSnapType()
+const LengthBox& RenderStyle::scrollPadding() const
 {
-    return { };
+    return m_rareNonInheritedData->scrollPadding;
 }
 
-ScrollSnapAlign RenderStyle::initialScrollSnapAlign()
+const Length& RenderStyle::scrollPaddingTop() const
 {
-    return { };
+    return scrollPadding().top();
 }
 
-const StyleScrollSnapPort& RenderStyle::scrollSnapPort() const
+const Length& RenderStyle::scrollPaddingBottom() const
 {
-    return *m_rareNonInheritedData->scrollSnapPort;
+    return scrollPadding().bottom();
 }
 
-const ScrollSnapType& RenderStyle::scrollSnapType() const
+const Length& RenderStyle::scrollPaddingLeft() const
 {
-    return m_rareNonInheritedData->scrollSnapPort->type;
+    return scrollPadding().left();
 }
 
-const LengthBox& RenderStyle::scrollPadding() const
+const Length& RenderStyle::scrollPaddingRight() const
 {
-    return m_rareNonInheritedData->scrollSnapPort->scrollPadding;
+    return scrollPadding().right();
 }
 
-const Length& RenderStyle::scrollPaddingTop() const
+void RenderStyle::setScrollPaddingTop(Length&& length)
 {
-    return scrollPadding().top();
+    SET_VAR(m_rareNonInheritedData, scrollPadding.top(), WTFMove(length));
 }
 
-const Length& RenderStyle::scrollPaddingBottom() const
+void RenderStyle::setScrollPaddingBottom(Length&& length)
 {
-    return scrollPadding().bottom();
+    SET_VAR(m_rareNonInheritedData, scrollPadding.bottom(), WTFMove(length));
 }
 
-const Length& RenderStyle::scrollPaddingLeft() const
+void RenderStyle::setScrollPaddingLeft(Length&& length)
 {
-    return scrollPadding().left();
+    SET_VAR(m_rareNonInheritedData, scrollPadding.left(), WTFMove(length));
 }
 
-const Length& RenderStyle::scrollPaddingRight() const
+void RenderStyle::setScrollPaddingRight(Length&& length)
 {
-    return scrollPadding().right();
+    SET_VAR(m_rareNonInheritedData, scrollPadding.right(), WTFMove(length));
 }
+#if ENABLE(CSS_SCROLL_SNAP)
 
-const ScrollSnapAlign& RenderStyle::scrollSnapAlign() const
+ScrollSnapType RenderStyle::initialScrollSnapType()
 {
-    return m_rareNonInheritedData->scrollSnapAlign;
+    return { };
 }
 
-void RenderStyle::setScrollSnapType(const ScrollSnapType& type)
+ScrollSnapAlign RenderStyle::initialScrollSnapAlign()
 {
-    SET_NESTED_VAR(m_rareNonInheritedData, scrollSnapPort, type, type);
+    return { };
 }
 
-void RenderStyle::setScrollPaddingTop(Length&& length)
+const ScrollSnapType RenderStyle::scrollSnapType() const
 {
-    SET_NESTED_VAR(m_rareNonInheritedData, scrollSnapPort, scrollPadding.top(), WTFMove(length));
+    return m_rareNonInheritedData->scrollSnapType;
 }
 
-void RenderStyle::setScrollPaddingBottom(Length&& length)
+const ScrollSnapAlign& RenderStyle::scrollSnapAlign() const
 {
-    SET_NESTED_VAR(m_rareNonInheritedData, scrollSnapPort, scrollPadding.bottom(), WTFMove(length));
+    return m_rareNonInheritedData->scrollSnapAlign;
 }
 
-void RenderStyle::setScrollPaddingLeft(Length&& length)
+void RenderStyle::setScrollSnapType(const ScrollSnapType type)
 {
-    SET_NESTED_VAR(m_rareNonInheritedData, scrollSnapPort, scrollPadding.left(), WTFMove(length));
+    SET_VAR(m_rareNonInheritedData, scrollSnapType, type);
 }
 
-void RenderStyle::setScrollPaddingRight(Length&& length)
-{
-    SET_NESTED_VAR(m_rareNonInheritedData, scrollSnapPort, scrollPadding.right(), WTFMove(length));
-}
-
 void RenderStyle::setScrollSnapAlign(const ScrollSnapAlign& alignment)
 {
     SET_VAR(m_rareNonInheritedData, scrollSnapAlign, alignment);

Modified: trunk/Source/WebCore/rendering/style/RenderStyle.h (270022 => 270023)


--- trunk/Source/WebCore/rendering/style/RenderStyle.h	2020-11-19 13:55:40 UTC (rev 270022)
+++ trunk/Source/WebCore/rendering/style/RenderStyle.h	2020-11-19 13:59:56 UTC (rev 270023)
@@ -117,7 +117,6 @@
 class StyleImage;
 class StyleInheritedData;
 class StyleScrollSnapArea;
-class StyleScrollSnapPort;
 class TransformationMatrix;
 
 struct ScrollSnapAlign;
@@ -725,12 +724,6 @@
     const Length& scrollMarginLeft() const;
     const Length& scrollMarginRight() const;
 
-#if ENABLE(CSS_SCROLL_SNAP)
-    bool hasSnapPosition() const;
-
-    // Scroll snap port style.
-    const StyleScrollSnapPort& scrollSnapPort() const;
-    const ScrollSnapType& scrollSnapType() const;
     const LengthBox& scrollPadding() const;
     const Length& scrollPaddingTop() const;
     const Length& scrollPaddingBottom() const;
@@ -737,6 +730,9 @@
     const Length& scrollPaddingLeft() const;
     const Length& scrollPaddingRight() const;
 
+#if ENABLE(CSS_SCROLL_SNAP)
+    bool hasSnapPosition() const;
+    const ScrollSnapType scrollSnapType() const;
     const ScrollSnapAlign& scrollSnapAlign() const;
 #endif
 
@@ -1270,13 +1266,13 @@
     void setScrollMarginLeft(Length&&);
     void setScrollMarginRight(Length&&);
 
-#if ENABLE(CSS_SCROLL_SNAP)
-    void setScrollSnapType(const ScrollSnapType&);
     void setScrollPaddingTop(Length&&);
     void setScrollPaddingBottom(Length&&);
     void setScrollPaddingLeft(Length&&);
     void setScrollPaddingRight(Length&&);
 
+#if ENABLE(CSS_SCROLL_SNAP)
+    void setScrollSnapType(const ScrollSnapType);
     void setScrollSnapAlign(const ScrollSnapAlign&);
 #endif
 
@@ -1676,11 +1672,11 @@
     static TouchAction initialTouchActions() { return TouchAction::Auto; }
 
     static Length initialScrollMargin() { return Length(Fixed); }
+    static Length initialScrollPadding() { return Length(Fixed); }
 
 #if ENABLE(CSS_SCROLL_SNAP)
     static ScrollSnapType initialScrollSnapType();
     static ScrollSnapAlign initialScrollSnapAlign();
-    static Length initialScrollPadding() { return Length(Fixed); }
 #endif
 
 #if ENABLE(CSS_TRAILING_WORD)

Modified: trunk/Source/WebCore/rendering/style/StyleRareNonInheritedData.cpp (270022 => 270023)


--- trunk/Source/WebCore/rendering/style/StyleRareNonInheritedData.cpp	2020-11-19 13:55:40 UTC (rev 270022)
+++ trunk/Source/WebCore/rendering/style/StyleRareNonInheritedData.cpp	2020-11-19 13:59:56 UTC (rev 270023)
@@ -59,9 +59,6 @@
 #endif
     , grid(StyleGridData::create())
     , gridItem(StyleGridItemData::create())
-#if ENABLE(CSS_SCROLL_SNAP)
-    , scrollSnapPort(StyleScrollSnapPort::create())
-#endif
     , willChange(RenderStyle::initialWillChange())
     , mask(FillLayer::create(FillLayerType::Mask))
     , maskBoxImage(NinePieceImage::Type::Mask)
@@ -138,8 +135,9 @@
     , grid(o.grid)
     , gridItem(o.gridItem)
     , scrollMargin(o.scrollMargin)
+    , scrollPadding(o.scrollPadding)
 #if ENABLE(CSS_SCROLL_SNAP)
-    , scrollSnapPort(o.scrollSnapPort)
+    , scrollSnapType(o.scrollSnapType)
     , scrollSnapAlign(o.scrollSnapAlign)
 #endif
     , content(o.content ? o.content->clone() : nullptr)
@@ -241,8 +239,9 @@
         && grid == o.grid
         && gridItem == o.gridItem
         && scrollMargin == o.scrollMargin
+        && scrollPadding == o.scrollPadding
 #if ENABLE(CSS_SCROLL_SNAP)
-        && scrollSnapPort == o.scrollSnapPort
+        && scrollSnapType == o.scrollSnapType
         && scrollSnapAlign == o.scrollSnapAlign
 #endif
         && contentDataEquivalent(o)

Modified: trunk/Source/WebCore/rendering/style/StyleRareNonInheritedData.h (270022 => 270023)


--- trunk/Source/WebCore/rendering/style/StyleRareNonInheritedData.h	2020-11-19 13:55:40 UTC (rev 270022)
+++ trunk/Source/WebCore/rendering/style/StyleRareNonInheritedData.h	2020-11-19 13:59:56 UTC (rev 270023)
@@ -132,8 +132,9 @@
     DataRef<StyleGridItemData> gridItem;
 
     LengthBox scrollMargin { 0, 0, 0, 0 };
+    LengthBox scrollPadding { 0, 0, 0, 0 };
 #if ENABLE(CSS_SCROLL_SNAP)
-    DataRef<StyleScrollSnapPort> scrollSnapPort;
+    ScrollSnapType scrollSnapType;
     ScrollSnapAlign scrollSnapAlign;
 #endif
 

Deleted: trunk/Source/WebCore/rendering/style/StyleScrollSnapPoints.cpp (270022 => 270023)


--- trunk/Source/WebCore/rendering/style/StyleScrollSnapPoints.cpp	2020-11-19 13:55:40 UTC (rev 270022)
+++ trunk/Source/WebCore/rendering/style/StyleScrollSnapPoints.cpp	2020-11-19 13:59:56 UTC (rev 270023)
@@ -1,51 +0,0 @@
-/*
- * Copyright (C) 2014-2016 Apple Inc. All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- * 1. Redistributions of source code must retain the above copyright
- *    notice, this list of conditions and the following disclaimer.
- * 2. Redistributions in binary form must reproduce the above copyright
- *    notice, this list of conditions and the following disclaimer in the
- *    documentation and/or other materials provided with the distribution.
- *
- * THIS SOFTWARE IS PROVIDED BY APPLE INC. AND ITS CONTRIBUTORS ``AS IS''
- * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
- * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
- * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR ITS CONTRIBUTORS
- * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
- * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
- * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
- * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
- * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
- * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF
- * THE POSSIBILITY OF SUCH DAMAGE.
- */
-
-#include "config.h"
-#include "StyleScrollSnapPoints.h"
-
-#if ENABLE(CSS_SCROLL_SNAP)
-
-namespace WebCore {
-
-Ref<StyleScrollSnapPort> StyleScrollSnapPort::copy() const
-{
-    return adoptRef(*new StyleScrollSnapPort(*this));
-}
-
-StyleScrollSnapPort::StyleScrollSnapPort()
-{
-}
-
-inline StyleScrollSnapPort::StyleScrollSnapPort(const StyleScrollSnapPort& other)
-    : RefCounted()
-    , type(other.type)
-    , scrollPadding(other.scrollPadding)
-{
-}
-
-} // namespace WebCore
-
-#endif /* ENABLE(CSS_SCROLL_SNAP) */

Modified: trunk/Source/WebCore/rendering/style/StyleScrollSnapPoints.h (270022 => 270023)


--- trunk/Source/WebCore/rendering/style/StyleScrollSnapPoints.h	2020-11-19 13:55:40 UTC (rev 270022)
+++ trunk/Source/WebCore/rendering/style/StyleScrollSnapPoints.h	2020-11-19 13:59:56 UTC (rev 270023)
@@ -47,26 +47,6 @@
 
 inline bool operator!=(const ScrollSnapType& a, const ScrollSnapType& b) { return !(a == b); }
 
-class StyleScrollSnapPort : public RefCounted<StyleScrollSnapPort> {
-public:
-    static Ref<StyleScrollSnapPort> create() { return adoptRef(*new StyleScrollSnapPort); }
-    Ref<StyleScrollSnapPort> copy() const;
-
-    ScrollSnapType type;
-    LengthBox scrollPadding { 0, 0, 0, 0 };
-
-private:
-    StyleScrollSnapPort();
-    StyleScrollSnapPort(const StyleScrollSnapPort&);
-};
-
-inline bool operator==(const StyleScrollSnapPort& a, const StyleScrollSnapPort& b)
-{
-    return a.type == b.type && a.scrollPadding == b.scrollPadding;
-}
-
-inline bool operator!=(const StyleScrollSnapPort& a, const StyleScrollSnapPort& b) { return !(a == b); }
-
 struct ScrollSnapAlign {
     ScrollSnapAxisAlignType x { ScrollSnapAxisAlignType::None };
     ScrollSnapAxisAlignType y { ScrollSnapAxisAlignType::None };
_______________________________________________
webkit-changes mailing list
[email protected]
https://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to