Commit eab2c2c
Fix click dispatch for ephemeral hit-testable pseudo-elements
The `PseudoElementsHitTestable` feature allows pseudo-elements to be
returned by hit-testing. However, ephemeral pseudo-elements (like
`:active::after`) are often destroyed synchronously during event
dispatch, causing `click` events to be silently dropped.
Root Cause Steps:
1. `mousedown` sets an element to `:active`, causing `::after` to
appear and become hit-testable.
2. `mouseup` hit-tests the newly created `::after` pseudo-element.
3. `PointerEventManager` caches `::after` as the `mouse_target` and
dispatches the `pointerup` and `mouseup` events.
4. JavaScript listeners (e.g., React) trigger a state update and
synchronous layout on `mouseup`.
5. The `:active` state is removed, causing `::after` to be disposed
and orphaned (parent set to `nullptr`).
6. `PointerEventManager` attempts to dispatch the `click` event using
the cached, now-orphaned `::after` target.
7. `CommonAncestor` between the `mousedown` target and the orphaned
`mouseup` target returns `nullptr`, dropping the click event.
This CL fixes interaction leaks by gracefully falling back to the
originating element when a hit-testable pseudo-element is removed,
matching pre-feature behavior:
- `PseudoElement::Dispose`: Now notifies the Document via
`NodeWillBeRemoved` before clearing its parent.
- `MouseEventManager`: Falls back `mousedown_element_` to the
originating element instead of clearing it to `nullptr`.
- `PointerEventManager`: Updates pointer capture targets to the
originating element. Also falls back the local `mouse_target`
during click dispatch if it disconnected mid-dispatch.
- `PointerEventFactory`: Updates `pointer_down_target` and
`pointer_up_target` for Popover Light Dismiss calculations.
- `TouchEventManager`: Falls back active touch targets to the
originating element.
Fixed: 500640685
Change-Id: I5d08dc3e4d50f5a8a8fb6e1a3d1f69c7127a7939
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/7735452
Reviewed-by: Mason Freed <masonf@chromium.org>
Commit-Queue: Daniil Sakhapov <sakhapov@chromium.org>
Cr-Commit-Position: refs/heads/main@{#1616450}1 parent 3c0a160 commit eab2c2c
2 files changed
Lines changed: 127 additions & 0 deletions
File tree
- css/css-pseudo
- dom/events
Lines changed: 64 additions & 0 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
| 1 | + | |
| 2 | + | |
| 3 | + | |
| 4 | + | |
| 5 | + | |
| 6 | + | |
| 7 | + | |
| 8 | + | |
| 9 | + | |
| 10 | + | |
| 11 | + | |
| 12 | + | |
| 13 | + | |
| 14 | + | |
| 15 | + | |
| 16 | + | |
| 17 | + | |
| 18 | + | |
| 19 | + | |
| 20 | + | |
| 21 | + | |
| 22 | + | |
| 23 | + | |
| 24 | + | |
| 25 | + | |
| 26 | + | |
| 27 | + | |
| 28 | + | |
| 29 | + | |
| 30 | + | |
| 31 | + | |
| 32 | + | |
| 33 | + | |
| 34 | + | |
| 35 | + | |
| 36 | + | |
| 37 | + | |
| 38 | + | |
| 39 | + | |
| 40 | + | |
| 41 | + | |
| 42 | + | |
| 43 | + | |
| 44 | + | |
| 45 | + | |
| 46 | + | |
| 47 | + | |
| 48 | + | |
| 49 | + | |
| 50 | + | |
| 51 | + | |
| 52 | + | |
| 53 | + | |
| 54 | + | |
| 55 | + | |
| 56 | + | |
| 57 | + | |
| 58 | + | |
| 59 | + | |
| 60 | + | |
| 61 | + | |
| 62 | + | |
| 63 | + | |
| 64 | + | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
| 1 | + | |
| 2 | + | |
| 3 | + | |
| 4 | + | |
| 5 | + | |
| 6 | + | |
| 7 | + | |
| 8 | + | |
| 9 | + | |
| 10 | + | |
| 11 | + | |
| 12 | + | |
| 13 | + | |
| 14 | + | |
| 15 | + | |
| 16 | + | |
| 17 | + | |
| 18 | + | |
| 19 | + | |
| 20 | + | |
| 21 | + | |
| 22 | + | |
| 23 | + | |
| 24 | + | |
| 25 | + | |
| 26 | + | |
| 27 | + | |
| 28 | + | |
| 29 | + | |
| 30 | + | |
| 31 | + | |
| 32 | + | |
| 33 | + | |
| 34 | + | |
| 35 | + | |
| 36 | + | |
| 37 | + | |
| 38 | + | |
| 39 | + | |
| 40 | + | |
| 41 | + | |
| 42 | + | |
| 43 | + | |
| 44 | + | |
| 45 | + | |
| 46 | + | |
| 47 | + | |
| 48 | + | |
| 49 | + | |
| 50 | + | |
| 51 | + | |
| 52 | + | |
| 53 | + | |
| 54 | + | |
| 55 | + | |
| 56 | + | |
| 57 | + | |
| 58 | + | |
| 59 | + | |
| 60 | + | |
| 61 | + | |
| 62 | + | |
| 63 | + | |
0 commit comments