Title: [121982] trunk/Source/WebCore
Revision
121982
Author
[email protected]
Date
2012-07-06 10:05:39 -0700 (Fri, 06 Jul 2012)

Log Message

Separate mutating CSSStyleDeclaration operations.
<http://webkit.org/b/89945>

Reviewed by Antti Koivisto.

Use separate paths for mutating the StylePropertySet wrapped by a CSSStyleDeclaration.
PropertySetCSSStyleDeclaration now has:

    - propertySet() const
    - ensureMutablePropertySet()

This is prep work for supporting immutable ElementAttributeData objects, the idea being
that calling ensureMutablePropertySet() may cause the element to convert its internal
attribute storage (which also holds the inline StylePropertySet.)

* css/PropertySetCSSStyleDeclaration.cpp:
(WebCore::PropertySetCSSStyleDeclaration::length):
(WebCore::PropertySetCSSStyleDeclaration::item):
(WebCore::PropertySetCSSStyleDeclaration::cssText):
(WebCore::PropertySetCSSStyleDeclaration::setCssText):
(WebCore::PropertySetCSSStyleDeclaration::getPropertyCSSValue):
(WebCore::PropertySetCSSStyleDeclaration::getPropertyValue):
(WebCore::PropertySetCSSStyleDeclaration::getPropertyPriority):
(WebCore::PropertySetCSSStyleDeclaration::getPropertyShorthand):
(WebCore::PropertySetCSSStyleDeclaration::isPropertyImplicit):
(WebCore::PropertySetCSSStyleDeclaration::setProperty):
(WebCore::PropertySetCSSStyleDeclaration::removeProperty):
(WebCore::PropertySetCSSStyleDeclaration::getPropertyCSSValueInternal):
(WebCore::PropertySetCSSStyleDeclaration::getPropertyValueInternal):
(WebCore::PropertySetCSSStyleDeclaration::setPropertyInternal):
(WebCore::PropertySetCSSStyleDeclaration::copy):
(WebCore::PropertySetCSSStyleDeclaration::makeMutable):
(WebCore::PropertySetCSSStyleDeclaration::cssPropertyMatches):
(WebCore::InlineCSSStyleDeclaration::didMutate):
(WebCore::InlineCSSStyleDeclaration::ensureMutablePropertySet):
* css/PropertySetCSSStyleDeclaration.h:
(PropertySetCSSStyleDeclaration):
(WebCore::PropertySetCSSStyleDeclaration::propertySet):
(WebCore::PropertySetCSSStyleDeclaration::ensureMutablePropertySet):

Modified Paths

Diff

Modified: trunk/Source/WebCore/ChangeLog (121981 => 121982)


--- trunk/Source/WebCore/ChangeLog	2012-07-06 16:54:04 UTC (rev 121981)
+++ trunk/Source/WebCore/ChangeLog	2012-07-06 17:05:39 UTC (rev 121982)
@@ -1,3 +1,45 @@
+2012-07-06  Andreas Kling  <[email protected]>
+
+        Separate mutating CSSStyleDeclaration operations.
+        <http://webkit.org/b/89945>
+
+        Reviewed by Antti Koivisto.
+
+        Use separate paths for mutating the StylePropertySet wrapped by a CSSStyleDeclaration.
+        PropertySetCSSStyleDeclaration now has:
+
+            - propertySet() const
+            - ensureMutablePropertySet()
+
+        This is prep work for supporting immutable ElementAttributeData objects, the idea being
+        that calling ensureMutablePropertySet() may cause the element to convert its internal
+        attribute storage (which also holds the inline StylePropertySet.)
+
+        * css/PropertySetCSSStyleDeclaration.cpp:
+        (WebCore::PropertySetCSSStyleDeclaration::length):
+        (WebCore::PropertySetCSSStyleDeclaration::item):
+        (WebCore::PropertySetCSSStyleDeclaration::cssText):
+        (WebCore::PropertySetCSSStyleDeclaration::setCssText):
+        (WebCore::PropertySetCSSStyleDeclaration::getPropertyCSSValue):
+        (WebCore::PropertySetCSSStyleDeclaration::getPropertyValue):
+        (WebCore::PropertySetCSSStyleDeclaration::getPropertyPriority):
+        (WebCore::PropertySetCSSStyleDeclaration::getPropertyShorthand):
+        (WebCore::PropertySetCSSStyleDeclaration::isPropertyImplicit):
+        (WebCore::PropertySetCSSStyleDeclaration::setProperty):
+        (WebCore::PropertySetCSSStyleDeclaration::removeProperty):
+        (WebCore::PropertySetCSSStyleDeclaration::getPropertyCSSValueInternal):
+        (WebCore::PropertySetCSSStyleDeclaration::getPropertyValueInternal):
+        (WebCore::PropertySetCSSStyleDeclaration::setPropertyInternal):
+        (WebCore::PropertySetCSSStyleDeclaration::copy):
+        (WebCore::PropertySetCSSStyleDeclaration::makeMutable):
+        (WebCore::PropertySetCSSStyleDeclaration::cssPropertyMatches):
+        (WebCore::InlineCSSStyleDeclaration::didMutate):
+        (WebCore::InlineCSSStyleDeclaration::ensureMutablePropertySet):
+        * css/PropertySetCSSStyleDeclaration.h:
+        (PropertySetCSSStyleDeclaration):
+        (WebCore::PropertySetCSSStyleDeclaration::propertySet):
+        (WebCore::PropertySetCSSStyleDeclaration::ensureMutablePropertySet):
+
 2012-07-06  Pavel Feldman  <[email protected]>
 
         Web Inspector: text editor scrolls 2px horizontally as one navigates the source code.

