Title: [97985] trunk/Source/WebCore
Revision
97985
Author
andreas.kl...@nokia.com
Date
2011-10-20 09:23:55 -0700 (Thu, 20 Oct 2011)

Log Message

CSSStyleDeclaration: Remove inheritance from StyleBase.
https://bugs.webkit.org/show_bug.cgi?id=70411

Reviewed by Antti Koivisto.

* bindings/js/JSDOMBinding.h:
(WebCore::root):

    Specialized root() for CSSStyleDeclaration and CSSMutableStyleDeclaration.

* css/CSSMutableStyleDeclaration.cpp:
(WebCore::CSSMutableStyleDeclaration::setNeedsStyleRecalc):

    Start the parent chain traversal from the parentStyleSheet().

(WebCore::CSSMutableStyleDeclaration::addSubresourceStyleURLs):
* css/CSSParser.cpp:
(WebCore::parseColorValue):
(WebCore::parseSimpleLengthValue):
(WebCore::CSSParser::parseValue):
(WebCore::CSSParser::parseColor):
(WebCore::CSSParser::parseDeclaration):

    Remove now-unnecessary assertions and casts.

* css/CSSStyleDeclaration.cpp:
(WebCore::CSSStyleDeclaration::CSSStyleDeclaration):
* css/CSSStyleDeclaration.h:
(WebCore::CSSStyleDeclaration::~CSSStyleDeclaration):
(WebCore::CSSStyleDeclaration::parentRule):
(WebCore::CSSStyleDeclaration::setParentRule):
(WebCore::CSSStyleDeclaration::setParentStyleSheet):
(WebCore::CSSStyleDeclaration::parentStyleSheet):

    Make CSSStyleDeclaration inherit directly from RefCounted, and have either
    a CSSRule or CSSStyleSheet parent. Eventually it should only need to have
    rules as parents, but CSSParser depends on having style sheet parents for
    URL completion and primitive value cache.

* css/StyleBase.h:
* css/CSSStyleDeclaration.h:
(WebCore::CSSStyleDeclaration::isMutableStyleDeclaration):

    Moved from StyleBase down to CSSStyleDeclaration.

* css/CSSStyleRule.cpp:
(WebCore::CSSStyleRule::~CSSStyleRule):
(WebCore::CSSStyleRule::setSelectorText):
* css/WebKitCSSKeyframeRule.cpp:
(WebCore::WebKitCSSKeyframeRule::~WebKitCSSKeyframeRule):
(WebCore::WebKitCSSKeyframeRule::setDeclaration):
* css/WebKitCSSKeyframesRule.cpp:
(WebCore::WebKitCSSKeyframesRule::~WebKitCSSKeyframesRule):
(WebCore::WebKitCSSKeyframesRule::append):
(WebCore::WebKitCSSKeyframesRule::deleteRule):
* dom/StyledElement.cpp:
(WebCore::StyledElement::createInlineStyleDecl):
(WebCore::StyledElement::destroyInlineStyleDecl):
(WebCore::StyledElement::attributeChanged):
(WebCore::StyledElement::createMappedDecl):
(WebCore::StyledElement::didMoveToNewOwnerDocument):
* html/HTMLTableElement.cpp:
(WebCore::HTMLTableElement::additionalAttributeStyleDecls):
(WebCore::HTMLTableElement::addSharedCellBordersDecl):
(WebCore::HTMLTableElement::addSharedCellPaddingDecl):
(WebCore::HTMLTableElement::addSharedGroupDecls):
* page/PageSerializer.cpp:
(WebCore::PageSerializer::retrieveResourcesForCSSDeclaration):
* svg/SVGFontFaceElement.cpp:
(WebCore::SVGFontFaceElement::SVGFontFaceElement):

    Use the new parenting methods of CSSStyleDeclaration.

* css/StyleBase.cpp:
(WebCore::StyleBase::node):

    Remove the isMutableStyleDeclaration() code path.

Modified Paths

Diff

Modified: trunk/Source/WebCore/ChangeLog (97984 => 97985)


--- trunk/Source/WebCore/ChangeLog	2011-10-20 16:07:46 UTC (rev 97984)
+++ trunk/Source/WebCore/ChangeLog	2011-10-20 16:23:55 UTC (rev 97985)
@@ -1,3 +1,83 @@
+2011-10-20  Andreas Kling  <kl...@webkit.org>
+
+        CSSStyleDeclaration: Remove inheritance from StyleBase.
+        https://bugs.webkit.org/show_bug.cgi?id=70411
+
+        Reviewed by Antti Koivisto.
+
+        * bindings/js/JSDOMBinding.h:
+        (WebCore::root):
+
+            Specialized root() for CSSStyleDeclaration and CSSMutableStyleDeclaration.
+
+        * css/CSSMutableStyleDeclaration.cpp:
+        (WebCore::CSSMutableStyleDeclaration::setNeedsStyleRecalc):
+
+            Start the parent chain traversal from the parentStyleSheet().
+
+        (WebCore::CSSMutableStyleDeclaration::addSubresourceStyleURLs):
+        * css/CSSParser.cpp:
+        (WebCore::parseColorValue):
+        (WebCore::parseSimpleLengthValue):
+        (WebCore::CSSParser::parseValue):
+        (WebCore::CSSParser::parseColor):
+        (WebCore::CSSParser::parseDeclaration):
+
+            Remove now-unnecessary assertions and casts.
+
+        * css/CSSStyleDeclaration.cpp:
+        (WebCore::CSSStyleDeclaration::CSSStyleDeclaration):
+        * css/CSSStyleDeclaration.h:
+        (WebCore::CSSStyleDeclaration::~CSSStyleDeclaration):
+        (WebCore::CSSStyleDeclaration::parentRule):
+        (WebCore::CSSStyleDeclaration::setParentRule):
+        (WebCore::CSSStyleDeclaration::setParentStyleSheet):
+        (WebCore::CSSStyleDeclaration::parentStyleSheet):
+
+            Make CSSStyleDeclaration inherit directly from RefCounted, and have either
+            a CSSRule or CSSStyleSheet parent. Eventually it should only need to have
+            rules as parents, but CSSParser depends on having style sheet parents for
+            URL completion and primitive value cache.
+
+        * css/StyleBase.h:
+        * css/CSSStyleDeclaration.h:
+        (WebCore::CSSStyleDeclaration::isMutableStyleDeclaration):
+
+            Moved from StyleBase down to CSSStyleDeclaration.
+
+        * css/CSSStyleRule.cpp:
+        (WebCore::CSSStyleRule::~CSSStyleRule):
+        (WebCore::CSSStyleRule::setSelectorText):
+        * css/WebKitCSSKeyframeRule.cpp:
+        (WebCore::WebKitCSSKeyframeRule::~WebKitCSSKeyframeRule):
+        (WebCore::WebKitCSSKeyframeRule::setDeclaration):
+        * css/WebKitCSSKeyframesRule.cpp:
+        (WebCore::WebKitCSSKeyframesRule::~WebKitCSSKeyframesRule):
+        (WebCore::WebKitCSSKeyframesRule::append):
+        (WebCore::WebKitCSSKeyframesRule::deleteRule):
+        * dom/StyledElement.cpp:
+        (WebCore::StyledElement::createInlineStyleDecl):
+        (WebCore::StyledElement::destroyInlineStyleDecl):
+        (WebCore::StyledElement::attributeChanged):
+        (WebCore::StyledElement::createMappedDecl):
+        (WebCore::StyledElement::didMoveToNewOwnerDocument):
+        * html/HTMLTableElement.cpp:
+        (WebCore::HTMLTableElement::additionalAttributeStyleDecls):
+        (WebCore::HTMLTableElement::addSharedCellBordersDecl):
+        (WebCore::HTMLTableElement::addSharedCellPaddingDecl):
+        (WebCore::HTMLTableElement::addSharedGroupDecls):
+        * page/PageSerializer.cpp:
+        (WebCore::PageSerializer::retrieveResourcesForCSSDeclaration):
+        * svg/SVGFontFaceElement.cpp:
+        (WebCore::SVGFontFaceElement::SVGFontFaceElement):
+
+            Use the new parenting methods of CSSStyleDeclaration.
+
+        * css/StyleBase.cpp:
+        (WebCore::StyleBase::node):
+
+            Remove the isMutableStyleDeclaration() code path.
+
 2011-10-20  Pavel Feldman  <pfeld...@google.com>
 
         Web Inspector: detach should call hide so that overrides are processed.

