summaryrefslogtreecommitdiff
path: root/Userland/Libraries/LibWebView/DumpLayoutTree/main.cpp
blob: 0f7e824f39f164d9f357a7adbec39a8d8925f15e (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
/*
 * Copyright (c) 2020, Andreas Kling <kling@serenityos.org>
 *
 * SPDX-License-Identifier: BSD-2-Clause
 */

#include <LibGUI/Application.h>
#include <LibGUI/Window.h>
#include <LibWebView/OutOfProcessWebView.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<WebView::OutOfProcessWebView>().release_value_but_fixme_should_propagate_errors();
    web_view->load(URL::create_with_file_scheme(argv[1]));
    web_view->on_load_finish = [&](auto&) {
        auto dump = web_view->dump_layout_tree();
        write(STDOUT_FILENO, dump.characters(), dump.length() + 1);
        _exit(0);
    };
    return app->exec();
}