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 4aef4cf533e6dc8aca53d88dba46458b8d7be27f..300a200a207ece0bb65acbd2be82257227a90081 100644 |
--- a/third_party/WebKit/Source/core/css/parser/CSSPropertyParser.cpp |
+++ b/third_party/WebKit/Source/core/css/parser/CSSPropertyParser.cpp |
@@ -183,6 +183,25 @@ static PassRefPtrWillBeRawPtr<CSSPrimitiveValue> consumeInteger(CSSParserTokenRa |
return nullptr; |
} |
+static PassRefPtrWillBeRawPtr<CSSPrimitiveValue> consumeNumber(CSSParserTokenRange& range, ValueRange valueRange) |
+{ |
+ const CSSParserToken& token = range.peek(); |
+ if (token.type() == NumberToken) { |
+ if (valueRange == ValueRangeNonNegative && token.numericValue() < 0) |
+ return nullptr; |
+ return cssValuePool().createValue(range.consumeIncludingWhitespace().numericValue(), token.unitType()); |
+ } |
+ CalcParser calcParser(range, ValueRangeAll); |
+ if (const CSSCalcValue* calculation = calcParser.value()) { |
+ // TODO(rwlbuis) Calcs should not be subject to parse time range checks. |
+ // spec: https://drafts.csswg.org/css-values-3/#calc-range |
+ if (calculation->category() != CalcNumber || (valueRange == ValueRangeNonNegative && calculation->isNegative())) |
+ return nullptr; |
+ return calcParser.consumeNumber(); |
+ } |
+ return nullptr; |
+} |
+ |
inline bool shouldAcceptUnitlessValues(double fValue, CSSParserMode cssParserMode, UnitlessQuirk unitless) |
{ |
// Quirks mode for certain properties and presentation attributes accept unit-less values for certain units. |
@@ -545,6 +564,17 @@ static PassRefPtrWillBeRawPtr<CSSValue> consumeFontSize(CSSParserTokenRange& ran |
return consumeLengthOrPercent(range, cssParserMode, ValueRangeNonNegative, UnitlessQuirk::Allow); |
} |
+static PassRefPtrWillBeRawPtr<CSSPrimitiveValue> consumeLineHeight(CSSParserTokenRange& range, CSSParserMode cssParserMode) |
+{ |
+ if (range.peek().id() == CSSValueNormal) |
+ return consumeIdent(range); |
+ |
+ RefPtrWillBeRawPtr<CSSPrimitiveValue> lineHeight = consumeNumber(range, ValueRangeNonNegative); |
+ if (lineHeight) |
+ return lineHeight; |
+ return consumeLengthOrPercent(range, cssParserMode, ValueRangeNonNegative); |
+} |
+ |
PassRefPtrWillBeRawPtr<CSSValue> CSSPropertyParser::parseSingleValue(CSSPropertyID propId) |
{ |
m_range.consumeWhitespace(); |
@@ -574,6 +604,8 @@ PassRefPtrWillBeRawPtr<CSSValue> CSSPropertyParser::parseSingleValue(CSSProperty |
return consumeTabSize(m_range, m_context.mode()); |
case CSSPropertyFontSize: |
return consumeFontSize(m_range, m_context.mode()); |
+ case CSSPropertyLineHeight: |
+ return consumeLineHeight(m_range, m_context.mode()); |
default: |
return nullptr; |
} |