Move remaining implementation from CSSStyleDeclaration to subclasses
authorantti@apple.com <antti@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Thu, 2 Feb 2012 18:08:08 +0000 (18:08 +0000)
committerantti@apple.com <antti@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Thu, 2 Feb 2012 18:08:08 +0000 (18:08 +0000)
https://bugs.webkit.org/show_bug.cgi?id=77621

Reviewed by Andreas Kling.

This leaves CSSStyleDeclaration a near-pure CSSOM interface.

* bindings/js/JSCSSStyleDeclarationCustom.cpp:
(WebCore::isCSSPropertyName):
(WebCore::JSCSSStyleDeclaration::putDelegate):
* css/CSSComputedStyleDeclaration.cpp:
(WebCore::CSSComputedStyleDeclaration::parentRule):
(WebCore):
* css/CSSComputedStyleDeclaration.h:
(CSSComputedStyleDeclaration):
* css/CSSMutableStyleDeclaration.cpp:
(WebCore::CSSMutableStyleDeclaration::CSSMutableStyleDeclaration):
(WebCore::CSSMutableStyleDeclaration::contextStyleSheet):
(WebCore):
(WebCore::CSSMutableStyleDeclaration::parentRule):
* css/CSSMutableStyleDeclaration.h:
(WebCore::CSSMutableStyleDeclaration::isInlineStyleDeclaration):
(WebCore::CSSMutableStyleDeclaration::parentRuleInternal):
(WebCore::CSSMutableStyleDeclaration::clearParentRule):
(CSSMutableStyleDeclaration):
(WebCore::CSSMutableStyleDeclaration::parentElement):
(WebCore::CSSMutableStyleDeclaration::clearParentElement):
(WebCore::CSSMutableStyleDeclaration::parentStyleSheet):
* css/CSSParser.cpp:
(WebCore::parseColorValue):
(WebCore::parseSimpleLengthValue):
(WebCore::CSSParser::parseValue):
(WebCore::CSSParser::parseDeclaration):
* css/CSSStyleDeclaration.cpp:
(WebCore):
* css/CSSStyleDeclaration.h:
(CSSStyleDeclaration):
(WebCore::CSSStyleDeclaration::parentStyleSheet):
(WebCore::CSSStyleDeclaration::CSSStyleDeclaration):
* css/CSSStyleRule.cpp:
(WebCore::CSSStyleRule::setSelectorText):

    Eliminate unnecessary call to CSSMutableStyleDeclaration::parentStyleSheet()

* css/CSSStyleRule.h:
(WebCore::CSSStyleRule::setDeclaration):
* css/CSSStyleSelector.cpp:
(WebCore::isInsideRegionRule):
(WebCore::CSSStyleSelector::applyDeclaration):
* css/WebKitCSSKeyframeRule.cpp:
(WebCore::WebKitCSSKeyframeRule::setDeclaration):
* page/PageSerializer.cpp:
(WebCore::PageSerializer::serializeFrame):
(WebCore::PageSerializer::serializeCSSStyleSheet):
(WebCore::PageSerializer::retrieveResourcesForCSSRule):
(WebCore::PageSerializer::retrieveResourcesForCSSDeclaration):
* page/PageSerializer.h:

    Eliminate unnecessary call to CSSMutableStyleDeclaration::parentStyleSheet()

(WebCore):
(PageSerializer):

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

15 files changed:
Source/WebCore/ChangeLog
Source/WebCore/bindings/js/JSCSSStyleDeclarationCustom.cpp
Source/WebCore/css/CSSComputedStyleDeclaration.cpp
Source/WebCore/css/CSSComputedStyleDeclaration.h
Source/WebCore/css/CSSMutableStyleDeclaration.cpp
Source/WebCore/css/CSSMutableStyleDeclaration.h
Source/WebCore/css/CSSParser.cpp
Source/WebCore/css/CSSStyleDeclaration.cpp
Source/WebCore/css/CSSStyleDeclaration.h
Source/WebCore/css/CSSStyleRule.cpp
Source/WebCore/css/CSSStyleRule.h
Source/WebCore/css/CSSStyleSelector.cpp
Source/WebCore/css/WebKitCSSKeyframeRule.cpp
Source/WebCore/page/PageSerializer.cpp
Source/WebCore/page/PageSerializer.h

index e5d56bf..7f902eb 100644 (file)
@@ -1,3 +1,68 @@
+2012-02-02  Antti Koivisto  <antti@apple.com>
+
+        Move remaining implementation from CSSStyleDeclaration to subclasses 
+        https://bugs.webkit.org/show_bug.cgi?id=77621
+
+        Reviewed by Andreas Kling.
+
+        This leaves CSSStyleDeclaration a near-pure CSSOM interface.
+
+        * bindings/js/JSCSSStyleDeclarationCustom.cpp:
+        (WebCore::isCSSPropertyName):
+        (WebCore::JSCSSStyleDeclaration::putDelegate):
+        * css/CSSComputedStyleDeclaration.cpp:
+        (WebCore::CSSComputedStyleDeclaration::parentRule):
+        (WebCore):
+        * css/CSSComputedStyleDeclaration.h:
+        (CSSComputedStyleDeclaration):
+        * css/CSSMutableStyleDeclaration.cpp:
+        (WebCore::CSSMutableStyleDeclaration::CSSMutableStyleDeclaration):
+        (WebCore::CSSMutableStyleDeclaration::contextStyleSheet):
+        (WebCore):
+        (WebCore::CSSMutableStyleDeclaration::parentRule):
+        * css/CSSMutableStyleDeclaration.h:
+        (WebCore::CSSMutableStyleDeclaration::isInlineStyleDeclaration):
+        (WebCore::CSSMutableStyleDeclaration::parentRuleInternal):
+        (WebCore::CSSMutableStyleDeclaration::clearParentRule):
+        (CSSMutableStyleDeclaration):
+        (WebCore::CSSMutableStyleDeclaration::parentElement):
+        (WebCore::CSSMutableStyleDeclaration::clearParentElement):
+        (WebCore::CSSMutableStyleDeclaration::parentStyleSheet):
+        * css/CSSParser.cpp:
+        (WebCore::parseColorValue):
+        (WebCore::parseSimpleLengthValue):
+        (WebCore::CSSParser::parseValue):
+        (WebCore::CSSParser::parseDeclaration):
+        * css/CSSStyleDeclaration.cpp:
+        (WebCore):
+        * css/CSSStyleDeclaration.h:
+        (CSSStyleDeclaration):
+        (WebCore::CSSStyleDeclaration::parentStyleSheet):
+        (WebCore::CSSStyleDeclaration::CSSStyleDeclaration):
+        * css/CSSStyleRule.cpp:
+        (WebCore::CSSStyleRule::setSelectorText):
+                            
+            Eliminate unnecessary call to CSSMutableStyleDeclaration::parentStyleSheet()
+
+        * css/CSSStyleRule.h:
+        (WebCore::CSSStyleRule::setDeclaration):
+        * css/CSSStyleSelector.cpp:
+        (WebCore::isInsideRegionRule):
+        (WebCore::CSSStyleSelector::applyDeclaration):
+        * css/WebKitCSSKeyframeRule.cpp:
+        (WebCore::WebKitCSSKeyframeRule::setDeclaration):
+        * page/PageSerializer.cpp:
+        (WebCore::PageSerializer::serializeFrame):
+        (WebCore::PageSerializer::serializeCSSStyleSheet):
+        (WebCore::PageSerializer::retrieveResourcesForCSSRule):
+        (WebCore::PageSerializer::retrieveResourcesForCSSDeclaration):
+        * page/PageSerializer.h:
+        
+            Eliminate unnecessary call to CSSMutableStyleDeclaration::parentStyleSheet()
+        
+        (WebCore):
+        (PageSerializer):
+
 2012-02-02  Chris Marrin  <cmarrin@apple.com>
 
         Turn on CSS Filters on Windows
index 23fda48..126cce1 100644 (file)
@@ -27,6 +27,7 @@
 #include "JSCSSStyleDeclarationCustom.h"
 
 #include "CSSMutableStyleDeclaration.h"
+#include "CSSParser.h"
 #include "CSSPrimitiveValue.h"
 #include "CSSPropertyNames.h"
 #include "CSSValue.h"
