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

Issue 704421 link

Starred by 3 users

Issue metadata

Status: Fixed
Owner:
Closed: Mar 2018
Cc:
Components:
EstimatedDays: ----
NextAction: ----
OS: All
Pri: 2
Type: Bug

Blocked on:
issue 704415
issue 819189


Show other hotlists

Hotlists containing this issue:
style-dev-current


Sign in to add a comment

getComputedStyle should not always force a layout for elements inside a shadow tree

Project Member Reported by esprehn@chromium.org, Mar 23 2017

Issue description

https://cs.chromium.org/chromium/src/third_party/WebKit/Source/core/css/CSSComputedStyleDeclaration.cpp?l=404

  bool forceFullLayout =
      isLayoutDependent(propertyID, style, layoutObject) ||
      styledNode->isInShadowTree() || <--- This is a bad, it's hiding bugs.
      (document.localOwner() &&
       document.styleEngine().hasViewportDependentMediaQueries());

This means doing getComputedStyle().color on an element in a shadow tree, or getComputedStyle().padding where padding is a fixed value like 5px will always do a layout, even though one wasn't needed.

When I remove this I fail these tests:

- fast/dom/shadow/sibling-rules-dynamic-changes.html
- fast/dom/shadow/sibling-rules-under-shadow-root.html

These tests seem to fail because Document::needsLayoutTreeUpdateForNode traverses up the tree using LayoutTreeBuilderTraversal::parent(), which skips ShadowRoots, so any bits or invalidation sets on a ShadowRoot are ignored.

- fast/alignment/parse-alignment-of-root-elements.html

This test fails because it's styling a <slot>, which returns false from canParticipateInFlatTree(), see  issue 704415 .

The same problem exists for invalidation sets that might be scheduled on an insertion point (<slot> or <content>). Since we skip those in LayoutTreeBuilderTraversal::parent() we never check the bits, and get the wrong answer.
 
Attached is a reduction of the sibling-rules-* test cases, since we skip every ShadowRoot in the loop inside needsLayoutTreeUpdateForNode we don't handle those cases right without the forced layout.

Here's an ancient patch where I fixed it:
https://codereview.chromium.org/1649983003

And here's another where I fixed it a different way by traversing the scopes separately:
https://codereview.chromium.org/2775563002

In the new patch I also had the fix the canParticipateInFlatTree() bug since there's tests for styling <slot>'s these days...

rune@ What do you think?
sibling-invalidation-shadow-computed-style.html
658 bytes View Download

Comment 2 by r...@opera.com, Mar 23 2017

Cc: eco...@igalia.com
I think we can actually make slots part of the flat tree now without shipping display:contents entirely because Emilio landed the code for layout tree building for display:contents on real dom elements already (pseudo elements in progress).

Unless I'm ignoring some important details here, I think we can support slots in the flat tree by:

1. Allow slots in Node::canParticipateInFlatTree
2. Possibly remove some other isSlot hardcoded checks
3. Allow display:contents in UASheetMode, or hardcode additional slot check in hasDisplayContentsStyle()

Comment 3 by r...@opera.com, Mar 23 2017

Looking at it, there's quite a bit of code changes necessary in FlatTreeTraversal to include slot elements in the flat tree.

Cc: dominicc@chromium.org
Components: -Blink>DOM>ShadowDOM Blink>CSS
meade, can your team work on this?

Comment 5 by eco...@igalia.com, Apr 18 2017

> 3. Allow display:contents in UASheetMode, or hardcode additional slot check in hasDisplayContentsStyle()

Just as a heads-up, I believe the first one (allowing display: contents in UASheetMode) may not be as trivial, since it seems to me that the style could leak via inheritance (i.e., you could end up with arbitrarily deep display: contents elements using:

  <slot>
    <div style="display: inherit">
      <!-- ... -->
    </div>
  </slot>

(perhaps not a huge deal though? I recall safari having a hardcoded display: contents implementation for <slot>, don't know if you can inherit from it correctly).

Comment 6 by nainar@chromium.org, Apr 18 2017

Cc: nainar@chromium.org

Comment 7 by meade@chromium.org, Apr 18 2017

Hi! We won't have time to work on it in Q2 as we've already got a lot on our plates. I can add it to our list of stuff to consider in Q3 though.

Comment 8 by nainar@chromium.org, Apr 18 2017

An option is landing esprehn@'s change (https://codereview.chromium.org/2775563002) which fixes this issue since all it requires is them hitting Commit :P 

And then we can raise a separate bug for adding slots to FlatTree traversal. 

Would that be preferable to folks? Or would you rather we make the larger change at the same time? 

Comment 9 by hayato@chromium.org, Apr 18 2017

> And then we can raise a separate bug for adding slots to FlatTree traversal. 

The bug is here:
https://bugs.chromium.org/p/chromium/issues/detail?id=660265


Re: comment #2

> I think we can actually make slots part of the flat tree now without shipping display:contents entirely because Emilio landed the code for layout tree building for display:contents on real dom elements already (pseudo elements in progress).

I think flex layout would be broken if we make slots part of the flat tree without shipping dispaly:contents. I have heard that Polymer is using flex layout with slot.

So here is the problem; when should we make slot part of the flat tree?
I thought that we should do it *after* display:contents is shipped.


If we make slot "display:contents", internally, without shipping "display:contents", I think we can make slots part of the flat tree without shipping "display:contents".

I am afraid that I won't have time to work on  bug 660265  in Q2, but if  bug 660265  is blocking someone and we can start to work on  bug 660265  without waiting for shipping "display: contents", please let me know it.
Status: Available (was: Untriaged)
Labels: Performance
Labels: Update-Monthly
Labels: -Performance Performance-Loading

Comment 16 by shend@chromium.org, Sep 28 2017

Cc: shend@chromium.org

Comment 17 by meade@chromium.org, Nov 27 2017

Labels: -Update-Monthly BlockedBug Update-Quarterly
Updated code link: https://cs.chromium.org/chromium/src/third_party/WebKit/Source/core/css/CSSComputedStyleDeclaration.cpp?l=346
Labels: -Update-Quarterly
Cc: -r...@opera.com
Owner: futhark@chromium.org
Status: Started (was: Available)
Blockedon: 819189
Labels: -Pri-3 Pri-2
Project Member

Comment 22 by bugdroid1@chromium.org, Mar 10 2018

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

commit 913382f37e466b5e59a57445e36ff5e8ef9f6f13
Author: Rune Lillesveen <futhark@chromium.org>
Date: Sat Mar 10 20:20:21 2018

Don't always force recalc for getComputedStyle in shadow trees.

We used to force clean style and layout tree getComputedStyle queries to
elements inside shadow trees. This was because the traversal in
Document::NeedsLayoutTreeUpdateForNode() skipped slots and shadow roots.
Now that slots are included in the flat tree, we can simply add checks
for shadow roots walking up the flat tree.

TEST=fast/dom/shadow/sibling-rules-under-shadow-root.html

Bug:  704421 
Change-Id: Iee46f326ea96c0a4fad3e09b7784cf86d1dcdc85
Reviewed-on: https://chromium-review.googlesource.com/950042
Commit-Queue: Rune Lillesveen <futhark@chromium.org>
Reviewed-by: Hayato Ito <hayato@chromium.org>
Cr-Commit-Position: refs/heads/master@{#542386}
[modify] https://crrev.com/913382f37e466b5e59a57445e36ff5e8ef9f6f13/third_party/WebKit/Source/core/BUILD.gn
[modify] https://crrev.com/913382f37e466b5e59a57445e36ff5e8ef9f6f13/third_party/WebKit/Source/core/css/CSSComputedStyleDeclaration.cpp
[add] https://crrev.com/913382f37e466b5e59a57445e36ff5e8ef9f6f13/third_party/WebKit/Source/core/css/CSSComputedStyleDeclarationTest.cpp
[modify] https://crrev.com/913382f37e466b5e59a57445e36ff5e8ef9f6f13/third_party/WebKit/Source/core/dom/Document.cpp

Status: Fixed (was: Started)

Sign in to add a comment