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

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

Issue 1331233003: Move parseFontFaceDescriptor to CSSPropertyParser.cpp (Closed) Base URL: https://chromium.googlesource.com/chromium/blink.git@master
Patch Set: Patch for review Created 5 years, 3 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
Index: Source/core/css/parser/LegacyCSSPropertyParser.cpp
diff --git a/Source/core/css/parser/LegacyCSSPropertyParser.cpp b/Source/core/css/parser/LegacyCSSPropertyParser.cpp
index 38fe11864b07f8d8df945590b0c3b88848388a3b..7650b719107af317def86e9d547640aac48d06ad 100644
--- a/Source/core/css/parser/LegacyCSSPropertyParser.cpp
+++ b/Source/core/css/parser/LegacyCSSPropertyParser.cpp
@@ -35,8 +35,6 @@
#include "core/css/CSSCounterValue.h"
#include "core/css/CSSCrossfadeValue.h"
#include "core/css/CSSCursorImageValue.h"
-#include "core/css/CSSFontFaceSrcValue.h"
-#include "core/css/CSSFontFeatureValue.h"
#include "core/css/CSSFunctionValue.h"
#include "core/css/CSSGridLineNamesValue.h"
#include "core/css/CSSImageSetValue.h"
@@ -50,7 +48,6 @@
#include "core/css/CSSSVGDocumentValue.h"
#include "core/css/CSSShadowValue.h"
#include "core/css/CSSTimingFunctionValue.h"
-#include "core/css/CSSUnicodeRangeValue.h"
#include "core/css/CSSValuePair.h"
#include "core/css/CSSValuePool.h"
#include "core/css/HashTools.h"
@@ -460,15 +457,6 @@ bool CSSPropertyParser::parseValue(CSSPropertyID unresolvedProperty, bool import
* correctly and allows optimization in blink::applyRule(..)
*/
- case CSSPropertyTextAlign:
- // left | right | center | justify | -webkit-left | -webkit-right | -webkit-center | -webkit-match-parent
- // | start | end | <string> | inherit | -webkit-auto (converted to start)
- // FIXME: <string> not supported right now
- if ((id >= CSSValueWebkitAuto && id <= CSSValueWebkitMatchParent) || id == CSSValueStart || id == CSSValueEnd) {
- validPrimitive = true;
- }
- break;
-
case CSSPropertyFontWeight: // normal | bold | bolder | lighter | 100 | 200 | 300 | 400 | 500 | 600 | 700 | 800 | 900 | inherit
return parseFontWeight(important) && !m_valueList->next();
@@ -747,9 +735,6 @@ bool CSSPropertyParser::parseValue(CSSPropertyID unresolvedProperty, bool import
case CSSPropertyFontSize:
return parseFontSize(important);
- case CSSPropertyFontVariant: // normal | small-caps | inherit
- return parseFontVariant(important);
-
case CSSPropertyVerticalAlign:
// baseline | sub | super | top | text-top | middle | bottom | text-bottom |
// <percentage> | <length> | inherit
@@ -1233,9 +1218,6 @@ bool CSSPropertyParser::parseValue(CSSPropertyID unresolvedProperty, bool import
else
validPrimitive = validUnit(value, FLength | FNonNeg);
break;
- case CSSPropertyWebkitColumnSpan: // none | all | 1 (will be dropped in the unprefixed property)
- validPrimitive = id == CSSValueAll || id == CSSValueNone || (value->unit() == CSSPrimitiveValue::UnitType::Number && value->fValue == 1);
- break;
case CSSPropertyWebkitColumnWidth: // auto | <length>
parsedValue = parseColumnWidth();
break;
@@ -1253,16 +1235,6 @@ bool CSSPropertyParser::parseValue(CSSPropertyID unresolvedProperty, bool import
validPrimitive = validUnit(value, FLength | FUnitlessQuirk);
break;
- case CSSPropertyWebkitHyphenateCharacter:
- case CSSPropertyWebkitLocale:
- if (id == CSSValueAuto) {
- validPrimitive = true;
- } else if (value->unit() == CSSPrimitiveValue::UnitType::String) {
- parsedValue = createPrimitiveStringValue(value);
- m_valueList->next();
- }
- break;
-
// End Apple-specific properties
case CSSPropertyWebkitAppRegion:
@@ -1375,19 +1347,6 @@ bool CSSPropertyParser::parseValue(CSSPropertyID unresolvedProperty, bool import
validPrimitive = true;
break;
- case CSSPropertyWebkitFontFeatureSettings:
- if (id == CSSValueNormal)
- validPrimitive = true;
- else
- parsedValue = parseFontFeatureSettings();
- break;
-
- case CSSPropertyFontVariantLigatures:
- if (id == CSSValueNormal)
- validPrimitive = true;
- else
- return parseFontVariantLigatures(important);
- break;
case CSSPropertyWebkitClipPath:
if (id == CSSValueNone) {
validPrimitive = true;
@@ -1445,6 +1404,13 @@ bool CSSPropertyParser::parseValue(CSSPropertyID unresolvedProperty, bool import
case CSSPropertyOverflow:
case CSSPropertyQuotes:
case CSSPropertyWebkitHighlight:
+ case CSSPropertyWebkitFontFeatureSettings:
+ case CSSPropertyFontVariantLigatures:
+ case CSSPropertyFontVariant:
+ case CSSPropertyWebkitColumnSpan:
+ case CSSPropertyWebkitHyphenateCharacter:
+ case CSSPropertyWebkitLocale:
+ case CSSPropertyTextAlign:
validPrimitive = false;
break;
@@ -4668,55 +4634,6 @@ bool CSSPropertyParser::parseFontSize(bool important)
return validPrimitive;
}
-bool CSSPropertyParser::parseFontVariant(bool important)
-{
- RefPtrWillBeRawPtr<CSSValueList> values = nullptr;
- if (m_valueList->size() > 1)
- values = CSSValueList::createCommaSeparated();
- bool expectComma = false;
- for (CSSParserValue* val = m_valueList->current(); val; val = m_valueList->current()) {
- RefPtrWillBeRawPtr<CSSPrimitiveValue> parsedValue = nullptr;
- if (!expectComma) {
- expectComma = true;
- if (val->id == CSSValueNormal || val->id == CSSValueSmallCaps)
- parsedValue = cssValuePool().createIdentifierValue(val->id);
- else if (val->id == CSSValueAll && !values) {
- // FIXME: CSSPropertyParser::parseFontVariant() implements
- // the old css3 draft:
- // http://www.w3.org/TR/2002/WD-css3-webfonts-20020802/#font-variant
- // 'all' is only allowed in @font-face and with no other values. Make a value list to
- // indicate that we are in the @font-face case.
- values = CSSValueList::createCommaSeparated();
- parsedValue = cssValuePool().createIdentifierValue(val->id);
- }
- } else if (consumeComma(m_valueList)) {
- expectComma = false;
- continue;
- }
-
- if (!parsedValue)
- return false;
-
- m_valueList->next();
-
- if (values)
- values->append(parsedValue.release());
- else {
- addProperty(CSSPropertyFontVariant, parsedValue.release(), important);
- return true;
- }
- }
-
- if (values && values->length()) {
- if (m_ruleType != StyleRule::FontFace)
- return false;
- addProperty(CSSPropertyFontVariant, values.release(), important);
- return true;
- }
-
- return false;
-}
-
bool CSSPropertyParser::parseFontWeight(bool important)
{
CSSParserValue* value = m_valueList->current();
@@ -4734,99 +4651,6 @@ bool CSSPropertyParser::parseFontWeight(bool important)
return false;
}
-bool CSSPropertyParser::parseFontFaceSrcURI(CSSValueList* valueList)
-{
- RefPtrWillBeRawPtr<CSSFontFaceSrcValue> uriValue(CSSFontFaceSrcValue::create(completeURL(m_valueList->current()->string), m_context.shouldCheckContentSecurityPolicy()));
- uriValue->setReferrer(m_context.referrer());
-
- CSSParserValue* value = m_valueList->next();
- if (!value || value->m_unit != CSSParserValue::Function || value->function->id != CSSValueFormat) {
- valueList->append(uriValue.release());
- return true;
- }
-
- // FIXME: http://www.w3.org/TR/2011/WD-css3-fonts-20111004/ says that format() contains a comma-separated list of strings,
- // but CSSFontFaceSrcValue stores only one format. Allowing one format for now.
- CSSParserValueList* args = value->function->args.get();
- if (!args || args->size() != 1 || (args->current()->unit() != CSSPrimitiveValue::UnitType::String && args->current()->m_unit != CSSParserValue::Identifier))
- return false;
- uriValue->setFormat(args->current()->string);
- valueList->append(uriValue.release());
- m_valueList->next();
- return true;
-}
-
-bool CSSPropertyParser::parseFontFaceSrcLocal(CSSValueList* valueList)
-{
- CSSParserValueList* args = m_valueList->current()->function->args.get();
- if (!args || !args->size())
- return false;
- m_valueList->next();
-
- ContentSecurityPolicyDisposition shouldCheckContentSecurityPolicy = m_context.shouldCheckContentSecurityPolicy();
- if (args->size() == 1 && args->current()->unit() == CSSPrimitiveValue::UnitType::String) {
- valueList->append(CSSFontFaceSrcValue::createLocal(args->current()->string, shouldCheckContentSecurityPolicy));
- } else if (args->current()->m_unit == CSSParserValue::Identifier) {
- StringBuilder builder;
- for (CSSParserValue* localValue = args->current(); localValue; localValue = args->next()) {
- if (localValue->m_unit != CSSParserValue::Identifier)
- return false;
- if (!builder.isEmpty())
- builder.append(' ');
- builder.append(localValue->string);
- }
- valueList->append(CSSFontFaceSrcValue::createLocal(builder.toString(), shouldCheckContentSecurityPolicy));
- } else
- return false;
-
- return true;
-}
-
-PassRefPtrWillBeRawPtr<CSSValueList> CSSPropertyParser::parseFontFaceSrc()
-{
- RefPtrWillBeRawPtr<CSSValueList> values(CSSValueList::createCommaSeparated());
-
- while (true) {
- CSSParserValue* value = m_valueList->current();
- if (!value)
- return nullptr;
- if (value->unit() == CSSPrimitiveValue::UnitType::URI) {
- if (!parseFontFaceSrcURI(values.get()))
- return nullptr;
- } else if (value->m_unit == CSSParserValue::Function && value->function->id == CSSValueLocal) {
- if (!parseFontFaceSrcLocal(values.get()))
- return nullptr;
- } else {
- return nullptr;
- }
-
- if (!m_valueList->current())
- return values.release();
- if (!consumeComma(m_valueList))
- return nullptr;
- }
-}
-
-PassRefPtrWillBeRawPtr<CSSValueList> CSSPropertyParser::parseFontFaceUnicodeRange()
-{
- RefPtrWillBeRawPtr<CSSValueList> values = CSSValueList::createCommaSeparated();
-
- do {
- CSSParserValue* current = m_valueList->current();
- if (!current || current->m_unit != CSSParserValue::UnicodeRange)
- return nullptr;
-
- UChar32 start = current->m_unicodeRange.start;
- UChar32 end = current->m_unicodeRange.end;
- if (start > end)
- return nullptr;
- values->append(CSSUnicodeRangeValue::create(start, end));
- m_valueList->next();
- } while (consumeComma(m_valueList));
-
- return values.release();
-}
-
inline int CSSPropertyParser::colorIntFromValue(CSSParserValue* v)
{
bool isPercent;
@@ -6966,110 +6790,6 @@ PassRefPtrWillBeRawPtr<CSSValue> CSSPropertyParser::parseTextIndent()
return list.release();
}
-bool CSSPropertyParser::parseFontFeatureTag(CSSValueList* settings)
-{
- // Feature tag name consists of 4-letter characters.
- static const unsigned tagNameLength = 4;
-
- CSSParserValue* value = m_valueList->current();
- // Feature tag name comes first
- if (value->unit() != CSSPrimitiveValue::UnitType::String)
- return false;
- if (value->string.length() != tagNameLength)
- return false;
- for (unsigned i = 0; i < tagNameLength; ++i) {
- // Limits the range of characters to 0x20-0x7E, following the tag name rules defiend in the OpenType specification.
- UChar character = value->string[i];
- if (character < 0x20 || character > 0x7E)
- return false;
- }
-
- AtomicString tag = value->string;
- int tagValue = 1;
- // Feature tag values could follow: <integer> | on | off
- value = m_valueList->next();
- if (value) {
- if (value->unit() == CSSPrimitiveValue::UnitType::Number && value->isInt && value->fValue >= 0) {
- tagValue = clampTo<int>(value->fValue);
- if (tagValue < 0)
- return false;
- m_valueList->next();
- } else if (value->id == CSSValueOn || value->id == CSSValueOff) {
- tagValue = value->id == CSSValueOn;
- m_valueList->next();
- }
- }
- settings->append(CSSFontFeatureValue::create(tag, tagValue));
- return true;
-}
-
-PassRefPtrWillBeRawPtr<CSSValue> CSSPropertyParser::parseFontFeatureSettings()
-{
- RefPtrWillBeRawPtr<CSSValueList> settings = CSSValueList::createCommaSeparated();
- while (true) {
- if (!m_valueList->current() || !parseFontFeatureTag(settings.get()))
- return nullptr;
- if (!m_valueList->current())
- break;
- if (!consumeComma(m_valueList))
- return nullptr;
- }
- return settings.release();
-}
-
-bool CSSPropertyParser::parseFontVariantLigatures(bool important)
-{
- RefPtrWillBeRawPtr<CSSValueList> ligatureValues = CSSValueList::createSpaceSeparated();
- bool sawCommonLigaturesValue = false;
- bool sawDiscretionaryLigaturesValue = false;
- bool sawHistoricalLigaturesValue = false;
- bool sawContextualLigaturesValue = false;
-
- for (CSSParserValue* value = m_valueList->current(); value; value = m_valueList->next()) {
- if (value->m_unit != CSSParserValue::Identifier)
- return false;
-
- switch (value->id) {
- case CSSValueNoCommonLigatures:
- case CSSValueCommonLigatures:
- if (sawCommonLigaturesValue)
- return false;
- sawCommonLigaturesValue = true;
- ligatureValues->append(cssValuePool().createIdentifierValue(value->id));
- break;
- case CSSValueNoDiscretionaryLigatures:
- case CSSValueDiscretionaryLigatures:
- if (sawDiscretionaryLigaturesValue)
- return false;
- sawDiscretionaryLigaturesValue = true;
- ligatureValues->append(cssValuePool().createIdentifierValue(value->id));
- break;
- case CSSValueNoHistoricalLigatures:
- case CSSValueHistoricalLigatures:
- if (sawHistoricalLigaturesValue)
- return false;
- sawHistoricalLigaturesValue = true;
- ligatureValues->append(cssValuePool().createIdentifierValue(value->id));
- break;
- case CSSValueNoContextual:
- case CSSValueContextual:
- if (sawContextualLigaturesValue)
- return false;
- sawContextualLigaturesValue = true;
- ligatureValues->append(cssValuePool().createIdentifierValue(value->id));
- break;
- default:
- return false;
- }
- }
-
- if (!ligatureValues->length())
- return false;
-
- addProperty(CSSPropertyFontVariantLigatures, ligatureValues.release(), important);
- return true;
-}
-
bool CSSPropertyParser::parseCalculation(CSSParserValue* value, ValueRange range)
{
ASSERT(isCalculation(value));
@@ -7085,54 +6805,6 @@ 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
- return parseFontWeight(false) && !m_valueList->next();
- 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()));
« Source/core/css/parser/CSSPropertyParser.cpp ('K') | « Source/core/css/parser/CSSPropertyParser.cpp ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698