https://bugs.webkit.org/show_bug.cgi?id=126363
Reviewed by Anders Carlsson.
Just use childrenOfType<Element>/descendantsOfType<Element> instead. They are not that much longer
and consistency is valuable.
* accessibility/AccessibilityNodeObject.cpp:
(WebCore::AccessibilityNodeObject::canvasHasFallbackContent):
(WebCore::siblingWithAriaRole):
* accessibility/AccessibilityTable.cpp:
(WebCore::AccessibilityTable::isDataTable):
* css/StyleInvalidationAnalysis.cpp:
(WebCore::StyleInvalidationAnalysis::invalidateStyle):
* dom/ChildNodeList.cpp:
(WebCore::ChildNodeList::namedItem):
* dom/Document.cpp:
(WebCore::Document::buildAccessKeyMap):
(WebCore::Document::childrenChanged):
* dom/Element.cpp:
(WebCore::Element::resetComputedStyle):
* dom/ElementChildIterator.h:
* dom/ElementDescendantIterator.h:
* dom/SelectorQuery.cpp:
(WebCore::elementsForLocalName):
(WebCore::anyElement):
(WebCore::SelectorDataList::executeSingleTagNameSelectorData):
(WebCore::SelectorDataList::executeSingleClassNameSelectorData):
(WebCore::SelectorDataList::executeSingleSelectorData):
(WebCore::SelectorDataList::executeSingleMultiSelectorData):
* editing/ApplyStyleCommand.cpp:
(WebCore::ApplyStyleCommand::cleanupUnstyledAppleStyleSpans):
* editing/ReplaceSelectionCommand.cpp:
(WebCore::removeHeadContents):
* editing/markup.cpp:
(WebCore::completeURLs):
* html/HTMLFieldSetElement.cpp:
(WebCore::HTMLFieldSetElement::refreshElementsIfNeeded):
* html/HTMLObjectElement.cpp:
(WebCore::HTMLObjectElement::containsJavaApplet):
* loader/PlaceholderDocument.cpp:
(WebCore::PlaceholderDocument::createRenderTree):
* rendering/RenderChildIterator.h:
* svg/SVGSVGElement.cpp:
(WebCore::SVGSVGElement::getElementById):
* svg/SVGUseElement.cpp:
(WebCore::subtreeContainsDisallowedElement):
(WebCore::removeDisallowedElementsFromSubtree):
git-svn-id: https://svn.webkit.org/repository/webkit/trunk@161196
268f45cc-cd09-0410-ab3c-
d52691b4dbfc
2014-01-01 Antti Koivisto <antti@apple.com>
+ Remove elementChildren/elementDescendants shorthands
+ https://bugs.webkit.org/show_bug.cgi?id=126363
+
+ Reviewed by Anders Carlsson.
+
+ Just use childrenOfType<Element>/descendantsOfType<Element> instead. They are not that much longer
+ and consistency is valuable.
+
+ * accessibility/AccessibilityNodeObject.cpp:
+ (WebCore::AccessibilityNodeObject::canvasHasFallbackContent):
+ (WebCore::siblingWithAriaRole):
+ * accessibility/AccessibilityTable.cpp:
+ (WebCore::AccessibilityTable::isDataTable):
+ * css/StyleInvalidationAnalysis.cpp:
+ (WebCore::StyleInvalidationAnalysis::invalidateStyle):
+ * dom/ChildNodeList.cpp:
+ (WebCore::ChildNodeList::namedItem):
+ * dom/Document.cpp:
+ (WebCore::Document::buildAccessKeyMap):
+ (WebCore::Document::childrenChanged):
+ * dom/Element.cpp:
+ (WebCore::Element::resetComputedStyle):
+ * dom/ElementChildIterator.h:
+ * dom/ElementDescendantIterator.h:
+ * dom/SelectorQuery.cpp:
+ (WebCore::elementsForLocalName):
+ (WebCore::anyElement):
+ (WebCore::SelectorDataList::executeSingleTagNameSelectorData):
+ (WebCore::SelectorDataList::executeSingleClassNameSelectorData):
+ (WebCore::SelectorDataList::executeSingleSelectorData):
+ (WebCore::SelectorDataList::executeSingleMultiSelectorData):
+ * editing/ApplyStyleCommand.cpp:
+ (WebCore::ApplyStyleCommand::cleanupUnstyledAppleStyleSpans):
+ * editing/ReplaceSelectionCommand.cpp:
+ (WebCore::removeHeadContents):
+ * editing/markup.cpp:
+ (WebCore::completeURLs):
+ * html/HTMLFieldSetElement.cpp:
+ (WebCore::HTMLFieldSetElement::refreshElementsIfNeeded):
+ * html/HTMLObjectElement.cpp:
+ (WebCore::HTMLObjectElement::containsJavaApplet):
+ * loader/PlaceholderDocument.cpp:
+ (WebCore::PlaceholderDocument::createRenderTree):
+ * rendering/RenderChildIterator.h:
+ * svg/SVGSVGElement.cpp:
+ (WebCore::SVGSVGElement::getElementById):
+ * svg/SVGUseElement.cpp:
+ (WebCore::subtreeContainsDisallowedElement):
+ (WebCore::removeDisallowedElementsFromSubtree):
+
+2014-01-01 Antti Koivisto <antti@apple.com>
+
Do less synchronous render tree construction
https://bugs.webkit.org/show_bug.cgi?id=126359
// If it has any children that are elements, we'll assume it might be fallback
// content. If it has no children or its only children are not elements
// (e.g. just text nodes), it doesn't have fallback content.
- return elementChildren(canvasElement).first();
+ return childrenOfType<Element>(canvasElement).first();
}
bool AccessibilityNodeObject::isImageButton() const
if (!parent)
return nullptr;
- for (auto& sibling : elementChildren(*parent)) {
+ for (auto& sibling : childrenOfType<Element>(*parent)) {
const AtomicString& siblingAriaRole = sibling.fastGetAttribute(roleAttr);
if (equalIgnoringCase(siblingAriaRole, role))
return &sibling;
return true;
// if there's a colgroup or col element, it's probably a data table.
- for (auto& child : elementChildren(*tableElement)) {
+ for (auto& child : childrenOfType<Element>(*tableElement)) {
if (child.hasTagName(colTag) || child.hasTagName(colgroupTag))
return true;
}
if (m_idScopes.isEmpty() && m_classScopes.isEmpty())
return;
- auto it = elementDescendants(document).begin();
- auto end = elementDescendants(document).end();
+ auto it = descendantsOfType<Element>(document).begin();
+ auto end = descendantsOfType<Element>(document).end();
while (it != end) {
if (elementMatchesSelectorScopes(*it, m_idScopes, m_classScopes)) {
it->setNeedsStyleRecalc();
if (!element || !m_parent.get().treeScope().containsMultipleElementsWithId(name))
return nullptr;
}
- for (auto& element : elementChildren(m_parent.get())) {
+ for (auto& element : childrenOfType<Element>(m_parent.get())) {
if (element.hasID() && element.idForStyleResolution() == name)
return const_cast<Element*>(&element);
}
{
ASSERT(scope);
ContainerNode* rootNode = scope->rootNode();
- for (auto& element : elementDescendants(*rootNode)) {
+ for (auto& element : descendantsOfType<Element>(*rootNode)) {
const AtomicString& accessKey = element.fastGetAttribute(accesskeyAttr);
if (!accessKey.isEmpty())
m_elementsByAccessKey.set(accessKey.impl(), &element);
}
#endif
- Element* newDocumentElement = elementChildren(*this).first();
+ Element* newDocumentElement = childrenOfType<Element>(*this).first();
if (newDocumentElement == m_documentElement)
return;
if (!hasRareData() || !elementRareData()->computedStyle())
return;
elementRareData()->resetComputedStyle();
- for (auto& child : elementDescendants(*this)) {
+ for (auto& child : descendantsOfType<Element>(*this)) {
if (child.hasRareData())
child.elementRareData()->resetComputedStyle();
}
const ContainerNode& m_parent;
};
-ElementChildIteratorAdapter<Element> elementChildren(ContainerNode&);
-ElementChildConstIteratorAdapter<Element> elementChildren(const ContainerNode&);
template <typename ElementType> ElementChildIteratorAdapter<ElementType> childrenOfType(ContainerNode&);
template <typename ElementType> ElementChildConstIteratorAdapter<ElementType> childrenOfType(const ContainerNode&);
// Standalone functions
-inline ElementChildIteratorAdapter<Element> elementChildren(ContainerNode& parent)
-{
- return ElementChildIteratorAdapter<Element>(parent);
-}
-
template <typename ElementType>
inline ElementChildIteratorAdapter<ElementType> childrenOfType(ContainerNode& parent)
{
return ElementChildIteratorAdapter<ElementType>(parent);
}
-inline ElementChildConstIteratorAdapter<Element> elementChildren(const ContainerNode& parent)
-{
- return ElementChildConstIteratorAdapter<Element>(parent);
-}
-
template <typename ElementType>
inline ElementChildConstIteratorAdapter<ElementType> childrenOfType(const ContainerNode& parent)
{
const ContainerNode& m_root;
};
-ElementDescendantIteratorAdapter<Element> elementDescendants(ContainerNode&);
-ElementDescendantConstIteratorAdapter<Element> elementDescendants(const ContainerNode&);
template <typename ElementType> ElementDescendantIteratorAdapter<ElementType> descendantsOfType(ContainerNode&);
template <typename ElementType> ElementDescendantConstIteratorAdapter<ElementType> descendantsOfType(const ContainerNode&);
// Standalone functions
-inline ElementDescendantIteratorAdapter<Element> elementDescendants(ContainerNode& root)
-{
- return ElementDescendantIteratorAdapter<Element>(root);
-}
-
template <typename ElementType>
inline ElementDescendantIteratorAdapter<ElementType> descendantsOfType(ContainerNode& root)
{
return ElementDescendantIteratorAdapter<ElementType>(root);
}
-inline ElementDescendantConstIteratorAdapter<Element> elementDescendants(const ContainerNode& root)
-{
- return ElementDescendantConstIteratorAdapter<Element>(root);
-}
-
template <typename ElementType>
inline ElementDescendantConstIteratorAdapter<ElementType> descendantsOfType(const ContainerNode& root)
{
template <typename SelectorQueryTrait>
static inline void elementsForLocalName(const ContainerNode& rootNode, const AtomicString& localName, typename SelectorQueryTrait::OutputType& output)
{
- for (auto& element : elementDescendants(const_cast<ContainerNode&>(rootNode))) {
+ for (auto& element : descendantsOfType<Element>(const_cast<ContainerNode&>(rootNode))) {
if (element.tagQName().localName() == localName) {
SelectorQueryTrait::appendOutputForElement(output, &element);
if (SelectorQueryTrait::shouldOnlyMatchFirstElement)
template <typename SelectorQueryTrait>
static inline void anyElement(const ContainerNode& rootNode, typename SelectorQueryTrait::OutputType& output)
{
- for (auto& element : elementDescendants(const_cast<ContainerNode&>(rootNode))) {
+ for (auto& element : descendantsOfType<Element>(const_cast<ContainerNode&>(rootNode))) {
SelectorQueryTrait::appendOutputForElement(output, &element);
if (SelectorQueryTrait::shouldOnlyMatchFirstElement)
return;
}
} else {
// Fallback: NamespaceURI is set, selectorLocalName may be starAtom.
- for (auto& element : elementDescendants(const_cast<ContainerNode&>(rootNode))) {
+ for (auto& element : descendantsOfType<Element>(const_cast<ContainerNode&>(rootNode))) {
if (element.namespaceURI() == selectorNamespaceURI && (selectorLocalName == starAtom || element.tagQName().localName() == selectorLocalName)) {
SelectorQueryTrait::appendOutputForElement(output, &element);
if (SelectorQueryTrait::shouldOnlyMatchFirstElement)
ASSERT(isSingleClassNameSelector(*selectorData.selector));
const AtomicString& className = selectorData.selector->value();
- for (auto& element : elementDescendants(const_cast<ContainerNode&>(rootNode))) {
+ for (auto& element : descendantsOfType<Element>(const_cast<ContainerNode&>(rootNode))) {
if (element.hasClass() && element.classNames().contains(className)) {
SelectorQueryTrait::appendOutputForElement(output, &element);
if (SelectorQueryTrait::shouldOnlyMatchFirstElement)
{
ASSERT(m_selectors.size() == 1);
- for (auto& element : elementDescendants(const_cast<ContainerNode&>(rootNode))) {
+ for (auto& element : descendantsOfType<Element>(const_cast<ContainerNode&>(rootNode))) {
if (selectorMatches(selectorData, element, rootNode)) {
SelectorQueryTrait::appendOutputForElement(output, &element);
if (SelectorQueryTrait::shouldOnlyMatchFirstElement)
ALWAYS_INLINE void SelectorDataList::executeSingleMultiSelectorData(const ContainerNode& rootNode, typename SelectorQueryTrait::OutputType& output) const
{
unsigned selectorCount = m_selectors.size();
- for (auto& element : elementDescendants(const_cast<ContainerNode&>(rootNode))) {
+ for (auto& element : descendantsOfType<Element>(const_cast<ContainerNode&>(rootNode))) {
for (unsigned i = 0; i < selectorCount; ++i) {
if (selectorMatches(m_selectors[i], element, rootNode)) {
SelectorQueryTrait::appendOutputForElement(output, &element);
// all the children of the dummy's parent
Vector<Element*> toRemove;
- for (auto& child : elementChildren(*dummySpanAncestor)) {
+ for (auto& child : childrenOfType<Element>(*dummySpanAncestor)) {
if (isSpanWithoutAttributesOrUnstyledStyleSpan(&child))
toRemove.append(&child);
}
Vector<Element*> toRemove;
- auto it = elementDescendants(*fragment.fragment()).begin();
- auto end = elementDescendants(*fragment.fragment()).end();
+ auto it = descendantsOfType<Element>(*fragment.fragment()).begin();
+ auto end = descendantsOfType<Element>(*fragment.fragment()).end();
while (it != end) {
if (it->hasTagName(baseTag) || it->hasTagName(linkTag) || it->hasTagName(metaTag) || it->hasTagName(styleTag) || isHTMLTitleElement(*it)) {
toRemove.append(&*it);
URL parsedBaseURL(ParsedURLString, baseURL);
- for (auto& element : elementDescendants(*fragment)) {
+ for (auto& element : descendantsOfType<Element>(*fragment)) {
if (!element.hasAttributes())
continue;
unsigned length = element.attributeCount();
m_associatedElements.clear();
- for (auto& element : elementDescendants(const_cast<HTMLFieldSetElement&>(*this))) {
+ for (auto& element : descendantsOfType<Element>(const_cast<HTMLFieldSetElement&>(*this))) {
if (element.hasTagName(objectTag))
m_associatedElements.append(&toHTMLObjectElement(element));
else if (element.isFormControlElement())
if (MIMETypeRegistry::isJavaAppletMIMEType(getAttribute(typeAttr)))
return true;
- for (auto& child : elementChildren(*this)) {
+ for (auto& child : childrenOfType<Element>(*this)) {
if (child.hasTagName(paramTag) && equalIgnoringCase(child.getNameAttribute(), "type")
&& MIMETypeRegistry::isJavaAppletMIMEType(child.getAttribute(valueAttr).string()))
return true;
{
ASSERT(!renderView());
- for (auto& child : elementChildren(*this))
+ for (auto& child : childrenOfType<Element>(*this))
Style::attachRenderTree(child);
}
const RenderElement& m_parent;
};
-RenderChildIteratorAdapter<RenderObject> elementChildren(RenderElement&);
-RenderChildConstIteratorAdapter<RenderObject> elementChildren(const RenderElement&);
template <typename T> RenderChildIteratorAdapter<T> childrenOfType(RenderElement&);
template <typename T> RenderChildConstIteratorAdapter<T> childrenOfType(const RenderElement&);
// Fall back to traversing our subtree. Duplicate ids are allowed, the first found will
// be returned.
- for (auto& element : elementDescendants(*this)) {
+ for (auto& element : descendantsOfType<Element>(*this)) {
if (element.getIdAttribute() == id)
return &element;
}
static bool subtreeContainsDisallowedElement(SVGElement& start)
{
- for (auto& element : elementDescendants(start)) {
+ for (auto& element : descendantsOfType<Element>(start)) {
if (isDisallowedElement(element))
return true;
}
{
ASSERT(!subtree.inDocument());
Vector<Element*> toRemove;
- auto it = elementDescendants(subtree).begin();
- auto end = elementDescendants(subtree).end();
+ auto it = descendantsOfType<Element>(subtree).begin();
+ auto end = descendantsOfType<Element>(subtree).end();
while (it != end) {
if (isDisallowedElement(*it)) {
toRemove.append(&*it);