Changeset 115971 in webkit
- Timestamp:
- May 3, 2012 7:45:12 AM (12 years ago)
- Location:
- trunk
- Files:
-
- 2 added
- 7 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/LayoutTests/ChangeLog
r115968 r115971 1 2012-05-03 Arpita Bahuguna <arpitabahuguna@gmail.com> 2 3 Broken handling of pseudo-elements in selectors API 4 https://bugs.webkit.org/show_bug.cgi?id=83446 5 6 Reviewed by Antti Koivisto. 7 8 * fast/dom/Window/querySelectorAll-with-pseudo-elements-expected.txt: Added. 9 * fast/dom/Window/querySelectorAll-with-pseudo-elements.html: Added. 10 New layout testcase added for verifying that the querySelectorAll() API returns zero 11 when querying for pseudo-elements selectors; as per the specification. 12 1 13 2012-05-03 Sudarsana Nagineni <sudarsana.nagineni@linux.intel.com> 2 14 -
trunk/Source/WebCore/ChangeLog
r115969 r115971 1 2012-05-03 Arpita Bahuguna <arpitabahuguna@gmail.com> 2 3 Broken handling of pseudo-elements in selectors API 4 https://bugs.webkit.org/show_bug.cgi?id=83446 5 6 Reviewed by Antti Koivisto. 7 8 Test: fast/dom/Window/querySelectorAll-with-pseudo-elements.html 9 10 * css/SelectorChecker.cpp: 11 (WebCore::SelectorChecker::SelectorChecker): 12 Setting the default value for the enum member m_mode to ResolvingStyle. 13 14 (WebCore::SelectorChecker::checkSelector): 15 Instead of verifying against the bool m_isCollectingRulesOnly, we now check whether or not 16 m_mode is set to ResolvingStyle. 17 18 (WebCore::SelectorChecker::checkOneSelector): 19 Instead of verifying against the bool m_isCollectingRulesOnly, we now check whether or not 20 m_mode is set to ResolvingStyle. Also, for the pseudo-elements case we check if its 21 value is set to QueryingRules in which case we return false. 22 23 * css/SelectorChecker.h: 24 (WebCore::SelectorChecker::mode): 25 Returns the mode (m_mode) value. 26 27 (WebCore::SelectorChecker::setMode): 28 Sets the mode (m_mode) to the passed enum value. 29 30 * css/StyleResolver.cpp: 31 (WebCore::StyleResolver::sortAndTransferMatchedRules): 32 (WebCore::StyleResolver::collectMatchingRulesForList): 33 Retrieves SelectorChecker's mode value. 34 35 * dom/SelectorQuery.cpp: 36 (WebCore::SelectorQuery::SelectorQuery): 37 Sets SelectorChecker's mode to QueryingRules. 38 39 * html/shadow/ContentSelectorQuery.cpp: 40 (WebCore::ContentSelectorQuery::ContentSelectorQuery): 41 Sets SelectorChecker's mode to CollectingRules. 42 1 43 2012-05-03 Pavel Feldman <pfeldman@chromium.org> 2 44 -
trunk/Source/WebCore/css/SelectorChecker.cpp
r111659 r115971 70 70 , m_strictParsing(strictParsing) 71 71 , m_documentIsHTML(document->isHTMLDocument()) 72 , m_ isCollectingRulesOnly(false)72 , m_mode(ResolvingStyle) 73 73 , m_pseudoStyle(NOPSEUDO) 74 74 , m_hasUnknownPseudoElements(false) … … 493 493 494 494 case CSSSelector::DirectAdjacent: 495 if ( !m_isCollectingRulesOnly&& context.element->parentElement()) {495 if (m_mode == ResolvingStyle && context.element->parentElement()) { 496 496 RenderStyle* parentStyle = context.elementStyle ? context.elementParentStyle : context.element->parentNode()->renderStyle(); 497 497 if (parentStyle) … … 507 507 508 508 case CSSSelector::IndirectAdjacent: 509 if ( !m_isCollectingRulesOnly&& context.element->parentElement()) {509 if (m_mode == ResolvingStyle && context.element->parentElement()) { 510 510 RenderStyle* parentStyle = context.elementStyle ? context.elementParentStyle : context.element->parentNode()->renderStyle(); 511 511 if (parentStyle) … … 527 527 // We make an exception for scrollbar pseudo elements and allow a set of pseudo classes (but nothing else) 528 528 // to follow the pseudo elements. 529 if ((context.elementStyle || m_ isCollectingRulesOnly) && dynamicPseudo != NOPSEUDO && dynamicPseudo != SELECTION529 if ((context.elementStyle || m_mode == CollectingRules || m_mode == QueryingRules) && dynamicPseudo != NOPSEUDO && dynamicPseudo != SELECTION 530 530 && !((RenderScrollbar::scrollbarForStyleResolve() || dynamicPseudo == SCROLLBAR_CORNER || dynamicPseudo == RESIZER) && nextContext.selector->m_match == CSSSelector::PseudoClass)) 531 531 return SelectorFailsCompletely; … … 774 774 } 775 775 } 776 if ( !m_isCollectingRulesOnly) {776 if (m_mode == ResolvingStyle) { 777 777 if (context.elementStyle) 778 778 context.elementStyle->setEmptyState(result); … … 788 788 if (!element->previousElementSibling()) 789 789 result = true; 790 if ( !m_isCollectingRulesOnly) {790 if (m_mode == ResolvingStyle) { 791 791 RenderStyle* childStyle = context.elementStyle ? context.elementStyle : element->renderStyle(); 792 792 RenderStyle* parentStyle = context.elementStyle ? context.elementParentStyle : element->parentNode()->renderStyle(); … … 810 810 } 811 811 } 812 if ( !m_isCollectingRulesOnly) {812 if (m_mode == ResolvingStyle) { 813 813 RenderStyle* parentStyle = context.elementStyle ? context.elementParentStyle : element->parentNode()->renderStyle(); 814 814 if (parentStyle) … … 822 822 if (Element* parentElement = element->parentElement()) { 823 823 bool result = parentElement->isFinishedParsingChildren() && !element->nextElementSibling(); 824 if ( !m_isCollectingRulesOnly) {824 if (m_mode == ResolvingStyle) { 825 825 RenderStyle* childStyle = context.elementStyle ? context.elementStyle : element->renderStyle(); 826 826 RenderStyle* parentStyle = context.elementStyle ? context.elementParentStyle : parentElement->renderStyle(); … … 836 836 // last-of-type matches the last element of its type 837 837 if (Element* parentElement = element->parentElement()) { 838 if ( !m_isCollectingRulesOnly) {838 if (m_mode == ResolvingStyle) { 839 839 RenderStyle* parentStyle = context.elementStyle ? context.elementParentStyle : parentElement->renderStyle(); 840 840 if (parentStyle) … … 856 856 bool onlyChild = firstChild && parentElement->isFinishedParsingChildren() && !element->nextElementSibling(); 857 857 858 if ( !m_isCollectingRulesOnly) {858 if (m_mode == ResolvingStyle) { 859 859 RenderStyle* childStyle = context.elementStyle ? context.elementStyle : element->renderStyle(); 860 860 RenderStyle* parentStyle = context.elementStyle ? context.elementParentStyle : parentElement->renderStyle(); … … 874 874 // FIXME: This selector is very slow. 875 875 if (Element* parentElement = element->parentElement()) { 876 if ( !m_isCollectingRulesOnly) {876 if (m_mode == ResolvingStyle) { 877 877 RenderStyle* parentStyle = context.elementStyle ? context.elementParentStyle : parentElement->renderStyle(); 878 878 if (parentStyle) { … … 910 910 } 911 911 912 if ( !m_isCollectingRulesOnly) {912 if (m_mode == ResolvingStyle) { 913 913 RenderStyle* childStyle = context.elementStyle ? context.elementStyle : element->renderStyle(); 914 914 RenderStyle* parentStyle = context.elementStyle ? context.elementParentStyle : parentElement->renderStyle(); … … 933 933 ++count; 934 934 } 935 if ( !m_isCollectingRulesOnly) {935 if (m_mode == ResolvingStyle) { 936 936 RenderStyle* parentStyle = context.elementStyle ? context.elementParentStyle : parentElement->renderStyle(); 937 937 if (parentStyle) … … 947 947 break; 948 948 if (Element* parentElement = element->parentElement()) { 949 if ( !m_isCollectingRulesOnly) {949 if (m_mode == ResolvingStyle) { 950 950 RenderStyle* parentStyle = context.elementStyle ? context.elementParentStyle : parentElement->renderStyle(); 951 951 if (parentStyle) … … 965 965 break; 966 966 if (Element* parentElement = element->parentElement()) { 967 if ( !m_isCollectingRulesOnly) {967 if (m_mode == ResolvingStyle) { 968 968 RenderStyle* parentStyle = context.elementStyle ? context.elementParentStyle : parentElement->renderStyle(); 969 969 if (parentStyle) … … 1170 1170 } 1171 1171 if (selector->m_match == CSSSelector::PseudoElement) { 1172 if ( !context.elementStyle && !m_isCollectingRulesOnly)1172 if ((!context.elementStyle && m_mode == ResolvingStyle) || m_mode == QueryingRules) 1173 1173 return false; 1174 1174 -
trunk/Source/WebCore/css/SelectorChecker.h
r114265 r115971 53 53 enum SelectorMatch { SelectorMatches, SelectorFailsLocally, SelectorFailsAllSiblings, SelectorFailsCompletely }; 54 54 enum VisitedMatchType { VisitedMatchDisabled, VisitedMatchEnabled }; 55 enum Mode { ResolvingStyle = 0, CollectingRules, QueryingRules }; 55 56 56 57 struct SelectorCheckingContext { … … 97 98 bool strictParsing() const { return m_strictParsing; } 98 99 99 bool isCollectingRulesOnly() const { return m_isCollectingRulesOnly; }100 void set CollectingRulesOnly(bool b) { m_isCollectingRulesOnly = b; }100 Mode mode() const { return m_mode; } 101 void setMode(Mode mode) { m_mode = mode; } 101 102 102 103 PseudoId pseudoStyle() const { return m_pseudoStyle; } … … 136 137 bool m_strictParsing; 137 138 bool m_documentIsHTML; 138 bool m_isCollectingRulesOnly;139 Mode m_mode; 139 140 PseudoId m_pseudoStyle; 140 141 mutable bool m_hasUnknownPseudoElements; -
trunk/Source/WebCore/css/StyleResolver.cpp
r115860 r115971 872 872 sortMatchedRules(); 873 873 874 if (m_checker. isCollectingRulesOnly()) {874 if (m_checker.mode() == SelectorChecker::CollectingRules) { 875 875 if (!m_ruleList) 876 876 m_ruleList = StaticCSSRuleList::create(); … … 1046 1046 // we really just matched a pseudo-element. 1047 1047 if (m_dynamicPseudo != NOPSEUDO && m_checker.pseudoStyle() == NOPSEUDO) { 1048 if (m_checker. isCollectingRulesOnly()) {1048 if (m_checker.mode() == SelectorChecker::CollectingRules) { 1049 1049 InspectorInstrumentation::didMatchRule(cookie, false); 1050 1050 continue; … … 2176 2176 return 0; 2177 2177 2178 m_checker.set CollectingRulesOnly(true);2178 m_checker.setMode(SelectorChecker::CollectingRules); 2179 2179 2180 2180 initElement(e); … … 2200 2200 } 2201 2201 2202 m_checker.set CollectingRulesOnly(false);2202 m_checker.setMode(SelectorChecker::ResolvingStyle); 2203 2203 2204 2204 return m_ruleList.release(); -
trunk/Source/WebCore/dom/SelectorQuery.cpp
r106902 r115971 152 152 , m_selectors(selectorList) 153 153 { 154 m_selectorChecker.set CollectingRulesOnly(true);154 m_selectorChecker.setMode(SelectorChecker::QueryingRules); 155 155 } 156 156 -
trunk/Source/WebCore/html/shadow/ContentSelectorQuery.cpp
r114217 r115971 38 38 , m_selectorChecker(insertionPoint->document(), !insertionPoint->document()->inQuirksMode()) 39 39 { 40 m_selectorChecker.set CollectingRulesOnly(true);40 m_selectorChecker.setMode(SelectorChecker::CollectingRules); 41 41 42 42 if (insertionPoint->select().isNull() || insertionPoint->select().isEmpty()) {
Note: See TracChangeset
for help on using the changeset viewer.