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

AK+Everywhere: Rename String to DeprecatedString

We have a new, improved string type coming up in AK (OOM aware, no null
state), and while it's going to use UTF-8, the name UTF8String is a
mouthful - so let's free up the String name by renaming the existing
class.
Making the old one have an annoying name will hopefully also help with
quick adoption :^)
This commit is contained in:
Linus Groh 2022-12-04 18:02:33 +00:00 committed by Andreas Kling
parent f74251606d
commit 6e19ab2bbc
2006 changed files with 11635 additions and 11636 deletions

View file

@ -69,7 +69,7 @@ void XMLHttpRequest::visit_edges(Cell::Visitor& visitor)
visitor.visit(*value);
}
void XMLHttpRequest::fire_progress_event(String const& event_name, u64 transmitted, u64 length)
void XMLHttpRequest::fire_progress_event(DeprecatedString const& event_name, u64 transmitted, u64 length)
{
ProgressEventInit event_init {};
event_init.length_computable = true;
@ -79,7 +79,7 @@ void XMLHttpRequest::fire_progress_event(String const& event_name, u64 transmitt
}
// https://xhr.spec.whatwg.org/#dom-xmlhttprequest-responsetext
WebIDL::ExceptionOr<String> XMLHttpRequest::response_text() const
WebIDL::ExceptionOr<DeprecatedString> XMLHttpRequest::response_text() const
{
// 1. If thiss response type is not the empty string or "text", then throw an "InvalidStateError" DOMException.
if (m_response_type != Bindings::XMLHttpRequestResponseType::Empty && m_response_type != Bindings::XMLHttpRequestResponseType::Text)
@ -87,7 +87,7 @@ WebIDL::ExceptionOr<String> XMLHttpRequest::response_text() const
// 2. If thiss state is not loading or done, then return the empty string.
if (m_state != State::Loading && m_state != State::Done)
return String::empty();
return DeprecatedString::empty();
return get_text_response();
}
@ -186,7 +186,7 @@ WebIDL::ExceptionOr<JS::Value> XMLHttpRequest::response()
}
// https://xhr.spec.whatwg.org/#text-response
String XMLHttpRequest::get_text_response() const
DeprecatedString XMLHttpRequest::get_text_response() const
{
// FIXME: 1. If xhrs responses body is null, then return the empty string.
@ -257,7 +257,7 @@ MimeSniff::MimeType XMLHttpRequest::get_response_mime_type() const
Optional<StringView> XMLHttpRequest::get_final_encoding() const
{
// 1. Let label be null.
Optional<String> label;
Optional<DeprecatedString> label;
// 2. Let responseMIME be the result of get a response MIME type for xhr.
auto response_mime = get_response_mime_type();
@ -287,7 +287,7 @@ Optional<StringView> XMLHttpRequest::get_final_encoding() const
}
// https://xhr.spec.whatwg.org/#dom-xmlhttprequest-setrequestheader
WebIDL::ExceptionOr<void> XMLHttpRequest::set_request_header(String const& name_string, String const& value_string)
WebIDL::ExceptionOr<void> XMLHttpRequest::set_request_header(DeprecatedString const& name_string, DeprecatedString const& value_string)
{
auto& realm = this->realm();
auto name = name_string.to_byte_buffer();
@ -325,13 +325,13 @@ WebIDL::ExceptionOr<void> XMLHttpRequest::set_request_header(String const& name_
}
// https://xhr.spec.whatwg.org/#dom-xmlhttprequest-open
WebIDL::ExceptionOr<void> XMLHttpRequest::open(String const& method_string, String const& url)
WebIDL::ExceptionOr<void> XMLHttpRequest::open(DeprecatedString const& method_string, DeprecatedString const& url)
{
// 8. If the async argument is omitted, set async to true, and set username and password to null.
return open(method_string, url, true, {}, {});
}
WebIDL::ExceptionOr<void> XMLHttpRequest::open(String const& method_string, String const& url, bool async, String const& username, String const& password)
WebIDL::ExceptionOr<void> XMLHttpRequest::open(DeprecatedString const& method_string, DeprecatedString const& url, bool async, DeprecatedString const& username, DeprecatedString const& password)
{
auto method = method_string.to_byte_buffer();
@ -431,7 +431,7 @@ WebIDL::ExceptionOr<void> XMLHttpRequest::send(Optional<DocumentOrXMLHttpRequest
body = {};
Optional<Fetch::Infrastructure::BodyWithType> body_with_type {};
Optional<String> serialized_document {};
Optional<DeprecatedString> serialized_document {};
if (body.has_value()) {
if (body->has<JS::Handle<DOM::Document>>())
serialized_document = TRY(body->get<JS::Handle<DOM::Document>>().cell()->serialize_fragment(DOMParsing::RequireWellFormed::No));
@ -481,13 +481,13 @@ WebIDL::ExceptionOr<void> XMLHttpRequest::send(Optional<DocumentOrXMLHttpRequest
// If thiss headerss header list does not contain `Content-Type`, then append (`Content-Type`, type) to thiss headers.
if (!m_author_request_headers->contains("Content-Type"sv.bytes())) {
if (body_with_type.has_value() && body_with_type->type.has_value()) {
request.set_header("Content-Type", String { body_with_type->type->span() });
request.set_header("Content-Type", DeprecatedString { body_with_type->type->span() });
} else if (body.has_value() && body->has<JS::Handle<DOM::Document>>()) {
request.set_header("Content-Type", "text/html;charset=UTF-8");
}
}
for (auto& it : *m_author_request_headers)
request.set_header(String::copy(it.name), String::copy(it.value));
request.set_header(DeprecatedString::copy(it.name), DeprecatedString::copy(it.value));
m_upload_complete = false;
m_timed_out = false;
@ -573,7 +573,7 @@ void XMLHttpRequest::set_onreadystatechange(WebIDL::CallbackType* value)
}
// https://xhr.spec.whatwg.org/#the-getallresponseheaders()-method
String XMLHttpRequest::get_all_response_headers() const
DeprecatedString XMLHttpRequest::get_all_response_headers() const
{
// FIXME: Implement the spec-compliant sort order.
@ -591,7 +591,7 @@ String XMLHttpRequest::get_all_response_headers() const
}
// https://xhr.spec.whatwg.org/#dom-xmlhttprequest-overridemimetype
WebIDL::ExceptionOr<void> XMLHttpRequest::override_mime_type(String const& mime)
WebIDL::ExceptionOr<void> XMLHttpRequest::override_mime_type(DeprecatedString const& mime)
{
// 1. If thiss state is loading or done, then throw an "InvalidStateError" DOMException.
if (m_state == State::Loading || m_state == State::Done)

View file

@ -24,7 +24,7 @@
namespace Web::XHR {
// https://fetch.spec.whatwg.org/#typedefdef-xmlhttprequestbodyinit
using DocumentOrXMLHttpRequestBodyInit = Variant<JS::Handle<Web::DOM::Document>, JS::Handle<Web::FileAPI::Blob>, JS::Handle<JS::Object>, JS::Handle<Web::URL::URLSearchParams>, AK::String>;
using DocumentOrXMLHttpRequestBodyInit = Variant<JS::Handle<Web::DOM::Document>, JS::Handle<Web::FileAPI::Blob>, JS::Handle<JS::Object>, JS::Handle<Web::URL::URLSearchParams>, AK::DeprecatedString>;
class XMLHttpRequest final : public XMLHttpRequestEventTarget {
WEB_PLATFORM_OBJECT(XMLHttpRequest, XMLHttpRequestEventTarget);
@ -44,24 +44,24 @@ public:
State ready_state() const { return m_state; };
Fetch::Infrastructure::Status status() const { return m_status; };
WebIDL::ExceptionOr<String> response_text() const;
WebIDL::ExceptionOr<DeprecatedString> response_text() const;
WebIDL::ExceptionOr<JS::Value> response();
Bindings::XMLHttpRequestResponseType response_type() const { return m_response_type; }
WebIDL::ExceptionOr<void> open(String const& method, String const& url);
WebIDL::ExceptionOr<void> open(String const& method, String const& url, bool async, String const& username = {}, String const& password = {});
WebIDL::ExceptionOr<void> open(DeprecatedString const& method, DeprecatedString const& url);
WebIDL::ExceptionOr<void> open(DeprecatedString const& method, DeprecatedString const& url, bool async, DeprecatedString const& username = {}, DeprecatedString const& password = {});
WebIDL::ExceptionOr<void> send(Optional<DocumentOrXMLHttpRequestBodyInit> body);
WebIDL::ExceptionOr<void> set_request_header(String const& header, String const& value);
WebIDL::ExceptionOr<void> set_request_header(DeprecatedString const& header, DeprecatedString const& value);
WebIDL::ExceptionOr<void> set_response_type(Bindings::XMLHttpRequestResponseType);
String get_response_header(String const& name) { return m_response_headers.get(name).value_or({}); }
String get_all_response_headers() const;
DeprecatedString get_response_header(DeprecatedString const& name) { return m_response_headers.get(name).value_or({}); }
DeprecatedString get_all_response_headers() const;
WebIDL::CallbackType* onreadystatechange();
void set_onreadystatechange(WebIDL::CallbackType*);
WebIDL::ExceptionOr<void> override_mime_type(String const& mime);
WebIDL::ExceptionOr<void> override_mime_type(DeprecatedString const& mime);
u32 timeout() const;
WebIDL::ExceptionOr<void> set_timeout(u32 timeout);
@ -76,20 +76,20 @@ private:
virtual bool must_survive_garbage_collection() const override;
void set_status(Fetch::Infrastructure::Status status) { m_status = status; }
void fire_progress_event(String const&, u64, u64);
void fire_progress_event(DeprecatedString const&, u64, u64);
MimeSniff::MimeType get_response_mime_type() const;
Optional<StringView> get_final_encoding() const;
MimeSniff::MimeType get_final_mime_type() const;
String get_text_response() const;
DeprecatedString get_text_response() const;
XMLHttpRequest(HTML::Window&, Fetch::Infrastructure::HeaderList&);
// Non-standard
JS::NonnullGCPtr<HTML::Window> m_window;
Fetch::Infrastructure::Status m_status { 0 };
HashMap<String, String, CaseInsensitiveStringTraits> m_response_headers;
HashMap<DeprecatedString, DeprecatedString, CaseInsensitiveStringTraits> m_response_headers;
// https://xhr.spec.whatwg.org/#concept-xmlhttprequest-state
// state
@ -114,7 +114,7 @@ private:
// https://xhr.spec.whatwg.org/#request-method
// request method
// A method.
String m_request_method;
DeprecatedString m_request_method;
// https://xhr.spec.whatwg.org/#request-url
// request URL