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

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

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/Element.cpp ('k') | Source/core/dom/TreeScope.cpp » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: Source/core/dom/TreeScope.h
diff --git a/Source/core/dom/TreeScope.h b/Source/core/dom/TreeScope.h
index fa7428aa8b56bf0e34d97536b3206a90cb56cb89..9e60a47973fffbd82cc8091f2244f775a32a4ce4 100644
--- a/Source/core/dom/TreeScope.h
+++ b/Source/core/dom/TreeScope.h
@@ -56,10 +56,17 @@ public:
Element* adjustedFocusedElement();
Element* getElementById(const AtomicString&) const;
- bool hasElementWithId(StringImpl* id) const;
- bool containsMultipleElementsWithId(const AtomicString& id) const;
- void addElementById(const AtomicString& elementId, Element*);
- void removeElementById(const AtomicString& elementId, Element*);
+ const Vector<Element*>* getAllElementsById(const AtomicString&) const;
+ bool hasElementWithId(StringImpl*) const; // FIXME: The argument should have type "const AtomicString&"" rather than "StringImpl*".
+ bool containsMultipleElementsWithId(const AtomicString&) const;
+ void addElementById(const AtomicString&, Element*);
+ void removeElementById(const AtomicString&, Element*);
+
+ Element* getElementByName(const AtomicString&) const;
+ bool hasElementWithName(const AtomicString&) const;
+ bool containsMultipleElementsWithName(const AtomicString&) const;
+ void addElementByName(const AtomicString&, Element*);
+ void removeElementByName(const AtomicString&, Element*);
Document* documentScope() const { return m_documentScope; }
@@ -168,6 +175,7 @@ private:
int m_guardRefCount;
OwnPtr<DocumentOrderedMap> m_elementsById;
+ OwnPtr<DocumentOrderedMap> m_elementsByName;
OwnPtr<DocumentOrderedMap> m_imageMapsByName;
OwnPtr<DocumentOrderedMap> m_labelsByForAttribute;
@@ -187,6 +195,18 @@ inline bool TreeScope::containsMultipleElementsWithId(const AtomicString& id) co
return m_elementsById && m_elementsById->containsMultiple(id.impl());
}
+inline bool TreeScope::hasElementWithName(const AtomicString& id) const
+{
+ ASSERT(id.impl());
+ return m_elementsByName && m_elementsByName->contains(id.impl());
+}
+
+inline bool TreeScope::containsMultipleElementsWithName(const AtomicString& name) const
+{
+ ASSERT(name.impl());
+ return m_elementsByName && m_elementsByName->containsMultiple(name.impl());
+}
+
Node* nodeFromPoint(Document*, int x, int y, LayoutPoint* localPoint = 0);
TreeScope* commonTreeScope(Node*, Node*);
« no previous file with comments | « Source/core/dom/Element.cpp ('k') | Source/core/dom/TreeScope.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698