main.cpp 802 B

123456789101112131415161718192021222324252627
  1. /*
  2. * Copyright (c) 2020, Andreas Kling <kling@serenityos.org>
  3. *
  4. * SPDX-License-Identifier: BSD-2-Clause
  5. */
  6. #include <LibGUI/Application.h>
  7. #include <LibGUI/Window.h>
  8. #include <LibWeb/OutOfProcessWebView.h>
  9. #include <unistd.h>
  10. int main(int argc, char** argv)
  11. {
  12. auto app = GUI::Application::construct(argc, argv);
  13. auto window = GUI::Window::construct();
  14. window->set_title("DumpLayoutTree");
  15. window->resize(800, 600);
  16. window->show();
  17. auto& web_view = window->set_main_widget<Web::OutOfProcessWebView>();
  18. web_view.load(URL::create_with_file_protocol(argv[1]));
  19. web_view.on_load_finish = [&](auto&) {
  20. auto dump = web_view.dump_layout_tree();
  21. write(STDOUT_FILENO, dump.characters(), dump.length() + 1);
  22. _exit(0);
  23. };
  24. return app->exec();
  25. }