[focus] Make mouse focus use flat tree parent
This is an updated version of patch:
https://crrev.com/c/1514433
Currently, mouse-triggered event will traverse up parentOrShadowHost
to find fallback element to receive mouse focus. This doesn't make sense
for slotted content, where we expect the parent to receive focus to be
the assigned slot. This is fixed by traversing using the Flat Tree.
In the DOM spec for the Dispatch algorithm [1]:
"If isActivationEvent is true, event’s bubbles attribute is true,
activationTarget is null, and parent has activation behavior, then set
activationTarget to parent."
The parent is found using the get the parent algorithm [2]:
"A node’s get the parent algorithm, given an event, returns the node’s
assigned slot, if node is assigned; otherwise node’s parent."
Previously, this patch was reverted because it broke the text selection
in DevTools Network panel, which uses slots. This is fixed by
updating FrameSelection to use flat tree traversal to find parent.
The change is behind flag MouseFocusFlatTreeParent.
[1] https://dom.spec.whatwg.org/#concept-event-dispatch
[2] https://dom.spec.whatwg.org/#get-the-parent
Change-Id: Ibfeaebab0dce4817c34b447f540e784b12b9ab56
Bug: 41420461
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/6004068
Auto-Submit: Di Zhang dizhangg@chromium.org
Commit-Queue: David Baron dbaron@chromium.org
Reviewed-by: David Baron dbaron@chromium.org
Cr-Commit-Position: refs/heads/main@{#1384575}