<?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>76515</bug_id>
          
          <creation_ts>2012-01-17 21:47:19 -0800</creation_ts>
          <short_desc>Update HTML Parser so that &lt;content&gt; element should be treated transparently.</short_desc>
          <delta_ts>2013-01-06 19:41:35 -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>Unspecified</op_sys>
          <bug_status>RESOLVED</bug_status>
          <resolution>LATER</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>76434</blocked>
          <everconfirmed>1</everconfirmed>
          <reporter name="Hayato Ito">hayato</reporter>
          <assigned_to name="Web Components Team">webcomponents-bugzilla</assigned_to>
          <cc>abarth</cc>
    
    <cc>dglazkov</cc>
    
    <cc>dominicc</cc>
    
    <cc>ian</cc>
    
    <cc>morrita</cc>
    
    <cc>rolandsteiner</cc>
    
    <cc>shinyak</cc>
          

      

      

      

          <comment_sort_order>oldest_to_newest</comment_sort_order>  
          <long_desc isprivate="0" >
    <commentid>537617</commentid>
    <comment_count>0</comment_count>
    <who name="Hayato Ito">hayato</who>
    <bug_when>2012-01-17 21:47:19 -0800</bug_when>
    <thetext>Suppose we have &lt;content&gt; element and given the following HTML:

&lt;table&gt;
  &lt;content&gt;
    &lt;td&gt;hello&lt;/td&gt;
  &lt;/content&gt;
&lt;/table&gt;


In the current HTML parser implementation, the result DOM tree would become:

&lt;content&gt;
&lt;/content&gt;
&lt;table&gt;
 &lt;tbody&gt;
    &lt;tr&gt;
      &lt;td&gt;hello&lt;/td&gt;
    &lt;/tr&gt;
  &lt;/tbody&gt;
&lt;/table&gt;

Yeah, &lt;content&gt; elements would be put outside of &lt;table&gt; element.

The result should be something like this:
&lt;table&gt;
  &lt;content&gt;
        &lt;td&gt;hello&lt;/td&gt;
  &lt;/content&gt;
&lt;/table&gt;

I am not sure whether we should add &lt;tbody&gt; or &lt;tr&gt; somewhere in this particular case.
At least, current implementation should be modified somehow.</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>537623</commentid>
    <comment_count>1</comment_count>
    <who name="Hayato Ito">hayato</who>
    <bug_when>2012-01-17 21:58:52 -0800</bug_when>
    <thetext>I found the related spec here:

http://www.whatwg.org/specs/web-apps/current-work/multipage/parsing.html#insertion-mode

So we might modify this spec or add some description to shadow DOM spec.</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>537666</commentid>
    <comment_count>2</comment_count>
    <who name="Adam Barth">abarth</who>
    <bug_when>2012-01-17 23:46:17 -0800</bug_when>
    <thetext>Changing the parser is a delicate matter.  Please coordinate any parser changes with Hixie.  We prefer to keep our implementation in close sync with the spec.</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>537668</commentid>
    <comment_count>3</comment_count>
    <who name="Adam Barth">abarth</who>
    <bug_when>2012-01-17 23:50:29 -0800</bug_when>
    <thetext>Is there something I can read so I can understand what changes you&apos;d like to make to the parser and what problem they solve?  (Maybe something in the Explainer is relevant here?)</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>537699</commentid>
    <comment_count>4</comment_count>
    <who name="Hayato Ito">hayato</who>
    <bug_when>2012-01-18 01:10:18 -0800</bug_when>
    <thetext>Okay. Although I don&apos;t have clear explanations yet about what the problem is exactly and what we should solve it, let me explain use cases using some examples.
I might update later after I&apos;ve read related specs carefully.

Suppose we have the following component: (See https://dvcs.w3.org/hg/webcomponents/raw-file/tip/spec/shadow/index.html for shadow DOM spec). 

&lt;div&gt; - component (shadow-host)
   &lt;td&gt;light children1&lt;/td&gt;
   &lt;td&gt;light children2&lt;/td&gt;
   [shadow-root] - template follows:
       &lt;table&gt;  
         &lt;content select=&apos;xxxx&apos;&gt;
            &lt;!- this is fallback elements --&gt;
            &lt;td&gt;td1&lt;/td&gt;
            &lt;td&gt;td2&lt;/td&gt;
         &lt;/content&gt;
         &lt;td&gt;td3&lt;/td&gt;
       &lt;/table&gt;


If &lt;content&gt; element is replaced with the light children, this component should be rendered as if the given html was given:
  &lt;div&gt;
    &lt;table&gt;
      &lt;tdoby&gt;
        &lt;tr&gt;
          &lt;td&gt;light children1&lt;/td&gt;
          &lt;td&gt;light children2&lt;/td&gt;
          &lt;td&gt;td3&lt;/td&gt;
        &lt;/tr&gt;
      &lt;tdoby&gt;
    &lt;/table&gt;
  &lt;/div&gt;


If &lt;content&gt; element is not replaced, this component should be rendered as if the given html was given:
  &lt;div&gt;
    &lt;table&gt;
      &lt;tdoby&gt;
        &lt;tr&gt;
          &lt;td&gt;td1&lt;/td&gt;
          &lt;td&gt;td2&lt;/td&gt;
          &lt;td&gt;td3&lt;/td&gt;
        &lt;/tr&gt;
      &lt;tdoby&gt;
    &lt;/table&gt;
  &lt;/div&gt;

To achieve it, what dom tree should HTML Parser generate when parsing the template?
According to the current spec, &lt;content&gt; element is *invalid* in &quot;IN_TABLE&quot; mode when parsing, so &lt;content&gt; element would be inserted outside of &lt;table&gt; element like this:  (See also http://www.whatwg.org/specs/web-apps/current-work/multipage/tree-construction.html#foster-parenting)

   &lt;content select=&apos;xxxx&apos;&gt;
   &lt;/content&gt;
   &lt;table&gt;  
     &lt;tbody&gt;
       &lt;tr&gt;
          &lt;!- this is fallback elements --&gt;
          &lt;td&gt;td1&lt;/td&gt;
          &lt;td&gt;td2&lt;/td&gt;
          &lt;td&gt;td3&lt;/td&gt;
       &lt;/tr&gt;
     &lt;/tdoby&gt;
   &lt;/table&gt;

This is undesirable result. We lost the position of &lt;content&gt; element. So we should treat &lt;content&gt; element specially in &lt;table&gt; or such elements.
* Note that &lt;tdoby&gt; and &lt;tr&gt; elements are inserted by parser.

So what DOM tree should the parser generate in this case? I&apos;ve come up three rough ideas.

1). Insert &lt;tbody&gt; and &lt;tr&gt; inside of &lt;content&gt; element.

    &lt;table&gt;  
      &lt;content select=&apos;xxxx&apos;&gt;
        &lt;tdoby&gt;
          &lt;tr&gt;
            &lt;td&gt;td1&lt;/td&gt;
            &lt;td&gt;td2&lt;/td&gt;
          &lt;/tr&gt;
        &lt;/tbody&gt;
       &lt;/content&gt;
       &lt;td&gt;td3&lt;/td&gt;
    &lt;/table&gt;

This is apparently wrong in this case.


2). Insert &lt;tbody&gt; and &lt;tr&gt; outside of &lt;content&gt; element and its siblings.

    &lt;table&gt;  
      &lt;tdoby&gt;
        &lt;tr&gt;
          &lt;content select=&apos;xxxx&apos;&gt;
            &lt;td&gt;td1&lt;/td&gt;
            &lt;td&gt;td2&lt;/td&gt;
          &lt;/content&gt;
          &lt;td&gt;td3&lt;/td&gt;
        &lt;/tr&gt;
      &lt;/tbody&gt;
    &lt;/table&gt;

This looks good in this case.


3). Avoid such auto-inserting elements across &lt;content&gt; elements. Return DOM tree &apos;as is&apos;.

    &lt;table&gt;  
      &lt;content select=&apos;xxxx&apos;&gt;
          &lt;td&gt;td1&lt;/td&gt;
          &lt;td&gt;td2&lt;/td&gt;
       &lt;/content&gt;
       &lt;td&gt;td3&lt;/td&gt;
    &lt;/table&gt;

This is ideal one? Can we achieve that?


Please correct or add anything if you find. I might miss something. I don&apos;t understand how such modification for the parser is tough.</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>537703</commentid>
    <comment_count>5</comment_count>
    <who name="Adam Barth">abarth</who>
    <bug_when>2012-01-18 01:19:54 -0800</bug_when>
    <thetext>&gt; I don&apos;t understand how such modification for the parser is tough.

It&apos;s not the modifications themselves that are tough, it&apos;s understanding all the consequences.  Have you considered how these documents will be handled by user agents that don&apos;t understand these new parsing rules?  What about other insertion modes besides InTable?

I&apos;m very hesitant to make changes to the parser without those changes first appearing in the HTML living standard.  The cost of having our parser diverge from the standard and from all the other browsers (who now implement the standard) is much higher than in other areas, such as JavaScript APIs.</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>537737</commentid>
    <comment_count>6</comment_count>
    <who name="Hayato Ito">hayato</who>
    <bug_when>2012-01-18 02:49:52 -0800</bug_when>
    <thetext>Hi Adam, thank you for the comment.

I totally agree your concerns. We have to consider all the consequences in addition to the spec change.
Let us continue to pursuit what should be done and use this bug for tracking the issue and updating the status.


(In reply to comment #5)
&gt; &gt; I don&apos;t understand how such modification for the parser is tough.
&gt; 
&gt; It&apos;s not the modifications themselves that are tough, it&apos;s understanding all the consequences.  Have you considered how these documents will be handled by user agents that don&apos;t understand these new parsing rules?  What about other insertion modes besides InTable?
&gt; 
&gt; I&apos;m very hesitant to make changes to the parser without those changes first appearing in the HTML living standard.  The cost of having our parser diverge from the standard and from all the other browsers (who now implement the standard) is much higher than in other areas, such as JavaScript APIs.</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>537880</commentid>
    <comment_count>7</comment_count>
    <who name="Dimitri Glazkov (Google)">dglazkov</who>
    <bug_when>2012-01-18 08:08:46 -0800</bug_when>
    <thetext>I think this is a bit of a cart-before-horse situation here. The spec as I wrote it doesn&apos;t -- yet -- specify any changes to the parser.</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>538398</commentid>
    <comment_count>8</comment_count>
    <who name="Hayato Ito">hayato</who>
    <bug_when>2012-01-18 18:57:09 -0800</bug_when>
    <thetext>I know we are starting the discussion in other place,  
http://lists.whatwg.org/pipermail/whatwg-whatwg.org/2012-January/034410.html

but let me add one more note here because the example I used in the explanation might not be good example.
Focus on the shadow host itself, ignoring shadow tree:

 &lt;div&gt;
   &lt;td&gt;light children1&lt;/td&gt;
   &lt;td&gt;light children2&lt;/td&gt;
 &lt;/div&gt;

This is totally invalid. If this host tree is parsed, &lt;td&gt; is gone because it do not appear in IN_TABLE mode. That becomes just a text node like:
 
 &lt;div&gt;
   light children1
   light children2
 &lt;/div&gt;

So we can not use light children which are valid only when inserted into &lt;content&gt;.
I just want to let you notify this limitation and my example is not good one.</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>539141</commentid>
    <comment_count>9</comment_count>
      <attachid>123220</attachid>
    <who name="Adam Barth">abarth</who>
    <bug_when>2012-01-19 16:27:34 -0800</bug_when>
    <thetext>Created attachment 123220
Sketch of possible changes (likely very broken)</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>801137</commentid>
    <comment_count>10</comment_count>
    <who name="Dominic Cooney">dominicc</who>
    <bug_when>2013-01-06 19:41:35 -0800</bug_when>
    <thetext>Per Comment 7, although the behavior is… interesting… it is per the spec. I’m closing this for now.</thetext>
  </long_desc>
      
          <attachment
              isobsolete="0"
              ispatch="1"
              isprivate="0"
          >
            <attachid>123220</attachid>
            <date>2012-01-19 16:27:34 -0800</date>
            <delta_ts>2012-01-19 16:27:34 -0800</delta_ts>
            <desc>Sketch of possible changes (likely very broken)</desc>
            <filename>bug-76515-20120119162733.patch</filename>
            <type>text/plain</type>
            <size>2475</size>
            <attacher name="Adam Barth">abarth</attacher>
            
              <data encoding="base64">SW5kZXg6IFNvdXJjZS9XZWJDb3JlL2h0bWwvcGFyc2VyL0hUTUxDb25zdHJ1Y3Rpb25TaXRlLmNw
cAo9PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09
PT09PT09PT09PT09Ci0tLSBTb3VyY2UvV2ViQ29yZS9odG1sL3BhcnNlci9IVE1MQ29uc3RydWN0
aW9uU2l0ZS5jcHAJKHJldmlzaW9uIDEwNTQ1OCkKKysrIFNvdXJjZS9XZWJDb3JlL2h0bWwvcGFy
c2VyL0hUTUxDb25zdHJ1Y3Rpb25TaXRlLmNwcAkod29ya2luZyBjb3B5KQpAQCAtNzcsNiArNzcs
NyBAQCBib29sIGNhdXNlc0Zvc3RlclBhcmVudGluZyhjb25zdCBRdWFsaWZpCiAgICAgICAgIHx8
IHRhZ05hbWUgPT0gdGJvZHlUYWcKICAgICAgICAgfHwgdGFnTmFtZSA9PSB0Zm9vdFRhZwogICAg
ICAgICB8fCB0YWdOYW1lID09IHRoZWFkVGFnCisgICAgICAgIHx8IHRhZ05hbWUgPT0gImNvbnRl
bnQiCiAgICAgICAgIHx8IHRhZ05hbWUgPT0gdHJUYWc7CiB9CiAKSW5kZXg6IFNvdXJjZS9XZWJD
b3JlL2h0bWwvcGFyc2VyL0hUTUxFbGVtZW50U3RhY2suY3BwCj09PT09PT09PT09PT09PT09PT09
PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT0KLS0tIFNvdXJj
ZS9XZWJDb3JlL2h0bWwvcGFyc2VyL0hUTUxFbGVtZW50U3RhY2suY3BwCShyZXZpc2lvbiAxMDU0
NTgpCisrKyBTb3VyY2UvV2ViQ29yZS9odG1sL3BhcnNlci9IVE1MRWxlbWVudFN0YWNrLmNwcAko
d29ya2luZyBjb3B5KQpAQCAtODgsMTIgKzg4LDE0IEBAIGlubGluZSBib29sIGlzTGlzdEl0ZW1T
Y29wZU1hcmtlcihDb250YWkKIGlubGluZSBib29sIGlzVGFibGVTY29wZU1hcmtlcihDb250YWlu
ZXJOb2RlKiBub2RlKQogewogICAgIHJldHVybiBub2RlLT5oYXNUYWdOYW1lKHRhYmxlVGFnKQor
ICAgICAgICB8fCBub2RlLT5oYXNUYWdOYW1lKCJjb250ZW50IikKICAgICAgICAgfHwgaXNSb290
Tm9kZShub2RlKTsKIH0KIAogaW5saW5lIGJvb2wgaXNUYWJsZUJvZHlTY29wZU1hcmtlcihDb250
YWluZXJOb2RlKiBub2RlKQogewogICAgIHJldHVybiBub2RlLT5oYXNUYWdOYW1lKHRib2R5VGFn
KQorICAgICAgICB8fCBub2RlLT5oYXNUYWdOYW1lKCJjb250ZW50IikKICAgICAgICAgfHwgbm9k
ZS0+aGFzVGFnTmFt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AgICAgICAgIHx8IHRhZ05hbWUgPT0g
dGZvb3RUYWcKICAgICAgICAgfHwgdGFnTmFtZSA9PSB0aGVhZFRhZzsKIH0KQEAgLTEwOTIsNiAr
MTA5OCwxMSBAQCB2b2lkIEhUTUxUcmVlQnVpbGRlcjo6cHJvY2Vzc1N0YXJ0VGFnRm9yCiAgICAg
ICAgIHByb2Nlc3NTdGFydFRhZyh0b2tlbik7CiAgICAgICAgIHJldHVybjsKICAgICB9CisgICAg
aWYgKHRva2VuLm5hbWUoKSA9PSAiY29udGVudCIpIHsKKyAgICAgICAgbV90cmVlLm9wZW5FbGVt
ZW50cygpLT5wb3BVbnRpbFRhYmxlU2NvcGVNYXJrZXIoKTsKKyAgICAgICAgbV90cmVlLmluc2Vy
dEhUTUxFbGVtZW50KHRva2VuKTsKKyAgICAgICAgcmV0dXJuOworICAgIH0KICAgICBpZiAoaXNU
YWJsZUJvZHlDb250ZXh0VGFnKHRva2VuLm5hbWUoKSkpIHsKICAgICAgICAgbV90cmVlLm9wZW5F
bGVtZW50cygpLT5wb3BVbnRpbFRhYmxlU2NvcGVNYXJrZXIoKTsKICAgICAgICAgbV90cmVlLmlu
c2VydEhUTUxFbGVtZW50KHRva2VuKTsK
</data>

          </attachment>
      

    </bug>

</bugzilla>