Add Element-specific traversal functions
authorantti@apple.com <antti@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Wed, 12 Dec 2012 03:12:23 +0000 (03:12 +0000)
committerantti@apple.com <antti@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Wed, 12 Dec 2012 03:12:23 +0000 (03:12 +0000)
commit3e794fff87caeaba4fa7d62653a06a676bb38935
tree380586c6b39706afc92a35b507e79f07c9e5bb4a
parent0b6dbb3b05f4f6a26e4ba6f833d20362fe467357
Add Element-specific traversal functions
https://bugs.webkit.org/show_bug.cgi?id=104685

Reviewed by Ryosuke Niwa.

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.

This patch adds ElementTraversal namespace, similar to NodeTraversal. It also switches
bunch of NodeTraversal call sites that obviously only care about elements to using
the new interface.

This should be a speedup too as we avoid number of branches by not having to look
for children of non-ContainerNodes and by allowing use of ContainerNode specific
accessors.

* accessibility/AccessibilityRenderObject.cpp:
(WebCore::AccessibilityRenderObject::addImageMapChildren):
* css/SelectorChecker.cpp:
(WebCore::linkAttribute):
(WebCore::SelectorChecker::allVisitedStateChanged):
(WebCore::SelectorChecker::visitedStateChanged):
* css/StyleInvalidationAnalysis.cpp:
(WebCore::elementMatchesSelectorScopes):
(WebCore::StyleInvalidationAnalysis::invalidateStyle):
* dom/ContainerNodeAlgorithms.h:
(WebCore::ChildFrameDisconnector::collectDescendant):
* dom/Document.cpp:
(WebCore::Document::buildAccessKeyMap):
(WebCore::Document::updateBaseURL):
(WebCore::Document::processBaseElement):
* dom/DocumentOrderedMap.cpp:
(WebCore::DocumentOrderedMap::get):
* dom/Element.cpp:
(WebCore::Element::firstElementChild):
* dom/Element.h:
(WebCore):
* dom/ElementShadow.cpp:
(WebCore::ElementShadow::collectSelectFeatureSetFrom):
* dom/NodeTraversal.h:
(ElementTraversal):
(WebCore):
(WebCore::ElementTraversal::traverseNextElementTemplate):
(WebCore::ElementTraversal::next):
(WebCore::ElementTraversal::firstWithin):
(WebCore::ElementTraversal::traverseNextElementSkippingChildrenTemplate):
(WebCore::ElementTraversal::nextSkippingChildren):
(NodeTraversal):
* dom/TreeScope.cpp:
(WebCore::TreeScope::labelElementForId):
(WebCore::TreeScope::findAnchor):
* editing/CompositeEditCommand.cpp:
(WebCore::CompositeEditCommand::cloneParagraphUnderNewElement):
* editing/DeleteSelectionCommand.cpp:
(WebCore::DeleteSelectionCommand::handleGeneralDelete):
* editing/FrameSelection.cpp:
(WebCore::scanForForm):
* editing/markup.cpp:
(WebCore::completeURLs):
* html/HTMLFieldSetElement.cpp:
(WebCore::HTMLFieldSetElement::invalidateDisabledStateUnder):
(WebCore::HTMLFieldSetElement::childrenChanged):
(WebCore::HTMLFieldSetElement::legend):
(WebCore::HTMLFieldSetElement::refreshElementsIfNeeded):
* html/HTMLFormElement.cpp:
(WebCore::HTMLFormElement::formElementIndex):
* html/HTMLLabelElement.cpp:
(WebCore::HTMLLabelElement::control):
* html/HTMLLegendElement.cpp:
(WebCore::HTMLLegendElement::associatedControl):
* html/HTMLMapElement.cpp:
(WebCore::HTMLMapElement::mapMouseEvent):
* html/HTMLNameCollection.cpp:
(WebCore::HTMLNameCollection::virtualItemAfter):
* html/HTMLObjectElement.cpp:
(WebCore::HTMLObjectElement::containsJavaApplet):
* html/HTMLSelectElement.cpp:
(WebCore::HTMLSelectElement::recalcListItems):
* html/shadow/ContentDistributor.cpp:
(WebCore::ShadowRootContentDistributionData::ensureInsertionPointList):
* page/FocusController.cpp:
(WebCore::FocusController::findFocusCandidateInContainer):
* rendering/RenderCounter.cpp:
(WebCore::nextInPreOrder):
* svg/SVGSVGElement.cpp:
(WebCore::SVGSVGElement::collectIntersectionOrEnclosureList):
* svg/SVGStyledElement.cpp:
(WebCore::SVGStyledElement::title):
* svg/SVGUseElement.cpp:
(WebCore::removeDisallowedElementsFromSubtree):
* svg/animation/SMILTimeContainer.cpp:
(WebCore::SMILTimeContainer::updateDocumentOrderIndexes):

git-svn-id: https://svn.webkit.org/repository/webkit/trunk@137406 268f45cc-cd09-0410-ab3c-d52691b4dbfc
32 files changed:
Source/WebCore/ChangeLog
Source/WebCore/accessibility/AccessibilityRenderObject.cpp
Source/WebCore/css/SelectorChecker.cpp
Source/WebCore/css/StyleInvalidationAnalysis.cpp
Source/WebCore/dom/ContainerNodeAlgorithms.h
Source/WebCore/dom/Document.cpp
Source/WebCore/dom/DocumentOrderedMap.cpp
Source/WebCore/dom/Element.cpp
Source/WebCore/dom/Element.h
Source/WebCore/dom/ElementShadow.cpp
Source/WebCore/dom/NodeTraversal.h
Source/WebCore/dom/TreeScope.cpp
Source/WebCore/editing/CompositeEditCommand.cpp
Source/WebCore/editing/DeleteSelectionCommand.cpp
Source/WebCore/editing/FrameSelection.cpp
Source/WebCore/editing/markup.cpp
Source/WebCore/html/BaseMultipleFieldsDateAndTimeInputType.cpp
Source/WebCore/html/HTMLFieldSetElement.cpp
Source/WebCore/html/HTMLFormElement.cpp
Source/WebCore/html/HTMLLabelElement.cpp
Source/WebCore/html/HTMLLegendElement.cpp
Source/WebCore/html/HTMLMapElement.cpp
Source/WebCore/html/HTMLNameCollection.cpp
Source/WebCore/html/HTMLObjectElement.cpp
Source/WebCore/html/HTMLSelectElement.cpp
Source/WebCore/html/shadow/ContentDistributor.cpp
Source/WebCore/page/FocusController.cpp
Source/WebCore/rendering/RenderCounter.cpp
Source/WebCore/svg/SVGSVGElement.cpp
Source/WebCore/svg/SVGStyledElement.cpp
Source/WebCore/svg/SVGUseElement.cpp
Source/WebCore/svg/animation/SMILTimeContainer.cpp