1
Fork 0
mirror of https://github.com/RGBCube/serenity synced 2025-07-27 02:47:35 +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

@ -45,7 +45,7 @@ WebSocketClientSocket::~WebSocketClientSocket() = default;
WebSocketClientManager::WebSocketClientManager() = default;
// https://websockets.spec.whatwg.org/#dom-websocket-websocket
WebIDL::ExceptionOr<JS::NonnullGCPtr<WebSocket>> WebSocket::construct_impl(JS::Realm& realm, String const& url)
WebIDL::ExceptionOr<JS::NonnullGCPtr<WebSocket>> WebSocket::construct_impl(JS::Realm& realm, DeprecatedString const& url)
{
auto& window = verify_cast<HTML::Window>(realm.global_object());
AK::URL url_record(url);
@ -112,27 +112,27 @@ WebSocket::ReadyState WebSocket::ready_state() const
}
// https://websockets.spec.whatwg.org/#dom-websocket-extensions
String WebSocket::extensions() const
DeprecatedString WebSocket::extensions() const
{
if (!m_websocket)
return String::empty();
return DeprecatedString::empty();
// https://websockets.spec.whatwg.org/#feedback-from-the-protocol
// FIXME: Change the extensions attribute's value to the extensions in use, if it is not the null value.
return String::empty();
return DeprecatedString::empty();
}
// https://websockets.spec.whatwg.org/#dom-websocket-protocol
String WebSocket::protocol() const
DeprecatedString WebSocket::protocol() const
{
if (!m_websocket)
return String::empty();
return DeprecatedString::empty();
// https://websockets.spec.whatwg.org/#feedback-from-the-protocol
// FIXME: Change the protocol attribute's value to the subprotocol in use, if it is not the null value.
return String::empty();
return DeprecatedString::empty();
}
// https://websockets.spec.whatwg.org/#dom-websocket-close
WebIDL::ExceptionOr<void> WebSocket::close(Optional<u16> code, Optional<String> reason)
WebIDL::ExceptionOr<void> WebSocket::close(Optional<u16> code, Optional<DeprecatedString> reason)
{
// 1. If code is present, but is neither an integer equal to 1000 nor an integer in the range 3000 to 4999, inclusive, throw an "InvalidAccessError" DOMException.
if (code.has_value() && *code != 1000 && (*code < 3000 || *code > 4099))
@ -154,12 +154,12 @@ WebIDL::ExceptionOr<void> WebSocket::close(Optional<u16> code, Optional<String>
// -> Otherwise
// NOTE: All of these are handled by the WebSocket Protocol when calling close()
// FIXME: LibProtocol does not yet support sending empty Close messages, so we use default values for now
m_websocket->close(code.value_or(1000), reason.value_or(String::empty()));
m_websocket->close(code.value_or(1000), reason.value_or(DeprecatedString::empty()));
return {};
}
// https://websockets.spec.whatwg.org/#dom-websocket-send
WebIDL::ExceptionOr<void> WebSocket::send(String const& data)
WebIDL::ExceptionOr<void> WebSocket::send(DeprecatedString const& data)
{
auto state = ready_state();
if (state == WebSocket::ReadyState::Connecting)
@ -188,7 +188,7 @@ void WebSocket::on_error()
}
// https://websockets.spec.whatwg.org/#feedback-from-the-protocol
void WebSocket::on_close(u16 code, String reason, bool was_clean)
void WebSocket::on_close(u16 code, DeprecatedString reason, bool was_clean)
{
// 1. Change the readyState attribute's value to CLOSED. This is handled by the Protocol's WebSocket
// 2. If [needed], fire an event named error at the WebSocket object. This is handled by the Protocol's WebSocket
@ -205,7 +205,7 @@ void WebSocket::on_message(ByteBuffer message, bool is_text)
if (m_websocket->ready_state() != WebSocket::ReadyState::Open)
return;
if (is_text) {
auto text_message = String(ReadonlyBytes(message));
auto text_message = DeprecatedString(ReadonlyBytes(message));
HTML::MessageEventInit event_init;
event_init.data = JS::js_string(vm(), text_message);
event_init.origin = url();

View file

@ -37,11 +37,11 @@ public:
Closed = 3,
};
static WebIDL::ExceptionOr<JS::NonnullGCPtr<WebSocket>> construct_impl(JS::Realm&, String const& url);
static WebIDL::ExceptionOr<JS::NonnullGCPtr<WebSocket>> construct_impl(JS::Realm&, DeprecatedString const& url);
virtual ~WebSocket() override;
String url() const { return m_url.to_string(); }
DeprecatedString url() const { return m_url.to_string(); }
#undef __ENUMERATE
#define __ENUMERATE(attribute_name, event_name) \
@ -51,20 +51,20 @@ public:
#undef __ENUMERATE
ReadyState ready_state() const;
String extensions() const;
String protocol() const;
DeprecatedString extensions() const;
DeprecatedString protocol() const;
String const& binary_type() { return m_binary_type; };
void set_binary_type(String const& type) { m_binary_type = type; };
DeprecatedString const& binary_type() { return m_binary_type; };
void set_binary_type(DeprecatedString const& type) { m_binary_type = type; };
WebIDL::ExceptionOr<void> close(Optional<u16> code, Optional<String> reason);
WebIDL::ExceptionOr<void> send(String const& data);
WebIDL::ExceptionOr<void> close(Optional<u16> code, Optional<DeprecatedString> reason);
WebIDL::ExceptionOr<void> send(DeprecatedString const& data);
private:
void on_open();
void on_message(ByteBuffer message, bool is_text);
void on_error();
void on_close(u16 code, String reason, bool was_clean);
void on_close(u16 code, DeprecatedString reason, bool was_clean);
WebSocket(HTML::Window&, AK::URL&);
@ -73,7 +73,7 @@ private:
JS::NonnullGCPtr<HTML::Window> m_window;
AK::URL m_url;
String m_binary_type { "blob" };
DeprecatedString m_binary_type { "blob" };
RefPtr<WebSocketClientSocket> m_websocket;
};
@ -82,8 +82,8 @@ public:
virtual ~WebSocketClientSocket();
struct CertificateAndKey {
String certificate;
String key;
DeprecatedString certificate;
DeprecatedString key;
};
struct Message {
@ -101,12 +101,12 @@ public:
virtual void send(ByteBuffer binary_or_text_message, bool is_text) = 0;
virtual void send(StringView text_message) = 0;
virtual void close(u16 code = 1005, String reason = {}) = 0;
virtual void close(u16 code = 1005, DeprecatedString reason = {}) = 0;
Function<void()> on_open;
Function<void(Message)> on_message;
Function<void(Error)> on_error;
Function<void(u16 code, String reason, bool was_clean)> on_close;
Function<void(u16 code, DeprecatedString reason, bool was_clean)> on_close;
Function<CertificateAndKey()> on_certificate_requested;
protected:
@ -119,7 +119,7 @@ public:
static void initialize(RefPtr<WebSocketClientManager>);
static WebSocketClientManager& the();
virtual RefPtr<WebSocketClientSocket> connect(AK::URL const&, String const& origin) = 0;
virtual RefPtr<WebSocketClientSocket> connect(AK::URL const&, DeprecatedString const& origin) = 0;
protected:
explicit WebSocketClientManager();