New issue
Advanced search Search tips

Issue 712559 link

Starred by 1 user

Issue metadata

Status: Fixed
Owner:
Closed: Apr 2017
Cc:
Components:
EstimatedDays: ----
NextAction: ----
OS: ----
Pri: 2
Type: Bug

Blocking:
issue 699838



Sign in to add a comment

Distribution calculation happens even when v1 shadow tree doesn't have a slot

Project Member Reported by hayato@chromium.org, Apr 18 2017

Issue description

The context: https://crbug.com/699838

It looks Blink recursively traverses down all shadow trees to *calculate* distribution even when a slot is not used at all there.

It looks wasteful, and actually consumes some time budget, though it is
not significant.

I think we can skip that because a distribution recalc flag is now set lazily (dynamically) when a relevant DOM mutation happens.

 

Comment 1 by hayato@chromium.org, Apr 19 2017

See the attached picture. We should remove the red circle part.
skip-distribution.png
186 KB View Download
Project Member

Comment 2 by bugdroid1@chromium.org, Apr 19 2017

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

commit a9c70fe4e42df88f817cb00cbc13a98b7727d99f
Author: hayato <hayato@chromium.org>
Date: Wed Apr 19 10:42:07 2017

Do not set a distribution recalc flag when v1 shadow tree is added

After rewriting Shadow DOM distribution engine for v1 [1], we no longer
need to set a distribution recalc flag when a v1 shadow tree is added.

A distribution recalc flag will be set correctly later, if necessary, when a
slot is inserted, removed, or other relevant DOM mutation happens.

Instead of setting recalc flag, host's children need to be lazy reattached in
adding a shadow root, which would be done in resolve assignments if we set a
distribution recalc flag.

This optimization would make loading slightly faster when there are many shadow
trees which will not have a slot because we do not need to traverse down the
trees. In the case of bug 699838, this can make loading 5ms (at most) faster.

[1] https://codereview.chromium.org/1995203002

BUG= 712559 

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

[add] https://crrev.com/a9c70fe4e42df88f817cb00cbc13a98b7727d99f/third_party/WebKit/LayoutTests/shadow-dom/layout-1-expected.html
[add] https://crrev.com/a9c70fe4e42df88f817cb00cbc13a98b7727d99f/third_party/WebKit/LayoutTests/shadow-dom/layout-1.html
[modify] https://crrev.com/a9c70fe4e42df88f817cb00cbc13a98b7727d99f/third_party/WebKit/Source/core/dom/shadow/ElementShadow.cpp

Comment 3 by hayato@chromium.org, Apr 19 2017

Status: Fixed (was: Assigned)

Sign in to add a comment