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

Issue 2059163002: Schedule sibling invalidation sets for sibling insert/remove. (Closed)

Created:
4 years, 6 months ago by rune
Modified:
4 years, 5 months ago
Reviewers:
esprehn, Eric Willigers
CC:
darktears, apavlov+blink_chromium.org, blink-reviews, blink-reviews-css, blink-reviews-dom_chromium.org, blink-reviews-style_chromium.org, chromium-reviews, dglazkov+blink, eae+blinkwatch, rwlbuis, sof, webcomponents-bugzilla_chromium.org
Base URL:
https://chromium.googlesource.com/chromium/src.git@master
Target Ref:
refs/pending/heads/master
Project:
chromium
Visibility:
Public.

Description

Schedule sibling invalidation sets for sibling insert/remove. Invalidation sets have been used only for changes which do not alter the tree structure, like changing id, class names, other attributes, and pseudo states. For dom tree changes, style invalidation relies on attach and detach of the layout tree for the inserted/removed element. For subsequent siblings of inserted/removed elements, we have been marking siblings for subtree recalc (when we know we have tried to match adjacent combinators on one of the siblings before) based on the maximum number of consecutive direct adjacent combinators or all subsequent siblings for indirect adjacent combinators. This CL starts using sibling invalidation sets on siblings instead of doing subtree recalcs. The following properties of invalidation sets affected how this first implementation was done: * Even though we invalidate descendants/siblings based on tag names, we don't have invalidation sets for tag names as elements do not change tag names dynamically. For inserted/removed elements, we could have used invalidation sets for tag names. Take the selector "div + span". If we remove a div we could have scheduled an invalidation set for div which invalidates a span sibling. * Invalidation sets for simple selectors and their negated versions, for instance ".a" and ":not(.a)", share invalidation sets and they may do so because invalidation sets have been applied when they change. That is, "a" is either part of old or the new class attribute when the invalidation set needs to be scheduled. When removing/inserting elements, a selector like ":not(.a) + .b" will need to schedule a sibling for ".a" for all elements not having the class "a". * Consider the selector "* + .a". We have to schedule a sibling invalidation for any inserted/removed element to invalidate a sibling with class "a". However, invalidation set construction has only created an invalidation set for ".a" with the invalidateSelf flag set. For this CL, we create a single universal sibling invalidation set to handle the cases above. In fact this CL only do sibling invalidations on element insert/remove for id, class, and attribute in addition to scheduling the universal sibling invalidation set. Also, we skip selector lists (that is, :not() and :-webkit-any() as :host() :host-context() and :slotted() never match when followed by an adjacent combinator). For the following set of selectors: :not(.a) + .b + .c #x:not(.a) + .d div + span :-webkit-any(.x) + .f .g We end up with the following universal sibling invalidation set with the descendant invalidation set, containing ".g", to the right. { .c, span, .f, invalidatesSelf } => { .g } Note that if a compound contains both :not() and for instance an id selector, we will not add it to the universal sibling invalidation set as we can properly invalidate ".d" siblings above using the invalidation set for "#x". == Scheduling sibling invalidations For changes not modifying the tree, we schedule sibling invalidation sets on the changed element and invalidate the siblings with descendant sets during the invalidation process. When removing an element, however, the element is not left in the tree, so we need to associate the invalidation set with another element. Given these siblings and the rules ".b + .c" and ".a + .b": div.a div.b div.c When we remove .b, we can schedule the invalidation set for .b on .a instead as that will invalidate .c as expected. However, if we remove .a, there is no preceding element to associate the invalidation set with. Instead we can schedule the invalidation set on .c, but also at the same time do the invalidation step for .c as the StyleInvalidator will start invalidating for sibling sets on subsequent siblings of the scheduling element. Additionaly, we need to reschedule already scheduled sibling invalidation sets for elements which are removed in order to not lose already scheduled invalidation set which have not been through the invalidator. == The effect on amazon.com This CL gets rid of all post-page-load full recalcs before you start interacting with the page. The full recalcs after you start interacting needs to be investigated further. BUG=542082

Patch Set 1 #

Patch Set 2 : Rebased #

Patch Set 3 : Works for removing multiple siblings by rescheduling sibling sets #

Patch Set 4 : Rebased #

Total comments: 2
Unified diffs Side-by-side diffs Delta from patch set Stats (+441 lines, -20 lines) Patch
A third_party/WebKit/LayoutTests/fast/css/invalidation/remove-multiple-siblings.html View 1 2 1 chunk +34 lines, -0 lines 0 comments Download
M third_party/WebKit/LayoutTests/fast/css/invalidation/sibling-inserted.html View 3 chunks +3 lines, -3 lines 0 comments Download
M third_party/WebKit/Source/core/css/RuleFeature.h View 4 chunks +8 lines, -0 lines 0 comments Download
M third_party/WebKit/Source/core/css/RuleFeature.cpp View 1 2 8 chunks +92 lines, -0 lines 2 comments Download
M third_party/WebKit/Source/core/css/RuleFeatureSetTest.cpp View 1 2 chunks +155 lines, -0 lines 0 comments Download
M third_party/WebKit/Source/core/css/invalidation/InvalidationSet.h View 1 2 1 chunk +1 line, -1 line 0 comments Download
M third_party/WebKit/Source/core/css/invalidation/StyleInvalidator.h View 1 2 1 chunk +2 lines, -0 lines 0 comments Download
M third_party/WebKit/Source/core/css/invalidation/StyleInvalidator.cpp View 1 2 1 chunk +40 lines, -0 lines 0 comments Download
M third_party/WebKit/Source/core/dom/CharacterData.cpp View 1 chunk +1 line, -1 line 0 comments Download
M third_party/WebKit/Source/core/dom/ContainerNode.h View 4 chunks +4 lines, -1 line 0 comments Download
M third_party/WebKit/Source/core/dom/ContainerNode.cpp View 1 2 5 chunks +25 lines, -10 lines 0 comments Download
M third_party/WebKit/Source/core/dom/Element.cpp View 1 2 3 2 chunks +2 lines, -2 lines 0 comments Download
M third_party/WebKit/Source/core/dom/StyleEngine.h View 1 2 1 chunk +4 lines, -1 line 0 comments Download
M third_party/WebKit/Source/core/dom/StyleEngine.cpp View 1 2 3 chunks +69 lines, -0 lines 0 comments Download
M third_party/WebKit/Source/core/dom/shadow/ShadowRoot.cpp View 1 chunk +1 line, -1 line 0 comments Download

Messages

Total messages: 17 (4 generated)
commit-bot: I haz the power
Dry run: CQ is trying da patch. Follow status at https://chromium-cq-status.appspot.com/patch-status/2059163002/60001
4 years, 6 months ago (2016-06-14 14:55:54 UTC) #2
commit-bot: I haz the power
Dry run: This issue passed the CQ dry run.
4 years, 6 months ago (2016-06-14 19:10:37 UTC) #4
esprehn
Very cool patch, can you expand the change description to explain what this does and ...
4 years, 6 months ago (2016-06-14 23:09:33 UTC) #5
rune
On 2016/06/14 23:09:33, esprehn wrote: > Very cool patch, can you expand the change description ...
4 years, 6 months ago (2016-06-16 08:16:34 UTC) #7
rune
4 years, 6 months ago (2016-06-16 08:18:14 UTC) #9
Eric Willigers
lgtm https://codereview.chromium.org/2059163002/diff/60001/third_party/WebKit/Source/core/css/RuleFeature.cpp File third_party/WebKit/Source/core/css/RuleFeature.cpp (right): https://codereview.chromium.org/2059163002/diff/60001/third_party/WebKit/Source/core/css/RuleFeature.cpp#newcode874 third_party/WebKit/Source/core/css/RuleFeature.cpp:874: universalSet.setInvalidatesSelf(); If this call is replaced with an ...
4 years, 6 months ago (2016-06-21 10:17:12 UTC) #10
rune
esprehn@: We discussed the potential n² problem for inserting n children with the presence of ...
4 years, 6 months ago (2016-06-22 09:00:19 UTC) #11
esprehn
I'll read through this tomorrow and see, I'm worried about the complexity and the possible ...
4 years, 6 months ago (2016-06-22 09:56:21 UTC) #12
rune
On 2016/06/22 09:56:21, esprehn wrote: > I'll read through this tomorrow and see, I'm worried ...
4 years, 6 months ago (2016-06-22 10:50:12 UTC) #13
rune
On 2016/06/22 10:50:12, rune wrote: > On 2016/06/22 09:56:21, esprehn wrote: > > I'll read ...
4 years, 6 months ago (2016-06-22 11:20:41 UTC) #14
rune
On 2016/06/22 11:20:41, rune wrote: > Technically, this looks possible, albeit ugly, if we cast ...
4 years, 6 months ago (2016-06-22 12:26:23 UTC) #15
rune
On 2016/06/22 12:26:23, rune wrote: > On 2016/06/22 11:20:41, rune wrote: > > Technically, this ...
4 years, 6 months ago (2016-06-22 23:23:19 UTC) #16
rune
4 years, 5 months ago (2016-07-01 10:58:12 UTC) #17
Message was sent while issue was closed.
On 2016/06/22 23:23:19, rune wrote:
> On 2016/06/22 12:26:23, rune wrote:
> > On 2016/06/22 11:20:41, rune wrote:
> > > Technically, this looks possible, albeit ugly, if we cast the
> > > SiblingInvalidationSet to a DescendantInvalidationSet as
> > > DescendantInvalidationSet does not add additional data members to the
> > > InvalidationSet base class. The only problem I've found is the checked
type
> > > conversion in StyleInvalidator::RecursionData::pushInvalidationSet(). But,
I
> > > don't think we need that conversion. We can just use the InvalidationSet
> type
> > > for that vector. I'll try out an alternative CL where I always schedule
> > > invalidation sets on the parent (even for direct siblings) and see where
we
> > get.
> > 
> > Need to be able to schedule invalidation sets on ShadowRoots as well, but
that
> > should be doable ...
> 
> Scheduling on parent attempt here: https://codereview.chromium.org/2089063005

Closing as the alternative approach landed.

Powered by Google App Engine
This is Rietveld 408576698