Re: [w3c/webcomponents] "The event relatedTarget retargeting process must occur prior to dispatch of an event." (#485)

(not talking about relatedTarget here, just retargeting target)
Gecko ends up effectively iterate during capture phase, but it could be optimized out with a flag:
- When Gecko creates event target chain (== path), it goes from target up. Each item in the chain
is stored as separate object, simplified as (currentTarget, newTarget)
So normally it is enough to store currentTarget, but when dealing with node which parent in event path is in different subtree (so, crossing shadow boundary), also newTarget is stored for the _parent_ item. So during creation child tells whether parent needs newTarget.
- The first item in the chain has both currentTarget and newTarget stored, pointing to the same object. This just simplifies the implementation a bit.
- Now, when event is being handled, during _capture_ phase whenever we see that item has newTarget set, we need to retarget to something inside the anonymous tree. So the event target chain is iterated towards the original target and the first time newTarget is stored on some item, that is used as a new target. This is the case where we could possibly always store newTarget in item, and effectively retarget always, but retargeting would just end up changing .target to its current value. That would optimize out the iteration.
(I can't recall why I did it the way I did 10 years ago :) )
- _target_ phase doesn't need any special handling
- _bubble_ phase is in Gecko simpler than capture, since there newTarget can be used without iteration. Whenever item has newTarget set to non-null, make event's target to be that one.

This all sounds very much like https://github.com/w3c/webcomponents/issues/485#issuecomment-211852259 : don't store just target, but some tuple (currenTarget, target) - and maybe also relatedTarget?.
https://github.com/w3c/webcomponents/issues/485#issuecomment-211914860 is perhaps a bit hard to follow. I'd rather have just one list containing these tuples.

---
You are receiving this because you are subscribed to this thread.
Reply to this email directly or view it on GitHub:
https://github.com/w3c/webcomponents/issues/485#issuecomment-212538719

Received on Wednesday, 20 April 2016 18:07:05 UTC