Modified: trunk/Source/WebCore/bindings/js/JSDOMBinding.h (97984 => 97985)


--- trunk/Source/WebCore/bindings/js/JSDOMBinding.h	2011-10-20 16:07:46 UTC (rev 97984)
+++ trunk/Source/WebCore/bindings/js/JSDOMBinding.h	2011-10-20 16:23:55 UTC (rev 97985)
@@ -22,6 +22,7 @@
 #ifndef JSDOMBinding_h
 #define JSDOMBinding_h
 
+#include "CSSRule.h"
 #include "CSSStyleSheet.h"
 #include "JSDOMGlobalObject.h"
 #include "JSDOMWrapper.h"
@@ -186,6 +187,26 @@
         return styleBase;
     }
 
+    inline void* root(CSSStyleDeclaration* style)
+    {
+        if (CSSRule* parentRule = style->parentRule())
+            return root(parentRule);
+        if (CSSStyleSheet* styleSheet = style->parentStyleSheet())
+            return root(styleSheet);
+        return style;
+    }
+
+    inline void* root(CSSMutableStyleDeclaration* style)
+    {
+        if (CSSRule* parentRule = style->parentRule())
+            return root(parentRule);
+        if (CSSStyleSheet* styleSheet = style->parentStyleSheet())
+            return root(styleSheet);
+        if (Node* node = style->node())
+            return root(node);
+        return style;
+    }
+
     inline void* root(MediaList* mediaList)
     {
         if (CSSStyleSheet* parentStyleSheet = mediaList->parentStyleSheet())

Modified: trunk/Source/WebCore/css/CSSMutableStyleDeclaration.cpp (97984 => 97985)


--- trunk/Source/WebCore/css/CSSMutableStyleDeclaration.cpp	2011-10-20 16:07:46 UTC (rev 97984)
+++ trunk/Source/WebCore/css/CSSMutableStyleDeclaration.cpp	2011-10-20 16:23:55 UTC (rev 97985)
@@ -519,7 +519,10 @@
         return;
     }
 
-    StyleBase* root = this;
+    if (!parentStyleSheet())
+        return;
+
+    StyleBase* root = parentStyleSheet();
     while (StyleBase* parent = root->parent())
         root = parent;
     if (root->isCSSStyleSheet()) {
@@ -779,7 +782,7 @@
 
 void CSSMutableStyleDeclaration::addSubresourceStyleURLs(ListHashSet<KURL>& urls)
 {
-    CSSStyleSheet* sheet = static_cast<CSSStyleSheet*>(stylesheet());
+    CSSStyleSheet* sheet = parentStyleSheet();
     size_t size = m_properties.size();
     for (size_t i = 0; i < size; ++i)
         m_properties[i].value()->addSubresourceStyleURLs(urls, sheet);

Modified: trunk/Source/WebCore/css/CSSParser.cpp (97984 => 97985)


--- trunk/Source/WebCore/css/CSSParser.cpp	2011-10-20 16:07:46 UTC (rev 97984)
+++ trunk/Source/WebCore/css/CSSParser.cpp	2011-10-20 16:23:55 UTC (rev 97985)
@@ -340,18 +340,18 @@
         validPrimitive = true;
     }
 
-    CSSStyleSheet* stylesheet = static_cast<CSSStyleSheet*>(declaration->stylesheet());
-    if (!stylesheet || !stylesheet->document())
+    CSSStyleSheet* styleSheet = declaration->parentStyleSheet();
+    if (!styleSheet || !styleSheet->document())
         return false;
     if (validPrimitive) {
-        CSSProperty property(propertyId, stylesheet->document()->cssPrimitiveValueCache()->createIdentifierValue(valueID), important);
+        CSSProperty property(propertyId, styleSheet->document()->cssPrimitiveValueCache()->createIdentifierValue(valueID), important);
         declaration->addParsedProperty(property);
         return true;
     }
     RGBA32 color;
     if (!CSSParser::parseColor(string, color, strict && string[0] != '#'))
         return false;
-    CSSProperty property(propertyId, stylesheet->document()->cssPrimitiveValueCache()->createColorValue(color), important);
+    CSSProperty property(propertyId, styleSheet->document()->cssPrimitiveValueCache()->createColorValue(color), important);
     declaration->addParsedProperty(property);
     return true;
 }
@@ -432,10 +432,10 @@
     if (number < 0 && !acceptsNegativeNumbers)
         return false;
 
-    CSSStyleSheet* stylesheet = static_cast<CSSStyleSheet*>(declaration->stylesheet());
-    if (!stylesheet || !stylesheet->document())
+    CSSStyleSheet* styleSheet = declaration->parentStyleSheet();
+    if (!styleSheet || !styleSheet->document())
         return false;
-    CSSProperty property(propertyId, stylesheet->document()->cssPrimitiveValueCache()->createValue(number, unit), important);
+    CSSProperty property(propertyId, styleSheet->document()->cssPrimitiveValueCache()->createValue(number, unit), important);
     declaration->addParsedProperty(property);
     return true;
 }
@@ -452,8 +452,7 @@
 
 bool CSSParser::parseValue(CSSMutableStyleDeclaration* declaration, int propertyId, const String& string, bool important)
 {
-    ASSERT(!declaration->stylesheet() || declaration->stylesheet()->isCSSStyleSheet());
-    setStyleSheet(static_cast<CSSStyleSheet*>(declaration->stylesheet()));
+    setStyleSheet(declaration->parentStyleSheet());
 
     setupParser("@-webkit-value{", string, "} ");
 
@@ -505,8 +504,7 @@
 
 bool CSSParser::parseColor(CSSMutableStyleDeclaration* declaration, const String& string)
 {
-    ASSERT(!declaration->stylesheet() || declaration->stylesheet()->isCSSStyleSheet());
-    setStyleSheet(static_cast<CSSStyleSheet*>(declaration->stylesheet()));
+    setStyleSheet(declaration->parentStyleSheet());
 
     setupParser("@-webkit-decls{color:", string, "} ");
     cssyyparse(this);
@@ -553,8 +551,7 @@
     // Length of the "@-webkit-decls{" prefix.
     static const unsigned prefixLength = 15;
 
-    ASSERT(!declaration->stylesheet() || declaration->stylesheet()->isCSSStyleSheet());
-    setStyleSheet(static_cast<CSSStyleSheet*>(declaration->stylesheet()));
+    setStyleSheet(declaration->parentStyleSheet());
     if (styleSourceData) {
         m_currentRuleData = CSSRuleSourceData::create();
         m_currentRuleData->styleSourceData = CSSStyleSourceData::create();

Modified: trunk/Source/WebCore/css/CSSStyleDeclaration.cpp (97984 => 97985)


--- trunk/Source/WebCore/css/CSSStyleDeclaration.cpp	2011-10-20 16:07:46 UTC (rev 97984)
+++ trunk/Source/WebCore/css/CSSStyleDeclaration.cpp	2011-10-20 16:23:55 UTC (rev 97985)
@@ -40,7 +40,8 @@
 namespace WebCore {
 
 CSSStyleDeclaration::CSSStyleDeclaration(CSSRule* parent)
-    : StyleBase(parent)
+    : m_parentIsRule(true)
+    , m_parentRule(parent)
 {
 }
 
@@ -144,11 +145,6 @@
     return cssPropertyID(propertyName);
 }
 
-CSSRule* CSSStyleDeclaration::parentRule() const
-{
-    return (parent() && parent()->isRule()) ? static_cast<CSSRule*>(parent()) : 0;
-}
-
 bool CSSStyleDeclaration::cssPropertyMatches(const CSSProperty* property) const
 {
     RefPtr<CSSValue> value = getPropertyCSSValue(property->id());

Modified: trunk/Source/WebCore/css/CSSStyleDeclaration.h (97984 => 97985)


--- trunk/Source/WebCore/css/CSSStyleDeclaration.h	2011-10-20 16:07:46 UTC (rev 97984)
+++ trunk/Source/WebCore/css/CSSStyleDeclaration.h	2011-10-20 16:23:55 UTC (rev 97985)
@@ -21,6 +21,7 @@
 #ifndef CSSStyleDeclaration_h
 #define CSSStyleDeclaration_h
 
+#include "CSSRule.h"
 #include "StyleBase.h"
 #include <wtf/Forward.h>
 
@@ -28,17 +29,43 @@
 
 class CSSMutableStyleDeclaration;
 class CSSProperty;
-class CSSRule;
+class CSSStyleSheet;
 class CSSValue;
 
 typedef int ExceptionCode;
 
-class CSSStyleDeclaration : public StyleBase {
+class CSSStyleDeclaration : public RefCounted<CSSStyleDeclaration> {
 public:
+    virtual ~CSSStyleDeclaration() { }
+
     static bool isPropertyName(const String&);
 
-    CSSRule* parentRule() const;
+    // FIXME: Refactor so CSSStyleDeclaration never needs to have a style sheet parent.
 
+    CSSRule* parentRule() const
+    {
+        return m_parentIsRule ? m_parentRule : 0;
+    }
+
+    void setParentRule(CSSRule* rule)
+    {
+        m_parentIsRule = true;
+        m_parentRule = rule;
+    }
+
+    void setParentStyleSheet(CSSStyleSheet* styleSheet)
+    {
+        m_parentIsRule = false;
+        m_parentStyleSheet = styleSheet;
+    }
+
+    CSSStyleSheet* parentStyleSheet() const
+    {
+        if (!m_parentIsRule)
+            return m_parentStyleSheet;
+        return m_parentRule ? m_parentRule->parentStyleSheet() : 0;
+    }
+
     virtual String cssText() const = 0;
     virtual void setCssText(const String&, ExceptionCode&) = 0;
 
@@ -76,11 +103,19 @@
     void showStyle();
 #endif
 
+    virtual bool isMutableStyleDeclaration() const { return false; }
+
 protected:
     CSSStyleDeclaration(CSSRule* parentRule = 0);
 
     virtual bool cssPropertyMatches(const CSSProperty*) const;
 
+private:
+    bool m_parentIsRule;
+    union {
+        CSSRule* m_parentRule;
+        CSSStyleSheet* m_parentStyleSheet;
+    };
 };
 
 } // namespace WebCore

Modified: trunk/Source/WebCore/css/CSSStyleRule.cpp (97984 => 97985)


--- trunk/Source/WebCore/css/CSSStyleRule.cpp	2011-10-20 16:07:46 UTC (rev 97984)
+++ trunk/Source/WebCore/css/CSSStyleRule.cpp	2011-10-20 16:23:55 UTC (rev 97985)
@@ -40,7 +40,7 @@
 CSSStyleRule::~CSSStyleRule()
 {
     if (m_style)
-        m_style->setParent(0);
+        m_style->setParentRule(0);
 }
 
 String CSSStyleRule::selectorText() const
@@ -57,7 +57,7 @@
 void CSSStyleRule::setSelectorText(const String& selectorText)
 {
     Document* doc = 0;
-    StyleSheet* ownerStyleSheet = m_style->stylesheet();
+    StyleSheet* ownerStyleSheet = m_style->parentStyleSheet();
     if (ownerStyleSheet) {
         if (ownerStyleSheet->isCSSStyleSheet())
             doc = static_cast<CSSStyleSheet*>(ownerStyleSheet)->document();

Modified: trunk/Source/WebCore/css/StyleBase.cpp (97984 => 97985)


--- trunk/Source/WebCore/css/StyleBase.cpp	2011-10-20 16:07:46 UTC (rev 97984)
+++ trunk/Source/WebCore/css/StyleBase.cpp	2011-10-20 16:23:55 UTC (rev 97985)
@@ -46,9 +46,6 @@
     if (isStyleSheet())
         return static_cast<StyleSheet*>(this)->ownerNode();
 
-    if (isMutableStyleDeclaration())
-        return static_cast<CSSMutableStyleDeclaration*>(this)->node();
-
     return 0;
 }
 

Modified: trunk/Source/WebCore/css/StyleBase.h (97984 => 97985)


--- trunk/Source/WebCore/css/StyleBase.h	2011-10-20 16:07:46 UTC (rev 97984)
+++ trunk/Source/WebCore/css/StyleBase.h	2011-10-20 16:23:55 UTC (rev 97985)
@@ -53,8 +53,6 @@
         virtual bool isCSSStyleSheet() const { return false; }
         virtual bool isXSLStyleSheet() const { return false; }
 
-        virtual bool isMutableStyleDeclaration() const { return false; }
-
         virtual String cssText() const;
 
         virtual void checkLoaded();

Modified: trunk/Source/WebCore/css/WebKitCSSKeyframeRule.cpp (97984 => 97985)


--- trunk/Source/WebCore/css/WebKitCSSKeyframeRule.cpp	2011-10-20 16:07:46 UTC (rev 97984)
+++ trunk/Source/WebCore/css/WebKitCSSKeyframeRule.cpp	2011-10-20 16:23:55 UTC (rev 97985)
@@ -38,7 +38,7 @@
 WebKitCSSKeyframeRule::~WebKitCSSKeyframeRule()
 {
     if (m_style)
-        m_style->setParent(0);
+        m_style->setParentStyleSheet(0);
 }
 
 String WebKitCSSKeyframeRule::cssText() const
@@ -61,7 +61,7 @@
 void WebKitCSSKeyframeRule::setDeclaration(PassRefPtr<CSSMutableStyleDeclaration> style)
 {
     m_style = style;
-    m_style->setParent(parent());
+    m_style->setParentStyleSheet(parentStyleSheet());
 }
 
 /* static */

Modified: trunk/Source/WebCore/css/WebKitCSSKeyframesRule.cpp (97984 => 97985)


--- trunk/Source/WebCore/css/WebKitCSSKeyframesRule.cpp	2011-10-20 16:07:46 UTC (rev 97984)
+++ trunk/Source/WebCore/css/WebKitCSSKeyframesRule.cpp	2011-10-20 16:23:55 UTC (rev 97985)
@@ -45,7 +45,7 @@
     for (unsigned i = 0; i < length(); ++i) {
         WebKitCSSKeyframeRule* rule = item(i);
         if (CSSMutableStyleDeclaration* style = rule->style())
-            style->setParent(0);
+            style->setParentRule(0);
         rule->setParent(0);
     }
 }
@@ -93,7 +93,7 @@
     rule->setParent(this);
 
     if (CSSMutableStyleDeclaration* style = rule->style())
-        style->setParent(this);
+        style->setParentRule(this);
 }
 
 void WebKitCSSKeyframesRule::insertRule(const String& rule)
@@ -112,7 +112,7 @@
 
     WebKitCSSKeyframeRule* rule = item(i);
     if (CSSMutableStyleDeclaration* style = rule->style())
-        style->setParent(0);
+        style->setParentRule(0);
 
     m_lstCSSRules->deleteRule(i);
 }

Modified: trunk/Source/WebCore/dom/StyledElement.cpp (97984 => 97985)


--- trunk/Source/WebCore/dom/StyledElement.cpp	2011-10-20 16:07:46 UTC (rev 97984)
+++ trunk/Source/WebCore/dom/StyledElement.cpp	2011-10-20 16:23:55 UTC (rev 97985)
@@ -130,7 +130,7 @@
 void StyledElement::createInlineStyleDecl()
 {
     m_inlineStyleDecl = CSSMutableStyleDeclaration::create();
-    m_inlineStyleDecl->setParent(document()->elementSheet());
+    m_inlineStyleDecl->setParentStyleSheet(document()->elementSheet());
     m_inlineStyleDecl->setNode(this);
     m_inlineStyleDecl->setStrictParsing(isHTMLElement() && !document()->inQuirksMode());
 }
@@ -139,7 +139,7 @@
 {
     if (m_inlineStyleDecl) {
         m_inlineStyleDecl->setNode(0);
-        m_inlineStyleDecl->setParent(0);
+        m_inlineStyleDecl->setParentStyleSheet(0);
         m_inlineStyleDecl = 0;
     }
 }
@@ -195,7 +195,7 @@
         // Add the decl to the table in the appropriate spot.
         setMappedAttributeDecl(entry, attr, attr->decl());
         attr->decl()->setMappedState(entry, attr->name(), attr->value());
-        attr->decl()->setParent(0);
+        attr->decl()->setParentStyleSheet(0);
         attr->decl()->setNode(0);
         if (attributeMap())
             attributeMap()->declAdded();
@@ -405,7 +405,7 @@
 {
     RefPtr<CSSMappedAttributeDeclaration> decl = CSSMappedAttributeDeclaration::create();
     attr->setDecl(decl);
-    decl->setParent(document()->elementSheet());
+    decl->setParentStyleSheet(document()->elementSheet());
     decl->setNode(this);
     decl->setStrictParsing(false); // Mapped attributes are just always quirky.
 }
@@ -454,7 +454,7 @@
 void StyledElement::didMoveToNewOwnerDocument()
 {
     if (m_inlineStyleDecl)
-        m_inlineStyleDecl->setParent(document()->elementSheet());
+        m_inlineStyleDecl->setParentStyleSheet(document()->elementSheet());
 
     Element::didMoveToNewOwnerDocument();
 }

Modified: trunk/Source/WebCore/html/HTMLTableElement.cpp (97984 => 97985)


--- trunk/Source/WebCore/html/HTMLTableElement.cpp	2011-10-20 16:07:46 UTC (rev 97984)
+++ trunk/Source/WebCore/html/HTMLTableElement.cpp	2011-10-20 16:23:55 UTC (rev 97985)
@@ -455,7 +455,7 @@
     CSSMappedAttributeDeclaration* decl = getMappedAttributeDecl(ePersistent, tableborderAttr, borderValue);
     if (!decl) {
         decl = CSSMappedAttributeDeclaration::create().releaseRef(); // This single ref pins us in the table until the document dies.
-        decl->setParent(document()->elementSheet());
+        decl->setParentStyleSheet(document()->elementSheet());
         decl->setNode(this);
         decl->setStrictParsing(false); // Mapped attributes are just always quirky.
         
@@ -466,7 +466,7 @@
         decl->setProperty(CSSPropertyBorderRightStyle, v, false);
 
         setMappedAttributeDecl(ePersistent, tableborderAttr, borderValue, decl);
-        decl->setParent(0);
+        decl->setParentStyleSheet(0);
         decl->setNode(0);
         decl->setMappedState(ePersistent, tableborderAttr, borderValue);
     }
@@ -513,7 +513,7 @@
     CSSMappedAttributeDeclaration* decl = getMappedAttributeDecl(ePersistent, cellborderAttr, cellborderValue);
     if (!decl) {
         decl = CSSMappedAttributeDeclaration::create().releaseRef(); // This single ref pins us in the table until the document dies.
-        decl->setParent(document()->elementSheet());
+        decl->setParentStyleSheet(document()->elementSheet());
         decl->setNode(this);
         decl->setStrictParsing(false); // Mapped attributes are just always quirky.
         
@@ -554,7 +554,7 @@
         }
 
         setMappedAttributeDecl(ePersistent, cellborderAttr, *cellBorderNames[borders], decl);
-        decl->setParent(0);
+        decl->setParentStyleSheet(0);
         decl->setNode(0);
         decl->setMappedState(ePersistent, cellborderAttr, cellborderValue);
     }
@@ -572,7 +572,7 @@
         m_paddingDecl = getMappedAttributeDecl(eUniversal, cellpaddingAttr, paddingValue);
         if (!m_paddingDecl) {
             m_paddingDecl = CSSMappedAttributeDeclaration::create();
-            m_paddingDecl->setParent(document()->elementSheet());
+            m_paddingDecl->setParentStyleSheet(document()->elementSheet());
             m_paddingDecl->setNode(this);
             m_paddingDecl->setStrictParsing(false); // Mapped attributes are just always quirky.
             
@@ -582,7 +582,7 @@
             m_paddingDecl->setProperty(CSSPropertyPaddingLeft, paddingValue, false);
         }
         setMappedAttributeDecl(eUniversal, cellpaddingAttr, paddingValue, m_paddingDecl.get());
-        m_paddingDecl->setParent(0);
+        m_paddingDecl->setParentStyleSheet(0);
         m_paddingDecl->setNode(0);
         m_paddingDecl->setMappedState(eUniversal, cellpaddingAttr, paddingValue);
     }
@@ -599,7 +599,7 @@
     CSSMappedAttributeDeclaration* decl = getMappedAttributeDecl(ePersistent, rulesAttr, rulesValue);
     if (!decl) {
         decl = CSSMappedAttributeDeclaration::create().releaseRef(); // This single ref pins us in the table until the document dies.
-        decl->setParent(document()->elementSheet());
+        decl->setParentStyleSheet(document()->elementSheet());
         decl->setNode(this);
         decl->setStrictParsing(false); // Mapped attributes are just always quirky.
         
@@ -616,7 +616,7 @@
         }
 
         setMappedAttributeDecl(ePersistent, rulesAttr, rulesValue, decl);
-        decl->setParent(0);
+        decl->setParentStyleSheet(0);
         decl->setNode(0);
         decl->setMappedState(ePersistent, rulesAttr, rulesValue);
     }

Modified: trunk/Source/WebCore/page/PageSerializer.cpp (97984 => 97985)


--- trunk/Source/WebCore/page/PageSerializer.cpp	2011-10-20 16:07:46 UTC (rev 97984)
+++ trunk/Source/WebCore/page/PageSerializer.cpp	2011-10-20 16:23:55 UTC (rev 97985)
@@ -311,11 +311,9 @@
     if (!styleDeclaration)
         return;
 
