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

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

Issue 1103273010: Add parseFontFaceDescriptor for @font-face handling (Closed) Base URL: https://chromium.googlesource.com/chromium/blink.git@master
Patch Set: V5 Created 5 years, 8 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') | no next file » | 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 17a2b6113f22a83f9cdab3c68c21d7250b6f3ed8..957b732772d02ad220f50b778df8423f47c57f94 100644
--- a/Source/core/css/parser/CSSPropertyParser.cpp
+++ b/Source/core/css/parser/CSSPropertyParser.cpp
@@ -426,6 +426,11 @@ bool CSSPropertyParser::parseValue(CSSPropertyID unresolvedProperty, bool import
return parseViewportProperty(propId, important);
}
+ if (m_ruleType == StyleRule::FontFace) {
+ if (important)
+ return false;
+ return parseFontFaceDescriptor(propId);
+ }
// Note: m_parsedCalculation is used to pass the calc value to validUnit and then cleared at the end of this function.
// FIXME: This is to avoid having to pass parsedCalc to all validUnit callers.
@@ -926,12 +931,9 @@ bool CSSPropertyParser::parseValue(CSSPropertyID unresolvedProperty, bool import
m_context.useCounter()->count(UseCounter::CSSZoomNotEqualToOne);
break;
- case CSSPropertySrc: // Only used within @font-face so cannot use inherit | initial or be !important. This is a list of urls or local references.
- parsedValue = parseFontFaceSrc();
- break;
-
+ case CSSPropertySrc:
case CSSPropertyUnicodeRange:
- parsedValue = parseFontFaceUnicodeRange();
+ /* @font-face only descriptors */
break;
/* CSS3 properties */
@@ -7640,6 +7642,56 @@ bool CSSPropertyParser::parseCalculation(CSSParserValue* value, ValueRange range
return true;
}
+bool CSSPropertyParser::parseFontFaceDescriptor(CSSPropertyID propId)
+{
+ CSSParserValue* value = m_valueList->current();
+ ASSERT(value);
+ CSSValueID id = value->id;
+ RefPtrWillBeRawPtr<CSSValue> parsedValue = nullptr;
+
+ switch (propId) {
+ case CSSPropertyFontFamily:
+ // <family-name>
+ // TODO(rwlbuis): check there is only one family-name
+ parsedValue = parseFontFamily();
+ break;
+ case CSSPropertySrc: // This is a list of urls or local references.
+ parsedValue = parseFontFaceSrc();
+ break;
+ case CSSPropertyUnicodeRange:
+ parsedValue = parseFontFaceUnicodeRange();
+ break;
+ case CSSPropertyFontWeight: // normal | bold | 100 | 200 | 300 | 400 | 500 | 600 | 700 | 800 | 900
+ if (m_valueList->size() != 1)
+ return false;
+ return parseFontWeight(false);
+ case CSSPropertyFontStretch:
+ case CSSPropertyFontStyle:
+ if (!CSSParserFastPaths::isValidKeywordPropertyAndValue(propId, id))
+ return false;
+ addProperty(propId, cssValuePool().createIdentifierValue(id), false);
+ return true;
+ case CSSPropertyFontVariant: // normal | small-caps | inherit
+ return parseFontVariant(false);
+ case CSSPropertyWebkitFontFeatureSettings:
+ if (id == CSSValueNormal) {
+ parsedValue = cssValuePool().createIdentifierValue(CSSValueNormal);
+ m_valueList->next();
+ } else {
+ parsedValue = parseFontFeatureSettings();
+ }
+ break;
+ default:
+ break;
+ }
+
+ if (!parsedValue || m_valueList->current())
+ return false;
+
+ addProperty(propId, parsedValue.release(), false);
+ return true;
+}
+
bool CSSPropertyParser::parseViewportProperty(CSSPropertyID propId, bool important)
{
ASSERT(RuntimeEnabledFeatures::cssViewportEnabled() || isUASheetBehavior(m_context.mode()));
« no previous file with comments | « Source/core/css/parser/CSSPropertyParser.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698