New issue
Advanced search Search tips
Note: Color blocks (like or ) mean that a user may not be available. Tooltip shows the reason.

Issue 624277 link

Starred by 3 users

Issue metadata

Status: Fixed
Owner:
NOT IN USE
Closed: Aug 2016
Cc:
Components:
EstimatedDays: ----
NextAction: ----
OS: All
Pri: 3
Type: Bug



Sign in to add a comment

Use invalidation sets for sibling mutations affected by :nth-* selectors

Reported by r...@opera.com, Jun 29 2016

Issue description

We resort to using SubtreeStyleChange [1] on the parent of inserted/removed elements when siblings are affected by :nth-* selectors. See if we can utilize invalidation sets to do less recalculations for such changes.

[1] https://codesearch.chromium.org/chromium/src/third_party/WebKit/Source/core/dom/ContainerNode.cpp?q=checkForSiblingStyleChanges&sq=package:chromium&dr=CSs&l=1237-1241

 

Comment 1 by r...@opera.com, Jun 29 2016

Also, for other positional pseudo classes like :first-child, etc.

Comment 2 by r...@opera.com, Aug 10 2016

Status: Started (was: Available)
Project Member

Comment 3 by bugdroid1@chromium.org, Aug 12 2016

The following revision refers to this bug:
  https://chromium.googlesource.com/chromium/src.git/+/1ba555726fbc99f2eb999a97a69c728b31ca1cc5

commit 1ba555726fbc99f2eb999a97a69c728b31ca1cc5
Author: rune <rune@opera.com>
Date: Fri Aug 12 14:36:24 2016

Use invalidation sets for nth invalidations.

Invalidate siblings of inserted/removed elements for :nth type changes
by scheduling a descendant invalidation set on the parent node of the
inserted element.

There is currently one such set for all structural pseudo classes with
the exception of :first-child, :last-child, and :only-child, which have
their own sets and may have so since they can't affect arbitrary
siblings.

The descendant set never has invalidatesSelf since it's scheduled on
the parent node of where the actual change happens.

Structural pseudo classes in the righmost compound adds rightmost
compound features to the descendant set:

  .a:nth-child(3n) {} => adds ".a" to the descendant set.

Righmost compound structural pseudo classes where there are no other
features makes the descendant set have wholeSubtreeInvalid since all
siblings where the mutation happens have to be invalidated:

  :nth-child(3n) {} => setWholeSubtreeInvalid()

Sibling selectors turns into descendant features:

  :nth-child(3n) + .a {} => adds ".a" to the descendant set.

Descendant selectors causes features to be added as normal:

  :nth-child(3n) .a {} => adds ".a" to the descendant set.

This approach isn't super optimal since having a rightmost structural
pseudo without other features in the compound will cause nth-
invalidations to still be full subtree invalidations, but it should be
a good first iteration.

What we could do is something along the lines of what sibling
invalidations do where they have a maximum number of siblings a set
applies to. The nth-invalidation where the pseudo is in the rightmost
compound really needs to invalidation all siblings and not their
descendants. We could have some notion of removing descendant sets
which should no longer apply walking down the tree.

Traversing siblings scheduling invalidation sets on them was not chosen
for the same reason we schedule siblings invalidations as descendant
invalidations on the parent node for sibling mutations already.

R=esprehn@chromium.org,ericwilligers@chromium.org
BUG= 624277 

Review-Url: https://codereview.chromium.org/2235723002
Cr-Commit-Position: refs/heads/master@{#411647}

[modify] https://crrev.com/1ba555726fbc99f2eb999a97a69c728b31ca1cc5/third_party/WebKit/LayoutTests/fast/css/invalidation/nth-pseudo.html
[modify] https://crrev.com/1ba555726fbc99f2eb999a97a69c728b31ca1cc5/third_party/WebKit/Source/core/css/RuleFeature.cpp
[modify] https://crrev.com/1ba555726fbc99f2eb999a97a69c728b31ca1cc5/third_party/WebKit/Source/core/css/RuleFeature.h
[modify] https://crrev.com/1ba555726fbc99f2eb999a97a69c728b31ca1cc5/third_party/WebKit/Source/core/css/RuleFeatureSetTest.cpp
[modify] https://crrev.com/1ba555726fbc99f2eb999a97a69c728b31ca1cc5/third_party/WebKit/Source/core/css/invalidation/StyleInvalidator.cpp
[modify] https://crrev.com/1ba555726fbc99f2eb999a97a69c728b31ca1cc5/third_party/WebKit/Source/core/css/invalidation/StyleInvalidator.h
[modify] https://crrev.com/1ba555726fbc99f2eb999a97a69c728b31ca1cc5/third_party/WebKit/Source/core/dom/ContainerNode.cpp
[modify] https://crrev.com/1ba555726fbc99f2eb999a97a69c728b31ca1cc5/third_party/WebKit/Source/core/dom/StyleEngine.cpp
[modify] https://crrev.com/1ba555726fbc99f2eb999a97a69c728b31ca1cc5/third_party/WebKit/Source/core/dom/StyleEngine.h

Comment 4 by r...@opera.com, Aug 12 2016

Owner: r...@opera.com

Comment 5 by r...@opera.com, Aug 16 2016

Status: Fixed (was: Started)
Split out potential optimization as  issue 638147 .
Project Member

Comment 6 by bugdroid1@chromium.org, Aug 19 2016

The following revision refers to this bug:
  https://chromium.googlesource.com/chromium/src.git/+/dae81dbb5e468db696af6994346b8e3acde7bb26

commit dae81dbb5e468db696af6994346b8e3acde7bb26
Author: ericwilligers <ericwilligers@chromium.org>
Date: Fri Aug 19 01:25:56 2016

CSS: RuleFeature::clear clears all invalidation sets

The recently added members m_universalSiblingInvalidationSet and
m_nthInvalidationSet were not being cleared in RuleFeature::clear().

For consistency, we now also clear these members.

BUG= 624277 

Review-Url: https://codereview.chromium.org/2253053002
Cr-Commit-Position: refs/heads/master@{#413001}

[add] https://crrev.com/dae81dbb5e468db696af6994346b8e3acde7bb26/third_party/WebKit/LayoutTests/fast/css/invalidation/rule-change.html
[modify] https://crrev.com/dae81dbb5e468db696af6994346b8e3acde7bb26/third_party/WebKit/Source/core/css/RuleFeature.cpp

Sign in to add a comment