mirror of
https://github.com/LadybirdBrowser/ladybird.git
synced 2025-07-29 12:19:54 +00:00
Everywhere: Use URL::about_XXX factory functions
This commit is contained in:
parent
07f054e067
commit
9072a7caef
Notes:
github-actions[bot]
2025-02-15 17:06:59 +00:00
Author: https://github.com/shannonbooth
Commit: 9072a7caef
Pull-request: https://github.com/LadybirdBrowser/ladybird/pull/3586
Reviewed-by: https://github.com/tcl3 ✅
18 changed files with 28 additions and 28 deletions
|
@ -422,7 +422,7 @@ GC::Ref<Document> Document::create(JS::Realm& realm, URL::URL const& url)
|
|||
|
||||
GC::Ref<Document> Document::create_for_fragment_parsing(JS::Realm& realm)
|
||||
{
|
||||
return realm.create<Document>(realm, "about:blank"sv, TemporaryDocumentForFragmentParsing::Yes);
|
||||
return realm.create<Document>(realm, URL::about_blank(), TemporaryDocumentForFragmentParsing::Yes);
|
||||
}
|
||||
|
||||
Document::Document(JS::Realm& realm, const URL::URL& url, TemporaryDocumentForFragmentParsing temporary_document_for_fragment_parsing)
|
||||
|
|
|
@ -103,7 +103,7 @@ public:
|
|||
|
||||
static WebIDL::ExceptionOr<GC::Ref<Document>> create_and_initialize(Type, String content_type, HTML::NavigationParams const&);
|
||||
|
||||
[[nodiscard]] static GC::Ref<Document> create(JS::Realm&, URL::URL const& url = "about:blank"sv);
|
||||
[[nodiscard]] static GC::Ref<Document> create(JS::Realm&, URL::URL const& url = URL::about_blank());
|
||||
[[nodiscard]] static GC::Ref<Document> create_for_fragment_parsing(JS::Realm&);
|
||||
static WebIDL::ExceptionOr<GC::Ref<Document>> construct_impl(JS::Realm&);
|
||||
virtual ~Document() override;
|
||||
|
|
|
@ -33,7 +33,7 @@ GC::Ref<DOM::Document> create_document_for_inline_content(GC::Ptr<HTML::Navigabl
|
|||
// origin: origin
|
||||
// opener policy: coop
|
||||
HTML::OpenerPolicyEnforcementResult coop_enforcement_result {
|
||||
.url = URL::URL("about:error"), // AD-HOC
|
||||
.url = URL::about_error(), // AD-HOC
|
||||
.origin = origin,
|
||||
.opener_policy = coop
|
||||
};
|
||||
|
@ -55,7 +55,7 @@ GC::Ref<DOM::Document> create_document_for_inline_content(GC::Ptr<HTML::Navigabl
|
|||
// about base URL: null
|
||||
// user involvement: userInvolvement
|
||||
auto response = Fetch::Infrastructure::Response::create(vm);
|
||||
response->url_list().append(URL::URL("about:error")); // AD-HOC: https://github.com/whatwg/html/issues/9122
|
||||
response->url_list().append(URL::about_error()); // AD-HOC: https://github.com/whatwg/html/issues/9122
|
||||
auto navigation_params = vm.heap().allocate<HTML::NavigationParams>();
|
||||
navigation_params->id = navigation_id;
|
||||
navigation_params->navigable = navigable;
|
||||
|
|
|
@ -15,7 +15,7 @@ class XMLDocument final : public Document {
|
|||
GC_DECLARE_ALLOCATOR(XMLDocument);
|
||||
|
||||
public:
|
||||
static GC::Ref<XMLDocument> create(JS::Realm&, URL::URL const& url = "about:blank"sv);
|
||||
static GC::Ref<XMLDocument> create(JS::Realm&, URL::URL const& url = URL::about_blank());
|
||||
virtual ~XMLDocument() override = default;
|
||||
|
||||
private:
|
||||
|
|
|
@ -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);
|
||||
|
|
|
@ -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:
|
||||
|
|
|
@ -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.
|
||||
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -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.
|
||||
|
|
|
@ -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.
|
||||
|
|
|
@ -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))
|
||||
|
|
|
@ -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())) {
|
||||
|
|
|
@ -73,7 +73,7 @@ void Page::load_html(StringView html)
|
|||
// FIXME: #23909 Figure out why GC threshold does not stay low when repeatedly loading html from the WebView
|
||||
heap().collect_garbage();
|
||||
|
||||
(void)top_level_traversable()->navigate({ .url = "about:srcdoc"sv,
|
||||
(void)top_level_traversable()->navigate({ .url = URL::about_srcdoc(),
|
||||
.source_document = *top_level_traversable()->active_document(),
|
||||
.document_resource = String::from_utf8(html).release_value_but_fixme_should_propagate_errors(),
|
||||
.user_involvement = HTML::UserNavigationInvolvement::BrowserUI });
|
||||
|
|
|
@ -72,7 +72,7 @@ Trustworthiness is_origin_potentially_trustworthy(URL::Origin const& origin)
|
|||
Trustworthiness is_url_potentially_trustworthy(URL::URL const& url)
|
||||
{
|
||||
// 1. If url is "about:blank" or "about:srcdoc", return "Potentially Trustworthy".
|
||||
if (url == "about:blank"sv || url == "about:srcdoc"sv)
|
||||
if (url == URL::about_blank() || url == URL::about_srcdoc())
|
||||
return Trustworthiness::PotentiallyTrustworthy;
|
||||
|
||||
// 2. If url’s scheme is "data", return "Potentially Trustworthy".
|
||||
|
|
|
@ -19,7 +19,7 @@ PageHost::PageHost(ConnectionFromClient& client)
|
|||
: m_client(client)
|
||||
{
|
||||
auto& first_page = create_page();
|
||||
Web::HTML::TraversableNavigable::create_a_fresh_top_level_traversable(first_page.page(), URL::URL("about:blank")).release_value_but_fixme_should_propagate_errors();
|
||||
Web::HTML::TraversableNavigable::create_a_fresh_top_level_traversable(first_page.page(), URL::about_blank()).release_value_but_fixme_should_propagate_errors();
|
||||
}
|
||||
|
||||
PageClient& PageHost::create_page()
|
||||
|
|
|
@ -180,7 +180,7 @@
|
|||
return;
|
||||
}
|
||||
|
||||
[self createNewTab:URL::URL("about:version"sv)
|
||||
[self createNewTab:URL::URL(URL::about_version())
|
||||
fromTab:(Tab*)current_tab
|
||||
activateTab:Web::HTML::ActivateTab::Yes];
|
||||
}
|
||||
|
|
|
@ -382,7 +382,7 @@ static void run_test(HeadlessWebView& view, Test& test, Application& app)
|
|||
auto promise = Core::Promise<Empty>::construct();
|
||||
|
||||
view.on_load_finish = [promise](auto const& url) {
|
||||
if (!url.equals("about:blank"sv))
|
||||
if (!url.equals(URL::about_blank()))
|
||||
return;
|
||||
|
||||
Core::deferred_invoke([promise]() {
|
||||
|
@ -411,7 +411,7 @@ static void run_test(HeadlessWebView& view, Test& test, Application& app)
|
|||
VERIFY_NOT_REACHED();
|
||||
});
|
||||
|
||||
view.load("about:blank"sv);
|
||||
view.load(URL::about_blank());
|
||||
}
|
||||
|
||||
static void set_ui_callbacks_for_tests(HeadlessWebView& view)
|
||||
|
|
|
@ -63,7 +63,7 @@ ErrorOr<int> serenity_main(Main::Arguments arguments)
|
|||
{
|
||||
WebView::platform_init();
|
||||
|
||||
auto app = Ladybird::Application::create(arguments, "about:newtab"sv);
|
||||
auto app = Ladybird::Application::create(arguments, URL::about_newtab());
|
||||
TRY(app->launch_services());
|
||||
|
||||
Core::ResourceImplementation::install(make<Core::ResourceImplementationFile>(MUST(String::from_byte_string(app->resources_folder))));
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue