mirror of
https://github.com/RGBCube/serenity
synced 2025-07-28 07:17:34 +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
|
@ -1096,7 +1096,7 @@ void Window::alert(String const& message)
|
|||
// treated as alert("undefined"), but alert() is treated as alert("").
|
||||
// FIXME: Make this fully spec compliant.
|
||||
if (auto* page = this->page())
|
||||
page->did_request_alert(message.to_deprecated_string());
|
||||
page->did_request_alert(message);
|
||||
}
|
||||
|
||||
// https://html.spec.whatwg.org/multipage/timers-and-user-prompts.html#dom-confirm
|
||||
|
@ -1105,7 +1105,7 @@ bool Window::confirm(Optional<String> const& message)
|
|||
// FIXME: Make this fully spec compliant.
|
||||
// NOTE: `message` has an IDL-provided default value and is never empty.
|
||||
if (auto* page = this->page())
|
||||
return page->did_request_confirm(message->to_deprecated_string());
|
||||
return page->did_request_confirm(*message);
|
||||
return false;
|
||||
}
|
||||
|
||||
|
@ -1113,12 +1113,8 @@ bool Window::confirm(Optional<String> const& message)
|
|||
Optional<String> Window::prompt(Optional<String> const& message, Optional<String> const& default_)
|
||||
{
|
||||
// FIXME: Make this fully spec compliant.
|
||||
if (auto* page = this->page()) {
|
||||
auto response = page->did_request_prompt(message->to_deprecated_string(), default_->to_deprecated_string());
|
||||
if (response.is_null())
|
||||
return {};
|
||||
return String::from_deprecated_string(response).release_value_but_fixme_should_propagate_errors();
|
||||
}
|
||||
if (auto* page = this->page())
|
||||
return page->did_request_prompt(*message, *default_);
|
||||
return {};
|
||||
}
|
||||
|
||||
|
|
|
@ -187,7 +187,7 @@ static ResponseType spin_event_loop_until_dialog_closed(PageClient& client, Opti
|
|||
return response.release_value();
|
||||
}
|
||||
|
||||
void Page::did_request_alert(DeprecatedString const& message)
|
||||
void Page::did_request_alert(String const& message)
|
||||
{
|
||||
m_pending_dialog = PendingDialog::Alert;
|
||||
m_client.page_did_request_alert(message);
|
||||
|
@ -207,7 +207,7 @@ void Page::alert_closed()
|
|||
}
|
||||
}
|
||||
|
||||
bool Page::did_request_confirm(DeprecatedString const& message)
|
||||
bool Page::did_request_confirm(String const& message)
|
||||
{
|
||||
m_pending_dialog = PendingDialog::Confirm;
|
||||
m_client.page_did_request_confirm(message);
|
||||
|
@ -227,7 +227,7 @@ void Page::confirm_closed(bool accepted)
|
|||
}
|
||||
}
|
||||
|
||||
DeprecatedString Page::did_request_prompt(DeprecatedString const& message, DeprecatedString const& default_)
|
||||
Optional<String> Page::did_request_prompt(String const& message, String const& default_)
|
||||
{
|
||||
m_pending_dialog = PendingDialog::Prompt;
|
||||
m_client.page_did_request_prompt(message, default_);
|
||||
|
@ -238,7 +238,7 @@ DeprecatedString Page::did_request_prompt(DeprecatedString const& message, Depre
|
|||
return spin_event_loop_until_dialog_closed(m_client, m_pending_prompt_response);
|
||||
}
|
||||
|
||||
void Page::prompt_closed(DeprecatedString response)
|
||||
void Page::prompt_closed(Optional<String> response)
|
||||
{
|
||||
if (m_pending_dialog == PendingDialog::Prompt) {
|
||||
m_pending_dialog = PendingDialog::None;
|
||||
|
|
|
@ -93,14 +93,14 @@ public:
|
|||
DevicePixelSize window_size() const { return m_window_size; }
|
||||
void set_window_size(DevicePixelSize size) { m_window_size = size; }
|
||||
|
||||
void did_request_alert(DeprecatedString const& message);
|
||||
void did_request_alert(String const& message);
|
||||
void alert_closed();
|
||||
|
||||
bool did_request_confirm(DeprecatedString const& message);
|
||||
bool did_request_confirm(String const& message);
|
||||
void confirm_closed(bool accepted);
|
||||
|
||||
DeprecatedString did_request_prompt(DeprecatedString const& message, DeprecatedString const& default_);
|
||||
void prompt_closed(DeprecatedString response);
|
||||
Optional<String> did_request_prompt(String const& message, String const& default_);
|
||||
void prompt_closed(Optional<String> response);
|
||||
|
||||
enum class PendingDialog {
|
||||
None,
|
||||
|
@ -110,7 +110,7 @@ public:
|
|||
};
|
||||
bool has_pending_dialog() const { return m_pending_dialog != PendingDialog::None; }
|
||||
PendingDialog pending_dialog() const { return m_pending_dialog; }
|
||||
Optional<DeprecatedString> const& pending_dialog_text() const { return m_pending_dialog_text; }
|
||||
Optional<String> const& pending_dialog_text() const { return m_pending_dialog_text; }
|
||||
void dismiss_dialog();
|
||||
void accept_dialog();
|
||||
|
||||
|
@ -137,10 +137,10 @@ private:
|
|||
DevicePixelSize m_window_size {};
|
||||
|
||||
PendingDialog m_pending_dialog { PendingDialog::None };
|
||||
Optional<DeprecatedString> m_pending_dialog_text;
|
||||
Optional<String> m_pending_dialog_text;
|
||||
Optional<Empty> m_pending_alert_response;
|
||||
Optional<bool> m_pending_confirm_response;
|
||||
Optional<DeprecatedString> m_pending_prompt_response;
|
||||
Optional<Optional<String>> m_pending_prompt_response;
|
||||
|
||||
// https://html.spec.whatwg.org/multipage/system-state.html#pdf-viewer-supported
|
||||
// Each user agent has a PDF viewer supported boolean, whose value is implementation-defined (and might vary according to user preferences).
|
||||
|
@ -189,10 +189,10 @@ public:
|
|||
virtual void page_did_request_scroll(i32, i32) { }
|
||||
virtual void page_did_request_scroll_to(CSSPixelPoint) { }
|
||||
virtual void page_did_request_scroll_into_view(CSSPixelRect const&) { }
|
||||
virtual void page_did_request_alert(DeprecatedString const&) { }
|
||||
virtual void page_did_request_confirm(DeprecatedString const&) { }
|
||||
virtual void page_did_request_prompt(DeprecatedString const&, DeprecatedString const&) { }
|
||||
virtual void page_did_request_set_prompt_text(DeprecatedString const&) { }
|
||||
virtual void page_did_request_alert(String const&) { }
|
||||
virtual void page_did_request_confirm(String const&) { }
|
||||
virtual void page_did_request_prompt(String const&, String const&) { }
|
||||
virtual void page_did_request_set_prompt_text(String const&) { }
|
||||
virtual void page_did_request_accept_dialog() { }
|
||||
virtual void page_did_request_dismiss_dialog() { }
|
||||
virtual Vector<Web::Cookie::Cookie> page_did_request_all_cookies(AK::URL const&) { return {}; }
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue