mirror of
https://github.com/RGBCube/serenity
synced 2025-07-27 21:37:35 +00:00
Ladybird+LibWebView: Migrate dialog APIs to LibWebView callbacks
This commit is contained in:
parent
e6c01ef6e2
commit
ebdcba8b3b
15 changed files with 153 additions and 225 deletions
|
@ -416,7 +416,7 @@ struct HideCursor {
|
|||
[NSMenu popUpContextMenu:self.video_context_menu withEvent:event forView:self];
|
||||
};
|
||||
|
||||
m_web_view_bridge->on_alert = [self](auto const& message) {
|
||||
m_web_view_bridge->on_request_alert = [self](auto const& message) {
|
||||
auto* ns_message = Ladybird::string_to_ns_string(message);
|
||||
|
||||
self.dialog = [[NSAlert alloc] init];
|
||||
|
@ -429,7 +429,7 @@ struct HideCursor {
|
|||
}];
|
||||
};
|
||||
|
||||
m_web_view_bridge->on_confirm = [self](auto const& message) {
|
||||
m_web_view_bridge->on_request_confirm = [self](auto const& message) {
|
||||
auto* ns_message = Ladybird::string_to_ns_string(message);
|
||||
|
||||
self.dialog = [[NSAlert alloc] init];
|
||||
|
@ -444,7 +444,7 @@ struct HideCursor {
|
|||
}];
|
||||
};
|
||||
|
||||
m_web_view_bridge->on_prompt = [self](auto const& message, auto const& default_) {
|
||||
m_web_view_bridge->on_request_prompt = [self](auto const& message, auto const& default_) {
|
||||
auto* ns_message = Ladybird::string_to_ns_string(message);
|
||||
auto* ns_default = Ladybird::string_to_ns_string(default_);
|
||||
|
||||
|
@ -472,7 +472,7 @@ struct HideCursor {
|
|||
}];
|
||||
};
|
||||
|
||||
m_web_view_bridge->on_prompt_text_changed = [self](auto const& message) {
|
||||
m_web_view_bridge->on_request_set_prompt_text = [self](auto const& message) {
|
||||
if (self.dialog == nil || [self.dialog accessoryView] == nil) {
|
||||
return;
|
||||
}
|
||||
|
@ -483,7 +483,7 @@ struct HideCursor {
|
|||
[input setStringValue:ns_message];
|
||||
};
|
||||
|
||||
m_web_view_bridge->on_dialog_accepted = [self]() {
|
||||
m_web_view_bridge->on_request_accept_dialog = [self]() {
|
||||
if (self.dialog == nil) {
|
||||
return;
|
||||
}
|
||||
|
@ -492,7 +492,7 @@ struct HideCursor {
|
|||
returnCode:NSModalResponseOK];
|
||||
};
|
||||
|
||||
m_web_view_bridge->on_dialog_dismissed = [self]() {
|
||||
m_web_view_bridge->on_request_dismiss_dialog = [self]() {
|
||||
if (self.dialog == nil) {
|
||||
return;
|
||||
}
|
||||
|
|
|
@ -197,58 +197,6 @@ void WebViewBridge::notify_server_did_leave_tooltip_area(Badge<WebView::WebConte
|
|||
if (on_tooltip_left)
|
||||
on_tooltip_left();
|
||||
}
|
||||
|
||||
void WebViewBridge::notify_server_did_request_alert(Badge<WebView::WebContentClient>, String const& message)
|
||||
{
|
||||
if (on_alert)
|
||||
on_alert(message);
|
||||
}
|
||||
|
||||
void WebViewBridge::alert_closed()
|
||||
{
|
||||
client().async_alert_closed();
|
||||
}
|
||||
|
||||
void WebViewBridge::notify_server_did_request_confirm(Badge<WebView::WebContentClient>, String const& message)
|
||||
{
|
||||
if (on_confirm)
|
||||
on_confirm(message);
|
||||
}
|
||||
|
||||
void WebViewBridge::confirm_closed(bool accepted)
|
||||
{
|
||||
client().async_confirm_closed(accepted);
|
||||
}
|
||||
|
||||
void WebViewBridge::notify_server_did_request_prompt(Badge<WebView::WebContentClient>, String const& message, String const& default_)
|
||||
{
|
||||
if (on_prompt)
|
||||
on_prompt(message, default_);
|
||||
}
|
||||
|
||||
void WebViewBridge::prompt_closed(Optional<String> response)
|
||||
{
|
||||
client().async_prompt_closed(move(response));
|
||||
}
|
||||
|
||||
void WebViewBridge::notify_server_did_request_set_prompt_text(Badge<WebView::WebContentClient>, String const& message)
|
||||
{
|
||||
if (on_prompt_text_changed)
|
||||
on_prompt_text_changed(message);
|
||||
}
|
||||
|
||||
void WebViewBridge::notify_server_did_request_accept_dialog(Badge<WebView::WebContentClient>)
|
||||
{
|
||||
if (on_dialog_accepted)
|
||||
on_dialog_accepted();
|
||||
}
|
||||
|
||||
void WebViewBridge::notify_server_did_request_dismiss_dialog(Badge<WebView::WebContentClient>)
|
||||
{
|
||||
if (on_dialog_dismissed)
|
||||
on_dialog_dismissed();
|
||||
}
|
||||
|
||||
void WebViewBridge::notify_server_did_request_file(Badge<WebView::WebContentClient>, DeprecatedString const& path, i32 request_id)
|
||||
{
|
||||
auto file = Core::File::open(path, Core::File::OpenMode::Read);
|
||||
|
|
|
@ -59,19 +59,6 @@ public:
|
|||
Function<void(DeprecatedString const&)> on_tooltip_entered;
|
||||
Function<void()> on_tooltip_left;
|
||||
|
||||
Function<void(String const&)> on_alert;
|
||||
void alert_closed();
|
||||
|
||||
Function<void(String const&)> on_confirm;
|
||||
void confirm_closed(bool);
|
||||
|
||||
Function<void(String const&, String const&)> on_prompt;
|
||||
Function<void(String const&)> on_prompt_text_changed;
|
||||
void prompt_closed(Optional<String>);
|
||||
|
||||
Function<void()> on_dialog_accepted;
|
||||
Function<void()> on_dialog_dismissed;
|
||||
|
||||
private:
|
||||
WebViewBridge(Vector<Gfx::IntRect> screen_rects, float device_pixel_ratio, Optional<StringView> webdriver_content_ipc_path);
|
||||
|
||||
|
@ -85,12 +72,6 @@ private:
|
|||
virtual void notify_server_did_request_scroll_into_view(Badge<WebView::WebContentClient>, Gfx::IntRect const&) override;
|
||||
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_request_alert(Badge<WebView::WebContentClient>, String const& message) override;
|
||||
virtual void notify_server_did_request_confirm(Badge<WebView::WebContentClient>, String const& message) override;
|
||||
virtual void notify_server_did_request_prompt(Badge<WebView::WebContentClient>, String const& message, String const& default_) override;
|
||||
virtual void notify_server_did_request_set_prompt_text(Badge<WebView::WebContentClient>, String const& message) override;
|
||||
virtual void notify_server_did_request_accept_dialog(Badge<WebView::WebContentClient>) override;
|
||||
virtual void notify_server_did_request_dismiss_dialog(Badge<WebView::WebContentClient>) override;
|
||||
virtual void notify_server_did_request_file(Badge<WebView::WebContentClient>, DeprecatedString const& path, i32) override;
|
||||
virtual void notify_server_did_finish_handling_input_event(bool event_was_accepted) override;
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue