Changeset 161196 in webkit
- Timestamp:
- Jan 1, 2014, 1:48:13 PM (11 years ago)
- Location:
- trunk/Source/WebCore
- Files:
-
- 19 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/Source/WebCore/ChangeLog
r161195 r161196 1 2014-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 1 53 2014-01-01 Antti Koivisto <antti@apple.com> 2 54 -
trunk/Source/WebCore/accessibility/AccessibilityNodeObject.cpp
r160966 r161196 440 440 // content. If it has no children or its only children are not elements 441 441 // (e.g. just text nodes), it doesn't have fallback content. 442 return elementChildren(canvasElement).first();442 return childrenOfType<Element>(canvasElement).first(); 443 443 } 444 444 … … 1184 1184 return nullptr; 1185 1185 1186 for (auto& sibling : elementChildren(*parent)) {1186 for (auto& sibling : childrenOfType<Element>(*parent)) { 1187 1187 const AtomicString& siblingAriaRole = sibling.fastGetAttribute(roleAttr); 1188 1188 if (equalIgnoringCase(siblingAriaRole, role)) -
trunk/Source/WebCore/accessibility/AccessibilityTable.cpp
r160966 r161196 125 125 126 126 // 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)) { 128 128 if (child.hasTagName(colTag) || child.hasTagName(colgroupTag)) 129 129 return true; -
trunk/Source/WebCore/css/StyleInvalidationAnalysis.cpp
r157924 r161196 119 119 return; 120 120 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(); 123 123 while (it != end) { 124 124 if (elementMatchesSelectorScopes(*it, m_idScopes, m_classScopes)) { -
trunk/Source/WebCore/dom/ChildNodeList.cpp
r160598 r161196 95 95 return nullptr; 96 96 } 97 for (auto& element : elementChildren(m_parent.get())) {97 for (auto& element : childrenOfType<Element>(m_parent.get())) { 98 98 if (element.hasID() && element.idForStyleResolution() == name) 99 99 return const_cast<Element*>(&element); -
trunk/Source/WebCore/dom/Document.cpp
r161153 r161196 687 687 ASSERT(scope); 688 688 ContainerNode* rootNode = scope->rootNode(); 689 for (auto& element : elementDescendants(*rootNode)) {689 for (auto& element : descendantsOfType<Element>(*rootNode)) { 690 690 const AtomicString& accessKey = element.fastGetAttribute(accesskeyAttr); 691 691 if (!accessKey.isEmpty()) … … 807 807 #endif 808 808 809 Element* newDocumentElement = elementChildren(*this).first();809 Element* newDocumentElement = childrenOfType<Element>(*this).first(); 810 810 811 811 if (newDocumentElement == m_documentElement) -
trunk/Source/WebCore/dom/Element.cpp
r161181 r161196 2931 2931 return; 2932 2932 elementRareData()->resetComputedStyle(); 2933 for (auto& child : elementDescendants(*this)) {2933 for (auto& child : descendantsOfType<Element>(*this)) { 2934 2934 if (child.hasRareData()) 2935 2935 child.elementRareData()->resetComputedStyle(); -
trunk/Source/WebCore/dom/ElementChildIterator.h
r157924 r161196 73 73 }; 74 74 75 ElementChildIteratorAdapter<Element> elementChildren(ContainerNode&);76 ElementChildConstIteratorAdapter<Element> elementChildren(const ContainerNode&);77 75 template <typename ElementType> ElementChildIteratorAdapter<ElementType> childrenOfType(ContainerNode&); 78 76 template <typename ElementType> ElementChildConstIteratorAdapter<ElementType> childrenOfType(const ContainerNode&); … … 184 182 // Standalone functions 185 183 186 inline ElementChildIteratorAdapter<Element> elementChildren(ContainerNode& parent)187 {188 return ElementChildIteratorAdapter<Element>(parent);189 }190 191 184 template <typename ElementType> 192 185 inline ElementChildIteratorAdapter<ElementType> childrenOfType(ContainerNode& parent) 193 186 { 194 187 return ElementChildIteratorAdapter<ElementType>(parent); 195 }196 197 inline ElementChildConstIteratorAdapter<Element> elementChildren(const ContainerNode& parent)198 {199 return ElementChildConstIteratorAdapter<Element>(parent);200 188 } 201 189 -
trunk/Source/WebCore/dom/ElementDescendantIterator.h
r158530 r161196 79 79 }; 80 80 81 ElementDescendantIteratorAdapter<Element> elementDescendants(ContainerNode&);82 ElementDescendantConstIteratorAdapter<Element> elementDescendants(const ContainerNode&);83 81 template <typename ElementType> ElementDescendantIteratorAdapter<ElementType> descendantsOfType(ContainerNode&); 84 82 template <typename ElementType> ElementDescendantConstIteratorAdapter<ElementType> descendantsOfType(const ContainerNode&); … … 231 229 // Standalone functions 232 230 233 inline ElementDescendantIteratorAdapter<Element> elementDescendants(ContainerNode& root)234 {235 return ElementDescendantIteratorAdapter<Element>(root);236 }237 238 231 template <typename ElementType> 239 232 inline ElementDescendantIteratorAdapter<ElementType> descendantsOfType(ContainerNode& root) … … 242 235 } 243 236 244 inline ElementDescendantConstIteratorAdapter<Element> elementDescendants(const ContainerNode& root)245 {246 return ElementDescendantConstIteratorAdapter<Element>(root);247 }248 249 237 template <typename ElementType> 250 238 inline ElementDescendantConstIteratorAdapter<ElementType> descendantsOfType(const ContainerNode& root) -
trunk/Source/WebCore/dom/SelectorQuery.cpp
r160598 r161196 166 166 static inline void elementsForLocalName(const ContainerNode& rootNode, const AtomicString& localName, typename SelectorQueryTrait::OutputType& output) 167 167 { 168 for (auto& element : elementDescendants(const_cast<ContainerNode&>(rootNode))) {168 for (auto& element : descendantsOfType<Element>(const_cast<ContainerNode&>(rootNode))) { 169 169 if (element.tagQName().localName() == localName) { 170 170 SelectorQueryTrait::appendOutputForElement(output, &element); … … 178 178 static inline void anyElement(const ContainerNode& rootNode, typename SelectorQueryTrait::OutputType& output) 179 179 { 180 for (auto& element : elementDescendants(const_cast<ContainerNode&>(rootNode))) {180 for (auto& element : descendantsOfType<Element>(const_cast<ContainerNode&>(rootNode))) { 181 181 SelectorQueryTrait::appendOutputForElement(output, &element); 182 182 if (SelectorQueryTrait::shouldOnlyMatchFirstElement) … … 206 206 } else { 207 207 // 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))) { 209 209 if (element.namespaceURI() == selectorNamespaceURI && (selectorLocalName == starAtom || element.tagQName().localName() == selectorLocalName)) { 210 210 SelectorQueryTrait::appendOutputForElement(output, &element); … … 228 228 229 229 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))) { 231 231 if (element.hasClass() && element.classNames().contains(className)) { 232 232 SelectorQueryTrait::appendOutputForElement(output, &element); … … 242 242 ASSERT(m_selectors.size() == 1); 243 243 244 for (auto& element : elementDescendants(const_cast<ContainerNode&>(rootNode))) {244 for (auto& element : descendantsOfType<Element>(const_cast<ContainerNode&>(rootNode))) { 245 245 if (selectorMatches(selectorData, element, rootNode)) { 246 246 SelectorQueryTrait::appendOutputForElement(output, &element); … … 255 255 { 256 256 unsigned selectorCount = m_selectors.size(); 257 for (auto& element : elementDescendants(const_cast<ContainerNode&>(rootNode))) {257 for (auto& element : descendantsOfType<Element>(const_cast<ContainerNode&>(rootNode))) { 258 258 for (unsigned i = 0; i < selectorCount; ++i) { 259 259 if (selectorMatches(m_selectors[i], element, rootNode)) { -
trunk/Source/WebCore/editing/ApplyStyleCommand.cpp
r160966 r161196 440 440 441 441 Vector<Element*> toRemove; 442 for (auto& child : elementChildren(*dummySpanAncestor)) {442 for (auto& child : childrenOfType<Element>(*dummySpanAncestor)) { 443 443 if (isSpanWithoutAttributesOrUnstyledStyleSpan(&child)) 444 444 toRemove.append(&child); -
trunk/Source/WebCore/editing/ReplaceSelectionCommand.cpp
r161050 r161196 707 707 Vector<Element*> toRemove; 708 708 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(); 711 711 while (it != end) { 712 712 if (it->hasTagName(baseTag) || it->hasTagName(linkTag) || it->hasTagName(metaTag) || it->hasTagName(styleTag) || isHTMLTitleElement(*it)) { -
trunk/Source/WebCore/editing/markup.cpp
r160598 r161196 100 100 URL parsedBaseURL(ParsedURLString, baseURL); 101 101 102 for (auto& element : elementDescendants(*fragment)) {102 for (auto& element : descendantsOfType<Element>(*fragment)) { 103 103 if (!element.hasAttributes()) 104 104 continue; -
trunk/Source/WebCore/html/HTMLFieldSetElement.cpp
r161181 r161196 107 107 m_associatedElements.clear(); 108 108 109 for (auto& element : elementDescendants(const_cast<HTMLFieldSetElement&>(*this))) {109 for (auto& element : descendantsOfType<Element>(const_cast<HTMLFieldSetElement&>(*this))) { 110 110 if (element.hasTagName(objectTag)) 111 111 m_associatedElements.append(&toHTMLObjectElement(element)); -
trunk/Source/WebCore/html/HTMLObjectElement.cpp
r161195 r161196 462 462 return true; 463 463 464 for (auto& child : elementChildren(*this)) {464 for (auto& child : childrenOfType<Element>(*this)) { 465 465 if (child.hasTagName(paramTag) && equalIgnoringCase(child.getNameAttribute(), "type") 466 466 && MIMETypeRegistry::isJavaAppletMIMEType(child.getAttribute(valueAttr).string())) -
trunk/Source/WebCore/loader/PlaceholderDocument.cpp
r161127 r161196 35 35 ASSERT(!renderView()); 36 36 37 for (auto& child : elementChildren(*this))37 for (auto& child : childrenOfType<Element>(*this)) 38 38 Style::attachRenderTree(child); 39 39 } -
trunk/Source/WebCore/rendering/RenderChildIterator.h
r158551 r161196 73 73 }; 74 74 75 RenderChildIteratorAdapter<RenderObject> elementChildren(RenderElement&);76 RenderChildConstIteratorAdapter<RenderObject> elementChildren(const RenderElement&);77 75 template <typename T> RenderChildIteratorAdapter<T> childrenOfType(RenderElement&); 78 76 template <typename T> RenderChildConstIteratorAdapter<T> childrenOfType(const RenderElement&); -
trunk/Source/WebCore/svg/SVGSVGElement.cpp
r161181 r161196 776 776 // Fall back to traversing our subtree. Duplicate ids are allowed, the first found will 777 777 // be returned. 778 for (auto& element : elementDescendants(*this)) {778 for (auto& element : descendantsOfType<Element>(*this)) { 779 779 if (element.getIdAttribute() == id) 780 780 return &element; -
trunk/Source/WebCore/svg/SVGUseElement.cpp
r161181 r161196 366 366 static bool subtreeContainsDisallowedElement(SVGElement& start) 367 367 { 368 for (auto& element : elementDescendants(start)) {368 for (auto& element : descendantsOfType<Element>(start)) { 369 369 if (isDisallowedElement(element)) 370 370 return true; … … 659 659 ASSERT(!subtree.inDocument()); 660 660 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(); 663 663 while (it != end) { 664 664 if (isDisallowedElement(*it)) {
Note:
See TracChangeset
for help on using the changeset viewer.