mirror of
				https://github.com/RGBCube/serenity
				synced 2025-10-31 10:42:45 +00:00 
			
		
		
		
	LibWeb+Browser: Use the new HTML parser by default
You can still run the old parser with "br -O", but the new one is good enough to be the default parser now. We'll fix issues as we go and eventually remove the old one completely. :^)
This commit is contained in:
		
							parent
							
								
									517cf65c99
								
							
						
					
					
						commit
						8766e49a7c
					
				
					 5 changed files with 13 additions and 14 deletions
				
			
		|  | @ -59,7 +59,7 @@ | ||||||
| 
 | 
 | ||||||
| namespace Browser { | namespace Browser { | ||||||
| 
 | 
 | ||||||
| extern bool g_use_new_html_parser; | extern bool g_use_old_html_parser; | ||||||
| extern String g_home_url; | extern String g_home_url; | ||||||
| 
 | 
 | ||||||
| Tab::Tab() | Tab::Tab() | ||||||
|  | @ -71,7 +71,7 @@ Tab::Tab() | ||||||
|     auto& toolbar = m_toolbar_container->add<GUI::ToolBar>(); |     auto& toolbar = m_toolbar_container->add<GUI::ToolBar>(); | ||||||
|     m_page_view = widget.add<Web::PageView>(); |     m_page_view = widget.add<Web::PageView>(); | ||||||
| 
 | 
 | ||||||
|     m_page_view->set_use_new_parser(g_use_new_html_parser); |     m_page_view->set_use_old_parser(g_use_old_html_parser); | ||||||
| 
 | 
 | ||||||
|     m_go_back_action = GUI::CommonActions::make_go_back_action([this](auto&) { |     m_go_back_action = GUI::CommonActions::make_go_back_action([this](auto&) { | ||||||
|         m_history.go_back(); |         m_history.go_back(); | ||||||
|  |  | ||||||
|  | @ -45,7 +45,7 @@ namespace Browser { | ||||||
| 
 | 
 | ||||||
| static const char* bookmarks_filename = "/home/anon/bookmarks.json"; | static const char* bookmarks_filename = "/home/anon/bookmarks.json"; | ||||||
| String g_home_url; | String g_home_url; | ||||||
| bool g_use_new_html_parser = false; | bool g_use_old_html_parser = false; | ||||||
| 
 | 
 | ||||||
| } | } | ||||||
| 
 | 
 | ||||||
|  | @ -64,7 +64,7 @@ int main(int argc, char** argv) | ||||||
|     const char* specified_url = nullptr; |     const char* specified_url = nullptr; | ||||||
| 
 | 
 | ||||||
|     Core::ArgsParser args_parser; |     Core::ArgsParser args_parser; | ||||||
|     args_parser.add_option(Browser::g_use_new_html_parser, "Use new HTML parser", "new-parser", 'n'); |     args_parser.add_option(Browser::g_use_old_html_parser, "Use old HTML parser", "old-parser", 'O'); | ||||||
|     args_parser.add_positional_argument(specified_url, "URL to open", "url", Core::ArgsParser::Required::No); |     args_parser.add_positional_argument(specified_url, "URL to open", "url", Core::ArgsParser::Required::No); | ||||||
|     args_parser.parse(argc, argv); |     args_parser.parse(argc, argv); | ||||||
| 
 | 
 | ||||||
|  |  | ||||||
|  | @ -44,9 +44,9 @@ | ||||||
| #include <LibWeb/DOM/Text.h> | #include <LibWeb/DOM/Text.h> | ||||||
| #include <LibWeb/Dump.h> | #include <LibWeb/Dump.h> | ||||||
| #include <LibWeb/Frame.h> | #include <LibWeb/Frame.h> | ||||||
| #include <LibWeb/PageView.h> |  | ||||||
| #include <LibWeb/Layout/LayoutDocument.h> | #include <LibWeb/Layout/LayoutDocument.h> | ||||||
| #include <LibWeb/Layout/LayoutNode.h> | #include <LibWeb/Layout/LayoutNode.h> | ||||||
|  | #include <LibWeb/PageView.h> | ||||||
| #include <LibWeb/Parser/HTMLDocumentParser.h> | #include <LibWeb/Parser/HTMLDocumentParser.h> | ||||||
| #include <LibWeb/Parser/HTMLParser.h> | #include <LibWeb/Parser/HTMLParser.h> | ||||||
| #include <LibWeb/RenderingContext.h> | #include <LibWeb/RenderingContext.h> | ||||||
|  | @ -443,12 +443,11 @@ RefPtr<Document> PageView::create_document_from_mime_type(const ByteBuffer& data | ||||||
|     if (mime_type == "text/gemini") |     if (mime_type == "text/gemini") | ||||||
|         return create_gemini_document(data, url); |         return create_gemini_document(data, url); | ||||||
|     if (mime_type == "text/html") { |     if (mime_type == "text/html") { | ||||||
|         if (m_use_new_parser) { |         if (m_use_old_parser) | ||||||
|             HTMLDocumentParser parser(data, encoding); |             return parse_html_document(data, url, encoding); | ||||||
|             parser.run(url); |         HTMLDocumentParser parser(data, encoding); | ||||||
|             return parser.document(); |         parser.run(url); | ||||||
|         } |         return parser.document(); | ||||||
|         return parse_html_document(data, url, encoding); |  | ||||||
|     } |     } | ||||||
|     return nullptr; |     return nullptr; | ||||||
| } | } | ||||||
|  |  | ||||||
|  | @ -40,7 +40,7 @@ public: | ||||||
|     virtual ~PageView() override; |     virtual ~PageView() override; | ||||||
| 
 | 
 | ||||||
|     // FIXME: Remove this once the new parser is ready.
 |     // FIXME: Remove this once the new parser is ready.
 | ||||||
|     void set_use_new_parser(bool use_new_parser) { m_use_new_parser = use_new_parser; } |     void set_use_old_parser(bool use_old_parser) { m_use_old_parser = use_old_parser; } | ||||||
| 
 | 
 | ||||||
|     Document* document(); |     Document* document(); | ||||||
|     const Document* document() const; |     const Document* document() const; | ||||||
|  | @ -99,7 +99,7 @@ private: | ||||||
|     bool m_should_show_line_box_borders { false }; |     bool m_should_show_line_box_borders { false }; | ||||||
|     bool m_in_mouse_selection { false }; |     bool m_in_mouse_selection { false }; | ||||||
| 
 | 
 | ||||||
|     bool m_use_new_parser { false }; |     bool m_use_old_parser { false }; | ||||||
| }; | }; | ||||||
| 
 | 
 | ||||||
| } | } | ||||||
|  |  | ||||||
|  | @ -24,7 +24,7 @@ | ||||||
|  * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. |  * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. | ||||||
|  */ |  */ | ||||||
| 
 | 
 | ||||||
| #define PARSER_DEBUG | //#define PARSER_DEBUG
 | ||||||
| 
 | 
 | ||||||
| #include <AK/Utf32View.h> | #include <AK/Utf32View.h> | ||||||
| #include <LibWeb/DOM/Comment.h> | #include <LibWeb/DOM/Comment.h> | ||||||
|  |  | ||||||
		Loading…
	
	Add table
		Add a link
		
	
		Reference in a new issue
	
	 Andreas Kling
						Andreas Kling