Reduce non-CSSOM API of CSSStyleDeclaration
authorantti@apple.com <antti@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Mon, 30 Jan 2012 16:46:56 +0000 (16:46 +0000)
committerantti@apple.com <antti@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Mon, 30 Jan 2012 16:46:56 +0000 (16:46 +0000)
https://bugs.webkit.org/show_bug.cgi?id=77299

Reviewed by Andreas Kling.

../WebCore:

CSSStyleDeclaration should expose the CSSOM API only. Subclasses should expose the internal API only.
This will move us closer to being able to split the CSSOM API from the internal implementation.

- Make CSSStyleDeclaration CSSOM functions virtual, internal functions non-virtual.
- Move implementations to subclasses (CSSComputedStyleDeclaration, CSSMutableStyleDeclaration).
- Make CSSOM functions in the subclasses private (making it harder to invoke them internally).
- Switch a bunch of places to use internal API instead of CSSOM.

* bindings/v8/custom/V8CSSStyleDeclarationCustom.cpp:
(WebCore::V8CSSStyleDeclaration::namedPropertyGetter):
(WebCore::V8CSSStyleDeclaration::namedPropertySetter):

    Switch to *Internal versions of the CSSOM functions.

* css/CSSComputedStyleDeclaration.cpp:
(WebCore):
(WebCore::CSSComputedStyleDeclaration::length):
(WebCore::CSSComputedStyleDeclaration::cssPropertyMatches):
(WebCore::CSSComputedStyleDeclaration::copyPropertiesInSet):

    Move copyPropertiesInSet to subclasses, devirtualize.

(WebCore::CSSComputedStyleDeclaration::getPropertyCSSValue):
(WebCore::CSSComputedStyleDeclaration::getPropertyValue):
(WebCore::CSSComputedStyleDeclaration::getPropertyPriority):
(WebCore::CSSComputedStyleDeclaration::getPropertyShorthand):
(WebCore::CSSComputedStyleDeclaration::isPropertyImplicit):
(WebCore::CSSComputedStyleDeclaration::setProperty):
(WebCore::CSSComputedStyleDeclaration::removeProperty):
* css/CSSComputedStyleDeclaration.h:
(CSSComputedStyleDeclaration):
* css/CSSFontFaceRule.cpp:
(WebCore::CSSFontFaceRule::cssText):
* css/CSSMutableStyleDeclaration.cpp:
(WebCore::CSSMutableStyleDeclaration::length):
(WebCore::CSSMutableStyleDeclaration::asText):
(WebCore::CSSMutableStyleDeclaration::cssText):
(WebCore):
(WebCore::CSSMutableStyleDeclaration::getPropertyCSSValue):
(WebCore::CSSMutableStyleDeclaration::getPropertyValue):
(WebCore::CSSMutableStyleDeclaration::getPropertyPriority):
(WebCore::CSSMutableStyleDeclaration::getPropertyShorthand):
(WebCore::CSSMutableStyleDeclaration::isPropertyImplicit):
(WebCore::CSSMutableStyleDeclaration::setProperty):
(WebCore::CSSMutableStyleDeclaration::removeProperty):
(WebCore::CSSMutableStyleDeclaration::copyPropertiesInSet):

    Move copyPropertiesInSet to subclasses, devirtualize.

(WebCore::CSSMutableStyleDeclaration::cssPropertyMatches):
(WebCore::CSSMutableStyleDeclaration::removeEquivalentProperties):

    Move diff() to CSSMutableStyleDeclaration, rename to removeEquivalentProperties, switch to mutate
    this object instead of the argument object.

* css/CSSMutableStyleDeclaration.h:
(CSSMutableStyleDeclaration):
(WebCore::CSSMutableStyleDeclaration::propertyCount):
(WebCore::CSSMutableStyleDeclaration::isEmpty):
(WebCore::CSSMutableStyleDeclaration::propertyAt):

    Expose properties and property count internally (iterator should be removed in favor of these).

* css/CSSStyleDeclaration.cpp:
(WebCore):
* css/CSSStyleDeclaration.h:
(CSSStyleDeclaration):
(WebCore::CSSStyleDeclaration::getPropertyCSSValueInternal):
(WebCore::CSSStyleDeclaration::getPropertyValueInternal):
(WebCore::CSSStyleDeclaration::setPropertyInternal):

    Add *Internal versions of some CSSOM APIs to support some editing and bindings uses.
    These take propertyIDs instead of strings names.

* css/CSSStyleRule.cpp:
(WebCore::CSSStyleRule::cssText):
* css/CSSStyleSelector.cpp:
(WebCore::leftToRightDeclaration):
(WebCore::rightToLeftDeclaration):
(WebCore::CSSStyleSelector::collectMatchingRulesForList):
(WebCore::CSSStyleSelector::matchPageRulesForList):
* css/WebKitCSSKeyframeRule.cpp:
(WebCore::WebKitCSSKeyframeRule::cssText):
* dom/StyledElement.cpp:
(WebCore::StyledElement::updateStyleAttribute):
* editing/ApplyStyleCommand.cpp:
(WebCore::ApplyStyleCommand::applyRelativeFontStyleChange):
(WebCore::ApplyStyleCommand::removeEmbeddingUpToEnclosingBlock):
(WebCore::ApplyStyleCommand::applyInlineStyleToNodeRange):
(WebCore::ApplyStyleCommand::applyInlineStyleToPushDown):
(WebCore::ApplyStyleCommand::addBlockStyle):
(WebCore::ApplyStyleCommand::addInlineStyleIfNeeded):
* editing/EditingStyle.cpp:
():
(WebCore::copyEditingProperties):
(WebCore):
(WebCore::propertyCSSValue):
(WebCore::getRGBAFontColor):
(WebCore::EditingStyle::overrideWithStyle):
(WebCore::EditingStyle::removeStyleAddedByNode):
(WebCore::EditingStyle::removeStyleConflictingWithStyleOfNode):
(WebCore::EditingStyle::triStateOfStyle):
(WebCore::EditingStyle::styleIsPresentInComputedStyleOfNode):
(WebCore::EditingStyle::prepareToApplyAt):
(WebCore::removePropertiesInStyle):
(WebCore::EditingStyle::removeStyleFromRulesAndContext):
(WebCore::EditingStyle::removePropertiesInElementDefaultStyle):
(WebCore::StyleChange::StyleChange):
(WebCore::fontWeightIsBold):
(WebCore::getPropertiesNotIn):
(WebCore::getIdentifierValue):
(WebCore::hasTransparentBackgroundColor):
* editing/EditingStyle.h:

    Adapt to changes.

(WebCore):
* editing/ReplaceSelectionCommand.cpp:
(WebCore::ReplaceSelectionCommand::removeRedundantStylesAndKeepStyleSpanInline):
(WebCore::handleStyleSpansBeforeInsertion):
(WebCore::ReplaceSelectionCommand::handleStyleSpans):
* editing/mac/EditorMac.mm:
(WebCore::styleForSelectionStart):
* editing/markup.cpp:
(WebCore::StyledMarkupAccumulator::appendStyleNodeOpenTag):
(WebCore::StyledMarkupAccumulator::appendElement):
* html/ImageDocument.cpp:
(WebCore::ImageDocument::resizeImageToFit):
(WebCore::ImageDocument::restoreImageSize):
(WebCore::ImageDocument::windowSizeChanged):
* html/canvas/CanvasRenderingContext2D.cpp:
(WebCore::CanvasRenderingContext2D::setFont):
* html/canvas/CanvasStyle.cpp:
(WebCore::currentColor):
* inspector/InspectorStyleSheet.cpp:
(WebCore::InspectorStyleSheet::revalidateStyle):
* page/PageSerializer.cpp:
(WebCore::PageSerializer::retrieveResourcesForCSSDeclaration):
* rendering/RenderTreeAsText.cpp:
(WebCore::isEmptyOrUnstyledAppleStyleSpan):
* svg/SVGStyledElement.cpp:
(WebCore::SVGStyledElement::getPresentationAttribute):

../WebKit/qt:

* Api/qwebelement.cpp:
(QWebElement::styleProperty):
(QWebElement::setStyleProperty):
* WebCoreSupport/DumpRenderTreeSupportQt.cpp:
(DumpRenderTreeSupportQt::computedStyleIncludingVisitedInfo):

git-svn-id: https://svn.webkit.org/repository/webkit/trunk@106247 268f45cc-cd09-0410-ab3c-d52691b4dbfc

32 files changed:
Source/WebCore/ChangeLog
Source/WebCore/bindings/v8/custom/V8CSSStyleDeclarationCustom.cpp
Source/WebCore/css/CSSComputedStyleDeclaration.cpp
Source/WebCore/css/CSSComputedStyleDeclaration.h
Source/WebCore/css/CSSFontFaceRule.cpp
Source/WebCore/css/CSSMutableStyleDeclaration.cpp
Source/WebCore/css/CSSMutableStyleDeclaration.h
Source/WebCore/css/CSSStyleDeclaration.cpp
Source/WebCore/css/CSSStyleDeclaration.h
Source/WebCore/css/CSSStyleRule.cpp
Source/WebCore/css/CSSStyleSelector.cpp
Source/WebCore/css/WebKitCSSKeyframeRule.cpp
Source/WebCore/dom/StyledElement.cpp
Source/WebCore/editing/ApplyStyleCommand.cpp
Source/WebCore/editing/EditingStyle.cpp
Source/WebCore/editing/EditingStyle.h
Source/WebCore/editing/Editor.cpp
Source/WebCore/editing/ReplaceSelectionCommand.cpp
Source/WebCore/editing/mac/EditorMac.mm
Source/WebCore/editing/markup.cpp
Source/WebCore/html/ImageDocument.cpp
Source/WebCore/html/canvas/CanvasRenderingContext2D.cpp
Source/WebCore/html/canvas/CanvasStyle.cpp
Source/WebCore/inspector/InspectorStyleSheet.cpp
Source/WebCore/page/DragController.cpp
Source/WebCore/page/PageSerializer.cpp
Source/WebCore/rendering/RenderLayer.cpp
Source/WebCore/rendering/RenderTreeAsText.cpp
Source/WebCore/svg/SVGStyledElement.cpp
Source/WebKit/qt/Api/qwebelement.cpp
Source/WebKit/qt/ChangeLog
Source/WebKit/qt/WebCoreSupport/DumpRenderTreeSupportQt.cpp

index 44c4323..1cf3947 100644 (file)
@@ -1,3 +1,153 @@
+2012-01-29  Antti Koivisto  <antti@apple.com>
+
+        Reduce non-CSSOM API of CSSStyleDeclaration
+        https://bugs.webkit.org/show_bug.cgi?id=77299
+
+        Reviewed by Andreas Kling.
+
+        CSSStyleDeclaration should expose the CSSOM API only. Subclasses should expose the internal API only. 
+        This will move us closer to being able to split the CSSOM API from the internal implementation.
+        
+        - Make CSSStyleDeclaration CSSOM functions virtual, internal functions non-virtual.
+        - Move implementations to subclasses (CSSComputedStyleDeclaration, CSSMutableStyleDeclaration).
+        - Make CSSOM functions in the subclasses private (making it harder to invoke them internally).
+        - Switch a bunch of places to use internal API instead of CSSOM.
+
+        * bindings/v8/custom/V8CSSStyleDeclarationCustom.cpp:
+        (WebCore::V8CSSStyleDeclaration::namedPropertyGetter):
+        (WebCore::V8CSSStyleDeclaration::namedPropertySetter):
+        
+            Switch to *Internal versions of the CSSOM functions.
+        
+        * css/CSSComputedStyleDeclaration.cpp:
+        (WebCore):
+        (WebCore::CSSComputedStyleDeclaration::length):
+        (WebCore::CSSComputedStyleDeclaration::cssPropertyMatches):
+        (WebCore::CSSComputedStyleDeclaration::copyPropertiesInSet):
+        
+            Move copyPropertiesInSet to subclasses, devirtualize.
+            
+        (WebCore::CSSComputedStyleDeclaration::getPropertyCSSValue):
+        (WebCore::CSSComputedStyleDeclaration::getPropertyValue):
+        (WebCore::CSSComputedStyleDeclaration::getPropertyPriority):
+        (WebCore::CSSComputedStyleDeclaration::getPropertyShorthand):
+        (WebCore::CSSComputedStyleDeclaration::isPropertyImplicit):
+        (WebCore::CSSComputedStyleDeclaration::setProperty):
+        (WebCore::CSSComputedStyleDeclaration::removeProperty):
+        * css/CSSComputedStyleDeclaration.h:
+        (CSSComputedStyleDeclaration):
+        * css/CSSFontFaceRule.cpp:
+        (WebCore::CSSFontFaceRule::cssText):
+        * css/CSSMutableStyleDeclaration.cpp:
+        (WebCore::CSSMutableStyleDeclaration::length):
+        (WebCore::CSSMutableStyleDeclaration::asText):
+        (WebCore::CSSMutableStyleDeclaration::cssText):
+        (WebCore):
+        (WebCore::CSSMutableStyleDeclaration::getPropertyCSSValue):
+        (WebCore::CSSMutableStyleDeclaration::getPropertyValue):
+        (WebCore::CSSMutableStyleDeclaration::getPropertyPriority):
+        (WebCore::CSSMutableStyleDeclaration::getPropertyShorthand):
+        (WebCore::CSSMutableStyleDeclaration::isPropertyImplicit):
+        (WebCore::CSSMutableStyleDeclaration::setProperty):
+        (WebCore::CSSMutableStyleDeclaration::removeProperty):
+        (WebCore::CSSMutableStyleDeclaration::copyPropertiesInSet):
+        
+            Move copyPropertiesInSet to subclasses, devirtualize.
+        
+        (WebCore::CSSMutableStyleDeclaration::cssPropertyMatches):
+        (WebCore::CSSMutableStyleDeclaration::removeEquivalentProperties):
+        
+            Move diff() to CSSMutableStyleDeclaration, rename to removeEquivalentProperties, switch to mutate
+            this object instead of the argument object.
+    
+        * css/CSSMutableStyleDeclaration.h:
+        (CSSMutableStyleDeclaration):
+        (WebCore::CSSMutableStyleDeclaration::propertyCount):
+        (WebCore::CSSMutableStyleDeclaration::isEmpty):
+        (WebCore::CSSMutableStyleDeclaration::propertyAt):
+        
+            Expose properties and property count internally (iterator should be removed in favor of these).
+        
+        * css/CSSStyleDeclaration.cpp:
+        (WebCore):
+        * css/CSSStyleDeclaration.h:
+        (CSSStyleDeclaration):
+        (WebCore::CSSStyleDeclaration::getPropertyCSSValueInternal):
+        (WebCore::CSSStyleDeclaration::getPropertyValueInternal):
+        (WebCore::CSSStyleDeclaration::setPropertyInternal):
+        
+            Add *Internal versions of some CSSOM APIs to support some editing and bindings uses.
+            These take propertyIDs instead of strings names.
+
+        * css/CSSStyleRule.cpp:
+        (WebCore::CSSStyleRule::cssText):
+        * css/CSSStyleSelector.cpp:
+        (WebCore::leftToRightDeclaration):
+        (WebCore::rightToLeftDeclaration):
+        (WebCore::CSSStyleSelector::collectMatchingRulesForList):
+        (WebCore::CSSStyleSelector::matchPageRulesForList):
+        * css/WebKitCSSKeyframeRule.cpp:
+        (WebCore::WebKitCSSKeyframeRule::cssText):
+        * dom/StyledElement.cpp:
+        (WebCore::StyledElement::updateStyleAttribute):
+        * editing/ApplyStyleCommand.cpp:
+        (WebCore::ApplyStyleCommand::applyRelativeFontStyleChange):
+        (WebCore::ApplyStyleCommand::removeEmbeddingUpToEnclosingBlock):
+        (WebCore::ApplyStyleCommand::applyInlineStyleToNodeRange):
+        (WebCore::ApplyStyleCommand::applyInlineStyleToPushDown):
+        (WebCore::ApplyStyleCommand::addBlockStyle):
+        (WebCore::ApplyStyleCommand::addInlineStyleIfNeeded):
+        * editing/EditingStyle.cpp:
+        ():
+        (WebCore::copyEditingProperties):
+        (WebCore):
+        (WebCore::propertyCSSValue):
+        (WebCore::getRGBAFontColor):
+        (WebCore::EditingStyle::overrideWithStyle):
+        (WebCore::EditingStyle::removeStyleAddedByNode):
+        (WebCore::EditingStyle::removeStyleConflictingWithStyleOfNode):
+        (WebCore::EditingStyle::triStateOfStyle):
+        (WebCore::EditingStyle::styleIsPresentInComputedStyleOfNode):
+        (WebCore::EditingStyle::prepareToApplyAt):
+        (WebCore::removePropertiesInStyle):
+        (WebCore::EditingStyle::removeStyleFromRulesAndContext):
+        (WebCore::EditingStyle::removePropertiesInElementDefaultStyle):
+        (WebCore::StyleChange::StyleChange):
+        (WebCore::fontWeightIsBold):
+        (WebCore::getPropertiesNotIn):
+        (WebCore::getIdentifierValue):
+        (WebCore::hasTransparentBackgroundColor):
+        * editing/EditingStyle.h:
+        
+            Adapt to changes.
+    
+        (WebCore):
+        * editing/ReplaceSelectionCommand.cpp:
+        (WebCore::ReplaceSelectionCommand::removeRedundantStylesAndKeepStyleSpanInline):
+        (WebCore::handleStyleSpansBeforeInsertion):
+        (WebCore::ReplaceSelectionCommand::handleStyleSpans):
+        * editing/mac/EditorMac.mm:
+        (WebCore::styleForSelectionStart):
+        * editing/markup.cpp:
+        (WebCore::StyledMarkupAccumulator::appendStyleNodeOpenTag):
+        (WebCore::StyledMarkupAccumulator::appendElement):
+        * html/ImageDocument.cpp:
+        (WebCore::ImageDocument::resizeImageToFit):
+        (WebCore::ImageDocument::restoreImageSize):
+        (WebCore::ImageDocument::windowSizeChanged):
+        * html/canvas/CanvasRenderingContext2D.cpp:
+        (WebCore::CanvasRenderingContext2D::setFont):
+        * html/canvas/CanvasStyle.cpp:
+        (WebCore::currentColor):
+        * inspector/InspectorStyleSheet.cpp:
+        (WebCore::InspectorStyleSheet::revalidateStyle):
+        * page/PageSerializer.cpp:
+        (WebCore::PageSerializer::retrieveResourcesForCSSDeclaration):
+        * rendering/RenderTreeAsText.cpp:
+        (WebCore::isEmptyOrUnstyledAppleStyleSpan):
+        * svg/SVGStyledElement.cpp:
+        (WebCore::SVGStyledElement::getPresentationAttribute):
+
 2012-01-30  Pavel Feldman  <pfeldman@google.com>
 
         Web Inspector: protocol validator should fail if one of response fields turns optional
