On 10/16/20 11:32 PM, Rune Lillesveen wrote:> I think the main concern
was actually performance of dir="auto" without > introducing a cache for
element directionality, since that requires a > subtree traversal[1] for
each resolution.> > Based on [2] from the previous intent, it seems
Gecko caches the result.
It's not so much a cache (as in the nth-child kind of cache that all
browsers have) fwiw, it's more of a "Gecko keeps the directionality of
the DOM up-to-date on DOM mutations". In particular, we keep two node
bits for the dir pseudo-class[1]. There are a couple bits to make
dir=auto and directionality computation efficient and such too, much
like the existing Blink bits in the ComputedStyle...
It seems Blink right now stores dir=auto information in style for some
reason, which looks really odd/sketchy (and heh, it seems esprehn@
agreed[2]).
Regarding Shadow DOM, the behavior in Gecko is a bit more subtle than
walking the shadow-including parent chain (specially wrt slotting), but
we believe it is the right one based on the discussions in [3][4], and
was implemented in [5] and [6] (and there are some WPT tests for that).
Cheers,
-- Emilio
[1]:
https://searchfox.org/mozilla-central/rev/f43cef551760b268a3d22eaddd0e76719acf2d88/dom/events/EventStates.h#261-264
[2]:
https://source.chromium.org/chromium/chromium/src/+/master:third_party/blink/renderer/core/html/html_element.cc;l=1166-1173;drc=449eeaa3adcc30f2ad63611bf919e67e887da36d
[3]:
https://github.com/whatwg/html/issues/3699
[4]:
https://github.com/whatwg/html/issues/4906
[5]:
https://bugzilla.mozilla.org/show_bug.cgi?id=1469108
[6]:
https://bugzilla.mozilla.org/show_bug.cgi?id=1100912