mirror of
https://github.com/RGBCube/serenity
synced 2025-07-26 01:47:34 +00:00
Ladybird+LibWebView: Migrate cursor changes to LibWebView callbacks
This commit is contained in:
parent
bf464665a7
commit
00fe122b0a
9 changed files with 14 additions and 20 deletions
|
@ -104,12 +104,6 @@ Optional<WebViewBridge::Paintable> WebViewBridge::paintable()
|
||||||
return Paintable { *bitmap, bitmap_size };
|
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)
|
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.
|
// 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::IntPoint)> on_scroll;
|
||||||
|
|
||||||
Function<void(Gfx::StandardCursor)> on_cursor_change;
|
|
||||||
|
|
||||||
Function<void(DeprecatedString const&)> on_tooltip_entered;
|
Function<void(DeprecatedString const&)> on_tooltip_entered;
|
||||||
Function<void()> on_tooltip_left;
|
Function<void()> on_tooltip_left;
|
||||||
|
|
||||||
private:
|
private:
|
||||||
WebViewBridge(Vector<Gfx::IntRect> screen_rects, float device_pixel_ratio, Optional<StringView> webdriver_content_ipc_path);
|
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(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_to(Badge<WebView::WebContentClient>, Gfx::IntPoint) override;
|
||||||
virtual void notify_server_did_request_scroll_into_view(Badge<WebView::WebContentClient>, Gfx::IntRect const&) 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]() {
|
on_ready_to_paint = [this]() {
|
||||||
viewport()->update();
|
viewport()->update();
|
||||||
};
|
};
|
||||||
|
|
||||||
|
on_cursor_change = [this](auto cursor) {
|
||||||
|
update_cursor(cursor);
|
||||||
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
WebContentView::~WebContentView() = default;
|
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);
|
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) {
|
switch (cursor) {
|
||||||
case Gfx::StandardCursor::Hidden:
|
case Gfx::StandardCursor::Hidden:
|
||||||
|
|
|
@ -76,7 +76,6 @@ public:
|
||||||
};
|
};
|
||||||
void update_palette(PaletteMode = PaletteMode::Default);
|
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(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_to(Badge<WebContentClient>, Gfx::IntPoint) override;
|
||||||
virtual void notify_server_did_request_scroll_into_view(Badge<WebContentClient>, Gfx::IntRect const&) 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;
|
virtual Gfx::IntPoint to_widget_position(Gfx::IntPoint content_position) const override;
|
||||||
|
|
||||||
void update_viewport_rect();
|
void update_viewport_rect();
|
||||||
|
void update_cursor(Gfx::StandardCursor cursor);
|
||||||
|
|
||||||
qreal m_inverse_pixel_scaling_ratio { 1.0 };
|
qreal m_inverse_pixel_scaling_ratio { 1.0 };
|
||||||
bool m_should_show_line_box_borders { false };
|
bool m_should_show_line_box_borders { false };
|
||||||
|
|
|
@ -45,6 +45,10 @@ OutOfProcessWebView::OutOfProcessWebView()
|
||||||
else
|
else
|
||||||
client().async_handle_file_return(0, IPC::File(file.value().stream()), request_id);
|
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;
|
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());
|
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)
|
void OutOfProcessWebView::notify_server_did_request_scroll(Badge<WebContentClient>, i32 x_delta, i32 y_delta)
|
||||||
{
|
{
|
||||||
horizontal_scrollbar().increase_slider_by(x_delta);
|
horizontal_scrollbar().increase_slider_by(x_delta);
|
||||||
|
|
|
@ -82,7 +82,6 @@ private:
|
||||||
// ^WebView::ViewImplementation
|
// ^WebView::ViewImplementation
|
||||||
virtual void create_client(EnableCallgrindProfiling = EnableCallgrindProfiling::No) override;
|
virtual void create_client(EnableCallgrindProfiling = EnableCallgrindProfiling::No) override;
|
||||||
virtual void update_zoom() 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(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_to(Badge<WebContentClient>, Gfx::IntPoint) override;
|
||||||
virtual void notify_server_did_request_scroll_into_view(Badge<WebContentClient>, Gfx::IntRect const&) 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_navigate_forward;
|
||||||
Function<void()> on_refresh;
|
Function<void()> on_refresh;
|
||||||
Function<void(Gfx::Bitmap const&)> on_favicon_change;
|
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_alert;
|
||||||
Function<void(String const& message)> on_request_confirm;
|
Function<void(String const& message)> on_request_confirm;
|
||||||
Function<void(String const& message, String const& default_)> on_request_prompt;
|
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_minimize_window;
|
||||||
Function<Gfx::IntRect()> on_fullscreen_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(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_to(Badge<WebContentClient>, Gfx::IntPoint) = 0;
|
||||||
virtual void notify_server_did_request_scroll_into_view(Badge<WebContentClient>, Gfx::IntRect const&) = 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");
|
dbgln("DidRequestCursorChange: Bad cursor type");
|
||||||
return;
|
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)
|
void WebContentClient::did_layout(Gfx::IntSize content_size)
|
||||||
|
|
|
@ -102,7 +102,6 @@ public:
|
||||||
private:
|
private:
|
||||||
HeadlessWebContentView() = default;
|
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(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_to(Badge<WebView::WebContentClient>, Gfx::IntPoint) override { }
|
||||||
void notify_server_did_request_scroll_into_view(Badge<WebView::WebContentClient>, Gfx::IntRect const&) override { }
|
void notify_server_did_request_scroll_into_view(Badge<WebView::WebContentClient>, Gfx::IntRect const&) override { }
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue