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

Issue 659596 link

Starred by 2 users

Issue metadata

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

Blocked on:
issue 661914



Sign in to add a comment

:host rules don't apply after style is loaded via <link> tag

Reported by azar...@gmail.com, Oct 26 2016

Issue description

Chrome Version       : 54.0.2840.71 (64-bit)
Other browsers tested: NO

What steps will reproduce the problem?
Load css styles to a custom element using <link> tag (the style should contain rules affecting the height). 

What is the expected result?
customElement.scrollHeight/offsetHeight etc to be updated.

What happens instead?
customElement.scrollHeight/offsetHeight etc doesn't update

Additional info:
Example (plunker):
viewer: https://embed.plnkr.co/xFISoDytfNit2Rb9aOEI/
editor: https://plnkr.co/edit/xFISoDytfNit2Rb9aOEI?p=preview

Everything works as expected if use <style> tag instead of <link>



 
Components: -Blink Blink>CSS Blink>DOM

Comment 2 by nainar@chromium.org, Oct 26 2016

Components: -Blink>CSS
Status: Untriaged (was: Unconfirmed)

Comment 3 by tkent@chromium.org, Oct 28 2016

Components: -Blink>DOM Blink>HTML>CustomElements
Components: Blink>DOM>ShadowDOM
Status: Available (was: Untriaged)
Thanks for filing this bug.

Here's something I can't work out. I've made this variant of your repro which just uses shadow DOM:

https://embed.plnkr.co/eE0MYnP22zGPgascHwvy/

The key difference is this works--the host element's scroll height is non-zero all along.

Comment 5 Deleted

Cc: -kojii@chromium.org
Components: -Blink>HTML>CustomElements
OK, I think I have worked out what's happening here. This looks like a shadow DOM issue, here's a repro:

https://embed.plnkr.co/DG32MUv1JC4vAuVlJr1t/

What's happening here is if you load a stylesheet with a <link rel> in shadow DOM in M54, styles apply to the shadow DOM but :host rules do not apply.

Because the 'link rel' host has height: auto from the UA stylesheet, scrollHeight is 0.

If you populate it with inline styles, the :host rules work and the host gets display: block and scrollHeight starts returning a number.
Summary: :host rules don't apply after style is loaded via <link> tag (was: Custom Elements v1: Custom element doesn't update its height after style is loaded via <link> tag)

Comment 8 by azar...@gmail.com, Oct 31 2016

Hi dominicc. Thanks for your investigation. 
Just want to add or clarify that adding even an empty style tag to the shadow dom fixes the problem.
See updated example (customComponentWorking.js look for //HACK comment):
https://embed.plnkr.co/xFISoDytfNit2Rb9aOEI/

Cc: hayato@chromium.org
Components: Blink>CSS
Status: Untriaged (was: Available)
That's interesting; there's an element of dynamism to it. Let me flip this back to untriaged so hayato can retriage it. Every indication is that this is a shadow DOM issue.
Components: -Blink>CSS
Removing the Blink>CSS component for now so that we have one owner. Feel free to reassign if this turns out not to be related to shadow DOM.
Component != Owner, and I don't see how :host is not related to shadow DOM,
but CSS is your label so apply it as you see fit :)

Comment 12 by r...@opera.com, Nov 2 2016

Cc: r...@opera.com
With https://embed.plnkr.co/xFISoDytfNit2Rb9aOEI/ , none of the cases are working for me on master content_shell. I get white background and 0, 0 on both.

Comment 13 by r...@opera.com, Nov 2 2016

Components: -Blink>DOM>ShadowDOM Blink>CSS
Owner: r...@opera.com
Status: Started (was: Untriaged)
Labels: Blink-Only
Project Member

Comment 16 by bugdroid1@chromium.org, Nov 4 2016

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

commit 4215d863dcedd407dc69d31addc731a7bc80a7e8
Author: rune <rune@opera.com>
Date: Fri Nov 04 07:25:27 2016

