Changeset 181189 in webkit


Ignore:
Timestamp:
Mar 6, 2015 3:39:57 PM (9 years ago)
Author:
Brent Fulgham
Message:

Add 'initial' keyword support for scroll snap CSS properties
https://bugs.webkit.org/show_bug.cgi?id=136345
<rdar://problem/18162325>

Reviewed by Dean Jackson.

Source/WebCore:

Tested by css3/scroll-snap/scroll-snap-initial.html

The existing implementation already had 'initial' keyword support, but did not fully follow
the CSS specification. In particular, the 'initial' state for the scroll-snap-points-x and
scroll-snap-points-y properties was not handled correctly.

Revise implementation to represent ScrollSnapPoints as a pointer, so that 'none' is a valid
state.

  • css/CSSComputedStyleDeclaration.cpp:

(WebCore::scrollSnapPoints): If 'points' is null, return CSSValueNone.

  • css/CSSPropertyNames.in: Provide custom initial/inherit handles for snap point x/y sets.
  • css/StyleBuilderConverter.h:

(WebCore::StyleBuilderConverter::convertScrollSnapPoints): Update to represent ScrollSnapPoints
as a pointer.

  • css/StyleBuilderCustom.h:

(WebCore::StyleBuilderCustom::applyInitialWebkitScrollSnapPointsX): Provide custom pointer-based
implementation for ScrollSnapPoints.
(WebCore::StyleBuilderCustom::applyInheritWebkitScrollSnapPointsX): Ditto.
(WebCore::StyleBuilderCustom::applyInitialWebkitScrollSnapPointsY): Ditto.
(WebCore::StyleBuilderCustom::applyInheritWebkitScrollSnapPointsY): Ditto."

  • page/scrolling/AxisScrollSnapOffsets.cpp:

(WebCore::updateFromStyle): Handle ScrollSnapPoints as pointers.
(WebCore::updateSnapOffsetsForScrollableArea): Ditto.

  • rendering/style/RenderStyle.cpp:

(WebCore::RenderStyle::scrollSnapPointsX): Update to use pointer-based representation of ScrollSnapPoints.
(WebCore::RenderStyle::scrollSnapPointsY): Ditto.
(WebCore::RenderStyle::setScrollSnapPointsX): Ditto.
(WebCore::RenderStyle::setScrollSnapPointsY): Ditto.
(WebCore::RenderStyle::initialScrollSnapPointsX): Deleted.
(WebCore::RenderStyle::initialScrollSnapPointsY): Deleted.

  • rendering/style/RenderStyle.h:
  • rendering/style/StyleScrollSnapPoints.cpp:

(WebCore::StyleScrollSnapPoints::StyleScrollSnapPoints): Revise constructor to handle pointer argument.

  • rendering/style/StyleScrollSnapPoints.h:

LayoutTests:

  • css3/scroll-snap/scroll-snap-property-computed-style.js: Update for corrected 'initial' behavior.
  • css3/scroll-snap/scroll-snap-property-computed-style-expected.txt: Rebaselined.
  • css3/scroll-snap/scroll-snap-initial.html: Added.
  • css3/scroll-snap/scroll-snap-initial-expected.txt: Added.
  • platform/efl/TestExpectations:
  • platform/gtk/TestExpectations:
  • platform/win/TestExpectations:
Location:
trunk
Files:
2 added
16 edited

Legend:

Unmodified
Added
Removed
  • trunk/LayoutTests/ChangeLog

    r181183 r181189  
     12015-03-06  Brent Fulgham  <bfulgham@apple.com>
     2
     3        Add 'initial' keyword support for scroll snap CSS properties
     4        https://bugs.webkit.org/show_bug.cgi?id=136345
     5        <rdar://problem/18162325>
     6
     7        Reviewed by Dean Jackson.
     8
     9        * css3/scroll-snap/scroll-snap-property-computed-style.js: Update for corrected 'initial' behavior.
     10        * css3/scroll-snap/scroll-snap-property-computed-style-expected.txt: Rebaselined.
     11        * css3/scroll-snap/scroll-snap-initial.html: Added.
     12        * css3/scroll-snap/scroll-snap-initial-expected.txt: Added.
     13        * platform/efl/TestExpectations:
     14        * platform/gtk/TestExpectations:
     15        * platform/win/TestExpectations:
     16
    1172015-03-06  Joseph Pecoraro  <pecoraro@apple.com>
    218
  • trunk/LayoutTests/css3/scroll-snap/scroll-snap-property-computed-style-expected.txt

    r173659 r181189  
    99
    1010invalid points along x axis : hello world
    11 PASS window.getComputedStyle(document.body).getPropertyValue('-webkit-scroll-snap-points-x') is 'repeat(100%)'
     11PASS window.getComputedStyle(document.body).getPropertyValue('-webkit-scroll-snap-points-x') is 'none'
    1212
    1313invalid points along y axis : hello world
    14 PASS window.getComputedStyle(document.body).getPropertyValue('-webkit-scroll-snap-points-y') is 'repeat(100%)'
     14PASS window.getComputedStyle(document.body).getPropertyValue('-webkit-scroll-snap-points-y') is 'none'
    1515
    1616typo in point definition : repaet(50px)
    17 PASS window.getComputedStyle(document.body).getPropertyValue('-webkit-scroll-snap-points-x') is 'repeat(100%)'
     17PASS window.getComputedStyle(document.body).getPropertyValue('-webkit-scroll-snap-points-x') is 'none'
    1818
    1919another invalid point definition : ??px repeat(50px)
    20 PASS window.getComputedStyle(document.body).getPropertyValue('-webkit-scroll-snap-points-x') is 'repeat(100%)'
     20PASS window.getComputedStyle(document.body).getPropertyValue('-webkit-scroll-snap-points-x') is 'none'
    2121
    2222invalid destination : foo bar
     
    5151
    5252inherited points along x axis : inherit
    53 PASS window.getComputedStyle(document.body).getPropertyValue('-webkit-scroll-snap-points-x') is 'repeat(100%)'
     53PASS window.getComputedStyle(document.body).getPropertyValue('-webkit-scroll-snap-points-x') is 'none'
    5454
    5555initial points along x axis : initial
    56 PASS window.getComputedStyle(document.body).getPropertyValue('-webkit-scroll-snap-points-x') is 'repeat(100%)'
     56PASS window.getComputedStyle(document.body).getPropertyValue('-webkit-scroll-snap-points-x') is 'none'
    5757
    5858element points along x axis : elements
     
    8484
    8585inherited points along y axis : inherit
    86 PASS window.getComputedStyle(document.body).getPropertyValue('-webkit-scroll-snap-points-y') is 'repeat(100%)'
     86PASS window.getComputedStyle(document.body).getPropertyValue('-webkit-scroll-snap-points-y') is 'none'
    8787
    8888initial points along y axis : initial
    89 PASS window.getComputedStyle(document.body).getPropertyValue('-webkit-scroll-snap-points-y') is 'repeat(100%)'
     89PASS window.getComputedStyle(document.body).getPropertyValue('-webkit-scroll-snap-points-y') is 'none'
    9090
    9191element points along y axis : elements
  • trunk/LayoutTests/css3/scroll-snap/scroll-snap-property-computed-style.js

    r173659 r181189  
    1818
    1919testComputedScrollSnapRule("invalid snapping type", "type", "potato", "none");
    20 testComputedScrollSnapRule("invalid points along x axis", "points-x", "hello world", "repeat(100%)");
    21 testComputedScrollSnapRule("invalid points along y axis", "points-y", "hello world", "repeat(100%)");
    22 testComputedScrollSnapRule("typo in point definition", "points-x", "repaet(50px)", "repeat(100%)");
    23 testComputedScrollSnapRule("another invalid point definition", "points-x", "??px repeat(50px)", "repeat(100%)");
     20testComputedScrollSnapRule("invalid points along x axis", "points-x", "hello world", "none");
     21testComputedScrollSnapRule("invalid points along y axis", "points-y", "hello world", "none");
     22testComputedScrollSnapRule("typo in point definition", "points-x", "repaet(50px)", "none");
     23testComputedScrollSnapRule("another invalid point definition", "points-x", "??px repeat(50px)", "none");
    2424testComputedScrollSnapRule("invalid destination", "destination", "foo bar", "0px 0px");
    2525testComputedScrollSnapRule("short one destination value", "destination", "50%", "0px 0px");
     
    3434testComputedScrollSnapRule("proximity type", "type", "proximity", "proximity");
    3535
    36 testComputedScrollSnapRule("inherited points along x axis", "points-x", "inherit", "repeat(100%)");
    37 testComputedScrollSnapRule("initial points along x axis", "points-x", "initial", "repeat(100%)");
     36testComputedScrollSnapRule("inherited points along x axis", "points-x", "inherit", "none");
     37testComputedScrollSnapRule("initial points along x axis", "points-x", "initial", "none");
    3838testComputedScrollSnapRule("element points along x axis", "points-x", "elements", "elements");
    3939testComputedScrollSnapRule("percentage points along x axis", "points-x", "100% 50%", "100% 50%");
     
    4646testComputedScrollSnapRule("pixel points along x axis with pixel repeat", "points-x", "100px repeat(42px)", "100px repeat(42px)");
    4747
    48 testComputedScrollSnapRule("inherited points along y axis", "points-y", "inherit", "repeat(100%)");
    49 testComputedScrollSnapRule("initial points along y axis", "points-y", "initial", "repeat(100%)");
     48testComputedScrollSnapRule("inherited points along y axis", "points-y", "inherit", "none");
     49testComputedScrollSnapRule("initial points along y axis", "points-y", "initial", "none");
    5050testComputedScrollSnapRule("element points along y axis", "points-y", "elements", "elements");
    5151testComputedScrollSnapRule("percentage points along y axis", "points-y", "100% 50%", "100% 50%");
  • trunk/LayoutTests/platform/efl/TestExpectations

    r181148 r181189  
    5959fast/dom/Window/slow-unload-handler.html
    6060fast/dom/Window/slow-unload-handler-only-frame-is-stopped.html
     61
     62# Need a scroll snap point implementation
     63css3/scroll-snap [ Skip ]
    6164
    6265# ----------------------------------------
  • trunk/LayoutTests/platform/gtk/TestExpectations

    r181012 r181189  
    621621webkit.org/b/142291 fast/regions/repaint/fixed-in-named-flow-cb-changed.html [ ImageOnlyFailure ]
    622622
    623 
     623# TODO Scroll snap points
     624css3/scroll-snap [ Skip ]
    624625#////////////////////////////////////////////////////////////////////////////////////////
    625626# End of Expected failures
  • trunk/LayoutTests/platform/win/TestExpectations

    r181135 r181189  
    592592# TODO Attachment elements do not provide a custom renderer
    593593webkit.org/b/142260 fast/attachment [ Skip ]
     594
     595# TODO Scroll snap points
     596css3/scroll-snap [ Skip ]
    594597################################################################################
    595598###########    End Missing Functionality Prevents Testing         ##############
  • trunk/Source/WebCore/ChangeLog

    r181178 r181189  
     12015-03-06  Brent Fulgham  <bfulgham@apple.com>
     2
     3        Add 'initial' keyword support for scroll snap CSS properties
     4        https://bugs.webkit.org/show_bug.cgi?id=136345
     5        <rdar://problem/18162325>
     6
     7        Reviewed by Dean Jackson.
     8
     9        Tested by css3/scroll-snap/scroll-snap-initial.html
     10
     11        The existing implementation already had 'initial' keyword support, but did not fully follow
     12        the CSS specification. In particular, the 'initial' state for the scroll-snap-points-x and
     13        scroll-snap-points-y properties was not handled correctly.
     14
     15        Revise implementation to represent ScrollSnapPoints as a pointer, so that 'none' is a valid
     16        state.
     17
     18        * css/CSSComputedStyleDeclaration.cpp:
     19        (WebCore::scrollSnapPoints): If 'points' is null, return CSSValueNone.
     20        * css/CSSPropertyNames.in: Provide custom initial/inherit handles for snap point x/y sets.
     21        * css/StyleBuilderConverter.h:
     22        (WebCore::StyleBuilderConverter::convertScrollSnapPoints): Update to represent ScrollSnapPoints
     23        as a pointer.
     24        * css/StyleBuilderCustom.h:
     25        (WebCore::StyleBuilderCustom::applyInitialWebkitScrollSnapPointsX): Provide custom pointer-based
     26        implementation for ScrollSnapPoints.
     27        (WebCore::StyleBuilderCustom::applyInheritWebkitScrollSnapPointsX): Ditto.
     28        (WebCore::StyleBuilderCustom::applyInitialWebkitScrollSnapPointsY): Ditto.
     29        (WebCore::StyleBuilderCustom::applyInheritWebkitScrollSnapPointsY): Ditto."
     30        * page/scrolling/AxisScrollSnapOffsets.cpp:
     31        (WebCore::updateFromStyle): Handle ScrollSnapPoints as pointers.
     32        (WebCore::updateSnapOffsetsForScrollableArea): Ditto.
     33        * rendering/style/RenderStyle.cpp:
     34        (WebCore::RenderStyle::scrollSnapPointsX): Update to use pointer-based representation of ScrollSnapPoints.
     35        (WebCore::RenderStyle::scrollSnapPointsY): Ditto.
     36        (WebCore::RenderStyle::setScrollSnapPointsX): Ditto.
     37        (WebCore::RenderStyle::setScrollSnapPointsY): Ditto.
     38        (WebCore::RenderStyle::initialScrollSnapPointsX): Deleted.
     39        (WebCore::RenderStyle::initialScrollSnapPointsY): Deleted.
     40        * rendering/style/RenderStyle.h:
     41        * rendering/style/StyleScrollSnapPoints.cpp:
     42        (WebCore::StyleScrollSnapPoints::StyleScrollSnapPoints): Revise constructor to handle pointer argument.
     43        * rendering/style/StyleScrollSnapPoints.h:
     44
    1452015-03-05  Roger Fong  <roger_fong@apple.com>
    246
  • trunk/Source/WebCore/css/CSSComputedStyleDeclaration.cpp

    r180689 r181189  
    11071107
    11081108#if ENABLE(CSS_SCROLL_SNAP)
    1109 
    11101109static Ref<CSSValueList> scrollSnapDestination(RenderStyle& style, const LengthSize& destination)
    11111110{
     
    11161115}
    11171116
    1118 static Ref<CSSValue> scrollSnapPoints(RenderStyle& style, const ScrollSnapPoints& points)
    1119 {
    1120     if (points.usesElements)
     1117static Ref<CSSValue> scrollSnapPoints(RenderStyle& style, const ScrollSnapPoints* points)
     1118{
     1119    if (!points)
     1120        return cssValuePool().createIdentifierValue(CSSValueNone);
     1121
     1122    if (points->usesElements)
    11211123        return cssValuePool().createIdentifierValue(CSSValueElements);
    11221124    auto list = CSSValueList::createSpaceSeparated();
    1123     for (auto& point : points.offsets)
     1125    for (auto& point : points->offsets)
    11241126        list.get().append(percentageOrZoomAdjustedValue(point, &style));
    1125     if (points.hasRepeat)
    1126         list.get().append(cssValuePool().createValue(LengthRepeat::create(percentageOrZoomAdjustedValue(points.repeatOffset, &style))));
     1127    if (points->hasRepeat)
     1128        list.get().append(cssValuePool().createValue(LengthRepeat::create(percentageOrZoomAdjustedValue(points->repeatOffset, &style))));
    11271129    return WTF::move(list);
    11281130}
     
    11441146    return WTF::move(list);
    11451147}
    1146 
    11471148#endif
    11481149
  • trunk/Source/WebCore/css/CSSPropertyNames.in

    r180689 r181189  
    561561-webkit-rtl-ordering [Inherited, Setter=setRTLOrdering, Initial=initialRTLOrdering]
    562562#if defined(ENABLE_CSS_SCROLL_SNAP)
    563 -webkit-scroll-snap-points-x [Converter=ScrollSnapPoints]
    564 -webkit-scroll-snap-points-y [Converter=ScrollSnapPoints]
     563-webkit-scroll-snap-points-x [Converter=ScrollSnapPoints, Custom=Initial|Inherit]
     564-webkit-scroll-snap-points-y [Converter=ScrollSnapPoints, Custom=Initial|Inherit]
    565565-webkit-scroll-snap-type
    566566-webkit-scroll-snap-destination [Converter=SnapCoordinatePair]
  • trunk/Source/WebCore/css/StyleBuilderConverter.h

    r180140 r181189  
    9191    static PassRefPtr<ShapeValue> convertShapeValue(StyleResolver&, CSSValue&);
    9292#if ENABLE(CSS_SCROLL_SNAP)
    93     static ScrollSnapPoints convertScrollSnapPoints(StyleResolver&, CSSValue&);
     93    static std::unique_ptr<ScrollSnapPoints> convertScrollSnapPoints(StyleResolver&, CSSValue&);
    9494    static LengthSize convertSnapCoordinatePair(StyleResolver&, CSSValue&, size_t offset = 0);
    9595    static Vector<LengthSize> convertScrollSnapCoordinates(StyleResolver&, CSSValue&);
     
    709709}
    710710
    711 inline ScrollSnapPoints StyleBuilderConverter::convertScrollSnapPoints(StyleResolver& styleResolver, CSSValue& value)
    712 {
    713     ScrollSnapPoints points;
     711inline std::unique_ptr<ScrollSnapPoints> StyleBuilderConverter::convertScrollSnapPoints(StyleResolver& styleResolver, CSSValue& value)
     712{
     713    auto points = std::make_unique<ScrollSnapPoints>();
    714714
    715715    if (is<CSSPrimitiveValue>(value)) {
    716716        ASSERT(downcast<CSSPrimitiveValue>(value).getValueID() == CSSValueElements);
    717         points.usesElements = true;
     717        points->usesElements = true;
    718718        return points;
    719719    }
    720720
    721     points.hasRepeat = false;
     721    points->hasRepeat = false;
    722722    for (auto& currentValue : downcast<CSSValueList>(value)) {
    723723        auto& itemValue = downcast<CSSPrimitiveValue>(currentValue.get());
    724724        if (auto* lengthRepeat = itemValue.getLengthRepeatValue()) {
    725725            if (auto* interval = lengthRepeat->interval()) {
    726                 points.repeatOffset = parseSnapCoordinate(styleResolver, *interval);
    727                 points.hasRepeat = true;
     726                points->repeatOffset = parseSnapCoordinate(styleResolver, *interval);
     727                points->hasRepeat = true;
    728728                break;
    729729            }
    730730        }
    731         points.offsets.append(parseSnapCoordinate(styleResolver, itemValue));
     731        points->offsets.append(parseSnapCoordinate(styleResolver, itemValue));
    732732    }
    733733
  • trunk/Source/WebCore/css/StyleBuilderCustom.h

    r179100 r181189  
    129129    static void applyValueWebkitWritingMode(StyleResolver&, CSSValue&);
    130130    static void applyValueAlt(StyleResolver&, CSSValue&);
     131#if ENABLE(CSS_SCROLL_SNAP)
     132    static void applyInitialWebkitScrollSnapPointsX(StyleResolver&);
     133    static void applyInheritWebkitScrollSnapPointsX(StyleResolver&);
     134    static void applyInitialWebkitScrollSnapPointsY(StyleResolver&);
     135    static void applyInheritWebkitScrollSnapPointsY(StyleResolver&);
     136#endif
    131137
    132138private:
     
    16941700}
    16951701
     1702#if ENABLE(CSS_SCROLL_SNAP)
     1703inline void StyleBuilderCustom::applyInitialWebkitScrollSnapPointsX(StyleResolver& styleResolver)
     1704{
     1705    styleResolver.style()->setScrollSnapPointsX(nullptr);
     1706}
     1707
     1708inline void StyleBuilderCustom::applyInheritWebkitScrollSnapPointsX(StyleResolver& styleResolver)
     1709{
     1710    styleResolver.style()->setScrollSnapPointsX(styleResolver.parentStyle()->scrollSnapPointsX() ? std::make_unique<ScrollSnapPoints>(*styleResolver.parentStyle()->scrollSnapPointsX()) : nullptr);
     1711}
     1712
     1713inline void StyleBuilderCustom::applyInitialWebkitScrollSnapPointsY(StyleResolver& styleResolver)
     1714{
     1715    styleResolver.style()->setScrollSnapPointsY(nullptr);
     1716}
     1717
     1718inline void StyleBuilderCustom::applyInheritWebkitScrollSnapPointsY(StyleResolver& styleResolver)
     1719{
     1720    styleResolver.style()->setScrollSnapPointsY(styleResolver.parentStyle()->scrollSnapPointsY() ? std::make_unique<ScrollSnapPoints>(*styleResolver.parentStyle()->scrollSnapPointsY()) : nullptr);
     1721}
     1722#endif
     1723
    16961724} // namespace WebCore
    16971725
  • trunk/Source/WebCore/page/scrolling/AxisScrollSnapOffsets.cpp

    r175947 r181189  
    11/*
    2  * Copyright (C) 2014 Apple Inc. All rights reserved.
     2 * Copyright (C) 2014-2015 Apple Inc. All rights reserved.
    33 *
    44 * Redistribution and use in source and binary forms, with or without
     
    7676
    7777    bool isHorizontalAxis = axis == ScrollEventAxis::Horizontal;
    78     auto& points = isHorizontalAxis ? style.scrollSnapPointsX() : style.scrollSnapPointsY();
     78    auto* points = isHorizontalAxis ? style.scrollSnapPointsX() : style.scrollSnapPointsY();
    7979    auto& destination = style.scrollSnapDestination();
    80     bool hasRepeat = points.hasRepeat;
    81     LayoutUnit repeatOffset = valueForLength(points.repeatOffset, viewSize);
     80    bool hasRepeat = points ? points->hasRepeat : false;
     81    LayoutUnit repeatOffset = points ? valueForLength(points->repeatOffset, viewSize) : LayoutUnit();
    8282    LayoutUnit destinationOffset = valueForLength(isHorizontalAxis ? destination.width() : destination.height(), viewSize);
    8383    LayoutUnit curSnapPositionShift = 0;
     
    131131    Vector<LayoutUnit> verticalSnapOffsetSubsequence;
    132132
    133     if (scrollingElementStyle.scrollSnapPointsX().usesElements || scrollingElementStyle.scrollSnapPointsY().usesElements) {
    134         bool shouldAddHorizontalChildOffsets = scrollingElementStyle.scrollSnapPointsX().usesElements && canComputeHorizontalOffsets;
    135         bool shouldAddVerticalChildOffsets = scrollingElementStyle.scrollSnapPointsY().usesElements && canComputeVerticalOffsets;
     133    bool scrollSnapPointsXUsesElements = scrollingElementStyle.scrollSnapPointsX() ? scrollingElementStyle.scrollSnapPointsX()->usesElements : false;
     134    bool scrollSnapPointsYUsesElements = scrollingElementStyle.scrollSnapPointsY() ? scrollingElementStyle.scrollSnapPointsY()->usesElements : false;
     135
     136    if (scrollSnapPointsXUsesElements || scrollSnapPointsYUsesElements) {
     137        bool shouldAddHorizontalChildOffsets = scrollSnapPointsXUsesElements && canComputeHorizontalOffsets;
     138        bool shouldAddVerticalChildOffsets = scrollSnapPointsYUsesElements && canComputeVerticalOffsets;
    136139        appendChildSnapOffsets(scrollingElement, shouldAddHorizontalChildOffsets, horizontalSnapOffsetSubsequence, shouldAddVerticalChildOffsets, verticalSnapOffsetSubsequence);
    137140    }
    138141
    139     if (!scrollingElementStyle.scrollSnapPointsX().usesElements && canComputeHorizontalOffsets) {
    140         for (auto& snapLength : scrollingElementStyle.scrollSnapPointsX().offsets)
     142    if (scrollingElementStyle.scrollSnapPointsX() && !scrollSnapPointsXUsesElements && canComputeHorizontalOffsets) {
     143        for (auto& snapLength : scrollingElementStyle.scrollSnapPointsX()->offsets)
    141144            horizontalSnapOffsetSubsequence.append(valueForLength(snapLength, viewWidth));
    142145    }
    143146
    144     if (!scrollingElementStyle.scrollSnapPointsY().usesElements && canComputeVerticalOffsets) {
    145         for (auto& snapLength : scrollingElementStyle.scrollSnapPointsY().offsets)
     147    if (scrollingElementStyle.scrollSnapPointsY() && !scrollSnapPointsYUsesElements && canComputeVerticalOffsets) {
     148        for (auto& snapLength : scrollingElementStyle.scrollSnapPointsY()->offsets)
    146149            verticalSnapOffsetSubsequence.append(valueForLength(snapLength, viewHeight));
    147150    }
  • trunk/Source/WebCore/rendering/style/RenderStyle.cpp

    r181164 r181189  
    11/*
    22 * Copyright (C) 1999 Antti Koivisto (koivisto@kde.org)
    3  * Copyright (C) 2004-2014 Apple Inc. All rights reserved.
     3 * Copyright (C) 2004-2015 Apple Inc. All rights reserved.
    44 * Copyright (C) 2011 Adobe Systems Incorporated. All rights reserved.
    55 *
     
    18661866
    18671867#if ENABLE(CSS_SCROLL_SNAP)
    1868 
    1869 ScrollSnapPoints RenderStyle::initialScrollSnapPointsX()
    1870 {
    1871     return ScrollSnapPoints();
    1872 }
    1873 
    1874 ScrollSnapPoints RenderStyle::initialScrollSnapPointsY()
    1875 {
    1876     return ScrollSnapPoints();
    1877 }
    1878 
    18791868LengthSize RenderStyle::initialScrollSnapDestination()
    18801869{
     
    18871876}
    18881877
    1889 const ScrollSnapPoints& RenderStyle::scrollSnapPointsX() const
    1890 {
    1891     return rareNonInheritedData->m_scrollSnapPoints->xPoints;
    1892 }
    1893 
    1894 const ScrollSnapPoints& RenderStyle::scrollSnapPointsY() const
    1895 {
    1896     return rareNonInheritedData->m_scrollSnapPoints->yPoints;
     1878const ScrollSnapPoints* RenderStyle::scrollSnapPointsX() const
     1879{
     1880    return rareNonInheritedData->m_scrollSnapPoints->xPoints.get();
     1881}
     1882
     1883const ScrollSnapPoints* RenderStyle::scrollSnapPointsY() const
     1884{
     1885    return rareNonInheritedData->m_scrollSnapPoints->yPoints.get();
    18971886}
    18981887
     
    19071896}
    19081897
    1909 void RenderStyle::setScrollSnapPointsX(ScrollSnapPoints points)
    1910 {
    1911     if (rareNonInheritedData->m_scrollSnapPoints->xPoints == points)
     1898void RenderStyle::setScrollSnapPointsX(std::unique_ptr<ScrollSnapPoints> points)
     1899{
     1900    if (rareNonInheritedData->m_scrollSnapPoints->xPoints.get() == points.get())
    19121901        return;
    19131902    rareNonInheritedData.access()->m_scrollSnapPoints.access()->xPoints = WTF::move(points);
    19141903}
    19151904
    1916 void RenderStyle::setScrollSnapPointsY(ScrollSnapPoints points)
    1917 {
    1918     if (rareNonInheritedData->m_scrollSnapPoints->yPoints == points)
     1905void RenderStyle::setScrollSnapPointsY(std::unique_ptr<ScrollSnapPoints> points)
     1906{
     1907    if (rareNonInheritedData->m_scrollSnapPoints->yPoints.get() == points.get())
    19191908        return;
    19201909    rareNonInheritedData.access()->m_scrollSnapPoints.access()->yPoints = WTF::move(points);
  • trunk/Source/WebCore/rendering/style/RenderStyle.h

    r180689 r181189  
    10811081#if ENABLE(CSS_SCROLL_SNAP)
    10821082    ScrollSnapType scrollSnapType() const { return static_cast<ScrollSnapType>(rareNonInheritedData->m_scrollSnapType); }
    1083     const ScrollSnapPoints& scrollSnapPointsX() const;
    1084     const ScrollSnapPoints& scrollSnapPointsY() const;
     1083    const ScrollSnapPoints* scrollSnapPointsX() const;
     1084    const ScrollSnapPoints* scrollSnapPointsY() const;
    10851085    const LengthSize& scrollSnapDestination() const;
    10861086    const Vector<LengthSize>& scrollSnapCoordinates() const;
     
    16261626#if ENABLE(CSS_SCROLL_SNAP)
    16271627    void setScrollSnapType(ScrollSnapType type) { SET_VAR(rareNonInheritedData, m_scrollSnapType, static_cast<unsigned>(type)); }
    1628     void setScrollSnapPointsX(ScrollSnapPoints);
    1629     void setScrollSnapPointsY(ScrollSnapPoints);
     1628    void setScrollSnapPointsX(std::unique_ptr<ScrollSnapPoints>);
     1629    void setScrollSnapPointsY(std::unique_ptr<ScrollSnapPoints>);
    16301630    void setScrollSnapDestination(LengthSize);
    16311631    void setScrollSnapCoordinates(Vector<LengthSize>);
     
    19601960    static ImageResolutionSnap initialImageResolutionSnap() { return ImageResolutionNoSnap; }
    19611961    static float initialImageResolution() { return 1; }
    1962     static StyleImage* initialBorderImageSource() { return 0; }
    1963     static StyleImage* initialMaskBoxImageSource() { return 0; }
     1962    static StyleImage* initialBorderImageSource() { return nullptr; }
     1963    static StyleImage* initialMaskBoxImageSource() { return nullptr; }
    19641964    static PrintColorAdjust initialPrintColorAdjust() { return PrintColorAdjustEconomy; }
    19651965    static QuotesData* initialQuotes() { return nullptr; }
     
    19681968#if ENABLE(CSS_SCROLL_SNAP)
    19691969    static ScrollSnapType initialScrollSnapType() { return ScrollSnapType::None; }
    1970     static ScrollSnapPoints initialScrollSnapPointsX();
    1971     static ScrollSnapPoints initialScrollSnapPointsY();
     1970    static ScrollSnapPoints* initialScrollSnapPointsX() { return nullptr; }
     1971    static ScrollSnapPoints* initialScrollSnapPointsY() { return nullptr; }
    19721972    static LengthSize initialScrollSnapDestination();
    19731973    static Vector<LengthSize> initialScrollSnapCoordinates();
  • trunk/Source/WebCore/rendering/style/StyleScrollSnapPoints.cpp

    r177259 r181189  
    5858inline StyleScrollSnapPoints::StyleScrollSnapPoints(const StyleScrollSnapPoints& other)
    5959    : RefCounted()
    60     , xPoints(other.xPoints)
    61     , yPoints(other.yPoints)
     60    , xPoints(other.xPoints ? std::make_unique<ScrollSnapPoints>(*other.xPoints) : nullptr)
     61    , yPoints(other.yPoints ? std::make_unique<ScrollSnapPoints>(*other.yPoints) : nullptr)
    6262    , destination(other.destination)
    6363    , coordinates(other.coordinates)
  • trunk/Source/WebCore/rendering/style/StyleScrollSnapPoints.h

    r177259 r181189  
    5454    Ref<StyleScrollSnapPoints> copy() const;
    5555
    56     ScrollSnapPoints xPoints;
    57     ScrollSnapPoints yPoints;
     56    std::unique_ptr<ScrollSnapPoints> xPoints;
     57    std::unique_ptr<ScrollSnapPoints> yPoints;
    5858    LengthSize destination;
    5959    Vector<LengthSize> coordinates;
Note: See TracChangeset for help on using the changeset viewer.