In many cases where we use NodeTraversal we really only want Elements. By having Element specific iteration functions we can tighten the code and make it faster too.
Created attachment 178882 [details] patch
Comment on attachment 178882 [details] patch View in context: https://bugs.webkit.org/attachment.cgi?id=178882&action=review > Source/WebCore/ChangeLog:1529 > + Another build fix. > + > + * html/HTMLPropertiesCollection.cpp: > + (WebCore::nextNodeWithProperty): Please revert these changes. > Source/WebCore/dom/ContainerNodeAlgorithms.h:319 > + Element* element = (shouldIncludeRoot == IncludeRoot && root->isElementNode()) ? static_cast<Element*>(root) : ElementTraversal::firstWithin(root); I don't have toElement? > Source/WebCore/dom/NodeTraversal.h:102 > +template <class NodeType> > +inline Element* traverseNextElementTemplate(NodeType* current, const Node* stayWithin) > +{ > + Node* node = NodeTraversal::next(current, stayWithin); > + while (node && !node->isElementNode()) > + node = NodeTraversal::nextSkippingChildren(node, stayWithin); > + return static_cast<Element*>(node); > +} I'm sad that we have to duplicate the template like this. Can we had a boolean template argument and share the code between two? > Source/WebCore/dom/NodeTraversal.h:126 > +template <class NodeType> > +inline Element* traverseNextElementSkippingChildrenTemplate(NodeType* current, const Node* stayWithin) > +{ > + Node* node = NodeTraversal::nextSkippingChildren(current, stayWithin); > + while (node && !node->isElementNode()) > + node = NodeTraversal::nextSkippingChildren(node, stayWithin); > + return static_cast<Element*>(node); > +} Ditto.
Comment on attachment 178882 [details] patch Attachment 178882 [details] did not pass chromium-ews (chromium-xvfb): Output: http://queues.webkit.org/results/15277319
Created attachment 178892 [details] patch2
(In reply to comment #2) > I'm sad that we have to duplicate the template like this. Can we had a boolean template argument and share the code between two? I didn't do this as the templates get pretty messy and hard to understand if we also want optimal code.
http://trac.webkit.org/changeset/137406