<?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>15543</bug_id>
          
          <creation_ts>2012-01-13 01:27:31 +0000</creation_ts>
          <short_desc>[Shadow]: AT_TARGET must be fired multiple times, once for each boundary</short_desc>
          <delta_ts>2012-01-18 02:25:18 +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="Dimitri Glazkov">dglazkov</reporter>
          <assigned_to name="Dimitri Glazkov">dglazkov</assigned_to>
          <cc>hayato</cc>
          
          <qa_contact>public-webapps-bugzilla</qa_contact>

      

      

      

          <comment_sort_order>oldest_to_newest</comment_sort_order>  
          <long_desc isprivate="0" >
    <commentid>62642</commentid>
    <comment_count>0</comment_count>
    <who name="Dimitri Glazkov">dglazkov</who>
    <bug_when>2012-01-13 01:27:31 +0000</bug_when>
    <thetext>From https://bugs.webkit.org/show_bug.cgi?id=76217:

&quot;... the meaning of AT_TARGET changes in the presence of the shadow DOM, and the AT_TARGET must be fired more than one time -- once for each shadow boundary. Since we are retargeting events, we must also report each &quot;new&quot; target as a separate occurrence.&quot;</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>62650</commentid>
    <comment_count>1</comment_count>
    <who name="Hayato Ito">hayato</who>
    <bug_when>2012-01-13 05:39:15 +0000</bug_when>
    <thetext>That reminds me of this bug: https://bugs.webkit.org/show_bug.cgi?id=64160.

Should we apply a rule of &apos;AT_TARGET must be fired multiple times&apos; to only bubbling events?
Non-bubbling events, such as FocusEvent,  is out of scope of this rule?</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>62653</commentid>
    <comment_count>2</comment_count>
    <who name="Hayato Ito">hayato</who>
    <bug_when>2012-01-13 09:03:43 +0000</bug_when>
    <thetext>Let me ask another question.

After some thought, I am wondering how we should define MULTIPLE AT_TARGET rule.
Let me explain using the following tree:

- A 
  - B
    &lt;Shadow boundary&gt;
      - C
        - D
          &lt;Shadow boundary&gt;
            - E
              - F

Suppose &apos;click&apos; event happens in &apos;F&apos;. In the current spec, events will be fired in the following order:

* Legend (currentTarget - target - phase)

 1. A - B - CAPTURE
 2. B - B - CAPTURE
 3. C - D - CAPTURE
 4. D - D - CAPTURE
 5. E - F - CAPTURE
 6. F - F - TARGET
 7. E - F - BUBBLE
 8. D - D - BUBBLE
 9. C - D - BUBBLE
10. B - B - BUBBLE
11. A - B - BUBBLE


With multiple AT_TARGET rule, in which orders events should be fired?

e.g.
 1. A - B - CAPTURE
 2. B - B - TARGET
 3. C - D - CAPTURE
 4. D - D - TARGET
 5. E - F - CAPTURE
 6. F - F - TARGET
 7. E - F - BUBBLE
 9. C - D - BUBBLE
11. A - B - BUBBLE

Otherwise, we should isolate each event dispatching flow by shadow boundary, should we?

flow1)
 1. A - B - CAPTURE
 2. B - B - TARGET
 3. A - B - BUBBLE

flow2)
 1. C - D - CAPTURE
 2. D - D - TARGET
 3. C - D - BUBBLE

flow3)
 1. E - F - CAPTURE
 2. F - F - TARGET
 3. E - F - BUBBLE

- We don&apos;t define orders between flow1, 2 and 3. Each flow should be independent.
- event.stopPropagation() called in some flow should not take effect on other flows.


Any thoughts?</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>62685</commentid>
    <comment_count>3</comment_count>
    <who name="Dimitri Glazkov">dglazkov</who>
    <bug_when>2012-01-13 21:13:03 +0000</bug_when>
    <thetext>I think it should be:

1. A - B - CAPTURE
2. B - B - CAPTURE
3. C - D - CAPTURE
4. D - D - CAPTURE
5. E - F - CAPTURE
6. B - B - TARGET
7. D - D - TARGET
8. F - F - TARGET
9. E - F - BUBBLE
10. D - D - BUBBLE
11. C - D - BUBBLE
12. B - B - BUBBLE
13. A - B - BUBBLE

This way, the event phase always only progresses from CAPTURE to TARGET to BUBBLE. The stopPropagation() should just work as usual.

And yes, you&apos;re right -- bug https://bugs.webkit.org/show_bug.cgi?id=64160 is relevant here. We should&apos;ve seen that firing AT_TARGET on shadow host was necessary for the non-bubbling events.

WDYT?</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>62687</commentid>
    <comment_count>4</comment_count>
    <who name="Dimitri Glazkov">dglazkov</who>
    <bug_when>2012-01-13 21:18:49 +0000</bug_when>
    <thetext>(In reply to comment #3)

No wait -- it should be

 1. A - B - CAPTURE
 2. B - B - TARGET
 3. C - D - CAPTURE
 4. D - D - TARGET
 5. E - F - CAPTURE
 6. F - F - TARGET
 7. E - F - BUBBLE
 9. C - D - BUBBLE
10. B - B - BUBBLE
11. A - B - BUBBLE

As you mentioned before. You were right, Hayato-san.

&gt; 
&gt; This way, the event phase always only progresses from CAPTURE to TARGET to
&gt; BUBBLE. The stopPropagation() should just work as usual.
&gt; 
&gt; And yes, you&apos;re right -- bug https://bugs.webkit.org/show_bug.cgi?id=64160 is
&gt; relevant here. We should&apos;ve seen that firing AT_TARGET on shadow host was
&gt; necessary for the non-bubbling events.
&gt; 
&gt; WDYT?</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>62692</commentid>
    <comment_count>5</comment_count>
    <who name="Dimitri Glazkov">dglazkov</who>
    <bug_when>2012-01-13 21:24:31 +0000</bug_when>
    <thetext>The rule is easy -- anytime a node and adjusted target match is considered AT_TARGET. Weee!</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>62693</commentid>
    <comment_count>6</comment_count>
    <who name="Dimitri Glazkov">dglazkov</who>
    <bug_when>2012-01-13 22:16:58 +0000</bug_when>
    <thetext>This is all wrong. I am going to need to rewrite this section. Wait please...</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>62694</commentid>
    <comment_count>7</comment_count>
    <who name="Dimitri Glazkov">dglazkov</who>
    <bug_when>2012-01-13 22:48:25 +0000</bug_when>
    <thetext>http://dvcs.w3.org/hg/webcomponents/rev/50eb1e7fbc98

I reworked the algorithm to do the right thing. The resulting sequence for Hayato-san&apos;s example is:

1. A - B - CAPTURE
2. C - D - CAPTURE
3. E - F - CAPTURE
4. F - F - TARGET
5. E - F - BUBBLE
6. D - D - TARGET
7. C - D - BUBBLE
8. B - B - TARGET
9. A - B - BUBBLE</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>62767</commentid>
    <comment_count>8</comment_count>
    <who name="Hayato Ito">hayato</who>
    <bug_when>2012-01-16 02:11:27 +0000</bug_when>
    <thetext>LGTM. Thank you. That seems natural and reasonable order.

(In reply to comment #7)
&gt; http://dvcs.w3.org/hg/webcomponents/rev/50eb1e7fbc98
&gt; 
&gt; I reworked the algorithm to do the right thing. The resulting sequence for
&gt; Hayato-san&apos;s example is:
&gt; 
&gt; 1. A - B - CAPTURE
&gt; 2. C - D - CAPTURE
&gt; 3. E - F - CAPTURE
&gt; 4. F - F - TARGET
&gt; 5. E - F - BUBBLE
&gt; 6. D - D - TARGET
&gt; 7. C - D - BUBBLE
&gt; 8. B - B - TARGET
&gt; 9. A - B - BUBBLE

(In reply to comment #7)
&gt; http://dvcs.w3.org/hg/webcomponents/rev/50eb1e7fbc98
&gt; 
&gt; I reworked the algorithm to do the right thing. The resulting sequence for
&gt; Hayato-san&apos;s example is:
&gt; 
&gt; 1. A - B - CAPTURE
&gt; 2. C - D - CAPTURE
&gt; 3. E - F - CAPTURE
&gt; 4. F - F - TARGET
&gt; 5. E - F - BUBBLE
&gt; 6. D - D - TARGET
&gt; 7. C - D - BUBBLE
&gt; 8. B - B - TARGET
&gt; 9. A - B - BUBBLE</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>62770</commentid>
    <comment_count>9</comment_count>
    <who name="Hayato Ito">hayato</who>
    <bug_when>2012-01-16 08:41:48 +0000</bug_when>
    <thetext>I think that the new rule,

&gt; When processing step 3 of the event dispatch algorithm, the event listeners must not be invoked on a node when it is the same as its relative target

introduces a compatibility issue for non-bubbling events. If we register a listener, which uses (useCapture=true), for a non-bubbling event (event.bublles() == false) to each elements as follow:

A.addListener(&apos;focus&apos;, listener, true);
B.addListener(&apos;focus&apos;, listner, true);
...
...


Before the new rule, the following events will be fired:

A - B - CAPTURE
B - B - CAPTURE
C - D - CAPTURE
D - D - CAPTURE
E - F - CAPTURE
F - F - TARGET


Ater the new rule, only the following events will be fired:

1. A - B - CAPTURE
2. C - D - CAPTURE
3. E - F - CAPTURE
4. F - F - TARGET

So we miss AT_TARGET events at B and D for non-bubbling events, which should be called, shouldn&apos;t we?</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>62771</commentid>
    <comment_count>10</comment_count>
    <who name="Hayato Ito">hayato</who>
    <bug_when>2012-01-16 09:00:16 +0000</bug_when>
    <thetext>So what about this?

When processing step 3 of the event dispatch algorithm,
    if event.target == event.currentTarget:
       if event.bubbles:
           do not call event listeners.
       else:
           call event listeners with eventPhase attribute == AT_TARGET
    else:
        call event listeners.


(In reply to comment #9)
&gt; I think that the new rule,
&gt; 
&gt; &gt; When processing step 3 of the event dispatch algorithm, the event listeners must not be invoked on a node when it is the same as its relative target
&gt; 
&gt; introduces a compatibility issue for non-bubbling events. If we register a
&gt; listener, which uses (useCapture=true), for a non-bubbling event
&gt; (event.bublles() == false) to each elements as follow:
&gt; 
&gt; A.addListener(&apos;focus&apos;, listener, true);
&gt; B.addListener(&apos;focus&apos;, listner, true);
&gt; ...
&gt; ...
&gt; 
&gt; 
&gt; Before the new rule, the following events will be fired:
&gt; 
&gt; A - B - CAPTURE
&gt; B - B - CAPTURE
&gt; C - D - CAPTURE
&gt; D - D - CAPTURE
&gt; E - F - CAPTURE
&gt; F - F - TARGET
&gt; 
&gt; 
&gt; Ater the new rule, only the following events will be fired:
&gt; 
&gt; 1. A - B - CAPTURE
&gt; 2. C - D - CAPTURE
&gt; 3. E - F - CAPTURE
&gt; 4. F - F - TARGET
&gt; 
&gt; So we miss AT_TARGET events at B and D for non-bubbling events, which should be
&gt; called, shouldn&apos;t we?</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>62816</commentid>
    <comment_count>11</comment_count>
    <who name="Dimitri Glazkov">dglazkov</who>
    <bug_when>2012-01-17 21:23:16 +0000</bug_when>
    <thetext>(In reply to comment #10)
&gt; So what about this?
&gt; 
&gt; When processing step 3 of the event dispatch algorithm,
&gt;     if event.target == event.currentTarget:
&gt;        if event.bubbles:
&gt;            do not call event listeners.
&gt;        else:
&gt;            call event listeners with eventPhase attribute == AT_TARGET
&gt;     else:
&gt;         call event listeners.

This seems to change the order of how capture-&gt;target-&gt;bubbling progresses... What do you think about this? http://dvcs.w3.org/hg/webcomponents/rev/f46cfd9b0832</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>62825</commentid>
    <comment_count>12</comment_count>
    <who name="Hayato Ito">hayato</who>
    <bug_when>2012-01-18 01:15:37 +0000</bug_when>
    <thetext>Yours is concise and better than mine. I like it. Thank you. I&apos;ll close this bug.


(In reply to comment #11)
&gt; 
&gt; This seems to change the order of how capture-&gt;target-&gt;bubbling progresses...
&gt; What do you think about this?
&gt; http://dvcs.w3.org/hg/webcomponents/rev/f46cfd9b0832</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>62835</commentid>
    <comment_count>13</comment_count>
    <who name="Hayato Ito">hayato</who>
    <bug_when>2012-01-18 02:25:18 +0000</bug_when>
    <thetext>Let me note the order in both cases (in my original proposal and the current spec) for the record.


Case I). If we register eventListener, using (useCapture=false),

The events will be fired in the following order:

1) In my original proposal

F - F - TARGET
E - F - BUBBLE
D - D - TARGET
C - D - BUBBLE
B - B - TARGET
A - B - BUBBLE

2) In new proposal,

B - B - TARGET
D - D - TARGET
F - F - TARGET
E - F - BUBBLE
C - D - BUBBLE
A - B - BUBBLE



Case II). If we register eventListener, using (useCapture=true),

1) In my original proposal:

A - B - CAPTURE
C - D - CAPTURE
E - F - CAPTURE
F - F - TARGET
D - D - TARGET
B - B - TARGET

2) In new proposal:

A - B - CAPTURE
B - B - TARGET
C - D - CAPTURE
D - D - TARGET
E - F - CAPTURE
F - F - TARGET



Case III). If we register eventListener, using (useCapture=true), for non-bubble events

1) In my original proposal:

A - B - CAPTURE
B - B - TARGET
C - D - CAPTURE
D - D - TARGET
E - F - CAPTURE
F - F - TARGET

2) In new proposal:

A - B - CAPTURE
B - B - TARGET
C - D - CAPTURE
D - D - TARGET
E - F - CAPTURE
F - F - TARGET



Case IV). If we register eventListener, using both (useCapture=true) and (useCapture=true)

1) In my original proposal:

A - B - CAPTURE
C - D - CAPTURE
E - F - CAPTURE
F - F - TARGET
E - F - BUBBLE
D - D - TARGET
C - D - BUBBLE
B - B - TARGET
A - B - BUBBLE

2) In new proposal:

A - B - CAPTURE
B - B - TARGET
C - D - CAPTURE
D - D - TARGET
E - F - CAPTURE
F - F - TARGET
E - F - BUBBLE
C - D - BUBBLE
A - B - BUBBLE</thetext>
  </long_desc>
      
      

    </bug>

</bugzilla>