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

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

Issue 192293002: Use new is*Element() helper functions in DOM code (Closed) Base URL: svn://svn.chromium.org/blink/trunk
Patch Set: Add is*Element(PassRefPtr) helper Created 6 years, 9 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
Index: Source/core/dom/DocumentOrderedMap.cpp
diff --git a/Source/core/dom/DocumentOrderedMap.cpp b/Source/core/dom/DocumentOrderedMap.cpp
index cd28b033e6f51ec1176c88f3bcdb2d1be313ec71..5989a2b9bbf3d9252a5ad852398f158e67f48acc 100644
--- a/Source/core/dom/DocumentOrderedMap.cpp
+++ b/Source/core/dom/DocumentOrderedMap.cpp
@@ -41,24 +41,24 @@ namespace WebCore {
using namespace HTMLNames;
-inline bool keyMatchesId(StringImpl* key, Element* element)
+inline bool keyMatchesId(StringImpl* key, Element& element)
{
- return element->getIdAttribute().impl() == key;
+ return element.getIdAttribute().impl() == key;
}
-inline bool keyMatchesMapName(StringImpl* key, Element* element)
+inline bool keyMatchesMapName(StringImpl* key, Element& element)
{
- return element->hasTagName(mapTag) && toHTMLMapElement(element)->getName().impl() == key;
+ return isHTMLMapElement(element) && toHTMLMapElement(element).getName().impl() == key;
}
-inline bool keyMatchesLowercasedMapName(StringImpl* key, Element* element)
+inline bool keyMatchesLowercasedMapName(StringImpl* key, Element& element)
{
- return element->hasTagName(mapTag) && toHTMLMapElement(element)->getName().lower().impl() == key;
+ return isHTMLMapElement(element) && toHTMLMapElement(element).getName().lower().impl() == key;
}
-inline bool keyMatchesLabelForAttribute(StringImpl* key, Element* element)
+inline bool keyMatchesLabelForAttribute(StringImpl* key, Element& element)
{
- return element->hasTagName(labelTag) && element->getAttribute(forAttr).impl() == key;
+ return isHTMLLabelElement(element) && element.getAttribute(forAttr).impl() == key;
}
void DocumentOrderedMap::add(StringImpl* key, Element* element)
@@ -101,7 +101,7 @@ void DocumentOrderedMap::remove(StringImpl* key, Element* element)
}
}
-template<bool keyMatches(StringImpl*, Element*)>
+template<bool keyMatches(StringImpl*, Element&)>
inline Element* DocumentOrderedMap::get(StringImpl* key, const TreeScope* scope) const
{
ASSERT(key);
@@ -117,7 +117,7 @@ inline Element* DocumentOrderedMap::get(StringImpl* key, const TreeScope* scope)
// We know there's at least one node that matches; iterate to find the first one.
for (Element* element = ElementTraversal::firstWithin(scope->rootNode()); element; element = ElementTraversal::next(*element)) {
- if (!keyMatches(key, element))
+ if (!keyMatches(key, *element))
continue;
entry->element = element;
return element;
@@ -148,7 +148,7 @@ const Vector<Element*>& DocumentOrderedMap::getAllElementsById(StringImpl* key,
entry->orderedList.reserveCapacity(entry->count);
for (Element* element = entry->element ? entry->element : ElementTraversal::firstWithin(scope->rootNode()); entry->orderedList.size() < entry->count; element = ElementTraversal::next(*element)) {
ASSERT(element);
- if (!keyMatchesId(key, element))
+ if (!keyMatchesId(key, *element))
continue;
entry->orderedList.uncheckedAppend(element);
}

Powered by Google App Engine
This is Rietveld 408576698