New issue
Advanced search Search tips

Issue 787141 link

Starred by 1 user

Issue metadata

Status: Assigned
Owner:
Components:
EstimatedDays: ----
NextAction: ----
OS: Windows
Pri: 3
Type: Bug



Sign in to add a comment

base::NativeEvent does not include full modifier-state

Project Member Reported by w...@chromium.org, Nov 20 2017

Issue description

ui::Events created from platform input events include a base::NativeEvent containing the raw platform-native event data.

Under Windows, this is the MSG for the input event, which does not include full detail of the modifiers active when the event was received.  This means that code which expects to be able to re-create a ui::Event from a stored NativEvent runs the risk of re-creating it with incorrect modifiers set, if any other input MSGs have been processed in the meantime.

We could capture all the "raw" modifier state when receiving the MSG, to include in the base::NativeEvent, and migrate call-sites which currently rely on directly querying the ui::GetModifiersFromKeyState() helper.

 
We shouldn't ever recreate the event from the underlying MSG. When the ui::Event is created it should store all the good state.

I'm aware of two builders here:
https://cs.chromium.org/chromium/src/ui/events/blink/web_input_event_builders_win.h?sq=package:chromium

that should really be removed. Which ones were problems for you?

Comment 2 by w...@chromium.org, Nov 21 2017

I've already removed the KeyboardEvent equivalent of the builders you link
to in comment #1.

Besides the remaining builders we have
PenEventProcess::GenerateMouseEvent() using GetModifiersFromKeyState().  We
then have calls to ui::EventFromNative(), which internally calls on to
that, in various places.  Each of these call-sites is removed to some
degree from the HWND message handler, making it harder to reason about
whether the modifiers grabbed from the thread keyboard state are actually
correct.

We also expose the SystemEventStateLookup helpers so that anyone can query
the thread keyboard state; I'd suggest hiding those, to avoid misuse.
PenEventProcessor is called from the HWND handler so it is ok.

Personally my approach would be to never have the native os_event hung off of the ui::Event.

What is the primary reason it is still needed?

Comment 4 by w...@chromium.org, Nov 21 2017

Under Windows it gets used to populate fields in WebInputEvents that
ui::Event populates differently, or loses entirely.

For keyboard events, for example, ui::Event has a different notion of
whether the event is a "system key", and we lose the "native_key_code",
which it seems some Blink code may still rely on.

Auditing for uses of those and migrating them is likely tedious, but
certainly do-able, and I agree that we should convert to ui::Events and
work with that, not keep dipping back in to the "original" event.
Status: Assigned (was: Untriaged)
Owner: nzolghadr@chromium.org

Sign in to add a comment