summaryrefslogtreecommitdiffstats
path: root/Source/WebCore/dom
diff options
context:
space:
mode:
Diffstat (limited to 'Source/WebCore/dom')
-rw-r--r--Source/WebCore/dom/Document.cpp9
-rw-r--r--Source/WebCore/dom/Document.h7
-rw-r--r--Source/WebCore/dom/Element.cpp22
-rw-r--r--Source/WebCore/dom/Element.h16
-rw-r--r--Source/WebCore/dom/NamedNodeMap.cpp10
-rw-r--r--Source/WebCore/dom/NamedNodeMap.h14
-rw-r--r--Source/WebCore/dom/Node.cpp16
7 files changed, 58 insertions, 36 deletions
diff --git a/Source/WebCore/dom/Document.cpp b/Source/WebCore/dom/Document.cpp
index 60ecdb9..f319cac 100644
--- a/Source/WebCore/dom/Document.cpp
+++ b/Source/WebCore/dom/Document.cpp
@@ -110,6 +110,7 @@
#include "NestingLevelIncrementer.h"
#include "NodeFilter.h"
#include "NodeIterator.h"
+#include "NodeRareData.h"
#include "NodeWithIndex.h"
#include "OverflowEvent.h"
#include "Page.h"
@@ -424,6 +425,7 @@ Document::Document(Frame* frame, const KURL& url, bool isXHTML, bool isHTML)
, m_sawElementsInKnownNamespaces(false)
, m_usingGeolocation(false)
, m_eventQueue(EventQueue::create(this))
+ , m_documentRareData(0)
#if ENABLE(WML)
, m_containsWMLContent(false)
#endif
@@ -573,6 +575,13 @@ Document::~Document()
if (m_implementation)
m_implementation->ownerDocumentDestroyed();
+
+ if (hasRareData()) {
+ ASSERT(m_documentRareData);
+ delete m_documentRareData;
+ m_documentRareData = 0;
+ clearFlag(HasRareDataFlag);
+ }
}
void Document::removedLastRef()
diff --git a/Source/WebCore/dom/Document.h b/Source/WebCore/dom/Document.h
index 44f3f93..f94ce7a 100644
--- a/Source/WebCore/dom/Document.h
+++ b/Source/WebCore/dom/Document.h
@@ -104,6 +104,7 @@ class MediaQueryMatcher;
class MouseEventWithHitTestResults;
class NodeFilter;
class NodeIterator;
+class NodeRareData;
class Page;
class PlatformMouseEvent;
class ProcessingInstruction;
@@ -1109,12 +1110,14 @@ public:
ContentSecurityPolicy* contentSecurityPolicy() { return m_contentSecurityPolicy.get(); }
+ NodeRareData* documentRareData() const { return m_documentRareData; };
+ void setDocumentRareData(NodeRareData* rareData) { m_documentRareData = rareData; }
+
protected:
Document(Frame*, const KURL&, bool isXHTML, bool isHTML);
void clearXMLVersion() { m_xmlVersion = String(); }
-
private:
friend class IgnoreDestructiveWriteCountIncrementer;
@@ -1376,6 +1379,8 @@ private:
RefPtr<EventQueue> m_eventQueue;
+ NodeRareData* m_documentRareData;
+
#if ENABLE(WML)
bool m_containsWMLContent;
#endif
diff --git a/Source/WebCore/dom/Element.cpp b/Source/WebCore/dom/Element.cpp
index 5fb6cdc..4b9de49 100644
--- a/Source/WebCore/dom/Element.cpp
+++ b/Source/WebCore/dom/Element.cpp
@@ -622,7 +622,7 @@ static inline bool shouldIgnoreAttributeCase(const Element* e)
return e && e->document()->isHTMLDocument() && e->isHTMLElement();
}
-const AtomicString& Element::getAttribute(const String& name) const
+const AtomicString& Element::getAttribute(const AtomicString& name) const
{
bool ignoreCase = shouldIgnoreAttributeCase(this);
@@ -645,7 +645,7 @@ const AtomicString& Element::getAttribute(const String& name) const
return nullAtom;
}
-const AtomicString& Element::getAttributeNS(const String& namespaceURI, const String& localName) const
+const AtomicString& Element::getAttributeNS(const AtomicString& namespaceURI, const AtomicString& localName) const
{
return getAttribute(QualifiedName(nullAtom, localName, namespaceURI));
}
@@ -1471,11 +1471,11 @@ void Element::setAttributeNS(const AtomicString& namespaceURI, const AtomicStrin
setAttribute(qName, value, ec);
}
-void Element::removeAttribute(const String& name, ExceptionCode& ec)
+void Element::removeAttribute(const AtomicString& name, ExceptionCode& ec)
{
InspectorInstrumentation::willModifyDOMAttr(document(), this);
- String localName = shouldIgnoreAttributeCase(this) ? name.lower() : name;
+ AtomicString localName = shouldIgnoreAttributeCase(this) ? name.lower() : name;
if (m_attributeMap) {
m_attributeMap->removeNamedItem(localName, ec);
@@ -1486,21 +1486,21 @@ void Element::removeAttribute(const String& name, ExceptionCode& ec)
InspectorInstrumentation::didModifyDOMAttr(document(), this);
}
-void Element::removeAttributeNS(const String& namespaceURI, const String& localName, ExceptionCode& ec)
+void Element::removeAttributeNS(const AtomicString& namespaceURI, const AtomicString& localName, ExceptionCode& ec)
{
removeAttribute(QualifiedName(nullAtom, localName, namespaceURI), ec);
}
-PassRefPtr<Attr> Element::getAttributeNode(const String& name)
+PassRefPtr<Attr> Element::getAttributeNode(const AtomicString& name)
{
NamedNodeMap* attrs = attributes(true);
if (!attrs)
return 0;
- String localName = shouldIgnoreAttributeCase(this) ? name.lower() : name;
+ AtomicString localName = shouldIgnoreAttributeCase(this) ? name.lower() : name;
return static_pointer_cast<Attr>(attrs->getNamedItem(localName));
}
-PassRefPtr<Attr> Element::getAttributeNodeNS(const String& namespaceURI, const String& localName)
+PassRefPtr<Attr> Element::getAttributeNodeNS(const AtomicString& namespaceURI, const AtomicString& localName)
{
NamedNodeMap* attrs = attributes(true);
if (!attrs)
@@ -1508,7 +1508,7 @@ PassRefPtr<Attr> Element::getAttributeNodeNS(const String& namespaceURI, const S
return static_pointer_cast<Attr>(attrs->getNamedItem(QualifiedName(nullAtom, localName, namespaceURI)));
}
-bool Element::hasAttribute(const String& name) const
+bool Element::hasAttribute(const AtomicString& name) const
{
NamedNodeMap* attrs = attributes(true);
if (!attrs)
@@ -1516,11 +1516,11 @@ bool Element::hasAttribute(const String& name) const
// This call to String::lower() seems to be required but
// there may be a way to remove it.
- String localName = shouldIgnoreAttributeCase(this) ? name.lower() : name;
+ AtomicString localName = shouldIgnoreAttributeCase(this) ? name.lower() : name;
return attrs->getAttributeItem(localName, false);
}
-bool Element::hasAttributeNS(const String& namespaceURI, const String& localName) const
+bool Element::hasAttributeNS(const AtomicString& namespaceURI, const AtomicString& localName) const
{
NamedNodeMap* attrs = attributes(true);
if (!attrs)
diff --git a/Source/WebCore/dom/Element.h b/Source/WebCore/dom/Element.h
index 97265e9..79815dd 100644
--- a/Source/WebCore/dom/Element.h
+++ b/Source/WebCore/dom/Element.h
@@ -128,11 +128,11 @@ public:
bool hasAttributes() const;
- bool hasAttribute(const String& name) const;
- bool hasAttributeNS(const String& namespaceURI, const String& localName) const;
+ bool hasAttribute(const AtomicString& name) const;
+ bool hasAttributeNS(const AtomicString& namespaceURI, const AtomicString& localName) const;
- const AtomicString& getAttribute(const String& name) const;
- const AtomicString& getAttributeNS(const String& namespaceURI, const String& localName) const;
+ const AtomicString& getAttribute(const AtomicString& name) const;
+ const AtomicString& getAttributeNS(const AtomicString& namespaceURI, const AtomicString& localName) const;
void setAttribute(const AtomicString& name, const AtomicString& value, ExceptionCode&);
void setAttributeNS(const AtomicString& namespaceURI, const AtomicString& qualifiedName, const AtomicString& value, ExceptionCode&, FragmentScriptingPermission = FragmentScriptingAllowed);
@@ -176,11 +176,11 @@ public:
// Returns the absolute bounding box translated into screen coordinates:
IntRect screenRect() const;
- void removeAttribute(const String& name, ExceptionCode&);
- void removeAttributeNS(const String& namespaceURI, const String& localName, ExceptionCode&);
+ void removeAttribute(const AtomicString& name, ExceptionCode&);
+ void removeAttributeNS(const AtomicString& namespaceURI, const AtomicString& localName, ExceptionCode&);
- PassRefPtr<Attr> getAttributeNode(const String& name);
- PassRefPtr<Attr> getAttributeNodeNS(const String& namespaceURI, const String& localName);
+ PassRefPtr<Attr> getAttributeNode(const AtomicString& name);
+ PassRefPtr<Attr> getAttributeNodeNS(const AtomicString& namespaceURI, const AtomicString& localName);
PassRefPtr<Attr> setAttributeNode(Attr*, ExceptionCode&);
PassRefPtr<Attr> setAttributeNodeNS(Attr*, ExceptionCode&);
PassRefPtr<Attr> removeAttributeNode(Attr*, ExceptionCode&);
diff --git a/Source/WebCore/dom/NamedNodeMap.cpp b/Source/WebCore/dom/NamedNodeMap.cpp
index 6fa30bf..253bc53 100644
--- a/Source/WebCore/dom/NamedNodeMap.cpp
+++ b/Source/WebCore/dom/NamedNodeMap.cpp
@@ -54,7 +54,7 @@ NamedNodeMap::~NamedNodeMap()
detachAttributesFromElement();
}
-PassRefPtr<Node> NamedNodeMap::getNamedItem(const String& name) const
+PassRefPtr<Node> NamedNodeMap::getNamedItem(const AtomicString& name) const
{
Attribute* a = getAttributeItem(name, shouldIgnoreAttributeCase(m_element));
if (!a)
@@ -63,12 +63,12 @@ PassRefPtr<Node> NamedNodeMap::getNamedItem(const String& name) const
return a->createAttrIfNeeded(m_element);
}
-PassRefPtr<Node> NamedNodeMap::getNamedItemNS(const String& namespaceURI, const String& localName) const
+PassRefPtr<Node> NamedNodeMap::getNamedItemNS(const AtomicString& namespaceURI, const AtomicString& localName) const
{
return getNamedItem(QualifiedName(nullAtom, localName, namespaceURI));
}
-PassRefPtr<Node> NamedNodeMap::removeNamedItem(const String& name, ExceptionCode& ec)
+PassRefPtr<Node> NamedNodeMap::removeNamedItem(const AtomicString& name, ExceptionCode& ec)
{
Attribute* a = getAttributeItem(name, shouldIgnoreAttributeCase(m_element));
if (!a) {
@@ -79,7 +79,7 @@ PassRefPtr<Node> NamedNodeMap::removeNamedItem(const String& name, ExceptionCode
return removeNamedItem(a->name(), ec);
}
-PassRefPtr<Node> NamedNodeMap::removeNamedItemNS(const String& namespaceURI, const String& localName, ExceptionCode& ec)
+PassRefPtr<Node> NamedNodeMap::removeNamedItemNS(const AtomicString& namespaceURI, const AtomicString& localName, ExceptionCode& ec)
{
return removeNamedItem(QualifiedName(nullAtom, localName, namespaceURI), ec);
}
@@ -171,7 +171,7 @@ void NamedNodeMap::copyAttributesToVector(Vector<RefPtr<Attribute> >& copy)
copy = m_attributes;
}
-Attribute* NamedNodeMap::getAttributeItemSlowCase(const String& name, bool shouldIgnoreAttributeCase) const
+Attribute* NamedNodeMap::getAttributeItemSlowCase(const AtomicString& name, bool shouldIgnoreAttributeCase) const
{
unsigned len = length();
diff --git a/Source/WebCore/dom/NamedNodeMap.h b/Source/WebCore/dom/NamedNodeMap.h
index c3c2cd9..f4aedb0 100644
--- a/Source/WebCore/dom/NamedNodeMap.h
+++ b/Source/WebCore/dom/NamedNodeMap.h
@@ -46,11 +46,11 @@ public:
// Public DOM interface.
- PassRefPtr<Node> getNamedItem(const String& name) const;
- PassRefPtr<Node> removeNamedItem(const String& name, ExceptionCode&);
+ PassRefPtr<Node> getNamedItem(const AtomicString& name) const;
+ PassRefPtr<Node> removeNamedItem(const AtomicString& name, ExceptionCode&);
- PassRefPtr<Node> getNamedItemNS(const String& namespaceURI, const String& localName) const;
- PassRefPtr<Node> removeNamedItemNS(const String& namespaceURI, const String& localName, ExceptionCode&);
+ PassRefPtr<Node> getNamedItemNS(const AtomicString& namespaceURI, const AtomicString& localName) const;
+ PassRefPtr<Node> removeNamedItemNS(const AtomicString& namespaceURI, const AtomicString& localName, ExceptionCode&);
PassRefPtr<Node> getNamedItem(const QualifiedName& name) const;
PassRefPtr<Node> removeNamedItem(const QualifiedName& name, ExceptionCode&);
@@ -111,8 +111,8 @@ private:
void detachAttributesFromElement();
void detachFromElement();
- Attribute* getAttributeItem(const String& name, bool shouldIgnoreAttributeCase) const;
- Attribute* getAttributeItemSlowCase(const String& name, bool shouldIgnoreAttributeCase) const;
+ Attribute* getAttributeItem(const AtomicString& name, bool shouldIgnoreAttributeCase) const;
+ Attribute* getAttributeItemSlowCase(const AtomicString& name, bool shouldIgnoreAttributeCase) const;
void clearAttributes();
int declCount() const;
@@ -135,7 +135,7 @@ inline Attribute* NamedNodeMap::getAttributeItem(const QualifiedName& name) cons
// We use a boolean parameter instead of calling shouldIgnoreAttributeCase so that the caller
// can tune the behavior (hasAttribute is case sensitive whereas getAttribute is not).
-inline Attribute* NamedNodeMap::getAttributeItem(const String& name, bool shouldIgnoreAttributeCase) const
+inline Attribute* NamedNodeMap::getAttributeItem(const AtomicString& name, bool shouldIgnoreAttributeCase) const
{
unsigned len = length();
bool doSlowCheck = shouldIgnoreAttributeCase;
diff --git a/Source/WebCore/dom/Node.cpp b/Source/WebCore/dom/Node.cpp
index 1e56278..5b173bf 100644
--- a/Source/WebCore/dom/Node.cpp
+++ b/Source/WebCore/dom/Node.cpp
@@ -394,7 +394,7 @@ Node::~Node()
else {
if (m_document && rareData()->nodeLists())
m_document->removeNodeListCache();
-
+
NodeRareData::NodeRareDataMap& dataMap = NodeRareData::rareDataMap();
NodeRareData::NodeRareDataMap::iterator it = dataMap.find(this);
ASSERT(it != dataMap.end());
@@ -534,7 +534,9 @@ void Node::setTreeScopeRecursively(TreeScope* newTreeScope)
NodeRareData* Node::rareData() const
{
ASSERT(hasRareData());
- return NodeRareData::rareDataFromMap(this);
+ NodeRareData* data = isDocumentNode() ? static_cast<const Document*>(this)->documentRareData() : NodeRareData::rareDataFromMap(this);
+ ASSERT(data);
+ return data;
}
NodeRareData* Node::ensureRareData()
@@ -542,9 +544,15 @@ NodeRareData* Node::ensureRareData()
if (hasRareData())
return rareData();
- ASSERT(!NodeRareData::rareDataMap().contains(this));
NodeRareData* data = createRareData();
- NodeRareData::rareDataMap().set(this, data);
+ if (isDocumentNode()) {
+ // Fast path for a Document. A Document knows a pointer to NodeRareData.
+ ASSERT(!static_cast<Document*>(this)->documentRareData());
+ static_cast<Document*>(this)->setDocumentRareData(data);
+ } else {
+ ASSERT(!NodeRareData::rareDataMap().contains(this));
+ NodeRareData::rareDataMap().set(this, data);
+ }
setFlag(HasRareDataFlag);
return data;
}