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

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

Issue 1306823004: Split out String, URI and CustomIdent from CSSPrimitiveValue (Closed) Base URL: https://chromium.googlesource.com/chromium/blink.git@split_out_attr_values
Patch Set: Fixing tests 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..46ef68c4336bfb754762f9e168ddd3854c3385fb 100644
--- a/Source/core/css/parser/LegacyCSSPropertyParser.cpp
+++ b/Source/core/css/parser/LegacyCSSPropertyParser.cpp
@@ -259,16 +259,16 @@ PassRefPtrWillBeRawPtr<CSSPrimitiveValue> CSSPropertyParser::createPrimitiveNume
return cssValuePool().createValue(value->fValue, value->unit());
}
-inline PassRefPtrWillBeRawPtr<CSSPrimitiveValue> CSSPropertyParser::createPrimitiveStringValue(CSSParserValue* value)
+inline PassRefPtrWillBeRawPtr<CSSStringValue> CSSPropertyParser::createPrimitiveStringValue(CSSParserValue* value)
{
- ASSERT(value->unit() == CSSPrimitiveValue::UnitType::String || value->m_unit == CSSParserValue::Identifier);
- return cssValuePool().createValue(value->string, CSSPrimitiveValue::UnitType::String);
+ ASSERT(value->m_unit == CSSParserValue::String || value->m_unit == CSSParserValue::Identifier);
+ return CSSStringValue::create(value->string);
}
-inline PassRefPtrWillBeRawPtr<CSSPrimitiveValue> CSSPropertyParser::createPrimitiveCustomIdentValue(CSSParserValue* value)
+inline PassRefPtrWillBeRawPtr<CSSCustomIdentValue> CSSPropertyParser::createPrimitiveCustomIdentValue(CSSParserValue* value)
{
- ASSERT(value->unit() == CSSPrimitiveValue::UnitType::String || value->m_unit == CSSParserValue::Identifier);
- return cssValuePool().createValue(value->string, CSSPrimitiveValue::UnitType::CustomIdentifier);
+ ASSERT(value->m_unit == CSSParserValue::String || value->m_unit == CSSParserValue::Identifier);
+ return CSSCustomIdentValue::create(value->string);
}
inline PassRefPtrWillBeRawPtr<CSSValue> CSSPropertyParser::createCSSImageValueWithReferrer(const String& rawValue, const KURL& url)
@@ -532,7 +532,7 @@ bool CSSPropertyParser::parseValue(CSSPropertyID unresolvedProperty, bool import
RefPtrWillBeRawPtr<CSSValueList> list = nullptr;
while (value) {
RefPtrWillBeRawPtr<CSSValue> image = nullptr;
- if (value->unit() == CSSPrimitiveValue::UnitType::URI) {
+ if (value->m_unit == CSSParserValue::URI) {
String uri = value->string;
if (!uri.isNull())
image = createCSSImageValueWithReferrer(uri, completeURL(uri));
@@ -661,7 +661,7 @@ bool CSSPropertyParser::parseValue(CSSPropertyID unresolvedProperty, bool import
if (id == CSSValueNone) {
parsedValue = cssValuePool().createIdentifierValue(CSSValueNone);
m_valueList->next();
- } else if (value->unit() == CSSPrimitiveValue::UnitType::URI) {
+ } else if (value->m_unit == CSSParserValue::URI) {
parsedValue = createCSSImageValueWithReferrer(value->string, completeURL(value->string));
m_valueList->next();
} else if (isGeneratedImageValue(value)) {
@@ -1257,7 +1257,7 @@ bool CSSPropertyParser::parseValue(CSSPropertyID unresolvedProperty, bool import
case CSSPropertyWebkitLocale:
if (id == CSSValueAuto) {
validPrimitive = true;
- } else if (value->unit() == CSSPrimitiveValue::UnitType::String) {
+ } else if (value->m_unit == CSSParserValue::String) {
parsedValue = createPrimitiveStringValue(value);
m_valueList->next();
}
@@ -1393,8 +1393,8 @@ bool CSSPropertyParser::parseValue(CSSPropertyID unresolvedProperty, bool import
validPrimitive = true;
} else if (value->m_unit == CSSParserValue::Function) {
parsedValue = parseBasicShape();
- } else if (value->unit() == CSSPrimitiveValue::UnitType::URI) {
- parsedValue = CSSPrimitiveValue::create(value->string, CSSPrimitiveValue::UnitType::URI);
+ } else if (value->m_unit == CSSParserValue::URI) {
+ parsedValue = CSSURIValue::create(value->string);
addProperty(propId, parsedValue.release(), important);
return true;
}
@@ -1667,8 +1667,7 @@ static bool isValidTransitionPropertyList(CSSValueList* value)
// FIXME: Shorthand parsing shouldn't add initial to the list since it won't round-trip
if (property->isInitialValue())
continue;
- CSSPrimitiveValue* primitiveValue = toCSSPrimitiveValue(property.get());
- if (primitiveValue->isValueID() && primitiveValue->getValueID() == CSSValueNone)
+ if (property->isPrimitiveValue() && toCSSPrimitiveValue(*property).isValueID() && toCSSPrimitiveValue(*property).getValueID() == CSSValueNone)
return false;
}
return true;
@@ -2064,7 +2063,7 @@ PassRefPtrWillBeRawPtr<CSSValueList> CSSPropertyParser::parseContent()
while (CSSParserValue* val = m_valueList->current()) {
RefPtrWillBeRawPtr<CSSValue> parsedValue = nullptr;
- if (val->unit() == CSSPrimitiveValue::UnitType::URI) {
+ if (val->m_unit == CSSParserValue::URI) {
// url
parsedValue = createCSSImageValueWithReferrer(val->string, completeURL(val->string));
} else if (val->m_unit == CSSParserValue::Function) {
@@ -2096,7 +2095,7 @@ PassRefPtrWillBeRawPtr<CSSValueList> CSSPropertyParser::parseContent()
default:
break;
}
- } else if (val->unit() == CSSPrimitiveValue::UnitType::String) {
+ } else if (val->m_unit == CSSParserValue::String) {
parsedValue = createPrimitiveStringValue(val);
}
if (!parsedValue)
@@ -2129,7 +2128,7 @@ PassRefPtrWillBeRawPtr<CSSValue> CSSPropertyParser::parseAttr(CSSParserValueList
attrName = attrName.lower();
RefPtrWillBeRawPtr<CSSFunctionValue> attrValue = CSSFunctionValue::create(CSSValueAttr);
- attrValue->append(CSSPrimitiveValue::create(attrName, CSSPrimitiveValue::UnitType::CustomIdentifier));
+ attrValue->append(CSSCustomIdentValue::create(attrName));
return attrValue.release();
}
@@ -2203,7 +2202,7 @@ bool CSSPropertyParser::parseFillImage(CSSParserValueList* valueList, RefPtrWill
value = cssValuePool().createIdentifierValue(CSSValueNone);
return true;
}
- if (valueList->current()->unit() == CSSPrimitiveValue::UnitType::URI) {
+ if (valueList->current()->m_unit == CSSParserValue::URI) {
value = createCSSImageValueWithReferrer(valueList->current()->string, completeURL(valueList->current()->string));
return true;
}
@@ -2897,7 +2896,7 @@ PassRefPtrWillBeRawPtr<CSSValue> CSSPropertyParser::parseAnimationName(bool allo
if (value->m_unit == CSSParserValue::Identifier)
return createPrimitiveCustomIdentValue(value);
- if (allowQuotedName && value->unit() == CSSPrimitiveValue::UnitType::String) {
+ if (allowQuotedName && value->m_unit == CSSParserValue::String) {
// Legacy support for strings in prefixed animations
if (m_context.useCounter())
m_context.useCounter()->count(UseCounter::QuotedAnimationName);
@@ -3103,7 +3102,7 @@ static inline bool isValidCustomIdentForGridPositions(const CSSParserValue& valu
}
// The function parses [ <integer> || <custom-ident> ] in <grid-line> (which can be stand alone or with 'span').
-bool CSSPropertyParser::parseIntegerOrCustomIdentFromGridPosition(RefPtrWillBeRawPtr<CSSPrimitiveValue>& numericValue, RefPtrWillBeRawPtr<CSSPrimitiveValue>& gridLineName)
+bool CSSPropertyParser::parseIntegerOrCustomIdentFromGridPosition(RefPtrWillBeRawPtr<CSSPrimitiveValue>& numericValue, RefPtrWillBeRawPtr<CSSCustomIdentValue>& gridLineName)
{
CSSParserValue* value = m_valueList->current();
if (validUnit(value, FInteger) && value->fValue) {
@@ -3140,7 +3139,7 @@ PassRefPtrWillBeRawPtr<CSSValue> CSSPropertyParser::parseGridPosition()
}
RefPtrWillBeRawPtr<CSSPrimitiveValue> numericValue = nullptr;
- RefPtrWillBeRawPtr<CSSPrimitiveValue> gridLineName = nullptr;
+ RefPtrWillBeRawPtr<CSSCustomIdentValue> gridLineName = nullptr;
bool hasSeenSpanKeyword = false;
if (parseIntegerOrCustomIdentFromGridPosition(numericValue, gridLineName)) {
@@ -3172,7 +3171,7 @@ PassRefPtrWillBeRawPtr<CSSValue> CSSPropertyParser::parseGridPosition()
// For the <custom-ident> case.
if (gridLineName && !numericValue && !hasSeenSpanKeyword)
- return cssValuePool().createValue(gridLineName->getStringValue(), CSSPrimitiveValue::UnitType::CustomIdentifier);
+ return CSSCustomIdentValue::create(gridLineName->value());
RefPtrWillBeRawPtr<CSSValueList> values = CSSValueList::createSpaceSeparated();
if (hasSeenSpanKeyword)
@@ -3187,7 +3186,7 @@ PassRefPtrWillBeRawPtr<CSSValue> CSSPropertyParser::parseGridPosition()
static PassRefPtrWillBeRawPtr<CSSValue> gridMissingGridPositionValue(CSSValue* value)
{
- if (value->isPrimitiveValue() && toCSSPrimitiveValue(value)->isCustomIdent())
+ if (value->isCustomIdentValue())
return value;
return cssValuePool().createIdentifierValue(CSSValueAuto);
@@ -3246,7 +3245,7 @@ bool CSSPropertyParser::parseGridTemplateRowsAndAreas(PassRefPtrWillBeRawPtr<CSS
++rowCount;
// Handle template-rows's track-size.
- if (m_valueList->current() && m_valueList->current()->unit() != CSSPrimitiveValue::UnitType::String) {
+ if (m_valueList->current() && m_valueList->current()->m_unit != CSSParserValue::String) {
RefPtrWillBeRawPtr<CSSValue> value = parseGridTrackSize(*m_valueList);
if (!value)
return false;
@@ -3469,7 +3468,7 @@ bool CSSPropertyParser::parseGridLineNames(CSSParserValueList& inputList, CSSVal
if (!isValidCustomIdentForGridPositions(*identValue))
return false;
- RefPtrWillBeRawPtr<CSSPrimitiveValue> lineName = createPrimitiveCustomIdentValue(identValue);
+ RefPtrWillBeRawPtr<CSSCustomIdentValue> lineName = createPrimitiveCustomIdentValue(identValue);
lineNames->append(lineName.release());
inputList.next();
}
@@ -3673,7 +3672,7 @@ static Vector<String> parseGridTemplateAreasColumnNames(const String& gridRowNam
bool CSSPropertyParser::parseGridTemplateAreasRow(NamedGridAreaMap& gridAreaMap, const size_t rowCount, size_t& columnCount)
{
CSSParserValue* currentValue = m_valueList->current();
- if (!currentValue || currentValue->unit() != CSSPrimitiveValue::UnitType::String)
+ if (!currentValue || currentValue->m_unit != CSSParserValue::String)
return false;
String gridRowNames = currentValue->string;
@@ -3805,18 +3804,18 @@ PassRefPtrWillBeRawPtr<CSSValue> CSSPropertyParser::parseCounterContent(CSSParse
CSSParserValue* i = args->current();
if (i->m_unit != CSSParserValue::Identifier)
return nullptr;
- RefPtrWillBeRawPtr<CSSPrimitiveValue> identifier = createPrimitiveCustomIdentValue(i);
+ RefPtrWillBeRawPtr<CSSCustomIdentValue> identifier = createPrimitiveCustomIdentValue(i);
- RefPtrWillBeRawPtr<CSSPrimitiveValue> separator = nullptr;
+ RefPtrWillBeRawPtr<CSSCustomIdentValue> separator = nullptr;
if (!counters)
- separator = cssValuePool().createValue(String(), CSSPrimitiveValue::UnitType::CustomIdentifier);
+ separator = CSSCustomIdentValue::create(String());
else {
args->next();
if (!consumeComma(args))
return nullptr;
i = args->current();
- if (i->unit() != CSSPrimitiveValue::UnitType::String)
+ if (i->m_unit != CSSParserValue::String)
return nullptr;
separator = createPrimitiveCustomIdentValue(i);
@@ -4572,7 +4571,7 @@ PassRefPtrWillBeRawPtr<CSSValueList> CSSPropertyParser::parseFontFamily()
bool nextValBreaksFont = !nextValue || isComma(nextValue);
bool nextValIsFontName = nextValue &&
((nextValue->id >= CSSValueSerif && nextValue->id <= CSSValueWebkitBody) ||
- (nextValue->unit() == CSSPrimitiveValue::UnitType::String || nextValue->m_unit == CSSParserValue::Identifier));
+ (nextValue->m_unit == CSSParserValue::String || nextValue->m_unit == CSSParserValue::Identifier));
if (isCSSWideKeyword(*value) && !inFamily) {
if (nextValBreaksFont)
@@ -4592,7 +4591,7 @@ PassRefPtrWillBeRawPtr<CSSValueList> CSSPropertyParser::parseFontFamily()
familyBuilder.add(value->string);
inFamily = true;
}
- } else if (value->unit() == CSSPrimitiveValue::UnitType::String) {
+ } else if (value->m_unit == CSSParserValue::String) {
// Strings never share in a family name.
inFamily = false;
familyBuilder.commit();
@@ -4748,7 +4747,7 @@ bool CSSPropertyParser::parseFontFaceSrcURI(CSSValueList* valueList)
// 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))
+ if (!args || args->size() != 1 || (args->current()->m_unit != CSSParserValue::String && args->current()->m_unit != CSSParserValue::Identifier))
return false;
uriValue->setFormat(args->current()->string);
valueList->append(uriValue.release());
@@ -4764,7 +4763,7 @@ bool CSSPropertyParser::parseFontFaceSrcLocal(CSSValueList* valueList)
m_valueList->next();
ContentSecurityPolicyDisposition shouldCheckContentSecurityPolicy = m_context.shouldCheckContentSecurityPolicy();
- if (args->size() == 1 && args->current()->unit() == CSSPrimitiveValue::UnitType::String) {
+ if (args->size() == 1 && args->current()->m_unit == CSSParserValue::String) {
valueList->append(CSSFontFaceSrcValue::createLocal(args->current()->string, shouldCheckContentSecurityPolicy));
} else if (args->current()->m_unit == CSSParserValue::Identifier) {
StringBuilder builder;
@@ -4790,7 +4789,7 @@ PassRefPtrWillBeRawPtr<CSSValueList> CSSPropertyParser::parseFontFaceSrc()
CSSParserValue* value = m_valueList->current();
if (!value)
return nullptr;
- if (value->unit() == CSSPrimitiveValue::UnitType::URI) {
+ if (value->m_unit == CSSParserValue::URI) {
if (!parseFontFaceSrcURI(values.get()))
return nullptr;
} else if (value->m_unit == CSSParserValue::Function && value->function->id == CSSValueLocal) {
@@ -5346,7 +5345,7 @@ bool CSSPropertyParser::buildBorderImageParseContext(CSSPropertyID propId, Borde
context.commitForwardSlashOperator();
if (!context.canAdvance() && context.allowImage()) {
- if (val->unit() == CSSPrimitiveValue::UnitType::URI) {
+ if (val->m_unit == CSSParserValue::URI) {
context.commitImage(createCSSImageValueWithReferrer(val->string, m_context.completeURL(val->string)));
} else if (isGeneratedImageValue(val)) {
RefPtrWillBeRawPtr<CSSValue> value = nullptr;
@@ -5747,7 +5746,7 @@ PassRefPtrWillBeRawPtr<CSSValue> CSSPropertyParser::parseCounter(int defaultValu
CSSParserValue* val = m_valueList->current();
if (val->m_unit != CSSParserValue::Identifier)
return nullptr;
- RefPtrWillBeRawPtr<CSSPrimitiveValue> counterName = createPrimitiveCustomIdentValue(val);
+ RefPtrWillBeRawPtr<CSSCustomIdentValue> counterName = createPrimitiveCustomIdentValue(val);
m_valueList->next();
val = m_valueList->current();
@@ -6577,7 +6576,7 @@ PassRefPtrWillBeRawPtr<CSSValue> CSSPropertyParser::parseImageSet(CSSParserValue
while (functionArgs->current()) {
CSSParserValue* arg = functionArgs->current();
- if (arg->unit() != CSSPrimitiveValue::UnitType::URI)
+ if (arg->m_unit != CSSParserValue::URI)
return nullptr;
RefPtrWillBeRawPtr<CSSValue> image = createCSSImageValueWithReferrer(arg->string, completeURL(arg->string));
@@ -6702,11 +6701,11 @@ PassRefPtrWillBeRawPtr<CSSValueList> CSSPropertyParser::parseFilter()
// The filter is a list of functional primitives that specify individual operations.
RefPtrWillBeRawPtr<CSSValueList> list = CSSValueList::createSpaceSeparated();
for (CSSParserValue* value = m_valueList->current(); value; value = m_valueList->next()) {
- if (value->unit() != CSSPrimitiveValue::UnitType::URI && (value->m_unit != CSSParserValue::Function || !value->function))
+ if (value->m_unit != CSSParserValue::URI && (value->m_unit != CSSParserValue::Function || !value->function))
return nullptr;
// See if the specified primitive is one we understand.
- if (value->unit() == CSSPrimitiveValue::UnitType::URI) {
+ if (value->m_unit == CSSParserValue::URI) {
RefPtrWillBeRawPtr<CSSFunctionValue> referenceFilterValue = CSSFunctionValue::create(CSSValueUrl);
referenceFilterValue->append(CSSSVGDocumentValue::create(value->string));
list->append(referenceFilterValue.release());
@@ -6886,7 +6885,7 @@ PassRefPtrWillBeRawPtr<CSSValue> CSSPropertyParser::parseTextEmphasisStyle()
RefPtrWillBeRawPtr<CSSPrimitiveValue> shape = nullptr;
for (CSSParserValue* value = m_valueList->current(); value; value = m_valueList->next()) {
- if (value->unit() == CSSPrimitiveValue::UnitType::String) {
+ if (value->m_unit == CSSParserValue::String) {
if (fill || shape)
return nullptr;
m_valueList->next();
@@ -6973,7 +6972,7 @@ bool CSSPropertyParser::parseFontFeatureTag(CSSValueList* settings)
CSSParserValue* value = m_valueList->current();
// Feature tag name comes first
- if (value->unit() != CSSPrimitiveValue::UnitType::String)
+ if (value->m_unit != CSSParserValue::String)
return false;
if (value->string.length() != tagNameLength)
return false;
@@ -7323,8 +7322,8 @@ bool CSSPropertyParser::parseSVGValue(CSSPropertyID propId, bool important)
case CSSPropertyMask:
if (id == CSSValueNone) {
validPrimitive = true;
- } else if (value->unit() == CSSPrimitiveValue::UnitType::URI) {
- parsedValue = CSSPrimitiveValue::create(value->string, CSSPrimitiveValue::UnitType::URI);
+ } else if (value->m_unit == CSSParserValue::URI) {
+ parsedValue = CSSURIValue::create(value->string);
if (parsedValue)
m_valueList->next();
}
@@ -7365,10 +7364,10 @@ bool CSSPropertyParser::parseSVGValue(CSSPropertyID propId, bool important)
{
if (id == CSSValueNone) {
parsedValue = cssValuePool().createIdentifierValue(id);
- } else if (value->unit() == CSSPrimitiveValue::UnitType::URI) {
+ } else if (value->m_unit == CSSParserValue::URI) {
if (m_valueList->next()) {
RefPtrWillBeRawPtr<CSSValueList> values = CSSValueList::createSpaceSeparated();
- values->append(CSSPrimitiveValue::create(value->string, CSSPrimitiveValue::UnitType::URI));
+ values->append(CSSURIValue::create(value->string));
if (m_valueList->current()->id == CSSValueNone)
parsedValue = cssValuePool().createIdentifierValue(m_valueList->current()->id);
else
@@ -7379,7 +7378,7 @@ bool CSSPropertyParser::parseSVGValue(CSSPropertyID propId, bool important)
}
}
if (!parsedValue)
- parsedValue = CSSPrimitiveValue::create(value->string, CSSPrimitiveValue::UnitType::URI);
+ parsedValue = CSSURIValue::create(value->string);
} else {
parsedValue = parseColor(m_valueList->current());
}
@@ -7448,8 +7447,8 @@ bool CSSPropertyParser::parseSVGValue(CSSPropertyID propId, bool important)
if (validPrimitive) {
if (id)
parsedValue = CSSPrimitiveValue::createIdentifier(id);
- else if (value->unit() == CSSPrimitiveValue::UnitType::String)
- parsedValue = CSSPrimitiveValue::create(value->string, value->unit());
+ else if (value->m_unit == CSSParserValue::String)
+ parsedValue = CSSStringValue::create(value->string);
else if (value->unit() >= CSSPrimitiveValue::UnitType::Number && value->unit() <= CSSPrimitiveValue::UnitType::Kilohertz)
parsedValue = CSSPrimitiveValue::create(value->fValue, value->unit());
else if (value->unit() == CSSPrimitiveValue::UnitType::Rems || value->unit() == CSSPrimitiveValue::UnitType::Chs)
@@ -7756,7 +7755,7 @@ PassRefPtrWillBeRawPtr<CSSValue> CSSPropertyParser::parseMotionPath()
return nullptr;
CSSParserValue* arg = functionArgs->current();
- if (arg->unit() != CSSPrimitiveValue::UnitType::String)
+ if (arg->m_unit != CSSParserValue::String)
return nullptr;
String pathString = arg->string;

Powered by Google App Engine
This is Rietveld 408576698