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

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: offset-anchor default is not auto 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
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 db811aff923b963f1ce21b4345e7134d9deb362e..7b68f2946a358bc98ec7d11c6d5e9cb855e07827 100644
--- a/third_party/WebKit/Source/core/css/parser/CSSPropertyParser.cpp
+++ b/third_party/WebKit/Source/core/css/parser/CSSPropertyParser.cpp
@@ -1316,6 +1316,55 @@ bool CSSPropertyParser::consumeAnimationShorthand(const StylePropertyShorthand&
return m_range.atEnd();
}
+bool CSSPropertyParser::consumeOffsetShorthand(bool important)
+{
+ const CSSValue* offsetPosition = parseSingleValue(CSSPropertyOffsetPosition, CSSPropertyOffset);
Timothy Loh 2016/09/27 08:17:48 For all of these we should prefer just calling the
Eric Willigers 2016/09/29 03:53:19 Done.
Eric Willigers 2016/09/29 03:53:19 Done.
+ const CSSValue* offsetPath = parseSingleValue(CSSPropertyOffsetPath, CSSPropertyOffset);
+
+ if (!offsetPath && (!offsetPosition || !offsetPosition->isValuePair()))
Timothy Loh 2016/09/27 08:17:48 What's the offsetPosition->isValuePair() check for
Timothy Loh 2016/09/27 08:20:47 Actually, shouldn't we always fail if offsetPath i
Eric Willigers 2016/09/29 03:53:19 Checking that we don't have 'auto'. The offset sh
+ return false;
+
+ const CSSValue* offsetRotation = parseSingleValue(CSSPropertyOffsetRotation, CSSPropertyOffset);
+ const CSSValue* offsetDistance = nullptr;
+ if (offsetPath) {
+ offsetDistance = parseSingleValue(CSSPropertyOffsetDistance, CSSPropertyOffset);
+ if (offsetDistance && !offsetRotation)
+ offsetRotation = parseSingleValue(CSSPropertyOffsetRotation, CSSPropertyOffset);
+ }
+ const CSSValue* offsetAnchor = nullptr;
+ if (consumeSlashIncludingWhitespace(m_range)) {
Timothy Loh 2016/09/27 08:17:48 This code incorrectly allows <offset-position> / <
Eric Willigers 2016/09/29 03:53:19 Intended.
+ offsetAnchor = parseSingleValue(CSSPropertyOffsetAnchor, CSSPropertyOffset);
+ 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* consumeZIndex(CSSParserTokenRange& range)
{
if (range.peek().id() == CSSValueAuto)
@@ -4657,7 +4706,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:

Powered by Google App Engine
This is Rietveld 408576698