[Bug 23887] [Shadow] Change the order of insertion points which are involved in a re-distribution in event path

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

--- Comment #187 from Hayato Ito <hayato@chromium.org> ---
Okay. Let me propose the new algorithm. Let's call this "hayato-2015-04"
algorithm.

1. Let PATH be the empty ordered list of nodes
2. Let INSERTION-POINT-STACK be an empty stack of nodes
3. Let CURRENT be NODE
4. Repeat while CURRENT exists:
   1. Add CURRENT to PATH
   2. Let INSERTION-POINTS be the destination insertion points of CURRENT
   3. If INSERTION-POINTS is not empty:
      1. Push INSERTION-POINTS into INSERTION-POINT-STACK in order of first
destination to final destination
      2. Pop INSERTION-POINT-STACK and set CURRENT to be the popped node.
   4. Otherwise if CURRENT is a shadow root:
      1. If CURRENT is the oldest shadow root:
         1. Let HOST be the shadow host which hosts CURRENT
      2. Otherwise:
         1. Let HOST be the older shadow root relative to CURRENT
      3. If INSERTION-POINT-STACK is not empty and the most recent node in the
INSERTION-POINT-STACK is in the same node tree as HOST
         1. Pop INSERTION-POINT-STACK and set CURRENT to be the popped node.
      4. Otherwise if CURRENT and NODE participates in the same node tree and
EVENT is one of the events which must be stopped:
         1. Stop this algorithm
      5. Otherwise:
         1. Let CURRENT be HOST
   5. Otherwise:
      1. Let CURRENT be the parent node of CURRENT



"hayato-2015-04" is based on my mental model - A concept of "Multiple shadow
roots" are just a syntax sugar for "the older shadow root *hosts* the younger
shadow root".
According to this concept, we can merge (4.4.1) and (4.4.2) further by the
following one sentence:

  "Let HOST be the shadow host (or the shadow root) which *hosts* CURRENT".

Note that this is the moment where we move from the child tree to the parent
tree in a tree of trees. The new algorithm matches a concept of a tree of trees
nicely.


As a result, "hayato-2015-04" doesn't have to use a term of {older shadow root,
younger shadow root, oldest shadow root, youngest shadow root} nor {content
insertion point, shadow insertion point} at all. The algorithm doesn't need to
distinguish them. I'm feeling this is a good signal.


One side effect:
- Now the older shadow root receives an event after the younger shadow root.
However, this behavior matches "A shadow host receives an event after the
oldest shadow root".

I can say, in a uniform way, "The root node of the parent tree receives an
event after the root node of the child tree" in a tree of trees.


Caution: The new algorithm is only evaluated in my head in a short time. I'll
have another look later, however, I appreciate if you could give me early
feedback since I'm flying to Mountain View / San Francisco soon.

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

Received on Monday, 20 April 2015 03:21:33 UTC