-    if (!styleDeclaration->stylesheet()->isCSSStyleSheet())
-        return;
+    CSSStyleSheet* cssStyleSheet = styleDeclaration->parentStyleSheet();
+    ASSERT(cssStyleSheet);
 
-    CSSStyleSheet* cssStyleSheet = static_cast<CSSStyleSheet*>(styleDeclaration->stylesheet());
-
     // 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.

Modified: trunk/Source/WebCore/svg/SVGFontFaceElement.cpp (97984 => 97985)


--- trunk/Source/WebCore/svg/SVGFontFaceElement.cpp	2011-10-20 16:07:46 UTC (rev 97984)
+++ trunk/Source/WebCore/svg/SVGFontFaceElement.cpp	2011-10-20 16:23:55 UTC (rev 97985)
@@ -52,7 +52,7 @@
     , m_styleDeclaration(CSSMutableStyleDeclaration::create())
 {
     ASSERT(hasTagName(font_faceTag));
-    m_styleDeclaration->setParent(document->mappedElementSheet());
+    m_styleDeclaration->setParentStyleSheet(document->mappedElementSheet());
     m_styleDeclaration->setStrictParsing(true);
     m_fontFaceRule->setDeclaration(m_styleDeclaration.get());
 }
_______________________________________________
webkit-changes mailing list
webkit-changes@lists.webkit.org
http://lists.webkit.org/mailman/listinfo.cgi/webkit-changes

Reply via email to