Everywhere: Use URL::about_XXX factory functions

This commit is contained in:
Shannon Booth 2025-02-15 23:51:45 +13:00 committed by Tim Ledbetter
commit 9072a7caef
Notes: github-actions[bot] 2025-02-15 17:06:59 +00:00
18 changed files with 28 additions and 28 deletions

View file

@ -73,7 +73,7 @@ URL::Origin determine_the_origin(Optional<URL::URL const&> url, SandboxingFlagSe
}
// 3. If url is about:srcdoc, then:
if (url == "about:srcdoc"sv) {
if (url == URL::about_srcdoc()) {
// 1. Assert: sourceOrigin is non-null.
VERIFY(source_origin.has_value());
@ -167,7 +167,7 @@ WebIDL::ExceptionOr<BrowsingContext::BrowsingContextAndDocument> BrowsingContext
SandboxingFlagSet sandbox_flags = {};
// 7. Let origin be the result of determining the origin given about:blank, sandboxFlags, and creatorOrigin.
auto origin = determine_the_origin(URL::URL("about:blank"sv), sandbox_flags, creator_origin);
auto origin = determine_the_origin(URL::about_blank(), sandbox_flags, creator_origin);
// FIXME: 8. Let permissionsPolicy be the result of creating a permissions policy given embedder and origin. [PERMISSIONSPOLICY]
@ -192,7 +192,7 @@ WebIDL::ExceptionOr<BrowsingContext::BrowsingContextAndDocument> BrowsingContext
});
// 11. Let topLevelCreationURL be about:blank if embedder is null; otherwise embedder's relevant settings object's top-level creation URL.
auto top_level_creation_url = !embedder ? URL::URL("about:blank") : relevant_settings_object(*embedder).top_level_creation_url;
auto top_level_creation_url = !embedder ? URL::about_blank() : relevant_settings_object(*embedder).top_level_creation_url;
// 12. Let topLevelOrigin be origin if embedder is null; otherwise embedder's relevant settings object's top-level origin.
auto top_level_origin = !embedder ? origin : relevant_settings_object(*embedder).origin();
@ -200,7 +200,7 @@ WebIDL::ExceptionOr<BrowsingContext::BrowsingContextAndDocument> BrowsingContext
// 13. Set up a window environment settings object with about:blank, realm execution context, null, topLevelCreationURL, and topLevelOrigin.
WindowEnvironmentSettingsObject::setup(
page,
URL::URL("about:blank"),
URL::about_blank(),
move(realm_execution_context),
{},
top_level_creation_url,
@ -271,8 +271,8 @@ WebIDL::ExceptionOr<BrowsingContext::BrowsingContextAndDocument> BrowsingContext
}
// 17. Assert: document's URL and document's relevant settings object's creation URL are about:blank.
VERIFY(document->url() == "about:blank"sv);
VERIFY(document->relevant_settings_object().creation_url == "about:blank"sv);
VERIFY(document->url() == URL::about_blank());
VERIFY(document->relevant_settings_object().creation_url == URL::about_blank());
// 18. Mark document as ready for post-load tasks.
document->set_ready_for_post_load_tasks(true);

View file

@ -21,7 +21,7 @@ class HTMLDocument final : public DOM::Document {
public:
virtual ~HTMLDocument() override;
[[nodiscard]] static GC::Ref<HTMLDocument> create(JS::Realm&, URL::URL const& url = "about:blank"sv);
[[nodiscard]] static GC::Ref<HTMLDocument> create(JS::Realm&, URL::URL const& url = URL::about_blank());
WebIDL::ExceptionOr<GC::Ref<HTMLDocument>> construct_impl(JS::Realm&);
private:

View file

@ -104,7 +104,7 @@ void HTMLIFrameElement::process_the_iframe_attributes(bool initial_insertion)
// 1. Set element's lazy load resumption steps to the rest of this algorithm starting with the step labeled navigate to the srcdoc resource.
set_lazy_load_resumption_steps([this]() {
// 3. Navigate to the srcdoc resource: navigate an iframe or frame given element, about:srcdoc, the empty string, and the value of element's srcdoc attribute.
navigate_an_iframe_or_frame(URL::URL("about:srcdoc"sv), ReferrerPolicy::ReferrerPolicy::EmptyString, get_attribute(HTML::AttributeNames::srcdoc));
navigate_an_iframe_or_frame(URL::about_srcdoc(), ReferrerPolicy::ReferrerPolicy::EmptyString, get_attribute(HTML::AttributeNames::srcdoc));
// FIXME: The resulting Document must be considered an iframe srcdoc document.
});
@ -120,7 +120,7 @@ void HTMLIFrameElement::process_the_iframe_attributes(bool initial_insertion)
}
// 3. Navigate to the srcdoc resource: navigate an iframe or frame given element, about:srcdoc, the empty string, and the value of element's srcdoc attribute.
navigate_an_iframe_or_frame(URL::URL("about:srcdoc"sv), ReferrerPolicy::ReferrerPolicy::EmptyString, get_attribute(HTML::AttributeNames::srcdoc));
navigate_an_iframe_or_frame(URL::about_srcdoc(), ReferrerPolicy::ReferrerPolicy::EmptyString, get_attribute(HTML::AttributeNames::srcdoc));
// FIXME: The resulting Document must be considered an iframe srcdoc document.