Remove ShadowRoot::numberOfStyles().

This probably used to be an optimization which made sense when we had
<style scoped> implemented. Now, it should be equally cheap to just
check the ScopedStyleResolver member. The ScopedStyleResolver is null
when there are no active stylesheets in the tree-scope.

This also caused  issue 659596  because we only registered style elements
and not link elements, which lead the code to believe there were no
rules to match from the scope when there were only link stylesheets
present.

R=kochi@chromium.org,hayato@chromium.org
BUG= 659596 

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

[add] https://crrev.com/4215d863dcedd407dc69d31addc731a7bc80a7e8/third_party/WebKit/LayoutTests/shadow-dom/host-link-style.html
[modify] https://crrev.com/4215d863dcedd407dc69d31addc731a7bc80a7e8/third_party/WebKit/Source/core/css/resolver/StyleResolver.cpp
[modify] https://crrev.com/4215d863dcedd407dc69d31addc731a7bc80a7e8/third_party/WebKit/Source/core/dom/StyleElement.cpp
[modify] https://crrev.com/4215d863dcedd407dc69d31addc731a7bc80a7e8/third_party/WebKit/Source/core/dom/StyleElement.h
[modify] https://crrev.com/4215d863dcedd407dc69d31addc731a7bc80a7e8/third_party/WebKit/Source/core/dom/shadow/ShadowRoot.cpp
[modify] https://crrev.com/4215d863dcedd407dc69d31addc731a7bc80a7e8/third_party/WebKit/Source/core/dom/shadow/ShadowRoot.h
[modify] https://crrev.com/4215d863dcedd407dc69d31addc731a7bc80a7e8/third_party/WebKit/Source/core/html/HTMLStyleElement.cpp
[modify] https://crrev.com/4215d863dcedd407dc69d31addc731a7bc80a7e8/third_party/WebKit/Source/core/svg/SVGStyleElement.cpp

Comment 17 by r...@opera.com, Nov 4 2016

Status: Fixed (was: Started)

Comment 18 by azar...@gmail.com, Nov 5 2016

What version of Chrome will have this fix?

Comment 19 by r...@opera.com, Nov 7 2016

It will be in 56 if not merged to 55. hayato@, should I request a merge to 55?

Yeah, I think it is okay to merge this to 55. Thank you for the quick fix.

Comment 21 by r...@opera.com, Nov 8 2016

Labels: Merge-Request-55

Comment 22 by dimu@chromium.org, Nov 8 2016

Labels: -Merge-Request-55 Merge-Approved-55 Hotlist-Merge-Approved
Your change meets the bar and is auto-approved for M55 (branch: 2883)
Project Member

Comment 23 by bugdroid1@chromium.org, Nov 8 2016

Labels: -merge-approved-55 merge-merged-2883
The following revision refers to this bug:
  https://chromium.googlesource.com/chromium/src.git/+/0d29461d46ced2af6740e0a9255a35f0bb8e48d2

commit 0d29461d46ced2af6740e0a9255a35f0bb8e48d2
Author: Rune Lillesveen <rune@opera.com>
Date: Tue Nov 08 08:47:48 2016

Remove ShadowRoot::numberOfStyles().

This probably used to be an optimization which made sense when we had
<style scoped> implemented. Now, it should be equally cheap to just
check the ScopedStyleResolver member. The ScopedStyleResolver is null
when there are no active stylesheets in the tree-scope.

This also caused  issue 659596  because we only registered style elements
and not link elements, which lead the code to believe there were no
rules to match from the scope when there were only link stylesheets
present.

R=kochi@chromium.org,hayato@chromium.org
BUG= 659596 

Review-Url: https://codereview.chromium.org/2472613004
Cr-Commit-Position: refs/heads/master@{#429824}
(cherry picked from commit 4215d863dcedd407dc69d31addc731a7bc80a7e8)

Review URL: https://codereview.chromium.org/2488633002 .

Cr-Commit-Position: refs/branch-heads/2883@{#491}
Cr-Branched-From: 614d31daee2f61b0180df403a8ad43f20b9f6dd7-refs/heads/master@{#423768}

[add] https://crrev.com/0d29461d46ced2af6740e0a9255a35f0bb8e48d2/third_party/WebKit/LayoutTests/shadow-dom/host-link-style.html
[modify] https://crrev.com/0d29461d46ced2af6740e0a9255a35f0bb8e48d2/third_party/WebKit/Source/core/css/resolver/StyleResolver.cpp
[modify] https://crrev.com/0d29461d46ced2af6740e0a9255a35f0bb8e48d2/third_party/WebKit/Source/core/dom/StyleElement.cpp
[modify] https://crrev.com/0d29461d46ced2af6740e0a9255a35f0bb8e48d2/third_party/WebKit/Source/core/dom/StyleElement.h
[modify] https://crrev.com/0d29461d46ced2af6740e0a9255a35f0bb8e48d2/third_party/WebKit/Source/core/dom/shadow/ShadowRoot.cpp
[modify] https://crrev.com/0d29461d46ced2af6740e0a9255a35f0bb8e48d2/third_party/WebKit/Source/core/dom/shadow/ShadowRoot.h
[modify] https://crrev.com/0d29461d46ced2af6740e0a9255a35f0bb8e48d2/third_party/WebKit/Source/core/html/HTMLStyleElement.cpp
[modify] https://crrev.com/0d29461d46ced2af6740e0a9255a35f0bb8e48d2/third_party/WebKit/Source/core/svg/SVGStyleElement.cpp

Comment 24 by azar...@gmail.com, Nov 8 2016

Thank you all guys!
Labels: Needs-Feedback
Tested the issue on windows-7, Mac-10.11.6 and Linux Ubuntu-14.04 using chrome Beta-55.0.2883.44 with the below steps
1.opened chrome
2.Navigated to the urls  https://embed.plnkr.co/xFISoDytfNit2Rb9aOEI/
                         https://plnkr.co/edit/xFISoDytfNit2Rb9aOEI?p=preview and reload the page
Observed the output as per the screen-cast(55.0.2883.44.mp4).
Please find the attached screen-cast and please confirm is it the expected behavior?
Note: Please find the reported version screen-cast(54.0.2840.71)


Thanks..

55.0.2883.44.mp4
878 KB View Download
54.0.2840.71.mp4
683 KB View Download
Cc: sureshkumari@chromium.org

Comment 27 by r...@opera.com, Nov 9 2016

The unstyled content on reload does not happen for me on ToT content_shell.

Status: Assigned (was: Fixed)
As stated in Comment#25 and I checked this on Chrome version 55.0.2883.44, I still see similar behavior as shown in comment#25 video.

hence relabeling the status back to assigned.
Labels: ReleaseBlock-Stable

Comment 30 by r...@opera.com, Nov 9 2016

Have you tested a 56 build? If this works in 56 and for some reason not in 55, we could just revert from 55.

Yes I have checked this on M56 and it works fine, But consistently reproducible on M55(55.0.2883.44).

Comment 32 by r...@opera.com, Nov 11 2016

Building from M55 branch or tags gives me a completely white browser. I'm leaning towards reverting from M55.

Comment 33 by r...@opera.com, Nov 11 2016

I built 55.0.2883.47 which was apparently broken. I got 55.0.2883.44 to build and run. Looking ...

Comment 34 by r...@opera.com, Nov 11 2016

We need to cherry-pick the fix for  issue 661914  as well.

Comment 35 by r...@opera.com, Nov 11 2016

Blockedon: 661914

Comment 36 by r...@opera.com, Nov 14 2016

Status: Fixed (was: Assigned)
Setting back to fixed since blocking issue has been merged.

Sign in to add a comment