Modified: trunk/Source/WebCore/css/PropertySetCSSStyleDeclaration.cpp (121981 => 121982)


--- trunk/Source/WebCore/css/PropertySetCSSStyleDeclaration.cpp	2012-07-06 16:54:04 UTC (rev 121981)
+++ trunk/Source/WebCore/css/PropertySetCSSStyleDeclaration.cpp	2012-07-06 17:05:39 UTC (rev 121982)
@@ -132,19 +132,19 @@
 
 unsigned PropertySetCSSStyleDeclaration::length() const
 {
-    return m_propertySet->propertyCount();
+    return propertySet()->propertyCount();
 }
 
 String PropertySetCSSStyleDeclaration::item(unsigned i) const
 {
-    if (i >= m_propertySet->propertyCount())
+    if (i >= propertySet()->propertyCount())
         return "";
-    return m_propertySet->propertyAt(i).cssName();
+    return getPropertyName(propertySet()->propertyAt(i).id());
 }
 
 String PropertySetCSSStyleDeclaration::cssText() const
 {
-    return m_propertySet->asText();
+    return propertySet()->asText();
 }
     
 void PropertySetCSSStyleDeclaration::setCssText(const String& text, ExceptionCode& ec)
@@ -156,7 +156,7 @@
 
     ec = 0;
     // FIXME: Detect syntax errors and set ec.
-    m_propertySet->parseDeclaration(text, contextStyleSheet());
+    ensureMutablePropertySet()->parseDeclaration(text, contextStyleSheet());
 
     didMutate(PropertyChanged);
 
@@ -170,7 +170,7 @@
     CSSPropertyID propertyID = cssPropertyID(propertyName);
     if (!propertyID)
         return 0;
-    return cloneAndCacheForCSSOM(m_propertySet->getPropertyCSSValue(propertyID).get());
+    return cloneAndCacheForCSSOM(propertySet()->getPropertyCSSValue(propertyID).get());
 }
 
 String PropertySetCSSStyleDeclaration::getPropertyValue(const String &propertyName)
@@ -178,7 +178,7 @@
     CSSPropertyID propertyID = cssPropertyID(propertyName);
     if (!propertyID)
         return String();
-    return m_propertySet->getPropertyValue(propertyID);
+    return propertySet()->getPropertyValue(propertyID);
 }
 
 String PropertySetCSSStyleDeclaration::getPropertyPriority(const String& propertyName)
@@ -186,7 +186,7 @@
     CSSPropertyID propertyID = cssPropertyID(propertyName);
     if (!propertyID)
         return String();
-    return m_propertySet->propertyIsImportant(propertyID) ? "important" : "";
+    return propertySet()->propertyIsImportant(propertyID) ? "important" : "";
 }
 
 String PropertySetCSSStyleDeclaration::getPropertyShorthand(const String& propertyName)
@@ -194,7 +194,7 @@
     CSSPropertyID propertyID = cssPropertyID(propertyName);
     if (!propertyID)
         return String();
-    CSSPropertyID shorthandID = m_propertySet->getPropertyShorthand(propertyID);
+    CSSPropertyID shorthandID = propertySet()->getPropertyShorthand(propertyID);
     if (!shorthandID)
         return String();
     return getPropertyName(shorthandID);
@@ -205,7 +205,7 @@
     CSSPropertyID propertyID = cssPropertyID(propertyName);
     if (!propertyID)
         return false;
-    return m_propertySet->isPropertyImplicit(propertyID);
+    return propertySet()->isPropertyImplicit(propertyID);
 }
 
 void PropertySetCSSStyleDeclaration::setProperty(const String& propertyName, const String& value, const String& priority, ExceptionCode& ec)
@@ -222,7 +222,7 @@
     willMutate();
 
     ec = 0;
-    bool changed = m_propertySet->setProperty(propertyID, value, important, contextStyleSheet());
+    bool changed = ensureMutablePropertySet()->setProperty(propertyID, value, important, contextStyleSheet());
 
     didMutate(changed ? PropertyChanged : NoChanges);
 
@@ -248,7 +248,7 @@
 
     ec = 0;
     String result;
-    bool changed = m_propertySet->removeProperty(propertyID, &result);
+    bool changed = ensureMutablePropertySet()->removeProperty(propertyID, &result);
 
     didMutate(changed ? PropertyChanged : NoChanges);
 
@@ -262,12 +262,12 @@
 
 PassRefPtr<CSSValue> PropertySetCSSStyleDeclaration::getPropertyCSSValueInternal(CSSPropertyID propertyID)
 {
-    return m_propertySet->getPropertyCSSValue(propertyID);
+    return propertySet()->getPropertyCSSValue(propertyID);
 }
 
 String PropertySetCSSStyleDeclaration::getPropertyValueInternal(CSSPropertyID propertyID)
 { 
-    return m_propertySet->getPropertyValue(propertyID); 
+    return propertySet()->getPropertyValue(propertyID);
 }
 
 void PropertySetCSSStyleDeclaration::setPropertyInternal(CSSPropertyID propertyID, const String& value, bool important, ExceptionCode& ec)
@@ -278,7 +278,7 @@
     willMutate();
 
     ec = 0;
-    bool changed = m_propertySet->setProperty(propertyID, value, important, contextStyleSheet());
+    bool changed = ensureMutablePropertySet()->setProperty(propertyID, value, important, contextStyleSheet());
 
     didMutate(changed ? PropertyChanged : NoChanges);
 
@@ -313,17 +313,17 @@
 
 PassRefPtr<StylePropertySet> PropertySetCSSStyleDeclaration::copy() const
 {
-    return m_propertySet->copy();
+    return propertySet()->copy();
 }
 
 PassRefPtr<StylePropertySet> PropertySetCSSStyleDeclaration::makeMutable()
 {
-    return m_propertySet;
+    return ensureMutablePropertySet();
 }
 
 bool PropertySetCSSStyleDeclaration::cssPropertyMatches(const CSSProperty* property) const
 {
-    return m_propertySet->propertyMatches(property);
+    return propertySet()->propertyMatches(property);
 }
     
 StyleRuleCSSStyleDeclaration::StyleRuleCSSStyleDeclaration(StylePropertySet* propertySet, CSSRule* parentRule)
@@ -389,6 +389,7 @@
 
     if (!m_parentElement)
         return;
+
     m_parentElement->setNeedsStyleRecalc(InlineStyleChange);
     m_parentElement->invalidateStyleAttribute();
     StyleAttributeMutationScope(this).didInvalidateStyleAttr();
@@ -399,4 +400,10 @@
     return m_parentElement ? m_parentElement->document()->elementSheet() : 0;
 }
 
+StylePropertySet* InlineCSSStyleDeclaration::ensureMutablePropertySet()
+{
+    ASSERT(m_propertySet);
+    return m_propertySet;
+}
+
 } // namespace WebCore

Modified: trunk/Source/WebCore/css/PropertySetCSSStyleDeclaration.h (121981 => 121982)


--- trunk/Source/WebCore/css/PropertySetCSSStyleDeclaration.h	2012-07-06 16:54:04 UTC (rev 121981)
+++ trunk/Source/WebCore/css/PropertySetCSSStyleDeclaration.h	2012-07-06 17:05:39 UTC (rev 121982)
@@ -48,6 +48,10 @@
     virtual void ref() OVERRIDE;
     virtual void deref() OVERRIDE;
 
+protected:
+    const StylePropertySet* propertySet() const { return m_propertySet; }
+    virtual StylePropertySet* ensureMutablePropertySet() { return m_propertySet; }
+
 private:
     virtual CSSRule* parentRule() const OVERRIDE { return 0; };
     virtual unsigned length() const OVERRIDE;
@@ -106,6 +110,8 @@
     virtual void willMutate() OVERRIDE;
     virtual void didMutate(MutationType) OVERRIDE;
 
+    virtual StylePropertySet* ensureMutablePropertySet() OVERRIDE { return m_propertySet; }
+
     unsigned m_refCount;
     CSSRule* m_parentRule;
 };
@@ -125,6 +131,8 @@
     virtual void clearParentElement() OVERRIDE { m_parentElement = 0; }
 
     virtual void didMutate(MutationType) OVERRIDE;
+
+    virtual StylePropertySet* ensureMutablePropertySet() OVERRIDE;
     
     StyledElement* m_parentElement;
 };
_______________________________________________
webkit-changes mailing list
[email protected]
http://lists.webkit.org/mailman/listinfo.cgi/webkit-changes

Reply via email to