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

<bugzilla version="5.0.4"
          urlbase="https://www.w3.org/Bugs/Public/"
          
          maintainer="sysbot+bugzilla@w3.org"
>

    <bug>
          <bug_id>27359</bug_id>
          
          <creation_ts>2014-11-18 14:57:55 +0000</creation_ts>
          <short_desc>[Shadow]: Need to define interaction with directionality</short_desc>
          <delta_ts>2015-04-15 05:41:07 +0000</delta_ts>
          <reporter_accessible>1</reporter_accessible>
          <cclist_accessible>1</cclist_accessible>
          <classification_id>1</classification_id>
          <classification>Unclassified</classification>
          <product>WebAppsWG</product>
          <component>HISTORICAL - Component Model</component>
          <version>unspecified</version>
          <rep_platform>PC</rep_platform>
          <op_sys>All</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>
          
          <blocked>14978</blocked>
          <everconfirmed>1</everconfirmed>
          <reporter name="Boris Zbarsky">bzbarsky</reporter>
          <assigned_to name="Koji Ishii">kojiishi</assigned_to>
          <cc>felash</cc>
    
    <cc>hayato</cc>
    
    <cc>jackalmage</cc>
    
    <cc>kenjibaheux</cc>
    
    <cc>mike</cc>
    
    <cc>public-webapps</cc>
          
          <qa_contact>public-webapps-bugzilla</qa_contact>

      

      

      

          <comment_sort_order>oldest_to_newest</comment_sort_order>  
          <long_desc isprivate="0" >
    <commentid>115056</commentid>
    <comment_count>0</comment_count>
    <who name="Boris Zbarsky">bzbarsky</who>
    <bug_when>2014-11-18 14:57:55 +0000</bug_when>
    <thetext>Consider this testcase:

  &lt;div dir=&quot;rtl&quot;&gt;&lt;/div&gt;
  &lt;script&gt;
    var div = document.querySelector(&quot;div&quot;);
    var root = div.createShadowRoot();
    root.innerHTML = &quot;&lt;p&gt;aaa&lt;/p&gt;&quot;;
  &lt;/script&gt;

It seems like in at least Chrome and Firefox the directionality of the inner div is &quot;rtl&quot;.  But per HTML spec at https://html.spec.whatwg.org/multipage/dom.html#the-directionality in this case the &lt;p&gt; is a &quot;root element&quot; and hence its directionality is expected to be &quot;ltr&quot;.

It&apos;s not clear to me whether we want directionality to leak across the shadow DOM boundary by default or not, by the way, and whether it should be explicitly controllable by the component or not.</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>115057</commentid>
    <comment_count>1</comment_count>
    <who name="Boris Zbarsky">bzbarsky</who>
    <bug_when>2014-11-18 15:04:47 +0000</bug_when>
    <thetext>&gt; It seems like in at least Chrome and Firefox the directionality of the inner
&gt; div is &quot;rtl&quot;

Based on the rendering, that is.  :-moz-dir matching in Firefox thinks it&apos;s &quot;ltr&quot;, and I&apos;d be interested in other ways of poking at that state in Chrome if there are any.</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>115065</commentid>
    <comment_count>2</comment_count>
    <who name="Tab Atkins Jr.">jackalmage</who>
    <bug_when>2014-11-18 18:16:32 +0000</bug_when>
    <thetext>I&apos;d base the decision on whether to inherit directionality on whether styles inherit; directionality isn&apos;t quite a style (the &apos;direction&apos; property notwithstanding), but it&apos;s similar in effect.</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>115084</commentid>
    <comment_count>3</comment_count>
    <who name="Hayato Ito">hayato</who>
    <bug_when>2014-11-19 01:48:52 +0000</bug_when>
    <thetext>The relevant issue: https://www.w3.org/Bugs/Public/show_bug.cgi?id=27222

From the view of the spec, if we are to make &apos;rtl&apos; *inheritable* across the shadow DOM boundary, we should update the spec, using the term of parent/child relationship in the composed tree (maybe).

See https://www.w3.org/Bugs/Public/show_bug.cgi?id=26365#c23</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>115087</commentid>
    <comment_count>4</comment_count>
    <who name="Boris Zbarsky">bzbarsky</who>
    <bug_when>2014-11-19 03:35:06 +0000</bug_when>
    <thetext>This bug has nothing to do with bug 27222.  The title behavior (which is purely about event targeting, afaict) and the directionality issue are very different.</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>115089</commentid>
    <comment_count>5</comment_count>
    <who name="Hayato Ito">hayato</who>
    <bug_when>2014-11-19 03:45:53 +0000</bug_when>
    <thetext>Yeah, it&apos;s not directly related.

I just meant that the current spec doesn&apos;t provide a good term for handling this kind of &apos;attribute&apos; inheritance.

I agree that each should be handled differently.</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>115090</commentid>
    <comment_count>6</comment_count>
    <who name="Boris Zbarsky">bzbarsky</who>
    <bug_when>2014-11-19 03:59:29 +0000</bug_when>
    <thetext>Ah, there&apos;s some interesting subtlety here.

There&apos;s the inherent element directionality, but also the CSS directionality.  They both, separately, inherit.  The element directionality can affect the CSS directionality.

So it&apos;s possible that what&apos;s going on in terms of layout in Gecko and Blink is that the CSS directionality inherits.  That would explain the layout behavior.  But that leaves the question of element directionality open, of course.  I&apos;d be interested in a way to directly query that in Blink.</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>115109</commentid>
    <comment_count>7</comment_count>
    <who name="Hayato Ito">hayato</who>
    <bug_when>2014-11-19 09:40:24 +0000</bug_when>
    <thetext>(In reply to Boris Zbarsky from comment #6)
&gt; Ah, there&apos;s some interesting subtlety here.
&gt; 
&gt; There&apos;s the inherent element directionality, but also the CSS
&gt; directionality.  They both, separately, inherit.  The element directionality
&gt; can affect the CSS directionality.
&gt; 
&gt; So it&apos;s possible that what&apos;s going on in terms of layout in Gecko and Blink
&gt; is that the CSS directionality inherits.  That would explain the layout
&gt; behavior.  But that leaves the question of element directionality open, of
&gt; course.  I&apos;d be interested in a way to directly query that in Blink.

I&apos;m afraid that I don&apos;t have any idea how we should resolve this potential conflict situation.

That reminds me of the similar issue I&apos;ve encountered, &apos;contenteditable&apos; attribute in blink. WebKit has a CSS property that is similar to contentEditable: `-webkit-user-modify`.

WebKit/Blink treats contenteditable attribute to something like as if the element had &apos;user-modify&apos; css property so that contenteditable were processed as if it were css property.

To avoid the complex situation, I hope that we should treat both worlds, &apos;element attribute&apos; and &apos;css property&apos; in the same way as possible as we can.

My initial thought is that we should use a composed tree based tree walking for both worlds, which would explain the layout behavior and match the parent/child relationship which is used by a style inheritance.</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>115119</commentid>
    <comment_count>8</comment_count>
    <who name="Boris Zbarsky">bzbarsky</who>
    <bug_when>2014-11-19 14:34:06 +0000</bug_when>
    <thetext>I don&apos;t think there&apos;s a conflict at all.  

What needs to be defined is what happens with HTML directionality.  CSS computed &quot;dir&quot; values are already well-defined.

&gt; I hope that we should treat both worlds, &apos;element attribute&apos; and &apos;css property&apos;
&gt; in the same way as possible as we can

That&apos;s what comment 2 suggested.  That makes some sense for the &quot;dir&quot; attribute (but not at all for &quot;title&quot;, note).</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>116561</commentid>
    <comment_count>9</comment_count>
    <who name="Julien Wajsberg">felash</who>
    <bug_when>2014-12-19 17:05:46 +0000</bug_when>
    <thetext>Hey,

I&apos;m trying to understand how this could work if we don&apos;t inherit directionality inside the shadow DOM. How could a component change his internal layout if we don&apos;t inherit?

If you decide that both use cases can make sense, then maybe we need &quot;something&quot; so that the component author can decide whether his component will inherit directionality. `:root { direction: inherit }` ?</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>116607</commentid>
    <comment_count>10</comment_count>
    <who name="Hayato Ito">hayato</who>
    <bug_when>2014-12-20 10:46:35 +0000</bug_when>
    <thetext>Yeah, it&apos;d be nice that component author can have a way to inherit explicitly.
However, I&apos;m not sure what is the best solution here yet.

You might want to see the discussion on https://www.w3.org/Bugs/Public/show_bug.cgi?id=27222.

It&apos;d be nice that we have a general solution for this kind of &apos;attribute inheritance&apos;.</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>116636</commentid>
    <comment_count>11</comment_count>
    <who name="Julien Wajsberg">felash</who>
    <bug_when>2014-12-22 07:56:01 +0000</bug_when>
    <thetext>It would be simpler if the dir= attribute was expressed in terms of CSS only, at least for agents supporting CSS.</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>116644</commentid>
    <comment_count>12</comment_count>
    <who name="Boris Zbarsky">bzbarsky</who>
    <bug_when>2014-12-22 19:28:45 +0000</bug_when>
    <thetext>It can&apos;t be expressed in terms of CSS only, because for example CSS doesn&apos;t have an equivalent of the &quot;auto&quot; value.</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>116646</commentid>
    <comment_count>13</comment_count>
    <who name="Tab Atkins Jr.">jackalmage</who>
    <bug_when>2014-12-22 19:50:56 +0000</bug_when>
    <thetext>And we (the CSSWG) don&apos;t really intend to extend it to include that.  

Directionality is not a matter of style, but of content.  It&apos;s as much a part of the host document as the text itself is, and belongs in the host document for the same reason.  The CSS &apos;direction&apos; property is a hack, intended solely for use in styling arbitrary host languages that may not have a built-in way to indicate directionality.  For HTML it shouldn&apos;t really be used, as HTML has such a method - the dir attribute.

(Note, for example, that the &apos;all&apos; shorthand does not expand into &apos;direction&apos; &lt;http://dev.w3.org/csswg/css-cascade/#all-shorthand&gt;, because &apos;direction&apos; isn&apos;t a styling property in the same way as everything else, it&apos;s a host-document property that&apos;s encoded in CSS for convenience.)</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>116875</commentid>
    <comment_count>14</comment_count>
    <who name="Koji Ishii">kojiishi</who>
    <bug_when>2015-01-07 06:32:45 +0000</bug_when>
    <thetext>(In reply to Boris Zbarsky from comment #6)
&gt; Ah, there&apos;s some interesting subtlety here.
&gt; 
&gt; There&apos;s the inherent element directionality, but also the CSS
&gt; directionality.  They both, separately, inherit.  The element directionality
&gt; can affect the CSS directionality.
&gt; 
&gt; So it&apos;s possible that what&apos;s going on in terms of layout in Gecko and Blink
&gt; is that the CSS directionality inherits.  That would explain the layout
&gt; behavior.  But that leaves the question of element directionality open, of
&gt; course.  I&apos;d be interested in a way to directly query that in Blink.

Unfortunately, no, there&apos;s no way to directly query that in Blink.

I agree with Hayato and Tab that &quot;dir&quot; should be behave the same way as CSS inheritance. The &quot;dir&quot; attribute and CSS unicode-bidi/direction properties work together under the assumption of CSS inheritance works along with DOM tree traversal, so inheriting CSS without inheriting &quot;dir&quot; is likely to cause a problem.

Regarding the bug 27222, Hayato and I discussed when the bug came in, and rather than having one bug for each attribute, it must be better to review all attributes and update the spec at once, and then handle whatever we missed if any. Since it wasn&apos;t clearly communicated to you all, I&apos;ve changed the summary of the bug.

I can read Hayato and Tab prefer &quot;dir&quot; to be handled the same way as CSS inherits. Are we all in consensus?</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>117394</commentid>
    <comment_count>15</comment_count>
    <who name="Koji Ishii">kojiishi</who>
    <bug_when>2015-01-21 16:11:22 +0000</bug_when>
    <thetext>In addition to inheriting &quot;dir&quot; and CSS properties, we&apos;ll also need to use the composed tree to &quot;find the first character in tree order&quot;. Blink currently:
- Inherits dir
- Inherits CSS direction and unicode-bidi
but:
- the behavior around dir=auto is a little flaky around shadow boundaries
- does not use the composed tree to &quot;find the first character in tree order&quot;
I&apos;ll look into these two.</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>119510</commentid>
    <comment_count>16</comment_count>
    <who name="Hayato Ito">hayato</who>
    <bug_when>2015-04-15 05:41:07 +0000</bug_when>
    <thetext>I think we can close this issue now.

kojiishii@, if you have any remaining issue, please reopen this.</thetext>
  </long_desc>
      
      

    </bug>

</bugzilla>