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

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

Issue 2368013002: [WIP] CSS Motion Path: offset shorthand ready for position and anchor
Patch Set: code review feedback Created 4 years, 3 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 | « third_party/WebKit/Source/core/css/parser/CSSPropertyParser.h ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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 6ec988e3340bcecb4ff4d129cd760f1312259d5b..2e9ccec8b4cba2c3a6b4c3ff85ab82d8e6383127 100644
--- a/third_party/WebKit/Source/core/css/parser/CSSPropertyParser.cpp
+++ b/third_party/WebKit/Source/core/css/parser/CSSPropertyParser.cpp
@@ -1562,6 +1562,56 @@ CSSValue* consumeOffsetPosition(CSSParserTokenRange& range, CSSParserMode cssPar
return consumePosition(range, cssParserMode, UnitlessQuirk::Forbid);
}
+bool CSSPropertyParser::consumeOffsetShorthand(bool important)
+{
+ const CSSValue* offsetPosition = consumeOffsetPosition(m_range, m_context.mode());
+ const CSSValue* offsetPath = consumePathOrNone(m_range);
+
+ // If offsetPath is omitted, offsetPosition must be present, and must not be 'auto'
+ if (!offsetPath && (!offsetPosition || !offsetPosition->isValuePair()))
+ return false;
+
+ const CSSValue* offsetRotation = consumeOffsetRotation(m_range);
+ const CSSValue* offsetDistance = nullptr;
+ if (offsetPath) {
+ offsetDistance = consumeLengthOrPercent(m_range, m_context.mode(), ValueRangeAll);
+ if (offsetDistance && !offsetRotation)
+ offsetRotation = consumeOffsetRotation(m_range);
+ }
+ const CSSValue* offsetAnchor = nullptr;
+ if (consumeSlashIncludingWhitespace(m_range)) {
+ offsetAnchor = consumeOffsetPosition(m_range, m_context.mode());
+ if (!offsetAnchor)
+ return false;
+ }
+
+ if (RuntimeEnabledFeatures::cssOffsetPositionAnchorEnabled()) {
+ addProperty(CSSPropertyOffsetPosition, CSSPropertyOffset, offsetPosition ? *offsetPosition : *CSSPrimitiveValue::createIdentifier(CSSValueAuto), important);
+
+ if (!offsetAnchor) {
+ CSSPrimitiveValue* fiftyPercent = CSSPrimitiveValue::create(50, CSSPrimitiveValue::UnitType::Percentage);
+ offsetAnchor = CSSValuePair::create(fiftyPercent, fiftyPercent, CSSValuePair::KeepIdenticalValues);
+ }
+ addProperty(CSSPropertyOffsetAnchor, CSSPropertyOffset, *offsetAnchor, important);
+ } else if (offsetPosition || offsetAnchor) {
+ // We could report a console warning "offset-position and offset-anchor are not yet supported."
+ return false;
+ }
+
+ addProperty(CSSPropertyOffsetPath, CSSPropertyOffset, offsetPath ? *offsetPath : *CSSPrimitiveValue::createIdentifier(CSSValueNone), important);
+
+ addProperty(CSSPropertyOffsetDistance, CSSPropertyOffset, offsetDistance ? *offsetDistance : *CSSPrimitiveValue::create(0, CSSPrimitiveValue::UnitType::Pixels), important);
+
+ if (!offsetRotation) {
+ CSSValueList* list = CSSValueList::createSpaceSeparated();
+ list->append(*CSSPrimitiveValue::createIdentifier(CSSValueAuto));
+ offsetRotation = list;
+ }
+ addProperty(CSSPropertyOffsetRotation, CSSPropertyOffset, *offsetRotation, important);
+
+ return m_range.atEnd();
+}
+
static CSSValue* consumeTextEmphasisStyle(CSSParserTokenRange& range)
{
CSSValueID id = range.peek().id();
@@ -4664,7 +4714,7 @@ bool CSSPropertyParser::parseShorthand(CSSPropertyID unresolvedProperty, bool im
case CSSPropertyMotion:
return consumeShorthandGreedily(motionShorthand(), important);
case CSSPropertyOffset:
- return consumeShorthandGreedily(offsetShorthand(), important);
+ return consumeOffsetShorthand(important);
case CSSPropertyWebkitTextEmphasis:
return consumeShorthandGreedily(webkitTextEmphasisShorthand(), important);
case CSSPropertyOutline:
« no previous file with comments | « third_party/WebKit/Source/core/css/parser/CSSPropertyParser.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698