mirror of
https://github.com/RGBCube/serenity
synced 2025-07-25 04:57:44 +00:00
html: Create URL from filename, if any
This makes it possible for the WebView to resolve relative paths in documents loaded from a file.
This commit is contained in:
parent
f6af2d747e
commit
4ef3a55900
1 changed files with 3 additions and 1 deletions
|
@ -40,10 +40,12 @@ int main(int argc, char** argv)
|
||||||
auto app = GUI::Application::construct(argc, argv);
|
auto app = GUI::Application::construct(argc, argv);
|
||||||
|
|
||||||
auto f = Core::File::construct();
|
auto f = Core::File::construct();
|
||||||
|
URL url;
|
||||||
bool success;
|
bool success;
|
||||||
if (argc < 2) {
|
if (argc < 2) {
|
||||||
success = f->open(STDIN_FILENO, Core::IODevice::OpenMode::ReadOnly, Core::File::ShouldCloseFileDescription::No);
|
success = f->open(STDIN_FILENO, Core::IODevice::OpenMode::ReadOnly, Core::File::ShouldCloseFileDescription::No);
|
||||||
} else {
|
} else {
|
||||||
|
url = URL::create_with_file_protocol(argv[1]);
|
||||||
f->set_filename(argv[1]);
|
f->set_filename(argv[1]);
|
||||||
success = f->open(Core::IODevice::OpenMode::ReadOnly);
|
success = f->open(Core::IODevice::OpenMode::ReadOnly);
|
||||||
}
|
}
|
||||||
|
@ -56,7 +58,7 @@ int main(int argc, char** argv)
|
||||||
|
|
||||||
auto window = GUI::Window::construct();
|
auto window = GUI::Window::construct();
|
||||||
auto& widget = window->set_main_widget<Web::InProcessWebView>();
|
auto& widget = window->set_main_widget<Web::InProcessWebView>();
|
||||||
widget.load_html(html, URL());
|
widget.load_html(html, url);
|
||||||
if (!widget.document()->title().is_null())
|
if (!widget.document()->title().is_null())
|
||||||
window->set_title(String::format("%s - HTML", widget.document()->title().characters()));
|
window->set_title(String::format("%s - HTML", widget.document()->title().characters()));
|
||||||
else
|
else
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue