<?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>100451</bug_id>
          
          <creation_ts>2012-10-25 21:01:22 -0700</creation_ts>
          <short_desc>[Shadow DOM][Meta] Changing attribute does not cause distribution.</short_desc>
          <delta_ts>2012-11-19 18:14:09 -0800</delta_ts>
          <reporter_accessible>1</reporter_accessible>
          <cclist_accessible>1</cclist_accessible>
          <classification_id>1</classification_id>
          <classification>Unclassified</classification>
          <product>WebKit</product>
          <component>DOM</component>
          <version>528+ (Nightly build)</version>
          <rep_platform>Unspecified</rep_platform>
          <op_sys>Windows 7</op_sys>
          <bug_status>RESOLVED</bug_status>
          <resolution>FIXED</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>
          <dependson>100738</dependson>
    
    <dependson>100921</dependson>
    
    <dependson>100922</dependson>
    
    <dependson>101180</dependson>
    
    <dependson>101697</dependson>
    
    <dependson>101698</dependson>
    
    <dependson>101699</dependson>
    
    <dependson>101700</dependson>
    
    <dependson>101891</dependson>
    
    <dependson>101900</dependson>
    
    <dependson>101901</dependson>
    
    <dependson>101902</dependson>
    
    <dependson>101903</dependson>
    
    <dependson>102160</dependson>
          <blocked>63606</blocked>
          <everconfirmed>1</everconfirmed>
          <reporter name="Sergey G. Grekhov">sgrekhov</reporter>
          <assigned_to name="Nobody">webkit-unassigned</assigned_to>
          <cc>dglazkov</cc>
    
    <cc>morrita</cc>
    
    <cc>shinyak</cc>
    
    <cc>webcomponents-bugzilla</cc>
          

      

      

      

          <comment_sort_order>oldest_to_newest</comment_sort_order>  
          <long_desc isprivate="0" >
    <commentid>751501</commentid>
    <comment_count>0</comment_count>
    <who name="Sergey G. Grekhov">sgrekhov</who>
    <bug_when>2012-10-25 21:01:22 -0700</bug_when>
    <thetext>Found in Chrome  22.0.1229.94 m

The following test (in fact rewritten Bob-developer example from Shadow DOM spec) fails:

	var iframe = document.createElement(&apos;iframe&apos;);
	document.body.appendChild(iframe);

  
	iframe.contentDocument.body.innerHTML = &quot;&lt;ul class=&apos;stories&apos;&gt;&quot; +
    &quot;&lt;li id=&apos;li1&apos;&gt;&lt;a href=&apos;#1&apos;&gt;Link1&lt;/a&gt;&lt;/li&gt;&quot; +
    &quot;&lt;li id=&apos;li2&apos;&gt;&lt;a href=&apos;#2&apos;&gt;Link 2&lt;/a&gt;&lt;/li&gt;&quot; +
    &quot;&lt;li id=&apos;li3&apos; class=&apos;shadow&apos;&gt;&lt;a href=&apos;#3&apos;&gt;Link 3 Shadow&lt;/a&gt;&lt;/li&gt;&quot; +
    &quot;&lt;li id=&apos;li4&apos;&gt;&lt;a href=&apos;#4&apos;&gt;Link 4&lt;/a&gt;&lt;/li&gt;&quot; +
    &quot;&lt;li id=&apos;li5&apos;&gt;&lt;a href=&apos;#5&apos;&gt;Link 5&lt;/a&gt;&lt;/li&gt;&quot; +
    &quot;&lt;li id=&apos;li6&apos; class=&apos;shadow&apos;&gt;&lt;a href=&apos;#5&apos;&gt;Link 6 Shadow&lt;/a&gt;&lt;/li&gt;&quot; +
  	&quot;&lt;/ul&gt;&quot;;
  	
var d = iframe.contentDocument;
var ul = d.querySelector(&quot;ul.stories&quot;);
var SR = window.ShadowRoot ||
         window.WebKitShadowRoot;  
var s = new SR(ul);
  
  //make shadow subtree  
  var subdiv1 = document.createElement(&apos;div&apos;);
  subdiv1.innerHTML = &quot;&lt;ul&gt;&lt;content select=&apos;.shadow&apos;&gt;&lt;/content&gt;&lt;/ul&gt;&quot;;
  s.appendChild(subdiv1);
  
	assert_true(d.querySelector(&apos;#li3&apos;).offsetTop &lt; d.querySelector(&apos;#li6&apos;).offsetTop,
		&apos;Point 1: Elements that match insertion point criteria don\&apos;t participate in distribution&apos;);
	assert_true(d.querySelector(&apos;#li3&apos;).offsetTop &gt; 0,
		&apos;Point 2: Elements that match insertion point criteria don\&apos;t participate in distribution&apos;);
	assert_equals(d.querySelector(&apos;#li1&apos;).offsetTop, 0,
		&apos;Point 3: Elements that don\&apos;t match insertion point criteria participate in distribution&apos;);
	assert_equals(d.querySelector(&apos;#li2&apos;).offsetTop, 0,
		&apos;Point 4: Elements that don\&apos;t match insertion point criteria participate in distribution&apos;);
	assert_equals(d.querySelector(&apos;#li4&apos;).offsetTop, 0,
		&apos;Point 5: Elements that don\&apos;t match insertion point criteria participate in distribution&apos;);
	assert_equals(d.querySelector(&apos;#li5&apos;).offsetTop, 0,
		&apos;Point 6: Elements that don\&apos;t match insertion point criteria participate in distribution&apos;);
  	
	var li5 = d.querySelector(&apos;#li5&apos;);
	li5.className = &apos;shadow&apos;;
	
	assert_true(li5.offsetTop &gt; 0,
		&apos;Distribution should reoccur if a variable affecting it is changed&apos;);

Class name of li5 was changed to the one that matches insertion point criteria, so the distribution should reoccur but it doesn&apos;t.</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>753932</commentid>
    <comment_count>1</comment_count>
    <who name="Shinya Kawanaka">shinyak</who>
    <bug_when>2012-10-29 18:49:58 -0700</bug_when>
    <thetext>I&apos;ll see it today. If it&apos;s found in chrome 22, we might have fixed it already though...</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>753974</commentid>
    <comment_count>2</comment_count>
    <who name="Shinya Kawanaka">shinyak</who>
    <bug_when>2012-10-29 20:55:28 -0700</bug_when>
    <thetext>OK. I&apos;ve confirmed this test is still failing in the current trunk.</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>754111</commentid>
    <comment_count>3</comment_count>
    <who name="Shinya Kawanaka">shinyak</who>
    <bug_when>2012-10-30 02:26:02 -0700</bug_when>
    <thetext>Hmm... it seems changing attribute does not reflect immediately at all.
Let&apos;s use this as a meta bug and fix them one by one.</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>754165</commentid>
    <comment_count>4</comment_count>
    <who name="Hajime Morrita">morrita</who>
    <bug_when>2012-10-30 03:42:11 -0700</bug_when>
    <thetext>(In reply to comment #3)
&gt; Hmm... it seems changing attribute does not reflect immediately at all.
&gt; Let&apos;s use this as a meta bug and fix them one by one.

Right. we need to address this.
On the other hand, it is bad idea to re-run distribution algorithm for each attribute change
from a performance perspective. 
Can we do something more efficient like examining @select attribute values before
invalidating the distribution?</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>754511</commentid>
    <comment_count>5</comment_count>
    <who name="Dimitri Glazkov (Google)">dglazkov</who>
    <bug_when>2012-10-30 10:54:20 -0700</bug_when>
    <thetext>(In reply to comment #4)
&gt; (In reply to comment #3)
&gt; &gt; Hmm... it seems changing attribute does not reflect immediately at all.
&gt; &gt; Let&apos;s use this as a meta bug and fix them one by one.
&gt; 
&gt; Right. we need to address this.
&gt; On the other hand, it is bad idea to re-run distribution algorithm for each attribute change
&gt; from a performance perspective.

It may sound pretty bad, but it&apos;s something CSS does anyway, right?

&gt; Can we do something more efficient like examining @select attribute values before
&gt; invalidating the distribution?

This sounds like an interesting optimization:
1) determine effects of the select as some subset of DOM changes
2) act only on DOM changes that are in this subset.

Also sounds:
1) incredibly complex
2) something that could be shared with general CSS rule matching</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>754849</commentid>
    <comment_count>6</comment_count>
    <who name="Shinya Kawanaka">shinyak</who>
    <bug_when>2012-10-30 18:16:16 -0700</bug_when>
    <thetext>(In reply to comment #5)
&gt; (In reply to comment #4)
&gt; &gt; (In reply to comment #3)
&gt; &gt; &gt; Hmm... it seems changing attribute does not reflect immediately at all.
&gt; &gt; &gt; Let&apos;s use this as a meta bug and fix them one by one.
&gt; &gt; 
&gt; &gt; Right. we need to address this.
&gt; &gt; On the other hand, it is bad idea to re-run distribution algorithm for each attribute change
&gt; &gt; from a performance perspective.
&gt; 
&gt; It may sound pretty bad, but it&apos;s something CSS does anyway, right?
&gt; 
&gt; &gt; Can we do something more efficient like examining @select attribute values before
&gt; &gt; invalidating the distribution?
&gt; 
&gt; This sounds like an interesting optimization:
&gt; 1) determine effects of the select as some subset of DOM changes
&gt; 2) act only on DOM changes that are in this subset.
&gt; 
&gt; Also sounds:
&gt; 1) incredibly complex
&gt; 2) something that could be shared with general CSS rule matching

Seeing Element::attributeChanged, Element checks CSS Selector to decide whether we should recalculate style. So maybe we can do this? It&apos;s complex though...</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>754931</commentid>
    <comment_count>7</comment_count>
    <who name="Shinya Kawanaka">shinyak</who>
    <bug_when>2012-10-30 21:14:31 -0700</bug_when>
    <thetext>I&apos;m now thinking the following plan:

1. ShadowRoot should know the set of descendant InsertionPoint
    - Maybe we can hook insertedInto and removedFrom
2. ShadowRoot should also know the descendant elements having ElementShadow
    - We also track addShadowRoot()
3. ShadowRoot will have FeatureRuleSet or something like that
    - We update it when InsertionPoint / ElementShadow is added/removed
4. When attribute of the direct child (or non-direct child in fallback element case) is changed, we consult with the FeatureRuleSet whether the change is related or not.
    - If it&apos;s related, we invalidate the distribution.
    - If not, we recursively consult with ElementShadow.</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>754992</commentid>
    <comment_count>8</comment_count>
    <who name="Hajime Morrita">morrita</who>
    <bug_when>2012-10-30 23:12:38 -0700</bug_when>
    <thetext>(In reply to comment #7)
&gt; I&apos;m now thinking the following plan:
&gt; 
&gt; 1. ShadowRoot should know the set of descendant InsertionPoint
&gt;     - Maybe we can hook insertedInto and removedFrom
&gt; 2. ShadowRoot should also know the descendant elements having ElementShadow
&gt;     - We also track addShadowRoot()
&gt; 3. ShadowRoot will have FeatureRuleSet or something like that
&gt;     - We update it when InsertionPoint / ElementShadow is added/removed
&gt; 4. When attribute of the direct child (or non-direct child in fallback element case) is changed, we consult with the FeatureRuleSet whether the change is related or not.
&gt;     - If it&apos;s related, we invalidate the distribution.
&gt;     - If not, we recursively consult with ElementShadow.

Sounds like a plan.
I hope we only need to track only the number of insertion points/shadows instead of the nodes
themselves.

Probably we can land the slow version fast, then introducing these optimisation.</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>755002</commentid>
    <comment_count>9</comment_count>
    <who name="Shinya Kawanaka">shinyak</who>
    <bug_when>2012-10-30 23:47:04 -0700</bug_when>
    <thetext>If we track InsertionPoint, distribution will be fast, because we can only iterate such elements instead of all descendant nodes. (This is not directly related to this bug, though.)

So we might want consider it in another bug.</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>755007</commentid>
    <comment_count>10</comment_count>
    <who name="Shinya Kawanaka">shinyak</who>
    <bug_when>2012-10-30 23:49:49 -0700</bug_when>
    <thetext>I&apos;ve created: https://bugs.webkit.org/show_bug.cgi?id=100820</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>764090</commentid>
    <comment_count>11</comment_count>
    <who name="Shinya Kawanaka">shinyak</who>
    <bug_when>2012-11-11 23:17:58 -0800</bug_when>
    <thetext>For pseudoClasses, please see this.
http://www.whatwg.org/specs/web-apps/current-work/multipage/selectors.html#pseudo-classes</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>771341</commentid>
    <comment_count>12</comment_count>
    <who name="Shinya Kawanaka">shinyak</who>
    <bug_when>2012-11-19 18:14:09 -0800</bug_when>
    <thetext>All subbugs are closed. Let&apos;s close this.</thetext>
  </long_desc>
      
      

    </bug>

</bugzilla>