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 cb27b6b55f89c8eb1707cfce2d21562dcd142272..271c7991b2ed980e9f6507c21b657f4d259e4d0b 100644 |
--- a/third_party/WebKit/Source/core/css/parser/CSSPropertyParser.cpp |
+++ b/third_party/WebKit/Source/core/css/parser/CSSPropertyParser.cpp |
@@ -616,7 +616,8 @@ static CSSValue* consumeFontVariantList(CSSParserTokenRange& range) { |
static CSSIdentifierValue* consumeFontWeight(CSSParserTokenRange& range) { |
const CSSParserToken& token = range.peek(); |
- if (token.id() >= CSSValueNormal && token.id() <= CSSValueLighter) |
+ if (token.id() == CSSValueNormal || token.id() == CSSValueBold || |
+ token.id() == CSSValueBolder || token.id() == CSSValueLighter) |
return consumeIdent(range); |
if (token.type() != NumberToken || |
token.numericValueType() != IntegerValueType) |
@@ -625,8 +626,29 @@ static CSSIdentifierValue* consumeFontWeight(CSSParserTokenRange& range) { |
if ((weight % 100) || weight < 100 || weight > 900) |
return nullptr; |
range.consumeIncludingWhitespace(); |
- return CSSIdentifierValue::create( |
- static_cast<CSSValueID>(CSSValue100 + weight / 100 - 1)); |
+ switch (weight) { |
+ case 100: |
+ return CSSIdentifierValue::create(CSSValue100); |
+ case 200: |
+ return CSSIdentifierValue::create(CSSValue200); |
+ case 300: |
+ return CSSIdentifierValue::create(CSSValue300); |
+ case 400: |
+ return CSSIdentifierValue::create(CSSValue400); |
+ case 500: |
+ return CSSIdentifierValue::create(CSSValue500); |
+ case 600: |
+ return CSSIdentifierValue::create(CSSValue600); |
+ case 700: |
+ return CSSIdentifierValue::create(CSSValue700); |
+ case 800: |
+ return CSSIdentifierValue::create(CSSValue800); |
+ case 900: |
+ return CSSIdentifierValue::create(CSSValue900); |
+ default: |
+ NOTREACHED(); |
+ return nullptr; |
+ } |
} |
static String concatenateFamilyName(CSSParserTokenRange& range) { |
@@ -709,11 +731,22 @@ static CSSValue* consumeFontSize( |
CSSParserTokenRange& range, |
CSSParserMode cssParserMode, |
UnitlessQuirk unitless = UnitlessQuirk::Forbid) { |
- if (range.peek().id() >= CSSValueXxSmall && |
- range.peek().id() <= CSSValueLarger) |
- return consumeIdent(range); |
- return consumeLengthOrPercent(range, cssParserMode, ValueRangeNonNegative, |
- unitless); |
+ switch (range.peek().id()) { |
+ case CSSValueXxSmall: |
+ case CSSValueXSmall: |
+ case CSSValueSmall: |
+ case CSSValueMedium: |
+ case CSSValueLarge: |
+ case CSSValueXLarge: |
+ case CSSValueXxLarge: |
+ case CSSValueWebkitXxxLarge: |
+ case CSSValueSmaller: |
+ case CSSValueLarger: |
+ return consumeIdent(range); |
+ default: |
+ return consumeLengthOrPercent(range, cssParserMode, ValueRangeNonNegative, |
+ unitless); |
+ } |
} |
static CSSValue* consumeLineHeight(CSSParserTokenRange& range, |
@@ -1436,7 +1469,11 @@ static CSSFunctionValue* consumeFilterFunction( |
CSSParserTokenRange& range, |
const CSSParserContext& context) { |
CSSValueID filterType = range.peek().functionId(); |
- if (filterType < CSSValueInvert || filterType > CSSValueDropShadow) |
+ if (filterType != CSSValueInvert && filterType != CSSValueGrayscale && |
+ filterType != CSSValueSepia && filterType != CSSValueSaturate && |
+ filterType != CSSValueHueRotate && filterType != CSSValueOpacity && |
+ filterType != CSSValueBrightness && filterType != CSSValueContrast && |
+ filterType != CSSValueBlur && filterType != CSSValueDropShadow) |
return nullptr; |
CSSParserTokenRange args = consumeFunction(range); |
CSSFunctionValue* filterValue = CSSFunctionValue::create(filterType); |
@@ -2096,7 +2133,43 @@ static CSSValue* consumeCursor(CSSParserTokenRange& range, |
return nullptr; |
cursorType = CSSIdentifierValue::create(CSSValuePointer); |
range.consumeIncludingWhitespace(); |
- } else if ((id >= CSSValueAuto && id <= CSSValueWebkitZoomOut) || |
+ } else if ( |
+ id == CSSValueAuto || |
+ id == CSSValueCrosshair || |
+ id == CSSValueDefault || |
+ id == CSSValuePointer || |
+ id == CSSValueMove || |
+ id == CSSValueVerticalText || |
+ id == CSSValueCell || |
+ id == CSSValueContextMenu || |
+ id == CSSValueAlias || |
+ id == CSSValueProgress || |
+ id == CSSValueNoDrop || |
+ id == CSSValueNotAllowed || |
+ id == CSSValueZoomIn || |
+ id == CSSValueZoomOut || |
+ id == CSSValueEResize || |
+ id == CSSValueNeResize || |
+ id == CSSValueNwResize || |
+ id == CSSValueNResize || |
+ id == CSSValueSeResize || |
+ id == CSSValueSwResize || |
+ id == CSSValueSResize || |
+ id == CSSValueWResize || |
+ id == CSSValueEwResize || |
+ id == CSSValueNsResize || |
+ id == CSSValueNeswResize || |
+ id == CSSValueNwseResize || |
+ id == CSSValueColResize || |
+ id == CSSValueRowResize || |
+ id == CSSValueText || |
+ id == CSSValueWait || |
+ id == CSSValueHelp || |
+ id == CSSValueAllScroll || |
+ id == CSSValueWebkitGrab || |
+ id == CSSValueWebkitGrabbing || |
+ id == CSSValueWebkitZoomIn || |
+ id == CSSValueWebkitZoomOut || |
id == CSSValueCopy || id == CSSValueNone) { |
cursorType = consumeIdent(range); |
} else { |
@@ -2148,10 +2221,65 @@ static CSSValue* consumeCounterContent(CSSParserTokenRange args, |
CSSIdentifierValue* listStyle = nullptr; |
if (consumeCommaIncludingWhitespace(args)) { |
CSSValueID id = args.peek().id(); |
- if ((id != CSSValueNone && |
- (id < CSSValueDisc || id > CSSValueKatakanaIroha))) |
- return nullptr; |
- listStyle = consumeIdent(args); |
+ if (id != CSSValueNone && |
+ id != CSSValueDisc && |
+ id != CSSValueCircle && |
+ id != CSSValueSquare && |
+ id != CSSValueDecimal && |
+ id != CSSValueDecimalLeadingZero && |
+ id != CSSValueArabicIndic && |
+ id != CSSValueBengali && |
+ id != CSSValueCambodian && |
+ id != CSSValueKhmer && |
+ id != CSSValueDevanagari && |
+ id != CSSValueGujarati && |
+ id != CSSValueGurmukhi && |
+ id != CSSValueKannada && |
+ id != CSSValueLao && |
+ id != CSSValueMalayalam && |
+ id != CSSValueMongolian && |
+ id != CSSValueMyanmar && |
+ id != CSSValueOriya && |
+ id != CSSValuePersian && |
+ id != CSSValueUrdu && |
+ id != CSSValueTelugu && |
+ id != CSSValueTibetan && |
+ id != CSSValueThai && |
+ id != CSSValueLowerRoman && |
+ id != CSSValueUpperRoman && |
+ id != CSSValueLowerGreek && |
+ id != CSSValueLowerAlpha && |
+ id != CSSValueLowerLatin && |
+ id != CSSValueUpperAlpha && |
+ id != CSSValueUpperLatin && |
+ id != CSSValueCjkEarthlyBranch && |
+ id != CSSValueCjkHeavenlyStem && |
+ id != CSSValueEthiopicHalehame && |
+ id != CSSValueEthiopicHalehameAm && |
+ id != CSSValueEthiopicHalehameTiEr && |
+ id != CSSValueEthiopicHalehameTiEt && |
+ id != CSSValueHangul && |
+ id != CSSValueHangulConsonant && |
+ id != CSSValueKoreanHangulFormal && |
+ id != CSSValueKoreanHanjaFormal && |
+ id != CSSValueKoreanHanjaInformal && |
+ id != CSSValueHebrew && |
+ id != CSSValueArmenian && |
+ id != CSSValueLowerArmenian && |
+ id != CSSValueUpperArmenian && |
+ id != CSSValueGeorgian && |
+ id != CSSValueCjkIdeographic && |
+ id != CSSValueSimpChineseFormal && |
+ id != CSSValueSimpChineseInformal && |
+ id != CSSValueTradChineseFormal && |
+ id != CSSValueTradChineseInformal && |
+ id != CSSValueHiragana && |
+ id != CSSValueKatakana && |
+ id != CSSValueHiraganaIroha && |
+ id != CSSValueKatakanaIroha) { |
+ return nullptr; |
+ } |
+ listStyle = consumeIdent(args); |
} else { |
listStyle = CSSIdentifierValue::create(CSSValueDecimal); |
} |
@@ -2755,7 +2883,20 @@ static CSSValue* consumeImageOrientation(CSSParserTokenRange& range) { |
static CSSValue* consumeBackgroundBlendMode(CSSParserTokenRange& range) { |
CSSValueID id = range.peek().id(); |
if (id == CSSValueNormal || id == CSSValueOverlay || |
- (id >= CSSValueMultiply && id <= CSSValueLuminosity)) |
+ id == CSSValueMultiply || |
+ id == CSSValueScreen || |
+ id == CSSValueDarken || |
+ id == CSSValueLighten || |
+ id == CSSValueColorDodge || |
+ id == CSSValueColorBurn || |
+ id == CSSValueHardLight || |
+ id == CSSValueSoftLight || |
+ id == CSSValueDifference || |
+ id == CSSValueExclusion || |
+ id == CSSValueHue || |
+ id == CSSValueSaturation || |
+ id == CSSValueColor || |
+ id == CSSValueLuminosity) |
return consumeIdent(range); |
return nullptr; |
} |
@@ -3976,9 +4117,21 @@ bool CSSPropertyParser::parseFontFaceDescriptor(CSSPropertyID propId) { |
return true; |
} |
+static bool isValidSystemFontValue(CSSValueID systemFontID) { |
+ return systemFontID == CSSValueCaption || |
+ systemFontID == CSSValueIcon || |
+ systemFontID == CSSValueMenu || |
+ systemFontID == CSSValueMessageBox || |
+ systemFontID == CSSValueSmallCaption || |
+ systemFontID == CSSValueWebkitMiniControl || |
+ systemFontID == CSSValueWebkitSmallControl || |
+ systemFontID == CSSValueWebkitControl || |
+ systemFontID == CSSValueStatusBar; |
+} |
+ |
bool CSSPropertyParser::consumeSystemFont(bool important) { |
CSSValueID systemFontID = m_range.consumeIncludingWhitespace().id(); |
- ASSERT(systemFontID >= CSSValueCaption && systemFontID <= CSSValueStatusBar); |
+ ASSERT(isValidSystemFontValue(systemFontID)); |
if (!m_range.atEnd()) |
return false; |
@@ -5148,7 +5301,7 @@ bool CSSPropertyParser::parseShorthand(CSSPropertyID unresolvedProperty, |
} |
case CSSPropertyFont: { |
const CSSParserToken& token = m_range.peek(); |
- if (token.id() >= CSSValueCaption && token.id() <= CSSValueStatusBar) |
+ if (isValidSystemFontValue(token.id())) |
return consumeSystemFont(important); |
return consumeFont(important); |
} |