Changeset 130089 in webkit
- Timestamp:
- Oct 1, 2012 3:54:29 PM (12 years ago)
- Location:
- trunk/Source/WebCore
- Files:
-
- 3 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/Source/WebCore/ChangeLog
r130088 r130089 1 2012-10-01 Dimitri Glazkov <dglazkov@chromium.org> 2 3 Kill transitive effects of SelectorChecker::checkOneSelector. 4 https://bugs.webkit.org/show_bug.cgi?id=97953 5 6 Reviewed by Eric Seidel. 7 8 The dynamicPseudo/hasUnknownPseudoelements by-ref parameters that are passed into checkOneSelector make the logic harder to understand and aren't needed. Refactor the code to rid of them, replacing them instead with two flags in SelectorCheckingContext. 9 10 No change in behavior, covered by existing tests. 11 12 * css/SelectorChecker.cpp: 13 (WebCore::SelectorChecker::checkSelector): Rolled pseudo-element-checking code out of checkOneSelector into here, since that is where t 14 (WebCore::SelectorChecker::checkOneSelector): Changed to use SelectorCheckingContext rather than transitive params. 15 * css/SelectorChecker.h: 16 (WebCore::SelectorChecker::SelectorCheckingContext::SelectorCheckingContext): Added two new flags. 17 (SelectorCheckingContext): Ditto. 18 19 1 20 2012-10-01 Andreas Kling <kling@webkit.org> 2 21 -
trunk/Source/WebCore/css/SelectorChecker.cpp
r129974 r130089 267 267 } 268 268 269 PseudoId dynamicPseudo = NOPSEUDO;269 PseudoId ignoreDynamicPseudo = NOPSEUDO; 270 270 bool hasUnknownPseudoElements = false; 271 return checkSelector(SelectorCheckingContext(sel, element, SelectorChecker::VisitedMatchDisabled), dynamicPseudo, hasUnknownPseudoElements) == SelectorMatches;271 return checkSelector(SelectorCheckingContext(sel, element, SelectorChecker::VisitedMatchDisabled), ignoreDynamicPseudo, hasUnknownPseudoElements) == SelectorMatches; 272 272 } 273 273 … … 443 443 { 444 444 // first selector has to match 445 if (!checkOneSelector(context , dynamicPseudo, hasUnknownPseudoElements))445 if (!checkOneSelector(context)) 446 446 return SelectorFailsLocally; 447 448 if (context.selector->m_match == CSSSelector::PseudoElement) { 449 if (context.selector->isUnknownPseudoElement()) { 450 hasUnknownPseudoElements = true; 451 if (context.element->shadowPseudoId() != context.selector->value()) 452 return SelectorFailsLocally; 453 } else { 454 if ((!context.elementStyle && m_mode == ResolvingStyle) || m_mode == QueryingRules) 455 return SelectorFailsLocally; 456 457 PseudoId pseudoId = CSSSelector::pseudoId(context.selector->pseudoType()); 458 if (pseudoId == FIRST_LETTER) { 459 if (Document* document = context.element->document()) 460 document->styleSheetCollection()->setUsesFirstLetterRules(true); 461 } 462 if (pseudoId != NOPSEUDO) 463 dynamicPseudo = pseudoId; 464 } 465 } 447 466 448 467 // The rest of the selectors has to match … … 533 552 // We make an exception for scrollbar pseudo elements and allow a set of pseudo classes (but nothing else) 534 553 // to follow the pseudo elements. 535 if ((context.elementStyle || m_mode == CollectingRules || m_mode == QueryingRules) && dynamicPseudo != NOPSEUDO && dynamicPseudo != SELECTION 536 && !((RenderScrollbar::scrollbarForStyleResolve() || dynamicPseudo == SCROLLBAR_CORNER || dynamicPseudo == RESIZER) && nextContext.selector->m_match == CSSSelector::PseudoClass)) 554 nextContext.hasScrollbarPseudo = RenderScrollbar::scrollbarForStyleResolve() || dynamicPseudo == SCROLLBAR_CORNER || dynamicPseudo == RESIZER; 555 nextContext.hasSelectionPseudo = dynamicPseudo == SELECTION; 556 if ((context.elementStyle || m_mode == CollectingRules || m_mode == QueryingRules) && dynamicPseudo != NOPSEUDO 557 && !nextContext.hasSelectionPseudo 558 && !(nextContext.hasScrollbarPseudo && nextContext.selector->m_match == CSSSelector::PseudoClass)) 537 559 return SelectorFailsCompletely; 538 560 nextContext.isSubSelector = true; … … 705 727 } 706 728 707 bool SelectorChecker::checkOneSelector(const SelectorCheckingContext& context , PseudoId& dynamicPseudo, bool& hasUnknownPseudoElements) const729 bool SelectorChecker::checkOneSelector(const SelectorCheckingContext& context) const 708 730 { 709 731 Element* const & element = context.element; … … 752 774 if (subContext.selector->pseudoType() == CSSSelector::PseudoVisited || (subContext.selector->pseudoType() == CSSSelector::PseudoLink && subContext.visitedMatchType == VisitedMatchEnabled)) 753 775 return true; 754 if (!checkOneSelector(subContext , dynamicPseudo, hasUnknownPseudoElements))776 if (!checkOneSelector(subContext)) 755 777 return true; 756 778 } 757 } else if ( dynamicPseudo != NOPSEUDO && (RenderScrollbar::scrollbarForStyleResolve() || dynamicPseudo == SCROLLBAR_CORNER || dynamicPseudo == RESIZER)) {779 } else if (context.hasScrollbarPseudo) { 758 780 // CSS scrollbars match a specific subset of pseudo classes, and they have specialized rules for each 759 781 // (since there are no elements involved). 760 782 return checkScrollbarPseudoClass(selector); 761 } else if ( dynamicPseudo == SELECTION) {783 } else if (context.hasSelectionPseudo) { 762 784 if (selector->pseudoType() == CSSSelector::PseudoWindowInactive) 763 785 return !m_document->page()->focusController()->isActive(); … … 1001 1023 SelectorCheckingContext subContext(context); 1002 1024 subContext.isSubSelector = true; 1025 bool hasUnknownPseudoElements = false; 1026 PseudoId ignoreDynamicPseudo = NOPSEUDO; 1003 1027 for (subContext.selector = selector->selectorList()->first(); subContext.selector; subContext.selector = CSSSelectorList::next(subContext.selector)) { 1004 if (checkSelector(subContext, dynamicPseudo, hasUnknownPseudoElements) == SelectorMatches)1028 if (checkSelector(subContext, ignoreDynamicPseudo, hasUnknownPseudoElements) == SelectorMatches) 1005 1029 return true; 1006 1030 } … … 1175 1199 } 1176 1200 return false; 1177 }1178 if (selector->m_match == CSSSelector::PseudoElement) {1179 if (selector->isUnknownPseudoElement()) {1180 hasUnknownPseudoElements = true;1181 return element->shadowPseudoId() == selector->value();1182 }1183 1184 if ((!context.elementStyle && m_mode == ResolvingStyle) || m_mode == QueryingRules)1185 return false;1186 1187 PseudoId pseudoId = CSSSelector::pseudoId(selector->pseudoType());1188 if (pseudoId == FIRST_LETTER) {1189 if (Document* document = element->document())1190 document->styleSheetCollection()->setUsesFirstLetterRules(true);1191 }1192 if (pseudoId != NOPSEUDO)1193 dynamicPseudo = pseudoId;1194 1201 } 1195 1202 // ### add the rest of the checks... -
trunk/Source/WebCore/css/SelectorChecker.h
r129963 r130089 66 66 , isSubSelector(false) 67 67 , pseudoStyle(NOPSEUDO) 68 , hasScrollbarPseudo(false) 69 , hasSelectionPseudo(false) 68 70 { } 69 71 … … 76 78 bool isSubSelector; 77 79 PseudoId pseudoStyle; 80 bool hasScrollbarPseudo; 81 bool hasSelectionPseudo; 78 82 }; 79 83 … … 118 122 119 123 private: 120 bool checkOneSelector(const SelectorCheckingContext& , PseudoId&, bool& hasUnknownPseudoElements) const;124 bool checkOneSelector(const SelectorCheckingContext&) const; 121 125 bool checkScrollbarPseudoClass(CSSSelector*) const; 122 126 static bool isFrameFocused(const Element*);
Note: See TracChangeset
for help on using the changeset viewer.