1
Fork 0
mirror of https://github.com/RGBCube/serenity synced 2025-05-28 08:35:09 +00:00

LibWeb+WebContent: Port DumpLayoutTree to OutOfProcessWebView

This required adding a simple OOPWV::dump_layout_tree() API that
synchronously requests a dump of the layout tree from the WebContent
process.
This commit is contained in:
Andreas Kling 2021-09-08 00:55:35 +02:00
parent c6e56612f5
commit 9d03ea6f74
6 changed files with 28 additions and 18 deletions

View file

@ -7,9 +7,7 @@
#include <LibCore/ArgsParser.h>
#include <LibGUI/Application.h>
#include <LibGUI/Window.h>
#include <LibWeb/Dump.h>
#include <LibWeb/InProcessWebView.h>
#include <LibWeb/Layout/InitialContainingBlockBox.h>
#include <LibWeb/OutOfProcessWebView.h>
#include <unistd.h>
int main(int argc, char** argv)
@ -19,22 +17,11 @@ int main(int argc, char** argv)
window->set_title("DumpLayoutTree");
window->resize(800, 600);
window->show();
auto& web_view = window->set_main_widget<Web::InProcessWebView>();
auto& web_view = window->set_main_widget<Web::OutOfProcessWebView>();
web_view.load(URL::create_with_file_protocol(argv[1]));
web_view.on_load_finish = [&](auto&) {
auto* document = web_view.document();
if (!document) {
warnln("No document.");
_exit(1);
}
auto* layout_root = document->layout_node();
if (!layout_root) {
warnln("No layout tree.");
_exit(1);
}
StringBuilder builder;
Web::dump_tree(builder, *layout_root);
write(STDOUT_FILENO, builder.string_view().characters_without_null_termination(), builder.length());
auto dump = web_view.dump_layout_tree();
write(STDOUT_FILENO, dump.characters(), dump.length() + 1);
_exit(0);
};
return app->exec();