Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(568)

Unified Diff: Source/core/css/ComputedStyleCSSValueMapping.cpp

Issue 1148873005: Parsing CSS properties for scroll snap points (Closed) Base URL: https://chromium.googlesource.com/chromium/blink.git@master
Patch Set: Fix comment Created 5 years, 6 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « Source/core/css/CSSValueKeywords.in ('k') | Source/core/css/parser/CSSParserFastPaths.cpp » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: Source/core/css/ComputedStyleCSSValueMapping.cpp
diff --git a/Source/core/css/ComputedStyleCSSValueMapping.cpp b/Source/core/css/ComputedStyleCSSValueMapping.cpp
index 9d367e4f9669d4cc44a65587c578b6fa4ca13eb2..b03751723a3b8ce84cddd0aa5752ab5c3b63f58b 100644
--- a/Source/core/css/ComputedStyleCSSValueMapping.cpp
+++ b/Source/core/css/ComputedStyleCSSValueMapping.cpp
@@ -1325,6 +1325,42 @@ PassRefPtrWillBeRawPtr<CSSValue> ComputedStyleCSSValueMapping::valueForFilter(co
return list.release();
}
+static PassRefPtrWillBeRawPtr<CSSValue> valueForScrollSnapDestination(const LengthPoint& destination, const ComputedStyle& style)
+{
+ RefPtrWillBeRawPtr<CSSValueList> list = CSSValueList::createSpaceSeparated();
+ list->append(zoomAdjustedPixelValueForLength(destination.x(), style));
+ list->append(zoomAdjustedPixelValueForLength(destination.y(), style));
+ return list.release();
+}
+
+static PassRefPtrWillBeRawPtr<CSSValue> valueForScrollSnapPoints(const ScrollSnapPoints& points, const ComputedStyle& style)
+{
+ if (points.hasRepeat) {
+ RefPtrWillBeRawPtr<CSSFunctionValue> repeat = CSSFunctionValue::create(CSSValueRepeat);
+ repeat->append(zoomAdjustedPixelValueForLength(points.repeatOffset, style));
+ return repeat.release();
+ }
+
+ return cssValuePool().createIdentifierValue(CSSValueNone);
+}
+
+static PassRefPtrWillBeRawPtr<CSSValue> valueForScrollSnapCoordinate(const Vector<LengthPoint>& coordinates, const ComputedStyle& style)
+{
+ if (coordinates.isEmpty())
+ return cssValuePool().createIdentifierValue(CSSValueNone);
+
+ RefPtrWillBeRawPtr<CSSValueList> list = CSSValueList::createCommaSeparated();
+
+ for (auto& coordinate : coordinates) {
+ auto pair = CSSValueList::createSpaceSeparated();
+ pair->append(zoomAdjustedPixelValueForLength(coordinate.x(), style));
+ pair->append(zoomAdjustedPixelValueForLength(coordinate.y(), style));
+ list->append(pair);
+ }
+
+ return list.release();
+}
+
PassRefPtrWillBeRawPtr<CSSValue> ComputedStyleCSSValueMapping::get(CSSPropertyID propertyID, const ComputedStyle& style, const LayoutObject* layoutObject, Node* styledNode, bool allowVisitedStyle)
{
const SVGComputedStyle& svgStyle = style.svgStyle();
@@ -2584,6 +2620,16 @@ PassRefPtrWillBeRawPtr<CSSValue> ComputedStyleCSSValueMapping::get(CSSPropertyID
return zoomAdjustedPixelValueForLength(svgStyle.rx(), style);
case CSSPropertyRy:
return zoomAdjustedPixelValueForLength(svgStyle.ry(), style);
+ case CSSPropertyScrollSnapType:
+ return cssValuePool().createValue(style.scrollSnapType());
+ case CSSPropertyScrollSnapPointsX:
+ return valueForScrollSnapPoints(style.scrollSnapPointsX(), style);
+ case CSSPropertyScrollSnapPointsY:
+ return valueForScrollSnapPoints(style.scrollSnapPointsY(), style);
+ case CSSPropertyScrollSnapCoordinate:
+ return valueForScrollSnapCoordinate(style.scrollSnapCoordinate(), style);
+ case CSSPropertyScrollSnapDestination:
+ return valueForScrollSnapDestination(style.scrollSnapDestination(), style);
case CSSPropertyAll:
return nullptr;
« no previous file with comments | « Source/core/css/CSSValueKeywords.in ('k') | Source/core/css/parser/CSSParserFastPaths.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698