Changeset 147371 in webkit


Ignore:
Timestamp:
Apr 1, 2013 5:03:36 PM (11 years ago)
Author:
hayato@chromium.org
Message:

[Shadow DOM] Change the order of event dispatching at AT_TARGET phase.
https://bugs.webkit.org/show_bug.cgi?id=113676

Reviewed by Dimitri Glazkov.

Source/WebCore:

Change the order of event dispatching at AT_TARGET phase so that it mimics bubbling events.

The spec side bug is:
https://www.w3.org/Bugs/Public/show_bug.cgi?id=21404

Example:

Given the event path, from Node A (top-most) to Node G (target,
inner-most), where C and D are shadow hosts and G is the target,
the event dispatching order in the current WebKit implementation is:
(T: AT_TARGET, C: CAPTURING, B: BUBBLING)

For bubbling events:

A 1 (C) 11 (B)
B 2 (C) 10 (B)
C (SH) 3 (T)
D 4 (C) 9 (B)
E (SH) 5 (T)
F 6 (C) 8 (B)
G (Target) 7 (T)

For non-bubbling events:

A 1 (C)
B 2 (C)
C (SH) 3 (T)
D 4 (C)
E (SH) 5 (T)
F 6 (C)
G (Target) 7 (T)

This patch has changed the order of event dispatching as follows:

For bubbling events:

A 1 (C) 11 (B)
B 2 (C) 10 (B)
C (SH) 9 (T)
D 3 (C) 8 (B)
E (SH) 7 (T)
F 4 (C) 6 (B)
G (Target) 5 (T)

For non-bubbling events:

A 1 (C)
B 2 (C)
C (SH) 7 (T)
D 3 (C)
E (SH) 6 (T)
F 4 (C)
G (Target) 5 (T)

No new tests, updating existing layouts.

  • dom/EventDispatcher.cpp:

(WebCore::EventDispatcher::dispatchEventAtCapturing):
(WebCore::EventDispatcher::dispatchEventAtBubbling):

  • dom/EventDispatcher.h:

(EventDispatcher):

LayoutTests:

  • fast/dom/shadow/cppevent-in-shadow-expected.txt:
  • fast/dom/shadow/cppevent-input-in-shadow-expected.txt:
  • fast/dom/shadow/events-stopped-at-shadow-boundary-expected.txt:
  • fast/dom/shadow/gesture-tap-expected.txt:
  • fast/dom/shadow/shadow-boundary-events-expected.txt:
  • fast/dom/shadow/shadow-boundary-events.html:
  • fast/dom/shadow/shadow-dom-event-dispatching-distributed-text-node-expected.txt:
  • fast/dom/shadow/shadow-dom-event-dispatching-fallback-nodes-expected.txt:
  • fast/dom/shadow/shadow-dom-event-dispatching-non-distributed-nodes-expected.txt:
  • fast/dom/shadow/shadow-dom-event-dispatching-text-node-in-shadow-root-expected.txt:
  • fast/dom/shadow/shadow-root-blur-expected.txt:
Location:
trunk
Files:
15 edited

Legend:

