[Bug 21066] [Shadow]: Provide an event path api

https://www.w3.org/Bugs/Public/show_bug.cgi?id=21066

--- Comment #17 from Hayato Ito <hayato@chromium.org> ---
(In reply to comment #16)
> InsertionParent cannot be used to generate the event path. Here's an example:
> 
> <a>
>  <span id=”one” />
>  <span id=”two” />
> SR-a
>  <b>
>   <content id=”contentA”></content>
>  SR-b
>   <content id=”contentB” select=”#one”></content>
>   <content id=”contentB2” select=”#two”></content>
> 
> 
> click -> #one:
> #one
> [contentA]
> [contentB]
> SR-b
> b
> SR-a
> a
> 
> click -> #two:
> #two
> [contentA]
> [contentB2]
> SR-b
> b
> SR-a
> a
> 
> #contentA's insertionParent cannot be both #contentB and #contentB2.

That's right. That's the reason we cannot use the current implementation of
element.insertionParent() to emulate event.path as I noted in
https://www.w3.org/Bugs/Public/show_bug.cgi?id=21067#c11

- event.path should contain insertion points, which does not appear in the
flattened tree.
  The current element.insertionParent() cannot be used to traverse all
insertion points in case of reprojection.
- We need a *context* to determine insertionPoint.insertionParent().
  e.g. To determine #contentA's insertionParent, we need an additional context
(from where we are starting a path).
  In the above case, the context is #one or #two.

One idea is to make insertionParent() take additional parameter.

For example:
   contentA.insertionParent(#one) -> contentB
   contentA.insertionParent(#two) -> contentB2

Now, event.path can be emulated:

  var originalEventTarget = ....; // #one or #two
  var element = originalEventTarget;
  var eventPath = [element];
  while (element.insertionParent(originalEventTarget)) {
     element = element.insertionParent(originalEventTarget);
     // element might be an 'insertion point' in this case.
     eventPath.push(element);
  }

WDYT? Is this a reasonable API?

-- 
You are receiving this mail because:
You are the QA Contact for the bug.

Received on Wednesday, 24 April 2013 09:10:23 UTC