mirror of
https://github.com/RGBCube/serenity
synced 2025-05-31 04:58:13 +00:00
Ladybird+LibWebView: Migrate scrolling changes to LibWebView callbacks
This commit is contained in:
parent
00fe122b0a
commit
78d9339aa9
10 changed files with 73 additions and 98 deletions
|
@ -34,6 +34,35 @@ WebViewBridge::WebViewBridge(Vector<Gfx::IntRect> screen_rects, float device_pix
|
|||
m_inverse_device_pixel_ratio = 1.0 / device_pixel_ratio;
|
||||
|
||||
create_client(WebView::EnableCallgrindProfiling::No);
|
||||
|
||||
on_scroll_by_delta = [this](auto x_delta, auto y_delta) {
|
||||
// FIXME: This currently isn't reached because we do not yet propagate mouse wheel events to WebContent.
|
||||
// When that is implemented, make sure our mutations to the viewport position here are correct.
|
||||
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);
|
||||
};
|
||||
|
||||
on_scroll_into_view = [this](auto rect) {
|
||||
if (m_viewport_rect.contains(rect))
|
||||
return;
|
||||
|
||||
auto position = m_viewport_rect.location();
|
||||
|
||||
if (rect.top() < m_viewport_rect.top()) {
|
||||
position.set_y(rect.top());
|
||||
} else if (rect.top() > m_viewport_rect.top() && rect.bottom() > m_viewport_rect.bottom()) {
|
||||
position.set_y(rect.bottom() - m_viewport_rect.height());
|
||||
} else {
|
||||
return;
|
||||
}
|
||||
|
||||
if (on_scroll_to_point)
|
||||
on_scroll_to_point(position);
|
||||
};
|
||||
}
|
||||
|
||||
WebViewBridge::~WebViewBridge() = default;
|
||||
|
@ -104,43 +133,6 @@ Optional<WebViewBridge::Paintable> WebViewBridge::paintable()
|
|||
return Paintable { *bitmap, bitmap_size };
|
||||
}
|
||||
|
||||
void WebViewBridge::notify_server_did_request_scroll(Badge<WebView::WebContentClient>, i32 x_delta, i32 y_delta)
|
||||
{
|
||||
// FIXME: This currently isn't reached because we do not yet propagate mouse wheel events to WebContent.
|
||||
// When that is implemented, make sure our mutations to the viewport position here are correct.
|
||||
auto position = m_viewport_rect.location();
|
||||
position.set_x(position.x() + x_delta);
|
||||
position.set_y(position.y() + y_delta);
|
||||
|
||||
if (on_scroll)
|
||||
on_scroll(position);
|
||||
}
|
||||
|
||||
void WebViewBridge::notify_server_did_request_scroll_to(Badge<WebView::WebContentClient>, Gfx::IntPoint position)
|
||||
{
|
||||
if (on_scroll)
|
||||
on_scroll(position);
|
||||
}
|
||||
|
||||
void WebViewBridge::notify_server_did_request_scroll_into_view(Badge<WebView::WebContentClient>, Gfx::IntRect const& rect)
|
||||
{
|
||||
if (m_viewport_rect.contains(rect))
|
||||
return;
|
||||
|
||||
auto position = m_viewport_rect.location();
|
||||
|
||||
if (rect.top() < m_viewport_rect.top()) {
|
||||
position.set_y(rect.top());
|
||||
} else if (rect.top() > m_viewport_rect.top() && rect.bottom() > m_viewport_rect.bottom()) {
|
||||
position.set_y(rect.bottom() - m_viewport_rect.height());
|
||||
} else {
|
||||
return;
|
||||
}
|
||||
|
||||
if (on_scroll)
|
||||
on_scroll(position);
|
||||
}
|
||||
|
||||
void WebViewBridge::notify_server_did_enter_tooltip_area(Badge<WebView::WebContentClient>, Gfx::IntPoint, DeprecatedString const& tooltip)
|
||||
{
|
||||
if (on_tooltip_entered)
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue