<?xml version="1.0" encoding="UTF-8" standalone="yes" ?>
<!DOCTYPE bugzilla SYSTEM "https://bugs.webkit.org/page.cgi?id=bugzilla.dtd">

<bugzilla version="5.0.4.1"
          urlbase="https://bugs.webkit.org/"
          
          maintainer="admin@webkit.org"
>

    <bug>
          <bug_id>111281</bug_id>
          
          <creation_ts>2013-03-03 19:29:41 -0800</creation_ts>
          <short_desc>[Shadow] Siblings of a shadow host with the same tag name incorrectly inherit background color specified in @host rule</short_desc>
          <delta_ts>2019-10-04 22:52:49 -0700</delta_ts>
          <reporter_accessible>1</reporter_accessible>
          <cclist_accessible>1</cclist_accessible>
          <classification_id>1</classification_id>
          <classification>Unclassified</classification>
          <product>WebKit</product>
          <component>CSS</component>
          <version>528+ (Nightly build)</version>
          <rep_platform>Unspecified</rep_platform>
          <op_sys>Unspecified</op_sys>
          <bug_status>RESOLVED</bug_status>
          <resolution>CONFIGURATION CHANGED</resolution>
          
          
          <bug_file_loc></bug_file_loc>
          <status_whiteboard></status_whiteboard>
          <keywords></keywords>
          <priority>P2</priority>
          <bug_severity>Normal</bug_severity>
          <target_milestone>---</target_milestone>
          
          <blocked>59827</blocked>
          <everconfirmed>1</everconfirmed>
          <reporter name="Dominic Cooney">dominicc</reporter>
          <assigned_to name="Dominic Cooney">dominicc</assigned_to>
          <cc>chris.khoo</cc>
    
    <cc>dglazkov</cc>
    
    <cc>dominicc</cc>
    
    <cc>rniwa</cc>
    
    <cc>sorvell</cc>
    
    <cc>tasak</cc>
          

      

      

      

          <comment_sort_order>oldest_to_newest</comment_sort_order>  
          <long_desc isprivate="0" >
    <commentid>846137</commentid>
    <comment_count>0</comment_count>
    <who name="Dominic Cooney">dominicc</who>
    <bug_when>2013-03-03 19:29:41 -0800</bug_when>
    <thetext>See the attached repro.</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>846138</commentid>
    <comment_count>1</comment_count>
      <attachid>191160</attachid>
    <who name="Dominic Cooney">dominicc</who>
    <bug_when>2013-03-03 19:30:24 -0800</bug_when>
    <thetext>Created attachment 191160
Repro</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>847378</commentid>
    <comment_count>2</comment_count>
    <who name="Dominic Cooney">dominicc</who>
    <bug_when>2013-03-05 00:30:47 -0800</bug_when>
    <thetext>This is a style sharing bug. StyleResolver::styleSharingCandidateMatchesHostRules only matches whether one of the elements matches host rules. Hence shared styles won&apos;t bleed from an element that ISN&apos;T targeted by @host rules to one that IS, but can bleed from an element that IS targeted by @host rules to one that ISN&apos;T. This is what we&apos;re seeing here.</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>848349</commentid>
    <comment_count>3</comment_count>
    <who name="Dominic Cooney">dominicc</who>
    <bug_when>2013-03-05 18:32:36 -0800</bug_when>
    <thetext>Elements that have Shadow DOM and are targeted by @host rules should not share styles.

The reason is basically the same reason why elements with &lt;style scoped&gt; children should not share styles. Their styles may be different to their siblings/cousins/etc. due to rules set in the scoped style.

The question is how to trade off how precisely we compute which elements can share styles, and what extra resources it takes to do that.

At one extreme of using no extra resources (directly) we can conservatively turn off sharing for all elements with Shadow DOM. The most unfortunate side effect is that many form controls use Shadow DOM internally; those will no longer be able to share styles.

At another extreme we can add a bit to ElementRareData which tracks whether an element is targeted by an @host rule, like the &quot;children affected by first child&quot; bits.

To chew up more cycles but no more bytes we could broaden the meaning of Node::hasScopedHTMLStyleChild from &lt;style scoped&gt; elements to include Shadow DOM with &lt;style&gt; elements containing @host rules. In future if the syntax of @host rules is broadened to also style descendants of the host, there&apos;s strong overlap in semantics between these two: The @host rules are like a &quot;virtual &lt;style scoped&gt;.&quot; It should also be straightforward to make it work with shared stylesheets added with the ShadowRoot::addStyleSheet API.

For now I am going to pursue this approach. Feedback or ideas welcome.</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>848560</commentid>
    <comment_count>4</comment_count>
    <who name="Dominic Cooney">dominicc</who>
    <bug_when>2013-03-06 00:32:49 -0800</bug_when>
    <thetext>My initial idea is complicated by the timing of calls: Style sharing resolves that the shadow host and ordinary div can share styles before the shadow host knows it bears a style element (via ShadowRoot::registerScopedHTMLStyleChild.)

I need to understand better the relationship between style sharing and style recalculation. It seems there is basically tension between wanting to share as many styles are possible, but having to use a conservative heuristic about which styles can be shared. I hope it is not necessary to go to such extremes as disabling style sharing for all shadow hosts, or reapplying styles to the sibling list of an element which becomes a shadow host.

I ran into some obviously smelly code: ShadowRoot uses the HasScopedHTMLStyleChild flag to mean &quot;has a style element in the subtree&quot; so it seems methods like (un)registerScopedHTMLStyleChild and hasScopedHTMLStyleChild need to be renamed, if not these responsibilities untangled. Maybe I should pick at that scab for a while as I contemplate this.</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>857844</commentid>
    <comment_count>5</comment_count>
    <who name="Takashi Sakamoto">tasak</who>
    <bug_when>2013-03-18 18:37:46 -0700</bug_when>
    <thetext>*** Bug 112590 has been marked as a duplicate of this bug. ***</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>1577189</commentid>
    <comment_count>6</comment_count>
    <who name="Ryosuke Niwa">rniwa</who>
    <bug_when>2019-10-04 22:52:49 -0700</bug_when>
    <thetext>@host isn&apos;t a thing anymore.</thetext>
  </long_desc>
      
          <attachment
              isobsolete="0"
              ispatch="0"
              isprivate="0"
          >
            <attachid>191160</attachid>
            <date>2013-03-03 19:30:24 -0800</date>
            <delta_ts>2013-03-03 19:30:24 -0800</delta_ts>
            <desc>Repro</desc>
            <filename>shadow-dom-template.html</filename>
            <type>text/html</type>
            <size>591</size>
            <attacher name="Dominic Cooney">dominicc</attacher>
            
              <data encoding="base64">PCFET0NUWVBFIGh0bWw+CjxkaXYgaWQ9Imhvc3QiPjwvZGl2Pgo8cD5TaG91bGQgbm90IGhhdmUg
YSB5ZWxsb3cgYmFja2dyb3VuZCAoYW5kIGRvZXMgbm90IGJlY2F1c2UgaXQgaXMgYSAmbHQ7cCZn
dDsuKQo8ZGl2PlNob3VsZCBub3QgaGF2ZSBhIHllbGxvdyBiYWNrZ3JvdW5kIChhbmQgZG9lczsg
aXQgaXMgYSAmbHQ7ZGl2Jmd0Oy4pPC9kaXY+Cgo8dGVtcGxhdGUgaWQ9InRlbXBsYXRlIj4KCTxz
dHlsZT4KCUBob3N0IHsKCQkqIHsKCQkJYmFja2dyb3VuZC1jb2xvcjogI2ZmZmYwMDsKCQl9Cgl9
CglzdHJvbmcgewoJCWNvbG9yOiAjZmYwMDAwOwoJfQoJPC9zdHlsZT4KCTxwPlNob3VsZCBoYXZl
IGEgeWVsbG93IGJhY2tncm91bmQ8L3A+CjwvdGVtcGxhdGU+Cgo8c2NyaXB0Pgp2YXIgZWx0ID0g
ZG9jdW1lbnQuZ2V0RWxlbWVudEJ5SWQoJ2hvc3QnKTsKdmFyIHNoYWRvdyA9IGVsdC53ZWJraXRD
cmVhdGVTaGFkb3dSb290KCk7CnZhciB0ZW1wbGF0ZSA9IGRvY3VtZW50LmdldEVsZW1lbnRCeUlk
KCd0ZW1wbGF0ZScpOwpzaGFkb3cuYXBwZW5kQ2hpbGQodGVtcGxhdGUuY29udGVudC5jbG9uZU5v
ZGUodHJ1ZSkpOwo8L3NjcmlwdD4K
</data>

          </attachment>
      

    </bug>

</bugzilla>