Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(47)

Issue 1889993002: Implemented RuleSet diff for active stylesheets. (Closed)

Created:
4 years, 8 months ago by rune
Modified:
4 years, 3 months ago
Reviewers:
Timothy Loh, esprehn
CC:
darktears, apavlov+blink_chromium.org, blink-reviews, blink-reviews-css, blink-reviews-style_chromium.org, chromium-reviews, dglazkov+blink, rwlbuis
Base URL:
https://chromium.googlesource.com/chromium/src.git@master
Target Ref:
refs/pending/heads/master
Project:
chromium
Visibility:
Public.

Description

Implemented RuleSet diff for active stylesheets. This is an implementation of the diffing of active stylesheets outlined in [1] to replace the current compareStyleSheets method in TreeScopeStyleSheetCollection which currently cause a "Reconstruct" if you both have insertions and removals. With async stylesheet update we will more likely end up in those situations as changes to the list can happen in a batches. An important new aspect here is that together with each stylesheet keep a traced pointer to the RuleSet it had reference last time the active stylesheet list was updated. That way we can figure out what changed on media query and CSSOM changes. The comparison algorithm works like this: INPUTS: The new and old active stylesheet vectors OUTPUTS: A vector of added and removed RuleSets. Also a return value saying if we only appended stylesheets at the end. Given that sheets were only appended we can do certain optimizations updating rule data. * First linearly walk the old and new active list as long as the stylesheet pointers are the same. If the ruleset changed for the given sheet, add the old and new rulesets to the list of changed rulesets. * If we are finished walking any of the active lists, we have either appended a set of sheets to the end, or we have removed a set from the tail. Add the added/removed rulesets to the changed list and we are finished. * If we have remaining sheets in both the old and new active list, merge the remaining items from both lists and sort the merged vector on stylesheet pointers. For stylesheet pointers occuring in pairs, if the rulesets are different for the two entries, the ruleset changed so we add them to the changed list. For stylesheets which do not occur in pairs, they are either added or removed and we add the ruleset to the changed list. The time complexity for the algorithm is O(k) for the common prefix and the complexity for std::sort for the m + n remaining sheets in the new and old active lists. Note that each scope has its active list, so the larger n's will be for the document scope as shadow trees most often have a single stylesheet (I measured a max of three running some Polymer apps). An assumption here is that we will do ensureRuleSet() including media query evaluation for the media attribute as we collect active stylesheets. Currently, the analysis of which elements needs a style recalc happens synchronously while updating the active sheets while the rulesets are (re-)created asynchronously/on-demand via lazyAppendAuthorStyleSheets in StyleResolver. The idea is that since the active stylesheet update will be async, we can drop the lazyAppend things from StyleResolver and add the stylesheets directly to the ScopedStyleResolvers during the active stylesheet update. Creating the RuleSets as we collect active stylesheets means we have invalidation sets readily available to use style invalidation to trigger style recalcs only on elements affected by the added/removed stylesheets. [1] http://bit.ly/25uxtnU R=esprehn@chromium.org,timloh@chromium.org BUG=567021 Committed: https://crrev.com/f9d162281661e2fb8805814513a549683775d56b Cr-Commit-Position: refs/heads/master@{#416520}

Patch Set 1 #

Patch Set 2 : Fixed typo #

Patch Set 3 : Rebased #

Patch Set 4 : Use changed instead of added/removed #

Patch Set 5 : Rebased. #

Patch Set 6 : Missing CORE_EXPORT. #

Patch Set 7 : Rebased. #

Unified diffs Side-by-side diffs Delta from patch set Stats (+313 lines, -0 lines) Patch
M third_party/WebKit/Source/core/BUILD.gn View 1 2 3 4 5 6 1 chunk +1 line, -0 lines 0 comments Download
A third_party/WebKit/Source/core/css/ActiveStyleSheets.h View 1 2 3 4 5 1 chunk +31 lines, -0 lines 0 comments Download
A third_party/WebKit/Source/core/css/ActiveStyleSheets.cpp View 1 2 3 1 chunk +86 lines, -0 lines 0 comments Download
A third_party/WebKit/Source/core/css/ActiveStyleSheetsTest.cpp View 1 2 3 1 chunk +193 lines, -0 lines 0 comments Download
M third_party/WebKit/Source/core/css/BUILD.gn View 1 2 3 4 5 6 1 chunk +2 lines, -0 lines 0 comments Download

Messages

