Optimize matching of descendant selectors
authorantti@apple.com <antti@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Sat, 5 Feb 2011 11:23:43 +0000 (11:23 +0000)
committerantti@apple.com <antti@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Sat, 5 Feb 2011 11:23:43 +0000 (11:23 +0000)
commitd141fd8dc18eb6bbf81f99161a70cadb3531ae83
tree7a81eb3dd286de1c5e3b98dc36e3f9c22bd7a5e9
parent907cc721c62a4ef5bf271556dead97a2555923dc
Optimize matching of descendant selectors
https://bugs.webkit.org/show_bug.cgi?id=49876
<rdar://problem/8772822>

Reviewed by Dave Hyatt.

During style recalculation, maintain a filter of tags, ids and classes seen in ancestor elements.
Use the filter to quickly reject descendant and child selectors when doing style matching.

This speeds up style recalculations 3-6x on many major web sites.

* css/CSSStyleSelector.cpp:
(WebCore::RuleData::RuleData):
(WebCore::RuleData::descendantSelectorIdentifierHashes):
(WebCore::collectElementIdentifiers):
(WebCore::CSSStyleSelector::pushParent):
(WebCore::CSSStyleSelector::popParent):
(WebCore::CSSStyleSelector::fastRejectSelector):
(WebCore::CSSStyleSelector::matchRulesForList):
(WebCore::RuleData::collectDescendantSelectorIdentifierHashes):
* css/CSSStyleSelector.h:
(WebCore::CSSStyleSelector::ParentStackFrame::ParentStackFrame):
* dom/Element.cpp:
(WebCore::StyleSelectorParentPusher::StyleSelectorParentPusher):
(WebCore::StyleSelectorParentPusher::push):
(WebCore::StyleSelectorParentPusher::~StyleSelectorParentPusher):
(WebCore::Element::attach):
(WebCore::Element::recalcStyle):

git-svn-id: http://svn.webkit.org/repository/webkit/trunk@77740 268f45cc-cd09-0410-ab3c-d52691b4dbfc
Source/WebCore/ChangeLog
Source/WebCore/css/CSSStyleSelector.cpp
Source/WebCore/css/CSSStyleSelector.h
Source/WebCore/dom/Element.cpp