Move '-webkit-scroll-snap-*' CSS properties to the new StyleBuilder
authorcdumez@apple.com <cdumez@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Tue, 6 Jan 2015 16:49:58 +0000 (16:49 +0000)
committercdumez@apple.com <cdumez@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Tue, 6 Jan 2015 16:49:58 +0000 (16:49 +0000)
https://bugs.webkit.org/show_bug.cgi?id=140112

Reviewed by Darin Adler.

Move '-webkit-scroll-snap-*' CSS properties to the new StyleBuilder.

* css/CSSPropertyNames.in:
* css/StyleBuilderConverter.h:
(WebCore::StyleBuilderConverter::parseSnapCoordinate):
(WebCore::StyleBuilderConverter::convertScrollSnapPoints):
(WebCore::StyleBuilderConverter::convertSnapCoordinatePair):
(WebCore::StyleBuilderConverter::convertScrollSnapCoordinates):
* css/StyleResolver.cpp:
(WebCore::StyleResolver::applyProperty):
(WebCore::StyleResolver::parseSnapCoordinate): Deleted.
(WebCore::StyleResolver::parseSnapCoordinatePair): Deleted.
(WebCore::StyleResolver::parseSnapPoints): Deleted.
* css/StyleResolver.h:

git-svn-id: https://svn.webkit.org/repository/webkit/trunk@177958 268f45cc-cd09-0410-ab3c-d52691b4dbfc

Source/WebCore/ChangeLog
Source/WebCore/css/CSSPropertyNames.in
Source/WebCore/css/StyleBuilderConverter.h
Source/WebCore/css/StyleResolver.cpp
Source/WebCore/css/StyleResolver.h

index 421fc9b..34166d2 100644 (file)
@@ -1,3 +1,25 @@
+2015-01-06  Chris Dumez  <cdumez@apple.com>
+
+        Move '-webkit-scroll-snap-*' CSS properties to the new StyleBuilder
+        https://bugs.webkit.org/show_bug.cgi?id=140112
+
+        Reviewed by Darin Adler.
+
+        Move '-webkit-scroll-snap-*' CSS properties to the new StyleBuilder.
+
+        * css/CSSPropertyNames.in:
+        * css/StyleBuilderConverter.h:
+        (WebCore::StyleBuilderConverter::parseSnapCoordinate):
+        (WebCore::StyleBuilderConverter::convertScrollSnapPoints):
+        (WebCore::StyleBuilderConverter::convertSnapCoordinatePair):
+        (WebCore::StyleBuilderConverter::convertScrollSnapCoordinates):
+        * css/StyleResolver.cpp:
+        (WebCore::StyleResolver::applyProperty):
+        (WebCore::StyleResolver::parseSnapCoordinate): Deleted.
+        (WebCore::StyleResolver::parseSnapCoordinatePair): Deleted.
+        (WebCore::StyleResolver::parseSnapPoints): Deleted.
+        * css/StyleResolver.h:
+
 2015-01-06  Antti Koivisto  <antti@apple.com>
 
         Resolve mirroring and variant in Font instead of FontGlyphs
index 173e966..183f146 100644 (file)
@@ -510,11 +510,11 @@ order [TypeName=int]
 -webkit-print-color-adjust [Inherited, TypeName=PrintColorAdjust]
 -webkit-rtl-ordering [Inherited, TypeName=Order, Setter=setRTLOrdering, Initial=initialRTLOrdering]
 #if defined(ENABLE_CSS_SCROLL_SNAP)
