Changeset 139817 in webkit
- Timestamp:
- Jan 15, 2013 6:06:05 PM (11 years ago)
- Location:
- trunk/Source/WebCore
- Files:
-
- 3 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/Source/WebCore/ChangeLog
r139815 r139817 1 2013-01-15 Hayato Ito <hayato@chromium.org> 2 3 Group all request parameters which are used to match CSS Rules into a parameter object. 4 https://bugs.webkit.org/show_bug.cgi?id=106879 5 6 Reviewed by Dimitri Glazkov. 7 8 Introduces a MatchRequest which groups all request parameters to match CSS rules. 9 10 Factoring, no change in behavior. 11 12 * css/StyleResolver.cpp: 13 (WebCore::StyleResolver::collectMatchingRules): 14 (WebCore::StyleResolver::collectMatchingRulesForRegion): 15 (WebCore::StyleResolver::matchScopedAuthorRules): 16 (WebCore::StyleResolver::matchHostRules): 17 (WebCore::StyleResolver::matchAuthorRules): 18 (WebCore::StyleResolver::matchUserRules): 19 (WebCore::StyleResolver::matchUARules): 20 (WebCore::StyleResolver::collectMatchingRulesForList): 21 (WebCore::StyleResolver::styleSharingCandidateMatchesRuleSet): 22 * css/StyleResolver.h: 23 (WebCore::StyleResolver::MatchRequest::MatchRequest): 24 (MatchRequest): 25 (StyleResolver): 26 1 27 2013-01-15 Simon Fraser <simon.fraser@apple.com> 2 28 -
trunk/Source/WebCore/css/StyleResolver.cpp
r139639 r139817 643 643 bool MatchingUARulesScope::m_matchingUARules = false; 644 644 645 void StyleResolver::collectMatchingRules( RuleSet* rules, int& firstRuleIndex, int& lastRuleIndex, const MatchOptions& options)646 { 647 ASSERT( rules);645 void StyleResolver::collectMatchingRules(const MatchRequest& matchRequest, int& firstRuleIndex, int& lastRuleIndex) 646 { 647 ASSERT(matchRequest.ruleSet); 648 648 ASSERT(m_element); 649 649 … … 651 651 if (!pseudoId.isEmpty()) { 652 652 ASSERT(m_styledElement); 653 collectMatchingRulesForList( rules->shadowPseudoElementRules(pseudoId.impl()), firstRuleIndex, lastRuleIndex, options);653 collectMatchingRulesForList(matchRequest.ruleSet->shadowPseudoElementRules(pseudoId.impl()), matchRequest, firstRuleIndex, lastRuleIndex); 654 654 } 655 655 656 656 #if ENABLE(VIDEO_TRACK) 657 657 if (m_element->webVTTNodeType()) 658 collectMatchingRulesForList( rules->cuePseudoRules(), firstRuleIndex, lastRuleIndex, options);658 collectMatchingRulesForList(matchRequest.ruleSet->cuePseudoRules(), matchRequest, firstRuleIndex, lastRuleIndex); 659 659 #endif 660 660 // Check whether other types of rules are applicable in the current tree scope. Criteria for this: … … 665 665 if (!MatchingUARulesScope::isMatchingUARules() 666 666 && !treeScope->applyAuthorStyles() 667 && (! options.scope || options.scope->treeScope() != treeScope))667 && (!matchRequest.scope || matchRequest.scope->treeScope() != treeScope)) 668 668 return; 669 669 … … 671 671 // then sort the buffer. 672 672 if (m_element->hasID()) 673 collectMatchingRulesForList( rules->idRules(m_element->idForStyleResolution().impl()), firstRuleIndex, lastRuleIndex, options);673 collectMatchingRulesForList(matchRequest.ruleSet->idRules(m_element->idForStyleResolution().impl()), matchRequest, firstRuleIndex, lastRuleIndex); 674 674 if (m_styledElement && m_styledElement->hasClass()) { 675 675 for (size_t i = 0; i < m_styledElement->classNames().size(); ++i) 676 collectMatchingRulesForList( rules->classRules(m_styledElement->classNames()[i].impl()), firstRuleIndex, lastRuleIndex, options);676 collectMatchingRulesForList(matchRequest.ruleSet->classRules(m_styledElement->classNames()[i].impl()), matchRequest, firstRuleIndex, lastRuleIndex); 677 677 } 678 678 679 679 if (m_element->isLink()) 680 collectMatchingRulesForList( rules->linkPseudoClassRules(), firstRuleIndex, lastRuleIndex, options);680 collectMatchingRulesForList(matchRequest.ruleSet->linkPseudoClassRules(), matchRequest, firstRuleIndex, lastRuleIndex); 681 681 if (m_selectorChecker.matchesFocusPseudoClass(m_element)) 682 collectMatchingRulesForList( rules->focusPseudoClassRules(), firstRuleIndex, lastRuleIndex, options);683 collectMatchingRulesForList( rules->tagRules(m_element->localName().impl()), firstRuleIndex, lastRuleIndex, options);684 collectMatchingRulesForList( rules->universalRules(), firstRuleIndex, lastRuleIndex, options);685 } 686 687 void StyleResolver::collectMatchingRulesForRegion( RuleSet* rules, int& firstRuleIndex, int& lastRuleIndex, const MatchOptions& options)682 collectMatchingRulesForList(matchRequest.ruleSet->focusPseudoClassRules(), matchRequest, firstRuleIndex, lastRuleIndex); 683 collectMatchingRulesForList(matchRequest.ruleSet->tagRules(m_element->localName().impl()), matchRequest, firstRuleIndex, lastRuleIndex); 684 collectMatchingRulesForList(matchRequest.ruleSet->universalRules(), matchRequest, firstRuleIndex, lastRuleIndex); 685 } 686 687 void StyleResolver::collectMatchingRulesForRegion(const MatchRequest& matchRequest, int& firstRuleIndex, int& lastRuleIndex) 688 688 { 689 689 if (!m_regionForStyling) 690 690 return; 691 691 692 unsigned size = rules->m_regionSelectorsAndRuleSets.size();692 unsigned size = matchRequest.ruleSet->m_regionSelectorsAndRuleSets.size(); 693 693 for (unsigned i = 0; i < size; ++i) { 694 CSSSelector* regionSelector = rules->m_regionSelectorsAndRuleSets.at(i).selector;694 CSSSelector* regionSelector = matchRequest.ruleSet->m_regionSelectorsAndRuleSets.at(i).selector; 695 695 if (checkRegionSelector(regionSelector, static_cast<Element*>(m_regionForStyling->node()))) { 696 RuleSet* regionRules = rules->m_regionSelectorsAndRuleSets.at(i).ruleSet.get();696 RuleSet* regionRules = matchRequest.ruleSet->m_regionSelectorsAndRuleSets.at(i).ruleSet.get(); 697 697 ASSERT(regionRules); 698 collectMatchingRules( regionRules, firstRuleIndex, lastRuleIndex, options);698 collectMatchingRules(MatchRequest(regionRules, matchRequest.includeEmptyRules, matchRequest.scope), firstRuleIndex, lastRuleIndex); 699 699 } 700 700 } … … 754 754 } 755 755 756 Match Options options(includeEmptyRules, frame.m_scope);757 collectMatchingRules( frame.m_ruleSet, result.ranges.firstAuthorRule, result.ranges.lastAuthorRule, options);758 collectMatchingRulesForRegion( frame.m_ruleSet, result.ranges.firstAuthorRule, result.ranges.lastAuthorRule, options);756 MatchRequest matchRequest(frame.m_ruleSet, includeEmptyRules, frame.m_scope); 757 collectMatchingRules(matchRequest, result.ranges.firstAuthorRule, result.ranges.lastAuthorRule); 758 collectMatchingRulesForRegion(matchRequest, result.ranges.firstAuthorRule, result.ranges.lastAuthorRule); 759 759 sortAndTransferMatchedRules(result); 760 760 } … … 790 790 return; 791 791 792 MatchOptions options(includeEmptyRules, m_element);793 792 for (unsigned i = matchedRules.size(); i > 0; --i) 794 collectMatchingRules( matchedRules.at(i-1), result.ranges.firstAuthorRule, result.ranges.lastAuthorRule, options);793 collectMatchingRules(MatchRequest(matchedRules.at(i-1), includeEmptyRules, m_element), result.ranges.firstAuthorRule, result.ranges.lastAuthorRule); 795 794 sortAndTransferMatchedRules(result); 796 795 #else … … 809 808 810 809 // Match global author rules. 811 Match Options options(includeEmptyRules);812 collectMatchingRules(m _authorStyle.get(), result.ranges.firstAuthorRule, result.ranges.lastAuthorRule, options);813 collectMatchingRulesForRegion(m _authorStyle.get(), result.ranges.firstAuthorRule, result.ranges.lastAuthorRule, options);810 MatchRequest matchRequest(m_authorStyle.get(), includeEmptyRules); 811 collectMatchingRules(matchRequest, result.ranges.firstAuthorRule, result.ranges.lastAuthorRule); 812 collectMatchingRulesForRegion(matchRequest, result.ranges.firstAuthorRule, result.ranges.lastAuthorRule); 814 813 sortAndTransferMatchedRules(result); 815 814 … … 825 824 826 825 result.ranges.lastUserRule = result.matchedProperties.size() - 1; 827 collectMatchingRules(m_userStyle.get(), result.ranges.firstUserRule, result.ranges.lastUserRule, includeEmptyRules); 828 collectMatchingRulesForRegion(m_userStyle.get(), result.ranges.firstUserRule, result.ranges.lastUserRule, includeEmptyRules); 826 MatchRequest matchRequest(m_userStyle.get(), includeEmptyRules); 827 collectMatchingRules(matchRequest, result.ranges.firstUserRule, result.ranges.lastUserRule); 828 collectMatchingRulesForRegion(matchRequest, result.ranges.firstUserRule, result.ranges.lastUserRule); 829 829 830 830 sortAndTransferMatchedRules(result); … … 836 836 837 837 result.ranges.lastUARule = result.matchedProperties.size() - 1; 838 collectMatchingRules( rules, result.ranges.firstUARule, result.ranges.lastUARule, false);838 collectMatchingRules(MatchRequest(rules), result.ranges.firstUARule, result.ranges.lastUARule); 839 839 840 840 sortAndTransferMatchedRules(result); 841 841 } 842 842 843 void StyleResolver::collectMatchingRulesForList(const Vector<RuleData>* rules, int& firstRuleIndex, int& lastRuleIndex, const MatchOptions& options)843 void StyleResolver::collectMatchingRulesForList(const Vector<RuleData>* rules, const MatchRequest& matchRequest, int& firstRuleIndex, int& lastRuleIndex) 844 844 { 845 845 if (!rules) … … 858 858 StyleRule* rule = ruleData.rule(); 859 859 InspectorInstrumentationCookie cookie = InspectorInstrumentation::willMatchRule(document(), rule, this); 860 if (ruleMatches(ruleData, options.scope)) {860 if (ruleMatches(ruleData, matchRequest.scope)) { 861 861 // If the rule has no properties to apply, then ignore it in the non-debug mode. 862 862 const StylePropertySet* properties = rule->properties(); 863 if (!properties || (properties->isEmpty() && ! options.includeEmptyRules)) {863 if (!properties || (properties->isEmpty() && !matchRequest.includeEmptyRules)) { 864 864 InspectorInstrumentation::didMatchRule(cookie, false); 865 865 continue; … … 1062 1062 int firstRuleIndex = -1, lastRuleIndex = -1; 1063 1063 m_selectorChecker.setMode(SelectorChecker::SharingRules); 1064 collectMatchingRules( ruleSet, firstRuleIndex, lastRuleIndex, false);1064 collectMatchingRules(MatchRequest(ruleSet), firstRuleIndex, lastRuleIndex); 1065 1065 m_selectorChecker.setMode(SelectorChecker::ResolvingStyle); 1066 1066 if (m_matchedRules.isEmpty()) -
trunk/Source/WebCore/css/StyleResolver.h
r139406 r139817 343 343 }; 344 344 345 struct MatchOptions { 346 MatchOptions(bool includeEmptyRules, const ContainerNode* scope = 0) : scope(scope), includeEmptyRules(includeEmptyRules) { } 345 struct MatchRequest { 346 MatchRequest(RuleSet* ruleSet, bool includeEmptyRules = false, const ContainerNode* scope = 0) 347 : ruleSet(ruleSet) 348 , includeEmptyRules(includeEmptyRules) 349 , scope(scope) { } 350 const RuleSet* ruleSet; 351 const bool includeEmptyRules; 347 352 const ContainerNode* scope; 348 bool includeEmptyRules;349 353 }; 350 354 … … 359 363 void matchScopedAuthorRules(MatchResult&, bool includeEmptyRules); 360 364 void matchHostRules(MatchResult&, bool includeEmptyRules); 361 void collectMatchingRules(RuleSet*, int& firstRuleIndex, int& lastRuleIndex, const MatchOptions&); 362 void collectMatchingRulesForRegion(RuleSet*, int& firstRuleIndex, int& lastRuleIndex, const MatchOptions&); 363 void collectMatchingRulesForList(const Vector<RuleData>*, int& firstRuleIndex, int& lastRuleIndex, const MatchOptions&); 365 366 void collectMatchingRules(const MatchRequest&, int& firstRuleIndex, int& lastRuleIndex); 367 void collectMatchingRulesForRegion(const MatchRequest&, int& firstRuleIndex, int& lastRuleIndex); 368 void collectMatchingRulesForList(const Vector<RuleData>*, const MatchRequest&, int& firstRuleIndex, int& lastRuleIndex); 369 364 370 bool fastRejectSelector(const RuleData&) const; 365 371 void sortMatchedRules();
Note: See TracChangeset
for help on using the changeset viewer.