Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(772)

Unified Diff: Source/core/dom/TreeScope.cpp

Issue 22508006: Refactor adding and removing named and IDed elements (Closed) Base URL: svn://svn.chromium.org/blink/trunk
Patch Set: Address review comments Created 7 years, 4 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « Source/core/dom/TreeScope.h ('k') | Source/core/editing/ReplaceNodeWithSpanCommand.cpp » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: Source/core/dom/TreeScope.cpp
diff --git a/Source/core/dom/TreeScope.cpp b/Source/core/dom/TreeScope.cpp
index 1824cc17fb59cbea850fcf265468a6f06d8d6170..67e78820c42a5013c30657b9a75cf37f45529f0d 100644
--- a/Source/core/dom/TreeScope.cpp
+++ b/Source/core/dom/TreeScope.cpp
@@ -55,7 +55,7 @@ namespace WebCore {
struct SameSizeAsTreeScope {
virtual ~SameSizeAsTreeScope();
- void* pointers[8];
+ void* pointers[9];
int ints[1];
};
@@ -151,6 +151,15 @@ Element* TreeScope::getElementById(const AtomicString& elementId) const
return m_elementsById->getElementById(elementId.impl(), this);
}
+const Vector<Element*>* TreeScope::getAllElementsById(const AtomicString& elementId) const
+{
+ if (elementId.isEmpty())
+ return 0;
+ if (!m_elementsById)
+ return 0;
+ return m_elementsById->getAllElementsById(elementId.impl(), this);
+}
+
void TreeScope::addElementById(const AtomicString& elementId, Element* element)
{
if (!m_elementsById)
@@ -167,6 +176,29 @@ void TreeScope::removeElementById(const AtomicString& elementId, Element* elemen
m_idTargetObserverRegistry->notifyObservers(elementId);
}
+Element* TreeScope::getElementByName(const AtomicString& name) const
+{
+ if (name.isEmpty())
+ return 0;
+ if (!m_elementsByName)
+ return 0;
+ return m_elementsByName->getElementByName(name.impl(), this);
+}
+
+void TreeScope::addElementByName(const AtomicString& name, Element* element)
+{
+ if (!m_elementsByName)
+ m_elementsByName = adoptPtr(new DocumentOrderedMap);
+ m_elementsByName->add(name.impl(), element);
+}
+
+void TreeScope::removeElementByName(const AtomicString& name, Element* element)
+{
+ if (!m_elementsByName)
+ return;
+ m_elementsByName->remove(name.impl(), element);
+}
+
Node* TreeScope::ancestorInThisScope(Node* node) const
{
while (node) {
« no previous file with comments | « Source/core/dom/TreeScope.h ('k') | Source/core/editing/ReplaceNodeWithSpanCommand.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698