Changeset 270023 in webkit


Ignore:
Timestamp:
Nov 19, 2020 5:59:56 AM (20 months ago)
Author:
Martin Robinson
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.
Location:
trunk
Files:
1 deleted
19 edited

Legend:

Unmodified
Added
Removed
  • trunk/LayoutTests/ChangeLog

    r270018 r270023  
     12020-11-19  Martin Robinson  <mrobinson@webkit.org>
     2
     3        Make scroll-padding independent of scroll-snap and have it affect scrollIntoView
     4        https://bugs.webkit.org/show_bug.cgi?id=219073
     5
     6        Reviewed by Simon Fraser.
     7
     8        * TestExpectations: Mark some tests as passing.
     9        * platform/mac-wk1/TestExpectations: Mark one test as failing due to WebKit1 scrollbars.
     10
    1112020-11-17  Sergio Villar Senin  <svillar@igalia.com>
    212
  • trunk/LayoutTests/TestExpectations

    r270016 r270023  
    45694569webkit.org/b/218325 imported/w3c/web-platform-tests/css/css-scroll-snap/scroll-target-margin-001.html [ Pass ImageOnlyFailure ]
    45704570webkit.org/b/218325 imported/w3c/web-platform-tests/css/css-scroll-snap/scroll-target-margin-003.html [ Pass ImageOnlyFailure ]
    4571 imported/w3c/web-platform-tests/css/css-scroll-snap/scroll-target-padding-001.html [ ImageOnlyFailure ]
    4572 imported/w3c/web-platform-tests/css/css-scroll-snap/scroll-target-padding-002.html [ ImageOnlyFailure ]
    4573 imported/w3c/web-platform-tests/css/css-scroll-snap/scroll-target-padding-003.html [ ImageOnlyFailure ]
    45744571imported/w3c/web-platform-tests/css/css-scroll-snap/scroll-target-snap-001.html [ ImageOnlyFailure ]
    45754572imported/w3c/web-platform-tests/css/css-scroll-snap/scroll-target-snap-002.html [ ImageOnlyFailure ]
  • trunk/LayoutTests/imported/w3c/ChangeLog

    r270020 r270023  
     12020-11-19  Martin Robinson  <mrobinson@webkit.org>
     2
     3        Make scroll-padding independent of scroll-snap and have it affect scrollIntoView
     4        https://bugs.webkit.org/show_bug.cgi?id=219073
     5
     6        Reviewed by Simon Fraser.
     7
     8        * web-platform-tests/css/cssom-view/scrollIntoView-scrollPadding-expected.txt: Updated to reflect newly passing test.
     9
    1102020-11-19  Chris Lord  <clord@igalia.com>
    211
  • trunk/LayoutTests/imported/w3c/web-platform-tests/css/cssom-view/scrollIntoView-scrollPadding-expected.txt

    r235659 r270023  
    11
    2 FAIL scrollIntoView({block: "center", inline: "center"}) assert_approx_equals: scrollX expected 153.5 +/- 0.5 but got 158
    3 FAIL scrollIntoView({block: "start", inline: "start"}) assert_approx_equals: scrollX expected 184 +/- 0.5 but got 200
    4 FAIL scrollIntoView({block: "end", inline: "end"}) assert_approx_equals: scrollX expected 123 +/- 0.5 but got 115
     2PASS scrollIntoView({block: "center", inline: "center"})
     3PASS scrollIntoView({block: "start", inline: "start"})
     4PASS scrollIntoView({block: "end", inline: "end"})
    55
  • trunk/LayoutTests/platform/mac-wk1/TestExpectations

    r270016 r270023  
    446446imported/w3c/web-platform-tests/cookies/secure/set-from-ws.sub.html [ Failure ]
    447447
     448# WebKit1 frames use native scrollbars causing this reference test to fail.
     449imported/w3c/web-platform-tests/css/css-scroll-snap/scroll-target-padding-001.html [ ImageOnlyFailure ]
     450
    448451### END OF (2) Failures without bug reports
    449452########################################
  • trunk/Source/WebCore/ChangeLog

    r270019 r270023  
     12020-11-19  Martin Robinson  <mrobinson@webkit.org>
     2
     3        Make scroll-padding independent of scroll-snap and have it affect scrollIntoView
     4        https://bugs.webkit.org/show_bug.cgi?id=219073
     5
     6        Reviewed by Simon Fraser.
     7
     8        The scroll-padding CSS property is now available even when scroll-snap is not
     9        enabled at compile-time. Also make scroll-snap affect positioning during
     10        scrollIntoView operations.
     11
     12        * Sources.txt: Remove ScrollSnapPoints.cpp, because it is no longer necessary.
     13        * WebCore.xcodeproj/project.pbxproj: Ditto.
     14        * css/CSSComputedStyleDeclaration.cpp: Enable scroll-padding and scroll-padding-* unconditionally.
     15        (WebCore::ComputedStyleExtractor::valueForPropertyInStyle): Ditto.
     16        * css/CSSProperties.json: Ditto.
     17        * css/StyleProperties.cpp: Ditto.
     18        (WebCore::StyleProperties::getPropertyValue const): Ditto.
     19        (WebCore::StyleProperties::asText const): Ditto.
     20        * css/parser/CSSPropertyParser.cpp: Ditto.
     21        (WebCore::CSSPropertyParser::parseSingleValue): Ditto.
     22        (WebCore::CSSPropertyParser::parseShorthand): Ditto.
     23        * rendering/RenderLayer.cpp: Ditto.
     24        (WebCore::expandScrollRectToVisibleTargetRectToIncludeScrollPadding): Added this helper
     25        function which expands the target rectangle to include scroll padding from the container.
     26        This creates the affect that the container has a padding rectangle.
     27        (WebCore::RenderLayer::scrollRectToVisible): Now expand target rectangle to include
     28        scroll container padding. Also put some code into a lambda to simplify things.
     29        * rendering/RenderLayerModelObject.cpp: Ditto.
     30        (WebCore::scrollSnapContainerRequiresUpdateForStyleUpdate): Ditto.
     31        * rendering/style/RenderStyle.cpp: Ditto.
     32        (WebCore::RenderStyle::scrollPadding const): Ditto.
     33        (WebCore::RenderStyle::setScrollPaddingTop): Ditto.
     34        (WebCore::RenderStyle::setScrollPaddingBottom): Ditto.
     35        (WebCore::RenderStyle::setScrollPaddingLeft): Ditto.
     36        (WebCore::RenderStyle::setScrollPaddingRight): Ditto.
     37        (WebCore::RenderStyle::initialScrollSnapType): Ditto.
     38        (WebCore::RenderStyle::initialScrollSnapAlign): Ditto.
     39        (WebCore::RenderStyle::scrollSnapType const): Ditto.
     40        (WebCore::RenderStyle::scrollSnapAlign const): Ditto.
     41        (WebCore::RenderStyle::setScrollSnapType): Ditto.
     42        * rendering/style/RenderStyle.h: Ditto.
     43        (WebCore::RenderStyle::initialScrollPadding): Ditto.
     44        * rendering/style/StyleRareNonInheritedData.cpp: Have scroll-padding related properties
     45        be stored directly on StyleRareNonInheritedData.
     46        (WebCore::StyleRareNonInheritedData::StyleRareNonInheritedData):
     47        (WebCore::StyleRareNonInheritedData::operator== const):
     48        * rendering/style/StyleRareNonInheritedData.h: Ditto.
     49        * rendering/style/StyleScrollSnapPoints.cpp: Removed.
     50        * rendering/style/StyleScrollSnapPoints.h:
     51
    1522020-11-19  Carlos Garcia Campos  <cgarcia@igalia.com>
    253
  • trunk/Source/WebCore/Sources.txt

    r269984 r270023  
    23242324rendering/style/StyleRareInheritedData.cpp
    23252325rendering/style/StyleRareNonInheritedData.cpp
    2326 rendering/style/StyleScrollSnapPoints.cpp
    23272326rendering/style/StyleSelfAlignmentData.cpp
    23282327rendering/style/StyleSurroundData.cpp
  • trunk/Source/WebCore/WebCore.xcodeproj/project.pbxproj

    r269999 r270023  
    1646016460                F47A09CF20A939F600240FAE /* DisabledAdaptations.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = DisabledAdaptations.h; sourceTree = "<group>"; };
    1646116461                F47A09D420A9DD0400240FAE /* DisabledAdaptations.cpp */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.cpp.cpp; path = DisabledAdaptations.cpp; sourceTree = "<group>"; };
    16462                 F47A5E3A195B8C8A00483100 /* StyleScrollSnapPoints.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = StyleScrollSnapPoints.cpp; sourceTree = "<group>"; };
    1646316462                F47A5E3B195B8C8A00483100 /* StyleScrollSnapPoints.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = StyleScrollSnapPoints.h; sourceTree = "<group>"; };
    1646416463                F47A633C1FF6FD500081B3CC /* PromisedAttachmentInfo.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = PromisedAttachmentInfo.h; sourceTree = "<group>"; };
     
    2699126990                                BC2272BB0E82EAAE00E7F975 /* StyleRareNonInheritedData.h */,
    2699226991                                BC2272860E82E70700E7F975 /* StyleReflection.h */,
    26993                                 F47A5E3A195B8C8A00483100 /* StyleScrollSnapPoints.cpp */,
    2699426992                                F47A5E3B195B8C8A00483100 /* StyleScrollSnapPoints.h */,
    2699526993                                7199B94F2552103E00494A57 /* StyleSelfAlignmentData.cpp */,
  • trunk/Source/WebCore/css/CSSComputedStyleDeclaration.cpp

    r269820 r270023  
    38103810        case CSSPropertyScrollMarginLeft:
    38113811            return zoomAdjustedPixelValueForLength(style.scrollMarginLeft(), style);
    3812 #if ENABLE(CSS_SCROLL_SNAP)
    38133812        case CSSPropertyScrollPadding:
    38143813            return getCSSPropertyValuesFor4SidesShorthand(scrollPaddingShorthand());
     
    38213820        case CSSPropertyScrollPaddingLeft:
    38223821            return zoomAdjustedPixelValueForLength(style.scrollPaddingLeft(), style);
     3822#if ENABLE(CSS_SCROLL_SNAP)
    38233823        case CSSPropertyScrollSnapType:
    38243824            return valueForScrollSnapType(style.scrollSnapType());
  • trunk/Source/WebCore/css/CSSProperties.json

    r269862 r270023  
    66306630        "scroll-padding": {
    66316631            "codegen-properties": {
    6632                 "enable-if": "ENABLE_CSS_SCROLL_SNAP",
    66336632                "longhands": [
    66346633                    "scroll-padding-top",
     
    66456644        "scroll-padding-bottom": {
    66466645            "codegen-properties": {
    6647                 "enable-if": "ENABLE_CSS_SCROLL_SNAP",
    66486646                "initial": "initialScrollPadding",
    66496647                "converter": "Length"
     
    66566654        "scroll-padding-left": {
    66576655            "codegen-properties": {
    6658                 "enable-if": "ENABLE_CSS_SCROLL_SNAP",
    66596656                "initial": "initialScrollPadding",
    66606657                "converter": "Length"
     
    66676664        "scroll-padding-right": {
    66686665            "codegen-properties": {
    6669                 "enable-if": "ENABLE_CSS_SCROLL_SNAP",
    66706666                "initial": "initialScrollPadding",
    66716667                "converter": "Length"
     
    66786674        "scroll-padding-top": {
    66796675            "codegen-properties": {
    6680                 "enable-if": "ENABLE_CSS_SCROLL_SNAP",
    66816676                "initial": "initialScrollPadding",
    66826677                "converter": "Length"
     
    66896684        "scroll-padding-inline-start": {
    66906685            "codegen-properties": {
    6691                 "enable-if": "ENABLE_CSS_SCROLL_SNAP",
    66926686                "skip-codegen": true
    66936687            },
     
    67026696        "scroll-padding-block-start": {
    67036697            "codegen-properties": {
    6704                 "enable-if": "ENABLE_CSS_SCROLL_SNAP",
    67056698                "skip-codegen": true
    67066699            },
     
    67156708        "scroll-padding-inline-end": {
    67166709            "codegen-properties": {
    6717                 "enable-if": "ENABLE_CSS_SCROLL_SNAP",
    67186710                "skip-codegen": true
    67196711            },
     
    67286720        "scroll-padding-block-end": {
    67296721            "codegen-properties": {
    6730                 "enable-if": "ENABLE_CSS_SCROLL_SNAP",
    67316722                "skip-codegen": true
    67326723            },
     
    67456736                    "scroll-padding-block-end"
    67466737                ],
    6747                 "enable-if": "ENABLE_CSS_SCROLL_SNAP",
    67486738                "skip-codegen": true
    67496739            },
     
    67626752                    "scroll-padding-inline-end"
    67636753                ],
    6764                 "enable-if": "ENABLE_CSS_SCROLL_SNAP",
    67656754                "skip-codegen": true
    67666755            },
  • trunk/Source/WebCore/css/StyleProperties.cpp

    r269820 r270023  
    288288    case CSSPropertyScrollMargin:
    289289        return get4Values(scrollMarginShorthand());
    290 #if ENABLE(CSS_SCROLL_SNAP)
    291290    case CSSPropertyScrollPadding:
    292291        return get4Values(scrollPaddingShorthand());
    293 #endif
    294292    default:
    295293        return String();
     
    11751173                shorthandPropertyID = CSSPropertyScrollMargin;
    11761174                break;
    1177 #if ENABLE(CSS_SCROLL_SNAP)
    11781175            case CSSPropertyScrollPaddingTop:
    11791176            case CSSPropertyScrollPaddingRight:
     
    11821179                shorthandPropertyID = CSSPropertyScrollPadding;
    11831180                break;
    1184 #endif
    11851181            case CSSPropertyTransitionProperty:
    11861182            case CSSPropertyTransitionDuration:
  • trunk/Source/WebCore/css/parser/CSSPropertyParser.cpp

    r269957 r270023  
    41354135    case CSSPropertyScrollMarginTop:
    41364136        return consumeLength(m_range, m_context.mode, ValueRangeAll);
    4137 #if ENABLE(CSS_SCROLL_SNAP)
    41384137    case CSSPropertyScrollPaddingBottom:
    41394138    case CSSPropertyScrollPaddingLeft:
     
    41414140    case CSSPropertyScrollPaddingTop:
    41424141        return consumeLengthOrPercent(m_range, m_context.mode, ValueRangeAll);
     4142#if ENABLE(CSS_SCROLL_SNAP)
    41434143    case CSSPropertyScrollSnapAlign:
    41444144        return consumeScrollSnapAlign(m_range);
     
    58175817    case CSSPropertyScrollMargin:
    58185818        return consume4ValueShorthand(scrollMarginShorthand(), important);
    5819 #if ENABLE(CSS_SCROLL_SNAP)
    58205819    case CSSPropertyScrollPadding:
    58215820        return consume4ValueShorthand(scrollPaddingShorthand(), important);
    5822 #endif
    58235821    case CSSPropertyWebkitTextEmphasis:
    58245822        return consumeShorthandGreedily(webkitTextEmphasisShorthand(), important);
  • trunk/Source/WebCore/rendering/RenderLayer.cpp

    r269888 r270023  
    599599}
    600600
     601static void expandScrollRectToVisibleTargetRectToIncludeScrollPadding(RenderBox* renderBox, const LayoutRect& viewRect, LayoutRect& targetRect)
     602{
     603    if (!renderBox)
     604        return;
     605    // scroll-padding applies to the scroll container, but expand the rectangle that we want to expose in order
     606    // simulate padding the scroll container. This rectangle is passed up the tree of scrolling elements to
     607    // ensure that the padding on this scroll container is maintained.
     608    const auto& scrollPadding = renderBox->style().scrollPadding();
     609    LayoutBoxExtent scrollPaddingExtents(
     610        valueForLength(scrollPadding.top(), viewRect.height()), valueForLength(scrollPadding.right(), viewRect.width()),
     611        valueForLength(scrollPadding.bottom(), viewRect.height()), valueForLength(scrollPadding.left(), viewRect.width()));
     612    targetRect.expand(scrollPaddingExtents);
     613}
     614
    601615bool RenderLayer::shouldBeNormalFlowOnly() const
    602616{
     
    28112825    FrameView& frameView = renderer().view().frameView();
    28122826    auto* parentLayer = enclosingContainingBlockLayer(*this, CrossFrameBoundaries::No);
    2813     bool autoscrollNotInProgress = !renderer().frame().eventHandler().autoscrollInProgress();
     2827
     2828    auto shouldUseAnimatedScroll = [this](Element* element, ScrollBehavior behavior)
     2829    {
     2830        bool useAnimatedScrolling = !renderer().frame().eventHandler().autoscrollInProgress()
     2831            && element && useSmoothScrolling(behavior, element);
     2832        return useAnimatedScrolling ? AnimatedScroll::Yes : AnimatedScroll::No;
     2833    };
    28142834
    28152835    if (allowsCurrentScroll()) {
     
    28302850        }
    28312851        LayoutRect layerBounds(0_lu, 0_lu, box->clientWidth(), box->clientHeight());
     2852        expandScrollRectToVisibleTargetRectToIncludeScrollPadding(box, layerBounds, localExposeRect);
    28322853        LayoutRect revealRect = getRectToExpose(layerBounds, localExposeRect, insideFixed, options.alignX, options.alignY);
    28332854
     
    28352856        if (clampedScrollOffset != scrollOffset() || currentScrollBehaviorStatus() != ScrollBehaviorStatus::NotInAnimation) {
    28362857            ScrollOffset oldScrollOffset = scrollOffset();
    2837             AnimatedScroll animated = AnimatedScroll::No;
    2838             if (autoscrollNotInProgress && useSmoothScrolling(options.behavior, box->element()))
    2839                 animated = AnimatedScroll::Yes;
     2858            auto animated = shouldUseAnimatedScroll(box->element(), options.behavior);
    28402859            setScrollPosition(scrollPositionFromOffset(clampedScrollOffset), ScrollType::Programmatic, ScrollClamping::Clamped, animated);
    28412860            IntSize scrollOffsetDifference = clampedScrollOffset - oldScrollOffset;
     
    28572876
    28582877                LayoutRect viewRect = frameView.visibleContentRect(LegacyIOSDocumentVisibleRect);
    2859                 LayoutRect exposeRect = getRectToExpose(viewRect, absoluteRect, insideFixed, options.alignX, options.alignY);
     2878
     2879                auto* element = ownerElement->contentDocument() ? ownerElement->contentDocument()->documentElement() : nullptr;
     2880                RenderBox* renderer = element ? element->renderBox() : nullptr;
     2881                expandScrollRectToVisibleTargetRectToIncludeScrollPadding(renderer, viewRect, newRect);
     2882
     2883                LayoutRect exposeRect = getRectToExpose(viewRect, newRect, insideFixed, options.alignX, options.alignY);
    28602884
    28612885                IntPoint scrollPosition(roundedIntPoint(exposeRect.location()));
     
    28642888                // FIXME: Should we use contentDocument()->scrollingElement()?
    28652889                // See https://bugs.webkit.org/show_bug.cgi?id=205059
    2866                 AnimatedScroll animated = AnimatedScroll::No;
    2867                 if (autoscrollNotInProgress
    2868                     && ownerElement->contentDocument()
    2869                     && useSmoothScrolling(options.behavior, ownerElement->contentDocument()->documentElement()))
    2870                     animated = AnimatedScroll::Yes;
     2890                auto animated = shouldUseAnimatedScroll(element, options.behavior);
    28712891                frameView.setScrollPosition(scrollPosition, ScrollClamping::Clamped, animated);
    28722892
     
    29052925            targetRect.move(0, frameView.headerHeight());
    29062926
     2927            auto* element = frameView.frame().document() ? frameView.frame().document()->documentElement() : nullptr;
     2928            RenderBox* renderer = element ? element->renderBox() : nullptr;
     2929            expandScrollRectToVisibleTargetRectToIncludeScrollPadding(renderer, viewRect, targetRect);
     2930
    29072931            LayoutRect revealRect = getRectToExpose(viewRect, targetRect, insideFixed, options.alignX, options.alignY);
    29082932            // Avoid scrolling to the rounded value of revealRect.location() if we don't actually need to scroll
     
    29112935                // FIXME: Should we use document()->scrollingElement()?
    29122936                // See https://bugs.webkit.org/show_bug.cgi?id=205059
    2913                 AnimatedScroll animated = AnimatedScroll::No;
    2914                 if (autoscrollNotInProgress && useSmoothScrolling(options.behavior, renderer().document().documentElement()))
    2915                     animated = AnimatedScroll::Yes;
     2937                auto animated = shouldUseAnimatedScroll(element, options.behavior);
    29162938                frameView.setScrollPosition(clampedScrollPosition, ScrollClamping::Clamped, animated);
    29172939            }
  • trunk/Source/WebCore/rendering/RenderLayerModelObject.cpp

    r269144 r270023  
    123123static bool scrollSnapContainerRequiresUpdateForStyleUpdate(const RenderStyle& oldStyle, const RenderStyle& newStyle)
    124124{
    125     return oldStyle.scrollSnapPort() != newStyle.scrollSnapPort();
     125    return oldStyle.scrollPadding() != newStyle.scrollPadding() || oldStyle.scrollSnapType() != newStyle.scrollSnapType();
    126126}
    127127#endif
  • trunk/Source/WebCore/rendering/style/RenderStyle.cpp

    r269835 r270023  
    24402440}
    24412441
     2442const LengthBox& RenderStyle::scrollPadding() const
     2443{
     2444    return m_rareNonInheritedData->scrollPadding;
     2445}
     2446
     2447const Length& RenderStyle::scrollPaddingTop() const
     2448{
     2449    return scrollPadding().top();
     2450}
     2451
     2452const Length& RenderStyle::scrollPaddingBottom() const
     2453{
     2454    return scrollPadding().bottom();
     2455}
     2456
     2457const Length& RenderStyle::scrollPaddingLeft() const
     2458{
     2459    return scrollPadding().left();
     2460}
     2461
     2462const Length& RenderStyle::scrollPaddingRight() const
     2463{
     2464    return scrollPadding().right();
     2465}
     2466
     2467void RenderStyle::setScrollPaddingTop(Length&& length)
     2468{
     2469    SET_VAR(m_rareNonInheritedData, scrollPadding.top(), WTFMove(length));
     2470}
     2471
     2472void RenderStyle::setScrollPaddingBottom(Length&& length)
     2473{
     2474    SET_VAR(m_rareNonInheritedData, scrollPadding.bottom(), WTFMove(length));
     2475}
     2476
     2477void RenderStyle::setScrollPaddingLeft(Length&& length)
     2478{
     2479    SET_VAR(m_rareNonInheritedData, scrollPadding.left(), WTFMove(length));
     2480}
     2481
     2482void RenderStyle::setScrollPaddingRight(Length&& length)
     2483{
     2484    SET_VAR(m_rareNonInheritedData, scrollPadding.right(), WTFMove(length));
     2485}
    24422486#if ENABLE(CSS_SCROLL_SNAP)
    24432487
     
    24522496}
    24532497
    2454 const StyleScrollSnapPort& RenderStyle::scrollSnapPort() const
    2455 {
    2456     return *m_rareNonInheritedData->scrollSnapPort;
    2457 }
    2458 
    2459 const ScrollSnapType& RenderStyle::scrollSnapType() const
    2460 {
    2461     return m_rareNonInheritedData->scrollSnapPort->type;
    2462 }
    2463 
    2464 const LengthBox& RenderStyle::scrollPadding() const
    2465 {
    2466     return m_rareNonInheritedData->scrollSnapPort->scrollPadding;
    2467 }
    2468 
    2469 const Length& RenderStyle::scrollPaddingTop() const
    2470 {
    2471     return scrollPadding().top();
    2472 }
    2473 
    2474 const Length& RenderStyle::scrollPaddingBottom() const
    2475 {
    2476     return scrollPadding().bottom();
    2477 }
    2478 
    2479 const Length& RenderStyle::scrollPaddingLeft() const
    2480 {
    2481     return scrollPadding().left();
    2482 }
    2483 
    2484 const Length& RenderStyle::scrollPaddingRight() const
    2485 {
    2486     return scrollPadding().right();
     2498const ScrollSnapType RenderStyle::scrollSnapType() const
     2499{
     2500    return m_rareNonInheritedData->scrollSnapType;
    24872501}
    24882502
     
    24922506}
    24932507
    2494 void RenderStyle::setScrollSnapType(const ScrollSnapType& type)
    2495 {
    2496     SET_NESTED_VAR(m_rareNonInheritedData, scrollSnapPort, type, type);
    2497 }
    2498 
    2499 void RenderStyle::setScrollPaddingTop(Length&& length)
    2500 {
    2501     SET_NESTED_VAR(m_rareNonInheritedData, scrollSnapPort, scrollPadding.top(), WTFMove(length));
    2502 }
    2503 
    2504 void RenderStyle::setScrollPaddingBottom(Length&& length)
    2505 {
    2506     SET_NESTED_VAR(m_rareNonInheritedData, scrollSnapPort, scrollPadding.bottom(), WTFMove(length));
    2507 }
    2508 
    2509 void RenderStyle::setScrollPaddingLeft(Length&& length)
    2510 {
    2511     SET_NESTED_VAR(m_rareNonInheritedData, scrollSnapPort, scrollPadding.left(), WTFMove(length));
    2512 }
    2513 
    2514 void RenderStyle::setScrollPaddingRight(Length&& length)
    2515 {
    2516     SET_NESTED_VAR(m_rareNonInheritedData, scrollSnapPort, scrollPadding.right(), WTFMove(length));
     2508void RenderStyle::setScrollSnapType(const ScrollSnapType type)
     2509{
     2510    SET_VAR(m_rareNonInheritedData, scrollSnapType, type);
    25172511}
    25182512
  • trunk/Source/WebCore/rendering/style/RenderStyle.h

    r269835 r270023  
    118118class StyleInheritedData;
    119119class StyleScrollSnapArea;
    120 class StyleScrollSnapPort;
    121120class TransformationMatrix;
    122121
     
    726725    const Length& scrollMarginRight() const;
    727726
    728 #if ENABLE(CSS_SCROLL_SNAP)
    729     bool hasSnapPosition() const;
    730 
    731     // Scroll snap port style.
    732     const StyleScrollSnapPort& scrollSnapPort() const;
    733     const ScrollSnapType& scrollSnapType() const;
    734727    const LengthBox& scrollPadding() const;
    735728    const Length& scrollPaddingTop() const;
     
    738731    const Length& scrollPaddingRight() const;
    739732
     733#if ENABLE(CSS_SCROLL_SNAP)
     734    bool hasSnapPosition() const;
     735    const ScrollSnapType scrollSnapType() const;
    740736    const ScrollSnapAlign& scrollSnapAlign() const;
    741737#endif
     
    12711267    void setScrollMarginRight(Length&&);
    12721268
    1273 #if ENABLE(CSS_SCROLL_SNAP)
    1274     void setScrollSnapType(const ScrollSnapType&);
    12751269    void setScrollPaddingTop(Length&&);
    12761270    void setScrollPaddingBottom(Length&&);
     
    12781272    void setScrollPaddingRight(Length&&);
    12791273
     1274#if ENABLE(CSS_SCROLL_SNAP)
     1275    void setScrollSnapType(const ScrollSnapType);
    12801276    void setScrollSnapAlign(const ScrollSnapAlign&);
    12811277#endif
     
    16771673
    16781674    static Length initialScrollMargin() { return Length(Fixed); }
     1675    static Length initialScrollPadding() { return Length(Fixed); }
    16791676
    16801677#if ENABLE(CSS_SCROLL_SNAP)
    16811678    static ScrollSnapType initialScrollSnapType();
    16821679    static ScrollSnapAlign initialScrollSnapAlign();
    1683     static Length initialScrollPadding() { return Length(Fixed); }
    16841680#endif
    16851681
  • trunk/Source/WebCore/rendering/style/StyleRareNonInheritedData.cpp

    r269820 r270023  
    6060    , grid(StyleGridData::create())
    6161    , gridItem(StyleGridItemData::create())
    62 #if ENABLE(CSS_SCROLL_SNAP)
    63     , scrollSnapPort(StyleScrollSnapPort::create())
    64 #endif
    6562    , willChange(RenderStyle::initialWillChange())
    6663    , mask(FillLayer::create(FillLayerType::Mask))
     
    139136    , gridItem(o.gridItem)
    140137    , scrollMargin(o.scrollMargin)
     138    , scrollPadding(o.scrollPadding)
    141139#if ENABLE(CSS_SCROLL_SNAP)
    142     , scrollSnapPort(o.scrollSnapPort)
     140    , scrollSnapType(o.scrollSnapType)
    143141    , scrollSnapAlign(o.scrollSnapAlign)
    144142#endif
     
    242240        && gridItem == o.gridItem
    243241        && scrollMargin == o.scrollMargin
     242        && scrollPadding == o.scrollPadding
    244243#if ENABLE(CSS_SCROLL_SNAP)
    245         && scrollSnapPort == o.scrollSnapPort
     244        && scrollSnapType == o.scrollSnapType
    246245        && scrollSnapAlign == o.scrollSnapAlign
    247246#endif
  • trunk/Source/WebCore/rendering/style/StyleRareNonInheritedData.h

    r269820 r270023  
    133133
    134134    LengthBox scrollMargin { 0, 0, 0, 0 };
     135    LengthBox scrollPadding { 0, 0, 0, 0 };
    135136#if ENABLE(CSS_SCROLL_SNAP)
    136     DataRef<StyleScrollSnapPort> scrollSnapPort;
     137    ScrollSnapType scrollSnapType;
    137138    ScrollSnapAlign scrollSnapAlign;
    138139#endif
  • trunk/Source/WebCore/rendering/style/StyleScrollSnapPoints.h

    r269144 r270023  
    4848inline bool operator!=(const ScrollSnapType& a, const ScrollSnapType& b) { return !(a == b); }
    4949
    50 class StyleScrollSnapPort : public RefCounted<StyleScrollSnapPort> {
    51 public:
    52     static Ref<StyleScrollSnapPort> create() { return adoptRef(*new StyleScrollSnapPort); }
    53     Ref<StyleScrollSnapPort> copy() const;
    54 
    55     ScrollSnapType type;
    56     LengthBox scrollPadding { 0, 0, 0, 0 };
    57 
    58 private:
    59     StyleScrollSnapPort();
    60     StyleScrollSnapPort(const StyleScrollSnapPort&);
    61 };
    62 
    63 inline bool operator==(const StyleScrollSnapPort& a, const StyleScrollSnapPort& b)
    64 {
    65     return a.type == b.type && a.scrollPadding == b.scrollPadding;
    66 }
    67 
    68 inline bool operator!=(const StyleScrollSnapPort& a, const StyleScrollSnapPort& b) { return !(a == b); }
    69 
    7050struct ScrollSnapAlign {
    7151    ScrollSnapAxisAlignType x { ScrollSnapAxisAlignType::None };
Note: See TracChangeset for help on using the changeset viewer.