https://bugs.webkit.org/show_bug.cgi?id=120355
Reviewed by Andreas Kling.
Move from Traversal<ElementType>::next() and Traversal<ElementType>::nextSibling() to iterators.
* css/CSSFontFaceSource.cpp:
(WebCore::CSSFontFaceSource::getFontData):
* dom/Document.cpp:
(WebCore::Document::removeTitle):
(WebCore::Document::updateBaseURL):
(WebCore::Document::processBaseElement):
* dom/TreeScope.cpp:
(WebCore::TreeScope::labelElementForId):
(WebCore::TreeScope::findAnchor):
* html/HTMLFieldSetElement.cpp:
(WebCore::HTMLFieldSetElement::invalidateDisabledStateUnder):
(WebCore::HTMLFieldSetElement::childrenChanged):
* html/HTMLLabelElement.cpp:
(WebCore::HTMLLabelElement::control):
* html/HTMLMediaElement.cpp:
(WebCore::HTMLMediaElement::cancelPendingEventsAndCallbacks):
* html/HTMLObjectElement.cpp:
(WebCore::HTMLObjectElement::parametersForPlugin):
* rendering/FilterEffectRenderer.cpp:
(WebCore::FilterEffectRenderer::buildReferenceFilter):
* svg/SVGFilterPrimitiveStandardAttributes.h:
(WebCore::isSVGFilterPrimitiveStandardAttributes):
(WebCore::SVGFilterPrimitiveStandardAttributes):
* svg/animation/SMILTimeContainer.cpp:
(WebCore::SMILTimeContainer::updateDocumentOrderIndexes):
* svg/graphics/SVGImage.cpp:
(WebCore::SVGImage::hasSingleSecurityOrigin):
git-svn-id: https://svn.webkit.org/repository/webkit/trunk@154679
268f45cc-cd09-0410-ab3c-
d52691b4dbfc
+2013-08-27 Antti Koivisto <antti@apple.com>
+
+ Switch some more code to element child/descendant iterators
+ https://bugs.webkit.org/show_bug.cgi?id=120355
+
+ Reviewed by Andreas Kling.
+
+ Move from Traversal<ElementType>::next() and Traversal<ElementType>::nextSibling() to iterators.
+
+ * css/CSSFontFaceSource.cpp:
+ (WebCore::CSSFontFaceSource::getFontData):
+ * dom/Document.cpp:
+ (WebCore::Document::removeTitle):
+ (WebCore::Document::updateBaseURL):
+ (WebCore::Document::processBaseElement):
+ * dom/TreeScope.cpp:
+ (WebCore::TreeScope::labelElementForId):
+ (WebCore::TreeScope::findAnchor):
+ * html/HTMLFieldSetElement.cpp:
+ (WebCore::HTMLFieldSetElement::invalidateDisabledStateUnder):
+ (WebCore::HTMLFieldSetElement::childrenChanged):
+ * html/HTMLLabelElement.cpp:
+ (WebCore::HTMLLabelElement::control):
+ * html/HTMLMediaElement.cpp:
+ (WebCore::HTMLMediaElement::cancelPendingEventsAndCallbacks):
+ * html/HTMLObjectElement.cpp:
+ (WebCore::HTMLObjectElement::parametersForPlugin):
+ * rendering/FilterEffectRenderer.cpp:
+ (WebCore::FilterEffectRenderer::buildReferenceFilter):
+ * svg/SVGFilterPrimitiveStandardAttributes.h:
+ (WebCore::isSVGFilterPrimitiveStandardAttributes):
+ (WebCore::SVGFilterPrimitiveStandardAttributes):
+ * svg/animation/SMILTimeContainer.cpp:
+ (WebCore::SMILTimeContainer::updateDocumentOrderIndexes):
+ * svg/graphics/SVGImage.cpp:
+ (WebCore::SVGImage::hasSingleSecurityOrigin):
+
2013-08-26 Andreas Kling <akling@apple.com>
FocusController::focusedOrMainFrame() should return a reference.
#include "config.h"
#include "CSSFontFaceSource.h"
-#include "CachedFont.h"
#include "CSSFontFace.h"
#include "CSSFontSelector.h"
+#include "CachedFont.h"
#include "CachedResourceLoader.h"
+#include "ChildIterator.h"
#include "Document.h"
-#include "ElementTraversal.h"
#include "FontCache.h"
#include "FontDescription.h"
#include "SimpleFontData.h"
if (!m_externalSVGFontElement)
return 0;
- if (auto fontFaceElement = Traversal<SVGFontFaceElement>::firstChild(m_externalSVGFontElement.get())) {
+ auto fontFaceChildren = childrenOfType<SVGFontFaceElement>(m_externalSVGFontElement.get());
+ auto firstFontFace = fontFaceChildren.begin();
+ if (firstFontFace != fontFaceChildren.end()) {
if (!m_svgFontFaceElement) {
// We're created using a CSS @font-face rule, that means we're not associated with a SVGFontFaceElement.
// Use the imported <font-face> tag as referencing font-face element for these cases.
- m_svgFontFaceElement = fontFaceElement;
+ m_svgFontFaceElement = &*firstFontFace;
}
- fontData = SimpleFontData::create(SVGFontData::create(fontFaceElement), fontDescription.computedPixelSize(), syntheticBold, syntheticItalic);
+ fontData = SimpleFontData::create(SVGFontData::create(&*firstFontFace), fontDescription.computedPixelSize(), syntheticBold, syntheticItalic);
}
} else
#endif
// Update title based on first title element in the head, if one exists.
if (HTMLElement* headElement = head()) {
- if (HTMLTitleElement* titleElement = Traversal<HTMLTitleElement>::firstWithin(headElement))
- setTitleElement(titleElement->textWithDirection(), titleElement);
+ auto firstTitle = childrenOfType<HTMLTitleElement>(headElement).begin();
+ if (firstTitle != childrenOfType<HTMLTitleElement>(headElement).end())
+ setTitleElement(firstTitle->textWithDirection(), &*firstTitle);
}
if (!m_titleElement)
if (!equalIgnoringFragmentIdentifier(oldBaseURL, m_baseURL)) {
// Base URL change changes any relative visited links.
// FIXME: There are other URLs in the tree that would need to be re-evaluated on dynamic base URL change. Style should be invalidated too.
- for (HTMLAnchorElement* anchor = Traversal<HTMLAnchorElement>::firstWithin(this); anchor; anchor = Traversal<HTMLAnchorElement>::next(anchor))
+ auto anchorDescendants = descendantsOfType<HTMLAnchorElement>(this);
+ for (auto anchor = anchorDescendants.begin(), end = anchorDescendants.end(); anchor != end; ++anchor)
anchor->invalidateCachedVisitedLinkHash();
}
}
// Find the first href attribute in a base element and the first target attribute in a base element.
const AtomicString* href = 0;
const AtomicString* target = 0;
- for (HTMLBaseElement* base = Traversal<HTMLBaseElement>::firstWithin(this); base && (!href || !target); base = Traversal<HTMLBaseElement>::next(base)) {
+ auto baseDescendants = descendantsOfType<HTMLBaseElement>(this);
+ for (auto base = baseDescendants.begin(), end = baseDescendants.end(); base != end && (!href || !target); ++base) {
if (!href) {
const AtomicString& value = base->fastGetAttribute(hrefAttr);
if (!value.isNull())
#include "ContainerNode.h"
#include "DOMSelection.h"
#include "DOMWindow.h"
+#include "DescendantIterator.h"
#include "Document.h"
#include "Element.h"
-#include "ElementTraversal.h"
#include "FocusController.h"
#include "Frame.h"
#include "FrameView.h"
if (!m_labelsByForAttribute) {
// Populate the map on first access.
m_labelsByForAttribute = adoptPtr(new DocumentOrderedMap);
- for (HTMLLabelElement* label = Traversal<HTMLLabelElement>::firstWithin(rootNode()); label; label = Traversal<HTMLLabelElement>::next(label)) {
+
+ auto labelDescendants = descendantsOfType<HTMLLabelElement>(rootNode());
+ for (auto label = labelDescendants.begin(), end = labelDescendants.end(); label != end; ++label) {
const AtomicString& forValue = label->fastGetAttribute(forAttr);
if (!forValue.isEmpty())
- addLabel(forValue, label);
+ addLabel(forValue, &*label);
}
}
return 0;
if (Element* element = getElementById(name))
return element;
- for (HTMLAnchorElement* anchor = Traversal<HTMLAnchorElement>::firstWithin(rootNode()); anchor; anchor = Traversal<HTMLAnchorElement>::next(anchor)) {
+ auto anchorDescendants = descendantsOfType<HTMLAnchorElement>(rootNode());
+ for (auto anchor = anchorDescendants.begin(), end = anchorDescendants.end(); anchor != end; ++anchor) {
if (rootNode()->document()->inQuirksMode()) {
// Quirks mode, case insensitive comparison of names.
if (equalIgnoringCase(anchor->name(), name))
- return anchor;
+ return &*anchor;
} else {
// Strict mode, names need to match exactly.
if (anchor->name() == name)
- return anchor;
+ return &*anchor;
}
}
return 0;
#include "config.h"
#include "HTMLFieldSetElement.h"
-#include "ElementTraversal.h"
+#include "ChildIterator.h"
+#include "DescendantIterator.h"
#include "HTMLCollection.h"
#include "HTMLLegendElement.h"
#include "HTMLNames.h"
void HTMLFieldSetElement::invalidateDisabledStateUnder(Element* base)
{
- for (HTMLFormControlElement* control = Traversal<HTMLFormControlElement>::firstWithin(base); control; control = Traversal<HTMLFormControlElement>::next(control, base))
+ auto formControlDescendants = descendantsOfType<HTMLFormControlElement>(base);
+ for (auto control = formControlDescendants.begin(), end = formControlDescendants.end(); control != end; ++control)
control->ancestorDisabledStateWasChanged();
}
void HTMLFieldSetElement::childrenChanged(bool changedByParser, Node* beforeChange, Node* afterChange, int childCountDelta)
{
HTMLFormControlElement::childrenChanged(changedByParser, beforeChange, afterChange, childCountDelta);
- for (HTMLLegendElement* legend = Traversal<HTMLLegendElement>::firstChild(this); legend; legend = Traversal<HTMLLegendElement>::nextSibling(legend))
- invalidateDisabledStateUnder(legend);
+
+ auto legendChildren = childrenOfType<HTMLLegendElement>(this);
+ for (auto legend = legendChildren.begin(), end = legendChildren.end(); legend != end; ++legend)
+ invalidateDisabledStateUnder(&*legend);
}
bool HTMLFieldSetElement::supportsFocus() const
#include "config.h"
#include "HTMLLabelElement.h"
+#include "DescendantIterator.h"
#include "Document.h"
-#include "ElementTraversal.h"
#include "Event.h"
#include "EventNames.h"
#include "FormAssociatedElement.h"
// Search the children and descendants of the label element for a form element.
// per http://dev.w3.org/html5/spec/Overview.html#the-label-element
// the form element must be "labelable form-associated element".
-
- LabelableElement* labelableElement = Traversal<LabelableElement>::firstWithin(this);
- for (; labelableElement; labelableElement = Traversal<LabelableElement>::next(labelableElement, this)) {
+ auto labelableDescendants = descendantsOfType<LabelableElement>(this);
+ for (auto labelableElement = labelableDescendants.begin(), end = labelableDescendants.end(); labelableElement != end; ++labelableElement) {
if (labelableElement->supportLabels())
- return labelableElement;
+ return &*labelableElement;
}
return 0;
}
LOG(Media, "HTMLMediaElement::cancelPendingEventsAndCallbacks");
m_asyncEventQueue->cancelAllEvents();
- for (auto source = Traversal<HTMLSourceElement>::firstChild(this); source; source = Traversal<HTMLSourceElement>::nextSibling(source))
+ auto sourceChildren = childrenOfType<HTMLSourceElement>(this);
+ for (auto source = sourceChildren.begin(), end = sourceChildren.end(); source != end; ++source)
source->cancelPendingErrorEvent();
}
#include "Attribute.h"
#include "CSSValueKeywords.h"
#include "CachedImage.h"
+#include "ChildIterator.h"
#include "Chrome.h"
#include "ChromeClient.h"
-#include "ElementTraversal.h"
#include "EventNames.h"
#include "ExceptionCode.h"
#include "FormDataList.h"
// Scan the PARAM children and store their name/value pairs.
// Get the URL and type from the params if we don't already have them.
- for (auto param = Traversal<HTMLParamElement>::firstChild(this); param; param = Traversal<HTMLParamElement>::nextSibling(param)) {
+ auto paramChildren = childrenOfType<HTMLParamElement>(this);
+ for (auto param = paramChildren.begin(), end = paramChildren.end(); param != end; ++param) {
String name = param->name();
if (name.isEmpty())
continue;
#include "FilterEffectRenderer.h"
+#include "ChildIterator.h"
#include "ColorSpace.h"
#include "Document.h"
-#include "ElementTraversal.h"
#include "FEColorMatrix.h"
#include "FEComponentTransfer.h"
#include "FEDropShadow.h"
// This may need a spec clarification.
RefPtr<SVGFilterBuilder> builder = SVGFilterBuilder::create(previousEffect, SourceAlpha::create(this));
- for (SVGElement* svgElement = Traversal<SVGElement>::firstChild(filter); svgElement; svgElement = Traversal<SVGElement>::nextSibling(svgElement)) {
- if (!svgElement->isFilterEffect())
- continue;
- SVGFilterPrimitiveStandardAttributes* effectElement = static_cast<SVGFilterPrimitiveStandardAttributes*>(svgElement);
-
+ auto attributesChildren = childrenOfType<SVGFilterPrimitiveStandardAttributes>(filter);
+ for (auto it = attributesChildren.begin(), end = attributesChildren.end(); it != end; ++it) {
+ SVGFilterPrimitiveStandardAttributes* effectElement = &*it;
effect = effectElement->build(builder.get(), this);
if (!effect)
continue;
void invalidateFilterPrimitiveParent(SVGElement*);
+inline bool isSVGFilterPrimitiveStandardAttributes(const Node* node)
+{
+ return node->isSVGElement() && toSVGElement(node)->isFilterEffect();
+}
+
+template <> inline bool isElementOfType<SVGFilterPrimitiveStandardAttributes>(const Element* element) { return isSVGFilterPrimitiveStandardAttributes(element); }
+
+
} // namespace WebCore
#endif // ENABLE(SVG)
#include "SMILTimeContainer.h"
#if ENABLE(SVG)
+#include "DescendantIterator.h"
#include "Document.h"
-#include "ElementTraversal.h"
#include "SVGNames.h"
#include "SVGSMILElement.h"
#include "SVGSVGElement.h"
void SMILTimeContainer::updateDocumentOrderIndexes()
{
unsigned timingElementCount = 0;
- SVGSMILElement* smilElement = Traversal<SVGSMILElement>::firstWithin(m_ownerSVGElement);
- for (; smilElement; smilElement = Traversal<SVGSMILElement>::next(smilElement, m_ownerSVGElement))
+
+ auto smilDescendants = descendantsOfType<SVGSMILElement>(m_ownerSVGElement);
+ for (auto smilElement = smilDescendants.begin(), end = smilDescendants.end(); smilElement != end; ++smilElement)
smilElement->setDocumentOrderIndex(timingElementCount++);
+
m_documentOrderIndexesDirty = false;
}
#include "SVGImage.h"
#include "Chrome.h"
+#include "DescendantIterator.h"
#include "DocumentLoader.h"
-#include "ElementTraversal.h"
#include "FrameView.h"
#include "ImageBuffer.h"
#include "ImageObserver.h"
return true;
// Don't allow foreignObject elements since they can leak information with arbitrary HTML (like spellcheck or control theme).
- if (Traversal<SVGForeignObjectElement>::firstWithin(rootElement))
+ auto foreignObjectDescendants = descendantsOfType<SVGForeignObjectElement>(rootElement);
+ if (foreignObjectDescendants.begin() != foreignObjectDescendants.end())
return false;
// Because SVG image rendering disallows external resources and links,