index b3afda5..993bc93 100644 (file)
@@ -202,7 +202,7 @@ v8::Handle<v8::Value> V8CSSStyleDeclaration::namedPropertyGetter(v8::Local<v8::S
         return notHandledByInterceptor();
 
     CSSStyleDeclaration* imp = V8CSSStyleDeclaration::toNative(info.Holder());
-    RefPtr<CSSValue> cssValue = imp->getPropertyCSSValue(propInfo->propID);
+    RefPtr<CSSValue> cssValue = imp->getPropertyCSSValueInternal(static_cast<CSSPropertyID>(propInfo->propID));
     if (cssValue) {
         if (propInfo->hadPixelOrPosPrefix &&
             cssValue->isPrimitiveValue()) {
@@ -212,7 +212,7 @@ v8::Handle<v8::Value> V8CSSStyleDeclaration::namedPropertyGetter(v8::Local<v8::S
         return v8StringOrNull(cssValue->cssText());
     }
 
-    String result = imp->getPropertyValue(propInfo->propID);
+    String result = imp->getPropertyValueInternal(static_cast<CSSPropertyID>(propInfo->propID));
     if (result.isNull())
         result = "";  // convert null to empty string.
 
@@ -232,7 +232,7 @@ v8::Handle<v8::Value> V8CSSStyleDeclaration::namedPropertySetter(v8::Local<v8::S
         propertyValue.append("px");
 
     ExceptionCode ec = 0;
-    imp->setProperty(propInfo->propID, propertyValue, false, ec);
+    imp->setPropertyInternal(static_cast<CSSPropertyID>(propInfo->propID), propertyValue, false, ec);
 
     if (ec)
         throwError(ec);
index e5190df..90f98c8 100644 (file)
@@ -29,6 +29,7 @@
 #include "CSSBorderImage.h"
 #include "CSSLineBoxContainValue.h"
 #include "CSSMutableStyleDeclaration.h"
+#include "CSSParser.h"
 #include "CSSPrimitiveValue.h"
 #include "CSSPrimitiveValueMappings.h"
 #include "CSSProperty.h"
@@ -2475,24 +2476,8 @@ String CSSComputedStyleDeclaration::getPropertyValue(int propertyID) const
     return "";
 }
 
-bool CSSComputedStyleDeclaration::getPropertyPriority(int /*propertyID*/) const
-{
-    // All computed styles have a priority of false (not "important").
-    return false;
-}
-
-String CSSComputedStyleDeclaration::removeProperty(int /*propertyID*/, ExceptionCode& ec)
-{
-    ec = NO_MODIFICATION_ALLOWED_ERR;
-    return String();
-}
 
-void CSSComputedStyleDeclaration::setProperty(int /*propertyID*/, const String& /*value*/, bool /*important*/, ExceptionCode& ec)
-{
-    ec = NO_MODIFICATION_ALLOWED_ERR;
-}
-
-unsigned CSSComputedStyleDeclaration::virtualLength() const
+unsigned CSSComputedStyleDeclaration::length() const
 {
     Node* node = m_node.get();
     if (!node)
@@ -2525,8 +2510,8 @@ bool CSSComputedStyleDeclaration::cssPropertyMatches(const CSSProperty* property
                 return true;
         }
     }
-
-    return CSSStyleDeclaration::cssPropertyMatches(property);
+    RefPtr<CSSValue> value = getPropertyCSSValue(property->id());
+    return value && value->cssText() == property->value()->cssText();
 }
 
 PassRefPtr<CSSMutableStyleDeclaration> CSSComputedStyleDeclaration::copy() const
@@ -2577,4 +2562,74 @@ PassRefPtr<CSSValueList> CSSComputedStyleDeclaration::getCSSPropertyValuesForSid
     return list.release();
 }
 
+PassRefPtr<CSSMutableStyleDeclaration> CSSComputedStyleDeclaration::copyPropertiesInSet(const int* set, unsigned length) const
+{
+    Vector<CSSProperty> list;
+    list.reserveInitialCapacity(length);
+    for (unsigned i = 0; i < length; ++i) {
+        RefPtr<CSSValue> value = getPropertyCSSValue(set[i]);
+        if (value)
+            list.append(CSSProperty(set[i], value.release(), false));
+    }
+    return CSSMutableStyleDeclaration::create(list);
+}
+
+PassRefPtr<CSSValue> CSSComputedStyleDeclaration::getPropertyCSSValue(const String& propertyName)
+{
+    int propertyID = cssPropertyID(propertyName);
+    if (!propertyID)
+        return 0;
+    return getPropertyCSSValue(propertyID);
+}
+
+String CSSComputedStyleDeclaration::getPropertyValue(const String &propertyName)
+{
+    int propertyID = cssPropertyID(propertyName);
+    if (!propertyID)
+        return String();
+    return getPropertyValue(propertyID);
+}
+
+String CSSComputedStyleDeclaration::getPropertyPriority(const String&)
+{
+    // All computed styles have a priority of not "important".
+    return "";
+}
+
+String CSSComputedStyleDeclaration::getPropertyShorthand(const String&)
+{
+    return "";
+}
+
+bool CSSComputedStyleDeclaration::isPropertyImplicit(const String&)
+{
+    return false;
+}
+
+void CSSComputedStyleDeclaration::setProperty(const String&, const String&, const String&, ExceptionCode& ec)
+{
+    ec = NO_MODIFICATION_ALLOWED_ERR;
+}
+
+String CSSComputedStyleDeclaration::removeProperty(const String&, ExceptionCode& ec)
+{
+    ec = NO_MODIFICATION_ALLOWED_ERR;
+    return String();
+}
+    
+PassRefPtr<CSSValue> CSSComputedStyleDeclaration::getPropertyCSSValueInternal(CSSPropertyID propertyID)
+{
+    return getPropertyCSSValue(propertyID);
+}
+
+String CSSComputedStyleDeclaration::getPropertyValueInternal(CSSPropertyID propertyID)
+{
+    return getPropertyValue(propertyID);
+}
+
+void CSSComputedStyleDeclaration::setPropertyInternal(CSSPropertyID, const String&, bool, ExceptionCode& ec)
+{
+    ec = NO_MODIFICATION_ALLOWED_ERR;
+}
+
 } // namespace WebCore
index b7e6864..b44a5cf 100644 (file)
@@ -50,16 +50,9 @@ public:
     friend PassRefPtr<CSSComputedStyleDeclaration> computedStyle(PassRefPtr<Node>, bool allowVisitedStyle, const String& pseudoElementName);
     virtual ~CSSComputedStyleDeclaration();
 
-    virtual String cssText() const;
-
-    virtual unsigned virtualLength() const;
-    virtual String item(unsigned index) const;
-
-    virtual PassRefPtr<CSSValue> getPropertyCSSValue(int propertyID) const;
-    virtual String getPropertyValue(int propertyID) const;
-    virtual bool getPropertyPriority(int propertyID) const;
-    virtual int getPropertyShorthand(int /*propertyID*/) const { return -1; }
-    virtual bool isPropertyImplicit(int /*propertyID*/) const { return false; }
+    PassRefPtr<CSSValue> getPropertyCSSValue(int propertyID) const;
+    String getPropertyValue(int propertyID) const;
+    bool getPropertyPriority(int propertyID) const;
 
     virtual PassRefPtr<CSSMutableStyleDeclaration> copy() const;
     virtual PassRefPtr<CSSMutableStyleDeclaration> makeMutable();
@@ -71,16 +64,28 @@ public:
     PassRefPtr<CSSValue> getSVGPropertyCSSValue(int propertyID, EUpdateLayout) const;
 #endif
 
-protected:
-    virtual bool cssPropertyMatches(const CSSProperty*) const;
+    PassRefPtr<CSSMutableStyleDeclaration> copyPropertiesInSet(const int* set, unsigned length) const;
 
 private:
     CSSComputedStyleDeclaration(PassRefPtr<Node>, bool allowVisitedStyle, const String&);
 
+    // CSSOM functions. Don't make these public.
+    virtual unsigned length() const;
+    virtual String item(unsigned index) const;
+    virtual PassRefPtr<CSSValue> getPropertyCSSValue(const String& propertyName);
+    virtual String getPropertyValue(const String& propertyName);
+    virtual String getPropertyPriority(const String& propertyName);
+    virtual String getPropertyShorthand(const String& propertyName);
+    virtual bool isPropertyImplicit(const String& propertyName);
+    virtual void setProperty(const String& propertyName, const String& value, const String& priority, ExceptionCode&);
+    virtual String removeProperty(const String& propertyName, ExceptionCode&);
+    virtual String cssText() const;
     virtual void setCssText(const String&, ExceptionCode&);
+    virtual PassRefPtr<CSSValue> getPropertyCSSValueInternal(CSSPropertyID);
+    virtual String getPropertyValueInternal(CSSPropertyID);
+    virtual void setPropertyInternal(CSSPropertyID, const String& value, bool important, ExceptionCode&);
 
-    virtual String removeProperty(int propertyID, ExceptionCode&);
-    virtual void setProperty(int propertyId, const String& value, bool important, ExceptionCode&);
+    virtual bool cssPropertyMatches(const CSSProperty*) const;
 
     PassRefPtr<CSSValue> valueForShadow(const ShadowData*, int, RenderStyle*) const;
     PassRefPtr<CSSPrimitiveValue> currentColorOrValidColor(RenderStyle*, const Color&) const;
index 672185f..092f2ae 100644 (file)
@@ -42,7 +42,7 @@ String CSSFontFaceRule::cssText() const
 {
     String result("@font-face");
     result += " { ";
-    result += m_style->cssText();
+    result += m_style->asText();
     result += "}";
     return result;
 }
index 31e4a2e..6ad06e6 100644 (file)
@@ -682,18 +682,6 @@ bool CSSMutableStyleDeclaration::isPropertyImplicit(int propertyID) const
     return property ? property->isImplicit() : false;
 }
 
-void CSSMutableStyleDeclaration::setProperty(int propertyID, const String& value, bool important, ExceptionCode& ec)
-{
-    ec = 0;
-    setProperty(propertyID, value, important, true);
-}
-
-String CSSMutableStyleDeclaration::removeProperty(int propertyID, ExceptionCode& ec)
-{
-    ec = 0;
-    return removeProperty(propertyID, true, true);
-}
-
 bool CSSMutableStyleDeclaration::setProperty(int propertyID, const String& value, bool important, bool notifyChanged)
 {
     ASSERT(!m_iteratorCount);
@@ -826,9 +814,9 @@ void CSSMutableStyleDeclaration::addParsedProperty(const CSSProperty& property)
 #endif
 }
 
-unsigned CSSMutableStyleDeclaration::virtualLength() const
+unsigned CSSMutableStyleDeclaration::length() const
 {
-    return length();
+    return propertyCount();
 }
 
 String CSSMutableStyleDeclaration::item(unsigned i) const
@@ -838,7 +826,7 @@ String CSSMutableStyleDeclaration::item(unsigned i) const
     return getPropertyName(static_cast<CSSPropertyID>(m_properties[i].id()));
 }
 
-String CSSMutableStyleDeclaration::cssText() const
+String CSSMutableStyleDeclaration::asText() const
 {
     String result = "";
 
@@ -1052,4 +1040,119 @@ CSSProperty* CSSMutableStyleDeclaration::findPropertyWithId(int propertyID)
     return 0;
 }
 
