Description
Describe the bug:
A touch triggers both touch and mouse events. Normally, after a component touchs down, the mouse event is skipped. However, in this case, the component responds to both touch and mouse signals. Currently, I found that when get the hit_test_result, the DOM tree has changed, and the node responding to the mouse event has also changed.
To Reproduce:
The current phenomenon : Touch event redirects to a new pop-up window, and then the mouse event close the pop-up.
LOG:
touch
10-27 21:43:28.868 54199 54960 E A00000/micservice.5765880207855116497/script::dom::document_event_h..: dingran1 TOUCH Up: at (359.3077, 567.4231) cursor Text
10-27 21:43:28.868 54199 54960 E A00000/micservice.5765880207855116497/script::dom::node: dingran1 Touch or Mouse ==node.dump==: "Element(HTMLElement(HTMLElement))"
10-27 21:43:28.868 54199 54960 E A00000/micservice.5765880207855116497/script::dom::node: dingran1 Touch or Mouse ==node.dump==: " CharacterData(Text(Text))"
10-27 21:43:28.871 54199 54960 E A00000/micservice.5765880207855116497/layout::display_list::hit_test: dingran1 HITTest hit_test result [ElementsFromPointResult { node: OpaqueNode(400575822312), point_in_target: (8.391052, 9.519714), cursor: Text }] point (359.3077, 567.4231)
Mouse
10-27 21:43:28.895 54199 54960 E A00000/micservice.5765880207855116497/script::dom::document_event_h..: dingran1 :: ==MouseButton DOWN== InputEvent
10-27 21:43:28.895 54199 54960 E A00000/micservice.5765880207855116497/layout::display_list::hit_test: dingran1 HITTest hit_test result [ElementsFromPointResult { node: OpaqueNode(400575880816), point_in_target: (359.3077, 567.4231), cursor: Default }] point (359.3077, 567.4231)
10-27 21:43:28.895 54199 54960 E A00000/micservice.5765880207855116497/script::dom::node: dingran1 Touch or Mouse ==node.dump==: "Element(HTMLElement(HTMLElement))"
Platform:
Ohos/Android.
Not sure if can be reproduced with touch simulation.
Activity
yezhizhen commentedon Oct 28, 2025
So the problem is,
yezhizhen commentedon Oct 28, 2025
I just checked the example provided by @kongbai1996. It seems firefox/Chromium also has the same behaviour: synthesized click has different target than the touch when layout changes.
code sample
I suspect there is nothing wrong with servo after reading spec. It is website's responsibility, to either
a. call
preventDefaultto prevent corresponding mouse events.or b. Use
pointerEventto unify all input devicescc @xiaochengh @mrobinson It seems the mouse synthesis is a legacy feature, and website developer should do one of above things.
mrobinson commentedon Nov 5, 2025
@yezhizhen Yep, seems pretty reasonable! Considering that the behavior here is the same as other browsers. Can we close this one?
script: Dispatch touch compatibility mouse events synchronously in `S…
script: Dispatch touch compatibility mouse events synchronously in `S…