diff options
author | Andreas Kling <kling@serenityos.org> | 2020-05-27 21:57:30 +0200 |
---|---|---|
committer | Andreas Kling <kling@serenityos.org> | 2020-05-27 21:57:30 +0200 |
commit | 2cb50f6750d07fad48e8d51bf12f2ca144ff2ccd (patch) | |
tree | 9d0b58cdab2c9706ccb8b1770eba5dd0627563ed /Applications | |
parent | 08e29072107a250e563d8b12729a1cbd276b5d96 (diff) | |
download | serenity-2cb50f6750d07fad48e8d51bf12f2ca144ff2ccd.zip |
LibWeb+Browser: Add ability to run Browser with the new HTML parser
You can now pass "-n" to the browser to use the new HTML parser.
It's not turned on by default since it's still very immature, but this
is a huge step towards bringing it into maturity. :^)
Diffstat (limited to 'Applications')
-rw-r--r-- | Applications/Browser/Tab.cpp | 3 | ||||
-rw-r--r-- | Applications/Browser/main.cpp | 13 |
2 files changed, 14 insertions, 2 deletions
diff --git a/Applications/Browser/Tab.cpp b/Applications/Browser/Tab.cpp index d6df6d2c28..3aea7be8bc 100644 --- a/Applications/Browser/Tab.cpp +++ b/Applications/Browser/Tab.cpp @@ -59,6 +59,7 @@ namespace Browser { +extern bool g_use_new_html_parser; extern String g_home_url; Tab::Tab() @@ -70,6 +71,8 @@ Tab::Tab() auto& toolbar = m_toolbar_container->add<GUI::ToolBar>(); m_html_widget = widget.add<Web::HtmlView>(); + m_html_widget->set_use_new_parser(g_use_new_html_parser); + m_go_back_action = GUI::CommonActions::make_go_back_action([this](auto&) { m_history.go_back(); update_actions(); diff --git a/Applications/Browser/main.cpp b/Applications/Browser/main.cpp index fc2eebfa4e..50257828d3 100644 --- a/Applications/Browser/main.cpp +++ b/Applications/Browser/main.cpp @@ -28,6 +28,7 @@ #include "InspectorWidget.h" #include "Tab.h" #include "WindowActions.h" +#include <LibCore/ArgsParser.h> #include <LibCore/ConfigFile.h> #include <LibCore/File.h> #include <LibGUI/AboutDialog.h> @@ -44,6 +45,7 @@ namespace Browser { static const char* bookmarks_filename = "/home/anon/bookmarks.json"; String g_home_url; +bool g_use_new_html_parser = false; } @@ -59,6 +61,13 @@ int main(int argc, char** argv) return 1; } + const char* specified_url = nullptr; + + Core::ArgsParser args_parser; + args_parser.add_option(Browser::g_use_new_html_parser, "Use new HTML parser", "new-parser", 'n'); + args_parser.add_positional_argument(specified_url, "URL to open", "url", Core::ArgsParser::Required::No); + args_parser.parse(argc, argv); + GUI::Application app(argc, argv); // Connect to the ProtocolServer immediately so we can drop the "unix" pledge. @@ -174,8 +183,8 @@ int main(int argc, char** argv) }; URL first_url = Browser::g_home_url; - if (app.args().size() >= 1) - first_url = URL::create_with_url_or_path(app.args()[0]); + if (specified_url) + first_url = URL::create_with_url_or_path(specified_url); window_actions.on_create_new_tab = [&] { create_new_tab(Browser::g_home_url, true); |