Unmodified
Added
Removed
  • trunk/LayoutTests/ChangeLog

    r147367 r147371  
     12013-04-01  Hayato Ito  <hayato@chromium.org>
     2
     3        [Shadow DOM] Change the order of event dispatching at AT_TARGET phase.
     4        https://bugs.webkit.org/show_bug.cgi?id=113676
     5
     6        Reviewed by Dimitri Glazkov.
     7
     8        * fast/dom/shadow/cppevent-in-shadow-expected.txt:
     9        * fast/dom/shadow/cppevent-input-in-shadow-expected.txt:
     10        * fast/dom/shadow/events-stopped-at-shadow-boundary-expected.txt:
     11        * fast/dom/shadow/gesture-tap-expected.txt:
     12        * fast/dom/shadow/shadow-boundary-events-expected.txt:
     13        * fast/dom/shadow/shadow-boundary-events.html:
     14        * fast/dom/shadow/shadow-dom-event-dispatching-distributed-text-node-expected.txt:
     15        * fast/dom/shadow/shadow-dom-event-dispatching-fallback-nodes-expected.txt:
     16        * fast/dom/shadow/shadow-dom-event-dispatching-non-distributed-nodes-expected.txt:
     17        * fast/dom/shadow/shadow-dom-event-dispatching-text-node-in-shadow-root-expected.txt:
     18        * fast/dom/shadow/shadow-root-blur-expected.txt:
     19
    1202013-04-01  Nate Chapin  <japhet@chromium.org>
    221
  • trunk/LayoutTests/fast/dom/shadow/cppevent-in-shadow-expected.txt

    r145873 r147371  
     1dark: copy is fired.
    12host: copy is fired.
    2 dark: copy is fired.
     3dark: cut is fired.
    34host: cut is fired.
    4 dark: cut is fired.
     5dark: paste is fired.
    56host: paste is fired.
    6 dark: paste is fired.
    77PASS successfullyParsed is true
    88
  • trunk/LayoutTests/fast/dom/shadow/cppevent-input-in-shadow-expected.txt

    r145873 r147371  
     1dark: copy is fired.
    12host: copy is fired.
    2 dark: copy is fired.
     3dark: cut is fired.
    34host: cut is fired.
    4 dark: cut is fired.
     5dark: paste is fired.
    56host: paste is fired.
    6 dark: paste is fired.
    77PASS successfullyParsed is true
    88
  • trunk/LayoutTests/fast/dom/shadow/events-stopped-at-shadow-boundary-expected.txt

    r145873 r147371  
    4343
    4444  click
    45      @host (target: host)
    4645     @target (target: target)
    4746     @parent-of-target (target: target)
     47     @host (target: host)
    4848     @top (target: host)
    4949
  • trunk/LayoutTests/fast/dom/shadow/gesture-tap-expected.txt

    r146427 r147371  
    66
    77  gesturetap
     8     @div1-shadow-root-child (target: div1-shadow-root-child)
    89     @div1 (target: div1)
    9      @div1-shadow-root-child (target: div1-shadow-root-child)
    1010
  • trunk/LayoutTests/fast/dom/shadow/shadow-boundary-events-expected.txt

    r145873 r147371  
    2828Moving mouse from shadowD/shadowF/shadowG/divI to shadowD/divE
    2929PASS dispatchedEvent("mouseover") is ["divE(<-shadowF)(@divE)"]
    30 PASS dispatchedEvent("mouseout") is ["shadowF(<-divE)(@shadowF)", "shadowG(<-divE)(@shadowG)", "divI(<-divE)(@divI)", "shadowF(<-divE)(@divE)"]
     30PASS dispatchedEvent("mouseout") is ["divI(<-divE)(@divI)", "shadowG(<-divE)(@shadowG)", "shadowF(<-divE)(@shadowF)", "shadowF(<-divE)(@divE)"]
    3131
    3232Target (shadow host) is an ancestor of relatedTarget.
    3333Moving mouse from shadowD/shadowF/shadowG/divI to shadowD/shadowF
    3434PASS dispatchedEvent("mouseover") is []
    35 PASS dispatchedEvent("mouseout") is ["shadowG(<-shadowF)(@shadowG)", "divI(<-shadowF)(@divI)"]
     35PASS dispatchedEvent("mouseout") is ["divI(<-shadowF)(@divI)", "shadowG(<-shadowF)(@shadowG)"]
    3636
    3737Target (shadow host) is an ancestor of relatedTarget (shadow host).
    3838Moving mouse from shadowD/shadowF/shadowG to shadowD
    3939PASS dispatchedEvent("mouseover") is []
    40 PASS dispatchedEvent("mouseout") is ["shadowF(<-shadowD)(@shadowF)", "shadowG(<-shadowD)(@shadowG)", "shadowF(<-shadowD)(@divE)"]
     40PASS dispatchedEvent("mouseout") is ["shadowG(<-shadowD)(@shadowG)", "shadowF(<-shadowD)(@shadowF)", "shadowF(<-shadowD)(@divE)"]
    4141
    4242RelatedTarget is ancestor of target.
    4343Moving mouse from shadowD/divE to shadowD/shadowF/shadowG/divI
    44 PASS dispatchedEvent("mouseover") is ["shadowF(<-divE)(@shadowF)", "shadowG(<-divE)(@shadowG)",  "divI(<-divE)(@divI)", "shadowF(<-divE)(@divE)"]
     44PASS dispatchedEvent("mouseover") is ["divI(<-divE)(@divI)", "shadowG(<-divE)(@shadowG)", "shadowF(<-divE)(@shadowF)", "shadowF(<-divE)(@divE)"]
    4545PASS dispatchedEvent("mouseout") is ["divE(<-shadowF)(@divE)"]
    4646
    4747RelatedTarget (shadow host) is ancestor of target.
    4848Moving mouse from shadowD/shadowF to shadowD/shadowF/shadowG/divI
    49 PASS dispatchedEvent("mouseover") is ["shadowG(<-shadowF)(@shadowG)", "divI(<-shadowF)(@divI)"]
     49PASS dispatchedEvent("mouseover") is ["divI(<-shadowF)(@divI)", "shadowG(<-shadowF)(@shadowG)"]
    5050PASS dispatchedEvent("mouseout") is []
    5151
    5252RelatedTarget (shadow host) is an ancestor of target (shadow host).
    5353Moving mouse from shadowD to shadowD/shadowF/shadowG
    54 PASS dispatchedEvent("mouseover") is ["shadowF(<-shadowD)(@shadowF)", "shadowG(<-shadowD)(@shadowG)", "shadowF(<-shadowD)(@divE)"]
     54PASS dispatchedEvent("mouseover") is ["shadowG(<-shadowD)(@shadowG)", "shadowF(<-shadowD)(@shadowF)", "shadowF(<-shadowD)(@divE)"]
    5555PASS dispatchedEvent("mouseout") is []
    5656
    5757Target and relatedTarget exist in separated subtree, crossing shadow boundaries. Making sure that event is not dispatched beyond the lowest common boundary.
    5858Moving mouse from shadowD/shadowF/shadowG/divH to shadowD/shadowK/divL
    59 PASS dispatchedEvent("mouseover") is ["shadowK(<-shadowF)(@shadowK)", "divL(<-shadowF)(@divL)", "shadowK(<-shadowF)(@divJ)"]
    60 PASS dispatchedEvent("mouseout") is ["shadowF(<-shadowK)(@shadowF)", "shadowG(<-shadowK)(@shadowG)", "divH(<-shadowK)(@divH)", "shadowF(<-shadowK)(@divE)"]
     59PASS dispatchedEvent("mouseover") is ["divL(<-shadowF)(@divL)", "shadowK(<-shadowF)(@shadowK)", "shadowK(<-shadowF)(@divJ)"]
     60PASS dispatchedEvent("mouseout") is ["divH(<-shadowK)(@divH)", "shadowG(<-shadowK)(@shadowG)", "shadowF(<-shadowK)(@shadowF)", "shadowF(<-shadowK)(@divE)"]
    6161
    6262Move focus from a node to its sibling node. All nodes are outside of shadow boundary.
     
    6767Old focused node and new focused node exist in separated subtrees, crossing shadow boundaries. Making sure that an event is not dispatched beyond the lowest common boundary.
    6868Moving focus from shadowD/shadowF/shadowG/divH to shadowD/shadowK/divL
    69 PASS dispatchedEvent("focusin") is ["shadowK(<-shadowF)(@shadowK)", "divL(<-shadowF)(@divL)", "shadowK(<-shadowF)(@divJ)"]
    70 PASS dispatchedEvent("focusout") is ["shadowF(<-shadowK)(@shadowF)", "shadowG(<-shadowK)(@shadowG)", "divH(<-shadowK)(@divH)", "shadowF(<-shadowK)(@divE)"]
     69PASS dispatchedEvent("focusin") is ["divL(<-shadowF)(@divL)", "shadowK(<-shadowF)(@shadowK)", "shadowK(<-shadowF)(@divJ)"]
     70PASS dispatchedEvent("focusout") is ["divH(<-shadowK)(@divH)", "shadowG(<-shadowK)(@shadowG)", "shadowF(<-shadowK)(@shadowF)", "shadowF(<-shadowK)(@divE)"]
    7171
    7272Move focus from a node to its sibling node. All nodes are outside of shadow boundary.
     
    7777Old focused node and new focused node exist in separated subtrees, crossing shadow boundaries. Making sure that an event is not dispatched beyond the lowest common boundary.
    7878Moving focus from shadowD/shadowF/shadowG/divH to shadowD/shadowK/divL
    79 PASS dispatchedEvent("focus") is ["shadowK(<-shadowF)(@divJ)(capturing phase)", "shadowK(<-shadowF)(@shadowK)", "divL(<-shadowF)(@divL)"]
    80 PASS dispatchedEvent("blur") is ["shadowF(<-shadowK)(@divE)(capturing phase)", "shadowF(<-shadowK)(@shadowF)", "shadowG(<-shadowK)(@shadowG)", "divH(<-shadowK)(@divH)"]
     79PASS dispatchedEvent("focus") is ["shadowK(<-shadowF)(@divJ)(capturing phase)", "divL(<-shadowF)(@divL)", "shadowK(<-shadowF)(@shadowK)"]
     80PASS dispatchedEvent("blur") is ["shadowF(<-shadowK)(@divE)(capturing phase)", "divH(<-shadowK)(@divH)", "shadowG(<-shadowK)(@shadowG)", "shadowF(<-shadowK)(@shadowF)"]
    8181PASS successfullyParsed is true
    8282
  • trunk/LayoutTests/fast/dom/shadow/shadow-boundary-events.html

    r145873 r147371  
    146146              'Target is an ancestor of relatedTarget.');
    147147    shouldBe('dispatchedEvent("mouseover")', '["divE(<-shadowF)(@divE)"]');
    148     shouldBe('dispatchedEvent("mouseout")', '["shadowF(<-divE)(@shadowF)", "shadowG(<-divE)(@shadowG)", "divI(<-divE)(@divI)", "shadowF(<-divE)(@divE)"]');
     148    shouldBe('dispatchedEvent("mouseout")', '["divI(<-divE)(@divI)", "shadowG(<-divE)(@shadowG)", "shadowF(<-divE)(@shadowF)", "shadowF(<-divE)(@divE)"]');
    149149
    150150    moveMouse('shadowD/shadowF/shadowG/divI', 'shadowD/shadowF',
    151151              'Target (shadow host) is an ancestor of relatedTarget.');
    152152    shouldBe('dispatchedEvent("mouseover")', '[]');
    153     shouldBe('dispatchedEvent("mouseout")', '["shadowG(<-shadowF)(@shadowG)", "divI(<-shadowF)(@divI)"]');
     153    shouldBe('dispatchedEvent("mouseout")', '["divI(<-shadowF)(@divI)", "shadowG(<-shadowF)(@shadowG)"]');
    154154
    155155    moveMouse('shadowD/shadowF/shadowG', 'shadowD',
    156156              'Target (shadow host) is an ancestor of relatedTarget (shadow host).');
    157157    shouldBe('dispatchedEvent("mouseover")', '[]');
    158     shouldBe('dispatchedEvent("mouseout")', '["shadowF(<-shadowD)(@shadowF)", "shadowG(<-shadowD)(@shadowG)", "shadowF(<-shadowD)(@divE)"]');
     158    shouldBe('dispatchedEvent("mouseout")', '["shadowG(<-shadowD)(@shadowG)", "shadowF(<-shadowD)(@shadowF)", "shadowF(<-shadowD)(@divE)"]');
    159159
    160160    moveMouse('shadowD/divE', 'shadowD/shadowF/shadowG/divI',
    161161              'RelatedTarget is ancestor of target.');
    162     shouldBe('dispatchedEvent("mouseover")', '["shadowF(<-divE)(@shadowF)", "shadowG(<-divE)(@shadowG)",  "divI(<-divE)(@divI)", "shadowF(<-divE)(@divE)"]');
     162    shouldBe('dispatchedEvent("mouseover")', '["divI(<-divE)(@divI)", "shadowG(<-divE)(@shadowG)", "shadowF(<-divE)(@shadowF)", "shadowF(<-divE)(@divE)"]');
    163163    shouldBe('dispatchedEvent("mouseout")', '["divE(<-shadowF)(@divE)"]');
    164164
    165165    moveMouse('shadowD/shadowF', 'shadowD/shadowF/shadowG/divI',
    166166              'RelatedTarget (shadow host) is ancestor of target.');
    167     shouldBe('dispatchedEvent("mouseover")', '["shadowG(<-shadowF)(@shadowG)", "divI(<-shadowF)(@divI)"]');
     167    shouldBe('dispatchedEvent("mouseover")', '["divI(<-shadowF)(@divI)", "shadowG(<-shadowF)(@shadowG)"]');
    168168    shouldBe('dispatchedEvent("mouseout")', '[]');
    169169
    170170    moveMouse('shadowD', 'shadowD/shadowF/shadowG',
    171171              'RelatedTarget (shadow host) is an ancestor of target (shadow host).');
    172     shouldBe('dispatchedEvent("mouseover")', '["shadowF(<-shadowD)(@shadowF)", "shadowG(<-shadowD)(@shadowG)", "shadowF(<-shadowD)(@divE)"]');
     172    shouldBe('dispatchedEvent("mouseover")', '["shadowG(<-shadowD)(@shadowG)", "shadowF(<-shadowD)(@shadowF)", "shadowF(<-shadowD)(@divE)"]');
    173173    shouldBe('dispatchedEvent("mouseout")', '[]');
    174174
    175175    moveMouse('shadowD/shadowF/shadowG/divH', 'shadowD/shadowK/divL',
    176176              'Target and relatedTarget exist in separated subtree, crossing shadow boundaries. Making sure that event is not dispatched beyond the lowest common boundary.');
    177     shouldBe('dispatchedEvent("mouseover")', '["shadowK(<-shadowF)(@shadowK)", "divL(<-shadowF)(@divL)", "shadowK(<-shadowF)(@divJ)"]');
    178     shouldBe('dispatchedEvent("mouseout")', '["shadowF(<-shadowK)(@shadowF)", "shadowG(<-shadowK)(@shadowG)", "divH(<-shadowK)(@divH)", "shadowF(<-shadowK)(@divE)"]');
     177    shouldBe('dispatchedEvent("mouseover")', '["divL(<-shadowF)(@divL)", "shadowK(<-shadowF)(@shadowK)", "shadowK(<-shadowF)(@divJ)"]');
     178    shouldBe('dispatchedEvent("mouseout")', '["divH(<-shadowK)(@divH)", "shadowG(<-shadowK)(@shadowG)", "shadowF(<-shadowK)(@shadowF)", "shadowF(<-shadowK)(@divE)"]');
    179179
    180180    // Test for focusin/focusout events.
     
    186186    moveFocus('shadowD/shadowF/shadowG/divH', 'shadowD/shadowK/divL',
    187187              'Old focused node and new focused node exist in separated subtrees, crossing shadow boundaries. Making sure that an event is not dispatched beyond the lowest common boundary.');
    188     shouldBe('dispatchedEvent("focusin")', '["shadowK(<-shadowF)(@shadowK)", "divL(<-shadowF)(@divL)", "shadowK(<-shadowF)(@divJ)"]');
    189     shouldBe('dispatchedEvent("focusout")', '["shadowF(<-shadowK)(@shadowF)", "shadowG(<-shadowK)(@shadowG)", "divH(<-shadowK)(@divH)", "shadowF(<-shadowK)(@divE)"]');
     188    shouldBe('dispatchedEvent("focusin")', '["divL(<-shadowF)(@divL)", "shadowK(<-shadowF)(@shadowK)", "shadowK(<-shadowF)(@divJ)"]');
     189    shouldBe('dispatchedEvent("focusout")', '["divH(<-shadowK)(@divH)", "shadowG(<-shadowK)(@shadowG)", "shadowF(<-shadowK)(@shadowF)", "shadowF(<-shadowK)(@divE)"]');
    190190
    191191    // Omitted test cases where either a oldFocusedNode or newFocusedNode is an ancestor of the other.
     
    200200    moveFocus('shadowD/shadowF/shadowG/divH', 'shadowD/shadowK/divL',
    201201              'Old focused node and new focused node exist in separated subtrees, crossing shadow boundaries. Making sure that an event is not dispatched beyond the lowest common boundary.');
    202     shouldBe('dispatchedEvent("focus")', '["shadowK(<-shadowF)(@divJ)(capturing phase)", "shadowK(<-shadowF)(@shadowK)", "divL(<-shadowF)(@divL)"]');
    203     shouldBe('dispatchedEvent("blur")', '["shadowF(<-shadowK)(@divE)(capturing phase)", "shadowF(<-shadowK)(@shadowF)", "shadowG(<-shadowK)(@shadowG)", "divH(<-shadowK)(@divH)"]');
     202    shouldBe('dispatchedEvent("focus")', '["shadowK(<-shadowF)(@divJ)(capturing phase)", "divL(<-shadowF)(@divL)", "shadowK(<-shadowF)(@shadowK)"]');
     203    shouldBe('dispatchedEvent("blur")', '["shadowF(<-shadowK)(@divE)(capturing phase)", "divH(<-shadowK)(@divH)", "shadowG(<-shadowK)(@shadowG)", "shadowF(<-shadowK)(@shadowF)"]');
    204204}
    205205
  • trunk/LayoutTests/fast/dom/shadow/shadow-dom-event-dispatching-distributed-text-node-expected.txt

    r145873 r147371  
    2323
    2424  mousewheel
    25      @shadow-host (target: shadow-host)
    2625     @content (target: content)
    2726     @shadow-root (target: content)
     27     @shadow-host (target: shadow-host)
    2828     @top (target: shadow-host)
    2929
    3030  touchstart
    31      @shadow-host (target: shadow-host) (touches: shadow-host) (targetTouches: shadow-host) (changedTouches: shadow-host)
    3231     @content (target: content) (touches: content) (targetTouches: content) (changedTouches: content)
    3332     @shadow-root (target: content) (touches: content) (targetTouches: content) (changedTouches: content)
     33     @shadow-host (target: shadow-host) (touches: shadow-host) (targetTouches: shadow-host) (changedTouches: shadow-host)
    3434     @top (target: shadow-host) (touches: shadow-host) (targetTouches: shadow-host) (changedTouches: shadow-host)
    3535PASS successfullyParsed is true
  • trunk/LayoutTests/fast/dom/shadow/shadow-dom-event-dispatching-fallback-nodes-expected.txt

    r145873 r147371  
    3535
    3636  click
    37      @A (target: A)
    3837     @non-used-fallback (target: non-used-fallback)
    3938     @content2 (target: non-used-fallback)
    4039     @shadow-root (target: non-used-fallback)
     40     @A (target: A)
    4141     @top (target: A)
    4242PASS successfullyParsed is true
  • trunk/LayoutTests/fast/dom/shadow/shadow-dom-event-dispatching-non-distributed-nodes-expected.txt

    r145873 r147371  
    1616
    1717  click
    18      @A (target: A)
    1918     @C (target: C)
    2019     @B (target: C)
    2120     @orphaned-shadow-root (target: C)
     21     @A (target: A)
    2222     @top (target: A)
    2323
  • trunk/LayoutTests/fast/dom/shadow/shadow-dom-event-dispatching-text-node-in-shadow-root-expected.txt

    r145873 r147371  
    2323
    2424  touchstart
     25     @shadow-root (target: shadow-root) (touches: shadow-root) (targetTouches: shadow-root) (changedTouches: shadow-root)
    2526     @shadow-host (target: shadow-host) (touches: shadow-host) (targetTouches: shadow-host) (changedTouches: shadow-host)
    26      @shadow-root (target: shadow-root) (touches: shadow-root) (targetTouches: shadow-root) (changedTouches: shadow-root)
    2727     @top (target: shadow-host) (touches: shadow-host) (targetTouches: shadow-host) (changedTouches: shadow-host)
    2828
    2929  mousewheel
     30     @shadow-root (target: shadow-root)
    3031     @shadow-host (target: shadow-host)
    31      @shadow-root (target: shadow-root)
    3232     @top (target: shadow-host)
    3333PASS successfullyParsed is true
  • trunk/LayoutTests/fast/dom/shadow/shadow-root-blur-expected.txt

    r111672 r147371  
    1616PASS document.activeElement.id is "shadowHostA"
    1717getNodeInShadowTreeStack('shadowHostA/shadowHostB').blur();
     18shadowHostB onblur called!
    1819shadowHostA onblur called!
    19 shadowHostB onblur called!
    2020PASS document.activeElement is document.body
    2121PASS getNodeInShadowTreeStack('shadowHostA/').activeElement is null
     
    2525PASS document.activeElement.id is "shadowHostA"
    2626getNodeInShadowTreeStack('shadowHostA').blur();
     27shadowHostB onblur called!
    2728shadowHostA onblur called!
    28 shadowHostB onblur called!
    2929PASS document.activeElement is document.body
    3030PASS getNodeInShadowTreeStack('shadowHostA/').activeElement is null
  • trunk/Source/WebCore/ChangeLog

    r147370 r147371  
     12013-04-01  Hayato Ito  <hayato@chromium.org>
     2
     3        [Shadow DOM] Change the order of event dispatching at AT_TARGET phase.
     4        https://bugs.webkit.org/show_bug.cgi?id=113676
     5
     6        Reviewed by Dimitri Glazkov.
     7
     8        Change the order of event dispatching at AT_TARGET phase so that it mimics bubbling events.
     9
     10        The spec side bug is:
     11        https://www.w3.org/Bugs/Public/show_bug.cgi?id=21404
     12
     13        Example:
     14
     15        Given the event path, from Node A (top-most) to Node G (target,
     16        inner-most), where C and D are shadow hosts and G is the target,
     17        the event dispatching order in the current WebKit implementation is:
     18        (T: AT_TARGET, C: CAPTURING, B: BUBBLING)
     19
     20        For bubbling events:
     21
     22          A          1 (C)  11 (B)
     23          B          2 (C)  10 (B)
     24          C (SH)     3 (T)
     25          D          4 (C)   9 (B)
     26          E (SH)     5 (T)
     27          F          6 (C)   8 (B)
     28          G (Target) 7 (T)
     29
     30        For non-bubbling events:
     31
     32          A          1 (C)
     33          B          2 (C)
     34          C (SH)     3 (T)
     35          D          4 (C)
     36          E (SH)     5 (T)
     37          F          6 (C)
     38          G (Target) 7 (T)
     39
     40        This patch has changed the order of event dispatching as follows:
     41
     42        For bubbling events:
     43
     44          A          1 (C)  11 (B)
     45          B          2 (C)  10 (B)
     46          C (SH)             9 (T)
     47          D          3 (C)   8 (B)
     48          E (SH)             7 (T)
     49          F          4 (C)   6 (B)
     50          G (Target)         5 (T)
     51
     52        For non-bubbling events:
     53
     54          A          1 (C)
     55          B          2 (C)
     56          C (SH)            7 (T)
     57          D          3 (C)
     58          E (SH)            6 (T)
     59          F          4 (C)
     60          G (Target)        5 (T)
     61
     62        No new tests, updating existing layouts.
     63
     64        * dom/EventDispatcher.cpp:
     65        (WebCore::EventDispatcher::dispatchEventAtCapturing):
     66        (WebCore::EventDispatcher::dispatchEventAtBubbling):
     67        * dom/EventDispatcher.h:
     68        (EventDispatcher):
     69
    1702013-04-01  Nate Chapin  <japhet@chromium.org>
    271
  • trunk/Source/WebCore/dom/EventDispatcher.cpp

    r147135 r147371  
    154154        const EventContext& eventContext = *m_eventPath[i];
    155155        if (eventContext.currentTargetSameAsTarget())
    156             m_event->setEventPhase(Event::AT_TARGET);
    157         else
    158             m_event->setEventPhase(Event::CAPTURING_PHASE);
     156            continue;
    159157        eventContext.handleLocalEvents(m_event.get());
    160158        if (m_event->propagationStopped())
     
    172170}
    173171
    174 inline EventDispatchContinuation EventDispatcher::dispatchEventAtBubbling(WindowEventContext& windowContext)
    175 {
     172inline void EventDispatcher::dispatchEventAtBubbling(WindowEventContext& windowContext)
     173{
     174    // Trigger bubbling event handlers, starting at the bottom and working our way up.
     175    size_t size = m_eventPath.size();
     176    for (size_t i = 1; i < size; ++i) {
     177        const EventContext& eventContext = *m_eventPath[i];
     178        if (eventContext.currentTargetSameAsTarget())
     179            m_event->setEventPhase(Event::AT_TARGET);
     180        else if (m_event->bubbles() && !m_event->cancelBubble())
     181            m_event->setEventPhase(Event::BUBBLING_PHASE);
     182        else
     183            continue;
     184        eventContext.handleLocalEvents(m_event.get());
     185        if (m_event->propagationStopped())
     186            return;
     187    }
    176188    if (m_event->bubbles() && !m_event->cancelBubble()) {
    177         // Trigger bubbling event handlers, starting at the bottom and working our way up.
    178189        m_event->setEventPhase(Event::BUBBLING_PHASE);
    179 
    180         size_t size = m_eventPath.size();
    181         for (size_t i = 1; i < size; ++i) {
    182             const EventContext& eventContext = *m_eventPath[i];
    183             if (eventContext.currentTargetSameAsTarget())
    184                 continue;
    185             else
    186                 m_event->setEventPhase(Event::BUBBLING_PHASE);
    187             eventContext.handleLocalEvents(m_event.get());
    188             if (m_event->propagationStopped() || m_event->cancelBubble())
    189                 return DoneDispatching;
    190         }
    191190        windowContext.handleLocalEvents(m_event.get());
    192191    }
    193     return ContinueDispatching;
    194192}
    195193
  • trunk/Source/WebCore/dom/EventDispatcher.h

    r143426 r147371  
    7171    EventDispatchContinuation dispatchEventAtCapturing(WindowEventContext&);
    7272    EventDispatchContinuation dispatchEventAtTarget();
    73     EventDispatchContinuation dispatchEventAtBubbling(WindowEventContext&);
     73    void dispatchEventAtBubbling(WindowEventContext&);
    7474    void dispatchEventPostProcess(void* preDispatchEventHandlerResult);
    7575
Note: See TracChangeset for help on using the changeset viewer.