mirror of
https://github.com/LadybirdBrowser/ladybird.git
synced 2025-04-24 05:25:13 +00:00
LibWeb: Fire "mousedown" and "mousemove" events in the DOM :^)
This commit is contained in:
parent
f39e5352f0
commit
e265058768
Notes:
sideshowbarker
2024-07-19 08:15:27 +09:00
Author: https://github.com/awesomekling Commit: https://github.com/SerenityOS/serenity/commit/e2650587689
3 changed files with 28 additions and 6 deletions
25
Base/home/anon/www/events.html
Normal file
25
Base/home/anon/www/events.html
Normal file
|
@ -0,0 +1,25 @@
|
|||
<!DOCTYPE html>
|
||||
<html>
|
||||
<head>
|
||||
<script>
|
||||
function foo() {
|
||||
alert("It loaded!");
|
||||
}
|
||||
document.addEventListener("DOMContentLoaded", foo);
|
||||
|
||||
function on_mousedown() {
|
||||
alert("Mouse down!");
|
||||
}
|
||||
|
||||
function on_mousemove() {
|
||||
alert("Mouse move!");
|
||||
}
|
||||
|
||||
document.getElementById("my_div").addEventListener("mousedown", on_mousedown);
|
||||
document.getElementById("my_div").addEventListener("mousemove", on_mousemove);
|
||||
</script>
|
||||
</head>
|
||||
<body>
|
||||
<div id="my_div">Hello there!</div>
|
||||
</body>
|
||||
</html>
|
|
@ -17,18 +17,13 @@ h1 {
|
|||
color: #a00;
|
||||
}
|
||||
</style>
|
||||
<script>
|
||||
function foo() {
|
||||
alert("It loaded!");
|
||||
}
|
||||
document.addEventListener("DOMContentLoaded", foo);
|
||||
</script>
|
||||
</head>
|
||||
<body link="#44f" vlink="#c4c" background="90s-bg.png">
|
||||
<h1>Welcome to the Serenity Browser!</h1>
|
||||
<p>This is a very simple browser built on the LibWeb engine.</p>
|
||||
<p>Some small test pages:</p>
|
||||
<ul>
|
||||
<li><a href="events.html">simple DOM events test</a></li>
|
||||
<li><a href="dom.html">simple DOM JS test</a></li>
|
||||
<li><a href="alert.html">alert() test</a></li>
|
||||
<li><a href="small.html">small</a></li>
|
||||
|
|
|
@ -184,6 +184,7 @@ void HtmlView::mousemove_event(GUI::MouseEvent& event)
|
|||
#endif
|
||||
is_hovering_link = true;
|
||||
}
|
||||
const_cast<Node*>(node)->dispatch_event("mousemove");
|
||||
}
|
||||
if (m_in_mouse_selection) {
|
||||
layout_root()->selection().set_end({ result.layout_node, result.index_in_node });
|
||||
|
@ -234,6 +235,7 @@ void HtmlView::mousedown_event(GUI::MouseEvent& event)
|
|||
m_in_mouse_selection = true;
|
||||
}
|
||||
}
|
||||
const_cast<Node*>(node)->dispatch_event("mousedown");
|
||||
}
|
||||
}
|
||||
if (hovered_node_changed)
|
||||
|
|
Loading…
Add table
Reference in a new issue