Bug 54103 - Implement fast path for matching simple selectors
Summary: Implement fast path for matching simple selectors
Status: RESOLVED FIXED
Alias: None
Product: WebKit
Classification: Unclassified
Component: CSS (show other bugs)
Version: 528+ (Nightly build)
Hardware: PC OS X 10.5
: P2 Normal
Assignee: Nobody
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2011-02-09 07:20 PST by Antti Koivisto
Modified: 2011-06-08 02:00 PDT (History)
6 users (show)

See Also:


Attachments
patch (11.95 KB, patch)
2011-02-09 15:36 PST, Antti Koivisto
darin: review+
Details | Formatted Diff | Diff

Note You need to log in before you can comment on or make changes to this bug.
Description Antti Koivisto 2011-02-09 07:20:00 PST
Common selectors consisting of id, class and tag rules only can be resolved much faster using a specialized fast path.
Comment 1 Antti Koivisto 2011-02-09 15:36:26 PST
Created attachment 81885 [details]
patch

Implement a fast path for single and descendant selectors consisting of id, class and tag selectors only.

Selectors like this are marked on style selector initialization. When  encountered during style matching the are resolved using a fast path. Since selectors like are very common, this speeds up style matching quite a bit (up to 50% on some sites according to Shark).
Comment 2 WebKit Review Bot 2011-02-09 15:38:45 PST
Attachment 81885 [details] did not pass style-queue:

Failed to run "['Tools/Scripts/check-webkit-style', '--diff-files', u'Source/WebCore/ChangeLog', u'Source/WebCor..." exit_code: 1

Source/WebCore/css/CSSStyleSelector.cpp:2122:  A case label should not be indented, but line up with its switch statement.  [whitespace/indent] [4]
Total errors found: 1 in 3 files


If any of these errors are false positives, please file a bug against check-webkit-style.
Comment 3 Darin Adler 2011-02-09 16:02:36 PST
Comment on attachment 81885 [details]
patch

View in context: https://bugs.webkit.org/attachment.cgi?id=81885&action=review

> Source/WebCore/css/CSSStyleSelector.cpp:365
> +    bool canFastCheckSelector() const { return m_canFastCheckSelector; }
> +    bool hasMultipartSelector() const { return m_hasMultipartSelector; }
> +    bool topHTMLSelectorMatchesBasedOnRuleHash() const { return m_topHTMLSelectorMatchesBasedOnRuleHash; }

When possible I prefer booleans that read like sentences “rule data <xxx>”. The first and third names here don’t really work that way.
Comment 4 Antti Koivisto 2011-02-10 02:43:41 PST
http://trac.webkit.org/changeset/78183