mirror of
https://github.com/LadybirdBrowser/ladybird.git
synced 2025-09-15 05:52:19 +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.
This commit is contained in:
parent
728fca1b1f
commit
31d7fa2442
Notes:
sideshowbarker
2024-07-17 21:16:31 +09:00
Author: https://github.com/tcl3
Commit: 31d7fa2442
Pull-request: https://github.com/LadybirdBrowser/ladybird/pull/238
Issue: https://github.com/LadybirdBrowser/ladybird/issues/175
3 changed files with 25 additions and 0 deletions
1
Tests/LibWeb/Text/expected/UIEvents/auxevent.txt
Normal file
1
Tests/LibWeb/Text/expected/UIEvents/auxevent.txt
Normal file
|
@ -0,0 +1 @@
|
||||||
|
auxclick event fired
|
22
Tests/LibWeb/Text/input/UIEvents/auxevent.html
Normal file
22
Tests/LibWeb/Text/input/UIEvents/auxevent.html
Normal 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>
|
|
@ -278,6 +278,8 @@ bool EventHandler::handle_mouseup(CSSPixelPoint viewport_position, CSSPixelPoint
|
||||||
if (node.ptr() == m_mousedown_target) {
|
if (node.ptr() == m_mousedown_target) {
|
||||||
if (button == UIEvents::MouseButton::Primary) {
|
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());
|
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) {
|
} else if (button == UIEvents::MouseButton::Secondary) {
|
||||||
// Allow the user to bypass custom context menus by holding shift, like Firefox.
|
// Allow the user to bypass custom context menus by holding shift, like Firefox.
|
||||||
if ((modifiers & UIEvents::Mod_Shift) == 0)
|
if ((modifiers & UIEvents::Mod_Shift) == 0)
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue