
SPDX License Identifiers are a more compact / standardized way of representing file license information. See: https://spdx.dev/resources/use/#identifiers This was done with the `ambr` search and replace tool. ambr --no-parent-ignore --key-from-file --rep-from-file key.txt rep.txt *
41 lines
1.2 KiB
C++
41 lines
1.2 KiB
C++
/*
|
|
* Copyright (c) 2020, Andreas Kling <kling@serenityos.org>
|
|
*
|
|
* SPDX-License-Identifier: BSD-2-Clause
|
|
*/
|
|
|
|
#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 <unistd.h>
|
|
|
|
int main(int argc, char** argv)
|
|
{
|
|
auto app = GUI::Application::construct(argc, argv);
|
|
auto window = GUI::Window::construct();
|
|
window->set_title("DumpLayoutTree");
|
|
window->resize(800, 600);
|
|
window->show();
|
|
auto& web_view = window->set_main_widget<Web::InProcessWebView>();
|
|
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());
|
|
_exit(0);
|
|
};
|
|
return app->exec();
|
|
}
|