Chromium Code Reviews| 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: |