7
7
#include " BrowserWindow.h"
8
8
#include " Settings.h"
9
9
#include " Utilities.h"
10
+ #include " WebContentView.h"
10
11
#include < Browser/CookieJar.h>
11
12
#include < Browser/Database.h>
12
13
#include < LibCore/ArgsParser.h>
@@ -68,13 +69,32 @@ ErrorOr<int> serenity_main(Main::Arguments arguments)
68
69
69
70
StringView raw_url;
70
71
StringView webdriver_content_ipc_path;
72
+ bool dump_layout_tree;
71
73
72
74
Core::ArgsParser args_parser;
73
75
args_parser.set_general_help (" The Ladybird web browser :^)" );
74
76
args_parser.add_positional_argument (raw_url, " URL to open" , " url" , Core::ArgsParser::Required::No);
75
77
args_parser.add_option (webdriver_content_ipc_path, " Path to WebDriver IPC for WebContent" , " webdriver-content-path" , 0 , " path" );
78
+ args_parser.add_option (dump_layout_tree, " Dump layout tree and exit" , " dump-layout-tree" , ' d' );
76
79
args_parser.parse (arguments);
77
80
81
+ URL url = raw_url;
82
+ if (Core::File::exists (raw_url))
83
+ url = URL::create_with_file_scheme (Core::File::real_path_for (raw_url));
84
+ else if (!url.is_valid ())
85
+ url = DeprecatedString::formatted (" http://{}" , raw_url);
86
+
87
+ if (dump_layout_tree) {
88
+ WebContentView view ({});
89
+ view.on_load_finish = [&](auto &) {
90
+ auto dump = view.dump_layout_tree ().release_value_but_fixme_should_propagate_errors ();
91
+ outln (" {}" , dump);
92
+ _exit (0 );
93
+ };
94
+ view.load (url);
95
+ return app.exec ();
96
+ }
97
+
78
98
auto cookie_jar = TRY (Browser::CookieJar::create (*database));
79
99
80
100
BrowserWindow window (cookie_jar, webdriver_content_ipc_path);
@@ -83,12 +103,6 @@ ErrorOr<int> serenity_main(Main::Arguments arguments)
83
103
window.resize (800 , 600 );
84
104
window.show ();
85
105
86
- URL url = raw_url;
87
- if (Core::File::exists (raw_url))
88
- url = URL::create_with_file_scheme (Core::File::real_path_for (raw_url));
89
- else if (!url.is_valid ())
90
- url = DeprecatedString::formatted (" http://{}" , raw_url);
91
-
92
106
if (url.is_valid ())
93
107
window.view ().load (url);
94
108
0 commit comments