mirror of
https://github.com/LadybirdBrowser/ladybird.git
synced 2024-09-11 05:25:32 +03:00
Ladybird+LibWebView: Migrate cursor changes to LibWebView callbacks
This commit is contained in:
parent
bf464665a7
commit
00fe122b0a
Notes:
sideshowbarker
2024-07-16 21:51:02 +09:00
Author: https://github.com/trflynn89 Commit: https://github.com/SerenityOS/serenity/commit/00fe122b0a Pull-request: https://github.com/SerenityOS/serenity/pull/20727 Reviewed-by: https://github.com/awesomekling ✅
@ -104,12 +104,6 @@ Optional<WebViewBridge::Paintable> WebViewBridge::paintable()
|
||||
return Paintable { *bitmap, bitmap_size };
|
||||
}
|
||||
|
||||
void WebViewBridge::notify_server_did_request_cursor_change(Badge<WebView::WebContentClient>, Gfx::StandardCursor cursor)
|
||||
{
|
||||
if (on_cursor_change)
|
||||
on_cursor_change(cursor);
|
||||
}
|
||||
|
||||
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.
|
||||
|
@ -51,15 +51,12 @@ public:
|
||||
|
||||
Function<void(Gfx::IntPoint)> on_scroll;
|
||||
|
||||
Function<void(Gfx::StandardCursor)> on_cursor_change;
|
||||
|
||||
Function<void(DeprecatedString const&)> on_tooltip_entered;
|
||||
Function<void()> on_tooltip_left;
|
||||
|
||||
private:
|
||||
WebViewBridge(Vector<Gfx::IntRect> screen_rects, float device_pixel_ratio, Optional<StringView> webdriver_content_ipc_path);
|
||||
|
||||
virtual void notify_server_did_request_cursor_change(Badge<WebView::WebContentClient>, Gfx::StandardCursor cursor) override;
|
||||
virtual void notify_server_did_request_scroll(Badge<WebView::WebContentClient>, i32, i32) override;
|
||||
virtual void notify_server_did_request_scroll_to(Badge<WebView::WebContentClient>, Gfx::IntPoint) override;
|
||||
virtual void notify_server_did_request_scroll_into_view(Badge<WebView::WebContentClient>, Gfx::IntRect const&) override;
|
||||
|
@ -88,6 +88,10 @@ WebContentView::WebContentView(StringView webdriver_content_ipc_path, WebView::E
|
||||
on_ready_to_paint = [this]() {
|
||||
viewport()->update();
|
||||
};
|
||||
|
||||
on_cursor_change = [this](auto cursor) {
|
||||
update_cursor(cursor);
|
||||
};
|
||||
}
|
||||
|
||||
WebContentView::~WebContentView() = default;
|
||||
@ -600,7 +604,7 @@ void WebContentView::create_client(WebView::EnableCallgrindProfiling enable_call
|
||||
client().async_connect_to_webdriver(m_webdriver_content_ipc_path);
|
||||
}
|
||||
|
||||
void WebContentView::notify_server_did_request_cursor_change(Badge<WebContentClient>, Gfx::StandardCursor cursor)
|
||||
void WebContentView::update_cursor(Gfx::StandardCursor cursor)
|
||||
{
|
||||
switch (cursor) {
|
||||
case Gfx::StandardCursor::Hidden:
|
||||
|
@ -76,7 +76,6 @@ public:
|
||||
};
|
||||
void update_palette(PaletteMode = PaletteMode::Default);
|
||||
|
||||
virtual void notify_server_did_request_cursor_change(Badge<WebContentClient>, Gfx::StandardCursor cursor) override;
|
||||
virtual void notify_server_did_request_scroll(Badge<WebContentClient>, i32, i32) override;
|
||||
virtual void notify_server_did_request_scroll_to(Badge<WebContentClient>, Gfx::IntPoint) override;
|
||||
virtual void notify_server_did_request_scroll_into_view(Badge<WebContentClient>, Gfx::IntRect const&) override;
|
||||
@ -96,6 +95,7 @@ private:
|
||||
virtual Gfx::IntPoint to_widget_position(Gfx::IntPoint content_position) const override;
|
||||
|
||||
void update_viewport_rect();
|
||||
void update_cursor(Gfx::StandardCursor cursor);
|
||||
|
||||
qreal m_inverse_pixel_scaling_ratio { 1.0 };
|
||||
bool m_should_show_line_box_borders { false };
|
||||
|
@ -45,6 +45,10 @@ OutOfProcessWebView::OutOfProcessWebView()
|
||||
else
|
||||
client().async_handle_file_return(0, IPC::File(file.value().stream()), request_id);
|
||||
};
|
||||
|
||||
on_cursor_change = [this](auto cursor) {
|
||||
set_override_cursor(cursor);
|
||||
};
|
||||
}
|
||||
|
||||
OutOfProcessWebView::~OutOfProcessWebView() = default;
|
||||
@ -183,11 +187,6 @@ void OutOfProcessWebView::screen_rects_change_event(GUI::ScreenRectsChangeEvent&
|
||||
client().async_update_screen_rects(event.rects(), event.main_screen_index());
|
||||
}
|
||||
|
||||
void OutOfProcessWebView::notify_server_did_request_cursor_change(Badge<WebContentClient>, Gfx::StandardCursor cursor)
|
||||
{
|
||||
set_override_cursor(cursor);
|
||||
}
|
||||
|
||||
void OutOfProcessWebView::notify_server_did_request_scroll(Badge<WebContentClient>, i32 x_delta, i32 y_delta)
|
||||
{
|
||||
horizontal_scrollbar().increase_slider_by(x_delta);
|
||||
|
@ -82,7 +82,6 @@ private:
|
||||
// ^WebView::ViewImplementation
|
||||
virtual void create_client(EnableCallgrindProfiling = EnableCallgrindProfiling::No) override;
|
||||
virtual void update_zoom() override;
|
||||
virtual void notify_server_did_request_cursor_change(Badge<WebContentClient>, Gfx::StandardCursor cursor) override;
|
||||
virtual void notify_server_did_request_scroll(Badge<WebContentClient>, i32, i32) override;
|
||||
virtual void notify_server_did_request_scroll_to(Badge<WebContentClient>, Gfx::IntPoint) override;
|
||||
virtual void notify_server_did_request_scroll_into_view(Badge<WebContentClient>, Gfx::IntRect const&) override;
|
||||
|
@ -115,6 +115,7 @@ public:
|
||||
Function<void()> on_navigate_forward;
|
||||
Function<void()> on_refresh;
|
||||
Function<void(Gfx::Bitmap const&)> on_favicon_change;
|
||||
Function<void(Gfx::StandardCursor)> on_cursor_change;
|
||||
Function<void(String const& message)> on_request_alert;
|
||||
Function<void(String const& message)> on_request_confirm;
|
||||
Function<void(String const& message, String const& default_)> on_request_prompt;
|
||||
@ -140,7 +141,6 @@ public:
|
||||
Function<Gfx::IntRect()> on_minimize_window;
|
||||
Function<Gfx::IntRect()> on_fullscreen_window;
|
||||
|
||||
virtual void notify_server_did_request_cursor_change(Badge<WebContentClient>, Gfx::StandardCursor cursor) = 0;
|
||||
virtual void notify_server_did_request_scroll(Badge<WebContentClient>, i32, i32) = 0;
|
||||
virtual void notify_server_did_request_scroll_to(Badge<WebContentClient>, Gfx::IntPoint) = 0;
|
||||
virtual void notify_server_did_request_scroll_into_view(Badge<WebContentClient>, Gfx::IntRect const&) = 0;
|
||||
|
@ -82,7 +82,9 @@ void WebContentClient::did_request_cursor_change(i32 cursor_type)
|
||||
dbgln("DidRequestCursorChange: Bad cursor type");
|
||||
return;
|
||||
}
|
||||
m_view.notify_server_did_request_cursor_change({}, (Gfx::StandardCursor)cursor_type);
|
||||
|
||||
if (m_view.on_cursor_change)
|
||||
m_view.on_cursor_change(static_cast<Gfx::StandardCursor>(cursor_type));
|
||||
}
|
||||
|
||||
void WebContentClient::did_layout(Gfx::IntSize content_size)
|
||||
|
@ -102,7 +102,6 @@ public:
|
||||
private:
|
||||
HeadlessWebContentView() = default;
|
||||
|
||||
void notify_server_did_request_cursor_change(Badge<WebView::WebContentClient>, Gfx::StandardCursor) override { }
|
||||
void notify_server_did_request_scroll(Badge<WebView::WebContentClient>, i32, i32) override { }
|
||||
void notify_server_did_request_scroll_to(Badge<WebView::WebContentClient>, Gfx::IntPoint) override { }
|
||||
void notify_server_did_request_scroll_into_view(Badge<WebView::WebContentClient>, Gfx::IntRect const&) override { }
|
||||
|
Loading…
Reference in New Issue
Block a user