LibWeb: Use resource scheme for icons in internal pages

This commit is contained in:
Bastiaan van der Plaat 2023-12-26 10:12:14 +01:00 committed by Tim Flynn
parent 44d623d588
commit b39d99cf2f
Notes: sideshowbarker 2024-07-16 22:26:05 +09:00
7 changed files with 4 additions and 23 deletions

View file

@ -28,13 +28,13 @@
background-size: contain;
}
.folder {
background-image: url('@resource_directory_url@/icons/32x32/filetype-folder.png');
background-image: url('resource://icons/32x32/filetype-folder.png');
}
.file {
background-image: url('@resource_directory_url@/icons/32x32/filetype-unknown.png');
background-image: url('resource://icons/32x32/filetype-unknown.png');
}
.open-parent {
background-image: url('@resource_directory_url@/icons/16x16/open-parent-directory.png');
background-image: url('resource://icons/16x16/open-parent-directory.png');
}
</style>
</head>

View file

@ -16,7 +16,7 @@
</head>
<body>
<header>
<img src="@resource_directory_url@/icons/32x32/msgbox-warning.png" alt="Warning" width="24" height="24">
<img src="resource://icons/32x32/msgbox-warning.png" alt="Warning" width="24" height="24">
<h1>Failed to load @failed_url@</h1>
</header>
</body>

View file

@ -72,7 +72,6 @@ ErrorOr<int> service_main(int ipc_socket, int fd_passing_socket)
Web::HTML::Window::set_internals_object_exposed(is_layout_test_mode);
Web::Platform::FontPlugin::install(*new Ladybird::FontPlugin(is_layout_test_mode));
Web::set_resource_directory_url(TRY(String::formatted("file://{}/res", s_serenity_resource_root)));
Web::set_error_page_url(TRY(String::formatted("file://{}/res/ladybird/error.html", s_serenity_resource_root)));
Web::set_directory_page_url(TRY(String::formatted("file://{}/res/ladybird/directory.html", s_serenity_resource_root)));

View file

@ -115,7 +115,6 @@ ErrorOr<int> serenity_main(Main::Arguments arguments)
Web::Platform::FontPlugin::install(*new Ladybird::FontPlugin(is_layout_test_mode));
Web::set_resource_directory_url(TRY(String::formatted("file://{}/res", s_serenity_resource_root)));
Web::set_error_page_url(TRY(String::formatted("file://{}/res/ladybird/error.html", s_serenity_resource_root)));
Web::set_directory_page_url(TRY(String::formatted("file://{}/res/ladybird/directory.html", s_serenity_resource_root)));

View file

@ -49,7 +49,6 @@ ErrorOr<int> serenity_main(Main::Arguments arguments)
VERIFY(fd_passing_socket >= 0);
Web::set_resource_directory_url(TRY(String::formatted("file://{}/res", s_serenity_resource_root)));
Web::set_error_page_url(TRY(String::formatted("file://{}/res/ladybird/error.html", s_serenity_resource_root)));
Web::set_directory_page_url(TRY(String::formatted("file://{}/res/ladybird/directory.html", s_serenity_resource_root)));

View file

@ -14,18 +14,6 @@
namespace Web {
static String s_resource_directory_url = "file:///res"_string;
String resource_directory_url()
{
return s_resource_directory_url;
}
void set_resource_directory_url(String resource_directory_url)
{
s_resource_directory_url = resource_directory_url;
}
static String s_error_page_url = "file:///res/ladybird/error.html"_string;
String error_page_url()
@ -59,7 +47,6 @@ ErrorOr<String> load_error_page(AK::URL const& url)
auto template_contents = TRY(template_file->read_until_eof());
StringBuilder builder;
SourceGenerator generator { builder };
generator.set("resource_directory_url", resource_directory_url());
generator.set("failed_url", url.to_byte_string());
generator.append(template_contents);
return TRY(String::from_utf8(generator.as_string_view()));
@ -101,7 +88,6 @@ ErrorOr<String> load_file_directory_page(LoadRequest const& request)
auto template_contents = TRY(template_file->read_until_eof());
StringBuilder builder;
SourceGenerator generator { builder };
generator.set("resource_directory_url", resource_directory_url());
generator.set("path", escape_html_entities(lexical_path.string()));
generator.set("parent_path", escape_html_entities(lexical_path.parent().string()));
generator.set("contents", contents.to_byte_string());

View file

@ -11,8 +11,6 @@
namespace Web {
String resource_directory_url();
void set_resource_directory_url(String);
String error_page_url();
void set_error_page_url(String);
String directory_page_url();