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

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: Revert incorrect changes Created 4 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: 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 c067f76c1c233ecc83699205fe30ab7b41faca5f..f41c78e2ef0d35e9c74daf045976e433f1b019a4 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 (!isPropertyIDWithName(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(isPropertyIDWithName(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 (!isPropertyIDWithName(property.id()))
return false;
return m_longhandPropertyUsed.test(property.id() - firstCSSProperty);
}
CSSPropertyID propertyID = static_cast<CSSPropertyID>(index + firstCSSProperty);
- ASSERT(firstCSSProperty <= propertyID && propertyID <= lastCSSProperty);
+ DCHECK(isPropertyIDWithName(propertyID));
// Since "all" is expanded, we don't need to process "all".
// We should not process expanded shorthands (e.g. font, background,
@@ -157,7 +157,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(' ');
@@ -214,10 +214,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:
@@ -283,7 +283,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();
}
@@ -505,7 +505,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)
@@ -527,7 +527,7 @@ void StylePropertySerializer::appendFontLonghandValueIfNotNormal(CSSPropertyID p
prefix = '/';
break;
default:
- ASSERT_NOT_REACHED();
+ NOTREACHED();
}
if (prefix && !result.isEmpty())
@@ -704,7 +704,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