+String CSSMutableStyleDeclaration::cssText() const
+{
+    return asText();
+}
+
+PassRefPtr<CSSValue> CSSMutableStyleDeclaration::getPropertyCSSValue(const String& propertyName)
+{
+    int propertyID = cssPropertyID(propertyName);
+    if (!propertyID)
+        return 0;
+    return getPropertyCSSValue(propertyID);
+}
+
+String CSSMutableStyleDeclaration::getPropertyValue(const String &propertyName)
+{
+    int propertyID = cssPropertyID(propertyName);
+    if (!propertyID)
+        return String();
+    return getPropertyValue(propertyID);
+}
+
+String CSSMutableStyleDeclaration::getPropertyPriority(const String& propertyName)
+{
+    int propertyID = cssPropertyID(propertyName);
+    if (!propertyID)
+        return String();
+    return getPropertyPriority(propertyID) ? "important" : "";
+}
+
+String CSSMutableStyleDeclaration::getPropertyShorthand(const String& propertyName)
+{
+    int propertyID = cssPropertyID(propertyName);
+    if (!propertyID)
+        return String();
+    int shorthandID = getPropertyShorthand(propertyID);
+    if (!shorthandID)
+        return String();
+    return getPropertyName(static_cast<CSSPropertyID>(shorthandID));
+}
+
+bool CSSMutableStyleDeclaration::isPropertyImplicit(const String& propertyName)
+{
+    int propertyID = cssPropertyID(propertyName);
+    if (!propertyID)
+        return false;
+    return isPropertyImplicit(propertyID);
+}
+
+void CSSMutableStyleDeclaration::setProperty(const String& propertyName, const String& value, const String& priority, ExceptionCode& ec)
+{
+    int propertyID = cssPropertyID(propertyName);
+    if (!propertyID)
+        return;
+    bool important = priority.find("important", 0, false) != notFound;
+    ec = 0;
+    setProperty(propertyID, value, important, true);
+}
+
+String CSSMutableStyleDeclaration::removeProperty(const String& propertyName, ExceptionCode& ec)
+{
+    int propertyID = cssPropertyID(propertyName);
+    if (!propertyID)
+        return String();
+    ec = 0;
+    return removeProperty(propertyID, true, true);
+}
+
+PassRefPtr<CSSValue> CSSMutableStyleDeclaration::getPropertyCSSValueInternal(CSSPropertyID propertyID)
+{ 
+    return getPropertyCSSValue(propertyID); 
+}
+
+String CSSMutableStyleDeclaration::getPropertyValueInternal(CSSPropertyID propertyID)
+{ 
+    return getPropertyValue(propertyID); 
+}
+
+void CSSMutableStyleDeclaration::setPropertyInternal(CSSPropertyID propertyID, const String& value, bool important, ExceptionCode& ec)
+{ 
+    ec = 0;
+    setProperty(propertyID, value, important, true);
+}
+
+PassRefPtr<CSSMutableStyleDeclaration> CSSMutableStyleDeclaration::copyPropertiesInSet(const int* set, unsigned length) const
+{
+    Vector<CSSProperty> list;
+    list.reserveInitialCapacity(length);
+    for (unsigned i = 0; i < length; ++i) {
+        RefPtr<CSSValue> value = getPropertyCSSValue(set[i]);
+        if (value)
+            list.append(CSSProperty(set[i], value.release(), false));
+    }
+    return CSSMutableStyleDeclaration::create(list);
+}
+
+bool CSSMutableStyleDeclaration::cssPropertyMatches(const CSSProperty* property) const
+{
+    RefPtr<CSSValue> value = getPropertyCSSValue(property->id());
+    return value && value->cssText() == property->value()->cssText();
+}
+
+void CSSMutableStyleDeclaration::removeEquivalentProperties(const CSSStyleDeclaration* style)
+{
+    Vector<int> propertiesToRemove;
+    size_t size = m_properties.size();
+    for (size_t i = 0; i < size; ++i) {
+        const CSSProperty& property = m_properties[i];
+        if (style->cssPropertyMatches(&property))
+            propertiesToRemove.append(property.id());
+    }    
+    // FIXME: This should use mass removal.
+    for (unsigned i = 0; i < propertiesToRemove.size(); ++i)
+        removeProperty(propertiesToRemove[i]);
+}
+
 } // namespace WebCore
index c6813f7..e046580 100644 (file)
@@ -83,6 +83,8 @@ public:
     { 
         return adoptRef(new CSSMutableStyleDeclaration(element, false));
     }
+    
+    static bool isPropertyName(const String&);
 
     // Used by StyledElement::copyNonAttributeProperties().
     void copyPropertiesFrom(const CSSMutableStyleDeclaration&);
@@ -92,27 +94,18 @@ public:
     const_iterator begin() { return const_iterator(this, m_properties.begin()); }
     const_iterator end() { return const_iterator(this, m_properties.end()); }
 
-    virtual String cssText() const;
-    virtual void setCssText(const String&, ExceptionCode&);
+    unsigned propertyCount() const { return m_properties.size(); }
+    bool isEmpty() const { return m_properties.isEmpty(); }
+    const CSSProperty& propertyAt(unsigned index) const { return m_properties[index]; }
 
-    virtual unsigned virtualLength() const;
-    unsigned length() const { return m_properties.size(); }
-
-    virtual String item(unsigned index) const;
-
-    virtual PassRefPtr<CSSValue> getPropertyCSSValue(int propertyID) const;
-    virtual String getPropertyValue(int propertyID) const;
-    virtual bool getPropertyPriority(int propertyID) const;
-    virtual int getPropertyShorthand(int propertyID) const;
-    virtual bool isPropertyImplicit(int propertyID) const;
-
-    virtual void setProperty(int propertyId, const String& value, bool important, ExceptionCode&);
-    virtual String removeProperty(int propertyID, ExceptionCode&);
+    PassRefPtr<CSSValue> getPropertyCSSValue(int propertyID) const;
+    String getPropertyValue(int propertyID) const;
+    bool getPropertyPriority(int propertyID) const;
+    int getPropertyShorthand(int propertyID) const;
+    bool isPropertyImplicit(int propertyID) const;
 
     virtual PassRefPtr<CSSMutableStyleDeclaration> copy() const;
 
-    using CSSStyleDeclaration::getPropertyCSSValue;
-
     bool setProperty(int propertyID, int value, bool important = false) { return setProperty(propertyID, value, important, true); }
     bool setProperty(int propertyId, double value, CSSPrimitiveValue::UnitTypes unit, bool important = false) { return setProperty(propertyId, value, unit, important, true); }
     bool setProperty(int propertyID, const String& value, bool important = false) { return setProperty(propertyID, value, important, true); }
@@ -138,6 +131,12 @@ public:
     bool useStrictParsing() const { return m_strictParsing; }
 
     void addSubresourceStyleURLs(ListHashSet<KURL>&);
+    
+    void removeEquivalentProperties(const CSSStyleDeclaration*);
+
+    PassRefPtr<CSSMutableStyleDeclaration> copyPropertiesInSet(const int* set, unsigned length) const;
+
+    String asText() const;
 
 protected:
     CSSMutableStyleDeclaration();
@@ -153,6 +152,22 @@ private:
 
     virtual PassRefPtr<CSSMutableStyleDeclaration> makeMutable();
 
+    // CSSOM functions. Don't make these public.
+    virtual unsigned length() const;
+    virtual String item(unsigned index) const;
+    virtual PassRefPtr<CSSValue> getPropertyCSSValue(const String& propertyName);
+    virtual String getPropertyValue(const String& propertyName);
+    virtual String getPropertyPriority(const String& propertyName);
+    virtual String getPropertyShorthand(const String& propertyName);
+    virtual bool isPropertyImplicit(const String& propertyName);
+    virtual void setProperty(const String& propertyName, const String& value, const String& priority, ExceptionCode&);
+    virtual String removeProperty(const String& propertyName, ExceptionCode&);
+    virtual String cssText() const;
+    virtual void setCssText(const String&, ExceptionCode&);
+    virtual PassRefPtr<CSSValue> getPropertyCSSValueInternal(CSSPropertyID);
+    virtual String getPropertyValueInternal(CSSPropertyID);
+    virtual void setPropertyInternal(CSSPropertyID, const String& value, bool important, ExceptionCode&);
+
     void setNeedsStyleRecalc();
 
     String getShorthandValue(const int* properties, size_t) const;
@@ -173,6 +188,8 @@ private:
     bool removeShorthandProperty(int propertyID, bool notifyChanged);
     bool removePropertiesInSet(const int* set, unsigned length, bool notifyChanged);
 
+    virtual bool cssPropertyMatches(const CSSProperty*) const;
+
     Vector<CSSProperty>::const_iterator findPropertyWithId(int propertyId) const;
     Vector<CSSProperty>::iterator findPropertyWithId(int propertyId);
 
index 67706b1..a45c422 100644 (file)
@@ -77,109 +77,11 @@ CSSStyleSheet* CSSStyleDeclaration::parentStyleSheet() const
     return m_parent.rule->parentStyleSheet();
 }
 
-PassRefPtr<CSSValue> CSSStyleDeclaration::getPropertyCSSValue(const String& propertyName)
-{
-    int propID = cssPropertyID(propertyName);
-    if (!propID)
-        return 0;
-    return getPropertyCSSValue(propID);
-}
-
-String CSSStyleDeclaration::getPropertyValue(const String &propertyName)
-{
-    int propID = cssPropertyID(propertyName);
-    if (!propID)
-        return String();
-    return getPropertyValue(propID);
-}
-
-String CSSStyleDeclaration::getPropertyPriority(const String& propertyName)
-{
-    int propID = cssPropertyID(propertyName);
-    if (!propID)
-        return String();
-    return getPropertyPriority(propID) ? "important" : "";
-}
-
-String CSSStyleDeclaration::getPropertyShorthand(const String& propertyName)
-{
-    int propID = cssPropertyID(propertyName);
-    if (!propID)
-        return String();
-    int shorthandID = getPropertyShorthand(propID);
-    if (!shorthandID)
-        return String();
-    return getPropertyName(static_cast<CSSPropertyID>(shorthandID));
-}
-
-bool CSSStyleDeclaration::isPropertyImplicit(const String& propertyName)
-{
-    int propID = cssPropertyID(propertyName);
-    if (!propID)
-        return false;
-    return isPropertyImplicit(propID);
-}
-
-void CSSStyleDeclaration::setProperty(const String& propertyName, const String& value, const String& priority, ExceptionCode& ec)
-{
-    int propID = cssPropertyID(propertyName);
-    if (!propID)
-        return;
-    bool important = priority.find("important", 0, false) != notFound;
-    setProperty(propID, value, important, ec);
-}
-
-String CSSStyleDeclaration::removeProperty(const String& propertyName, ExceptionCode& ec)
-{
-    int propID = cssPropertyID(propertyName);
-    if (!propID)
-        return String();
-    return removeProperty(propID, ec);
-}
-
 bool CSSStyleDeclaration::isPropertyName(const String& propertyName)
 {
     return cssPropertyID(propertyName);
 }
 
