Changeset 175788 in webkit
- Timestamp:
- Nov 8, 2014, 9:59:52 PM (11 years ago)
- Location:
- trunk/Source/WebCore
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/Source/WebCore/ChangeLog
r175787 r175788 1 2014-11-08 Chris Dumez <cdumez@apple.com> 2 3 Call faster HTMLElement::hasTagName() in HTMLCollection 4 https://bugs.webkit.org/show_bug.cgi?id=138529 5 6 Reviewed by Darin Adler. 7 8 Call faster HTMLElement::hasTagName() in HTMLCollection instead of 9 slower Node::hasTagName() by restructuring the code a bit to 10 distinguish collection that deal only with HTMLElements from others. 11 12 No new tests, no behavior change. 13 14 * html/HTMLCollection.cpp: 15 (WebCore::isMatchingHTMLElement): 16 (WebCore::isMatchingElement): 17 1 18 2014-11-08 Chris Dumez <cdumez@apple.com> 2 19 -
trunk/Source/WebCore/html/HTMLCollection.cpp
r174225 r175788 170 170 } 171 171 172 inline bool isMatchingElement(const HTMLCollection& htmlCollection, Element& element) 173 { 174 CollectionType type = htmlCollection.type(); 175 if (!element.isHTMLElement() && !(type == DocAll || type == NodeChildren || type == WindowNamedItems)) 176 return false; 177 178 switch (type) { 172 inline bool isMatchingHTMLElement(const HTMLCollection& collection, HTMLElement& element) 173 { 174 switch (collection.type()) { 179 175 case DocImages: 180 176 return element.hasTagName(imgTag); … … 210 206 case DocAnchors: 211 207 return element.hasTagName(aTag) && element.fastHasAttribute(nameAttr); 208 case DocumentNamedItems: 209 return static_cast<const DocumentNameCollection&>(collection).elementMatches(element); 210 case DocAll: 211 case NodeChildren: 212 case WindowNamedItems: 213 case FormControls: 214 case TableRows: 215 break; 216 } 217 ASSERT_NOT_REACHED(); 218 return false; 219 } 220 221 inline bool isMatchingElement(const HTMLCollection& collection, Element& element) 222 { 223 // Collection types that deal with any type of Elements, not just HTMLElements. 224 switch (collection.type()) { 212 225 case DocAll: 213 226 case NodeChildren: 214 227 return true; 215 case DocumentNamedItems:216 return static_cast<const DocumentNameCollection&>(htmlCollection).elementMatches(element);217 228 case WindowNamedItems: 218 return static_cast<const WindowNameCollection&>(htmlCollection).elementMatches(element); 219 case FormControls: 220 case TableRows: 221 break; 222 } 223 ASSERT_NOT_REACHED(); 224 return false; 229 return static_cast<const WindowNameCollection&>(collection).elementMatches(element); 230 default: 231 // Collection types that only deal with HTMLElements. 232 return is<HTMLElement>(element) && isMatchingHTMLElement(collection, downcast<HTMLElement>(element)); 233 } 225 234 } 226 235
Note:
See TracChangeset
for help on using the changeset viewer.