1
Fork 0
mirror of https://github.com/RGBCube/serenity synced 2025-07-25 06:37:43 +00:00

AK+Everywhere: Remove the null state of DeprecatedString

This commit removes DeprecatedString's "null" state, and replaces all
its users with one of the following:
- A normal, empty DeprecatedString
- Optional<DeprecatedString>

Note that null states of DeprecatedFlyString/StringView/etc are *not*
affected by this commit. However, DeprecatedString::empty() is now
considered equal to a null StringView.
This commit is contained in:
Ali Mohammad Pur 2023-10-10 15:00:58 +03:30 committed by Ali Mohammad Pur
parent daf6d8173c
commit aeee98b3a1
189 changed files with 597 additions and 652 deletions

View file

@ -16,7 +16,7 @@ namespace Web::HTML {
class Origin {
public:
Origin() = default;
Origin(DeprecatedString const& scheme, AK::URL::Host const& host, u16 port)
Origin(Optional<DeprecatedString> const& scheme, AK::URL::Host const& host, u16 port)
: m_scheme(scheme)
, m_host(host)
, m_port(port)
@ -24,9 +24,12 @@ public:
}
// https://html.spec.whatwg.org/multipage/origin.html#concept-origin-opaque
bool is_opaque() const { return m_scheme.is_null() && m_host.has<Empty>() && m_port == 0; }
bool is_opaque() const { return !m_scheme.has_value() && m_host.has<Empty>() && m_port == 0; }
DeprecatedString const& scheme() const { return m_scheme; }
StringView scheme() const
{
return m_scheme.map([](auto& str) { return str.view(); }).value_or(StringView {});
}
AK::URL::Host const& host() const { return m_host; }
u16 port() const { return m_port; }
@ -110,7 +113,7 @@ public:
bool operator==(Origin const& other) const { return is_same_origin(other); }
private:
DeprecatedString m_scheme;
Optional<DeprecatedString> m_scheme;
AK::URL::Host m_host;
u16 m_port { 0 };
};