--webkit-scroll-snap-points-x [LegacyStyleBuilder]
--webkit-scroll-snap-points-y [LegacyStyleBuilder]
--webkit-scroll-snap-type [LegacyStyleBuilder]
--webkit-scroll-snap-destination [LegacyStyleBuilder]
--webkit-scroll-snap-coordinate [LegacyStyleBuilder]
+-webkit-scroll-snap-points-x [Converter=ScrollSnapPoints]
+-webkit-scroll-snap-points-y [Converter=ScrollSnapPoints]
+-webkit-scroll-snap-type [TypeName=ScrollSnapType]
+-webkit-scroll-snap-destination [Converter=SnapCoordinatePair]
+-webkit-scroll-snap-coordinate [Converter=ScrollSnapCoordinates, NameForMethods=ScrollSnapCoordinates]
 #endif
 -webkit-text-combine [Inherited, TypeName=TextCombine]
 -epub-text-combine = -webkit-text-combine
index cc93dd7..079a38d 100644 (file)
 #include "CSSReflectValue.h"
 #include "Frame.h"
 #include "Length.h"
+#include "LengthRepeat.h"
 #include "Pair.h"
 #include "QuotesData.h"
 #include "Settings.h"
 #include "StyleResolver.h"
+#include "StyleScrollSnapPoints.h"
 #include "TransformFunctions.h"
 
 namespace WebCore {
@@ -82,6 +84,11 @@ public:
     static LineBoxContain convertLineBoxContain(StyleResolver&, CSSValue&);
     static TextDecorationSkip convertTextDecorationSkip(StyleResolver&, CSSValue&);
     static PassRefPtr<ShapeValue> convertShapeValue(StyleResolver&, CSSValue&);
+#if ENABLE(CSS_SCROLL_SNAP)
+    static ScrollSnapPoints convertScrollSnapPoints(StyleResolver&, CSSValue&);
+    static LengthSize convertSnapCoordinatePair(StyleResolver&, CSSValue&, size_t offset = 0);
+    static Vector<LengthSize> convertScrollSnapCoordinates(StyleResolver&, CSSValue&);
+#endif
 #if ENABLE(CSS_GRID_LAYOUT)
     static bool convertGridTrackSize(StyleResolver&, CSSValue&, GridTrackSize&);
     static bool convertGridPosition(StyleResolver&, CSSValue&, GridPosition&);
@@ -98,6 +105,9 @@ private:
     static Length convertToRadiusLength(CSSToLengthConversionData&, CSSPrimitiveValue&);
     static TextEmphasisPosition valueToEmphasisPosition(CSSPrimitiveValue&);
     static TextDecorationSkip valueToDecorationSkip(const CSSPrimitiveValue&);
+#if ENABLE(CSS_SCROLL_SNAP)
+    static Length parseSnapCoordinate(StyleResolver&, const CSSValue&);
+#endif
 #if ENABLE(CSS_GRID_LAYOUT)
     static bool createGridTrackBreadth(CSSPrimitiveValue&, StyleResolver&, GridLength&);
     static bool createGridTrackSize(CSSValue&, GridTrackSize&, StyleResolver&);
@@ -661,6 +671,57 @@ inline PassRefPtr<ShapeValue> StyleBuilderConverter::convertShapeValue(StyleReso
 }
 #endif // ENABLE(CSS_SHAPES)
 
+#if ENABLE(CSS_SCROLL_SNAP)
+inline Length StyleBuilderConverter::parseSnapCoordinate(StyleResolver& styleResolver, const CSSValue& value)
+{
+    return downcast<CSSPrimitiveValue>(value).convertToLength<FixedIntegerConversion | PercentConversion | AutoConversion>(styleResolver.state().cssToLengthConversionData());
+}
+
+inline ScrollSnapPoints StyleBuilderConverter::convertScrollSnapPoints(StyleResolver& styleResolver, CSSValue& value)
+{
+    ScrollSnapPoints points;
+
+    if (is<CSSPrimitiveValue>(value)) {
+        ASSERT(downcast<CSSPrimitiveValue>(value).getValueID() == CSSValueElements);
+        points.usesElements = true;
+        return points;
+    }
+
+    points.hasRepeat = false;
+    for (auto& currentValue : downcast<CSSValueList>(value)) {
+        auto& itemValue = downcast<CSSPrimitiveValue>(currentValue.get());
+        if (auto* lengthRepeat = itemValue.getLengthRepeatValue()) {
+            if (auto* interval = lengthRepeat->interval()) {
+                points.repeatOffset = parseSnapCoordinate(styleResolver, *interval);
+                points.hasRepeat = true;
+                break;
+            }
+        }
+        points.offsets.append(parseSnapCoordinate(styleResolver, itemValue));
+    }
+
+    return points;
+}
+
+inline LengthSize StyleBuilderConverter::convertSnapCoordinatePair(StyleResolver& styleResolver, CSSValue& value, size_t offset)
+{
+    auto& valueList = downcast<CSSValueList>(value);
+    return LengthSize(parseSnapCoordinate(styleResolver, *valueList.item(offset)), parseSnapCoordinate(styleResolver, *valueList.item(offset + 1)));
+}
+
+inline Vector<LengthSize> StyleBuilderConverter::convertScrollSnapCoordinates(StyleResolver& styleResolver, CSSValue& value)
+{
+    auto& valueList = downcast<CSSValueList>(value);
+    ASSERT(!(valueList.length() % 2));
+    size_t pointCount = valueList.length() / 2;
+    Vector<LengthSize> coordinates;
+    coordinates.reserveInitialCapacity(pointCount);
+    for (size_t i = 0; i < pointCount; ++i)
+        coordinates.uncheckedAppend(convertSnapCoordinatePair(styleResolver, valueList, i * 2));
+    return coordinates;
+}
+#endif
+
 #if ENABLE(CSS_GRID_LAYOUT)
 bool StyleBuilderConverter::createGridTrackBreadth(CSSPrimitiveValue& primitiveValue, StyleResolver& styleResolver, GridLength& workingLength)
 {
index c6f8977..f4e3bea 100644 (file)
@@ -1947,52 +1947,6 @@ bool StyleResolver::useSVGZoomRulesForLength()
     return is<SVGElement>(m_state.element()) && !(is<SVGSVGElement>(*m_state.element()) && m_state.element()->parentNode());
 }
 
-#if ENABLE(CSS_SCROLL_SNAP)
-
-Length StyleResolver::parseSnapCoordinate(CSSPrimitiveValue& value)
-{
-    return value.convertToLength<FixedIntegerConversion | PercentConversion | AutoConversion>(m_state.cssToLengthConversionData());
-}
-
-Length StyleResolver::parseSnapCoordinate(CSSValueList& valueList, unsigned offset)
-{
-    return parseSnapCoordinate(downcast<CSSPrimitiveValue>(*valueList.item(offset)));
-}
-
-LengthSize StyleResolver::parseSnapCoordinatePair(CSSValueList& valueList, unsigned offset)
-{
-    return LengthSize(parseSnapCoordinate(valueList, offset), parseSnapCoordinate(valueList, offset + 1));
-}
-
-ScrollSnapPoints StyleResolver::parseSnapPoints(CSSValue& value)
-{
-    ScrollSnapPoints points;
-
-    if (is<CSSPrimitiveValue>(value) && downcast<CSSPrimitiveValue>(value).getValueID() == CSSValueElements) {
-        points.usesElements = true;
-        return points;
-    }
-
-    points.hasRepeat = false;
-    if (is<CSSValueList>(value)) {
-        for (auto& currentValue : downcast<CSSValueList>(value)) {
-            auto& itemValue = downcast<CSSPrimitiveValue>(currentValue.get());
-            if (auto* lengthRepeat = itemValue.getLengthRepeatValue()) {
-                if (auto* interval = lengthRepeat->interval()) {
-                    points.repeatOffset = parseSnapCoordinate(*interval);
-                    points.hasRepeat = true;
-                    break;
-                }
-            }
-            points.offsets.append(parseSnapCoordinate(itemValue));
-        }
-    }
-
-    return points;
-}
-
-#endif
-
 void StyleResolver::applyProperty(CSSPropertyID id, CSSValue* value)
 {
     ASSERT_WITH_MESSAGE(!isExpandedShorthand(id), "Shorthand property id = %d wasn't expanded at parsing time", id);
@@ -2412,38 +2366,6 @@ void StyleResolver::applyProperty(CSSPropertyID id, CSSValue* value)
 
         return;
     }
-
-#if ENABLE(CSS_SCROLL_SNAP)
-    case CSSPropertyWebkitScrollSnapType:
-        HANDLE_INHERIT_AND_INITIAL(scrollSnapType, ScrollSnapType);
-        state.style()->setScrollSnapType(*primitiveValue);
-        return;
-    case CSSPropertyWebkitScrollSnapPointsX:
-        HANDLE_INHERIT_AND_INITIAL(scrollSnapPointsX, ScrollSnapPointsX);
-        state.style()->setScrollSnapPointsX(parseSnapPoints(*value));
-        return;
-    case CSSPropertyWebkitScrollSnapPointsY:
-        HANDLE_INHERIT_AND_INITIAL(scrollSnapPointsY, ScrollSnapPointsY);
-        state.style()->setScrollSnapPointsY(parseSnapPoints(*value));
-        break;
-    case CSSPropertyWebkitScrollSnapDestination: {
-        HANDLE_INHERIT_AND_INITIAL(scrollSnapDestination, ScrollSnapDestination)
-        state.style()->setScrollSnapDestination(parseSnapCoordinatePair(downcast<CSSValueList>(*value), 0));
-        return;
-    }
-    case CSSPropertyWebkitScrollSnapCoordinate: {
-        HANDLE_INHERIT_AND_INITIAL(scrollSnapCoordinates, ScrollSnapCoordinates)
-        CSSValueList& valueList = downcast<CSSValueList>(*value);
-        ASSERT(!(valueList.length() % 2));
-        size_t pointCount = valueList.length() / 2;
-        Vector<LengthSize> coordinates;
-        coordinates.reserveInitialCapacity(pointCount);
-        for (size_t i = 0; i < pointCount; i++)
-            coordinates.append(parseSnapCoordinatePair(valueList, i * 2));
-        state.style()->setScrollSnapCoordinates(WTF::move(coordinates));
-        return;
-    }
-#endif
     
     // These properties are aliased and StyleBuilder already applied the property on the prefixed version.
     case CSSPropertyAnimationDelay:
@@ -2688,6 +2610,13 @@ void StyleResolver::applyProperty(CSSPropertyID id, CSSValue* value)
     case CSSPropertyWebkitTextAlignLast:
     case CSSPropertyWebkitTextJustify:
 #endif // CSS3_TEXT
+#if ENABLE(CSS_SCROLL_SNAP)
+    case CSSPropertyWebkitScrollSnapType:
+    case CSSPropertyWebkitScrollSnapPointsX:
+    case CSSPropertyWebkitScrollSnapPointsY:
+    case CSSPropertyWebkitScrollSnapDestination:
+    case CSSPropertyWebkitScrollSnapCoordinate:
+#endif
     case CSSPropertyWebkitTextDecorationLine:
     case CSSPropertyWebkitTextDecorationStyle:
     case CSSPropertyWebkitTextDecorationColor:
index 02ae516..5276a8e 100644 (file)
@@ -505,11 +505,6 @@ private:
     bool classNamesAffectedByRules(const SpaceSplitString&) const;
     bool sharingCandidateHasIdenticalStyleAffectingAttributes(StyledElement*) const;
 
-    Length parseSnapCoordinate(CSSPrimitiveValue&);
-    Length parseSnapCoordinate(CSSValueList&, unsigned offset);
-    LengthSize parseSnapCoordinatePair(CSSValueList&, unsigned offset);
-    ScrollSnapPoints parseSnapPoints(CSSValue&);
-
     unsigned m_matchedPropertiesCacheAdditionsSinceLastSweep;
 
     typedef HashMap<unsigned, MatchedPropertiesCacheItem> MatchedPropertiesCache;