mirror of
https://github.com/RGBCube/serenity
synced 2025-05-28 06:45:07 +00:00
Ladybird: Add --dump-layout-tree mode that dumps layout tree and exits
This commit is contained in:
parent
90fee39290
commit
ddbdeb3ca0
3 changed files with 27 additions and 6 deletions
|
@ -1055,3 +1055,8 @@ void WebContentView::notify_server_did_get_accessibility_tree(DeprecatedString c
|
||||||
{
|
{
|
||||||
dbgln("TODO: support accessibility tree in Ladybird");
|
dbgln("TODO: support accessibility tree in Ladybird");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
ErrorOr<String> WebContentView::dump_layout_tree()
|
||||||
|
{
|
||||||
|
return String::from_deprecated_string(client().dump_layout_tree());
|
||||||
|
}
|
||||||
|
|
|
@ -94,6 +94,8 @@ public:
|
||||||
void show_js_console();
|
void show_js_console();
|
||||||
void show_inspector();
|
void show_inspector();
|
||||||
|
|
||||||
|
ErrorOr<String> dump_layout_tree();
|
||||||
|
|
||||||
Gfx::IntPoint to_content(Gfx::IntPoint) const;
|
Gfx::IntPoint to_content(Gfx::IntPoint) const;
|
||||||
Gfx::IntPoint to_widget(Gfx::IntPoint) const;
|
Gfx::IntPoint to_widget(Gfx::IntPoint) const;
|
||||||
|
|
||||||
|
|
|
@ -7,6 +7,7 @@
|
||||||
#include "BrowserWindow.h"
|
#include "BrowserWindow.h"
|
||||||
#include "Settings.h"
|
#include "Settings.h"
|
||||||
#include "Utilities.h"
|
#include "Utilities.h"
|
||||||
|
#include "WebContentView.h"
|
||||||
#include <Browser/CookieJar.h>
|
#include <Browser/CookieJar.h>
|
||||||
#include <Browser/Database.h>
|
#include <Browser/Database.h>
|
||||||
#include <LibCore/ArgsParser.h>
|
#include <LibCore/ArgsParser.h>
|
||||||
|
@ -68,13 +69,32 @@ ErrorOr<int> serenity_main(Main::Arguments arguments)
|
||||||
|
|
||||||
StringView raw_url;
|
StringView raw_url;
|
||||||
StringView webdriver_content_ipc_path;
|
StringView webdriver_content_ipc_path;
|
||||||
|
bool dump_layout_tree;
|
||||||
|
|
||||||
Core::ArgsParser args_parser;
|
Core::ArgsParser args_parser;
|
||||||
args_parser.set_general_help("The Ladybird web browser :^)");
|
args_parser.set_general_help("The Ladybird web browser :^)");
|
||||||
args_parser.add_positional_argument(raw_url, "URL to open", "url", Core::ArgsParser::Required::No);
|
args_parser.add_positional_argument(raw_url, "URL to open", "url", Core::ArgsParser::Required::No);
|
||||||
args_parser.add_option(webdriver_content_ipc_path, "Path to WebDriver IPC for WebContent", "webdriver-content-path", 0, "path");
|
args_parser.add_option(webdriver_content_ipc_path, "Path to WebDriver IPC for WebContent", "webdriver-content-path", 0, "path");
|
||||||
|
args_parser.add_option(dump_layout_tree, "Dump layout tree and exit", "dump-layout-tree", 'd');
|
||||||
args_parser.parse(arguments);
|
args_parser.parse(arguments);
|
||||||
|
|
||||||
|
URL url = raw_url;
|
||||||
|
if (Core::File::exists(raw_url))
|
||||||
|
url = URL::create_with_file_scheme(Core::File::real_path_for(raw_url));
|
||||||
|
else if (!url.is_valid())
|
||||||
|
url = DeprecatedString::formatted("http://{}", raw_url);
|
||||||
|
|
||||||
|
if (dump_layout_tree) {
|
||||||
|
WebContentView view({});
|
||||||
|
view.on_load_finish = [&](auto&) {
|
||||||
|
auto dump = view.dump_layout_tree().release_value_but_fixme_should_propagate_errors();
|
||||||
|
outln("{}", dump);
|
||||||
|
_exit(0);
|
||||||
|
};
|
||||||
|
view.load(url);
|
||||||
|
return app.exec();
|
||||||
|
}
|
||||||
|
|
||||||
auto cookie_jar = TRY(Browser::CookieJar::create(*database));
|
auto cookie_jar = TRY(Browser::CookieJar::create(*database));
|
||||||
|
|
||||||
BrowserWindow window(cookie_jar, webdriver_content_ipc_path);
|
BrowserWindow window(cookie_jar, webdriver_content_ipc_path);
|
||||||
|
@ -83,12 +103,6 @@ ErrorOr<int> serenity_main(Main::Arguments arguments)
|
||||||
window.resize(800, 600);
|
window.resize(800, 600);
|
||||||
window.show();
|
window.show();
|
||||||
|
|
||||||
URL url = raw_url;
|
|
||||||
if (Core::File::exists(raw_url))
|
|
||||||
url = URL::create_with_file_scheme(Core::File::real_path_for(raw_url));
|
|
||||||
else if (!url.is_valid())
|
|
||||||
url = DeprecatedString::formatted("http://{}", raw_url);
|
|
||||||
|
|
||||||
if (url.is_valid())
|
if (url.is_valid())
|
||||||
window.view().load(url);
|
window.view().load(url);
|
||||||
|
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue