diff options
Diffstat (limited to 'Source/WebCore/css/CSSStyleDeclaration.cpp')
-rw-r--r-- | Source/WebCore/css/CSSStyleDeclaration.cpp | 33 |
1 files changed, 30 insertions, 3 deletions
diff --git a/Source/WebCore/css/CSSStyleDeclaration.cpp b/Source/WebCore/css/CSSStyleDeclaration.cpp index 422dd0d..67dc6e0 100644 --- a/Source/WebCore/css/CSSStyleDeclaration.cpp +++ b/Source/WebCore/css/CSSStyleDeclaration.cpp @@ -22,10 +22,13 @@ #include "CSSStyleDeclaration.h" #include "CSSMutableStyleDeclaration.h" +#include "CSSMutableValue.h" #include "CSSParser.h" #include "CSSProperty.h" #include "CSSPropertyNames.h" #include "CSSRule.h" +#include "Node.h" +#include "SVGElement.h" #include <wtf/ASCIICType.h> using namespace WTF; @@ -42,7 +45,28 @@ PassRefPtr<CSSValue> CSSStyleDeclaration::getPropertyCSSValue(const String& prop int propID = cssPropertyID(propertyName); if (!propID) return 0; - return getPropertyCSSValue(propID); + + // Short-cut, not involving any change to the refcount. + if (!isMutableStyleDeclaration()) + return getPropertyCSSValue(propID); + + // Slow path. + RefPtr<CSSValue> value = getPropertyCSSValue(propID); + if (!value || !value->isMutableValue()) + return value.release(); + + Node* node = static_cast<CSSMutableStyleDeclaration*>(this)->node(); + if (!node || !node->isStyledElement()) + return value.release(); + + Node* associatedNode = static_cast<CSSMutableValue*>(value.get())->node(); + if (associatedNode) { + ASSERT(associatedNode == node); + return value.release(); + } + + static_cast<CSSMutableValue*>(value.get())->setNode(node); + return value.release(); } String CSSStyleDeclaration::getPropertyValue(const String &propertyName) @@ -83,10 +107,13 @@ bool CSSStyleDeclaration::isPropertyImplicit(const String& propertyName) void CSSStyleDeclaration::setProperty(const String& propertyName, const String& value, ExceptionCode& ec) { size_t important = value.find("!important", 0, false); + int propertyID = cssPropertyID(propertyName); + if (!propertyID) + return; if (important == notFound) - setProperty(propertyName, value, "", ec); + setProperty(propertyID, value, false, ec); else - setProperty(propertyName, value.left(important - 1), "important", ec); + setProperty(propertyID, value.left(important - 1), true, ec); } void CSSStyleDeclaration::setProperty(const String& propertyName, const String& value, const String& priority, ExceptionCode& ec) |