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

Unified Diff: Source/core/css/resolver/StyleBuilderConverter.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/resolver/StyleBuilderConverter.cpp
diff --git a/Source/core/css/resolver/StyleBuilderConverter.cpp b/Source/core/css/resolver/StyleBuilderConverter.cpp
index 8d8bad9c2873015a3cb386e817cd5be414fef5a4..dabb174e4f11d8468d5cb063feafe927d035e656 100644
--- a/Source/core/css/resolver/StyleBuilderConverter.cpp
+++ b/Source/core/css/resolver/StyleBuilderConverter.cpp
@@ -92,9 +92,8 @@ Color StyleBuilderConverter::convertColor(StyleResolverState& state, CSSValue* v
AtomicString StyleBuilderConverter::convertFragmentIdentifier(StyleResolverState& state, CSSValue* value)
{
- CSSPrimitiveValue* primitiveValue = toCSSPrimitiveValue(value);
- if (primitiveValue->isURI())
- return SVGURIReference::fragmentIdentifierFromIRIString(primitiveValue->getStringValue(), state.element()->treeScope());
+ if (value->isURIValue())
+ return SVGURIReference::fragmentIdentifierFromIRIString(toCSSURIValue(value)->value(), state.element()->treeScope());
return nullAtom;
}
@@ -130,14 +129,14 @@ static FontDescription::GenericFamilyType convertGenericFamily(CSSValueID valueI
}
}
-static bool convertFontFamilyName(StyleResolverState& state, CSSPrimitiveValue* primitiveValue,
+static bool convertFontFamilyName(StyleResolverState& state, CSSValue* value,
FontDescription::GenericFamilyType& genericFamily, AtomicString& familyName)
{
- if (primitiveValue->isCustomIdent()) {
+ if (value->isCustomIdentValue()) {
genericFamily = FontDescription::NoFamily;
- familyName = AtomicString(primitiveValue->getStringValue());
+ familyName = AtomicString(toCSSCustomIdentValue(value)->value());
} else if (state.document().settings()) {
- genericFamily = convertGenericFamily(primitiveValue->getValueID());
+ genericFamily = convertGenericFamily(toCSSPrimitiveValue(value)->getValueID());
familyName = state.fontBuilder().genericFontFamilyName(genericFamily);
}
@@ -155,7 +154,7 @@ FontDescription::FamilyDescription StyleBuilderConverter::convertFontFamily(Styl
FontDescription::GenericFamilyType genericFamily = FontDescription::NoFamily;
AtomicString familyName;
- if (!convertFontFamilyName(state, toCSSPrimitiveValue(family.get()), genericFamily, familyName))
+ if (!convertFontFamilyName(state, family.get(), genericFamily, familyName))
continue;
if (!currFamily) {
@@ -397,16 +396,15 @@ GridPosition StyleBuilderConverter::convertGridPosition(StyleResolverState&, CSS
GridPosition position;
- if (value->isPrimitiveValue()) {
- CSSPrimitiveValue* primitiveValue = toCSSPrimitiveValue(value);
+ if (value->isCustomIdentValue()) {
// We translate <custom-ident> to <string> during parsing as it
// makes handling it more simple.
- if (primitiveValue->isCustomIdent()) {
- position.setNamedGridArea(primitiveValue->getStringValue());
- return position;
- }
+ position.setNamedGridArea(toCSSCustomIdentValue(value)->value());
+ return position;
+ }
- ASSERT(primitiveValue->getValueID() == CSSValueAuto);
+ if (value->isPrimitiveValue()) {
+ ASSERT(toCSSPrimitiveValue(value)->getValueID() == CSSValueAuto);
return position;
}
@@ -419,21 +417,21 @@ GridPosition StyleBuilderConverter::convertGridPosition(StyleResolverState&, CSS
String gridLineName;
auto it = values->begin();
- CSSPrimitiveValue* currentValue = toCSSPrimitiveValue(it->get());
- if (currentValue->getValueID() == CSSValueSpan) {
+ CSSValue* currentValue = it->get();
+ if (currentValue->isPrimitiveValue() && toCSSPrimitiveValue(currentValue)->getValueID() == CSSValueSpan) {
isSpanPosition = true;
++it;
- currentValue = it != values->end() ? toCSSPrimitiveValue(it->get()) : nullptr;
+ currentValue = it != values->end() ? it->get() : nullptr;
}
- if (currentValue && currentValue->isNumber()) {
- gridLineNumber = currentValue->getIntValue();
+ if (currentValue && currentValue->isPrimitiveValue() && toCSSPrimitiveValue(currentValue)->isNumber()) {
+ gridLineNumber = toCSSPrimitiveValue(currentValue)->getIntValue();
++it;
- currentValue = it != values->end() ? toCSSPrimitiveValue(it->get()) : nullptr;
+ currentValue = it != values->end() ? it->get() : nullptr;
}
- if (currentValue && currentValue->isCustomIdent()) {
- gridLineName = currentValue->getStringValue();
+ if (currentValue && currentValue->isCustomIdentValue()) {
+ gridLineName = toCSSCustomIdentValue(currentValue)->value();
++it;
}
@@ -469,8 +467,7 @@ void StyleBuilderConverter::convertGridTrackList(CSSValue* value, Vector<GridTra
for (auto& currValue : *toCSSValueList(value)) {
if (currValue->isGridLineNamesValue()) {
for (auto& namedGridLineValue : toCSSGridLineNamesValue(*currValue)) {
- ASSERT(toCSSPrimitiveValue(namedGridLineValue.get())->isCustomIdent());
- String namedGridLine = toCSSPrimitiveValue(namedGridLineValue.get())->getStringValue();
+ String namedGridLine = toCSSCustomIdentValue(namedGridLineValue.get())->value();
NamedGridLinesMap::AddResult result = namedGridLines.add(namedGridLine, Vector<size_t>());
result.storedValue->value.append(currentNamedGridLine);
OrderedNamedGridLines::AddResult orderedInsertionResult = orderedNamedGridLines.add(currentNamedGridLine, Vector<String>());
@@ -731,10 +728,8 @@ PassRefPtr<QuotesData> StyleBuilderConverter::convertQuotes(StyleResolverState&,
for (size_t i = 0; i < list->length(); i += 2) {
CSSValue* first = list->item(i);
CSSValue* second = list->item(i + 1);
- ASSERT(toCSSPrimitiveValue(first)->isString());
- ASSERT(toCSSPrimitiveValue(second)->isString());
- String startQuote = toCSSPrimitiveValue(first)->getStringValue();
- String endQuote = toCSSPrimitiveValue(second)->getStringValue();
+ String startQuote = toCSSStringValue(first)->value();
+ String endQuote = toCSSStringValue(second)->value();
quotes->addPair(std::make_pair(startQuote, endQuote));
}
return quotes.release();

Powered by Google App Engine
This is Rietveld 408576698