Bug 77410 - <style scoped>: Improve shortcut code for cases where <style scoped> isn't used
Summary: <style scoped>: Improve shortcut code for cases where <style scoped> isn't used
Status: RESOLVED FIXED
Alias: None
Product: WebKit
Classification: Unclassified
Component: CSS (show other bugs)
Version: 528+ (Nightly build)
Hardware: Unspecified Unspecified
: P2 Normal
Assignee: Roland Steiner
URL:
Keywords:
Depends on:
Blocks: 73192
  Show dependency treegraph
 
Reported: 2012-01-31 00:58 PST by Roland Steiner
Modified: 2012-01-31 03:04 PST (History)
5 users (show)

See Also:


Attachments
Patch (5.11 KB, patch)
2012-01-31 01:02 PST, Roland Steiner
koivisto: review+
koivisto: commit-queue-
Details | Formatted Diff | Diff

Note You need to log in before you can comment on or make changes to this bug.
Description Roland Steiner 2012-01-31 00:58:46 PST
When working on bug 73192 I noticed a few places where shortcut code for cases when <style scoped> isn't used at all could be improved. Esp. CSSStyleSelector::matchAuthorRules can skip a whole code block.
Comment 1 Roland Steiner 2012-01-31 01:02:44 PST
Created attachment 124680 [details]
Patch

Move shortcut out from setupScopingElementStack() to calling sites, where a larger chunk of work can be skipped.
Comment 2 WebKit Review Bot 2012-01-31 01:06:27 PST
Attachment 124680 [details] did not pass style-queue:

Failed to run "['Tools/Scripts/update-webkit']" exit_code: 9

Updating OpenSource
First, rewinding head to replay your work on top of it...
Applying: Fix compilation errors on build-webkit --debug --no-workers on mac.
Using index info to reconstruct a base tree...
Falling back to patching base and 3-way merge...
Auto-merging LayoutTests/ChangeLog
CONFLICT (content): Merge conflict in LayoutTests/ChangeLog
Auto-merging LayoutTests/platform/qt/Skipped
CONFLICT (content): Merge conflict in LayoutTests/platform/qt/Skipped
Failed to merge in the changes.
Patch failed at 0001 Fix compilation errors on build-webkit --debug --no-workers on mac.

When you have resolved this problem run "git rebase --continue".
If you would prefer to skip this patch, instead run "git rebase --skip".
To restore the original branch and stop rebasing run "git rebase --abort".

rebase refs/remotes/origin/master: command returned error: 1

Died at Tools/Scripts/update-webkit line 164.


If any of these errors are false positives, please file a bug against check-webkit-style.
Comment 3 Antti Koivisto 2012-01-31 01:14:11 PST
Comment on attachment 124680 [details]
Patch

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

> Source/WebCore/css/CSSStyleSelector.cpp:858
> +    if (!m_scopedAuthorStyles.isEmpty()) {
> +        // Match scoped author rules by traversing the scoped element stack (rebuild it if it got inconsistent).
> +        const Element* parent = m_element->parentOrHostElement();
> +        if (!scopingElementStackIsConsistent(parent))
> +            setupScopingElementStack(parent);
> +        for (size_t i = m_scopingElementStack.size(); i; --i) {
> +            collectMatchingRules(m_scopingElementStack[i - 1].m_ruleSet, firstRuleIndex, lastRuleIndex, includeEmptyRules);
> +            collectMatchingRulesForRegion(m_scopingElementStack[i - 1].m_ruleSet, firstRuleIndex, lastRuleIndex, includeEmptyRules);
> +        }
> +        // Also include the current element.
> +        RuleSet* ruleSet = scopedRuleSetForElement(m_element);
> +        if (ruleSet) {
> +            collectMatchingRules(ruleSet, firstRuleIndex, lastRuleIndex, includeEmptyRules);
> +            collectMatchingRulesForRegion(ruleSet, firstRuleIndex, lastRuleIndex, includeEmptyRules);
> +        }
>      }

The code inside if (!m_scopedAuthorStyles.isEmpty())  could be factored into a function, matchScopedAuthorRules() or something.
Comment 4 Roland Steiner 2012-01-31 03:04:25 PST
Committed r106351: <http://trac.webkit.org/changeset/106351>