Touch selection contextmenu pointer type

#41487195 Filed 2023-12-28 Open

What changes

Double-tap an editable word with touch input. The DOM sees pointerdown(touch), pointerup(touch) twice, then a contextmenu event. The inherited code synthesizes that menu event with a mouse pointer type; the patch uses touch for touch-originated menu sources. The menu event still fires.

The screenshots below capture actual input through Chromium's touch pipeline: two Input.dispatchTouchEvent taps into the same locally built content_shell, before with the kill switch disabled, after with it enabled. They are not JS-created DOM events.

Before / feature off contextmenu.pointerType = "mouse"
After / feature on contextmenu.pointerType = "touch"

Before and after captures

Before: two touch pointerdown/up pairs followed by a contextmenu with pointerType mouse
BEFORE: touch selection fires contextmenu with pointerType=mouse. Click to read the full log.
After: two touch pointerdown/up pairs followed by a contextmenu with pointerType touch
AFTER: same two touch taps; the menu event reports pointerType=touch.

View changed pixels

Try the live repro

On a touchscreen, double-tap the editable text below and read the event sequence. On Android, dragging a selection handle can issue another menu request. The live result reflects your browser, not the captures above. Mouse-only devices will not exercise this case.

Open live repro directly

Scope and remaining limitation

EventHandler::ShowNonLocatedContextMenu creates a synthetic WebMouseEvent. Touch menu sources get pointerType=touch with the feature on; disabling ContextMenuPointerTypeForTouch restores mouse. The captured pointerId is still 1 for the menu event, while the second tap is 3: this change addresses pointerType only, not the spec's pointerId requirement.

To recapture: xvfb-run -a python3 capture_screenshots.py from ~/lab/samplers/i-41487195 with Pillow and websocket-client installed. No physical touchscreen was exposed on this build machine; the captures use Chromium's DevTools touch input.