Log Message
Don't use CSSOM's CSSValue.cssValueType internally in WebCore. <http://webkit.org/b/71679>
Reviewed by Darin Adler. Swap out cssValueType() usage for isPrimitiveValue(), isInitialValue() and isInheritedValue() to increase code clarity. The plan is to turn cssValueType() into a computed value based on the CSSValue subclass (coming soon to <http://webkit.org/b/71668>.) This is a clean-up in preparation for that. * bindings/js/JSCSSStyleDeclarationCustom.cpp: (WebCore::JSCSSStyleDeclaration::nameGetter): * bindings/v8/custom/V8CSSStyleDeclarationCustom.cpp: (WebCore::V8CSSStyleDeclaration::namedPropertyGetter): * css/CSSInheritedValue.h: (WebCore::CSSInheritedValue::isInheritedValue): * css/CSSInitialValue.h: (WebCore::CSSInitialValue::isInitialValue): * css/CSSParser.cpp: (WebCore::CSSParser::parseColor): * css/CSSStyleSelector.cpp: (WebCore::CSSStyleSelector::applyDeclaration): (WebCore::CSSStyleSelector::applyProperty): (WebCore::CSSStyleSelector::mapFillAttachment): (WebCore::CSSStyleSelector::mapFillClip): (WebCore::CSSStyleSelector::mapFillComposite): (WebCore::CSSStyleSelector::mapFillOrigin): (WebCore::CSSStyleSelector::mapFillImage): (WebCore::CSSStyleSelector::mapFillRepeatX): (WebCore::CSSStyleSelector::mapFillRepeatY): (WebCore::CSSStyleSelector::mapFillSize): (WebCore::CSSStyleSelector::mapFillXPosition): (WebCore::CSSStyleSelector::mapFillYPosition): (WebCore::CSSStyleSelector::mapAnimationDelay): (WebCore::CSSStyleSelector::mapAnimationDirection): (WebCore::CSSStyleSelector::mapAnimationDuration): (WebCore::CSSStyleSelector::mapAnimationFillMode): (WebCore::CSSStyleSelector::mapAnimationIterationCount): (WebCore::CSSStyleSelector::mapAnimationName): (WebCore::CSSStyleSelector::mapAnimationPlayState): (WebCore::CSSStyleSelector::mapAnimationProperty): (WebCore::CSSStyleSelector::mapAnimationTimingFunction): * css/CSSValue.h: (WebCore::CSSValue::isInheritedValue): (WebCore::CSSValue::isInitialValue): * css/SVGCSSStyleSelector.cpp: (WebCore::CSSStyleSelector::applySVGProperty): * editing/EditingStyle.cpp: (WebCore::EditingStyle::extractFontSizeDelta): (WebCore::EditingStyle::mergeStyleFromRulesForSerialization):
Modified Paths
- trunk/Source/WebCore/ChangeLog
- trunk/Source/WebCore/bindings/js/JSCSSStyleDeclarationCustom.cpp
- trunk/Source/WebCore/bindings/v8/custom/V8CSSStyleDeclarationCustom.cpp
- trunk/Source/WebCore/css/CSSInheritedValue.h
- trunk/Source/WebCore/css/CSSInitialValue.h
- trunk/Source/WebCore/css/CSSParser.cpp
- trunk/Source/WebCore/css/CSSStyleSelector.cpp
- trunk/Source/WebCore/css/CSSValue.h
- trunk/Source/WebCore/css/SVGCSSStyleSelector.cpp
- trunk/Source/WebCore/editing/EditingStyle.cpp
Diff
Modified: trunk/Source/WebCore/ChangeLog (99449 => 99450)
--- trunk/Source/WebCore/ChangeLog 2011-11-07 19:20:40 UTC (rev 99449)
+++ trunk/Source/WebCore/ChangeLog 2011-11-07 19:20:59 UTC (rev 99450)
@@ -1,3 +1,58 @@
+2011-11-07 Andreas Kling <[email protected]>
+
+ Don't use CSSOM's CSSValue.cssValueType internally in WebCore.
+ <http://webkit.org/b/71679>
+
+ Reviewed by Darin Adler.
+
+ Swap out cssValueType() usage for isPrimitiveValue(), isInitialValue()
+ and isInheritedValue() to increase code clarity.
+
+ The plan is to turn cssValueType() into a computed value based on the
+ CSSValue subclass (coming soon to <http://webkit.org/b/71668>.)
+ This is a clean-up in preparation for that.
+
+ * bindings/js/JSCSSStyleDeclarationCustom.cpp:
+ (WebCore::JSCSSStyleDeclaration::nameGetter):
+ * bindings/v8/custom/V8CSSStyleDeclarationCustom.cpp:
+ (WebCore::V8CSSStyleDeclaration::namedPropertyGetter):
+ * css/CSSInheritedValue.h:
+ (WebCore::CSSInheritedValue::isInheritedValue):
+ * css/CSSInitialValue.h:
+ (WebCore::CSSInitialValue::isInitialValue):
+ * css/CSSParser.cpp:
+ (WebCore::CSSParser::parseColor):
+ * css/CSSStyleSelector.cpp:
+ (WebCore::CSSStyleSelector::applyDeclaration):
+ (WebCore::CSSStyleSelector::applyProperty):
+ (WebCore::CSSStyleSelector::mapFillAttachment):
+ (WebCore::CSSStyleSelector::mapFillClip):
+ (WebCore::CSSStyleSelector::mapFillComposite):
+ (WebCore::CSSStyleSelector::mapFillOrigin):
+ (WebCore::CSSStyleSelector::mapFillImage):
+ (WebCore::CSSStyleSelector::mapFillRepeatX):
+ (WebCore::CSSStyleSelector::mapFillRepeatY):
+ (WebCore::CSSStyleSelector::mapFillSize):
+ (WebCore::CSSStyleSelector::mapFillXPosition):
+ (WebCore::CSSStyleSelector::mapFillYPosition):
+ (WebCore::CSSStyleSelector::mapAnimationDelay):
+ (WebCore::CSSStyleSelector::mapAnimationDirection):
+ (WebCore::CSSStyleSelector::mapAnimationDuration):
+ (WebCore::CSSStyleSelector::mapAnimationFillMode):
+ (WebCore::CSSStyleSelector::mapAnimationIterationCount):
+ (WebCore::CSSStyleSelector::mapAnimationName):
+ (WebCore::CSSStyleSelector::mapAnimationPlayState):
+ (WebCore::CSSStyleSelector::mapAnimationProperty):
+ (WebCore::CSSStyleSelector::mapAnimationTimingFunction):
+ * css/CSSValue.h:
+ (WebCore::CSSValue::isInheritedValue):
+ (WebCore::CSSValue::isInitialValue):
+ * css/SVGCSSStyleSelector.cpp:
+ (WebCore::CSSStyleSelector::applySVGProperty):
+ * editing/EditingStyle.cpp:
+ (WebCore::EditingStyle::extractFontSizeDelta):
+ (WebCore::EditingStyle::mergeStyleFromRulesForSerialization):
+
2011-11-07 Sheriff Bot <[email protected]>
Unreviewed, rolling out r99432.
Modified: trunk/Source/WebCore/bindings/js/JSCSSStyleDeclarationCustom.cpp (99449 => 99450)
--- trunk/Source/WebCore/bindings/js/JSCSSStyleDeclarationCustom.cpp 2011-11-07 19:20:40 UTC (rev 99449)
+++ trunk/Source/WebCore/bindings/js/JSCSSStyleDeclarationCustom.cpp 2011-11-07 19:20:59 UTC (rev 99450)
@@ -154,7 +154,7 @@
String prop = cssPropertyName(propertyName, &pixelOrPos);
RefPtr<CSSValue> v = thisObj->impl()->getPropertyCSSValue(prop);
if (v) {
- if (pixelOrPos && v->cssValueType() == CSSValue::CSS_PRIMITIVE_VALUE)
+ if (pixelOrPos && v->isPrimitiveValue())
return jsNumber(static_pointer_cast<CSSPrimitiveValue>(v)->getFloatValue(CSSPrimitiveValue::CSS_PX));
return jsStringOrNull(exec, v->cssText());
}
Modified: trunk/Source/WebCore/bindings/v8/custom/V8CSSStyleDeclarationCustom.cpp (99449 => 99450)
--- trunk/Source/WebCore/bindings/v8/custom/V8CSSStyleDeclarationCustom.cpp 2011-11-07 19:20:40 UTC (rev 99449)
+++ trunk/Source/WebCore/bindings/v8/custom/V8CSSStyleDeclarationCustom.cpp 2011-11-07 19:20:59 UTC (rev 99450)
@@ -171,7 +171,7 @@
RefPtr<CSSValue> cssValue = imp->getPropertyCSSValue(propInfo->propID);
if (cssValue) {
if (propInfo->hadPixelOrPosPrefix &&
- cssValue->cssValueType() == CSSValue::CSS_PRIMITIVE_VALUE) {
+ cssValue->isPrimitiveValue()) {
return v8::Number::New(static_cast<CSSPrimitiveValue*>(
cssValue.get())->getFloatValue(CSSPrimitiveValue::CSS_PX));
}
Modified: trunk/Source/WebCore/css/CSSInheritedValue.h (99449 => 99450)
--- trunk/Source/WebCore/css/CSSInheritedValue.h 2011-11-07 19:20:40 UTC (rev 99449)
+++ trunk/Source/WebCore/css/CSSInheritedValue.h 2011-11-07 19:20:59 UTC (rev 99450)
@@ -40,6 +40,8 @@
: CSSValue(CSS_INHERIT)
{
}
+
+ virtual bool isInheritedValue() const { return true; }
};
} // namespace WebCore
Modified: trunk/Source/WebCore/css/CSSInitialValue.h (99449 => 99450)
--- trunk/Source/WebCore/css/CSSInitialValue.h 2011-11-07 19:20:40 UTC (rev 99449)
+++ trunk/Source/WebCore/css/CSSInitialValue.h 2011-11-07 19:20:59 UTC (rev 99450)
@@ -53,6 +53,7 @@
return adoptRef(new CSSInitialValue(implicit));
}
+ virtual bool isInitialValue() const { return true; }
virtual bool isImplicitInitialValue() const { return m_implicit; }
bool m_implicit;
Modified: trunk/Source/WebCore/css/CSSParser.cpp (99449 => 99450)
--- trunk/Source/WebCore/css/CSSParser.cpp 2011-11-07 19:20:40 UTC (rev 99449)
+++ trunk/Source/WebCore/css/CSSParser.cpp 2011-11-07 19:20:59 UTC (rev 99450)
@@ -493,7 +493,7 @@
return false;
CSSValue* value = parser.m_parsedProperties[0]->value();
- if (value->cssValueType() != CSSValue::CSS_PRIMITIVE_VALUE)
+ if (!value->isPrimitiveValue())
return false;
CSSPrimitiveValue* primitiveValue = static_cast<CSSPrimitiveValue*>(value);
Modified: trunk/Source/WebCore/css/CSSStyleSelector.cpp (99449 => 99450)
--- trunk/Source/WebCore/css/CSSStyleSelector.cpp 2011-11-07 19:20:40 UTC (rev 99449)
+++ trunk/Source/WebCore/css/CSSStyleSelector.cpp 2011-11-07 19:20:59 UTC (rev 99450)
@@ -2111,7 +2111,7 @@
if (isImportant != current.isImportant())
continue;
if (inheritedOnly && !current.isInherited()) {
- if (current.value()->cssValueType() != CSSValue::CSS_INHERIT)
+ if (!current.value()->isInheritedValue())
continue;
// If the property value is explicitly inherited, we need to apply further non-inherited properties
// as they might override the value inherited here. This is really per-property but that is
@@ -2475,13 +2475,9 @@
void CSSStyleSelector::applyProperty(int id, CSSValue *value)
{
- Length l;
+ bool isInherit = m_parentNode && value->isInheritedValue();
+ bool isInitial = value->isInitialValue() || (!m_parentNode && value->isInheritedValue());
- unsigned short valueType = value->cssValueType();
-
- bool isInherit = m_parentNode && valueType == CSSValue::CSS_INHERIT;
- bool isInitial = valueType == CSSValue::CSS_INITIAL || (!m_parentNode && valueType == CSSValue::CSS_INHERIT);
-
ASSERT(!isInherit || !isInitial); // isInherit -> !isInitial && isInitial -> !isInherit
if (!applyPropertyToRegularStyle() && (!applyPropertyToVisitedLinkStyle() || !isValidVisitedLinkProperty(id))) {
@@ -3407,7 +3403,8 @@
HANDLE_INHERIT_AND_INITIAL_AND_PRIMITIVE_WITH_VALUE(regionBreakInside, RegionBreakInside, PageBreak)
return;
case CSSPropertyWebkitMarquee:
- if (valueType != CSSValue::CSS_INHERIT || !m_parentNode) return;
+ if (!m_parentNode || !value->isInheritedValue())
+ return;
m_style->setMarqueeDirection(m_parentStyle->marqueeDirection());
m_style->setMarqueeIncrement(m_parentStyle->marqueeIncrement());
m_style->setMarqueeSpeed(m_parentStyle->marqueeSpeed());
@@ -4159,7 +4156,7 @@
void CSSStyleSelector::mapFillAttachment(CSSPropertyID, FillLayer* layer, CSSValue* value)
{
- if (value->cssValueType() == CSSValue::CSS_INITIAL) {
+ if (value->isInitialValue()) {
layer->setAttachment(FillLayer::initialFillAttachment(layer->type()));
return;
}
@@ -4185,7 +4182,7 @@
void CSSStyleSelector::mapFillClip(CSSPropertyID, FillLayer* layer, CSSValue* value)
{
- if (value->cssValueType() == CSSValue::CSS_INITIAL) {
+ if (value->isInitialValue()) {
layer->setClip(FillLayer::initialFillClip(layer->type()));
return;
}
@@ -4199,7 +4196,7 @@
void CSSStyleSelector::mapFillComposite(CSSPropertyID, FillLayer* layer, CSSValue* value)
{
- if (value->cssValueType() == CSSValue::CSS_INITIAL) {
+ if (value->isInitialValue()) {
layer->setComposite(FillLayer::initialFillComposite(layer->type()));
return;
}
@@ -4213,7 +4210,7 @@
void CSSStyleSelector::mapFillOrigin(CSSPropertyID, FillLayer* layer, CSSValue* value)
{
- if (value->cssValueType() == CSSValue::CSS_INITIAL) {
+ if (value->isInitialValue()) {
layer->setOrigin(FillLayer::initialFillOrigin(layer->type()));
return;
}
@@ -4246,7 +4243,7 @@
void CSSStyleSelector::mapFillImage(CSSPropertyID property, FillLayer* layer, CSSValue* value)
{
- if (value->cssValueType() == CSSValue::CSS_INITIAL) {
+ if (value->isInitialValue()) {
layer->setImage(FillLayer::initialFillImage(layer->type()));
return;
}
@@ -4256,7 +4253,7 @@
void CSSStyleSelector::mapFillRepeatX(CSSPropertyID, FillLayer* layer, CSSValue* value)
{
- if (value->cssValueType() == CSSValue::CSS_INITIAL) {
+ if (value->isInitialValue()) {
layer->setRepeatX(FillLayer::initialFillRepeatX(layer->type()));
return;
}
@@ -4270,7 +4267,7 @@
void CSSStyleSelector::mapFillRepeatY(CSSPropertyID, FillLayer* layer, CSSValue* value)
{
- if (value->cssValueType() == CSSValue::CSS_INITIAL) {
+ if (value->isInitialValue()) {
layer->setRepeatY(FillLayer::initialFillRepeatY(layer->type()));
return;
}
@@ -4299,8 +4296,7 @@
LengthSize b = FillLayer::initialFillSizeLength(layer->type());
- if (value->cssValueType() == CSSValue::CSS_INITIAL || primitiveValue->getIdent() == CSSValueContain
- || primitiveValue->getIdent() == CSSValueCover) {
+ if (value->isInitialValue() || primitiveValue->getIdent() == CSSValueContain || primitiveValue->getIdent() == CSSValueCover) {
layer->setSizeLength(b);
return;
}
@@ -4341,7 +4337,7 @@
void CSSStyleSelector::mapFillXPosition(CSSPropertyID, FillLayer* layer, CSSValue* value)
{
- if (value->cssValueType() == CSSValue::CSS_INITIAL) {
+ if (value->isInitialValue()) {
layer->setXPosition(FillLayer::initialFillXPosition(layer->type()));
return;
}
@@ -4365,7 +4361,7 @@
void CSSStyleSelector::mapFillYPosition(CSSPropertyID, FillLayer* layer, CSSValue* value)
{
- if (value->cssValueType() == CSSValue::CSS_INITIAL) {
+ if (value->isInitialValue()) {
layer->setYPosition(FillLayer::initialFillYPosition(layer->type()));
return;
}
@@ -4389,7 +4385,7 @@
void CSSStyleSelector::mapAnimationDelay(Animation* animation, CSSValue* value)
{
- if (value->cssValueType() == CSSValue::CSS_INITIAL) {
+ if (value->isInitialValue()) {
animation->setDelay(Animation::initialAnimationDelay());
return;
}
@@ -4406,7 +4402,7 @@
void CSSStyleSelector::mapAnimationDirection(Animation* layer, CSSValue* value)
{
- if (value->cssValueType() == CSSValue::CSS_INITIAL) {
+ if (value->isInitialValue()) {
layer->setDirection(Animation::initialAnimationDirection());
return;
}
@@ -4420,7 +4416,7 @@
void CSSStyleSelector::mapAnimationDuration(Animation* animation, CSSValue* value)
{
- if (value->cssValueType() == CSSValue::CSS_INITIAL) {
+ if (value->isInitialValue()) {
animation->setDuration(Animation::initialAnimationDuration());
return;
}
@@ -4437,7 +4433,7 @@
void CSSStyleSelector::mapAnimationFillMode(Animation* layer, CSSValue* value)
{
- if (value->cssValueType() == CSSValue::CSS_INITIAL) {
+ if (value->isInitialValue()) {
layer->setFillMode(Animation::initialAnimationFillMode());
return;
}
@@ -4464,7 +4460,7 @@
void CSSStyleSelector::mapAnimationIterationCount(Animation* animation, CSSValue* value)
{
- if (value->cssValueType() == CSSValue::CSS_INITIAL) {
+ if (value->isInitialValue()) {
animation->setIterationCount(Animation::initialAnimationIterationCount());
return;
}
@@ -4481,7 +4477,7 @@
void CSSStyleSelector::mapAnimationName(Animation* layer, CSSValue* value)
{
- if (value->cssValueType() == CSSValue::CSS_INITIAL) {
+ if (value->isInitialValue()) {
layer->setName(Animation::initialAnimationName());
return;
}
@@ -4498,7 +4494,7 @@
void CSSStyleSelector::mapAnimationPlayState(Animation* layer, CSSValue* value)
{
- if (value->cssValueType() == CSSValue::CSS_INITIAL) {
+ if (value->isInitialValue()) {
layer->setPlayState(Animation::initialAnimationPlayState());
return;
}
@@ -4513,7 +4509,7 @@
void CSSStyleSelector::mapAnimationProperty(Animation* animation, CSSValue* value)
{
- if (value->cssValueType() == CSSValue::CSS_INITIAL) {
+ if (value->isInitialValue()) {
animation->setProperty(Animation::initialAnimationProperty());
return;
}
@@ -4532,7 +4528,7 @@
void CSSStyleSelector::mapAnimationTimingFunction(Animation* animation, CSSValue* value)
{
- if (value->cssValueType() == CSSValue::CSS_INITIAL) {
+ if (value->isInitialValue()) {
animation->setTimingFunction(Animation::initialAnimationTimingFunction());
return;
}
Modified: trunk/Source/WebCore/css/CSSValue.h (99449 => 99450)
--- trunk/Source/WebCore/css/CSSValue.h 2011-11-07 19:20:40 UTC (rev 99449)
+++ trunk/Source/WebCore/css/CSSValue.h 2011-11-07 19:20:59 UTC (rev 99450)
@@ -62,6 +62,8 @@
virtual bool isFontValue() const { return false; }
virtual bool isImageGeneratorValue() const { return false; }
virtual bool isImageValue() const { return false; }
+ virtual bool isInheritedValue() const { return false; }
+ virtual bool isInitialValue() const { return false; }
virtual bool isImplicitInitialValue() const { return false; }
virtual bool isPrimitiveValue() const { return false; }
virtual bool isReflectValue() const { return false; }
Modified: trunk/Source/WebCore/css/SVGCSSStyleSelector.cpp (99449 => 99450)
--- trunk/Source/WebCore/css/SVGCSSStyleSelector.cpp 2011-11-07 19:20:40 UTC (rev 99449)
+++ trunk/Source/WebCore/css/SVGCSSStyleSelector.cpp 2011-11-07 19:20:59 UTC (rev 99450)
@@ -110,10 +110,9 @@
primitiveValue = static_cast<CSSPrimitiveValue*>(value);
SVGRenderStyle* svgstyle = m_style->accessSVGStyle();
- unsigned short valueType = value->cssValueType();
- bool isInherit = m_parentNode && valueType == CSSPrimitiveValue::CSS_INHERIT;
- bool isInitial = valueType == CSSPrimitiveValue::CSS_INITIAL || (!m_parentNode && valueType == CSSPrimitiveValue::CSS_INHERIT);
+ bool isInherit = m_parentNode && value->isInheritedValue();
+ bool isInitial = value->isInitialValue() || (!m_parentNode && value->isInheritedValue());
// What follows is a list that maps the CSS properties into their
// corresponding front-end RenderStyle values. Shorthands(e.g. border,
Modified: trunk/Source/WebCore/editing/EditingStyle.cpp (99449 => 99450)
--- trunk/Source/WebCore/editing/EditingStyle.cpp 2011-11-07 19:20:40 UTC (rev 99449)
+++ trunk/Source/WebCore/editing/EditingStyle.cpp 2011-11-07 19:20:59 UTC (rev 99450)
@@ -422,7 +422,7 @@
// Get the adjustment amount out of the style.
RefPtr<CSSValue> value = m_mutableStyle->getPropertyCSSValue(CSSPropertyWebkitFontSizeDelta);
- if (!value || value->cssValueType() != CSSValue::CSS_PRIMITIVE_VALUE)
+ if (!value || !value->isPrimitiveValue())
return;
CSSPrimitiveValue* primitiveValue = static_cast<CSSPrimitiveValue*>(value.get());
@@ -1050,10 +1050,12 @@
for (CSSMutableStyleDeclaration::const_iterator it = m_mutableStyle->begin(); it != end; ++it) {
const CSSProperty& property = *it;
CSSValue* value = property.value();
- if (value->cssValueType() == CSSValue::CSS_PRIMITIVE_VALUE)
- if (static_cast<CSSPrimitiveValue*>(value)->primitiveType() == CSSPrimitiveValue::CSS_PERCENTAGE)
- if (RefPtr<CSSValue> computedPropertyValue = computedStyleForElement->getPropertyCSSValue(property.id()))
- fromComputedStyle->addParsedProperty(CSSProperty(property.id(), computedPropertyValue));
+ if (!value->isPrimitiveValue())
+ continue;
+ if (static_cast<CSSPrimitiveValue*>(value)->primitiveType() == CSSPrimitiveValue::CSS_PERCENTAGE) {
+ if (RefPtr<CSSValue> computedPropertyValue = computedStyleForElement->getPropertyCSSValue(property.id()))
+ fromComputedStyle->addParsedProperty(CSSProperty(property.id(), computedPropertyValue));
+ }
}
}
m_mutableStyle->merge(fromComputedStyle.get());
_______________________________________________ webkit-changes mailing list [email protected] http://lists.webkit.org/mailman/listinfo.cgi/webkit-changes
