mirror of
https://github.com/RGBCube/serenity
synced 2025-07-27 16:47:44 +00:00
LibWeb+Ladybird+Userland: Port window.[alert,confirm,prompt] to String
LibGUI and WebDriver (read: JSON) API boundaries use DeprecatedString, so that is as far as these changes can reach. The one change which isn't just a DeprecatedString to String replacement is handling the "null" prompt response. We previously checked for the null DeprecatedString, whereas we now represent this as an empty Optional<String>.
This commit is contained in:
parent
b4d3fea002
commit
97536e4684
18 changed files with 85 additions and 85 deletions
|
@ -346,7 +346,7 @@ void OutOfProcessWebView::notify_server_did_request_image_context_menu(Badge<Web
|
|||
on_image_context_menu_request(url, screen_relative_rect().location().translated(to_widget_position(content_position)), bitmap);
|
||||
}
|
||||
|
||||
void OutOfProcessWebView::notify_server_did_request_alert(Badge<WebContentClient>, DeprecatedString const& message)
|
||||
void OutOfProcessWebView::notify_server_did_request_alert(Badge<WebContentClient>, String const& message)
|
||||
{
|
||||
m_dialog = GUI::MessageBox::construct(window(), message, "Alert"sv, GUI::MessageBox::Type::Information, GUI::MessageBox::InputType::OK);
|
||||
m_dialog->set_icon(window()->icon());
|
||||
|
@ -356,7 +356,7 @@ void OutOfProcessWebView::notify_server_did_request_alert(Badge<WebContentClient
|
|||
m_dialog = nullptr;
|
||||
}
|
||||
|
||||
void OutOfProcessWebView::notify_server_did_request_confirm(Badge<WebContentClient>, DeprecatedString const& message)
|
||||
void OutOfProcessWebView::notify_server_did_request_confirm(Badge<WebContentClient>, String const& message)
|
||||
{
|
||||
m_dialog = GUI::MessageBox::construct(window(), message, "Confirm"sv, GUI::MessageBox::Type::Warning, GUI::MessageBox::InputType::OKCancel);
|
||||
m_dialog->set_icon(window()->icon());
|
||||
|
@ -365,23 +365,27 @@ void OutOfProcessWebView::notify_server_did_request_confirm(Badge<WebContentClie
|
|||
m_dialog = nullptr;
|
||||
}
|
||||
|
||||
void OutOfProcessWebView::notify_server_did_request_prompt(Badge<WebContentClient>, DeprecatedString const& message, DeprecatedString const& default_)
|
||||
void OutOfProcessWebView::notify_server_did_request_prompt(Badge<WebContentClient>, String const& message, String const& default_)
|
||||
{
|
||||
m_dialog = GUI::InputBox::construct(window(), default_, message, "Prompt"sv, GUI::InputType::Text, StringView {});
|
||||
m_dialog = GUI::InputBox::construct(window(), default_.to_deprecated_string(), message, "Prompt"sv, GUI::InputType::Text, StringView {});
|
||||
m_dialog->set_icon(window()->icon());
|
||||
|
||||
if (m_dialog->exec() == GUI::InputBox::ExecResult::OK)
|
||||
client().async_prompt_closed(static_cast<GUI::InputBox&>(*m_dialog).text_value());
|
||||
else
|
||||
if (m_dialog->exec() == GUI::InputBox::ExecResult::OK) {
|
||||
auto const& dialog = static_cast<GUI::InputBox const&>(*m_dialog);
|
||||
auto response = String::from_deprecated_string(dialog.text_value()).release_value_but_fixme_should_propagate_errors();
|
||||
|
||||
client().async_prompt_closed(move(response));
|
||||
} else {
|
||||
client().async_prompt_closed({});
|
||||
}
|
||||
|
||||
m_dialog = nullptr;
|
||||
}
|
||||
|
||||
void OutOfProcessWebView::notify_server_did_request_set_prompt_text(Badge<WebContentClient>, DeprecatedString const& message)
|
||||
void OutOfProcessWebView::notify_server_did_request_set_prompt_text(Badge<WebContentClient>, String const& message)
|
||||
{
|
||||
if (m_dialog && is<GUI::InputBox>(*m_dialog))
|
||||
static_cast<GUI::InputBox&>(*m_dialog).set_text_value(message);
|
||||
static_cast<GUI::InputBox&>(*m_dialog).set_text_value(message.to_deprecated_string());
|
||||
}
|
||||
|
||||
void OutOfProcessWebView::notify_server_did_request_accept_dialog(Badge<WebContentClient>)
|
||||
|
|
|
@ -143,10 +143,10 @@ private:
|
|||
virtual void notify_server_did_request_context_menu(Badge<WebContentClient>, Gfx::IntPoint) override;
|
||||
virtual void notify_server_did_request_link_context_menu(Badge<WebContentClient>, Gfx::IntPoint, const AK::URL&, DeprecatedString const& target, unsigned modifiers) override;
|
||||
virtual void notify_server_did_request_image_context_menu(Badge<WebContentClient>, Gfx::IntPoint, const AK::URL&, DeprecatedString const& target, unsigned modifiers, Gfx::ShareableBitmap const&) override;
|
||||
virtual void notify_server_did_request_alert(Badge<WebContentClient>, DeprecatedString const& message) override;
|
||||
virtual void notify_server_did_request_confirm(Badge<WebContentClient>, DeprecatedString const& message) override;
|
||||
virtual void notify_server_did_request_prompt(Badge<WebContentClient>, DeprecatedString const& message, DeprecatedString const& default_) override;
|
||||
virtual void notify_server_did_request_set_prompt_text(Badge<WebContentClient>, DeprecatedString const& message) override;
|
||||
virtual void notify_server_did_request_alert(Badge<WebContentClient>, String const& message) override;
|
||||
virtual void notify_server_did_request_confirm(Badge<WebContentClient>, String const& message) override;
|
||||
virtual void notify_server_did_request_prompt(Badge<WebContentClient>, String const& message, String const& default_) override;
|
||||
virtual void notify_server_did_request_set_prompt_text(Badge<WebContentClient>, String const& message) override;
|
||||
virtual void notify_server_did_request_accept_dialog(Badge<WebContentClient>) override;
|
||||
virtual void notify_server_did_request_dismiss_dialog(Badge<WebContentClient>) override;
|
||||
virtual void notify_server_did_get_source(const AK::URL& url, DeprecatedString const& source) override;
|
||||
|
|
|
@ -78,10 +78,10 @@ public:
|
|||
virtual void notify_server_did_request_context_menu(Badge<WebContentClient>, Gfx::IntPoint) = 0;
|
||||
virtual void notify_server_did_request_link_context_menu(Badge<WebContentClient>, Gfx::IntPoint, const AK::URL&, DeprecatedString const& target, unsigned modifiers) = 0;
|
||||
virtual void notify_server_did_request_image_context_menu(Badge<WebContentClient>, Gfx::IntPoint, const AK::URL&, DeprecatedString const& target, unsigned modifiers, Gfx::ShareableBitmap const&) = 0;
|
||||
virtual void notify_server_did_request_alert(Badge<WebContentClient>, DeprecatedString const& message) = 0;
|
||||
virtual void notify_server_did_request_confirm(Badge<WebContentClient>, DeprecatedString const& message) = 0;
|
||||
virtual void notify_server_did_request_prompt(Badge<WebContentClient>, DeprecatedString const& message, DeprecatedString const& default_) = 0;
|
||||
virtual void notify_server_did_request_set_prompt_text(Badge<WebContentClient>, DeprecatedString const& message) = 0;
|
||||
virtual void notify_server_did_request_alert(Badge<WebContentClient>, String const& message) = 0;
|
||||
virtual void notify_server_did_request_confirm(Badge<WebContentClient>, String const& message) = 0;
|
||||
virtual void notify_server_did_request_prompt(Badge<WebContentClient>, String const& message, String const& default_) = 0;
|
||||
virtual void notify_server_did_request_set_prompt_text(Badge<WebContentClient>, String const& message) = 0;
|
||||
virtual void notify_server_did_request_accept_dialog(Badge<WebContentClient>) = 0;
|
||||
virtual void notify_server_did_request_dismiss_dialog(Badge<WebContentClient>) = 0;
|
||||
virtual void notify_server_did_get_source(const AK::URL& url, DeprecatedString const& source) = 0;
|
||||
|
|
|
@ -176,22 +176,22 @@ void WebContentClient::did_get_js_console_messages(i32 start_index, Vector<Depre
|
|||
m_view.notify_server_did_get_js_console_messages(start_index, message_types, messages);
|
||||
}
|
||||
|
||||
void WebContentClient::did_request_alert(DeprecatedString const& message)
|
||||
void WebContentClient::did_request_alert(String const& message)
|
||||
{
|
||||
m_view.notify_server_did_request_alert({}, message);
|
||||
}
|
||||
|
||||
void WebContentClient::did_request_confirm(DeprecatedString const& message)
|
||||
void WebContentClient::did_request_confirm(String const& message)
|
||||
{
|
||||
m_view.notify_server_did_request_confirm({}, message);
|
||||
}
|
||||
|
||||
void WebContentClient::did_request_prompt(DeprecatedString const& message, DeprecatedString const& default_)
|
||||
void WebContentClient::did_request_prompt(String const& message, String const& default_)
|
||||
{
|
||||
m_view.notify_server_did_request_prompt({}, message, default_);
|
||||
}
|
||||
|
||||
void WebContentClient::did_request_set_prompt_text(DeprecatedString const& message)
|
||||
void WebContentClient::did_request_set_prompt_text(String const& message)
|
||||
{
|
||||
m_view.notify_server_did_request_set_prompt_text({}, message);
|
||||
}
|
||||
|
|
|
@ -58,10 +58,10 @@ private:
|
|||
virtual void did_output_js_console_message(i32 message_index) override;
|
||||
virtual void did_get_js_console_messages(i32 start_index, Vector<DeprecatedString> const& message_types, Vector<DeprecatedString> const& messages) override;
|
||||
virtual void did_change_favicon(Gfx::ShareableBitmap const&) override;
|
||||
virtual void did_request_alert(DeprecatedString const&) override;
|
||||
virtual void did_request_confirm(DeprecatedString const&) override;
|
||||
virtual void did_request_prompt(DeprecatedString const&, DeprecatedString const&) override;
|
||||
virtual void did_request_set_prompt_text(DeprecatedString const& message) override;
|
||||
virtual void did_request_alert(String const&) override;
|
||||
virtual void did_request_confirm(String const&) override;
|
||||
virtual void did_request_prompt(String const&, String const&) override;
|
||||
virtual void did_request_set_prompt_text(String const& message) override;
|
||||
virtual void did_request_accept_dialog() override;
|
||||
virtual void did_request_dismiss_dialog() override;
|
||||
virtual Messages::WebContentClient::DidRequestAllCookiesResponse did_request_all_cookies(AK::URL const&) override;
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue