main.cpp 834 B

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