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

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

Issue 406843002: Optimize hasTagName when called on an HTMLElement / SVGElement (Closed) Base URL: svn://svn.chromium.org/blink/trunk
Patch Set: Created 6 years, 5 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.h ('k') | Source/core/dom/Node.h » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: Source/core/dom/ElementTraversal.h
diff --git a/Source/core/dom/ElementTraversal.h b/Source/core/dom/ElementTraversal.h
index bebe74036ba4d09fc5f533722b64727e0ced11f5..e0165aec982dea919c66ad86739af7b5791100ef 100644
--- a/Source/core/dom/ElementTraversal.h
+++ b/Source/core/dom/ElementTraversal.h
@@ -210,60 +210,60 @@ template <class ElementType>
template <class NodeType>
inline ElementType* Traversal<ElementType>::firstWithinTemplate(NodeType& current)
{
- Element* element = Traversal<Element>::firstWithin(current);
- while (element && !isElementOfType<const ElementType>(*element))
- element = Traversal<Element>::next(*element, &current);
- return toElement<ElementType>(element);
+ Node* node = current.firstChild();
+ while (node && !isElementOfType<const ElementType>(*node))
+ node = NodeTraversal::next(*node, &current);
+ return toElement<ElementType>(node);
}
template <class ElementType>
template <class NodeType>
inline ElementType* Traversal<ElementType>::lastWithinTemplate(NodeType& current)
{
- Element* element = Traversal<Element>::lastWithin(current);
- while (element && !isElementOfType<const ElementType>(*element))
- element = Traversal<Element>::previous(element, &current);
- return toElement<ElementType>(element);
+ Node* node = current.lastChild();
+ while (node && !isElementOfType<const ElementType>(*node))
+ node = NodeTraversal::previous(node, &current);
+ return toElement<ElementType>(node);
}
template <class ElementType>
template <class NodeType>
inline ElementType* Traversal<ElementType>::nextTemplate(NodeType& current)
{
- Element* element = Traversal<Element>::next(current);
- while (element && !isElementOfType<const ElementType>(*element))
- element = Traversal<Element>::next(*element);
- return toElement<ElementType>(element);
+ Node* node = NodeTraversal::next(current);
+ while (node && !isElementOfType<const ElementType>(*node))
+ node = NodeTraversal::next(*node);
+ return toElement<ElementType>(node);
}
template <class ElementType>
template <class NodeType>
inline ElementType* Traversal<ElementType>::nextTemplate(NodeType& current, const Node* stayWithin)
{
- Element* element = Traversal<Element>::next(current, stayWithin);
- while (element && !isElementOfType<const ElementType>(*element))
- element = Traversal<Element>::next(*element, stayWithin);
- return toElement<ElementType>(element);
+ Node* node = NodeTraversal::next(current, stayWithin);
+ while (node && !isElementOfType<const ElementType>(*node))
+ node = NodeTraversal::next(*node, stayWithin);
+ return toElement<ElementType>(node);
}
template <class ElementType>
template <class NodeType>
inline ElementType* Traversal<ElementType>::previousTemplate(NodeType& current)
{
- Element* element = Traversal<Element>::previous(current);
- while (element && !isElementOfType<const ElementType>(*element))
- element = Traversal<Element>::previous(*element);
- return toElement<ElementType>(element);
+ Node* node = NodeTraversal::previous(current);
+ while (node && !isElementOfType<const ElementType>(*node))
+ node = NodeTraversal::previous(*node);
+ return toElement<ElementType>(node);
}
template <class ElementType>
template <class NodeType>
inline ElementType* Traversal<ElementType>::previousTemplate(NodeType& current, const Node* stayWithin)
{
- Element* element = Traversal<Element>::previous(current, stayWithin);
- while (element && !isElementOfType<const ElementType>(*element))
- element = Traversal<Element>::previous(*element, stayWithin);
- return toElement<ElementType>(element);
+ Node* node = NodeTraversal::previous(current, stayWithin);
+ while (node && !isElementOfType<const ElementType>(*node))
+ node = NodeTraversal::previous(*node, stayWithin);
+ return toElement<ElementType>(node);
}
template <class ElementType>
« no previous file with comments | « Source/core/dom/Element.h ('k') | Source/core/dom/Node.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698