1
Fork 0
mirror of https://github.com/RGBCube/serenity synced 2025-07-27 00:37:45 +00:00

Ladybird+LibWebView: Migrate tooltip changes to LibWebView callbacks

This commit is contained in:
Timothy Flynn 2023-08-23 11:11:39 -04:00 committed by Tim Flynn
parent 78d9339aa9
commit 5116e97a9d
10 changed files with 27 additions and 53 deletions

View file

@ -323,11 +323,11 @@ struct HideCursor {
[[self tabController] reload:nil];
};
m_web_view_bridge->on_tooltip_entered = [self](auto const& tooltip) {
m_web_view_bridge->on_enter_tooltip_area = [self](auto, auto const& tooltip) {
self.toolTip = Ladybird::string_to_ns_string(tooltip);
};
m_web_view_bridge->on_tooltip_left = [self]() {
m_web_view_bridge->on_leave_tooltip_area = [self]() {
self.toolTip = nil;
};

View file

@ -133,18 +133,6 @@ Optional<WebViewBridge::Paintable> WebViewBridge::paintable()
return Paintable { *bitmap, bitmap_size };
}
void WebViewBridge::notify_server_did_enter_tooltip_area(Badge<WebView::WebContentClient>, Gfx::IntPoint, DeprecatedString const& tooltip)
{
if (on_tooltip_entered)
on_tooltip_entered(tooltip);
}
void WebViewBridge::notify_server_did_leave_tooltip_area(Badge<WebView::WebContentClient>)
{
if (on_tooltip_left)
on_tooltip_left();
}
void WebViewBridge::notify_server_did_finish_handling_input_event(bool)
{
}

View file

@ -49,14 +49,9 @@ public:
};
Optional<Paintable> paintable();
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_enter_tooltip_area(Badge<WebView::WebContentClient>, Gfx::IntPoint, DeprecatedString const&) override;
virtual void notify_server_did_leave_tooltip_area(Badge<WebView::WebContentClient>) override;
virtual void notify_server_did_finish_handling_input_event(bool event_was_accepted) override;
virtual void update_zoom() override;

View file

@ -112,6 +112,17 @@ WebContentView::WebContentView(StringView webdriver_content_ipc_path, WebView::E
on_cursor_change = [this](auto cursor) {
update_cursor(cursor);
};
on_enter_tooltip_area = [this](auto position, auto tooltip) {
QToolTip::showText(
mapToGlobal(QPoint(position.x(), position.y())),
qstring_from_ak_deprecated_string(tooltip),
this);
};
on_leave_tooltip_area = []() {
QToolTip::hideText();
};
}
WebContentView::~WebContentView() = default;
@ -687,20 +698,6 @@ void WebContentView::update_cursor(Gfx::StandardCursor cursor)
}
}
void WebContentView::notify_server_did_enter_tooltip_area(Badge<WebContentClient>, Gfx::IntPoint content_position, DeprecatedString const& tooltip)
{
auto widget_position = to_widget_position(content_position);
QToolTip::showText(
mapToGlobal(QPoint(widget_position.x(), widget_position.y())),
qstring_from_ak_deprecated_string(tooltip),
this);
}
void WebContentView::notify_server_did_leave_tooltip_area(Badge<WebContentClient>)
{
QToolTip::hideText();
}
Gfx::IntRect WebContentView::viewport_rect() const
{
return m_viewport_rect;

View file

@ -76,8 +76,6 @@ public:
};
void update_palette(PaletteMode = PaletteMode::Default);
virtual void notify_server_did_enter_tooltip_area(Badge<WebContentClient>, Gfx::IntPoint, DeprecatedString const&) override;
virtual void notify_server_did_leave_tooltip_area(Badge<WebContentClient>) override;
virtual void notify_server_did_finish_handling_input_event(bool event_was_accepted) override;
signals: