Diff
Modified: trunk/Source/WebCore/ChangeLog (101171 => 101172)
--- trunk/Source/WebCore/ChangeLog 2011-11-25 14:35:08 UTC (rev 101171)
+++ trunk/Source/WebCore/ChangeLog 2011-11-25 14:44:55 UTC (rev 101172)
@@ -1,3 +1,83 @@
+2011-11-25 Andreas Kling <kl...@webkit.org>
+
+ Factor element pointer out of CSSMutableStyleDeclaration.
+ <http://webkit.org/b/73121>
+
+ Reviewed by Antti Koivisto.
+
+ Move the StyledElement pointer out of CSSMutableStyleDeclaration and into a subclass
+ for the cases where it's needed. This reduces the size of vanilla style declarations
+ by one CPU word (4 or 8 bytes, depending on architecture.)
+
+ * css/CSSMutableStyleDeclaration.h:
+ (WebCore::CSSElementStyleDeclaration::element):
+ (WebCore::CSSElementStyleDeclaration::setElement):
+ (WebCore::CSSElementStyleDeclaration::CSSElementStyleDeclaration):
+ (WebCore::CSSElementStyleDeclaration::~CSSElementStyleDeclaration):
+
+ Added CSSElementStyleDeclaration, a common parent class for inline styles
+ and mapped attributes. It extends CSSMutableStyleDeclaration by adding a backpointer
+ to the StyledElement that owns it.
+
+ * GNUmakefile.list.am:
+ * Target.pri:
+ * WebCore.gypi:
+ * WebCore.vcproj/WebCore.vcproj:
+ * WebCore.xcodeproj/project.pbxproj:
+ * css/CSSInlineStyleDeclaration.h: Added.
+ (WebCore::CSSInlineStyleDeclaration::~CSSInlineStyleDeclaration):
+ (WebCore::CSSInlineStyleDeclaration::create):
+ (WebCore::CSSInlineStyleDeclaration::CSSInlineStyleDeclaration):
+
+ Added CSSInlineStyleDeclaration.
+
+ * bindings/js/JSDOMBinding.h:
+ (WebCore::root):
+ * css/CSSMutableStyleDeclaration.cpp:
+ (WebCore::CSSMutableStyleDeclaration::setNeedsStyleRecalc):
+ * css/CSSStyleRule.cpp:
+ (WebCore::CSSStyleRule::setSelectorText):
+
+ Only follow the associated element on CSSElementStyleDeclarations.
+
+ * css/CSSMutableStyleDeclaration.cpp:
+ (WebCore::CSSMutableStyleDeclaration::CSSMutableStyleDeclaration):
+ (WebCore::CSSMutableStyleDeclaration::operator=):
+
+ Remove comment about m_element since the field was moved to a subclass.
+
+ * css/CSSStyleDeclaration.cpp:
+ (WebCore::CSSStyleDeclaration::CSSStyleDeclaration):
+ * css/CSSStyleDeclaration.h:
+ (WebCore::CSSStyleDeclaration::isElementStyleDeclaration):
+ (WebCore::CSSStyleDeclaration::isInlineStyleDeclaration):
+
+ We no longer need to track whether a style declaration is mutable or not,
+ so the constructors are slightly simplified.
+ Added two bits (isElementStyleDeclaration and isInlineStyleDeclaration) for
+ runtime type checking. These are protected and set by the CSSElementStyleDeclaration
+ constructor.
+
+ * dom/CSSMappedAttributeDeclaration.h:
+ (WebCore::CSSMappedAttributeDeclaration::create):
+ (WebCore::CSSMappedAttributeDeclaration::CSSMappedAttributeDeclaration):
+
+ Remove pointless CSSRule* argument to constructor since we always passed 0.
+
+ * dom/StyledElement.h:
+ (WebCore::StyledElement::inlineStyleDecl):
+ * dom/StyledElement.cpp:
+ (WebCore::StyledElement::createInlineStyleDecl):
+ (WebCore::StyledElement::getInlineStyleDecl):
+ (WebCore::StyledElement::addSubresourceAttributeURLs):
+
+ Make the inline style on StyledElement a CSSInlineStyleDeclaration.
+
+ * inspector/InspectorCSSAgent.cpp:
+ (WebCore::InspectorCSSAgent::inlineStyleElement):
+
+ Slightly simplified by having CSSInlineStyleDeclaration.
+
2011-11-25 Pavel Feldman <pfeld...@google.com>
Web Inspector: unflake timeline-network tests
Modified: trunk/Source/WebCore/GNUmakefile.list.am (101171 => 101172)
--- trunk/Source/WebCore/GNUmakefile.list.am 2011-11-25 14:35:08 UTC (rev 101171)
+++ trunk/Source/WebCore/GNUmakefile.list.am 2011-11-25 14:44:55 UTC (rev 101172)
@@ -1011,6 +1011,7 @@
Source/WebCore/css/CSSInheritedValue.h \
Source/WebCore/css/CSSInitialValue.cpp \
Source/WebCore/css/CSSInitialValue.h \
+ Source/WebCore/css/CSSInlineStyleDeclaration.h \
Source/WebCore/css/CSSLineBoxContainValue.cpp \
Source/WebCore/css/CSSLineBoxContainValue.h \
Source/WebCore/css/CSSMediaRule.cpp \
Modified: trunk/Source/WebCore/Target.pri (101171 => 101172)
--- trunk/Source/WebCore/Target.pri 2011-11-25 14:35:08 UTC (rev 101171)
+++ trunk/Source/WebCore/Target.pri 2011-11-25 14:44:55 UTC (rev 101172)
@@ -1511,6 +1511,7 @@
css/CSSImportRule.h \
css/CSSInheritedValue.h \
css/CSSInitialValue.h \
+ css/CSSInlineStyleDeclaration.h \
css/CSSMediaRule.h \
css/CSSMutableStyleDeclaration.h \
css/CSSOMUtils.h \
Modified: trunk/Source/WebCore/WebCore.gypi (101171 => 101172)
--- trunk/Source/WebCore/WebCore.gypi 2011-11-25 14:35:08 UTC (rev 101171)
+++ trunk/Source/WebCore/WebCore.gypi 2011-11-25 14:44:55 UTC (rev 101172)
@@ -488,6 +488,7 @@
'css/CSSHelper.h',
'css/CSSImageGeneratorValue.h',
'css/CSSImageValue.h',
+ 'css/CSSInlineStyleDeclaration.h',
'css/CSSLineBoxContainValue.h',
'css/CSSMutableStyleDeclaration.h',
'css/CSSParserValues.h',
Modified: trunk/Source/WebCore/WebCore.vcproj/WebCore.vcproj (101171 => 101172)
--- trunk/Source/WebCore/WebCore.vcproj/WebCore.vcproj 2011-11-25 14:35:08 UTC (rev 101171)
+++ trunk/Source/WebCore/WebCore.vcproj/WebCore.vcproj 2011-11-25 14:44:55 UTC (rev 101172)
@@ -32570,6 +32570,10 @@
>
</File>
<File
+ RelativePath="..\css\CSSInlineStyleDeclaration.h"
+ >
+ </File>
+ <File
RelativePath="..\css\CSSLineBoxContainValue.cpp"
>
</File>
Modified: trunk/Source/WebCore/WebCore.xcodeproj/project.pbxproj (101171 => 101172)
--- trunk/Source/WebCore/WebCore.xcodeproj/project.pbxproj 2011-11-25 14:35:08 UTC (rev 101171)
+++ trunk/Source/WebCore/WebCore.xcodeproj/project.pbxproj 2011-11-25 14:44:55 UTC (rev 101172)
@@ -2952,6 +2952,7 @@
8CADF2AB135C7B36009EF43F /* LevelDBDatabase.h in Headers */ = {isa = PBXBuildFile; fileRef = 8CADF2A5135C7B36009EF43F /* LevelDBDatabase.h */; };
8CADF2AD135C7B36009EF43F /* LevelDBIterator.h in Headers */ = {isa = PBXBuildFile; fileRef = 8CADF2A7135C7B36009EF43F /* LevelDBIterator.h */; };
8CADF2AE135C7B36009EF43F /* LevelDBSlice.h in Headers */ = {isa = PBXBuildFile; fileRef = 8CADF2A8135C7B36009EF43F /* LevelDBSlice.h */; };
+ 8CF7DDE4147ECF940041A6F2 /* CSSInlineStyleDeclaration.h in Headers */ = {isa = PBXBuildFile; fileRef = 8CF7DDE1147E432D0041A6F2 /* CSSInlineStyleDeclaration.h */; settings = {ATTRIBUTES = (Private, ); }; };
8F67561B1288B17B0047ACA3 /* EventQueue.h in Headers */ = {isa = PBXBuildFile; fileRef = 8F6756191288B17B0047ACA3 /* EventQueue.h */; settings = {ATTRIBUTES = (Private, ); }; };
8FAC774D119872CB0015AE94 /* JSMainThreadExecState.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 8F934D841189F1EE00508D5D /* JSMainThreadExecState.cpp */; };
9001774012E0347800648462 /* OESStandardDerivatives.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 9001773D12E0347800648462 /* OESStandardDerivatives.cpp */; };
@@ -10162,6 +10163,7 @@
8CADF2A5135C7B36009EF43F /* LevelDBDatabase.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = LevelDBDatabase.h; sourceTree = "<group>"; };
8CADF2A7135C7B36009EF43F /* LevelDBIterator.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = LevelDBIterator.h; sourceTree = "<group>"; };
8CADF2A8135C7B36009EF43F /* LevelDBSlice.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = LevelDBSlice.h; sourceTree = "<group>"; };
+ 8CF7DDE1147E432D0041A6F2 /* CSSInlineStyleDeclaration.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = CSSInlineStyleDeclaration.h; sourceTree = "<group>"; };
8F6756191288B17B0047ACA3 /* EventQueue.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = EventQueue.h; sourceTree = "<group>"; };
8F934D831189F1EE00508D5D /* JSMainThreadExecState.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = JSMainThreadExecState.h; sourceTree = "<group>"; };
8F934D841189F1EE00508D5D /* JSMainThreadExecState.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = JSMainThreadExecState.cpp; sourceTree = "<group>"; };
@@ -20632,6 +20634,7 @@
F523D18402DE42E8018635CA /* css */ = {
isa = PBXGroup;
children = (
+ 8CF7DDE1147E432D0041A6F2 /* CSSInlineStyleDeclaration.h */,
5038BC0614711CDB0095E0D1 /* WebKitCSSShaderValue.cpp */,
50B42157146976960087E604 /* WebKitCSSShaderValue.h */,
AD03AAF81468453900A39B5B /* CSSValue.cpp */,
@@ -21705,6 +21708,7 @@
isa = PBXHeadersBuildPhase;
buildActionMask = 2147483647;
files = (
+ 8CF7DDE4147ECF940041A6F2 /* CSSInlineStyleDeclaration.h in Headers */,
A3BB59F41457A40D00AC56FE /* DocumentEventQueue.h in Headers */,
3106037014327D2E00ABF4BA /* WebKitCSSFilterValue.h in Headers */,
A8EA800C0A19516E00A8EF5F /* StyleSheet.h in Headers */,
Modified: trunk/Source/WebCore/bindings/js/JSDOMBinding.h (101171 => 101172)
--- trunk/Source/WebCore/bindings/js/JSDOMBinding.h 2011-11-25 14:35:08 UTC (rev 101171)
+++ trunk/Source/WebCore/bindings/js/JSDOMBinding.h 2011-11-25 14:44:55 UTC (rev 101172)
@@ -22,6 +22,7 @@
#ifndef JSDOMBinding_h
#define JSDOMBinding_h
+#include "CSSMutableStyleDeclaration.h"
#include "CSSRule.h"
#include "CSSStyleSheet.h"
#include "JSDOMGlobalObject.h"
@@ -206,9 +207,9 @@
return root(parentRule);
if (CSSStyleSheet* styleSheet = style->parentStyleSheet())
return root(styleSheet);
- if (style->isMutableStyleDeclaration()) {
- if (Node* node = static_cast<CSSMutableStyleDeclaration*>(style)->element())
- return root(node);
+ if (style->isElementStyleDeclaration()) {
+ if (StyledElement* element = static_cast<CSSElementStyleDeclaration*>(style)->element())
+ return root(element);
}
return style;
}
Added: trunk/Source/WebCore/css/CSSInlineStyleDeclaration.h (0 => 101172)
--- trunk/Source/WebCore/css/CSSInlineStyleDeclaration.h (rev 0)
+++ trunk/Source/WebCore/css/CSSInlineStyleDeclaration.h 2011-11-25 14:44:55 UTC (rev 101172)
@@ -0,0 +1,52 @@
+/*
+ * Copyright (C) 2004, 2005, 2006, 2008 Apple Inc. All rights reserved.
+ * Copyright (C) 2011 Andreas Kling (kl...@webkit.org)
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY APPLE COMPUTER, INC. ``AS IS'' AND ANY
+ * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE COMPUTER, INC. OR
+ * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
+ * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
+ * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
+ * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
+ * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+ * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#ifndef CSSInlineStyleDeclaration_h
+#define CSSInlineStyleDeclaration_h
+
+#include "CSSMutableStyleDeclaration.h"
+
+namespace WebCore {
+
+class CSSInlineStyleDeclaration : public CSSElementStyleDeclaration {
+public:
+ virtual ~CSSInlineStyleDeclaration() { }
+
+ static PassRefPtr<CSSInlineStyleDeclaration> create()
+ {
+ return adoptRef(new CSSInlineStyleDeclaration);
+ }
+
+private:
+ CSSInlineStyleDeclaration()
+ : CSSElementStyleDeclaration(/* isInline */ true)
+ {
+ }
+};
+
+} // namespace WebCore
+
+#endif // CSSInlineStyleDeclaration_h
Modified: trunk/Source/WebCore/css/CSSMutableStyleDeclaration.cpp (101171 => 101172)
--- trunk/Source/WebCore/css/CSSMutableStyleDeclaration.cpp 2011-11-25 14:35:08 UTC (rev 101171)
+++ trunk/Source/WebCore/css/CSSMutableStyleDeclaration.cpp 2011-11-25 14:44:55 UTC (rev 101172)
@@ -107,31 +107,27 @@
#endif // ENABLE(MUTATION_OBSERVERS)
CSSMutableStyleDeclaration::CSSMutableStyleDeclaration()
- : CSSStyleDeclaration(0, /* isMutable */ true)
- , m_element(0)
+ : CSSStyleDeclaration(0)
{
// This constructor is used for various inline style declarations, so disable strict parsing.
m_strictParsing = false;
}
CSSMutableStyleDeclaration::CSSMutableStyleDeclaration(CSSRule* parent)
- : CSSStyleDeclaration(parent, /* isMutable */ true)
- , m_element(0)
+ : CSSStyleDeclaration(parent)
{
}
CSSMutableStyleDeclaration::CSSMutableStyleDeclaration(CSSRule* parent, const Vector<CSSProperty>& properties)
- : CSSStyleDeclaration(parent, /* isMutable */ true)
+ : CSSStyleDeclaration(parent)
, m_properties(properties)
- , m_element(0)
{
m_properties.shrinkToFit();
// FIXME: This allows duplicate properties.
}
CSSMutableStyleDeclaration::CSSMutableStyleDeclaration(CSSRule* parent, const CSSProperty* const * properties, int numProperties)
- : CSSStyleDeclaration(parent, /* isMutable */ true)
- , m_element(0)
+ : CSSStyleDeclaration(parent)
{
m_properties.reserveInitialCapacity(numProperties);
HashMap<int, bool> candidates;
@@ -156,7 +152,6 @@
CSSMutableStyleDeclaration& CSSMutableStyleDeclaration::operator=(const CSSMutableStyleDeclaration& other)
{
ASSERT(!m_iteratorCount);
- // don't attach it to the same element, just leave the current m_element value
m_properties = other.m_properties;
m_strictParsing = other.m_strictParsing;
return *this;
@@ -614,24 +609,18 @@
return value;
}
-bool CSSMutableStyleDeclaration::isInlineStyleDeclaration()
-{
- // FIXME: Ideally, this should be factored better and there
- // should be a subclass of CSSMutableStyleDeclaration just
- // for inline style declarations that handles this
- return m_element && m_element->inlineStyleDecl() == this;
-}
-
void CSSMutableStyleDeclaration::setNeedsStyleRecalc()
{
- if (m_element) {
- if (isInlineStyleDeclaration()) {
- m_element->setNeedsStyleRecalc(InlineStyleChange);
- m_element->invalidateStyleAttribute();
- if (m_element->document())
- InspectorInstrumentation::didInvalidateStyleAttr(m_element->document(), m_element);
- } else
- m_element->setNeedsStyleRecalc(FullStyleChange);
+ if (isElementStyleDeclaration() && static_cast<CSSElementStyleDeclaration*>(this)->element()) {
+ StyledElement* element = static_cast<CSSElementStyleDeclaration*>(this)->element();
+ if (!isInlineStyleDeclaration())
+ element->setNeedsStyleRecalc(FullStyleChange);
+ else {
+ element->setNeedsStyleRecalc(InlineStyleChange);
+ element->invalidateStyleAttribute();
+ if (Document* document = element->document())
+ InspectorInstrumentation::didInvalidateStyleAttr(document, element);
+ }
return;
}
Modified: trunk/Source/WebCore/css/CSSMutableStyleDeclaration.h (101171 => 101172)
--- trunk/Source/WebCore/css/CSSMutableStyleDeclaration.h 2011-11-25 14:35:08 UTC (rev 101171)
+++ trunk/Source/WebCore/css/CSSMutableStyleDeclaration.h 2011-11-25 14:44:55 UTC (rev 101172)
@@ -83,10 +83,6 @@
const_iterator begin() { return const_iterator(this, m_properties.begin()); }
const_iterator end() { return const_iterator(this, m_properties.end()); }
- void setElement(StyledElement* element) { m_element = element; }
-
- StyledElement* element() const { return m_element; }
-
virtual String cssText() const;
virtual void setCssText(const String&, ExceptionCode&);
@@ -139,13 +135,11 @@
bool propertiesEqual(const CSSMutableStyleDeclaration* o) const { return m_properties == o->m_properties; }
- bool isInlineStyleDeclaration();
-
protected:
CSSMutableStyleDeclaration(CSSRule* parentRule);
+ CSSMutableStyleDeclaration();
private:
- CSSMutableStyleDeclaration();
CSSMutableStyleDeclaration(CSSRule* parentRule, const Vector<CSSProperty>&);
CSSMutableStyleDeclaration(CSSRule* parentRule, const CSSProperty* const *, int numProperties);
@@ -178,11 +172,29 @@
Vector<CSSProperty, 4> m_properties;
- StyledElement* m_element;
-
friend class CSSMutableStyleDeclarationConstIterator;
};
+class CSSElementStyleDeclaration : public CSSMutableStyleDeclaration {
+public:
+ StyledElement* element() const { return m_element; }
+ void setElement(StyledElement* element) { m_element = element; }
+
+protected:
+ CSSElementStyleDeclaration(bool isInline)
+ : CSSMutableStyleDeclaration()
+ , m_element(0)
+ {
+ m_isElementStyleDeclaration = true;
+ m_isInlineStyleDeclaration = isInline;
+ }
+
+ virtual ~CSSElementStyleDeclaration() { }
+
+private:
+ StyledElement* m_element;
+};
+
inline CSSMutableStyleDeclarationConstIterator::CSSMutableStyleDeclarationConstIterator(const CSSMutableStyleDeclaration* decl, CSSProperty* current)
: m_decl(decl)
, m_current(current)
Modified: trunk/Source/WebCore/css/CSSStyleDeclaration.cpp (101171 => 101172)
--- trunk/Source/WebCore/css/CSSStyleDeclaration.cpp 2011-11-25 14:35:08 UTC (rev 101171)
+++ trunk/Source/WebCore/css/CSSStyleDeclaration.cpp 2011-11-25 14:44:55 UTC (rev 101172)
@@ -38,12 +38,13 @@
namespace WebCore {
-CSSStyleDeclaration::CSSStyleDeclaration(CSSRule* parent, bool isMutable)
+CSSStyleDeclaration::CSSStyleDeclaration(CSSRule* parent)
: m_strictParsing(!parent || parent->useStrictParsing())
#ifndef NDEBUG
, m_iteratorCount(0)
#endif
- , m_isMutableStyleDeclaration(isMutable)
+ , m_isElementStyleDeclaration(false)
+ , m_isInlineStyleDeclaration(false)
, m_parentIsRule(true)
, m_parentRule(parent)
{
Modified: trunk/Source/WebCore/css/CSSStyleDeclaration.h (101171 => 101172)
--- trunk/Source/WebCore/css/CSSStyleDeclaration.h 2011-11-25 14:35:08 UTC (rev 101171)
+++ trunk/Source/WebCore/css/CSSStyleDeclaration.h 2011-11-25 14:44:55 UTC (rev 101172)
@@ -102,22 +102,28 @@
void showStyle();
#endif
- bool isMutableStyleDeclaration() const { return m_isMutableStyleDeclaration; }
+ bool isElementStyleDeclaration() const { return m_isElementStyleDeclaration; }
+ bool isInlineStyleDeclaration() const { return m_isInlineStyleDeclaration; }
protected:
- CSSStyleDeclaration(CSSRule* parentRule = 0, bool isMutable = false);
+ CSSStyleDeclaration(CSSRule* parentRule = 0);
virtual bool cssPropertyMatches(const CSSProperty*) const;
- // These bits are only used by CSSMutableStyleDeclaration but kept here
+ // The bits in this section are only used by specific subclasses but kept here
// to maximize struct packing.
+
+ // CSSMutableStyleDeclaration bits:
bool m_strictParsing : 1;
#ifndef NDEBUG
unsigned m_iteratorCount : 4;
#endif
+ // CSSElementStyleDeclaration bits:
+ bool m_isElementStyleDeclaration : 1;
+ bool m_isInlineStyleDeclaration : 1;
+
private:
- bool m_isMutableStyleDeclaration : 1;
bool m_parentIsRule : 1;
union {
CSSRule* m_parentRule;
Modified: trunk/Source/WebCore/css/CSSStyleRule.cpp (101171 => 101172)
--- trunk/Source/WebCore/css/CSSStyleRule.cpp 2011-11-25 14:35:08 UTC (rev 101171)
+++ trunk/Source/WebCore/css/CSSStyleRule.cpp 2011-11-25 14:44:55 UTC (rev 101172)
@@ -66,8 +66,10 @@
if (CSSStyleSheet* styleSheet = m_style->parentStyleSheet())
doc = styleSheet->findDocument();
- if (!doc)
- doc = m_style->element() ? m_style->element()->document() : 0;
+ if (!doc && m_style->isElementStyleDeclaration()) {
+ if (StyledElement* element = static_cast<CSSElementStyleDeclaration*>(m_style.get())->element())
+ doc = element->document();
+ }
if (!doc)
return;
Modified: trunk/Source/WebCore/dom/CSSMappedAttributeDeclaration.h (101171 => 101172)
--- trunk/Source/WebCore/dom/CSSMappedAttributeDeclaration.h 2011-11-25 14:35:08 UTC (rev 101171)
+++ trunk/Source/WebCore/dom/CSSMappedAttributeDeclaration.h 2011-11-25 14:44:55 UTC (rev 101172)
@@ -31,11 +31,11 @@
namespace WebCore {
-class CSSMappedAttributeDeclaration : public CSSMutableStyleDeclaration {
+class CSSMappedAttributeDeclaration : public CSSElementStyleDeclaration {
public:
static PassRefPtr<CSSMappedAttributeDeclaration> create()
{
- return adoptRef(new CSSMappedAttributeDeclaration(0));
+ return adoptRef(new CSSMappedAttributeDeclaration);
}
virtual ~CSSMappedAttributeDeclaration();
@@ -48,13 +48,13 @@
}
private:
- CSSMappedAttributeDeclaration(CSSRule* parentRule)
- : CSSMutableStyleDeclaration(parentRule)
+ CSSMappedAttributeDeclaration()
+ : CSSElementStyleDeclaration(/* isInline */ false)
, m_entryType(eNone)
, m_attrName(anyQName())
{
}
-
+
MappedAttributeEntry m_entryType;
QualifiedName m_attrName;
AtomicString m_attrValue;
Modified: trunk/Source/WebCore/dom/StyledElement.cpp (101171 => 101172)
--- trunk/Source/WebCore/dom/StyledElement.cpp 2011-11-25 14:35:08 UTC (rev 101171)
+++ trunk/Source/WebCore/dom/StyledElement.cpp 2011-11-25 14:44:55 UTC (rev 101172)
@@ -25,7 +25,7 @@
#include "StyledElement.h"
#include "Attribute.h"
-#include "CSSMutableStyleDeclaration.h"
+#include "CSSInlineStyleDeclaration.h"
#include "CSSStyleSelector.h"
#include "CSSStyleSheet.h"
#include "CSSValueKeywords.h"
@@ -129,7 +129,7 @@
void StyledElement::createInlineStyleDecl()
{
- m_inlineStyleDecl = CSSMutableStyleDeclaration::create();
+ m_inlineStyleDecl = CSSInlineStyleDeclaration::create();
m_inlineStyleDecl->setParentStyleSheet(document()->elementSheet());
m_inlineStyleDecl->setElement(this);
m_inlineStyleDecl->setStrictParsing(isHTMLElement() && !document()->inQuirksMode());
@@ -249,7 +249,7 @@
}
}
-CSSMutableStyleDeclaration* StyledElement::getInlineStyleDecl()
+CSSInlineStyleDeclaration* StyledElement::getInlineStyleDecl()
{
if (!m_inlineStyleDecl)
createInlineStyleDecl();
@@ -446,7 +446,7 @@
void StyledElement::addSubresourceAttributeURLs(ListHashSet<KURL>& urls) const
{
- if (CSSMutableStyleDeclaration* style = inlineStyleDecl())
+ if (CSSInlineStyleDeclaration* style = inlineStyleDecl())
style->addSubresourceStyleURLs(urls);
}
Modified: trunk/Source/WebCore/dom/StyledElement.h (101171 => 101172)
--- trunk/Source/WebCore/dom/StyledElement.h 2011-11-25 14:35:08 UTC (rev 101171)
+++ trunk/Source/WebCore/dom/StyledElement.h 2011-11-25 14:44:55 UTC (rev 101172)
@@ -25,6 +25,7 @@
#ifndef StyledElement_h
#define StyledElement_h
+#include "CSSInlineStyleDeclaration.h"
#include "Element.h"
#include "MappedAttributeEntry.h"
@@ -32,7 +33,6 @@
class Attribute;
class CSSMappedAttributeDeclaration;
-class CSSMutableStyleDeclaration;
class StyledElement : public Element {
public:
@@ -54,10 +54,10 @@
static CSSMappedAttributeDeclaration* getMappedAttributeDecl(MappedAttributeEntry, Attribute*);
static void setMappedAttributeDecl(MappedAttributeEntry, Attribute*, CSSMappedAttributeDeclaration*);
- CSSMutableStyleDeclaration* inlineStyleDecl() const { return m_inlineStyleDecl.get(); }
+ CSSInlineStyleDeclaration* inlineStyleDecl() const { return m_inlineStyleDecl.get(); }
virtual bool canHaveAdditionalAttributeStyleDecls() const { return false; }
virtual void additionalAttributeStyleDecls(Vector<CSSMutableStyleDeclaration*>&) { }
- CSSMutableStyleDeclaration* getInlineStyleDecl();
+ CSSInlineStyleDeclaration* getInlineStyleDecl();
CSSStyleDeclaration* style();
void invalidateStyleAttribute();
@@ -93,7 +93,7 @@
void destroyInlineStyleDecl();
virtual void updateStyleAttribute() const;
- RefPtr<CSSMutableStyleDeclaration> m_inlineStyleDecl;
+ RefPtr<CSSInlineStyleDeclaration> m_inlineStyleDecl;
};
inline const SpaceSplitString& StyledElement::classNames() const
Modified: trunk/Source/WebCore/inspector/InspectorCSSAgent.cpp (101171 => 101172)
--- trunk/Source/WebCore/inspector/InspectorCSSAgent.cpp 2011-11-25 14:35:08 UTC (rev 101171)
+++ trunk/Source/WebCore/inspector/InspectorCSSAgent.cpp 2011-11-25 14:44:55 UTC (rev 101172)
@@ -442,12 +442,9 @@
// static
Element* InspectorCSSAgent::inlineStyleElement(CSSStyleDeclaration* style)
{
- if (!style || !style->isMutableStyleDeclaration())
+ if (!style || !style->isInlineStyleDeclaration())
return 0;
- CSSMutableStyleDeclaration* mutableStyle = static_cast<CSSMutableStyleDeclaration*>(style);
- if (!mutableStyle->isInlineStyleDeclaration())
- return 0;
- return mutableStyle->element();
+ return static_cast<CSSInlineStyleDeclaration*>(style)->element();
}
InspectorStyleSheetForInlineStyle* InspectorCSSAgent::asInspectorStyleSheet(Element* element)