View file

@ -112,7 +112,7 @@ URL::URL Location::url() const
// A Location object has an associated url, which is this Location object's relevant Document's URL,
// if this Location object's relevant Document is non-null, and about:blank otherwise.
auto const relevant_document = this->relevant_document();
return relevant_document ? relevant_document->url() : "about:blank"sv;
return relevant_document ? relevant_document->url() : URL::about_blank();
}
// https://html.spec.whatwg.org/multipage/history.html#dom-location-href

View file

@ -625,7 +625,7 @@ static PolicyContainer determine_navigation_params_policy_container(URL::URL con
}
// 2. If responseURL is about:srcdoc, then:
if (response_url == "about:srcdoc"sv) {
if (response_url == URL::about_srcdoc()) {
// 1. Assert: parentPolicyContainer is not null.
VERIFY(parent_policy_container.has_value());
@ -699,7 +699,7 @@ static GC::Ref<NavigationParams> create_navigation_params_from_a_srcdoc_resource
// header list: (`Content-Type`, `text/html`)
// body: the UTF-8 encoding of documentResource, as a body
auto response = Fetch::Infrastructure::Response::create(vm);
response->url_list().append(URL::URL("about:srcdoc"));
response->url_list().append(URL::about_srcdoc());
auto header = Fetch::Infrastructure::Header::from_string_pair("Content-Type"sv, "text/html"sv);
response->header_list()->append(move(header));
@ -1254,7 +1254,7 @@ WebIDL::ExceptionOr<void> Navigable::populate_session_history_entry_document(
auto error_html = load_error_page(entry->url(), error_message).release_value_but_fixme_should_propagate_errors();
entry->document_state()->set_document(create_document_for_inline_content(this, navigation_id, user_involvement, [this, error_html](auto& document) {
auto parser = HTML::HTMLParser::create(document, error_html, "utf-8"sv);
document.set_url(URL::URL("about:error"));
document.set_url(URL::about_error());
parser->run();
// NOTE: Once the page has been set up, the user agent must act as if it had stopped parsing.

View file

@ -203,7 +203,7 @@ Optional<URL::URL> NavigableContainer::shared_attribute_processing_steps_for_ifr
return {};
// 1. Let url be the URL record about:blank.
auto url = URL::URL("about:blank");
auto url = URL::about_blank();
// 2. If element has a src attribute specified, and its value is not the empty string,
// then parse the value of that attribute relative to element's node document.

View file

@ -26,7 +26,7 @@ GC::Ref<ClassicScript> ClassicScript::create(ByteString filename, StringView sou
// 1. If muted errors is true, then set baseURL to about:blank.
if (muted_errors == MutedErrors::Yes)
base_url = "about:blank"sv;
base_url = URL::about_blank();
// 2. If scripting is disabled for realm, then set source to the empty string.
if (is_scripting_disabled(realm))

View file

@ -255,7 +255,7 @@ WebIDL::ExceptionOr<Window::OpenedWindow> Window::window_open_steps_internal(Str
// 3. If urlRecord is null, then set urlRecord to a URL record representing about:blank.
if (!url_record.has_value())
url_record = URL::URL("about:blank"sv);
url_record = URL::about_blank();
// 4. If urlRecord matches about:blank, then perform the URL and history update steps given targetNavigable's active document and urlRecord.
if (url_matches_about_blank(url_record.value())) {