@@ -193,7 +194,7 @@ static bool isCSSPropertyName(const Identifier& propertyIdentifier)
 {
     // FIXME: This mallocs a string for the property name and then throws it
     // away.  This shows up on peacekeeper's domDynamicCreationCreateElement.
-    return CSSStyleDeclaration::isPropertyName(cssPropertyName(propertyIdentifier));
+    return cssPropertyID(cssPropertyName(propertyIdentifier));
 }
 
 bool JSCSSStyleDeclaration::canGetItemsForName(ExecState*, CSSStyleDeclaration*, const Identifier& propertyName)
@@ -229,7 +230,7 @@ bool JSCSSStyleDeclaration::putDelegate(ExecState* exec, const Identifier& prope
 {
     bool pixelOrPos;
     String prop = cssPropertyName(propertyName, &pixelOrPos);
-    if (!CSSStyleDeclaration::isPropertyName(prop))
+    if (!cssPropertyID(prop))
         return false;
 
     String propValue = valueToStringWithNullCheck(exec, value);
index 90f98c8..d677437 100644 (file)
@@ -1,6 +1,6 @@
 /*
  * Copyright (C) 2004 Zack Rusin <zack@kde.org>
- * Copyright (C) 2004, 2005, 2006, 2007, 2008, 2009, 2010, 2011 Apple Inc. All rights reserved.
+ * Copyright (C) 2004, 2005, 2006, 2007, 2008, 2009, 2010, 2011, 2012 Apple Inc. All rights reserved.
  * Copyright (C) 2007 Alexey Proskuryakov <ap@webkit.org>
  * Copyright (C) 2007 Nicholas Shanks <webkit@nickshanks.com>
  * Copyright (C) 2011 Sencha, Inc. All rights reserved.
@@ -2574,6 +2574,11 @@ PassRefPtr<CSSMutableStyleDeclaration> CSSComputedStyleDeclaration::copyProperti
     return CSSMutableStyleDeclaration::create(list);
 }
 
+CSSRule* CSSComputedStyleDeclaration::parentRule() const
+{
+    return 0;
+}
+
 PassRefPtr<CSSValue> CSSComputedStyleDeclaration::getPropertyCSSValue(const String& propertyName)
 {
     int propertyID = cssPropertyID(propertyName);
index b44a5cf..2b61355 100644 (file)
@@ -1,6 +1,6 @@
 /*
  * Copyright (C) 2004 Zack Rusin <zack@kde.org>
- * Copyright (C) 2004, 2005, 2006, 2008 Apple Inc. All rights reserved.
+ * Copyright (C) 2004, 2005, 2006, 2008, 2012 Apple Inc. All rights reserved.
  *
  * This library is free software; you can redistribute it and/or
  * modify it under the terms of the GNU Lesser General Public
@@ -70,6 +70,7 @@ private:
     CSSComputedStyleDeclaration(PassRefPtr<Node>, bool allowVisitedStyle, const String&);
 
     // CSSOM functions. Don't make these public.
+    virtual CSSRule* parentRule() const;
     virtual unsigned length() const;
     virtual String item(unsigned index) const;
     virtual PassRefPtr<CSSValue> getPropertyCSSValue(const String& propertyName);
index c7d5d06..8ba60d9 100644 (file)
@@ -1,6 +1,6 @@
 /*
  * (C) 1999-2003 Lars Knoll (knoll@kde.org)
- * Copyright (C) 2004, 2005, 2006, 2007, 2008, 2009, 2010 Apple Inc. All rights reserved.
+ * Copyright (C) 2004, 2005, 2006, 2007, 2008, 2009, 2010, 2012 Apple Inc. All rights reserved.
  * Copyright (C) 2011 Research In Motion Limited. All rights reserved.
  *
  * This library is free software; you can redistribute it and/or
@@ -134,26 +134,33 @@ bool StyleAttributeMutationScope::s_shouldDeliver = false;
 } // namespace
 
 CSSMutableStyleDeclaration::CSSMutableStyleDeclaration()
+    : m_strictParsing(false)
+    , m_isInlineStyleDeclaration(false)
+    , m_parent(static_cast<CSSRule*>(0))
 {
-    // This constructor is used for various inline style declarations, so disable strict parsing.
-    m_strictParsing = false;
 }
 
-CSSMutableStyleDeclaration::CSSMutableStyleDeclaration(CSSRule* parent)
-    : CSSStyleDeclaration(parent)
+CSSMutableStyleDeclaration::CSSMutableStyleDeclaration(CSSRule* parentRule)
+    : m_strictParsing(!parentRule || parentRule->useStrictParsing())
+    , m_isInlineStyleDeclaration(false)
+    , m_parent(parentRule)
 {
 }
 
-CSSMutableStyleDeclaration::CSSMutableStyleDeclaration(CSSRule* parent, const Vector<CSSProperty>& properties)
-    : CSSStyleDeclaration(parent)
-    , m_properties(properties)
+CSSMutableStyleDeclaration::CSSMutableStyleDeclaration(CSSRule* parentRule, const Vector<CSSProperty>& properties)
+    : m_properties(properties)
+    , m_strictParsing(!parentRule || parentRule->useStrictParsing())
+    , m_isInlineStyleDeclaration(false)
+    , m_parent(parentRule)
 {
     m_properties.shrinkToFit();
     // FIXME: This allows duplicate properties.
 }
 
-CSSMutableStyleDeclaration::CSSMutableStyleDeclaration(CSSRule* parent, const CSSProperty* const * properties, int numProperties)
-    : CSSStyleDeclaration(parent)
+CSSMutableStyleDeclaration::CSSMutableStyleDeclaration(CSSRule* parentRule, const CSSProperty* const * properties, int numProperties)
+    : m_strictParsing(!parentRule || parentRule->useStrictParsing())
+    , m_isInlineStyleDeclaration(false)
+    , m_parent(parentRule)
 {
     m_properties.reserveInitialCapacity(numProperties);
     HashMap<int, bool> candidates;
@@ -174,8 +181,10 @@ CSSMutableStyleDeclaration::CSSMutableStyleDeclaration(CSSRule* parent, const CS
     }
 }
 
-CSSMutableStyleDeclaration::CSSMutableStyleDeclaration(StyledElement* element) 
-    : CSSStyleDeclaration(element)
+CSSMutableStyleDeclaration::CSSMutableStyleDeclaration(StyledElement* parentElement) 
+    : m_strictParsing(false)
+    , m_isInlineStyleDeclaration(true)
+    , m_parent(parentElement)
 { 
 }
 
@@ -183,6 +192,15 @@ CSSMutableStyleDeclaration::~CSSMutableStyleDeclaration()
 {
 }
 
+CSSStyleSheet* CSSMutableStyleDeclaration::contextStyleSheet() const
+{
+    if (m_isInlineStyleDeclaration) {
+        Document* document = m_parent.element ? m_parent.element->document() : 0;
+        return document ? document->elementSheet() : 0;
+    }
+    return m_parent.rule ? m_parent.rule->parentStyleSheet() : 0;
+}
+
 void CSSMutableStyleDeclaration::copyPropertiesFrom(const CSSMutableStyleDeclaration& other)
 {
     m_properties = other.m_properties;
@@ -1031,6 +1049,11 @@ CSSProperty* CSSMutableStyleDeclaration::findPropertyWithId(int propertyID)
     return 0;
 }
 
+CSSRule* CSSMutableStyleDeclaration::parentRule() const
+{
+    return parentRuleInternal();
+}
+
 String CSSMutableStyleDeclaration::cssText() const
 {
     return asText();
index 73af49f..5f4fc09 100644 (file)
@@ -1,6 +1,6 @@
 /*
  * (C) 1999-2003 Lars Knoll (knoll@kde.org)
- * Copyright (C) 2004, 2005, 2006, 2008 Apple Inc. All rights reserved.
+ * Copyright (C) 2004, 2005, 2006, 2008, 2012 Apple Inc. All rights reserved.
  *
  * This library is free software; you can redistribute it and/or
  * modify it under the terms of the GNU Library General Public
@@ -95,6 +95,7 @@ public:
 
     void setStrictParsing(bool b) { m_strictParsing = b; }
     bool useStrictParsing() const { return m_strictParsing; }
+    bool isInlineStyleDeclaration() const { return m_isInlineStyleDeclaration; }
 
     void addSubresourceStyleURLs(ListHashSet<KURL>&);
 
@@ -105,6 +106,14 @@ public:
 
     PassRefPtr<CSSMutableStyleDeclaration> copyPropertiesInSet(const int* set, unsigned length) const;
 
+    CSSRule* parentRuleInternal() const { return m_isInlineStyleDeclaration ? 0 : m_parent.rule; }
+    void clearParentRule() { ASSERT(!m_isInlineStyleDeclaration); m_parent.rule = 0; }
+    
+    StyledElement* parentElement() const { ASSERT(m_isInlineStyleDeclaration); return m_parent.element; }
+    void clearParentElement() { ASSERT(m_isInlineStyleDeclaration); m_parent.element = 0; }
+    
+    CSSStyleSheet* contextStyleSheet() const;
+    
     String asText() const;
 
 private:
@@ -117,6 +126,7 @@ private:
     virtual PassRefPtr<CSSMutableStyleDeclaration> makeMutable();
 
     // CSSOM functions. Don't make these public.
+    virtual CSSRule* parentRule() const;
     virtual unsigned length() const;
     virtual String item(unsigned index) const;
     virtual PassRefPtr<CSSValue> getPropertyCSSValue(const String& propertyName);
@@ -153,11 +163,22 @@ private:
     bool removePropertiesInSet(const int* set, unsigned length, bool notifyChanged);
 
     virtual bool cssPropertyMatches(const CSSProperty*) const;
+    virtual CSSStyleSheet* parentStyleSheet() const { return contextStyleSheet(); }
 
     const CSSProperty* findPropertyWithId(int propertyId) const;
     CSSProperty* findPropertyWithId(int propertyId);
 
     Vector<CSSProperty, 4> m_properties;
+
+    bool m_strictParsing : 1;
+    bool m_isInlineStyleDeclaration : 1;
+
+    union Parent {
+        Parent(CSSRule* rule) : rule(rule) { }
+        Parent(StyledElement* element) : element(element) { }
+        CSSRule* rule;
+        StyledElement* element;
+    } m_parent;    
 };
 
 } // namespace WebCore
index ac8d177..7cda4ae 100644 (file)
@@ -346,7 +346,7 @@ static bool parseColorValue(CSSMutableStyleDeclaration* declaration, int propert
         validPrimitive = true;
     }
 
-    CSSStyleSheet* styleSheet = contextStyleSheet ? contextStyleSheet : declaration->parentStyleSheet();
+    CSSStyleSheet* styleSheet = contextStyleSheet ? contextStyleSheet : declaration->contextStyleSheet();
     if (!styleSheet)
         return false;
     Document* document = styleSheet->findDocument();
@@ -473,7 +473,7 @@ static bool parseSimpleLengthValue(CSSMutableStyleDeclaration* declaration, int
     if (number < 0 && !acceptsNegativeNumbers)
         return false;
 
-    CSSStyleSheet* styleSheet = contextStyleSheet ? contextStyleSheet : declaration->parentStyleSheet();
+    CSSStyleSheet* styleSheet = contextStyleSheet ? contextStyleSheet : declaration->contextStyleSheet();
     if (!styleSheet)
         return false;
     Document* document = styleSheet->findDocument();
@@ -513,7 +513,7 @@ bool CSSParser::parseValue(CSSMutableStyleDeclaration* declaration, int property
     if (contextStyleSheet)
         setStyleSheet(contextStyleSheet);
     else
-        setStyleSheet(declaration->parentStyleSheet());
+        setStyleSheet(declaration->contextStyleSheet());
 
     setupParser("@-webkit-value{", string, "} ");
 
@@ -616,7 +616,7 @@ bool CSSParser::parseDeclaration(CSSMutableStyleDeclaration* declaration, const
     if (contextStyleSheet)
         setStyleSheet(contextStyleSheet);
     else
-        setStyleSheet(declaration->parentStyleSheet());
+        setStyleSheet(declaration->contextStyleSheet());
     if (styleSourceData) {
         m_currentRuleData = CSSRuleSourceData::create();
         m_currentRuleData->styleSourceData = CSSStyleSourceData::create();
index 133fea2..a71e00d 100644 (file)
@@ -1,6 +1,6 @@
 /*
  * (C) 1999-2003 Lars Knoll (knoll@kde.org)
- * Copyright (C) 2004, 2005, 2006, 2007, 2008 Apple Inc. All rights reserved.
+ * Copyright (C) 2004, 2005, 2006, 2007, 2008, 2012 Apple Inc. All rights reserved.
  *
  * This library is free software; you can redistribute it and/or
  * modify it under the terms of the GNU Library General Public
 #include "config.h"
 #include "CSSStyleDeclaration.h"
 
-#include "CSSMutableStyleDeclaration.h"
-#include "CSSParser.h"
-#include "CSSProperty.h"
-#include "CSSPropertyNames.h"
-#include "CSSRule.h"
-#include "Node.h"
-#include "SVGElement.h"
-#include "StyledElement.h"
+#ifndef NDEBUG
 #include <wtf/ASCIICType.h>
 #include <wtf/text/CString.h>
-#ifndef NDEBUG
 #include <stdio.h>
 #endif
 
@@ -39,34 +31,6 @@ using namespace WTF;
 
 namespace WebCore {
 
-CSSStyleDeclaration::CSSStyleDeclaration(CSSRule* parentRule)
-    : m_strictParsing(!parentRule || parentRule->useStrictParsing())
-    , m_isInlineStyleDeclaration(false)
-    , m_parent(parentRule)
-{
-}
-
-CSSStyleDeclaration::CSSStyleDeclaration(StyledElement* parentElement)
-    : m_strictParsing(false)
-    , m_isInlineStyleDeclaration(true)
-    , m_parent(parentElement)
-{
-}
-
-CSSStyleSheet* CSSStyleDeclaration::parentStyleSheet() const
-{
-    if (m_isInlineStyleDeclaration) {
-        Document* document = m_parent.element ? m_parent.element->document() : 0;
-        return document ? document->elementSheet() : 0;
-    }
-    return m_parent.rule ? m_parent.rule->parentStyleSheet() : 0;
-}
-
-bool CSSStyleDeclaration::isPropertyName(const String& propertyName)
-{
-    return cssPropertyID(propertyName);
-}
-
 #ifndef NDEBUG
 void CSSStyleDeclaration::showStyle()
 {
index 12910da..a55071f 100644 (file)
@@ -1,6 +1,6 @@
 /*
  * (C) 1999-2003 Lars Knoll (knoll@kde.org)
- * Copyright (C) 2004, 2005, 2006, 2008 Apple Inc. All rights reserved.
+ * Copyright (C) 2004, 2005, 2006, 2008, 2012 Apple Inc. All rights reserved.
  *
  * This library is free software; you can redistribute it and/or
  * modify it under the terms of the GNU Library General Public
@@ -40,16 +40,7 @@ class CSSStyleDeclaration : public RefCounted<CSSStyleDeclaration> {
 public:
     virtual ~CSSStyleDeclaration() { }
 
-    static bool isPropertyName(const String&);
-
-    CSSRule* parentRule() const { return m_isInlineStyleDeclaration ? 0 : m_parent.rule; }
-    void clearParentRule() { ASSERT(!m_isInlineStyleDeclaration); m_parent.rule = 0; }
-
-    StyledElement* parentElement() const { ASSERT(m_isInlineStyleDeclaration); return m_parent.element; }
-    void clearParentElement() { ASSERT(m_isInlineStyleDeclaration); m_parent.element = 0; }
-
-    CSSStyleSheet* parentStyleSheet() const;
-
+    virtual CSSRule* parentRule() const = 0;
     virtual String cssText() const = 0;
     virtual void setCssText(const String&, ExceptionCode&) = 0;
     virtual unsigned length() const = 0;
@@ -72,31 +63,14 @@ public:
     virtual PassRefPtr<CSSMutableStyleDeclaration> makeMutable() = 0;
 
     virtual bool cssPropertyMatches(const CSSProperty*) const = 0;
-
+    virtual CSSStyleSheet* parentStyleSheet() const { return 0; }
 #ifndef NDEBUG
     void showStyle();
 #endif
 
-    bool isInlineStyleDeclaration() const { return m_isInlineStyleDeclaration; }
-
 protected:
-    CSSStyleDeclaration(CSSRule* parentRule = 0);
-    CSSStyleDeclaration(StyledElement* parentElement);
-
-    // The bits in this section are only used by specific subclasses but kept here
-    // to maximize struct packing.
-
-    // CSSMutableStyleDeclaration bits:
-    bool m_strictParsing : 1;
-    bool m_isInlineStyleDeclaration : 1;
-
-private:
-    union Parent {
-        Parent(CSSRule* rule) : rule(rule) { }
-        Parent(StyledElement* element) : element(element) { }
-        CSSRule* rule;
-        StyledElement* element;
-    } m_parent;
+    CSSStyleDeclaration() { }
 };
 
 } // namespace WebCore
index 535e9f1..4f18816 100644 (file)
@@ -98,7 +98,7 @@ String CSSStyleRule::selectorText() const
 void CSSStyleRule::setSelectorText(const String& selectorText)
 {
     Document* doc = 0;
-    if (CSSStyleSheet* styleSheet = m_style->parentStyleSheet())
+    if (CSSStyleSheet* styleSheet = parentStyleSheet())
         doc = styleSheet->findDocument();
     if (!doc)
         return;
index 713e682..0a21577 100644 (file)
@@ -48,7 +48,7 @@ public:
     String cssText() const;
 
     void adoptSelectorVector(Vector<OwnPtr<CSSParserSelector> >& selectors) { m_selectorList.adoptSelectorVector(selectors); }
-    void setDeclaration(PassRefPtr<CSSMutableStyleDeclaration> style) { ASSERT(style->parentRule() == this); m_style = style; }
+    void setDeclaration(PassRefPtr<CSSMutableStyleDeclaration> style) { ASSERT(style->parentRuleInternal() == this); m_style = style; }
 
     const CSSSelectorList& selectorList() const { return m_selectorList; }
     CSSMutableStyleDeclaration* declaration() const { return m_style.get(); }
index abac398..832d101 100644 (file)
@@ -2437,7 +2437,7 @@ static inline bool isInsideRegionRule(CSSMutableStyleDeclaration* styleDeclarati
 {
     ASSERT(styleDeclaration);
 
-    CSSRule* parentRule = styleDeclaration->parentRule();
+    CSSRule* parentRule = styleDeclaration->parentRuleInternal();
     while (parentRule) {
         if (parentRule->isRegionRule())
             return true;
@@ -2449,7 +2449,7 @@ static inline bool isInsideRegionRule(CSSMutableStyleDeclaration* styleDeclarati
 template <bool applyFirst>
 void CSSStyleSelector::applyDeclaration(CSSMutableStyleDeclaration* styleDeclaration, bool isImportant, bool inheritedOnly)
 {
-    InspectorInstrumentationCookie cookie = InspectorInstrumentation::willProcessRule(document(), styleDeclaration->parentRule());
+    InspectorInstrumentationCookie cookie = InspectorInstrumentation::willProcessRule(document(), styleDeclaration->parentRuleInternal());
     bool styleDeclarationInsideRegionRule = m_regionForStyling ? isInsideRegionRule(styleDeclaration) : false;
 
     unsigned propertyCount = styleDeclaration->propertyCount();
index 674aa5a..a324237 100644 (file)
@@ -54,7 +54,7 @@ String WebKitCSSKeyframeRule::cssText() const
 
 void WebKitCSSKeyframeRule::setDeclaration(PassRefPtr<CSSMutableStyleDeclaration> style)
 {
-    ASSERT(style->parentRule() == this);
+    ASSERT(style->parentRuleInternal() == this);
     m_style = style;
 }
 
index 2c3778b..2ea0fbe 100644 (file)
@@ -227,7 +227,7 @@ void PageSerializer::serializeFrame(Frame* frame)
         Element* element = toElement(node);
         // We have to process in-line style as it might contain some resources (typically background images).
         if (element->isStyledElement())
-            retrieveResourcesForCSSDeclaration(static_cast<StyledElement*>(element)->inlineStyleDecl());
+            retrieveResourcesForCSSDeclaration(static_cast<StyledElement*>(element)->inlineStyleDecl(), document);
 
         if (element->hasTagName(HTMLNames::imgTag)) {
             HTMLImageElement* imageElement = static_cast<HTMLImageElement*>(element);
@@ -263,10 +263,10 @@ void PageSerializer::serializeCSSStyleSheet(CSSStyleSheet* styleSheet, const KUR
             if (i < styleSheet->length() - 1)
                 cssText.append("\n\n");
         }
+        Document* document = styleSheet->findDocument();
         // Some rules have resources associated with them that we need to retrieve.
         if (rule->isImportRule()) {
-            CSSImportRule* importRule = static_cast<CSSImportRule*>(rule);
-            Document* document = styleSheet->findDocument();
+            CSSImportRule* importRule = static_cast<CSSImportRule*>(rule);            
             KURL importURL = document->completeURL(importRule->href());
             if (m_resourceURLs.contains(importURL))
                 continue;
@@ -275,7 +275,7 @@ void PageSerializer::serializeCSSStyleSheet(CSSStyleSheet* styleSheet, const KUR
             // FIXME: Add support for font face rule. It is not clear to me at this point if the actual otf/eot file can
             // be retrieved from the CSSFontFaceRule object.
         } else if (rule->isStyleRule())
-            retrieveResourcesForCSSRule(static_cast<CSSStyleRule*>(rule));
+            retrieveResourcesForCSSRule(static_cast<CSSStyleRule*>(rule), document);
     }
 
     if (url.isValid() && !m_resourceURLs.contains(url)) {
@@ -302,19 +302,16 @@ void PageSerializer::addImageToResources(CachedImage* image, RenderObject* image
     m_resourceURLs.add(url);
 }
 
-void PageSerializer::retrieveResourcesForCSSRule(CSSStyleRule* rule)
+void PageSerializer::retrieveResourcesForCSSRule(CSSStyleRule* rule, Document* document)
 {
-    retrieveResourcesForCSSDeclaration(rule->declaration());
+    retrieveResourcesForCSSDeclaration(rule->declaration(), document);
 }
 
-void PageSerializer::retrieveResourcesForCSSDeclaration(CSSMutableStyleDeclaration* styleDeclaration)
+void PageSerializer::retrieveResourcesForCSSDeclaration(CSSMutableStyleDeclaration* styleDeclaration, Document* document)
 {
     if (!styleDeclaration)
         return;
 
-    CSSStyleSheet* cssStyleSheet = styleDeclaration->parentStyleSheet();
-    ASSERT(cssStyleSheet);
-
     // 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.
@@ -332,7 +329,6 @@ void PageSerializer::retrieveResourcesForCSSDeclaration(CSSMutableStyleDeclarati
 
         CachedImage* image = static_cast<StyleCachedImage*>(styleImage)->cachedImage();
 
-        Document* document = cssStyleSheet->findDocument();
         KURL url = document->completeURL(image->url());
         addImageToResources(image, 0, url);
     }
index d92ef20..1a8ae57 100644 (file)
@@ -44,6 +44,7 @@ class CachedImage;
 class CSSMutableStyleDeclaration;
 class CSSStyleRule;
 class CSSStyleSheet;
+class Document;
 class Frame;
 class Page;
 class RenderObject;
@@ -77,8 +78,8 @@ private:
     void serializeCSSStyleSheet(CSSStyleSheet*, const KURL&);
 
     void addImageToResources(CachedImage*, RenderObject*, const KURL&);
-    void retrieveResourcesForCSSDeclaration(CSSMutableStyleDeclaration*);
-    void retrieveResourcesForCSSRule(CSSStyleRule*);
+    void retrieveResourcesForCSSDeclaration(CSSMutableStyleDeclaration*, Document*);
+    void retrieveResourcesForCSSRule(CSSStyleRule*, Document*);
 
     Vector<Resource>* m_resources;
     ListHashSet<KURL> m_resourceURLs;