Changeset 106351 in webkit
- Timestamp:
- Jan 31, 2012 3:04:10 AM (12 years ago)
- Location:
- trunk/Source/WebCore
- Files:
-
- 3 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/Source/WebCore/ChangeLog
r106347 r106351 1 2012-01-31 Roland Steiner <rolandsteiner@chromium.org> 2 3 <style scoped>: Improve shortcut code for cases where <style scoped> isn't used 4 https://bugs.webkit.org/show_bug.cgi?id=77410 5 6 Move shortcut from setupScopingElementStack(), do it at the calling sites instead 7 (where a larger chunk of work can be skipped). 8 9 Reviewed by Antti Koivisto. 10 11 No new tests. (refactoring) 12 13 * css/CSSStyleSelector.cpp: 14 (WebCore::CSSStyleSelector::setupScopingElementStack): remove shortcut code 15 (WebCore::CSSStyleSelector::pushParent): add shortcut code 16 (WebCore::CSSStyleSelector::matchScopedAuthorRules): factor matching scoped rules out from matchAuthorRules 17 (WebCore::CSSStyleSelector::matchAuthorRules): add shortcut code 18 * css/CSSStyleSelector.h: 19 (CSSStyleSelector): add matchScopedAuthorRules 20 1 21 2012-01-31 Pavel Feldman <pfeldman@google.com> 2 22 -
trunk/Source/WebCore/css/CSSStyleSelector.cpp
r106331 r106351 499 499 void CSSStyleSelector::setupScopingElementStack(const Element* parent) 500 500 { 501 // Shortcut: abort if <style scoped> isn't used anywhere 502 if (m_scopedAuthorStyles.isEmpty()) { 503 ASSERT(!m_scopingElementStackParent); 504 ASSERT(m_scopingElementStack.isEmpty()); 505 return; 506 } 501 // The scoping element stack shouldn't be used if <style scoped> isn't used anywhere. 502 ASSERT(!m_scopedAuthorStyles.isEmpty()); 503 507 504 m_scopingElementStack.shrink(0); 508 505 for (; parent; parent = parent->parentOrHostElement()) { … … 529 526 530 527 #if ENABLE(STYLE_SCOPED) 528 // Shortcut: Don't bother with the scoping element stack if <style scoped> isn't used anywhere. 529 if (m_scopedAuthorStyles.isEmpty()) { 530 ASSERT(!m_scopingElementStackParent); 531 ASSERT(m_scopingElementStack.isEmpty()); 532 return; 533 } 534 // In some wacky cases during style resolve we may get invoked for random elements. 535 // Recreate the whole scoping element stack in such cases. 531 536 if (!scopingElementStackIsConsistent(parentsParent)) { 532 // In some wacky cases during style resolve we may get invoked for random elements -533 // recreate the scoping element stack in such cases.534 537 setupScopingElementStack(parent); 535 538 return; 536 539 } 540 // Otherwise just push the parent onto the stack. 537 541 RuleSet* ruleSet = scopedRuleSetForElement(parent); 538 542 if (ruleSet) … … 825 829 } 826 830 827 void CSSStyleSelector::matchAuthorRules(int& firstRuleIndex, int& lastRuleIndex, bool includeEmptyRules) 828 { 829 m_matchedRules.clear(); 830 831 if (!m_element) 832 return; 833 834 // Match global author rules. 835 collectMatchingRules(m_authorStyle.get(), firstRuleIndex, lastRuleIndex, includeEmptyRules); 836 collectMatchingRulesForRegion(m_authorStyle.get(), firstRuleIndex, lastRuleIndex, includeEmptyRules); 837 831 void CSSStyleSelector::matchScopedAuthorRules(int& firstRuleIndex, int& lastRuleIndex, bool includeEmptyRules) 832 { 838 833 #if ENABLE(STYLE_SCOPED) 834 if (m_scopedAuthorStyles.isEmpty()) 835 return; 836 839 837 // Match scoped author rules by traversing the scoped element stack (rebuild it if it got inconsistent). 840 838 const Element* parent = m_element->parentOrHostElement(); … … 851 849 collectMatchingRulesForRegion(ruleSet, firstRuleIndex, lastRuleIndex, includeEmptyRules); 852 850 } 851 #else 852 UNUSED_PARAM(firstRuleIndex); 853 UNUSED_PARAM(lastRuleIndex); 854 UNUSED_PARAM(includeEmptyRules); 853 855 #endif 856 } 857 858 void CSSStyleSelector::matchAuthorRules(int& firstRuleIndex, int& lastRuleIndex, bool includeEmptyRules) 859 { 860 m_matchedRules.clear(); 861 862 if (!m_element) 863 return; 864 865 // Match global author rules. 866 collectMatchingRules(m_authorStyle.get(), firstRuleIndex, lastRuleIndex, includeEmptyRules); 867 collectMatchingRulesForRegion(m_authorStyle.get(), firstRuleIndex, lastRuleIndex, includeEmptyRules); 868 869 matchScopedAuthorRules(firstRuleIndex, lastRuleIndex, includeEmptyRules); 854 870 855 871 sortAndTransferMatchedRules(); -
trunk/Source/WebCore/css/CSSStyleSelector.h
r106331 r106351 281 281 void matchRules(RuleSet*, int& firstRuleIndex, int& lastRuleIndex, bool includeEmptyRules); 282 282 void matchAuthorRules(int& firstRuleIndex, int& lastRuleIndex, bool includeEmptyRules); 283 void matchScopedAuthorRules(int& firstRuleIndex, int& lastRuleIndex, bool includeEmptyRules); 283 284 void collectMatchingRules(RuleSet*, int& firstRuleIndex, int& lastRuleIndex, bool includeEmptyRules); 284 285 void collectMatchingRulesForRegion(RuleSet*, int& firstRuleIndex, int& lastRuleIndex, bool includeEmptyRules);
Note: See TracChangeset
for help on using the changeset viewer.