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

Unified Diff: third_party/WebKit/Source/core/css/parser/CSSPropertyParser.cpp

Issue 2932593004: Update the snap points css properties (Closed)
Patch Set: rebase Created 3 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
Index: third_party/WebKit/Source/core/css/parser/CSSPropertyParser.cpp
diff --git a/third_party/WebKit/Source/core/css/parser/CSSPropertyParser.cpp b/third_party/WebKit/Source/core/css/parser/CSSPropertyParser.cpp
index eda9dfb196a270dbd326f49a2db7fcae9c3d8984..b9473cf6ad12958f455f557c90f06257922e3b41 100644
--- a/third_party/WebKit/Source/core/css/parser/CSSPropertyParser.cpp
+++ b/third_party/WebKit/Source/core/css/parser/CSSPropertyParser.cpp
@@ -752,24 +752,6 @@ static CSSValue* ConsumePerspective(CSSParserTokenRange& range,
return nullptr;
}
-static CSSValue* ConsumeScrollSnapPoints(CSSParserTokenRange& range,
- CSSParserMode css_parser_mode) {
- if (range.Peek().Id() == CSSValueNone)
- return ConsumeIdent(range);
- if (range.Peek().FunctionId() == CSSValueRepeat) {
- CSSParserTokenRange args = ConsumeFunction(range);
- CSSPrimitiveValue* parsed_value =
- ConsumeLengthOrPercent(args, css_parser_mode, kValueRangeNonNegative);
- if (args.AtEnd() && parsed_value &&
- (parsed_value->IsCalculated() || parsed_value->GetDoubleValue() > 0)) {
- CSSFunctionValue* result = CSSFunctionValue::Create(CSSValueRepeat);
- result->Append(*parsed_value);
- return result;
- }
- }
- return nullptr;
-}
-
static CSSValue* ConsumeReflect(CSSParserTokenRange& range,
const CSSParserContext* context) {
CSSIdentifierValue* direction =
@@ -1479,10 +1461,6 @@ const CSSValue* CSSPropertyParser::ParseSingleValue(
case CSSPropertyWebkitLogicalWidth:
case CSSPropertyWebkitLogicalHeight:
return CSSPropertyLengthUtils::ConsumeWidthOrHeight(range_, *context_);
- case CSSPropertyScrollSnapDestination:
- // TODO(crbug.com/724912): Retire scroll-snap-destination
- return ConsumePosition(range_, *context_, UnitlessQuirk::kForbid,
- Optional<WebFeature>());
case CSSPropertyObjectPosition:
return ConsumePosition(range_, *context_, UnitlessQuirk::kForbid,
WebFeature::kThreeValuedPositionObjectPosition);
@@ -1599,9 +1577,6 @@ const CSSValue* CSSPropertyParser::ParseSingleValue(
return ConsumePerspective(
range_, context_,
unresolved_property == CSSPropertyAliasWebkitPerspective);
- case CSSPropertyScrollSnapPointsX:
- case CSSPropertyScrollSnapPointsY:
- return ConsumeScrollSnapPoints(range_, context_->Mode());
case CSSPropertyBorderImageRepeat:
case CSSPropertyWebkitMaskBoxImageRepeat:
return CSSPropertyBorderImageUtils::ConsumeBorderImageRepeat(range_);
@@ -2288,6 +2263,23 @@ bool CSSPropertyParser::ConsumeBorder(bool important) {
return range_.AtEnd();
}
+bool CSSPropertyParser::Consume2Values(const StylePropertyShorthand& shorthand,
+ bool important) {
+ DCHECK_EQ(shorthand.length(), 2u);
+ const CSSPropertyID* longhands = shorthand.properties();
+ const CSSValue* start = ParseSingleValue(longhands[0], shorthand.id());
+ if (!start)
+ return false;
+
+ const CSSValue* end = ParseSingleValue(longhands[1], shorthand.id());
+ if (!end)
+ end = start;
+ AddParsedProperty(longhands[0], shorthand.id(), *start, important);
+ AddParsedProperty(longhands[1], shorthand.id(), *end, important);
+
+ return range_.AtEnd();
+}
+
bool CSSPropertyParser::Consume4Values(const StylePropertyShorthand& shorthand,
bool important) {
DCHECK_EQ(shorthand.length(), 4u);
@@ -3258,6 +3250,18 @@ bool CSSPropertyParser::ParseShorthand(CSSPropertyID unresolved_property,
return ConsumePlaceItemsShorthand(important);
case CSSPropertyPlaceSelf:
return ConsumePlaceSelfShorthand(important);
+ case CSSPropertyScrollPadding:
+ return Consume4Values(scrollPaddingShorthand(), important);
+ case CSSPropertyScrollPaddingBlock:
+ return Consume2Values(scrollPaddingBlockShorthand(), important);
+ case CSSPropertyScrollPaddingInline:
+ return Consume2Values(scrollPaddingInlineShorthand(), important);
+ case CSSPropertyScrollSnapMargin:
+ return Consume4Values(scrollSnapMarginShorthand(), important);
+ case CSSPropertyScrollSnapMarginBlock:
+ return Consume2Values(scrollSnapMarginBlockShorthand(), important);
+ case CSSPropertyScrollSnapMarginInline:
+ return Consume2Values(scrollSnapMarginInlineShorthand(), important);
default:
return false;
}

Powered by Google App Engine
This is Rietveld 408576698