Total messages: 38 (14 generated)
rune
I have implemented active stylesheet comparison as outlined in the design document I sent to ...
4 years, 8 months ago (2016-04-14 21:17:39 UTC) #1
rune
@timloh, @esprehn: could you take a look at this, please?
4 years, 8 months ago (2016-04-20 20:57:13 UTC) #3
rune
ping
4 years, 8 months ago (2016-04-25 13:32:58 UTC) #4
esprehn
This seems fine, but I'm not sure why we need to know if sheets changed ...
4 years, 7 months ago (2016-04-28 02:49:14 UTC) #5
rune
On 2016/04/28 02:49:14, esprehn wrote: > This seems fine, but I'm not sure why we ...
4 years, 7 months ago (2016-04-28 07:32:13 UTC) #6
esprehn
On 2016/04/28 at 07:32:13, rune wrote: > On 2016/04/28 02:49:14, esprehn wrote: > > This ...
4 years, 7 months ago (2016-05-17 22:28:46 UTC) #7
rune
On 2016/05/17 22:28:46, esprehn wrote: > On 2016/04/28 at 07:32:13, rune wrote: > > On ...
4 years, 7 months ago (2016-05-18 09:03:17 UTC) #8
rune
On 2016/05/18 09:03:17, rune wrote: > On 2016/05/17 22:28:46, esprehn wrote: > > Can we ...
4 years, 7 months ago (2016-05-18 13:15:27 UTC) #10
esprehn
Hmm, I must be confused, I'm still not sure why we need this prefix matching ...
4 years, 6 months ago (2016-06-01 05:16:10 UTC) #11
rune
On 2016/06/01 05:16:10, esprehn wrote: > Hmm, I must be confused, I'm still not sure ...
4 years, 6 months ago (2016-06-01 07:59:29 UTC) #12
esprehn
On 2016/06/01 at 07:59:29, rune wrote: > ... > Will you be at BlinkOn in ...
4 years, 6 months ago (2016-06-11 11:56:48 UTC) #13
esprehn
So what's the status here? Should I review this?
4 years, 5 months ago (2016-06-29 04:45:36 UTC) #14
rune
On 2016/06/29 04:45:36, esprehn wrote: > So what's the status here? Should I review this? ...
4 years, 5 months ago (2016-06-29 08:04:53 UTC) #15
rune
ping, see comment #12.
4 years, 4 months ago (2016-08-08 09:40:09 UTC) #16
esprehn
lgtm
4 years, 3 months ago (2016-09-01 23:15:45 UTC) #17
commit-bot: I haz the power
CQ is trying da patch. Follow status at https://chromium-cq-status.appspot.com/v2/patch-status/codereview.chromium.org/1889993002/80001
4 years, 3 months ago (2016-09-02 14:09:53 UTC) #20
commit-bot: I haz the power
Try jobs failed on following builders: linux_chromium_compile_dbg_ng on master.tryserver.chromium.linux (JOB_FAILED, http://build.chromium.org/p/tryserver.chromium.linux/builders/linux_chromium_compile_dbg_ng/builds/151243)
4 years, 3 months ago (2016-09-02 14:38:56 UTC) #22
commit-bot: I haz the power
CQ is trying da patch. Follow status at https://chromium-cq-status.appspot.com/v2/patch-status/codereview.chromium.org/1889993002/100001
4 years, 3 months ago (2016-09-02 16:19:37 UTC) #25
commit-bot: I haz the power
Exceeded global retry quota
4 years, 3 months ago (2016-09-02 18:24:20 UTC) #27
commit-bot: I haz the power
CQ is trying da patch. Follow status at https://chromium-cq-status.appspot.com/v2/patch-status/codereview.chromium.org/1889993002/100001
4 years, 3 months ago (2016-09-05 08:18:44 UTC) #29
commit-bot: I haz the power
Try jobs failed on following builders: cast_shell_linux on master.tryserver.chromium.linux (JOB_FAILED, http://build.chromium.org/p/tryserver.chromium.linux/builders/cast_shell_linux/builds/219137) mac_chromium_compile_dbg_ng on master.tryserver.chromium.mac (JOB_FAILED, ...
4 years, 3 months ago (2016-09-05 08:21:01 UTC) #31
commit-bot: I haz the power
CQ is trying da patch. Follow status at https://chromium-cq-status.appspot.com/v2/patch-status/codereview.chromium.org/1889993002/120001
4 years, 3 months ago (2016-09-05 08:29:26 UTC) #34
commit-bot: I haz the power
Committed patchset #7 (id:120001)
4 years, 3 months ago (2016-09-05 10:18:26 UTC) #36
commit-bot: I haz the power
4 years, 3 months ago (2016-09-05 10:20:39 UTC) #38
Message was sent while issue was closed.
Patchset 7 (id:??) landed as
https://crrev.com/f9d162281661e2fb8805814513a549683775d56b
Cr-Commit-Position: refs/heads/master@{#416520}

Powered by Google App Engine
This is Rietveld 408576698