Changeset 203439 in webkit
- Timestamp:
- Jul 19, 2016, 6:29:25 PM (10 years ago)
- Location:
- trunk
- Files:
-
- 4 added
- 3 edited
-
LayoutTests/ChangeLog (modified) (1 diff)
-
LayoutTests/fast/selectors/id-attribute-querySelector-used-as-id-selector-expected.txt (added)
-
LayoutTests/fast/selectors/id-attribute-querySelector-used-as-id-selector-quirks-expected.txt (added)
-
LayoutTests/fast/selectors/id-attribute-querySelector-used-as-id-selector-quirks.html (added)
-
LayoutTests/fast/selectors/id-attribute-querySelector-used-as-id-selector.html (added)
-
Source/WebCore/ChangeLog (modified) (1 diff)
-
Source/WebCore/dom/SelectorQuery.cpp (modified) (7 diffs)
Legend:
- Unmodified
- Added
- Removed
-
trunk/LayoutTests/ChangeLog
r203438 r203439 1 2016-07-19 Benjamin Poulain <bpoulain@apple.com> 2 3 Use getElementById for attribute matching if the attribute name is html's id 4 https://bugs.webkit.org/show_bug.cgi?id=159960 5 6 Reviewed by Chris Dumez. 7 8 * fast/selectors/id-attribute-querySelector-used-as-id-selector-expected.txt: Added. 9 * fast/selectors/id-attribute-querySelector-used-as-id-selector-quirks-expected.txt: Added. 10 * fast/selectors/id-attribute-querySelector-used-as-id-selector-quirks.html: Added. 11 * fast/selectors/id-attribute-querySelector-used-as-id-selector.html: Added. 12 1 13 2016-07-19 Chris Dumez <cdumez@apple.com> 2 14 -
trunk/Source/WebCore/ChangeLog
r203438 r203439 1 2016-07-19 Benjamin Poulain <bpoulain@apple.com> 2 3 Use getElementById for attribute matching if the attribute name is html's id 4 https://bugs.webkit.org/show_bug.cgi?id=159960 5 6 Reviewed by Chris Dumez. 7 8 Elliott Sprehn discovered YUI makes heavy uses of querySelector with [id=value] 9 (https://bugs.chromium.org/p/chromium/issues/detail?id=627242). 10 11 If we are not in quirks mode, IdForStyleResolution has the same value 12 as the Id attribute. We can use the same optimization for both cases. 13 14 Tests: fast/selectors/id-attribute-querySelector-used-as-id-selector-quirks.html 15 fast/selectors/id-attribute-querySelector-used-as-id-selector.html 16 17 * dom/SelectorQuery.cpp: 18 (WebCore::canBeUsedForIdFastPath): 19 (WebCore::findIdMatchingType): 20 (WebCore::SelectorDataList::SelectorDataList): 21 (WebCore::selectorForIdLookup): 22 (WebCore::filterRootById): 23 1 24 2016-07-19 Chris Dumez <cdumez@apple.com> 2 25 -
trunk/Source/WebCore/dom/SelectorQuery.cpp
r203301 r203439 1 1 /* 2 * Copyright (C) 2011, 2013, 2014 Apple Inc. All rights reserved.2 * Copyright (C) 2011, 2013, 2014, 2016 Apple Inc. All rights reserved. 3 3 * Copyright (C) 2014 Yusuke Suzuki <utatane.tea@gmail.com> 4 4 * … … 30 30 #include "CSSParser.h" 31 31 #include "ElementDescendantIterator.h" 32 #include "HTMLNames.h" 32 33 #include "SelectorChecker.h" 33 34 #include "StaticNodeList.h" … … 54 55 }; 55 56 57 static bool canBeUsedForIdFastPath(const CSSSelector& selector) 58 { 59 return selector.match() == CSSSelector::Id 60 || (selector.match() == CSSSelector::Exact && selector.attribute() == HTMLNames::idAttr && !selector.attributeValueMatchingIsCaseInsensitive()); 61 } 62 56 63 static IdMatchingType findIdMatchingType(const CSSSelector& firstSelector) 57 64 { 58 65 bool inRightmost = true; 59 66 for (const CSSSelector* selector = &firstSelector; selector; selector = selector->tagHistory()) { 60 if ( selector->match() == CSSSelector::Id) {67 if (canBeUsedForIdFastPath(*selector)) { 61 68 if (inRightmost) 62 69 return IdMatchingType::Rightmost; … … 89 96 m_matchType = ClassNameMatch; 90 97 break; 91 case CSSSelector::Id:92 m_matchType = RightMostWithIdMatch;93 break;94 98 default: 95 m_matchType = CompilableSingle; 99 if (canBeUsedForIdFastPath(selector)) 100 m_matchType = RightMostWithIdMatch; 101 else 102 m_matchType = CompilableSingle; 96 103 break; 97 104 } … … 195 202 196 203 for (const CSSSelector* selector = &firstSelector; selector; selector = selector->tagHistory()) { 197 if ( selector->match() == CSSSelector::Id)204 if (canBeUsedForIdFastPath(*selector)) 198 205 return selector; 199 206 if (selector->relation() != CSSSelector::SubSelector) … … 248 255 const CSSSelector* selector = &firstSelector; 249 256 do { 250 ASSERT( selector->match() != CSSSelector::Id);257 ASSERT(!canBeUsedForIdFastPath(*selector)); 251 258 if (selector->relation() != CSSSelector::SubSelector) 252 259 break; … … 256 263 bool inAdjacentChain = false; 257 264 for (; selector; selector = selector->tagHistory()) { 258 if ( selector->match() == CSSSelector::Id) {265 if (canBeUsedForIdFastPath(*selector)) { 259 266 const AtomicString& idToMatch = selector->value(); 260 267 if (ContainerNode* searchRoot = rootNode.treeScope().getElementById(idToMatch)) {
Note:
See TracChangeset
for help on using the changeset viewer.