mirror of
https://github.com/LadybirdBrowser/ladybird.git
synced 2024-11-22 23:50:19 +00:00
headless-browser: Implement on_scroll_to_point and on_scroll_by_delta
Without these callbacks "scroll" events are not emitted so we can't write tests for scrolling.
This commit is contained in:
parent
b27a62488c
commit
a93ab25487
Notes:
sideshowbarker
2024-07-17 07:25:39 +09:00
Author: https://github.com/kalenikaliaksandr Commit: https://github.com/SerenityOS/serenity/commit/a93ab25487 Pull-request: https://github.com/SerenityOS/serenity/pull/22351
1 changed files with 16 additions and 1 deletions
|
@ -109,7 +109,22 @@ public:
|
|||
}
|
||||
|
||||
private:
|
||||
HeadlessWebContentView() = default;
|
||||
HeadlessWebContentView()
|
||||
{
|
||||
on_scroll_to_point = [this](auto position) {
|
||||
auto new_viewport_rect = m_viewport_rect;
|
||||
new_viewport_rect.set_location(position);
|
||||
client().async_set_viewport_rect(new_viewport_rect.to_type<Web::DevicePixels>());
|
||||
};
|
||||
|
||||
on_scroll_by_delta = [this](auto x_delta, auto y_delta) {
|
||||
auto position = m_viewport_rect.location();
|
||||
position.set_x(position.x() + x_delta);
|
||||
position.set_y(position.y() + y_delta);
|
||||
if (on_scroll_to_point)
|
||||
on_scroll_to_point(position);
|
||||
};
|
||||
}
|
||||
|
||||
void update_zoom() override { }
|
||||
void create_client() override { }
|
||||
|
|
Loading…
Reference in a new issue