-bool CSSStyleDeclaration::cssPropertyMatches(const CSSProperty* property) const
-{
-    RefPtr<CSSValue> value = getPropertyCSSValue(property->id());
-    return value && value->cssText() == property->value()->cssText();
-}
-
-void CSSStyleDeclaration::diff(CSSMutableStyleDeclaration* style) const
-{
-    if (!style)
-        return;
-
-    Vector<int> propertiesToRemove;
-    {
-        CSSMutableStyleDeclaration::const_iterator end = style->end();
-        for (CSSMutableStyleDeclaration::const_iterator it = style->begin(); it != end; ++it) {
-            const CSSProperty& property = *it;
-            if (cssPropertyMatches(&property))
-                propertiesToRemove.append(property.id());
-        }
-    }
-
-    // FIXME: This should use mass removal.
-    for (unsigned i = 0; i < propertiesToRemove.size(); i++)
-        style->removeProperty(propertiesToRemove[i]);
-}
-
-PassRefPtr<CSSMutableStyleDeclaration> CSSStyleDeclaration::copyPropertiesInSet(const int* set, unsigned length) const
-{
-    Vector<CSSProperty> list;
-    list.reserveInitialCapacity(length);
-    for (unsigned i = 0; i < length; i++) {
-        RefPtr<CSSValue> value = getPropertyCSSValue(set[i]);
-        if (value)
-            list.append(CSSProperty(set[i], value.release(), false));
-    }
-    return CSSMutableStyleDeclaration::create(list);
-}
-
 #ifndef NDEBUG
 void CSSStyleDeclaration::showStyle()
 {
index 8c1e84d..2e9a2ea 100644 (file)
@@ -21,6 +21,7 @@
 #ifndef CSSStyleDeclaration_h
 #define CSSStyleDeclaration_h
 
+#include "CSSPropertyNames.h"
 #include "CSSRule.h"
 #include <wtf/Forward.h>
 
@@ -51,35 +52,26 @@ public:
 
     virtual String cssText() const = 0;
     virtual void setCssText(const String&, ExceptionCode&) = 0;
-
-    unsigned length() const { return virtualLength(); }
-    virtual unsigned virtualLength() const = 0;
-    bool isEmpty() const { return !length(); }
+    virtual unsigned length() const = 0;
     virtual String item(unsigned index) const = 0;
-
-    PassRefPtr<CSSValue> getPropertyCSSValue(const String& propertyName);
-    String getPropertyValue(const String& propertyName);
-    String getPropertyPriority(const String& propertyName);
-    String getPropertyShorthand(const String& propertyName);
-    bool isPropertyImplicit(const String& propertyName);
-
-    virtual PassRefPtr<CSSValue> getPropertyCSSValue(int propertyID) const = 0;
-    virtual String getPropertyValue(int propertyID) const = 0;
-    virtual bool getPropertyPriority(int propertyID) const = 0;
-    virtual int getPropertyShorthand(int propertyID) const = 0;
-    virtual bool isPropertyImplicit(int propertyID) const = 0;
-
-    void setProperty(const String& propertyName, const String& value, const String& priority, ExceptionCode&);
-    String removeProperty(const String& propertyName, ExceptionCode&);
-    virtual void setProperty(int propertyId, const String& value, bool important, ExceptionCode&) = 0;
-    virtual String removeProperty(int propertyID, ExceptionCode&) = 0;
+    virtual PassRefPtr<CSSValue> getPropertyCSSValue(const String& propertyName) = 0;
+    virtual String getPropertyValue(const String& propertyName) = 0;
+    virtual String getPropertyPriority(const String& propertyName) = 0;
+    virtual String getPropertyShorthand(const String& propertyName) = 0;
+    virtual bool isPropertyImplicit(const String& propertyName) = 0;
+    virtual void setProperty(const String& propertyName, const String& value, const String& priority, ExceptionCode&) = 0;
+    virtual String removeProperty(const String& propertyName, ExceptionCode&) = 0;
+
+    // CSSPropertyID versions of the CSSOM functions to support bindings and editing.
+    // Use the non-virtual methods in the concrete subclasses when possible.
+    virtual PassRefPtr<CSSValue> getPropertyCSSValueInternal(CSSPropertyID) = 0;
+    virtual String getPropertyValueInternal(CSSPropertyID) = 0;
+    virtual void setPropertyInternal(CSSPropertyID, const String& value, bool important, ExceptionCode&) = 0;
 
     virtual PassRefPtr<CSSMutableStyleDeclaration> copy() const = 0;
     virtual PassRefPtr<CSSMutableStyleDeclaration> makeMutable() = 0;
 
-    void diff(CSSMutableStyleDeclaration*) const;
-
-    PassRefPtr<CSSMutableStyleDeclaration> copyPropertiesInSet(const int* set, unsigned length) const;
+    virtual bool cssPropertyMatches(const CSSProperty*) const = 0;
 
 #ifndef NDEBUG
     void showStyle();
@@ -92,8 +84,6 @@ protected:
     CSSStyleDeclaration(CSSRule* parentRule = 0);
     CSSStyleDeclaration(StyledElement* parentElement, bool isInline);
 
-    virtual bool cssPropertyMatches(const CSSProperty*) const;
-
     // The bits in this section are only used by specific subclasses but kept here
     // to maximize struct packing.
 
index 62e64f7..535e9f1 100644 (file)
@@ -128,7 +128,7 @@ String CSSStyleRule::cssText() const
     String result = selectorText();
 
     result += " { ";
-    result += m_style->cssText();
+    result += m_style->asText();
     result += "}";
 
     return result;
index e32b65b..240c83e 100644 (file)
@@ -299,7 +299,7 @@ static const MediaQueryEvaluator& printEval()
 static CSSMutableStyleDeclaration* leftToRightDeclaration()
 {
     DEFINE_STATIC_LOCAL(RefPtr<CSSMutableStyleDeclaration>, leftToRightDecl, (CSSMutableStyleDeclaration::create()));
-    if (!leftToRightDecl->length())
+    if (leftToRightDecl->isEmpty())
         leftToRightDecl->setProperty(CSSPropertyDirection, CSSValueLtr);
     return leftToRightDecl.get();
 }
@@ -307,7 +307,7 @@ static CSSMutableStyleDeclaration* leftToRightDeclaration()
 static CSSMutableStyleDeclaration* rightToLeftDeclaration()
 {
     DEFINE_STATIC_LOCAL(RefPtr<CSSMutableStyleDeclaration>, rightToLeftDecl, (CSSMutableStyleDeclaration::create()));
-    if (!rightToLeftDecl->length())
+    if (rightToLeftDecl->isEmpty())
         rightToLeftDecl->setProperty(CSSPropertyDirection, CSSValueRtl);
     return rightToLeftDecl.get();
 }
@@ -780,7 +780,7 @@ void CSSStyleSelector::collectMatchingRulesForList(const Vector<RuleData>* rules
             }
             // If the rule has no properties to apply, then ignore it in the non-debug mode.
             CSSMutableStyleDeclaration* decl = rule->declaration();
-            if (!decl || (!decl->length() && !includeEmptyRules)) {
+            if (!decl || (decl->isEmpty() && !includeEmptyRules)) {
                 InspectorInstrumentation::didMatchRule(cookie, false);
                 continue;
             }
@@ -2526,7 +2526,7 @@ void CSSStyleSelector::matchPageRulesForList(const Vector<RuleData>* rules, bool
 
         // If the rule has no properties to apply, then ignore it.
         CSSMutableStyleDeclaration* decl = rule->declaration();
-        if (!decl || !decl->length())
+        if (!decl || decl->isEmpty())
             continue;
 
         // Add this rule to our list of matched rules.
index 23bdeca..674aa5a 100644 (file)
@@ -46,7 +46,7 @@ String WebKitCSSKeyframeRule::cssText() const
     String result = m_key;
 
     result += " { ";
-    result += m_style->cssText();
+    result += m_style->asText();
     result += "}";
 
     return result;
index abbd782..cb9e452 100644 (file)
@@ -112,8 +112,8 @@ void StyledElement::updateStyleAttribute() const
     ASSERT(!isStyleAttributeValid());
     setIsStyleAttributeValid();
     setIsSynchronizingStyleAttribute();
-    if (m_inlineStyleDecl)
-        const_cast<StyledElement*>(this)->setAttribute(styleAttr, m_inlineStyleDecl->cssText());
+    if (CSSMutableStyleDeclaration* inlineStyle = inlineStyleDecl())
+        const_cast<StyledElement*>(this)->setAttribute(styleAttr, inlineStyle->asText());
     clearIsSynchronizingStyleAttribute();
 }
 
index 5aa0eb0..41735c5 100644 (file)
@@ -395,7 +395,7 @@ void ApplyStyleCommand::applyRelativeFontStyleChange(EditingStyle* style)
         }
         if (currentFontSize != desiredFontSize) {
             inlineStyleDecl->setProperty(CSSPropertyFontSize, String::number(desiredFontSize) + "px", false);
-            setNodeAttribute(element.get(), styleAttr, inlineStyleDecl->cssText());
+            setNodeAttribute(element.get(), styleAttr, inlineStyleDecl->asText());
         }
         if (inlineStyleDecl->isEmpty()) {
             removeNodeAttribute(element.get(), styleAttr);
@@ -515,7 +515,7 @@ void ApplyStyleCommand::removeEmbeddingUpToEnclosingBlock(Node* node, Node* unsp
             RefPtr<CSSMutableStyleDeclaration> inlineStyle = element->ensureInlineStyleDecl()->copy();
             inlineStyle->setProperty(CSSPropertyUnicodeBidi, CSSValueNormal);
             inlineStyle->removeProperty(CSSPropertyDirection);
-            setNodeAttribute(element, styleAttr, inlineStyle->cssText());
+            setNodeAttribute(element, styleAttr, inlineStyle->asText());
             if (isSpanWithoutAttributesOrUnstyledStyleSpan(element))
                 removeNodePreservingChildren(element);
         }
@@ -728,7 +728,7 @@ void ApplyStyleCommand::applyInlineStyleToNodeRange(EditingStyle* style, Node* n
             HTMLElement* element = toHTMLElement(node);
             RefPtr<CSSMutableStyleDeclaration> inlineStyle = element->ensureInlineStyleDecl()->copy();
             inlineStyle->merge(style->style());
-            setNodeAttribute(element, styleAttr, inlineStyle->cssText());
+            setNodeAttribute(element, styleAttr, inlineStyle->asText());
             next = node->traverseNextSibling();
             continue;
         }
@@ -943,7 +943,7 @@ void ApplyStyleCommand::applyInlineStyleToPushDown(Node* node, EditingStyle* sty
     // Since addInlineStyleIfNeeded can't add styles to block-flow render objects, add style attribute instead.
     // FIXME: applyInlineStyleToRange should be used here instead.
     if ((node->renderer()->isBlockFlow() || node->childNodeCount()) && node->isHTMLElement()) {
-        setNodeAttribute(toHTMLElement(node), styleAttr, newInlineStyle->style()->cssText());
+        setNodeAttribute(toHTMLElement(node), styleAttr, newInlineStyle->style()->asText());
         return;
     }
 
@@ -1312,7 +1312,7 @@ void ApplyStyleCommand::addBlockStyle(const StyleChange& styleChange, HTMLElemen
         
     String cssText = styleChange.cssStyle();
     if (CSSMutableStyleDeclaration* decl = block->inlineStyleDecl())
-        cssText += decl->cssText();
+        cssText += decl->asText();
     setNodeAttribute(block, styleAttr, cssText);
 }
 
@@ -1377,7 +1377,7 @@ void ApplyStyleCommand::addInlineStyleIfNeeded(EditingStyle* style, PassRefPtr<N
     if (styleChange.cssStyle().length()) {
         if (styleContainer) {
             if (CSSMutableStyleDeclaration* existingStyle = styleContainer->inlineStyleDecl())
-                setNodeAttribute(styleContainer, styleAttr, existingStyle->cssText() + styleChange.cssStyle());
+                setNodeAttribute(styleContainer, styleAttr, existingStyle->asText() + styleChange.cssStyle());
             else
                 setNodeAttribute(styleContainer, styleAttr, styleChange.cssStyle());
         } else {
index ca8f061..d3c50b3 100644 (file)
@@ -82,7 +82,8 @@ static const int editingProperties[] = {
 
 enum EditingPropertiesType { OnlyInheritableEditingProperties, AllEditingProperties };
 
-static PassRefPtr<CSSMutableStyleDeclaration> copyEditingProperties(CSSStyleDeclaration* style, EditingPropertiesType type = OnlyInheritableEditingProperties)
+template <class StyleDeclarationType>
+static PassRefPtr<CSSMutableStyleDeclaration> copyEditingProperties(StyleDeclarationType* style, EditingPropertiesType type = OnlyInheritableEditingProperties)
 {
     if (type == AllEditingProperties)
         return style->copyPropertiesInSet(editingProperties, WTF_ARRAY_LENGTH(editingProperties));
@@ -347,7 +348,7 @@ static RGBA32 cssValueToRGBA(CSSValue* colorValue)
 
 static inline RGBA32 getRGBAFontColor(CSSStyleDeclaration* style)
 {
-    return cssValueToRGBA(style->getPropertyCSSValue(CSSPropertyColor).get());
+    return cssValueToRGBA(style->getPropertyCSSValueInternal(CSSPropertyColor).get());
 }
 
 static inline RGBA32 rgbaBackgroundColorInEffect(Node* node)
@@ -387,12 +388,10 @@ void EditingStyle::removeTextFillAndStrokeColorsIfNeeded(RenderStyle* renderStyl
     // If a node's text fill color is invalid, then its children use 
     // their font-color as their text fill color (they don't
     // inherit it).  Likewise for stroke color.
-    ExceptionCode ec = 0;
     if (!renderStyle->textFillColor().isValid())
-        m_mutableStyle->removeProperty(CSSPropertyWebkitTextFillColor, ec);
+        m_mutableStyle->removeProperty(CSSPropertyWebkitTextFillColor);
     if (!renderStyle->textStrokeColor().isValid())
-        m_mutableStyle->removeProperty(CSSPropertyWebkitTextStrokeColor, ec);
-    ASSERT(!ec);
+        m_mutableStyle->removeProperty(CSSPropertyWebkitTextStrokeColor);
 }
 
 void EditingStyle::setProperty(int propertyID, const String& value, bool important)
@@ -400,8 +399,7 @@ void EditingStyle::setProperty(int propertyID, const String& value, bool importa
     if (!m_mutableStyle)
         m_mutableStyle = CSSMutableStyleDeclaration::create();
 
-    ExceptionCode ec;
-    m_mutableStyle->setProperty(propertyID, value, important, ec);
+    m_mutableStyle->setProperty(propertyID, value, important);
 }
 
 void EditingStyle::replaceFontSizeByKeywordIfPossible(RenderStyle* renderStyle, CSSComputedStyleDeclaration* computedStyle)
@@ -482,7 +480,7 @@ void EditingStyle::setStyle(PassRefPtr<CSSMutableStyleDeclaration> style)
 
 void EditingStyle::overrideWithStyle(const CSSMutableStyleDeclaration* style)
 {
-    if (!style || !style->length())
+    if (!style || style->isEmpty())
         return;
     if (!m_mutableStyle)
         m_mutableStyle = CSSMutableStyleDeclaration::create();
@@ -547,8 +545,8 @@ void EditingStyle::removeStyleAddedByNode(Node* node)
         return;
     RefPtr<CSSMutableStyleDeclaration> parentStyle = editingStyleFromComputedStyle(computedStyle(node->parentNode()), AllEditingProperties);
     RefPtr<CSSMutableStyleDeclaration> nodeStyle = editingStyleFromComputedStyle(computedStyle(node), AllEditingProperties);
-    parentStyle->diff(nodeStyle.get());
-    nodeStyle->diff(m_mutableStyle.get());
+    nodeStyle->removeEquivalentProperties(parentStyle.get());
+    m_mutableStyle->removeEquivalentProperties(nodeStyle.get());
 }
 
 void EditingStyle::removeStyleConflictingWithStyleOfNode(Node* node)
@@ -558,7 +556,7 @@ void EditingStyle::removeStyleConflictingWithStyleOfNode(Node* node)
 
     RefPtr<CSSMutableStyleDeclaration> parentStyle = editingStyleFromComputedStyle(computedStyle(node->parentNode()), AllEditingProperties);
     RefPtr<CSSMutableStyleDeclaration> nodeStyle = editingStyleFromComputedStyle(computedStyle(node), AllEditingProperties);
-    parentStyle->diff(nodeStyle.get());
+    nodeStyle->removeEquivalentProperties(parentStyle.get());
 
     CSSMutableStyleDeclaration::const_iterator end = nodeStyle->end();
     for (CSSMutableStyleDeclaration::const_iterator it = nodeStyle->begin(); it != end; ++it)
@@ -610,9 +608,9 @@ TriState EditingStyle::triStateOfStyle(CSSStyleDeclaration* styleToCompare, Shou
     if (shouldIgnoreTextOnlyProperties == IgnoreTextOnlyProperties)
         difference->removePropertiesInSet(textOnlyProperties, WTF_ARRAY_LENGTH(textOnlyProperties));
 
-    if (!difference->length())
+    if (difference->isEmpty())
         return TrueTriState;
-    if (difference->length() == m_mutableStyle->length())
+    if (difference->propertyCount() == m_mutableStyle->propertyCount())
         return FalseTriState;
 
     return MixedTriState;
@@ -800,7 +798,7 @@ bool EditingStyle::extractConflictingImplicitStyleOfAttributes(HTMLElement* elem
 
 bool EditingStyle::styleIsPresentInComputedStyleOfNode(Node* node) const
 {
-    return !m_mutableStyle || !getPropertiesNotIn(m_mutableStyle.get(), computedStyle(node).get())->length();
+    return !m_mutableStyle || getPropertiesNotIn(m_mutableStyle.get(), computedStyle(node).get())->isEmpty();
 }
 
 bool EditingStyle::elementIsStyledSpanOrHTMLEquivalent(const HTMLElement* element)
@@ -869,7 +867,8 @@ void EditingStyle::prepareToApplyAt(const Position& position, ShouldPreserveWrit
         direction = m_mutableStyle->getPropertyCSSValue(CSSPropertyDirection);
     }
 
-    style->m_mutableStyle->diff(m_mutableStyle.get());
+    m_mutableStyle->removeEquivalentProperties(style->m_mutableStyle.get());
+
     if (getRGBAFontColor(m_mutableStyle.get()) == getRGBAFontColor(style->m_mutableStyle.get()))
         m_mutableStyle->removeProperty(CSSPropertyColor);
 
@@ -996,7 +995,6 @@ void EditingStyle::mergeStyle(CSSMutableStyleDeclaration* style, CSSPropertyOver
     CSSMutableStyleDeclaration::const_iterator end = style->end();
     for (CSSMutableStyleDeclaration::const_iterator it = style->begin(); it != end; ++it) {
         RefPtr<CSSValue> value = m_mutableStyle->getPropertyCSSValue(it->id());
-        ExceptionCode ec;
 
         // text decorations never override values
         if ((it->id() == CSSPropertyTextDecoration || it->id() == CSSPropertyWebkitTextDecorationsInEffect) && it->value()->isValueList() && value) {
@@ -1008,7 +1006,7 @@ void EditingStyle::mergeStyle(CSSMutableStyleDeclaration* style, CSSPropertyOver
         }
 
         if (mode == OverrideValues || (mode == DoNotOverrideValues && !value))
-            m_mutableStyle->setProperty(it->id(), it->value()->cssText(), it->isImportant(), ec);
+            m_mutableStyle->setProperty(it->id(), it->value()->cssText(), it->isImportant());
     }
 }
 
@@ -1068,7 +1066,7 @@ void EditingStyle::mergeStyleFromRulesForSerialization(StyledElement* element)
 
 static void removePropertiesInStyle(CSSMutableStyleDeclaration* styleToRemovePropertiesFrom, CSSMutableStyleDeclaration* style)
 {
-    Vector<int> propertiesToRemove(style->length());
+    Vector<int> propertiesToRemove(style->propertyCount());
     size_t i = 0;
     CSSMutableStyleDeclaration::const_iterator end = style->end();
     for (CSSMutableStyleDeclaration::const_iterator it = style->begin(); it != end; ++it, ++i)
@@ -1085,7 +1083,7 @@ void EditingStyle::removeStyleFromRulesAndContext(StyledElement* element, Node*
 
     // 1. Remove style from matched rules because style remain without repeating it in inline style declaration
     RefPtr<CSSMutableStyleDeclaration> styleFromMatchedRules = styleFromMatchedRulesForElement(element, CSSStyleSelector::AllButEmptyCSSRules);
-    if (styleFromMatchedRules && styleFromMatchedRules->length())
+    if (styleFromMatchedRules && !styleFromMatchedRules->isEmpty())
         m_mutableStyle = getPropertiesNotIn(m_mutableStyle.get(), styleFromMatchedRules.get());
 
     // 2. Remove style present in context and not overriden by matched rules.
@@ -1110,7 +1108,7 @@ void EditingStyle::removeStyleFromRulesAndContext(StyledElement* element, Node*
 
 void EditingStyle::removePropertiesInElementDefaultStyle(Element* element)
 {
-    if (!m_mutableStyle || !m_mutableStyle->length())
+    if (!m_mutableStyle || m_mutableStyle->isEmpty())
         return;
 
     RefPtr<CSSMutableStyleDeclaration> defaultStyle = styleFromMatchedRulesForElement(element, CSSStyleSelector::UAAndUserCSSRules);
@@ -1217,7 +1215,7 @@ StyleChange::StyleChange(EditingStyle* style, const Position& position)
         mutableStyle->setProperty(CSSPropertyDirection, style->style()->getPropertyValue(CSSPropertyDirection));
 
     // Save the result for later
-    m_cssStyle = mutableStyle->cssText().stripWhiteSpace();
+    m_cssStyle = mutableStyle->asText().stripWhiteSpace();
 }
 
 static void setTextDecorationProperty(CSSMutableStyleDeclaration* style, const CSSValueList* newTextDecoration, int propertyID)
@@ -1312,7 +1310,7 @@ static void diffTextDecorations(CSSMutableStyleDeclaration* style, int propertID
 static bool fontWeightIsBold(CSSStyleDeclaration* style)
 {
     ASSERT(style);
-    RefPtr<CSSValue> fontWeight = style->getPropertyCSSValue(CSSPropertyFontWeight);
+    RefPtr<CSSValue> fontWeight = style->getPropertyCSSValueInternal(CSSPropertyFontWeight);
 
     if (!fontWeight)
         return false;
@@ -1366,30 +1364,30 @@ RefPtr<CSSMutableStyleDeclaration> getPropertiesNotIn(CSSStyleDeclaration* style
     ASSERT(baseStyle);
     RefPtr<CSSMutableStyleDeclaration> result = styleWithRedundantProperties->copy();
 
-    baseStyle->diff(result.get());
+    result->removeEquivalentProperties(baseStyle);
 
-    RefPtr<CSSValue> baseTextDecorationsInEffect = baseStyle->getPropertyCSSValue(CSSPropertyWebkitTextDecorationsInEffect);
+    RefPtr<CSSValue> baseTextDecorationsInEffect = baseStyle->getPropertyCSSValueInternal(CSSPropertyWebkitTextDecorationsInEffect);
     diffTextDecorations(result.get(), CSSPropertyTextDecoration, baseTextDecorationsInEffect.get());
     diffTextDecorations(result.get(), CSSPropertyWebkitTextDecorationsInEffect, baseTextDecorationsInEffect.get());
 
-    if (baseStyle->getPropertyCSSValue(CSSPropertyFontSize) && fontWeightIsBold(result.get()) == fontWeightIsBold(baseStyle))
+    if (baseStyle->getPropertyCSSValueInternal(CSSPropertyFontSize) && fontWeightIsBold(result.get()) == fontWeightIsBold(baseStyle))
         result->removeProperty(CSSPropertyFontWeight);
 
-    if (baseStyle->getPropertyCSSValue(CSSPropertyColor) && getRGBAFontColor(result.get()) == getRGBAFontColor(baseStyle))
+    if (baseStyle->getPropertyCSSValueInternal(CSSPropertyColor) && getRGBAFontColor(result.get()) == getRGBAFontColor(baseStyle))
         result->removeProperty(CSSPropertyColor);
 
-    if (baseStyle->getPropertyCSSValue(CSSPropertyTextAlign) && getTextAlignment(result.get()) == getTextAlignment(baseStyle))
+    if (baseStyle->getPropertyCSSValueInternal(CSSPropertyTextAlign) && getTextAlignment(result.get()) == getTextAlignment(baseStyle))
         result->removeProperty(CSSPropertyTextAlign);
 
     return result;
 }
 
-int getIdentifierValue(CSSStyleDeclaration* style, int propertyID)
+int getIdentifierValue(CSSStyleDeclaration* style, CSSPropertyID propertyID)
 {
     if (!style)
         return 0;
 
-    RefPtr<CSSValue> value = style->getPropertyCSSValue(propertyID);
+    RefPtr<CSSValue> value = style->getPropertyCSSValueInternal(propertyID);
     if (!value || !value->isPrimitiveValue())
         return 0;
 
@@ -1422,7 +1420,7 @@ int legacyFontSizeFromCSSValue(Document* document, CSSPrimitiveValue* value, boo
 
 bool hasTransparentBackgroundColor(CSSStyleDeclaration* style)
 {
-    RefPtr<CSSValue> cssValue = style->getPropertyCSSValue(CSSPropertyBackgroundColor);
+    RefPtr<CSSValue> cssValue = style->getPropertyCSSValueInternal(CSSPropertyBackgroundColor);
     if (!cssValue)
         return true;
     
index 8ec66d7..b497dc9 100644 (file)
@@ -216,7 +216,7 @@ private:
 };
 
 // FIXME: Remove these functions or make them non-global to discourage using CSSStyleDeclaration directly.
-int getIdentifierValue(CSSStyleDeclaration*, int propertyID);
+int getIdentifierValue(CSSStyleDeclaration*, CSSPropertyID);
 
 } // namespace WebCore
 
index e2d2b57..9e64376 100644 (file)
@@ -2751,13 +2751,9 @@ void Editor::applyEditingStyleToElement(Element* element) const
     if (!element->isStyledElement())
         return;
     CSSMutableStyleDeclaration* style = static_cast<StyledElement*>(element)->ensureInlineStyleDecl();
-    ExceptionCode ec = 0;
-    style->setProperty(CSSPropertyWordWrap, "break-word", false, ec);
-    ASSERT(!ec);
-    style->setProperty(CSSPropertyWebkitNbspMode, "space", false, ec);
-    ASSERT(!ec);
-    style->setProperty(CSSPropertyWebkitLineBreak, "after-white-space", false, ec);
-    ASSERT(!ec);
+    style->setProperty(CSSPropertyWordWrap, "break-word", false);
+    style->setProperty(CSSPropertyWebkitNbspMode, "space", false);
+    style->setProperty(CSSPropertyWebkitLineBreak, "after-white-space", false);
 }
 
 // Searches from the beginning of the document if nothing is selected.
index 2d1fbed..18f622e 100644 (file)
@@ -502,8 +502,8 @@ void ReplaceSelectionCommand::removeRedundantStylesAndKeepStyleSpanInline(Insert
                 continue;
             } else
                 removeNodeAttribute(element, styleAttr);
-        } else if (newInlineStyle->style()->length() != inlineStyle->length())
-            setNodeAttribute(element, styleAttr, newInlineStyle->style()->cssText());
+        } else if (newInlineStyle->style()->propertyCount() != inlineStyle->propertyCount())
+            setNodeAttribute(element, styleAttr, newInlineStyle->style()->asText());
 
         // FIXME: Tolerate differences in id, class, and style attributes.
         if (isNonTableCellHTMLBlockElement(element) && areIdenticalElements(element, element->parentNode())
@@ -660,7 +660,7 @@ static bool handleStyleSpansBeforeInsertion(ReplacementFragment& fragment, const
 
     Node* wrappingStyleSpan = topNode;
     RefPtr<EditingStyle> styleAtInsertionPos = EditingStyle::create(insertionPos.parentAnchoredEquivalent());
-    String styleText = styleAtInsertionPos->style()->cssText();
+    String styleText = styleAtInsertionPos->style()->asText();
 
     // FIXME: This string comparison is a naive way of comparing two styles.
     // We should be taking the diff and check that the diff is empty.
@@ -720,7 +720,7 @@ void ReplaceSelectionCommand::handleStyleSpans(InsertedNodes& insertedNodes)
         insertedNodes.willRemoveNodePreservingChildren(wrappingStyleSpan);
         removeNodePreservingChildren(wrappingStyleSpan);
     } else
-        setNodeAttribute(wrappingStyleSpan, styleAttr, style->style()->cssText());
+        setNodeAttribute(wrappingStyleSpan, styleAttr, style->style()->asText());
 }
 
 void ReplaceSelectionCommand::mergeEndIfNeeded()
index fca360d..f3d995e 100644 (file)
@@ -112,7 +112,7 @@ static RenderStyle* styleForSelectionStart(Frame* frame, Node *&nodeToRemove)
 
     RefPtr<Element> styleElement = frame->document()->createElement(spanTag, false);
 
-    String styleText = typingStyle->style()->cssText() + " display: inline";
+    String styleText = typingStyle->style()->asText() + " display: inline";
     styleElement->setAttribute(styleAttr, styleText.impl());
 
     styleElement->appendChild(frame->document()->createEditingTextNode(""), ASSERT_NO_EXCEPTION);
index 6b43ff7..c6441e6 100644 (file)
@@ -191,7 +191,7 @@ void StyledMarkupAccumulator::appendStyleNodeOpenTag(StringBuilder& out, CSSMuta
     DEFINE_STATIC_LOCAL(const String, divStyle, ("<div style=\""));
     DEFINE_STATIC_LOCAL(const String, styleSpanOpen, ("<span style=\""));
     out.append(isBlock ? divStyle : styleSpanOpen);
-    appendAttributeValue(out, style->cssText(), document->isHTMLDocument());
+    appendAttributeValue(out, style->asText(), document->isHTMLDocument());
     out.append('\"');
     out.append('>');
 }
@@ -328,7 +328,7 @@ void StyledMarkupAccumulator::appendElement(StringBuilder& out, Element* element
         if (!newInlineStyle->isEmpty()) {
             DEFINE_STATIC_LOCAL(const String, stylePrefix, (" style=\""));
             out.append(stylePrefix);
-            appendAttributeValue(out, newInlineStyle->style()->cssText(), documentIsHTML);
+            appendAttributeValue(out, newInlineStyle->style()->asText(), documentIsHTML);
             out.append('\"');
         }
     }
index d4a73d3..dc95a0d 100644 (file)
@@ -253,8 +253,7 @@ void ImageDocument::resizeImageToFit()
     m_imageElement->setWidth(static_cast<int>(imageSize.width() * scale));
     m_imageElement->setHeight(static_cast<int>(imageSize.height() * scale));
     
-    ExceptionCode ec;
-    m_imageElement->style()->setProperty(CSSPropertyCursor, "-webkit-zoom-in", false, ec);
+    m_imageElement->ensureInlineStyleDecl()->setProperty(CSSPropertyCursor, "-webkit-zoom-in", false);
 }
 
 void ImageDocument::imageClicked(int x, int y)
@@ -307,11 +306,10 @@ void ImageDocument::restoreImageSize()
     m_imageElement->setWidth(imageSize.width());
     m_imageElement->setHeight(imageSize.height());
     
-    ExceptionCode ec;
     if (imageFitsInWindow())
-        m_imageElement->style()->removeProperty(CSSPropertyCursor, ec);
+        m_imageElement->ensureInlineStyleDecl()->removeProperty(CSSPropertyCursor);
     else
-        m_imageElement->style()->setProperty(CSSPropertyCursor, "-webkit-zoom-out", false, ec);
+        m_imageElement->ensureInlineStyleDecl()->setProperty(CSSPropertyCursor, "-webkit-zoom-out", false);
         
     m_didShrinkImage = false;
 }
@@ -341,12 +339,10 @@ void ImageDocument::windowSizeChanged()
     // If the image has been explicitly zoomed in, restore the cursor if the image fits
     // and set it to a zoom out cursor if the image doesn't fit
     if (!m_shouldShrinkImage) {
-        ExceptionCode ec;
-        
         if (fitsInWindow)
-            m_imageElement->style()->removeProperty(CSSPropertyCursor, ec);
+            m_imageElement->ensureInlineStyleDecl()->removeProperty(CSSPropertyCursor);
         else
-            m_imageElement->style()->setProperty(CSSPropertyCursor, "-webkit-zoom-out", false, ec);
+            m_imageElement->ensureInlineStyleDecl()->setProperty(CSSPropertyCursor, "-webkit-zoom-out", false);
         return;
     }
     
index c4647e7..118cd45 100644 (file)
@@ -1987,7 +1987,7 @@ void CanvasRenderingContext2D::setFont(const String& newFont)
     String declarationText("font: ");
     declarationText += newFont;
     parser.parseDeclaration(tempDecl.get(), declarationText);
-    if (!tempDecl->length())
+    if (tempDecl->isEmpty())
         return;
 
     // The parse succeeded.
index 3aee6e8..3ed1fee 100644 (file)
@@ -69,7 +69,7 @@ RGBA32 currentColor(HTMLCanvasElement* canvas)
     if (!canvas || !canvas->inDocument())
         return Color::black;
     RGBA32 rgba = Color::black;
-    CSSParser::parseColor(rgba, canvas->style()->getPropertyValue(CSSPropertyColor));
+    CSSParser::parseColor(rgba, canvas->ensureInlineStyleDecl()->getPropertyValue(CSSPropertyColor));
     return rgba;
 }
 
index 65f74f8..8f5d45b 100644 (file)
@@ -1085,7 +1085,7 @@ void InspectorStyleSheet::revalidateStyle(CSSStyleDeclaration* pageStyle)
     for (unsigned i = 0, size = m_flatRules.size(); i < size; ++i) {
         CSSStyleRule* parsedRule = m_flatRules.at(i);
         if (parsedRule->style() == pageStyle) {
-            if (parsedRule->style()->cssText() != pageStyle->cssText()) {
+            if (parsedRule->style()->asText() != pageStyle->cssText()) {
                 // Clear the disabled properties for the invalid style here.
                 m_inspectorStyles.remove(pageStyle);
                 setStyleText(pageStyle, pageStyle->cssText());
index 877b1e7..5ccedc3 100644 (file)
@@ -446,8 +446,7 @@ bool DragController::concludeEditDrag(DragData* dragData)
             return false;
         RefPtr<Range> innerRange = innerFrame->selection()->toNormalizedRange();
         RefPtr<CSSMutableStyleDeclaration> style = CSSMutableStyleDeclaration::create();
-        ExceptionCode ec;
-        style->setProperty(CSSPropertyColor, color.serialized(), false, ec);
+        style->setProperty(CSSPropertyColor, color.serialized(), false);
         if (!innerFrame->editor()->shouldApplyStyle(style.get(), innerRange.get()))
             return false;
         m_client->willPerformDragDestinationAction(DragDestinationActionEdit, dragData);
index 972f8e8..7adde3e 100644 (file)
@@ -317,12 +317,9 @@ void PageSerializer::retrieveResourcesForCSSDeclaration(CSSMutableStyleDeclarati
     // The background-image and list-style-image (for ul or ol) are the CSS properties
     // that make use of images. We iterate to make sure we include any other
     // image properties there might be.
-    for (unsigned i = 0; i < styleDeclaration->length(); ++i) {
-        // FIXME: It's kind of ridiculous to get the property name and then get
-        // the value out of the name. Ideally we would get the value out of the
-        // property ID, but CSSStyleDeclaration only gives access to property
-        // names, not IDs.
-        RefPtr<CSSValue> cssValue = styleDeclaration->getPropertyCSSValue(styleDeclaration->item(i));
+    unsigned propertyCount = styleDeclaration->propertyCount();
+    for (unsigned i = 0; i < propertyCount; ++i) {
+        RefPtr<CSSValue> cssValue = styleDeclaration->propertyAt(i).value();
         if (!cssValue->isImageValue())
             continue;
 
index 2c386d6..455ef9d 100644 (file)
@@ -1710,28 +1710,26 @@ void RenderLayer::resize(const PlatformMouseEvent& evt, const LayoutSize& oldOff
     CSSMutableStyleDeclaration* styleDeclaration = static_cast<StyledElement*>(element)->ensureInlineStyleDecl();
     bool isBoxSizingBorder = renderer->style()->boxSizing() == BORDER_BOX;
 
-    ExceptionCode ec;
-
     if (resize != RESIZE_VERTICAL && difference.width()) {
         if (element->isFormControlElement()) {
             // Make implicit margins from the theme explicit (see <http://bugs.webkit.org/show_bug.cgi?id=9547>).
-            styleDeclaration->setProperty(CSSPropertyMarginLeft, String::number(renderer->marginLeft() / zoomFactor) + "px", false, ec);
-            styleDeclaration->setProperty(CSSPropertyMarginRight, String::number(renderer->marginRight() / zoomFactor) + "px", false, ec);
+            styleDeclaration->setProperty(CSSPropertyMarginLeft, String::number(renderer->marginLeft() / zoomFactor) + "px", false);
+            styleDeclaration->setProperty(CSSPropertyMarginRight, String::number(renderer->marginRight() / zoomFactor) + "px", false);
         }
         LayoutUnit baseWidth = renderer->width() - (isBoxSizingBorder ? 0 : renderer->borderAndPaddingWidth());
         baseWidth = baseWidth / zoomFactor;
-        styleDeclaration->setProperty(CSSPropertyWidth, String::number(baseWidth + difference.width()) + "px", false, ec);
+        styleDeclaration->setProperty(CSSPropertyWidth, String::number(baseWidth + difference.width()) + "px", false);
     }
 
     if (resize != RESIZE_HORIZONTAL && difference.height()) {
         if (element->isFormControlElement()) {
             // Make implicit margins from the theme explicit (see <http://bugs.webkit.org/show_bug.cgi?id=9547>).
-            styleDeclaration->setProperty(CSSPropertyMarginTop, String::number(renderer->marginTop() / zoomFactor) + "px", false, ec);
-            styleDeclaration->setProperty(CSSPropertyMarginBottom, String::number(renderer->marginBottom() / zoomFactor) + "px", false, ec);
+            styleDeclaration->setProperty(CSSPropertyMarginTop, String::number(renderer->marginTop() / zoomFactor) + "px", false);
+            styleDeclaration->setProperty(CSSPropertyMarginBottom, String::number(renderer->marginBottom() / zoomFactor) + "px", false);
         }
         LayoutUnit baseHeight = renderer->height() - (isBoxSizingBorder ? 0 : renderer->borderAndPaddingHeight());
         baseHeight = baseHeight / zoomFactor;
-        styleDeclaration->setProperty(CSSPropertyHeight, String::number(baseHeight + difference.height()) + "px", false, ec);
+        styleDeclaration->setProperty(CSSPropertyHeight, String::number(baseHeight + difference.height()) + "px", false);
     }
 
     document->updateLayout();
index 7c1f93f..88ad4ac 100644 (file)
@@ -184,7 +184,7 @@ static bool isEmptyOrUnstyledAppleStyleSpan(const Node* node)
         return true;
 
     CSSMutableStyleDeclaration* inlineStyleDecl = elem->inlineStyleDecl();
-    return (!inlineStyleDecl || inlineStyleDecl->length() == 0);
+    return (!inlineStyleDecl || inlineStyleDecl->isEmpty());
 }
 
 String quoteAndEscapeNonPrintables(const String& s)
index 08349ff..2e87d3a 100644 (file)
@@ -437,7 +437,7 @@ PassRefPtr<CSSValue> SVGStyledElement::getPresentationAttribute(const String& na
         int propId = SVGStyledElement::cssPropertyIdForSVGAttributeName(cssSVGAttr->name());
         addCSSProperty(cssSVGAttr, propId, cssSVGAttr->value());
     }
-    return cssSVGAttr->decl()->getPropertyCSSValue(name);
+    return cssSVGAttr->decl()->getPropertyCSSValue(cssPropertyID(name));
 }
 
 bool SVGStyledElement::instanceUpdatesBlocked() const
index 07716ef..85ee070 100644 (file)
@@ -844,7 +844,7 @@ QString QWebElement::styleProperty(const QString &name, StyleResolveStrategy str
     if (!propID)
         return QString();
 
-    CSSStyleDeclaration* style = static_cast<StyledElement*>(m_element)->style();
+    CSSMutableStyleDeclaration* style = static_cast<StyledElement*>(m_element)->ensureInlineStyleDecl();
 
     if (strategy == InlineStyle)
         return style->getPropertyValue(propID);
@@ -909,12 +909,11 @@ void QWebElement::setStyleProperty(const QString &name, const QString &value)
         return;
 
     int propID = cssPropertyID(name);
-    CSSStyleDeclaration* style = static_cast<StyledElement*>(m_element)->style();
+    CSSMutableStyleDeclaration* style = static_cast<StyledElement*>(m_element)->ensureInlineStyleDecl();
     if (!propID || !style)
         return;
 
-    ExceptionCode exception = 0;
-    style->setProperty(name, value,emptyString(), exception);
+    style->setProperty(propID, value);
 }
 
 /*!
index e482ae0..6aefd70 100644 (file)
@@ -1,3 +1,16 @@
+2012-01-30  Antti Koivisto  <antti@apple.com>
+
+        Reduce non-CSSOM API of CSSStyleDeclaration
+        https://bugs.webkit.org/show_bug.cgi?id=77299
+
+        Reviewed by Andreas Kling.
+
+        * Api/qwebelement.cpp:
+        (QWebElement::styleProperty):
+        (QWebElement::setStyleProperty):
+        * WebCoreSupport/DumpRenderTreeSupportQt.cpp:
+        (DumpRenderTreeSupportQt::computedStyleIncludingVisitedInfo):
+
 2012-01-25  Zeno Albisser  <zeno@webkit.org>
 
         [Qt] public.pri is missing dependency to quick module.
index 92ecdf8..90254ae 100644 (file)
@@ -635,10 +635,11 @@ QVariantMap DumpRenderTreeSupportQt::computedStyleIncludingVisitedInfo(const QWe
     if (!webElement)
         return res;
 
-    RefPtr<WebCore::CSSComputedStyleDeclaration> style = computedStyle(webElement, true);
+    RefPtr<WebCore::CSSComputedStyleDeclaration> computedStyleDeclaration = computedStyle(webElement, true);
+    CSSStyleDeclaration* style = static_cast<WebCore::CSSStyleDeclaration*>(computedStyleDeclaration.get());
     for (unsigned i = 0; i < style->length(); i++) {
         QString name = style->item(i);
-        QString value = (static_cast<WebCore::CSSStyleDeclaration*>(style.get()))->getPropertyValue(name);
+        QString value = style->getPropertyValue(name);
         res[convertToPropertyName(name)] = QVariant(value);
     }
     return res;