Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(15)

Unified Diff: Source/core/css/parser/CSSPropertyParser.cpp

Issue 677103002: Expand system font values during property parsing. (Closed) Base URL: https://chromium.googlesource.com/chromium/blink.git@master
Patch Set: Remove isExpandedShorthandForAll. Created 6 years, 2 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « Source/core/css/parser/CSSPropertyParser.h ('k') | Source/core/css/resolver/FontBuilder.h » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: Source/core/css/parser/CSSPropertyParser.cpp
diff --git a/Source/core/css/parser/CSSPropertyParser.cpp b/Source/core/css/parser/CSSPropertyParser.cpp
index 447dbddba4d05d9fba7f7c8bbf22de789fc4c62b..a4fe06d622f8d7d7c940f78e1c68d7bed7ecfe8e 100644
--- a/Source/core/css/parser/CSSPropertyParser.cpp
+++ b/Source/core/css/parser/CSSPropertyParser.cpp
@@ -49,6 +49,7 @@
#include "core/css/CSSKeyframesRule.h"
#include "core/css/CSSLineBoxContainValue.h"
#include "core/css/CSSPrimitiveValue.h"
+#include "core/css/CSSPrimitiveValueMappings.h"
#include "core/css/CSSPropertyMetadata.h"
#include "core/css/CSSPropertySourceData.h"
#include "core/css/CSSReflectValue.h"
@@ -1397,11 +1398,11 @@ bool CSSPropertyParser::parseValue(CSSPropertyID propId, bool important)
case CSSPropertyFont:
// [ [ '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;
- else
- return parseFont(important);
- break;
+ if (num == 1 && id >= CSSValueCaption && id <= CSSValueStatusBar) {
+ parseSystemFont(important);
+ return true;
+ }
+ return parseFont(important);
case CSSPropertyListStyle:
return parseShorthand(propId, listStyleShorthand(), important);
case CSSPropertyWebkitColumns:
@@ -4438,6 +4439,30 @@ bool CSSPropertyParser::parseFont(bool important)
return true;
}
+void CSSPropertyParser::parseSystemFont(bool important)
+{
+ ASSERT(m_valueList->size() == 1);
+ CSSValueID systemFontID = m_valueList->valueAt(0)->id;
+ ASSERT(systemFontID >= CSSValueCaption && systemFontID <= CSSValueStatusBar);
+ m_valueList->next();
+
+ FontStyle fontStyle = FontStyleNormal;
+ FontWeight fontWeight = FontWeightNormal;
+ float fontSize = 0;
+ AtomicString fontFamily;
+ RenderTheme::theme().systemFont(systemFontID, fontStyle, fontWeight, fontSize, fontFamily);
+
+ ShorthandScope scope(this, CSSPropertyFont);
+ addProperty(CSSPropertyFontStyle, cssValuePool().createIdentifierValue(fontStyle == FontStyleItalic ? CSSValueItalic : CSSValueNormal), important);
+ addProperty(CSSPropertyFontWeight, cssValuePool().createValue(fontWeight), important);
+ addProperty(CSSPropertyFontSize, cssValuePool().createValue(fontSize, CSSPrimitiveValue::CSS_PX), important);
+ RefPtr<CSSValueList> fontFamilyList = CSSValueList::createCommaSeparated();
+ fontFamilyList->append(cssValuePool().createFontFamilyValue(fontFamily));
+ addProperty(CSSPropertyFontFamily, fontFamilyList.release(), important);
+ addProperty(CSSPropertyFontVariant, cssValuePool().createIdentifierValue(CSSValueNormal), important);
+ addProperty(CSSPropertyLineHeight, cssValuePool().createIdentifierValue(CSSValueNormal), important);
+}
+
class FontFamilyValueBuilder {
DISALLOW_ALLOCATION();
public:
« no previous file with comments | « Source/core/css/parser/CSSPropertyParser.h ('k') | Source/core/css/resolver/FontBuilder.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698