Diff
Modified: trunk/Source/WebCore/CMakeLists.txt (106322 => 106323)
--- trunk/Source/WebCore/CMakeLists.txt 2012-01-31 03:28:31 UTC (rev 106322)
+++ trunk/Source/WebCore/CMakeLists.txt 2012-01-31 03:53:40 UTC (rev 106323)
@@ -546,6 +546,7 @@
dom/DynamicNodeList.cpp
dom/EditingText.cpp
dom/Element.cpp
+ dom/ElementAttributeData.cpp
dom/EntityReference.cpp
dom/ErrorEvent.cpp
dom/Event.cpp
Modified: trunk/Source/WebCore/ChangeLog (106322 => 106323)
--- trunk/Source/WebCore/ChangeLog 2012-01-31 03:28:31 UTC (rev 106322)
+++ trunk/Source/WebCore/ChangeLog 2012-01-31 03:53:40 UTC (rev 106323)
@@ -1,3 +1,57 @@
+2012-01-30 Caio Marcelo de Oliveira Filho <[email protected]>
+
+ Add ElementAttributeData class to replace internal uses of NamedNodeMap
+ https://bugs.webkit.org/show_bug.cgi?id=77233
+
+ Reviewed by Andreas Kling.
+
+ Move part of non-DOM functionality of NamedNodeMap into a separate class. This is
+ the first step toward the goal of separating NamedNodeMap from internal attribute
+ storage, as described in https://bugs.webkit.org/show_bug.cgi?id=75069.
+
+ The internal attribute storage is exposed as attributeData() in Element, and when
+ necessary (because it has no back pointer to Element) via methods in Element.
+
+ No new tests. Except from setClass() change this is just moving the code, no new
+ feature was added.
+
+ * CMakeLists.txt:
+ * GNUmakefile.list.am:
+ * Target.pri:
+ * WebCore.gypi:
+ * WebCore.xcodeproj/project.pbxproj:
+ * dom/DOMAllInOne.cpp:
+ * dom/Element.cpp:
+ (WebCore::Element::idAttributeChanged):
+ * dom/Element.h:
+ (WebCore::Element::attributeData):
+ (WebCore::Element::ensureAttributeData):
+ (Element):
+ (WebCore::Element::idForStyleResolution):
+ * dom/ElementAttributeData.cpp: Added.
+ (WebCore):
+ (WebCore::ElementAttributeData::setClass): the only caller of this function
+ already deal with the case when the element has no class, so don't do it here.
+ * dom/ElementAttributeData.h: Added.
+ (WebCore):
+ (ElementAttributeData):
+ (WebCore::ElementAttributeData::clearClass):
+ (WebCore::ElementAttributeData::classNames):
+ (WebCore::ElementAttributeData::idForStyleResolution):
+ (WebCore::ElementAttributeData::setIdForStyleResolution):
+ (WebCore::ElementAttributeData::ElementAttributeData):
+ * dom/NamedNodeMap.cpp:
+ (WebCore::NamedNodeMap::clearAttributes):
+ * dom/NamedNodeMap.h:
+ (WebCore::NamedNodeMap::attributeData):
+ (NamedNodeMap):
+ * dom/StyledElement.cpp:
+ (WebCore::StyledElement::classAttributeChanged):
+ * dom/StyledElement.h:
+ (WebCore::StyledElement::classNames):
+ * html/ClassList.cpp:
+ (WebCore::ClassList::classNames):
+
2012-01-30 Gregg Tavares <[email protected]>
Add Plumming to get graphics error messages to JS Console
Modified: trunk/Source/WebCore/GNUmakefile.list.am (106322 => 106323)
--- trunk/Source/WebCore/GNUmakefile.list.am 2012-01-31 03:28:31 UTC (rev 106322)
+++ trunk/Source/WebCore/GNUmakefile.list.am 2012-01-31 03:53:40 UTC (rev 106323)
@@ -1533,6 +1533,8 @@
Source/WebCore/dom/EditingText.h \
Source/WebCore/dom/Element.cpp \
Source/WebCore/dom/Element.h \
+ Source/WebCore/dom/ElementAttributeData.cpp \
+ Source/WebCore/dom/ElementAttributeData.h \
Source/WebCore/dom/ElementRareData.h \
Source/WebCore/dom/Entity.h \
Source/WebCore/dom/EntityReference.cpp \
Modified: trunk/Source/WebCore/Target.pri (106322 => 106323)
--- trunk/Source/WebCore/Target.pri 2012-01-31 03:28:31 UTC (rev 106322)
+++ trunk/Source/WebCore/Target.pri 2012-01-31 03:53:40 UTC (rev 106323)
@@ -509,6 +509,7 @@
dom/DynamicNodeList.cpp \
dom/EditingText.cpp \
dom/Element.cpp \
+ dom/ElementAttributeData.cpp \
dom/EntityReference.cpp \
dom/ErrorEvent.cpp \
dom/Event.cpp \
@@ -1622,6 +1623,7 @@
dom/DynamicNodeList.h \
dom/EditingText.h \
dom/Element.h \
+ dom/ElementAttributeData.h \
dom/Entity.h \
dom/EntityReference.h \
dom/Event.h \
Modified: trunk/Source/WebCore/WebCore.gypi (106322 => 106323)
--- trunk/Source/WebCore/WebCore.gypi 2012-01-31 03:28:31 UTC (rev 106322)
+++ trunk/Source/WebCore/WebCore.gypi 2012-01-31 03:53:40 UTC (rev 106323)
@@ -595,6 +595,7 @@
'dom/DocumentTiming.h',
'dom/DocumentType.h',
'dom/Element.h',
+ 'dom/ElementAttributeData.h',
'dom/Event.h',
'dom/EventListener.h',
'dom/EventListenerMap.h',
@@ -4994,6 +4995,7 @@
'dom/EditingText.cpp',
'dom/EditingText.h',
'dom/Element.cpp',
+ 'dom/ElementAttributeData.cpp',
'dom/ElementRareData.h',
'dom/Entity.h',
'dom/EntityReference.cpp',
Modified: trunk/Source/WebCore/WebCore.xcodeproj/project.pbxproj (106322 => 106323)
--- trunk/Source/WebCore/WebCore.xcodeproj/project.pbxproj 2012-01-31 03:28:31 UTC (rev 106322)
+++ trunk/Source/WebCore/WebCore.xcodeproj/project.pbxproj 2012-01-31 03:53:40 UTC (rev 106323)
@@ -733,6 +733,8 @@
29D7BCFA1444AF7D0070619C /* AccessibilitySpinButton.h in Headers */ = {isa = PBXBuildFile; fileRef = 29D7BCF91444AF7D0070619C /* AccessibilitySpinButton.h */; };
2BE8E2C712A589EC00FAD550 /* HTMLMetaCharsetParser.h in Headers */ = {isa = PBXBuildFile; fileRef = 2BE8E2C612A589EC00FAD550 /* HTMLMetaCharsetParser.h */; };
2BE8E2C912A58A0100FAD550 /* HTMLMetaCharsetParser.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 2BE8E2C812A58A0100FAD550 /* HTMLMetaCharsetParser.cpp */; };
+ 2CF6878814D32EB500340F39 /* ElementAttributeData.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 2CF6878714D32EB500340F39 /* ElementAttributeData.cpp */; };
+ 2CF6878A14D32EFF00340F39 /* ElementAttributeData.h in Headers */ = {isa = PBXBuildFile; fileRef = 2CF6878914D32EFF00340F39 /* ElementAttributeData.h */; settings = {ATTRIBUTES = (Private, ); }; };
2D3A0E3613A7D76100E85AF0 /* SVGParsingError.h in Headers */ = {isa = PBXBuildFile; fileRef = 2D3A0E3513A7D76100E85AF0 /* SVGParsingError.h */; settings = {ATTRIBUTES = (Private, ); }; };
2D481F00146B5C4C00AA7834 /* CrossfadeGeneratedImage.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 2D2FC0541460CD6F00263633 /* CrossfadeGeneratedImage.cpp */; };
2D481F02146B5C5500AA7834 /* CrossfadeGeneratedImage.h in Headers */ = {isa = PBXBuildFile; fileRef = 2D2FC0551460CD6F00263633 /* CrossfadeGeneratedImage.h */; };
@@ -7479,6 +7481,8 @@
29D7BCF91444AF7D0070619C /* AccessibilitySpinButton.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = AccessibilitySpinButton.h; sourceTree = "<group>"; };
2BE8E2C612A589EC00FAD550 /* HTMLMetaCharsetParser.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = HTMLMetaCharsetParser.h; path = parser/HTMLMetaCharsetParser.h; sourceTree = "<group>"; };
2BE8E2C812A58A0100FAD550 /* HTMLMetaCharsetParser.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; name = HTMLMetaCharsetParser.cpp; path = parser/HTMLMetaCharsetParser.cpp; sourceTree = "<group>"; };
+ 2CF6878714D32EB500340F39 /* ElementAttributeData.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = ElementAttributeData.cpp; sourceTree = "<group>"; };
+ 2CF6878914D32EFF00340F39 /* ElementAttributeData.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = ElementAttributeData.h; sourceTree = "<group>"; };
2D2FC0541460CD6F00263633 /* CrossfadeGeneratedImage.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = CrossfadeGeneratedImage.cpp; sourceTree = "<group>"; };
2D2FC0551460CD6F00263633 /* CrossfadeGeneratedImage.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = CrossfadeGeneratedImage.h; sourceTree = "<group>"; };
2D2FC0561460CD6F00263633 /* GeneratorGeneratedImage.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = GeneratorGeneratedImage.cpp; sourceTree = "<group>"; };
@@ -20452,6 +20456,8 @@
A8C4A7F609D563270003AC8D /* Element.cpp */,
A8C4A7F509D563270003AC8D /* Element.h */,
93EEC1EA09C2877700C515D1 /* Element.idl */,
+ 2CF6878714D32EB500340F39 /* ElementAttributeData.cpp */,
+ 2CF6878914D32EFF00340F39 /* ElementAttributeData.h */,
637B7ADE0E8767B800E32194 /* ElementRareData.h */,
A8EA7EBA0A1945D000A8EF5F /* Entity.h */,
93EEC1EB09C2877700C515D1 /* Entity.idl */,
@@ -24101,6 +24107,7 @@
8AD0A59614C88358000D83C5 /* DOMWebKitCSSRegionRule.h in Headers */,
8AD0A59814C88358000D83C5 /* DOMWebKitCSSRegionRuleInternal.h in Headers */,
0720B0A114D3323500642955 /* GenericEventQueue.h in Headers */,
+ 2CF6878A14D32EFF00340F39 /* ElementAttributeData.h in Headers */,
);
runOnlyForDeploymentPostprocessing = 0;
};
@@ -27030,6 +27037,7 @@
FD537352137B651800008DCE /* ZeroPole.cpp in Sources */,
573D134714CE39FF0057ABCA /* InspectorTypeBuilder.cpp in Sources */,
0720B0A014D3323500642955 /* GenericEventQueue.cpp in Sources */,
+ 2CF6878814D32EB500340F39 /* ElementAttributeData.cpp in Sources */,
);
runOnlyForDeploymentPostprocessing = 0;
};
Modified: trunk/Source/WebCore/dom/DOMAllInOne.cpp (106322 => 106323)
--- trunk/Source/WebCore/dom/DOMAllInOne.cpp 2012-01-31 03:28:31 UTC (rev 106322)
+++ trunk/Source/WebCore/dom/DOMAllInOne.cpp 2012-01-31 03:53:40 UTC (rev 106323)
@@ -67,6 +67,7 @@
#include "DynamicNodeList.cpp"
#include "EditingText.cpp"
#include "Element.cpp"
+#include "ElementAttributeData.cpp"
#include "EntityReference.cpp"
#include "ErrorEvent.cpp"
#include "Event.cpp"
Modified: trunk/Source/WebCore/dom/Element.cpp (106322 => 106323)
--- trunk/Source/WebCore/dom/Element.cpp 2012-01-31 03:28:31 UTC (rev 106322)
+++ trunk/Source/WebCore/dom/Element.cpp 2012-01-31 03:53:40 UTC (rev 106323)
@@ -710,13 +710,13 @@
void Element::idAttributeChanged(Attribute* attr)
{
setHasID(!attr->isNull());
- if (attributeMap()) {
+ if (attributeData()) {
if (attr->isNull())
- attributeMap()->setIdForStyleResolution(nullAtom);
+ attributeData()->setIdForStyleResolution(nullAtom);
else if (document()->inQuirksMode())
- attributeMap()->setIdForStyleResolution(attr->value().lower());
+ attributeData()->setIdForStyleResolution(attr->value().lower());
else
- attributeMap()->setIdForStyleResolution(attr->value());
+ attributeData()->setIdForStyleResolution(attr->value());
}
setNeedsStyleRecalc();
}
Modified: trunk/Source/WebCore/dom/Element.h (106322 => 106323)
--- trunk/Source/WebCore/dom/Element.h 2012-01-31 03:28:31 UTC (rev 106322)
+++ trunk/Source/WebCore/dom/Element.h 2012-01-31 03:53:40 UTC (rev 106323)
@@ -224,6 +224,9 @@
NamedNodeMap* attributeMap() const { return m_attributeMap.get(); }
+ ElementAttributeData* attributeData() const { return m_attributeMap ? m_attributeMap->attributeData() : 0; }
+ ElementAttributeData* ensureAttributeData() const { return attributes()->attributeData(); }
+
void setAttributesFromElement(const Element&);
virtual void copyNonAttributeProperties(const Element* source);
@@ -572,7 +575,7 @@
inline const AtomicString& Element::idForStyleResolution() const
{
ASSERT(hasID());
- return m_attributeMap->idForStyleResolution();
+ return attributeData()->idForStyleResolution();
}
inline bool Element::isIdAttributeName(const QualifiedName& attributeName) const
Added: trunk/Source/WebCore/dom/ElementAttributeData.cpp (0 => 106323)
--- trunk/Source/WebCore/dom/ElementAttributeData.cpp (rev 0)
+++ trunk/Source/WebCore/dom/ElementAttributeData.cpp 2012-01-31 03:53:40 UTC (rev 106323)
@@ -0,0 +1,36 @@
+/*
+ * Copyright (C) 1999 Lars Knoll ([email protected])
+ * (C) 1999 Antti Koivisto ([email protected])
+ * (C) 2001 Peter Kelly ([email protected])
+ * (C) 2001 Dirk Mueller ([email protected])
+ * Copyright (C) 2003, 2004, 2005, 2006, 2008, 2010 Apple Inc. All rights reserved.
+ * Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Library General Public
+ * License as published by the Free Software Foundation; either
+ * version 2 of the License, or (at your option) any later version.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Library General Public License for more details.
+ *
+ * You should have received a copy of the GNU Library General Public License
+ * along with this library; see the file COPYING.LIB. If not, write to
+ * the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
+ * Boston, MA 02110-1301, USA.
+ *
+ */
+
+#include "config.h"
+#include "ElementAttributeData.h"
+
+namespace WebCore {
+
+void ElementAttributeData::setClass(const String& className, bool shouldFoldCase)
+{
+ m_classNames.set(className, shouldFoldCase);
+}
+
+}
Added: trunk/Source/WebCore/dom/ElementAttributeData.h (0 => 106323)
--- trunk/Source/WebCore/dom/ElementAttributeData.h (rev 0)
+++ trunk/Source/WebCore/dom/ElementAttributeData.h 2012-01-31 03:53:40 UTC (rev 106323)
@@ -0,0 +1,57 @@
+/*
+ * Copyright (C) 1999 Lars Knoll ([email protected])
+ * (C) 1999 Antti Koivisto ([email protected])
+ * (C) 2001 Peter Kelly ([email protected])
+ * (C) 2001 Dirk Mueller ([email protected])
+ * Copyright (C) 2003, 2004, 2005, 2006, 2008, 2010 Apple Inc. All rights reserved.
+ * Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Library General Public
+ * License as published by the Free Software Foundation; either
+ * version 2 of the License, or (at your option) any later version.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Library General Public License for more details.
+ *
+ * You should have received a copy of the GNU Library General Public License
+ * along with this library; see the file COPYING.LIB. If not, write to
+ * the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
+ * Boston, MA 02110-1301, USA.
+ *
+ */
+
+#ifndef ElementAttributeData_h
+#define ElementAttributeData_h
+
+#include "SpaceSplitString.h"
+
+namespace WebCore {
+
+class Element;
+
+class ElementAttributeData {
+public:
+ void clearClass() { m_classNames.clear(); }
+ void setClass(const String& className, bool shouldFoldCase);
+ const SpaceSplitString& classNames() const { return m_classNames; }
+
+ const AtomicString& idForStyleResolution() const { return m_idForStyleResolution; }
+ void setIdForStyleResolution(const AtomicString& newId) { m_idForStyleResolution = newId; }
+
+private:
+ friend class NamedNodeMap;
+
+ ElementAttributeData()
+ {
+ }
+
+ SpaceSplitString m_classNames;
+ AtomicString m_idForStyleResolution;
+};
+
+}
+
+#endif // ElementAttributeData_h
Modified: trunk/Source/WebCore/dom/NamedNodeMap.cpp (106322 => 106323)
--- trunk/Source/WebCore/dom/NamedNodeMap.cpp 2012-01-31 03:28:31 UTC (rev 106322)
+++ trunk/Source/WebCore/dom/NamedNodeMap.cpp 2012-01-31 03:53:40 UTC (rev 106323)
@@ -200,7 +200,7 @@
void NamedNodeMap::clearAttributes()
{
- m_classNames.clear();
+ attributeData()->clearClass();
detachAttributesFromElement();
m_attributes.clear();
}
@@ -301,16 +301,6 @@
m_element->didModifyAttribute(attribute.get());
}
-void NamedNodeMap::setClass(const String& classStr)
-{
- if (!element()->hasClass()) {
- m_classNames.clear();
- return;
- }
-
- m_classNames.set(classStr, element()->document()->inQuirksMode());
-}
-
bool NamedNodeMap::mapsEquivalent(const NamedNodeMap* otherMap) const
{
if (!otherMap)
Modified: trunk/Source/WebCore/dom/NamedNodeMap.h (106322 => 106323)
--- trunk/Source/WebCore/dom/NamedNodeMap.h 2012-01-31 03:28:31 UTC (rev 106322)
+++ trunk/Source/WebCore/dom/NamedNodeMap.h 2012-01-31 03:53:40 UTC (rev 106323)
@@ -26,6 +26,7 @@
#define NamedNodeMap_h
#include "Attribute.h"
+#include "ElementAttributeData.h"
#include "SpaceSplitString.h"
#include <wtf/NotFound.h>
@@ -84,9 +85,6 @@
addAttribute(newAttribute);
}
- const AtomicString& idForStyleResolution() const { return m_idForStyleResolution; }
- void setIdForStyleResolution(const AtomicString& newId) { m_idForStyleResolution = newId; }
-
bool mapsEquivalent(const NamedNodeMap* otherMap) const;
// These functions do no error checking.
@@ -96,12 +94,11 @@
Element* element() const { return m_element; }
- void clearClass() { m_classNames.clear(); }
- void setClass(const String&);
- const SpaceSplitString& classNames() const { return m_classNames; }
-
size_t mappedAttributeCount() const;
+ ElementAttributeData* attributeData() { return &m_attributeData; }
+ const ElementAttributeData* attributeData() const { return &m_attributeData; }
+
private:
NamedNodeMap(Element* element)
: m_element(element)
@@ -117,10 +114,13 @@
void clearAttributes();
void replaceAttribute(size_t index, PassRefPtr<Attribute>);
- SpaceSplitString m_classNames;
+ // FIXME: NamedNodeMap is being broken up into two classes, one containing data
+ // for elements with attributes, and one for exposure to the DOM.
+ // See <http://webkit.org/b/75069> for more information.
+ ElementAttributeData m_attributeData;
+
Element* m_element;
Vector<RefPtr<Attribute>, 4> m_attributes;
- AtomicString m_idForStyleResolution;
};
inline Attribute* NamedNodeMap::getAttributeItem(const QualifiedName& name) const
Modified: trunk/Source/WebCore/dom/StyledElement.cpp (106322 => 106323)
--- trunk/Source/WebCore/dom/StyledElement.cpp 2012-01-31 03:28:31 UTC (rev 106322)
+++ trunk/Source/WebCore/dom/StyledElement.cpp 2012-01-31 03:53:40 UTC (rev 106323)
@@ -215,11 +215,12 @@
bool hasClass = i < length;
setHasClass(hasClass);
if (hasClass) {
- attributes()->setClass(newClassString);
+ const bool shouldFoldCase = document()->inQuirksMode();
+ ensureAttributeData()->setClass(newClassString, shouldFoldCase);
if (DOMTokenList* classList = optionalClassList())
static_cast<ClassList*>(classList)->reset(newClassString);
- } else if (attributeMap())
- attributeMap()->clearClass();
+ } else if (attributeData())
+ attributeData()->clearClass();
setNeedsStyleRecalc();
dispatchSubtreeModifiedEvent();
}
Modified: trunk/Source/WebCore/dom/StyledElement.h (106322 => 106323)
--- trunk/Source/WebCore/dom/StyledElement.h 2012-01-31 03:28:31 UTC (rev 106322)
+++ trunk/Source/WebCore/dom/StyledElement.h 2012-01-31 03:53:40 UTC (rev 106323)
@@ -98,8 +98,8 @@
inline const SpaceSplitString& StyledElement::classNames() const
{
ASSERT(hasClass());
- ASSERT(attributeMap());
- return attributeMap()->classNames();
+ ASSERT(attributeData());
+ return attributeData()->classNames();
}
inline void StyledElement::invalidateStyleAttribute()
Modified: trunk/Source/WebCore/html/ClassList.cpp (106322 => 106323)
--- trunk/Source/WebCore/html/ClassList.cpp 2012-01-31 03:28:31 UTC (rev 106322)
+++ trunk/Source/WebCore/html/ClassList.cpp 2012-01-31 03:53:40 UTC (rev 106323)
@@ -140,7 +140,7 @@
ASSERT(m_element->hasClass());
if (!m_classNamesForQuirksMode.isNull())
return m_classNamesForQuirksMode;
- return m_element->attributeMap()->classNames();
+ return m_element->attributeData()->classNames();
}
} // namespace WebCore