summaryrefslogtreecommitdiff
path: root/Userland/Libraries/LibWeb
diff options
context:
space:
mode:
authornetworkException <git@nwex.de>2022-09-29 01:30:58 +0200
committerLinus Groh <mail@linusgroh.de>2022-09-29 09:39:04 +0100
commit4230dbbb21ec68cbb9844130d5e90276c96d16c2 (patch)
treea2586bed833a3577a997d2e8cd5e7df232978bc1 /Userland/Libraries/LibWeb
parent454bf1fde054591d1215404617126ce31b281171 (diff)
downloadserenity-4230dbbb21ec68cbb9844130d5e90276c96d16c2.zip
AK+Everywhere: Replace "protocol" with "scheme" url helpers
URL had properly named replacements for protocol(), set_protocol() and create_with_file_protocol() already. This patch removes these function and updates all call sites to use the functions named according to the specification. See https://url.spec.whatwg.org/#concept-url-scheme
Diffstat (limited to 'Userland/Libraries/LibWeb')
-rw-r--r--Userland/Libraries/LibWeb/Bindings/LocationObject.cpp2
-rw-r--r--Userland/Libraries/LibWeb/CSS/StyleComputer.cpp2
-rw-r--r--Userland/Libraries/LibWeb/HTML/BrowsingContext.cpp2
-rw-r--r--Userland/Libraries/LibWeb/HTML/BrowsingContextContainer.cpp2
-rw-r--r--Userland/Libraries/LibWeb/HTML/HTMLFormElement.cpp6
-rw-r--r--Userland/Libraries/LibWeb/HTML/HTMLIFrameElement.cpp2
-rw-r--r--Userland/Libraries/LibWeb/Loader/ContentFilter.cpp2
-rw-r--r--Userland/Libraries/LibWeb/Loader/FrameLoader.cpp4
-rw-r--r--Userland/Libraries/LibWeb/Loader/Resource.cpp2
-rw-r--r--Userland/Libraries/LibWeb/Loader/ResourceLoader.cpp14
-rw-r--r--Userland/Libraries/LibWeb/WebSockets/WebSocket.cpp2
-rw-r--r--Userland/Libraries/LibWeb/XHR/XMLHttpRequest.cpp2
12 files changed, 21 insertions, 21 deletions
diff --git a/Userland/Libraries/LibWeb/Bindings/LocationObject.cpp b/Userland/Libraries/LibWeb/Bindings/LocationObject.cpp
index 037b7775cc..86b7eca376 100644
--- a/Userland/Libraries/LibWeb/Bindings/LocationObject.cpp
+++ b/Userland/Libraries/LibWeb/Bindings/LocationObject.cpp
@@ -204,7 +204,7 @@ JS_DEFINE_NATIVE_FUNCTION(LocationObject::protocol_getter)
// FIXME: 1. If this's relevant Document is non-null and its origin is not same origin-domain with the entry settings object's origin, then throw a "SecurityError" DOMException.
// 2. Return this's url's scheme, followed by ":".
- return JS::js_string(vm, String::formatted("{}:", location_object->url().protocol()));
+ return JS::js_string(vm, String::formatted("{}:", location_object->url().scheme()));
}
// https://html.spec.whatwg.org/multipage/history.html#dom-location-port
diff --git a/Userland/Libraries/LibWeb/CSS/StyleComputer.cpp b/Userland/Libraries/LibWeb/CSS/StyleComputer.cpp
index f1ac365edd..dcd3d6b8a4 100644
--- a/Userland/Libraries/LibWeb/CSS/StyleComputer.cpp
+++ b/Userland/Libraries/LibWeb/CSS/StyleComputer.cpp
@@ -1383,7 +1383,7 @@ void StyleComputer::load_fonts_from_sheet(CSSStyleSheet const& sheet)
if (!source.url.is_valid())
continue;
- if (source.url.protocol() != "data") {
+ if (source.url.scheme() != "data") {
auto path = source.url.path();
if (!path.ends_with(".woff"sv, AK::CaseSensitivity::CaseInsensitive)
&& !path.ends_with(".ttf"sv, AK::CaseSensitivity::CaseInsensitive)) {
diff --git a/Userland/Libraries/LibWeb/HTML/BrowsingContext.cpp b/Userland/Libraries/LibWeb/HTML/BrowsingContext.cpp
index d3c3af2ab2..18cbdbdcfd 100644
--- a/Userland/Libraries/LibWeb/HTML/BrowsingContext.cpp
+++ b/Userland/Libraries/LibWeb/HTML/BrowsingContext.cpp
@@ -56,7 +56,7 @@ static HTML::Origin url_origin(AK::URL const& url)
if (url.scheme() == "file"sv) {
// Unfortunate as it is, this is left as an exercise to the reader. When in doubt, return a new opaque origin.
// Note: We must return an origin with the `file://' protocol for `file://' iframes to work from `file://' pages.
- return HTML::Origin(url.protocol(), String(), 0);
+ return HTML::Origin(url.scheme(), String(), 0);
}
return HTML::Origin {};
diff --git a/Userland/Libraries/LibWeb/HTML/BrowsingContextContainer.cpp b/Userland/Libraries/LibWeb/HTML/BrowsingContextContainer.cpp
index fecd1788c1..6ddbad68e9 100644
--- a/Userland/Libraries/LibWeb/HTML/BrowsingContextContainer.cpp
+++ b/Userland/Libraries/LibWeb/HTML/BrowsingContextContainer.cpp
@@ -168,7 +168,7 @@ void BrowsingContextContainer::shared_attribute_processing_steps_for_iframe_and_
// FIXME: Set the referrer policy.
// AD-HOC:
- if (url.protocol() == "file" && document().origin().protocol() != "file") {
+ if (url.scheme() == "file" && document().origin().protocol() != "file") {
dbgln("iframe failed to load URL: Security violation: {} may not load {}", document().url(), url);
return;
}
diff --git a/Userland/Libraries/LibWeb/HTML/HTMLFormElement.cpp b/Userland/Libraries/LibWeb/HTML/HTMLFormElement.cpp
index 9599f9390f..3a16a49cae 100644
--- a/Userland/Libraries/LibWeb/HTML/HTMLFormElement.cpp
+++ b/Userland/Libraries/LibWeb/HTML/HTMLFormElement.cpp
@@ -96,8 +96,8 @@ void HTMLFormElement::submit_form(JS::GCPtr<HTMLElement> submitter, bool from_su
return;
}
- if (url.protocol() == "file") {
- if (document().url().protocol() != "file") {
+ if (url.scheme() == "file") {
+ if (document().url().scheme() != "file") {
dbgln("Failed to submit form: Security violation: {} may not submit to {}", document().url(), url);
return;
}
@@ -105,7 +105,7 @@ void HTMLFormElement::submit_form(JS::GCPtr<HTMLElement> submitter, bool from_su
dbgln("Failed to submit form: Unsupported form method '{}' for URL: {}", method(), url);
return;
}
- } else if (url.protocol() != "http" && url.protocol() != "https") {
+ } else if (url.scheme() != "http" && url.scheme() != "https") {
dbgln("Failed to submit form: Unsupported protocol for URL: {}", url);
return;
}
diff --git a/Userland/Libraries/LibWeb/HTML/HTMLIFrameElement.cpp b/Userland/Libraries/LibWeb/HTML/HTMLIFrameElement.cpp
index 34fda75a53..34ba6df919 100644
--- a/Userland/Libraries/LibWeb/HTML/HTMLIFrameElement.cpp
+++ b/Userland/Libraries/LibWeb/HTML/HTMLIFrameElement.cpp
@@ -117,7 +117,7 @@ void HTMLIFrameElement::load_src(String const& value)
dbgln("iframe failed to load URL: Invalid URL: {}", value);
return;
}
- if (url.protocol() == "file" && document().origin().protocol() != "file") {
+ if (url.scheme() == "file" && document().origin().protocol() != "file") {
dbgln("iframe failed to load URL: Security violation: {} may not load {}", document().url(), url);
return;
}
diff --git a/Userland/Libraries/LibWeb/Loader/ContentFilter.cpp b/Userland/Libraries/LibWeb/Loader/ContentFilter.cpp
index adce6815a4..8a2c191773 100644
--- a/Userland/Libraries/LibWeb/Loader/ContentFilter.cpp
+++ b/Userland/Libraries/LibWeb/Loader/ContentFilter.cpp
@@ -21,7 +21,7 @@ ContentFilter::~ContentFilter() = default;
bool ContentFilter::is_filtered(const AK::URL& url) const
{
- if (url.protocol() == "data")
+ if (url.scheme() == "data")
return false;
auto url_string = url.to_string();
diff --git a/Userland/Libraries/LibWeb/Loader/FrameLoader.cpp b/Userland/Libraries/LibWeb/Loader/FrameLoader.cpp
index d45e90a8eb..dd1f74a67e 100644
--- a/Userland/Libraries/LibWeb/Loader/FrameLoader.cpp
+++ b/Userland/Libraries/LibWeb/Loader/FrameLoader.cpp
@@ -242,9 +242,9 @@ bool FrameLoader::load(LoadRequest& request, Type type)
if (document && document->has_active_favicon())
return true;
- if (url.protocol() == "http" || url.protocol() == "https") {
+ if (url.scheme() == "http" || url.scheme() == "https") {
AK::URL favicon_url;
- favicon_url.set_protocol(url.protocol());
+ favicon_url.set_scheme(url.scheme());
favicon_url.set_host(url.host());
favicon_url.set_port(url.port_or_default());
favicon_url.set_paths({ "favicon.ico" });
diff --git a/Userland/Libraries/LibWeb/Loader/Resource.cpp b/Userland/Libraries/LibWeb/Loader/Resource.cpp
index 931c1327da..cc28cfae05 100644
--- a/Userland/Libraries/LibWeb/Loader/Resource.cpp
+++ b/Userland/Libraries/LibWeb/Loader/Resource.cpp
@@ -105,7 +105,7 @@ void Resource::did_load(Badge<ResourceLoader>, ReadonlyBytes data, HashMap<Strin
// Let's use image/x-qoi for now, which is also what our Core::MimeData uses & would guess.
if (m_mime_type == "application/octet-stream" && url().path().ends_with(".qoi"sv))
m_mime_type = "image/x-qoi";
- } else if (url().protocol() == "data" && !url().data_mime_type().is_empty()) {
+ } else if (url().scheme() == "data" && !url().data_mime_type().is_empty()) {
dbgln_if(RESOURCE_DEBUG, "This is a data URL with mime-type _{}_", url().data_mime_type());
m_mime_type = url().data_mime_type();
} else {
diff --git a/Userland/Libraries/LibWeb/Loader/ResourceLoader.cpp b/Userland/Libraries/LibWeb/Loader/ResourceLoader.cpp
index d562506ac6..e5cf0a6d98 100644
--- a/Userland/Libraries/LibWeb/Loader/ResourceLoader.cpp
+++ b/Userland/Libraries/LibWeb/Loader/ResourceLoader.cpp
@@ -87,7 +87,7 @@ RefPtr<Resource> ResourceLoader::load_resource(Resource::Type type, LoadRequest&
if (!request.is_valid())
return nullptr;
- bool use_cache = request.url().protocol() != "file";
+ bool use_cache = request.url().scheme() != "file";
if (use_cache) {
auto it = s_resource_cache.find(request);
@@ -120,7 +120,7 @@ RefPtr<Resource> ResourceLoader::load_resource(Resource::Type type, LoadRequest&
static String sanitized_url_for_logging(AK::URL const& url)
{
- if (url.protocol() == "data"sv)
+ if (url.scheme() == "data"sv)
return String::formatted("[data URL, mime-type={}, size={}]", url.data_mime_type(), url.data_payload().length());
return url.to_string();
}
@@ -172,7 +172,7 @@ void ResourceLoader::load(LoadRequest& request, Function<void(ReadonlyBytes, Has
return;
}
- if (url.protocol() == "about") {
+ if (url.scheme() == "about") {
dbgln_if(SPAM_DEBUG, "Loading about: URL {}", url);
log_success(request);
@@ -185,7 +185,7 @@ void ResourceLoader::load(LoadRequest& request, Function<void(ReadonlyBytes, Has
return;
}
- if (url.protocol() == "data") {
+ if (url.scheme() == "data") {
dbgln_if(SPAM_DEBUG, "ResourceLoader loading a data URL with mime-type: '{}', base64={}, payload='{}'",
url.data_mime_type(),
url.data_payload_is_base64(),
@@ -212,7 +212,7 @@ void ResourceLoader::load(LoadRequest& request, Function<void(ReadonlyBytes, Has
return;
}
- if (url.protocol() == "file") {
+ if (url.scheme() == "file") {
if (request.page().has_value())
m_page = request.page().value();
@@ -263,7 +263,7 @@ void ResourceLoader::load(LoadRequest& request, Function<void(ReadonlyBytes, Has
return;
}
- if (url.protocol() == "http" || url.protocol() == "https" || url.protocol() == "gemini") {
+ if (url.scheme() == "http" || url.scheme() == "https" || url.scheme() == "gemini") {
auto proxy = ProxyMappings::the().proxy_for_url(url);
HashMap<String, String> headers;
@@ -326,7 +326,7 @@ void ResourceLoader::load(LoadRequest& request, Function<void(ReadonlyBytes, Has
return;
}
- auto not_implemented_error = String::formatted("Protocol not implemented: {}", url.protocol());
+ auto not_implemented_error = String::formatted("Protocol not implemented: {}", url.scheme());
log_failure(request, not_implemented_error);
if (error_callback)
error_callback(not_implemented_error, {});
diff --git a/Userland/Libraries/LibWeb/WebSockets/WebSocket.cpp b/Userland/Libraries/LibWeb/WebSockets/WebSocket.cpp
index 594a26bcce..39596604f4 100644
--- a/Userland/Libraries/LibWeb/WebSockets/WebSocket.cpp
+++ b/Userland/Libraries/LibWeb/WebSockets/WebSocket.cpp
@@ -52,7 +52,7 @@ WebIDL::ExceptionOr<JS::NonnullGCPtr<WebSocket>> WebSocket::create_with_global_o
AK::URL url_record(url);
if (!url_record.is_valid())
return WebIDL::SyntaxError::create(window, "Invalid URL");
- if (!url_record.protocol().is_one_of("ws", "wss"))
+ if (!url_record.scheme().is_one_of("ws", "wss"))
return WebIDL::SyntaxError::create(window, "Invalid protocol");
if (!url_record.fragment().is_empty())
return WebIDL::SyntaxError::create(window, "Presence of URL fragment is invalid");
diff --git a/Userland/Libraries/LibWeb/XHR/XMLHttpRequest.cpp b/Userland/Libraries/LibWeb/XHR/XMLHttpRequest.cpp
index 20240d7e46..472b1802d4 100644
--- a/Userland/Libraries/LibWeb/XHR/XMLHttpRequest.cpp
+++ b/Userland/Libraries/LibWeb/XHR/XMLHttpRequest.cpp
@@ -416,7 +416,7 @@ WebIDL::ExceptionOr<void> XMLHttpRequest::send(Optional<Fetch::XMLHttpRequestBod
dbgln("XHR send from {} to {}", m_window->associated_document().url(), request_url);
// TODO: Add support for preflight requests to support CORS requests
- auto request_url_origin = HTML::Origin(request_url.protocol(), request_url.host(), request_url.port_or_default());
+ auto request_url_origin = HTML::Origin(request_url.scheme(), request_url.host(), request_url.port_or_default());
bool should_enforce_same_origin_policy = true;
if (auto* page = m_window->page())