mirror of
https://github.com/LadybirdBrowser/ladybird.git
synced 2024-11-22 15:40:19 +00:00
LibWeb: Use resource scheme for icons in internal pages
This commit is contained in:
parent
44d623d588
commit
b39d99cf2f
Notes:
sideshowbarker
2024-07-16 22:26:05 +09:00
Author: https://github.com/bplaat Commit: https://github.com/SerenityOS/serenity/commit/b39d99cf2f Pull-request: https://github.com/SerenityOS/serenity/pull/22437 Reviewed-by: https://github.com/trflynn89
7 changed files with 4 additions and 23 deletions
|
@ -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>
|
||||
|
|
|
@ -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>
|
||||
|
|
|
@ -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)));
|
||||
|
||||
|
|
|
@ -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)));
|
||||
|
||||
|
|
|
@ -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)));
|
||||
|
||||
|
|
|
@ -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());
|
||||
|
|
|
@ -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();
|
||||
|
|
Loading…
Reference in a new issue