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: |