Chromium Code Reviews| Index: Source/core/css/parser/CSSPropertyParser.cpp |
| diff --git a/Source/core/css/parser/CSSPropertyParser.cpp b/Source/core/css/parser/CSSPropertyParser.cpp |
| index 89f31400a1c047514cc60219657d6f2a1bcab1c2..b20c3e520dde468c45ba6923286177d89f0d3030 100644 |
| --- a/Source/core/css/parser/CSSPropertyParser.cpp |
| +++ b/Source/core/css/parser/CSSPropertyParser.cpp |
| @@ -55,6 +55,7 @@ |
| #include "core/css/CSSLineBoxContainValue.h" |
| #include "core/css/CSSParserValues.h" |
| #include "core/css/CSSPrimitiveValue.h" |
| +#include "core/css/CSSPrimitiveValueMappings.h" |
| #include "core/css/CSSPropertySourceData.h" |
| #include "core/css/CSSReflectValue.h" |
| #include "core/css/CSSSVGDocumentValue.h" |
| @@ -1414,7 +1415,7 @@ bool CSSPropertyParser::parseValue(CSSPropertyID propId, bool important) |
| // [ [ 'font-style' || 'font-variant' || 'font-weight' ]? 'font-size' [ / 'line-height' ]? |
| // 'font-family' ] | caption | icon | menu | message-box | small-caption | status-bar | inherit |
| if (id >= CSSValueCaption && id <= CSSValueStatusBar) |
| - validPrimitive = true; |
| + return parseKeywordBasedFont(important); |
| else |
| return parseFont(important); |
| break; |
| @@ -4521,6 +4522,34 @@ PassRefPtrWillBeRawPtr<CSSPrimitiveValue> CSSPropertyParser::parseBasicShape() |
| return cssValuePool().createValue(shape.release()); |
| } |
| +// [ 'caption' | 'icon' | 'menu' | 'message-box' | 'small-caption' | 'status-bar' | '-webkit-mini-control' | '-webkit-small-control' | '-webkit-control' ] |
| +bool CSSPropertyParser::parseKeywordBasedFont(bool important) |
| +{ |
| + if (m_valueList->size() != 1) |
| + return false; |
|
darktears
2014/03/20 13:20:17
nit : You could assert here, so that we know if we
apavlov
2014/03/20 14:38:24
Done.
|
| + |
| + CSSParserValue* value = m_valueList->valueAt(0); |
| + CSSValueID id = value->id; |
| + ASSERT(id >= CSSValueCaption && id <= CSSValueStatusBar); |
| + |
| + FontDescription fontDescription; |
| + RenderTheme::theme().systemFont(id, fontDescription); |
| + RefPtr<CSSValueList> familyList = CSSValueList::createCommaSeparated(); |
| + familyList->append(cssValuePool().createFontFamilyValue(fontDescription.firstFamily().family())); |
| + |
| + ShorthandScope scope(this, CSSPropertyFont); |
| + addProperty(CSSPropertyFontFamily, familyList, important, false); |
| + addProperty(CSSPropertyFontStyle, cssValuePool().createIdentifierValue(fontDescription.style() == FontStyleItalic ? CSSValueItalic : CSSValueNormal), important, false); |
| + addProperty(CSSPropertyFontVariant, cssValuePool().createIdentifierValue(fontDescription.variant() == FontVariantSmallCaps ? CSSValueSmallCaps : CSSValueNormal), important, false); |
| + addProperty(CSSPropertyFontWeight, cssValuePool().createValue(fontDescription.weight()), important, false); |
| + CSSParserValue fontSizeValue; |
| + fontSizeValue.setFromNumber(fontDescription.specifiedSize(), CSSPrimitiveValue::CSS_PX); |
| + addProperty(CSSPropertyFontSize, parseValidPrimitive(fontSizeValue.id, &fontSizeValue), important, false); |
| + addProperty(CSSPropertyLineHeight, cssValuePool().createIdentifierValue(CSSValueNormal), important, false); |
| + |
| + return true; |
| +} |
| + |
| // [ 'font-style' || 'font-variant' || 'font-weight' ]? 'font-size' [ / 'line-height' ]? 'font-family' |
| bool CSSPropertyParser::parseFont(bool important) |
| { |