Changeset 156612 in webkit
- Timestamp:
- Sep 28, 2013, 1:20:56 PM (12 years ago)
- Location:
- trunk/Source/WebCore
- Files:
-
- 12 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/Source/WebCore/ChangeLog
r156611 r156612 1 2013-09-28 Antti Koivisto <antti@apple.com> 2 3 Add first()/last() to ElementIteratorAdapters 4 https://bugs.webkit.org/show_bug.cgi?id=122067 5 6 Reviewed by Darin Adler. 7 8 Add a convenient way for getting the first and last element if it exists. 9 10 Use it in some places. 11 12 * accessibility/AccessibilityNodeObject.cpp: 13 (WebCore::AccessibilityNodeObject::canvasHasFallbackContent): 14 * css/CSSFontFaceSource.cpp: 15 (WebCore::CSSFontFaceSource::getFontData): 16 * dom/Document.cpp: 17 (WebCore::Document::childrenChanged): 18 (WebCore::Document::removeTitle): 19 * dom/ElementChildIterator.h: 20 (WebCore::::first): 21 (WebCore::::last): 22 * dom/ElementDescendantIterator.h: 23 (WebCore::::first): 24 (WebCore::::last): 25 * html/HTMLFieldSetElement.cpp: 26 (WebCore::HTMLFieldSetElement::legend): 27 * html/HTMLLegendElement.cpp: 28 (WebCore::HTMLLegendElement::associatedControl): 29 * html/HTMLMediaElement.cpp: 30 (WebCore::HTMLMediaElement::finishParsingChildren): 31 (WebCore::HTMLMediaElement::selectMediaResource): 32 * svg/SVGElement.cpp: 33 (WebCore::SVGElement::title): 34 * svg/SVGFontFaceElement.cpp: 35 (WebCore::SVGFontFaceElement::rebuildFontFace): 36 * svg/graphics/SVGImage.cpp: 37 (WebCore::SVGImage::hasSingleSecurityOrigin): 38 1 39 2013-09-28 Mark Rowe <mrowe@apple.com> 2 40 -
trunk/Source/WebCore/accessibility/AccessibilityNodeObject.cpp
r156532 r156612 424 424 // content. If it has no children or its only children are not elements 425 425 // (e.g. just text nodes), it doesn't have fallback content. 426 return elementChildren(canvasElement). begin() != elementChildren(canvasElement).end();426 return elementChildren(canvasElement).first(); 427 427 } 428 428 -
trunk/Source/WebCore/css/CSSFontFaceSource.cpp
r155729 r156612 140 140 return 0; 141 141 142 auto fontFaceChildren = childrenOfType<SVGFontFaceElement>(m_externalSVGFontElement.get()); 143 auto firstFontFace = fontFaceChildren.begin(); 144 if (firstFontFace != fontFaceChildren.end()) { 142 if (auto firstFontFace = childrenOfType<SVGFontFaceElement>(m_externalSVGFontElement.get()).first()) { 145 143 if (!m_svgFontFaceElement) { 146 144 // We're created using a CSS @font-face rule, that means we're not associated with a SVGFontFaceElement. 147 145 // Use the imported <font-face> tag as referencing font-face element for these cases. 148 m_svgFontFaceElement = &*firstFontFace;146 m_svgFontFaceElement = firstFontFace; 149 147 } 150 148 151 fontData = SimpleFontData::create(SVGFontData::create( &*firstFontFace), fontDescription.computedPixelSize(), syntheticBold, syntheticItalic);149 fontData = SimpleFontData::create(SVGFontData::create(firstFontFace), fontDescription.computedPixelSize(), syntheticBold, syntheticItalic); 152 150 } 153 151 } else -
trunk/Source/WebCore/dom/Document.cpp
r156609 r156612 795 795 #endif 796 796 797 Element* newDocumentElement = 0; 798 auto firstElementChild = elementChildren(this).begin(); 799 if (firstElementChild != elementChildren(this).end()) 800 newDocumentElement = &*firstElementChild; 797 Element* newDocumentElement = elementChildren(this).first(); 801 798 802 799 if (newDocumentElement == m_documentElement) … … 1587 1584 // Update title based on first title element in the head, if one exists. 1588 1585 if (HTMLElement* headElement = head()) { 1589 auto firstTitle = childrenOfType<HTMLTitleElement>(headElement).begin(); 1590 if (firstTitle != childrenOfType<HTMLTitleElement>(headElement).end()) 1591 setTitleElement(firstTitle->textWithDirection(), &*firstTitle); 1586 if (auto firstTitle = childrenOfType<HTMLTitleElement>(headElement).first()) 1587 setTitleElement(firstTitle->textWithDirection(), firstTitle); 1592 1588 } 1593 1589 -
trunk/Source/WebCore/dom/ElementChildIterator.h
r154928 r156612 53 53 ElementChildIterator<ElementType> begin(); 54 54 ElementChildIterator<ElementType> end(); 55 ElementType* first(); 56 ElementType* last(); 55 57 56 58 private: … … 64 66 ElementChildConstIterator<ElementType> begin() const; 65 67 ElementChildConstIterator<ElementType> end() const; 68 const ElementType* first() const; 69 const ElementType* last() const; 66 70 67 71 private: … … 134 138 } 135 139 140 template <typename ElementType> 141 inline ElementType* ElementChildIteratorAdapter<ElementType>::first() 142 { 143 return Traversal<ElementType>::firstChild(m_root); 144 } 145 146 template <typename ElementType> 147 inline ElementType* ElementChildIteratorAdapter<ElementType>::last() 148 { 149 return Traversal<ElementType>::lastChild(m_root); 150 } 151 136 152 // ElementChildConstIteratorAdapter 137 153 … … 154 170 } 155 171 172 template <typename ElementType> 173 inline const ElementType* ElementChildConstIteratorAdapter<ElementType>::first() const 174 { 175 return Traversal<ElementType>::firstChild(m_root); 176 } 177 178 template <typename ElementType> 179 inline const ElementType* ElementChildConstIteratorAdapter<ElementType>::last() const 180 { 181 return Traversal<ElementType>::lastChild(m_root); 182 } 183 156 184 // Standalone functions 157 185 -
trunk/Source/WebCore/dom/ElementDescendantIterator.h
r154928 r156612 53 53 ElementDescendantIterator<ElementType> begin(); 54 54 ElementDescendantIterator<ElementType> end(); 55 ElementType* first(); 56 ElementType* last(); 55 57 56 58 private: … … 64 66 ElementDescendantConstIterator<ElementType> begin() const; 65 67 ElementDescendantConstIterator<ElementType> end() const; 68 const ElementType* first() const; 69 const ElementType* last() const; 66 70 67 71 private: … … 135 139 } 136 140 141 template <typename ElementType> 142 inline ElementType* ElementDescendantIteratorAdapter<ElementType>::first() 143 { 144 return Traversal<ElementType>::firstWithin(m_root); 145 } 146 147 template <typename ElementType> 148 inline ElementType* ElementDescendantIteratorAdapter<ElementType>::last() 149 { 150 return Traversal<ElementType>::lastWithin(m_root); 151 } 152 137 153 // ElementDescendantConstIteratorAdapter 138 154 … … 155 171 } 156 172 173 template <typename ElementType> 174 inline const ElementType* ElementDescendantConstIteratorAdapter<ElementType>::first() const 175 { 176 return Traversal<ElementType>::firstWithin(m_root); 177 } 178 179 template <typename ElementType> 180 inline const ElementType* ElementDescendantConstIteratorAdapter<ElementType>::last() const 181 { 182 return Traversal<ElementType>::lastWithin(m_root); 183 } 184 157 185 // Standalone functions 158 186 -
trunk/Source/WebCore/html/HTMLFieldSetElement.cpp
r156147 r156612 91 91 const HTMLLegendElement* HTMLFieldSetElement::legend() const 92 92 { 93 auto legendDescendants = descendantsOfType<HTMLLegendElement>(this); 94 auto firstLegend = legendDescendants.begin(); 95 if (firstLegend != legendDescendants.end()) 96 return &*firstLegend; 97 return nullptr; 93 return descendantsOfType<HTMLLegendElement>(this).first(); 98 94 } 99 95 -
trunk/Source/WebCore/html/HTMLLegendElement.cpp
r155795 r156612 57 57 // Find first form element inside the fieldset that is not a legend element. 58 58 // FIXME: Should we consider tabindex? 59 auto fieldsetFormControlDescendants = descendantsOfType<HTMLFormControlElement>(&*enclosingFieldset); 60 auto firstFormControl = fieldsetFormControlDescendants.begin(); 61 return firstFormControl != fieldsetFormControlDescendants.end() ? &*firstFormControl : nullptr; 59 return descendantsOfType<HTMLFormControlElement>(&*enclosingFieldset).first(); 62 60 } 63 61 -
trunk/Source/WebCore/html/HTMLMediaElement.cpp
r156550 r156612 549 549 return; 550 550 551 auto trackDescendants = descendantsOfType<HTMLTrackElement>(this); 552 if (trackDescendants.begin() != trackDescendants.end()) 551 if (descendantsOfType<HTMLTrackElement>(this).first()) 553 552 scheduleDelayedAction(ConfigureTextTracks); 554 553 #endif … … 940 939 // element child, then let mode be children and let candidate be the first such 941 940 // source element child in tree order. 942 auto source = childrenOfType<HTMLSourceElement>(this).begin(); 943 if (source != childrenOfType<HTMLSourceElement>(this).end()) { 941 if (auto firstSource = childrenOfType<HTMLSourceElement>(this).first()) { 944 942 mode = children; 945 m_nextChildNodeToConsider = &*source;943 m_nextChildNodeToConsider = firstSource; 946 944 m_currentSourceNode = 0; 947 945 } else { -
trunk/Source/WebCore/svg/SVGElement.cpp
r156231 r156612 954 954 // If we aren't an instance in a <use> or the <use> title was not found, then find the first 955 955 // <title> child of this element. 956 // If a title child was found, return the text contents. 957 auto titleDescendants = descendantsOfType<SVGTitleElement>(this); 958 auto firstTitle = titleDescendants.begin(); 959 if (firstTitle != titleDescendants.end()) 960 return const_cast<SVGTitleElement&>(*firstTitle).innerText(); 961 962 // Otherwise return a null/empty string. 963 return String(); 956 auto firstTitle = descendantsOfType<SVGTitleElement>(this).first(); 957 return firstTitle ? const_cast<SVGTitleElement*>(firstTitle)->innerText() : String(); 964 958 } 965 959 -
trunk/Source/WebCore/svg/SVGFontFaceElement.cpp
r155815 r156612 229 229 230 230 // we currently ignore all but the first src element, alternatively we could concat them 231 SVGFontFaceSrcElement* srcElement = 0; 232 auto firstFontFaceSrcElementChild = childrenOfType<SVGFontFaceSrcElement>(this).begin(); 233 if (firstFontFaceSrcElementChild != childrenOfType<SVGFontFaceSrcElement>(this).end()) 234 srcElement = &*firstFontFaceSrcElementChild; 231 auto srcElement = childrenOfType<SVGFontFaceSrcElement>(this).first(); 235 232 236 233 bool describesParentFont = isSVGFontElement(parentNode()); -
trunk/Source/WebCore/svg/graphics/SVGImage.cpp
r156550 r156612 76 76 77 77 // Don't allow foreignObject elements since they can leak information with arbitrary HTML (like spellcheck or control theme). 78 auto foreignObjectDescendants = descendantsOfType<SVGForeignObjectElement>(rootElement); 79 if (foreignObjectDescendants.begin() != foreignObjectDescendants.end()) 78 if (descendantsOfType<SVGForeignObjectElement>(rootElement).first()) 80 79 return false; 81 80
Note:
See TracChangeset
for help on using the changeset viewer.