mirror of
https://github.com/RGBCube/serenity
synced 2025-07-25 16:47:36 +00:00
LibWeb: Return correct value from EventHandler::fire_keyboard_event()
The returned bool should be true if the event was consumed, aka if we should ignore it. But `dispatch_event()` returns true if you *shouldn't* ignore it, so we have to invert that return value.
This commit is contained in:
parent
9ca41a181d
commit
b517032354
1 changed files with 4 additions and 3 deletions
|
@ -649,6 +649,7 @@ bool EventHandler::focus_previous_element()
|
|||
constexpr bool should_ignore_keydown_event(u32 code_point)
|
||||
{
|
||||
// FIXME: There are probably also keys with non-zero code points that should be filtered out.
|
||||
// FIXME: We should take the modifier keys into consideration somehow. This treats "Ctrl+C" as just "c".
|
||||
return code_point == 0 || code_point == 27;
|
||||
}
|
||||
|
||||
|
@ -666,16 +667,16 @@ bool EventHandler::fire_keyboard_event(FlyString const& event_name, HTML::Browsi
|
|||
}
|
||||
|
||||
auto event = UIEvents::KeyboardEvent::create_from_platform_event(document->realm(), event_name, key, modifiers, code_point);
|
||||
return focused_element->dispatch_event(*event);
|
||||
return !focused_element->dispatch_event(*event);
|
||||
}
|
||||
|
||||
// FIXME: De-duplicate this. This is just to prevent wasting a KeyboardEvent allocation when recursing into an (i)frame.
|
||||
auto event = UIEvents::KeyboardEvent::create_from_platform_event(document->realm(), event_name, key, modifiers, code_point);
|
||||
|
||||
if (JS::GCPtr<HTML::HTMLElement> body = document->body())
|
||||
return body->dispatch_event(*event);
|
||||
return !body->dispatch_event(*event);
|
||||
|
||||
return document->root().dispatch_event(*event);
|
||||
return !document->root().dispatch_event(*event);
|
||||
}
|
||||
|
||||
bool EventHandler::handle_keydown(KeyCode key, unsigned modifiers, u32 code_point)
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue