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

Unified Diff: third_party/WebKit/Source/core/css/StylePropertySerializer.cpp

Issue 2228313002: Make a function to query whether a CSSPropertyID is valid and whether it has a name. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@asan
Patch Set: Adjust animation dchecks Created 4 years, 4 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: third_party/WebKit/Source/core/css/StylePropertySerializer.cpp
diff --git a/third_party/WebKit/Source/core/css/StylePropertySerializer.cpp b/third_party/WebKit/Source/core/css/StylePropertySerializer.cpp
index 3b86029892426898b1b228412e1200b7cff64270..0982f1f872c89842ec803e0f9e41b99b50ad958d 100644
--- a/third_party/WebKit/Source/core/css/StylePropertySerializer.cpp
+++ b/third_party/WebKit/Source/core/css/StylePropertySerializer.cpp
@@ -55,7 +55,7 @@ StylePropertySerializer::StylePropertySetForSerializer::StylePropertySetForSeria
continue;
m_needToExpandAll = true;
}
- if (property.id() < firstCSSProperty || property.id() > lastCSSProperty)
+ if (!propertyHasName(property.id()))
continue;
m_longhandPropertyUsed.set(property.id() - firstCSSProperty);
}
@@ -79,10 +79,10 @@ StylePropertySerializer::PropertyValueForSerializer StylePropertySerializer::Sty
return StylePropertySerializer::PropertyValueForSerializer(m_propertySet->propertyAt(index));
CSSPropertyID propertyID = static_cast<CSSPropertyID>(index + firstCSSProperty);
- ASSERT(firstCSSProperty <= propertyID && propertyID <= lastCSSProperty);
+ DCHECK(propertyHasName(propertyID));
if (m_longhandPropertyUsed.test(index)) {
int index = m_propertySet->findPropertyIndex(propertyID);
- ASSERT(index != -1);
+ DCHECK_NE(index, -1);
return StylePropertySerializer::PropertyValueForSerializer(m_propertySet->propertyAt(index));
}
@@ -102,13 +102,13 @@ bool StylePropertySerializer::StylePropertySetForSerializer::shouldProcessProper
StylePropertySet::PropertyReference property = m_propertySet->propertyAt(index);
if (property.id() == CSSPropertyAll || !CSSProperty::isAffectedByAllProperty(property.id()))
return true;
- if (property.id() < firstCSSProperty || property.id() > lastCSSProperty)
+ if (!propertyHasName(property.id()))
return false;
return m_longhandPropertyUsed.test(property.id() - firstCSSProperty);
}
CSSPropertyID propertyID = static_cast<CSSPropertyID>(index + firstCSSProperty);
- ASSERT(firstCSSProperty <= propertyID && propertyID <= lastCSSProperty);
+ DCHECK(propertyHasName(propertyID));
// Since "all" is expanded, we don't need to process "all".
// We should not process expanded shorthands (e.g. font, background,
@@ -177,7 +177,7 @@ StylePropertySerializer::StylePropertySerializer(const StylePropertySet& propert
String StylePropertySerializer::getCustomPropertyText(const PropertyValueForSerializer& property, bool isNotFirstDecl) const
{
- ASSERT(property.id() == CSSPropertyVariable);
+ DCHECK_EQ(property.id(), CSSPropertyVariable);
StringBuilder result;
if (isNotFirstDecl)
result.append(' ');
@@ -234,10 +234,10 @@ String StylePropertySerializer::asText() const
StylePropertySerializer::PropertyValueForSerializer property = m_propertySet.propertyAt(n);
CSSPropertyID propertyID = property.id();
// Only enabled properties should be part of the style.
- ASSERT(CSSPropertyMetadata::isEnabledProperty(propertyID));
+ DCHECK(CSSPropertyMetadata::isEnabledProperty(propertyID));
// Shorthands with variable references are not expanded at parse time
// and hence may still be observed during serialization.
- ASSERT(!isShorthandProperty(propertyID) || property.value()->isVariableReferenceValue());
+ DCHECK(!isShorthandProperty(propertyID) || property.value()->isVariableReferenceValue());
switch (propertyID) {
case CSSPropertyVariable:
@@ -303,7 +303,7 @@ String StylePropertySerializer::asText() const
result.append(getPropertyText(propertyID, property.value()->cssText(), property.isImportant(), numDecls++));
}
- ASSERT(!numDecls ^ !result.isEmpty());
+ DCHECK(!numDecls ^ !result.isEmpty());
return result.toString();
}
@@ -525,7 +525,7 @@ String StylePropertySerializer::borderSpacingValue(const StylePropertyShorthand&
void StylePropertySerializer::appendFontLonghandValueIfNotNormal(CSSPropertyID propertyID, StringBuilder& result) const
{
int foundPropertyIndex = m_propertySet.findPropertyIndex(propertyID);
- ASSERT(foundPropertyIndex != -1);
+ DCHECK_NE(foundPropertyIndex, -1);
const CSSValue* val = m_propertySet.propertyAt(foundPropertyIndex).value();
if (val->isPrimitiveValue() && toCSSPrimitiveValue(val)->getValueID() == CSSValueNormal)
@@ -547,7 +547,7 @@ void StylePropertySerializer::appendFontLonghandValueIfNotNormal(CSSPropertyID p
prefix = '/';
break;
default:
- ASSERT_NOT_REACHED();
+ NOTREACHED();
}
if (prefix && !result.isEmpty())
@@ -724,7 +724,7 @@ String StylePropertySerializer::getLayeredShorthandValue(const StylePropertyShor
// Special case for background-repeat.
if ((propertyIndex < size - 1 && m_propertySet.isPropertyImplicit(property))
&& (property == CSSPropertyBackgroundRepeatX || property == CSSPropertyWebkitMaskRepeatX)) {
- ASSERT(shorthand.properties()[propertyIndex + 1] == CSSPropertyBackgroundRepeatY
+ DCHECK(shorthand.properties()[propertyIndex + 1] == CSSPropertyBackgroundRepeatY
|| shorthand.properties()[propertyIndex + 1] == CSSPropertyWebkitMaskRepeatY);
const CSSValue& yValue = values[propertyIndex + 1]->isValueList() ?
toCSSValueList(values[propertyIndex + 1])->item(layer) : *values[propertyIndex + 1];

Powered by Google App Engine
This is Rietveld 408576698