Skip to content

Commit

Permalink
LibWeb: Ignore mousewheel events in ViewportPaintable
Browse files Browse the repository at this point in the history
That allow EventHandler process wheel event on corresponding navigable.
For top-level navigable that means IPC call to let chrome know about
scrollbar position update.

Fixes #23599
Fixes #23493
Fixes #23966
  • Loading branch information
kalenikaliaksandr authored and awesomekling committed Apr 18, 2024
1 parent d530584 commit bad86ca
Show file tree
Hide file tree
Showing 4 changed files with 62 additions and 0 deletions.
@@ -0,0 +1 @@
new scrollY: 100
54 changes: 54 additions & 0 deletions Tests/LibWeb/Text/input/scroll-window-using-wheel-event.html
@@ -0,0 +1,54 @@
<!DOCTYPE html>
<style>
body {
overflow: scroll;
}

.box {
height: 300px;
width: 200px;
}

.red {
background-color: red;
}

.green {
background-color: green;
}

.cyan {
background-color: cyan;
}

.pink {
background-color: pink;
}

.blue {
background-color: blue;
}
</style>
<div class="container">
<div class="box red"></div>
<div class="box green"></div>
<div class="box blue"></div>
<div class="box pink"></div>
<div class="box cyan"></div>
<div class="box red"></div>
<div class="box green"></div>
<div class="box blue"></div>
<div class="box pink"></div>
<div class="box cyan"></div>
</div>
<script src="include.js"></script>
<script>
asyncTest(done => {
const container = document.querySelector(".container");
window.onscroll = () => {
println(`new scrollY: ${window.scrollY}`);
done();
};
internals.wheel(50, 50, 0, 100);
});
</script>
5 changes: 5 additions & 0 deletions Userland/Libraries/LibWeb/Painting/ViewportPaintable.cpp
Expand Up @@ -515,6 +515,11 @@ void ViewportPaintable::recompute_selection_states()
}
}

bool ViewportPaintable::handle_mousewheel(Badge<EventHandler>, CSSPixelPoint, unsigned, unsigned, int, int)
{
return false;
}

void ViewportPaintable::visit_edges(Visitor& visitor)
{
Base::visit_edges(visitor);
Expand Down
2 changes: 2 additions & 0 deletions Userland/Libraries/LibWeb/Painting/ViewportPaintable.h
Expand Up @@ -34,6 +34,8 @@ class ViewportPaintable final : public PaintableWithLines {
JS::GCPtr<Selection::Selection> selection() const;
void recompute_selection_states();

bool handle_mousewheel(Badge<EventHandler>, CSSPixelPoint, unsigned, unsigned, int wheel_delta_x, int wheel_delta_y) override;

private:
void build_stacking_context_tree();

Expand Down

0 comments on commit bad86ca

Please sign in to comment.