Changeset 161196 in webkit


Ignore:
Timestamp:
Jan 1, 2014, 1:48:13 PM (11 years ago)
Author:
Antti Koivisto
Message:

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):

Location:
trunk/Source/WebCore
Files:
19 edited

Legend:

Unmodified
Added
Removed
  • trunk/Source/WebCore/ChangeLog

    r161195 r161196  
     12014-01-01  Antti Koivisto  <antti@apple.com>
     2
     3        Remove elementChildren/elementDescendants shorthands
     4        https://bugs.webkit.org/show_bug.cgi?id=126363
     5
     6        Reviewed by Anders Carlsson.
     7
     8        Just use childrenOfType<Element>/descendantsOfType<Element> instead. They are not that much longer
     9        and consistency is valuable.
     10
     11        * accessibility/AccessibilityNodeObject.cpp:
     12        (WebCore::AccessibilityNodeObject::canvasHasFallbackContent):
     13        (WebCore::siblingWithAriaRole):
     14        * accessibility/AccessibilityTable.cpp:
     15        (WebCore::AccessibilityTable::isDataTable):
     16        * css/StyleInvalidationAnalysis.cpp:
     17        (WebCore::StyleInvalidationAnalysis::invalidateStyle):
     18        * dom/ChildNodeList.cpp:
     19        (WebCore::ChildNodeList::namedItem):
     20        * dom/Document.cpp:
     21        (WebCore::Document::buildAccessKeyMap):
     22        (WebCore::Document::childrenChanged):
     23        * dom/Element.cpp:
     24        (WebCore::Element::resetComputedStyle):
     25        * dom/ElementChildIterator.h:
     26        * dom/ElementDescendantIterator.h:
     27        * dom/SelectorQuery.cpp:
     28        (WebCore::elementsForLocalName):
     29        (WebCore::anyElement):
     30        (WebCore::SelectorDataList::executeSingleTagNameSelectorData):
     31        (WebCore::SelectorDataList::executeSingleClassNameSelectorData):
     32        (WebCore::SelectorDataList::executeSingleSelectorData):
     33        (WebCore::SelectorDataList::executeSingleMultiSelectorData):
     34        * editing/ApplyStyleCommand.cpp:
     35        (WebCore::ApplyStyleCommand::cleanupUnstyledAppleStyleSpans):
     36        * editing/ReplaceSelectionCommand.cpp:
     37        (WebCore::removeHeadContents):
     38        * editing/markup.cpp:
     39        (WebCore::completeURLs):
     40        * html/HTMLFieldSetElement.cpp:
     41        (WebCore::HTMLFieldSetElement::refreshElementsIfNeeded):
     42        * html/HTMLObjectElement.cpp:
     43        (WebCore::HTMLObjectElement::containsJavaApplet):
     44        * loader/PlaceholderDocument.cpp:
     45        (WebCore::PlaceholderDocument::createRenderTree):
     46        * rendering/RenderChildIterator.h:
     47        * svg/SVGSVGElement.cpp:
     48        (WebCore::SVGSVGElement::getElementById):
     49        * svg/SVGUseElement.cpp:
     50        (WebCore::subtreeContainsDisallowedElement):
     51        (WebCore::removeDisallowedElementsFromSubtree):
     52
    1532014-01-01  Antti Koivisto  <antti@apple.com>
    254
  • trunk/Source/WebCore/accessibility/AccessibilityNodeObject.cpp

    r160966 r161196  
    440440    // content. If it has no children or its only children are not elements
    441441    // (e.g. just text nodes), it doesn't have fallback content.
    442     return elementChildren(canvasElement).first();
     442    return childrenOfType<Element>(canvasElement).first();
    443443}
    444444
     
    11841184        return nullptr;
    11851185
    1186     for (auto& sibling : elementChildren(*parent)) {
     1186    for (auto& sibling : childrenOfType<Element>(*parent)) {
    11871187        const AtomicString& siblingAriaRole = sibling.fastGetAttribute(roleAttr);
    11881188        if (equalIgnoringCase(siblingAriaRole, role))
  • trunk/Source/WebCore/accessibility/AccessibilityTable.cpp

    r160966 r161196  
    125125
    126126    // if there's a colgroup or col element, it's probably a data table.
    127     for (auto& child : elementChildren(*tableElement)) {
     127    for (auto& child : childrenOfType<Element>(*tableElement)) {
    128128        if (child.hasTagName(colTag) || child.hasTagName(colgroupTag))
    129129            return true;
  • trunk/Source/WebCore/css/StyleInvalidationAnalysis.cpp

    r157924 r161196  
    119119        return;
    120120
    121     auto it = elementDescendants(document).begin();
    122     auto end = elementDescendants(document).end();
     121    auto it = descendantsOfType<Element>(document).begin();
     122    auto end = descendantsOfType<Element>(document).end();
    123123    while (it != end) {
    124124        if (elementMatchesSelectorScopes(*it, m_idScopes, m_classScopes)) {
  • trunk/Source/WebCore/dom/ChildNodeList.cpp

    r160598 r161196  
    9595            return nullptr;
    9696    }
    97     for (auto& element : elementChildren(m_parent.get())) {
     97    for (auto& element : childrenOfType<Element>(m_parent.get())) {
    9898        if (element.hasID() && element.idForStyleResolution() == name)
    9999            return const_cast<Element*>(&element);
  • trunk/Source/WebCore/dom/Document.cpp

    r161153 r161196  
    687687    ASSERT(scope);
    688688    ContainerNode* rootNode = scope->rootNode();
    689     for (auto& element : elementDescendants(*rootNode)) {
     689    for (auto& element : descendantsOfType<Element>(*rootNode)) {
    690690        const AtomicString& accessKey = element.fastGetAttribute(accesskeyAttr);
    691691        if (!accessKey.isEmpty())
     
    807807#endif
    808808
    809     Element* newDocumentElement = elementChildren(*this).first();
     809    Element* newDocumentElement = childrenOfType<Element>(*this).first();
    810810
    811811    if (newDocumentElement == m_documentElement)
  • trunk/Source/WebCore/dom/Element.cpp

    r161181 r161196  
    29312931        return;
    29322932    elementRareData()->resetComputedStyle();
    2933     for (auto& child : elementDescendants(*this)) {
     2933    for (auto& child : descendantsOfType<Element>(*this)) {
    29342934        if (child.hasRareData())
    29352935            child.elementRareData()->resetComputedStyle();
  • trunk/Source/WebCore/dom/ElementChildIterator.h

    r157924 r161196  
    7373};
    7474
    75 ElementChildIteratorAdapter<Element> elementChildren(ContainerNode&);
    76 ElementChildConstIteratorAdapter<Element> elementChildren(const ContainerNode&);
    7775template <typename ElementType> ElementChildIteratorAdapter<ElementType> childrenOfType(ContainerNode&);
    7876template <typename ElementType> ElementChildConstIteratorAdapter<ElementType> childrenOfType(const ContainerNode&);
     
    184182// Standalone functions
    185183
    186 inline ElementChildIteratorAdapter<Element> elementChildren(ContainerNode& parent)
    187 {
    188     return ElementChildIteratorAdapter<Element>(parent);
    189 }
    190 
    191184template <typename ElementType>
    192185inline ElementChildIteratorAdapter<ElementType> childrenOfType(ContainerNode& parent)
    193186{
    194187    return ElementChildIteratorAdapter<ElementType>(parent);
    195 }
    196 
    197 inline ElementChildConstIteratorAdapter<Element> elementChildren(const ContainerNode& parent)
    198 {
    199     return ElementChildConstIteratorAdapter<Element>(parent);
    200188}
    201189
  • trunk/Source/WebCore/dom/ElementDescendantIterator.h

    r158530 r161196  
    7979};
    8080
    81 ElementDescendantIteratorAdapter<Element> elementDescendants(ContainerNode&);
    82 ElementDescendantConstIteratorAdapter<Element> elementDescendants(const ContainerNode&);
    8381template <typename ElementType> ElementDescendantIteratorAdapter<ElementType> descendantsOfType(ContainerNode&);
    8482template <typename ElementType> ElementDescendantConstIteratorAdapter<ElementType> descendantsOfType(const ContainerNode&);
     
    231229// Standalone functions
    232230
    233 inline ElementDescendantIteratorAdapter<Element> elementDescendants(ContainerNode& root)
    234 {
    235     return ElementDescendantIteratorAdapter<Element>(root);
    236 }
    237 
    238231template <typename ElementType>
    239232inline ElementDescendantIteratorAdapter<ElementType> descendantsOfType(ContainerNode& root)
     
    242235}
    243236
    244 inline ElementDescendantConstIteratorAdapter<Element> elementDescendants(const ContainerNode& root)
    245 {
    246     return ElementDescendantConstIteratorAdapter<Element>(root);
    247 }
    248 
    249237template <typename ElementType>
    250238inline ElementDescendantConstIteratorAdapter<ElementType> descendantsOfType(const ContainerNode& root)
  • trunk/Source/WebCore/dom/SelectorQuery.cpp

    r160598 r161196  
    166166static inline void elementsForLocalName(const ContainerNode& rootNode, const AtomicString& localName, typename SelectorQueryTrait::OutputType& output)
    167167{
    168     for (auto& element : elementDescendants(const_cast<ContainerNode&>(rootNode))) {
     168    for (auto& element : descendantsOfType<Element>(const_cast<ContainerNode&>(rootNode))) {
    169169        if (element.tagQName().localName() == localName) {
    170170            SelectorQueryTrait::appendOutputForElement(output, &element);
     
    178178static inline void anyElement(const ContainerNode& rootNode, typename SelectorQueryTrait::OutputType& output)
    179179{
    180     for (auto& element : elementDescendants(const_cast<ContainerNode&>(rootNode))) {
     180    for (auto& element : descendantsOfType<Element>(const_cast<ContainerNode&>(rootNode))) {
    181181        SelectorQueryTrait::appendOutputForElement(output, &element);
    182182        if (SelectorQueryTrait::shouldOnlyMatchFirstElement)
     
    206206    } else {
    207207        // Fallback: NamespaceURI is set, selectorLocalName may be starAtom.
    208         for (auto& element : elementDescendants(const_cast<ContainerNode&>(rootNode))) {
     208        for (auto& element : descendantsOfType<Element>(const_cast<ContainerNode&>(rootNode))) {
    209209            if (element.namespaceURI() == selectorNamespaceURI && (selectorLocalName == starAtom || element.tagQName().localName() == selectorLocalName)) {
    210210                SelectorQueryTrait::appendOutputForElement(output, &element);
     
    228228
    229229    const AtomicString& className = selectorData.selector->value();
    230     for (auto& element : elementDescendants(const_cast<ContainerNode&>(rootNode))) {
     230    for (auto& element : descendantsOfType<Element>(const_cast<ContainerNode&>(rootNode))) {
    231231        if (element.hasClass() && element.classNames().contains(className)) {
    232232            SelectorQueryTrait::appendOutputForElement(output, &element);
     
    242242    ASSERT(m_selectors.size() == 1);
    243243
    244     for (auto& element : elementDescendants(const_cast<ContainerNode&>(rootNode))) {
     244    for (auto& element : descendantsOfType<Element>(const_cast<ContainerNode&>(rootNode))) {
    245245        if (selectorMatches(selectorData, element, rootNode)) {
    246246            SelectorQueryTrait::appendOutputForElement(output, &element);
     
    255255{
    256256    unsigned selectorCount = m_selectors.size();
    257     for (auto& element : elementDescendants(const_cast<ContainerNode&>(rootNode))) {
     257    for (auto& element : descendantsOfType<Element>(const_cast<ContainerNode&>(rootNode))) {
    258258        for (unsigned i = 0; i < selectorCount; ++i) {
    259259            if (selectorMatches(m_selectors[i], element, rootNode)) {
  • trunk/Source/WebCore/editing/ApplyStyleCommand.cpp

    r160966 r161196  
    440440
    441441    Vector<Element*> toRemove;
    442     for (auto& child : elementChildren(*dummySpanAncestor)) {
     442    for (auto& child : childrenOfType<Element>(*dummySpanAncestor)) {
    443443        if (isSpanWithoutAttributesOrUnstyledStyleSpan(&child))
    444444            toRemove.append(&child);
  • trunk/Source/WebCore/editing/ReplaceSelectionCommand.cpp

    r161050 r161196  
    707707    Vector<Element*> toRemove;
    708708
    709     auto it = elementDescendants(*fragment.fragment()).begin();
    710     auto end = elementDescendants(*fragment.fragment()).end();
     709    auto it = descendantsOfType<Element>(*fragment.fragment()).begin();
     710    auto end = descendantsOfType<Element>(*fragment.fragment()).end();
    711711    while (it != end) {
    712712        if (it->hasTagName(baseTag) || it->hasTagName(linkTag) || it->hasTagName(metaTag) || it->hasTagName(styleTag) || isHTMLTitleElement(*it)) {
  • trunk/Source/WebCore/editing/markup.cpp

    r160598 r161196  
    100100    URL parsedBaseURL(ParsedURLString, baseURL);
    101101
    102     for (auto& element : elementDescendants(*fragment)) {
     102    for (auto& element : descendantsOfType<Element>(*fragment)) {
    103103        if (!element.hasAttributes())
    104104            continue;
  • trunk/Source/WebCore/html/HTMLFieldSetElement.cpp

    r161181 r161196  
    107107    m_associatedElements.clear();
    108108
    109     for (auto& element : elementDescendants(const_cast<HTMLFieldSetElement&>(*this))) {
     109    for (auto& element : descendantsOfType<Element>(const_cast<HTMLFieldSetElement&>(*this))) {
    110110        if (element.hasTagName(objectTag))
    111111            m_associatedElements.append(&toHTMLObjectElement(element));
  • trunk/Source/WebCore/html/HTMLObjectElement.cpp

    r161195 r161196  
    462462        return true;
    463463
    464     for (auto& child : elementChildren(*this)) {
     464    for (auto& child : childrenOfType<Element>(*this)) {
    465465        if (child.hasTagName(paramTag) && equalIgnoringCase(child.getNameAttribute(), "type")
    466466            && MIMETypeRegistry::isJavaAppletMIMEType(child.getAttribute(valueAttr).string()))
  • trunk/Source/WebCore/loader/PlaceholderDocument.cpp

    r161127 r161196  
    3535    ASSERT(!renderView());
    3636
    37     for (auto& child : elementChildren(*this))
     37    for (auto& child : childrenOfType<Element>(*this))
    3838        Style::attachRenderTree(child);
    3939}
  • trunk/Source/WebCore/rendering/RenderChildIterator.h

    r158551 r161196  
    7373};
    7474
    75 RenderChildIteratorAdapter<RenderObject> elementChildren(RenderElement&);
    76 RenderChildConstIteratorAdapter<RenderObject> elementChildren(const RenderElement&);
    7775template <typename T> RenderChildIteratorAdapter<T> childrenOfType(RenderElement&);
    7876template <typename T> RenderChildConstIteratorAdapter<T> childrenOfType(const RenderElement&);
  • trunk/Source/WebCore/svg/SVGSVGElement.cpp

    r161181 r161196  
    776776    // Fall back to traversing our subtree. Duplicate ids are allowed, the first found will
    777777    // be returned.
    778     for (auto& element : elementDescendants(*this)) {
     778    for (auto& element : descendantsOfType<Element>(*this)) {
    779779        if (element.getIdAttribute() == id)
    780780            return &element;
  • trunk/Source/WebCore/svg/SVGUseElement.cpp

    r161181 r161196  
    366366static bool subtreeContainsDisallowedElement(SVGElement& start)
    367367{
    368     for (auto& element : elementDescendants(start)) {
     368    for (auto& element : descendantsOfType<Element>(start)) {
    369369        if (isDisallowedElement(element))
    370370            return true;
     
    659659    ASSERT(!subtree.inDocument());
    660660    Vector<Element*> toRemove;
    661     auto it = elementDescendants(subtree).begin();
    662     auto end = elementDescendants(subtree).end();
     661    auto it = descendantsOfType<Element>(subtree).begin();
     662    auto end = descendantsOfType<Element>(subtree).end();
    663663    while (it != end) {
    664664        if (isDisallowedElement(*it)) {
Note: See TracChangeset for help on using the changeset viewer.