1
Fork 0
mirror of https://github.com/RGBCube/serenity synced 2025-07-25 01:57:44 +00:00

LibWeb: Rename an origin's protocol to origin scheme

This patch updates the naming of an origin's protocol to be called
scheme according to the specification.

See https://html.spec.whatwg.org/multipage/origin.html#concept-origin-scheme
This commit is contained in:
networkException 2022-09-29 01:37:44 +02:00 committed by Linus Groh
parent 4230dbbb21
commit 9d1336a1c9
3 changed files with 11 additions and 11 deletions

View file

@ -168,7 +168,7 @@ void BrowsingContextContainer::shared_attribute_processing_steps_for_iframe_and_
// FIXME: Set the referrer policy. // FIXME: Set the referrer policy.
// AD-HOC: // AD-HOC:
if (url.scheme() == "file" && document().origin().protocol() != "file") { if (url.scheme() == "file" && document().origin().scheme() != "file") {
dbgln("iframe failed to load URL: Security violation: {} may not load {}", document().url(), url); dbgln("iframe failed to load URL: Security violation: {} may not load {}", document().url(), url);
return; return;
} }

View file

@ -117,7 +117,7 @@ void HTMLIFrameElement::load_src(String const& value)
dbgln("iframe failed to load URL: Invalid URL: {}", value); dbgln("iframe failed to load URL: Invalid URL: {}", value);
return; return;
} }
if (url.scheme() == "file" && document().origin().protocol() != "file") { if (url.scheme() == "file" && document().origin().scheme() != "file") {
dbgln("iframe failed to load URL: Security violation: {} may not load {}", document().url(), url); dbgln("iframe failed to load URL: Security violation: {} may not load {}", document().url(), url);
return; return;
} }

View file

@ -14,17 +14,17 @@ namespace Web::HTML {
class Origin { class Origin {
public: public:
Origin() = default; Origin() = default;
Origin(String const& protocol, String const& host, u16 port) Origin(String const& scheme, String const& host, u16 port)
: m_protocol(protocol) : m_scheme(scheme)
, m_host(host) , m_host(host)
, m_port(port) , m_port(port)
{ {
} }
// https://html.spec.whatwg.org/multipage/origin.html#concept-origin-opaque // https://html.spec.whatwg.org/multipage/origin.html#concept-origin-opaque
bool is_opaque() const { return m_protocol.is_null() && m_host.is_null() && m_port == 0; } bool is_opaque() const { return m_scheme.is_null() && m_host.is_null() && m_port == 0; }
String const& protocol() const { return m_protocol; } String const& scheme() const { return m_scheme; }
String const& host() const { return m_host; } String const& host() const { return m_host; }
u16 port() const { return m_port; } u16 port() const { return m_port; }
@ -37,7 +37,7 @@ public:
// 2. If A and B are both tuple origins and their schemes, hosts, and port are identical, then return true. // 2. If A and B are both tuple origins and their schemes, hosts, and port are identical, then return true.
// 3. Return false. // 3. Return false.
return protocol() == other.protocol() return scheme() == other.scheme()
&& host() == other.host() && host() == other.host()
&& port() == other.port(); && port() == other.port();
} }
@ -53,7 +53,7 @@ public:
if (!is_opaque() && !other.is_opaque()) { if (!is_opaque() && !other.is_opaque()) {
// 1. If A and B's schemes are identical, and their domains are identical and non-null, then return true. // 1. If A and B's schemes are identical, and their domains are identical and non-null, then return true.
// FIXME: Check domains once supported. // FIXME: Check domains once supported.
if (protocol() == other.protocol()) if (scheme() == other.scheme())
return true; return true;
// 2. Otherwise, if A and B are same origin and their domains are identical and null, then return true. // 2. Otherwise, if A and B are same origin and their domains are identical and null, then return true.
@ -75,7 +75,7 @@ public:
// 2. Otherwise, let result be origin's scheme. // 2. Otherwise, let result be origin's scheme.
StringBuilder result; StringBuilder result;
result.append(protocol()); result.append(scheme());
// 3. Append "://" to result. // 3. Append "://" to result.
result.append("://"sv); result.append("://"sv);
@ -109,7 +109,7 @@ public:
bool operator!=(Origin const& other) const { return !is_same_origin(other); } bool operator!=(Origin const& other) const { return !is_same_origin(other); }
private: private:
String m_protocol; String m_scheme;
String m_host; String m_host;
u16 m_port { 0 }; u16 m_port { 0 };
}; };
@ -121,7 +121,7 @@ template<>
struct Traits<Web::HTML::Origin> : public GenericTraits<Web::HTML::Origin> { struct Traits<Web::HTML::Origin> : public GenericTraits<Web::HTML::Origin> {
static unsigned hash(Web::HTML::Origin const& origin) static unsigned hash(Web::HTML::Origin const& origin)
{ {
return pair_int_hash(origin.protocol().hash(), pair_int_hash(int_hash(origin.port()), origin.host().hash())); return pair_int_hash(origin.scheme().hash(), pair_int_hash(int_hash(origin.port()), origin.host().hash()));
} }
}; };
} // namespace AK } // namespace AK