Bug 156235

Summary: Shadow DOM: :host() From The First Shadow Context Should Not Style All Shadow Context
Product: WebKit Reporter: Antti Koivisto <koivisto>
Component: DOMAssignee: Nobody <webkit-unassigned>
Status: RESOLVED FIXED    
Severity: Normal CC: rniwa, webkit-bug-importer
Priority: P2 Keywords: InRadar
Version: WebKit Nightly Build   
Hardware: Unspecified   
OS: Unspecified   
Attachments:
Description Flags
test
none
patch kling: review+

Description Antti Koivisto 2016-04-05 08:55:14 PDT
* SUMMARY
The first “:host()” context in a template seems to dictate the the “host” styles for all shadow context in the document. Quoting draft from here https://drafts.csswg.org/css-scoping/#host-selector (if it is up-to-date),:

“The :host pseudo-class, when evaluated in the context of a shadow tree, matches the shadow tree’s host element. In any other context, it matches nothing.”

* STEPS TO REPRODUCE
1. Open included test-case


* RESULTS
Expected: Host 2 from test case shold have a black border instead of pink.
Actual: Both hosts have pink borders.
Comment 1 Antti Koivisto 2016-04-05 08:55:56 PDT
Created attachment 275668 [details]
test
Comment 2 Antti Koivisto 2016-04-05 08:56:25 PDT
<rdar://problem/24668206>
Comment 3 Antti Koivisto 2016-04-05 09:11:31 PDT
Created attachment 275669 [details]
patch
Comment 4 Andreas Kling 2016-04-05 09:14:03 PDT
Comment on attachment 275669 [details]
patch

View in context: https://bugs.webkit.org/attachment.cgi?id=275669&action=review

r=me

> Source/WebCore/style/StyleSharingResolver.cpp:100
> +    if (element.shadowRoot() && !element.shadowRoot()->styleResolver().ruleSets().authorStyle()->hostPseudoClassRules().isEmpty())

This would look so nice if we made authorStyle() return a reference, too.

> Source/WebCore/style/StyleSharingResolver.cpp:287
> +    if (element.shadowRoot() && !element.shadowRoot()->styleResolver().ruleSets().authorStyle()->hostPseudoClassRules().isEmpty())

Mhm.
Comment 5 Antti Koivisto 2016-04-05 09:46:30 PDT
https://trac.webkit.org/r199060
Comment 6 Alex Christensen 2016-04-13 23:28:24 PDT
Comment on attachment 275669 [details]
patch

View in context: https://bugs.webkit.org/attachment.cgi?id=275669&action=review

> Source/WebCore/style/StyleSharingResolver.cpp:288
> +        return nullptr;

nullptr -> false 
:(
Comment 7 Antti Koivisto 2016-04-15 01:16:34 PDT
> nullptr -> false 
> :(

http://trac.webkit.org/changeset/199584