Changeset 142591 in webkit
- Timestamp:
- Feb 12, 2013 12:07:54 AM (11 years ago)
- Location:
- trunk/Source/WebCore
- Files:
-
- 5 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/Source/WebCore/ChangeLog
r142587 r142591 1 2013-02-12 Takashi Sakamoto <tasak@google.com> 2 3 [Refactoring] Make m_selectorChecker in StyleResolver an on-stack object. 4 https://bugs.webkit.org/show_bug.cgi?id=108595 5 6 Reviewed by Eric Seidel. 7 8 StyleResolver uses SelectorChecker's mode to change its resolving mode. 9 However it is a state of StyleResolver. StyleResolver should have the 10 mode and make SelectorChecker instance on a stack while required. 11 12 No new tests, just refactoring. 13 14 * css/SelectorChecker.cpp: 15 (WebCore::SelectorChecker::fastCheckRightmostSelector): 16 (WebCore::SelectorChecker::fastCheck): 17 (WebCore::SelectorChecker::commonPseudoClassSelectorMatches): 18 (WebCore::SelectorChecker::matchesFocusPseudoClass): 19 Changed to static class function, because these methods never use 20 "this". 21 (WebCore): 22 * css/SelectorChecker.h: 23 (SelectorChecker): 24 * css/StyleResolver.cpp: 25 (WebCore::StyleResolver::StyleResolver): 26 (WebCore::StyleResolver::collectMatchingRules): 27 Now, matchesFocusPseudoClass is not a static method of 28 SelectorChecker, so replaced "m_selectorChecker." with 29 "SelectorChecker::". 30 (WebCore::StyleResolver::sortAndTransferMatchedRules): 31 (WebCore::StyleResolver::collectMatchingRulesForList): 32 (WebCore::StyleResolver::styleSharingCandidateMatchesRuleSet): 33 (WebCore::StyleResolver::matchUARules): 34 (WebCore::StyleResolver::adjustRenderStyle): 35 (WebCore::StyleResolver::pseudoStyleRulesForElement): 36 Use m_mode instead of m_selectorChecker.mode(). 37 Also use document()->inQuirksMode() instead of 38 m_selectoChecker.strictParsing(). 39 (WebCore::StyleResolver::ruleMatches): 40 (WebCore::StyleResolver::checkRegionSelector): 41 Created an on-stack SelectorChecker object and used it to check 42 selectors. 43 * css/StyleResolver.h: 44 (WebCore::StyleResolver::State::State): 45 Added m_mode, this keeps m_selectorChecker's mode. 46 (State): 47 (StyleResolver): 48 Removed m_selectorChecker. 49 1 50 2013-02-11 Viatcheslav Ostapenko <sl.ostapenko@samsung.com> 2 51 -
trunk/Source/WebCore/css/SelectorChecker.cpp
r142043 r142591 140 140 } 141 141 142 inline bool SelectorChecker::fastCheckRightmostSelector(const CSSSelector* selector, const Element* element, VisitedMatchType visitedMatchType) const 143 { 144 ASSERT( isFastCheckableSelector(selector));142 bool SelectorChecker::fastCheckRightmostSelector(const CSSSelector* selector, const Element* element, SelectorChecker::VisitedMatchType visitedMatchType) 143 { 144 ASSERT(SelectorChecker::isFastCheckableSelector(selector)); 145 145 146 146 switch (selector->m_match) { … … 162 162 } 163 163 164 bool SelectorChecker::fastCheck(const CSSSelector* selector, const Element* element) const164 bool SelectorChecker::fastCheck(const CSSSelector* selector, const Element* element) 165 165 { 166 166 ASSERT(fastCheckRightmostSelector(selector, element, VisitedMatchEnabled)); … … 1000 1000 } 1001 1001 1002 bool SelectorChecker::commonPseudoClassSelectorMatches(const Element* element, const CSSSelector* selector, VisitedMatchType visitedMatchType) const1002 bool SelectorChecker::commonPseudoClassSelectorMatches(const Element* element, const CSSSelector* selector, VisitedMatchType visitedMatchType) 1003 1003 { 1004 1004 ASSERT(isCommonPseudoClassSelector(selector)); … … 1067 1067 } 1068 1068 1069 bool SelectorChecker::matchesFocusPseudoClass(const Element* element) 1070 { 1071 if (InspectorInstrumentation::forcePseudoState(const_cast<Element*>(element), CSSSelector::PseudoFocus)) 1072 return true; 1073 return element->focused() && isFrameFocused(element); 1074 } 1075 1069 1076 template 1070 1077 SelectorChecker::Match SelectorChecker::match(const SelectorCheckingContext&, PseudoId&, const DOMSiblingTraversalStrategy&) const; -
trunk/Source/WebCore/css/SelectorChecker.h
r140531 r142591 83 83 84 84 static bool isFastCheckableSelector(const CSSSelector*); 85 bool fastCheck(const CSSSelector*, const Element*) const;85 static bool fastCheck(const CSSSelector*, const Element*); 86 86 87 87 bool strictParsing() const { return m_strictParsing; } … … 92 92 static bool tagMatches(const Element*, const QualifiedName&); 93 93 static bool isCommonPseudoClassSelector(const CSSSelector*); 94 bool matchesFocusPseudoClass(const Element*) const;94 static bool matchesFocusPseudoClass(const Element*); 95 95 static bool fastCheckRightmostAttributeSelector(const Element*, const CSSSelector*); 96 96 static bool checkExactAttribute(const Element*, const QualifiedName& selectorAttributeName, const AtomicStringImpl* value); … … 101 101 private: 102 102 bool checkScrollbarPseudoClass(Document*, const CSSSelector*) const; 103 103 104 static bool isFrameFocused(const Element*); 104 105 105 bool fastCheckRightmostSelector(const CSSSelector*, const Element*, VisitedMatchType) const;106 bool commonPseudoClassSelectorMatches(const Element*, const CSSSelector*, VisitedMatchType) const;106 static bool fastCheckRightmostSelector(const CSSSelector*, const Element*, VisitedMatchType); 107 static bool commonPseudoClassSelectorMatches(const Element*, const CSSSelector*, VisitedMatchType); 107 108 108 109 bool m_strictParsing; … … 120 121 || pseudoType == CSSSelector::PseudoVisited 121 122 || pseudoType == CSSSelector::PseudoFocus; 122 }123 124 inline bool SelectorChecker::matchesFocusPseudoClass(const Element* element) const125 {126 if (InspectorInstrumentation::forcePseudoState(const_cast<Element*>(element), CSSSelector::PseudoFocus))127 return true;128 return element->focused() && isFrameFocused(element);129 123 } 130 124 -
trunk/Source/WebCore/css/StyleResolver.cpp
r142573 r142591 229 229 , m_matchedPropertiesCacheSweepTimer(this, &StyleResolver::sweepMatchedPropertiesCache) 230 230 , m_document(document) 231 , m_selectorChecker(document)232 231 , m_matchAuthorAndUserStyles(matchAuthorAndUserStyles) 233 232 , m_fontSelector(CSSFontSelector::create(document)) … … 459 458 if (element->isLink()) 460 459 collectMatchingRulesForList(matchRequest.ruleSet->linkPseudoClassRules(), matchRequest, ruleRange); 461 if ( m_selectorChecker.matchesFocusPseudoClass(element))460 if (SelectorChecker::matchesFocusPseudoClass(element)) 462 461 collectMatchingRulesForList(matchRequest.ruleSet->focusPseudoClassRules(), matchRequest, ruleRange); 463 462 collectMatchingRulesForList(matchRequest.ruleSet->tagRules(element->localName().impl()), matchRequest, ruleRange); … … 489 488 sortMatchedRules(); 490 489 491 if ( m_selectorChecker.mode()== SelectorChecker::CollectingRules) {490 if (state.mode == SelectorChecker::CollectingRules) { 492 491 if (!state.ruleList) 493 492 state.ruleList = StaticCSSRuleList::create(); … … 656 655 // we really just matched a pseudo-element. 657 656 if (state.dynamicPseudo != NOPSEUDO && state.pseudoStyle == NOPSEUDO) { 658 if ( m_selectorChecker.mode()== SelectorChecker::CollectingRules) {657 if (state.mode == SelectorChecker::CollectingRules) { 659 658 InspectorInstrumentation::didMatchRule(cookie, false); 660 659 continue; … … 852 851 m_state.matchedRules.clear(); 853 852 854 m_s electorChecker.setMode(SelectorChecker::SharingRules);853 m_state.mode = SelectorChecker::SharingRules; 855 854 int firstRuleIndex = -1, lastRuleIndex = -1; 856 855 RuleRange ruleRange(firstRuleIndex, lastRuleIndex); 857 856 collectMatchingRules(MatchRequest(ruleSet), ruleRange); 858 m_s electorChecker.setMode(SelectorChecker::ResolvingStyle);857 m_state.mode = SelectorChecker::ResolvingStyle; 859 858 if (m_state.matchedRules.isEmpty()) 860 859 return false; … … 1138 1137 1139 1138 // In quirks mode, we match rules from the quirks user agent sheet. 1140 if ( !m_selectorChecker.strictParsing())1139 if (document()->inQuirksMode()) 1141 1140 matchUARules(result, CSSDefaultStyleSheets::defaultQuirksStyle); 1142 1141 … … 1730 1729 // Sites also commonly use display:inline/block on <td>s and <table>s. In quirks mode we force 1731 1730 // these tags to retain their display types. 1732 if ( !m_selectorChecker.strictParsing() && e) {1731 if (document()->inQuirksMode() && e) { 1733 1732 if (e->hasTagName(tdTag)) { 1734 1733 style->setDisplay(TABLE_CELL); … … 1777 1776 // Absolute/fixed positioned elements, floating elements and the document element need block-like outside display. 1778 1777 if (style->hasOutOfFlowPosition() || style->isFloating() || (e && e->document()->documentElement() == e)) 1779 style->setDisplay(equivalentBlockDisplay(style->display(), style->isFloating(), m_selectorChecker.strictParsing()));1778 style->setDisplay(equivalentBlockDisplay(style->display(), style->isFloating(), !document()->inQuirksMode())); 1780 1779 1781 1780 // FIXME: Don't support this mutation for pseudo styles like first-letter or first-line, since it's not completely … … 1807 1806 if (isDisplayFlexibleBox(parentStyle->display())) { 1808 1807 style->setFloating(NoFloat); 1809 style->setDisplay(equivalentBlockDisplay(style->display(), style->isFloating(), m_selectorChecker.strictParsing()));1808 style->setDisplay(equivalentBlockDisplay(style->display(), style->isFloating(), !document()->inQuirksMode())); 1810 1809 } 1811 1810 … … 2026 2025 return 0; 2027 2026 2028 m_s electorChecker.setMode(SelectorChecker::CollectingRules);2027 m_state.mode = SelectorChecker::CollectingRules; 2029 2028 2030 2029 initElement(e); … … 2050 2049 } 2051 2050 2052 m_s electorChecker.setMode(SelectorChecker::ResolvingStyle);2051 m_state.mode = SelectorChecker::ResolvingStyle; 2053 2052 2054 2053 return m_state.ruleList.release(); … … 2075 2074 return false; 2076 2075 2077 return m_selectorChecker.fastCheck(ruleData.selector(), state.element);2076 return SelectorChecker::fastCheck(ruleData.selector(), state.element); 2078 2077 } 2079 2078 2080 2079 // Slow path. 2080 SelectorChecker selectorChecker(document()); 2081 selectorChecker.setMode(state.mode); 2081 2082 SelectorChecker::SelectorCheckingContext context(ruleData.selector(), state.element, SelectorChecker::VisitedMatchEnabled); 2082 2083 context.elementStyle = state.style.get(); 2083 2084 context.scope = scope; 2084 2085 context.pseudoStyle = state.pseudoStyle; 2085 SelectorChecker::Match match = m_selectorChecker.match(context, state.dynamicPseudo, DOMSiblingTraversalStrategy());2086 SelectorChecker::Match match = selectorChecker.match(context, state.dynamicPseudo, DOMSiblingTraversalStrategy()); 2086 2087 if (match != SelectorChecker::SelectorMatches) 2087 2088 return false; … … 2098 2099 m_state.pseudoStyle = NOPSEUDO; 2099 2100 2101 SelectorChecker selectorChecker(document()); 2100 2102 for (const CSSSelector* s = regionSelector; s; s = CSSSelectorList::next(s)) 2101 if ( m_selectorChecker.matches(s, regionElement))2103 if (selectorChecker.matches(s, regionElement)) 2102 2104 return true; 2103 2105 -
trunk/Source/WebCore/css/StyleResolver.h
r142573 r142591 444 444 , distributedToInsertionPoint(false) 445 445 , elementAffectedByClassRules(false) 446 , mode(SelectorChecker::ResolvingStyle) 446 447 , applyPropertyToRegularStyle(true) 447 448 , applyPropertyToVisitedLinkStyle(false) … … 477 478 PseudoId dynamicPseudo; 478 479 480 SelectorChecker::Mode mode; 481 479 482 // A buffer used to hold the set of matched rules for an element, 480 483 // and a temporary buffer used for merge sorting. … … 568 571 569 572 Document* m_document; 570 // FIXME: Make SelectorChecker an on-stack object and571 // move selectorChecker.mode() to State.572 // selectorChecker.stringParsing() can be replaced with573 // !document.inQuirksMode().574 SelectorChecker m_selectorChecker;575 573 SelectorFilter m_selectorFilter; 576 574
Note: See TracChangeset
for help on using the changeset viewer.