1
0
mirror of https://github.com/SerenityOS/serenity synced 2024-07-01 11:35:37 +00:00

LibWeb: Fire auxclick event on middle click

Previously, no event was fired on middle click. This change also allows
the UI to open a link in a new tab on middle click.

(cherry picked from commit 31d7fa244232c2a2239dbf6017ba9e3dd191ec2e)
This commit is contained in:
Tim Ledbetter 2024-06-21 22:00:19 +01:00 committed by Nico Weber
parent 2554d766bc
commit b62c572154
3 changed files with 25 additions and 0 deletions

View File

@ -0,0 +1 @@
auxclick event fired

View File

@ -0,0 +1,22 @@
<!DOCTYPE html>
<style>
body {
margin: 0px;
padding: 5px;
width: 200px;
height: 200px;
}
</style>
<script src="../include.js"></script>
<script>
asyncTest(done => {
document.body.onauxclick = () => {
println("auxclick event fired");
done();
};
window.onload = () => {
internals.middleClick(10, 10);
};
});
</script>

View File

@ -272,6 +272,8 @@ bool EventHandler::handle_mouseup(CSSPixelPoint position, CSSPixelPoint screen_p
if (node.ptr() == m_mousedown_target) {
if (button == UIEvents::MouseButton::Primary) {
run_activation_behavior = node->dispatch_event(UIEvents::MouseEvent::create_from_platform_event(node->realm(), UIEvents::EventNames::click, screen_position, page_offset, client_offset, offset, {}, 1, button, modifiers).release_value_but_fixme_should_propagate_errors());
} else if (button == UIEvents::MouseButton::Middle) {
run_activation_behavior = node->dispatch_event(UIEvents::MouseEvent::create_from_platform_event(node->realm(), UIEvents::EventNames::auxclick, screen_position, page_offset, client_offset, offset, {}, 1, button, modifiers).release_value_but_fixme_should_propagate_errors());
} else if (button == UIEvents::MouseButton::Secondary) {
// Allow the user to bypass custom context menus by holding shift, like Firefox.
if ((modifiers & Mod_Shift) == 0)