mirror of
				https://github.com/RGBCube/serenity
				synced 2025-10-31 17:52:45 +00:00 
			
		
		
		
	LibWeb: Rename Web::HtmlView => Web::PageView
This widget doesn't just view HTML, it views a web page. :^)
This commit is contained in:
		
							parent
							
								
									5f8cbe6a1b
								
							
						
					
					
						commit
						42243d2e06
					
				
					 24 changed files with 133 additions and 133 deletions
				
			
		|  | @ -28,7 +28,7 @@ | ||||||
| #include <LibGUI/Widget.h> | #include <LibGUI/Widget.h> | ||||||
| #include <LibJS/Console.h> | #include <LibJS/Console.h> | ||||||
| #include <LibJS/Forward.h> | #include <LibJS/Forward.h> | ||||||
| #include <LibWeb/HtmlView.h> | #include <LibWeb/PageView.h> | ||||||
| 
 | 
 | ||||||
| namespace Browser { | namespace Browser { | ||||||
| 
 | 
 | ||||||
|  |  | ||||||
|  | @ -56,7 +56,7 @@ ConsoleWidget::ConsoleWidget() | ||||||
|     html_element->append_child(body_element); |     html_element->append_child(body_element); | ||||||
|     m_output_container = body_element; |     m_output_container = body_element; | ||||||
| 
 | 
 | ||||||
|     m_output_view = add<Web::HtmlView>(); |     m_output_view = add<Web::PageView>(); | ||||||
|     m_output_view->set_document(base_document); |     m_output_view->set_document(base_document); | ||||||
| 
 | 
 | ||||||
|     m_input = add<GUI::TextBox>(); |     m_input = add<GUI::TextBox>(); | ||||||
|  |  | ||||||
|  | @ -29,7 +29,7 @@ | ||||||
| #include "History.h" | #include "History.h" | ||||||
| #include <LibGUI/Widget.h> | #include <LibGUI/Widget.h> | ||||||
| #include <LibJS/Forward.h> | #include <LibJS/Forward.h> | ||||||
| #include <LibWeb/HtmlView.h> | #include <LibWeb/PageView.h> | ||||||
| 
 | 
 | ||||||
| namespace Browser { | namespace Browser { | ||||||
| 
 | 
 | ||||||
|  | @ -47,7 +47,7 @@ private: | ||||||
|     ConsoleWidget(); |     ConsoleWidget(); | ||||||
| 
 | 
 | ||||||
|     RefPtr<GUI::TextBox> m_input; |     RefPtr<GUI::TextBox> m_input; | ||||||
|     RefPtr<Web::HtmlView> m_output_view; |     RefPtr<Web::PageView> m_output_view; | ||||||
|     RefPtr<Web::Element> m_output_container; |     RefPtr<Web::Element> m_output_container; | ||||||
|     WeakPtr<JS::Interpreter> m_interpreter; |     WeakPtr<JS::Interpreter> m_interpreter; | ||||||
|     OwnPtr<BrowserConsoleClient> m_console_client; |     OwnPtr<BrowserConsoleClient> m_console_client; | ||||||
|  |  | ||||||
|  | @ -49,7 +49,7 @@ | ||||||
| #include <LibWeb/DOMTreeModel.h> | #include <LibWeb/DOMTreeModel.h> | ||||||
| #include <LibWeb/Dump.h> | #include <LibWeb/Dump.h> | ||||||
| #include <LibWeb/Frame.h> | #include <LibWeb/Frame.h> | ||||||
| #include <LibWeb/HtmlView.h> | #include <LibWeb/PageView.h> | ||||||
| #include <LibWeb/Layout/LayoutBlock.h> | #include <LibWeb/Layout/LayoutBlock.h> | ||||||
| #include <LibWeb/Layout/LayoutDocument.h> | #include <LibWeb/Layout/LayoutDocument.h> | ||||||
| #include <LibWeb/Layout/LayoutInline.h> | #include <LibWeb/Layout/LayoutInline.h> | ||||||
|  | @ -69,34 +69,34 @@ Tab::Tab() | ||||||
| 
 | 
 | ||||||
|     m_toolbar_container = widget.add<GUI::ToolBarContainer>(); |     m_toolbar_container = widget.add<GUI::ToolBarContainer>(); | ||||||
|     auto& toolbar = m_toolbar_container->add<GUI::ToolBar>(); |     auto& toolbar = m_toolbar_container->add<GUI::ToolBar>(); | ||||||
|     m_html_widget = widget.add<Web::HtmlView>(); |     m_page_view = widget.add<Web::PageView>(); | ||||||
| 
 | 
 | ||||||
|     m_html_widget->set_use_new_parser(g_use_new_html_parser); |     m_page_view->set_use_new_parser(g_use_new_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(); | ||||||
|         update_actions(); |         update_actions(); | ||||||
|         TemporaryChange<bool> change(m_should_push_loads_to_history, false); |         TemporaryChange<bool> change(m_should_push_loads_to_history, false); | ||||||
|         m_html_widget->load(m_history.current()); |         m_page_view->load(m_history.current()); | ||||||
|     }, this); |     }, this); | ||||||
| 
 | 
 | ||||||
|     m_go_forward_action = GUI::CommonActions::make_go_forward_action([this](auto&) { |     m_go_forward_action = GUI::CommonActions::make_go_forward_action([this](auto&) { | ||||||
|         m_history.go_forward(); |         m_history.go_forward(); | ||||||
|         update_actions(); |         update_actions(); | ||||||
|         TemporaryChange<bool> change(m_should_push_loads_to_history, false); |         TemporaryChange<bool> change(m_should_push_loads_to_history, false); | ||||||
|         m_html_widget->load(m_history.current()); |         m_page_view->load(m_history.current()); | ||||||
|     }, this); |     }, this); | ||||||
| 
 | 
 | ||||||
|     toolbar.add_action(*m_go_back_action); |     toolbar.add_action(*m_go_back_action); | ||||||
|     toolbar.add_action(*m_go_forward_action); |     toolbar.add_action(*m_go_forward_action); | ||||||
| 
 | 
 | ||||||
|     toolbar.add_action(GUI::CommonActions::make_go_home_action([this](auto&) { |     toolbar.add_action(GUI::CommonActions::make_go_home_action([this](auto&) { | ||||||
|         m_html_widget->load(g_home_url); |         m_page_view->load(g_home_url); | ||||||
|     }, this)); |     }, this)); | ||||||
| 
 | 
 | ||||||
|     m_reload_action = GUI::CommonActions::make_reload_action([this](auto&) { |     m_reload_action = GUI::CommonActions::make_reload_action([this](auto&) { | ||||||
|         TemporaryChange<bool> change(m_should_push_loads_to_history, false); |         TemporaryChange<bool> change(m_should_push_loads_to_history, false); | ||||||
|         m_html_widget->reload(); |         m_page_view->reload(); | ||||||
|     }, this); |     }, this); | ||||||
| 
 | 
 | ||||||
|     toolbar.add_action(*m_reload_action); |     toolbar.add_action(*m_reload_action); | ||||||
|  | @ -114,8 +114,8 @@ Tab::Tab() | ||||||
|             location = builder.build(); |             location = builder.build(); | ||||||
|         } |         } | ||||||
| 
 | 
 | ||||||
|         m_html_widget->load(location); |         m_page_view->load(location); | ||||||
|         m_html_widget->set_focus(true); |         m_page_view->set_focus(true); | ||||||
|     }; |     }; | ||||||
| 
 | 
 | ||||||
|     m_location_box->add_custom_context_menu_action(GUI::Action::create("Paste & Go", [this](auto&) { |     m_location_box->add_custom_context_menu_action(GUI::Action::create("Paste & Go", [this](auto&) { | ||||||
|  | @ -130,7 +130,7 @@ Tab::Tab() | ||||||
|     m_bookmark_button->set_preferred_size(22, 22); |     m_bookmark_button->set_preferred_size(22, 22); | ||||||
| 
 | 
 | ||||||
|     m_bookmark_button->on_click = [this](auto) { |     m_bookmark_button->on_click = [this](auto) { | ||||||
|         auto url = m_html_widget->main_frame().document()->url().to_string(); |         auto url = m_page_view->main_frame().document()->url().to_string(); | ||||||
|         if (BookmarksBarWidget::the().contains_bookmark(url)) { |         if (BookmarksBarWidget::the().contains_bookmark(url)) { | ||||||
|             BookmarksBarWidget::the().remove_bookmark(url); |             BookmarksBarWidget::the().remove_bookmark(url); | ||||||
|         } else { |         } else { | ||||||
|  | @ -139,7 +139,7 @@ Tab::Tab() | ||||||
|         update_bookmark_button(url); |         update_bookmark_button(url); | ||||||
|     }; |     }; | ||||||
| 
 | 
 | ||||||
|     m_html_widget->on_load_start = [this](auto& url) { |     m_page_view->on_load_start = [this](auto& url) { | ||||||
|         m_location_box->set_text(url.to_string()); |         m_location_box->set_text(url.to_string()); | ||||||
|         if (m_should_push_loads_to_history) |         if (m_should_push_loads_to_history) | ||||||
|             m_history.push(url); |             m_history.push(url); | ||||||
|  | @ -147,36 +147,36 @@ Tab::Tab() | ||||||
|         update_bookmark_button(url.to_string()); |         update_bookmark_button(url.to_string()); | ||||||
|     }; |     }; | ||||||
| 
 | 
 | ||||||
|     m_html_widget->on_link_click = [this](auto& href, auto& target, unsigned modifiers) { |     m_page_view->on_link_click = [this](auto& href, auto& target, unsigned modifiers) { | ||||||
|         if (target == "_blank" || modifiers == Mod_Ctrl) { |         if (target == "_blank" || modifiers == Mod_Ctrl) { | ||||||
|             auto url = m_html_widget->document()->complete_url(href); |             auto url = m_page_view->document()->complete_url(href); | ||||||
|             on_tab_open_request(url); |             on_tab_open_request(url); | ||||||
|         } else { |         } else { | ||||||
|             if (href.starts_with("#")) { |             if (href.starts_with("#")) { | ||||||
|                 auto anchor = href.substring_view(1, href.length() - 1); |                 auto anchor = href.substring_view(1, href.length() - 1); | ||||||
|                 m_html_widget->scroll_to_anchor(anchor); |                 m_page_view->scroll_to_anchor(anchor); | ||||||
|             } else { |             } else { | ||||||
|                 auto url = m_html_widget->document()->complete_url(href); |                 auto url = m_page_view->document()->complete_url(href); | ||||||
|                 m_html_widget->load(url); |                 m_page_view->load(url); | ||||||
|             } |             } | ||||||
|         } |         } | ||||||
|     }; |     }; | ||||||
| 
 | 
 | ||||||
|     m_link_context_menu = GUI::Menu::construct(); |     m_link_context_menu = GUI::Menu::construct(); | ||||||
|     m_link_context_menu->add_action(GUI::Action::create("Open", [this](auto&) { |     m_link_context_menu->add_action(GUI::Action::create("Open", [this](auto&) { | ||||||
|         m_html_widget->on_link_click(m_link_context_menu_href, "", 0); |         m_page_view->on_link_click(m_link_context_menu_href, "", 0); | ||||||
|     })); |     })); | ||||||
|     m_link_context_menu->add_action(GUI::Action::create("Open in new tab", [this](auto&) { |     m_link_context_menu->add_action(GUI::Action::create("Open in new tab", [this](auto&) { | ||||||
|         m_html_widget->on_link_click(m_link_context_menu_href, "_blank", 0); |         m_page_view->on_link_click(m_link_context_menu_href, "_blank", 0); | ||||||
|     })); |     })); | ||||||
|     m_link_context_menu->add_action(GUI::Action::create("Copy link", [this](auto&) { |     m_link_context_menu->add_action(GUI::Action::create("Copy link", [this](auto&) { | ||||||
|         GUI::Clipboard::the().set_data(m_html_widget->document()->complete_url(m_link_context_menu_href).to_string()); |         GUI::Clipboard::the().set_data(m_page_view->document()->complete_url(m_link_context_menu_href).to_string()); | ||||||
|     })); |     })); | ||||||
|     m_link_context_menu->add_separator(); |     m_link_context_menu->add_separator(); | ||||||
|     m_link_context_menu->add_action(GUI::Action::create("Download", [this](auto&) { |     m_link_context_menu->add_action(GUI::Action::create("Download", [this](auto&) { | ||||||
|         auto window = GUI::Window::construct(); |         auto window = GUI::Window::construct(); | ||||||
|         window->set_rect(300, 300, 300, 150); |         window->set_rect(300, 300, 300, 150); | ||||||
|         auto url = m_html_widget->document()->complete_url(m_link_context_menu_href); |         auto url = m_page_view->document()->complete_url(m_link_context_menu_href); | ||||||
|         window->set_title(String::format("0%% of %s", url.basename().characters())); |         window->set_title(String::format("0%% of %s", url.basename().characters())); | ||||||
|         window->set_resizable(false); |         window->set_resizable(false); | ||||||
|         window->set_main_widget<DownloadWidget>(url); |         window->set_main_widget<DownloadWidget>(url); | ||||||
|  | @ -184,18 +184,18 @@ Tab::Tab() | ||||||
|         (void)window.leak_ref(); |         (void)window.leak_ref(); | ||||||
|     })); |     })); | ||||||
| 
 | 
 | ||||||
|     m_html_widget->on_link_context_menu_request = [this](auto& href, auto& screen_position) { |     m_page_view->on_link_context_menu_request = [this](auto& href, auto& screen_position) { | ||||||
|         m_link_context_menu_href = href; |         m_link_context_menu_href = href; | ||||||
|         m_link_context_menu->popup(screen_position); |         m_link_context_menu->popup(screen_position); | ||||||
|     }; |     }; | ||||||
| 
 | 
 | ||||||
|     m_html_widget->on_link_middle_click = [this](auto& href) { |     m_page_view->on_link_middle_click = [this](auto& href) { | ||||||
|         m_html_widget->on_link_click(href, "_blank", 0); |         m_page_view->on_link_click(href, "_blank", 0); | ||||||
|     }; |     }; | ||||||
| 
 | 
 | ||||||
|     m_html_widget->on_title_change = [this](auto& title) { |     m_page_view->on_title_change = [this](auto& title) { | ||||||
|         if (title.is_null()) { |         if (title.is_null()) { | ||||||
|             m_title = m_html_widget->main_frame().document()->url().to_string(); |             m_title = m_page_view->main_frame().document()->url().to_string(); | ||||||
|         } else { |         } else { | ||||||
|             m_title = title; |             m_title = title; | ||||||
|         } |         } | ||||||
|  | @ -203,13 +203,13 @@ Tab::Tab() | ||||||
|             on_title_change(m_title); |             on_title_change(m_title); | ||||||
|     }; |     }; | ||||||
| 
 | 
 | ||||||
|     m_html_widget->on_favicon_change = [this](auto& icon) { |     m_page_view->on_favicon_change = [this](auto& icon) { | ||||||
|         m_icon = icon; |         m_icon = icon; | ||||||
|         if (on_favicon_change) |         if (on_favicon_change) | ||||||
|             on_favicon_change(icon); |             on_favicon_change(icon); | ||||||
|     }; |     }; | ||||||
| 
 | 
 | ||||||
|     m_html_widget->on_set_document = [this](auto* document) { |     m_page_view->on_set_document = [this](auto* document) { | ||||||
|         if (document && m_console_window) { |         if (document && m_console_window) { | ||||||
|             auto* console_widget = static_cast<ConsoleWidget*>(m_console_window->main_widget()); |             auto* console_widget = static_cast<ConsoleWidget*>(m_console_window->main_widget()); | ||||||
|             console_widget->set_interpreter(document->interpreter().make_weak_ptr()); |             console_widget->set_interpreter(document->interpreter().make_weak_ptr()); | ||||||
|  | @ -225,12 +225,12 @@ Tab::Tab() | ||||||
| 
 | 
 | ||||||
|     m_statusbar = widget.add<GUI::StatusBar>(); |     m_statusbar = widget.add<GUI::StatusBar>(); | ||||||
| 
 | 
 | ||||||
|     m_html_widget->on_link_hover = [this](auto& href) { |     m_page_view->on_link_hover = [this](auto& href) { | ||||||
|         m_statusbar->set_text(href); |         m_statusbar->set_text(href); | ||||||
|     }; |     }; | ||||||
| 
 | 
 | ||||||
|     m_html_widget->on_url_drop = [this](auto& url) { |     m_page_view->on_url_drop = [this](auto& url) { | ||||||
|         m_html_widget->load(url); |         m_page_view->load(url); | ||||||
|     }; |     }; | ||||||
| 
 | 
 | ||||||
|     m_menubar = GUI::MenuBar::construct(); |     m_menubar = GUI::MenuBar::construct(); | ||||||
|  | @ -265,9 +265,9 @@ Tab::Tab() | ||||||
|     auto& inspect_menu = m_menubar->add_menu("Inspect"); |     auto& inspect_menu = m_menubar->add_menu("Inspect"); | ||||||
|     inspect_menu.add_action(GUI::Action::create( |     inspect_menu.add_action(GUI::Action::create( | ||||||
|         "View source", { Mod_Ctrl, Key_U }, [this](auto&) { |         "View source", { Mod_Ctrl, Key_U }, [this](auto&) { | ||||||
|             ASSERT(m_html_widget->document()); |             ASSERT(m_page_view->document()); | ||||||
|             auto url = m_html_widget->document()->url().to_string(); |             auto url = m_page_view->document()->url().to_string(); | ||||||
|             auto source = m_html_widget->document()->source(); |             auto source = m_page_view->document()->source(); | ||||||
|             auto window = GUI::Window::construct(); |             auto window = GUI::Window::construct(); | ||||||
|             auto& editor = window->set_main_widget<GUI::TextEditor>(); |             auto& editor = window->set_main_widget<GUI::TextEditor>(); | ||||||
|             editor.set_text(source); |             editor.set_text(source); | ||||||
|  | @ -288,7 +288,7 @@ Tab::Tab() | ||||||
|                 m_dom_inspector_window->set_main_widget<InspectorWidget>(); |                 m_dom_inspector_window->set_main_widget<InspectorWidget>(); | ||||||
|             } |             } | ||||||
|             auto* inspector_widget = static_cast<InspectorWidget*>(m_dom_inspector_window->main_widget()); |             auto* inspector_widget = static_cast<InspectorWidget*>(m_dom_inspector_window->main_widget()); | ||||||
|             inspector_widget->set_document(m_html_widget->document()); |             inspector_widget->set_document(m_page_view->document()); | ||||||
|             m_dom_inspector_window->show(); |             m_dom_inspector_window->show(); | ||||||
|             m_dom_inspector_window->move_to_front(); |             m_dom_inspector_window->move_to_front(); | ||||||
|         }, |         }, | ||||||
|  | @ -303,7 +303,7 @@ Tab::Tab() | ||||||
|                 m_console_window->set_main_widget<ConsoleWidget>(); |                 m_console_window->set_main_widget<ConsoleWidget>(); | ||||||
|             } |             } | ||||||
|             auto* console_widget = static_cast<ConsoleWidget*>(m_console_window->main_widget()); |             auto* console_widget = static_cast<ConsoleWidget*>(m_console_window->main_widget()); | ||||||
|             console_widget->set_interpreter(m_html_widget->document()->interpreter().make_weak_ptr()); |             console_widget->set_interpreter(m_page_view->document()->interpreter().make_weak_ptr()); | ||||||
|             m_console_window->show(); |             m_console_window->show(); | ||||||
|             m_console_window->move_to_front(); |             m_console_window->move_to_front(); | ||||||
|         }, |         }, | ||||||
|  | @ -312,17 +312,17 @@ Tab::Tab() | ||||||
|     auto& debug_menu = m_menubar->add_menu("Debug"); |     auto& debug_menu = m_menubar->add_menu("Debug"); | ||||||
|     debug_menu.add_action(GUI::Action::create( |     debug_menu.add_action(GUI::Action::create( | ||||||
|         "Dump DOM tree", [this](auto&) { |         "Dump DOM tree", [this](auto&) { | ||||||
|             Web::dump_tree(*m_html_widget->document()); |             Web::dump_tree(*m_page_view->document()); | ||||||
|         }, |         }, | ||||||
|         this)); |         this)); | ||||||
|     debug_menu.add_action(GUI::Action::create( |     debug_menu.add_action(GUI::Action::create( | ||||||
|         "Dump Layout tree", [this](auto&) { |         "Dump Layout tree", [this](auto&) { | ||||||
|             Web::dump_tree(*m_html_widget->document()->layout_node()); |             Web::dump_tree(*m_page_view->document()->layout_node()); | ||||||
|         }, |         }, | ||||||
|         this)); |         this)); | ||||||
|     debug_menu.add_action(GUI::Action::create( |     debug_menu.add_action(GUI::Action::create( | ||||||
|         "Dump Style sheets", [this](auto&) { |         "Dump Style sheets", [this](auto&) { | ||||||
|             for (auto& sheet : m_html_widget->document()->stylesheets()) { |             for (auto& sheet : m_page_view->document()->stylesheets()) { | ||||||
|                 dump_sheet(sheet); |                 dump_sheet(sheet); | ||||||
|             } |             } | ||||||
|         }, |         }, | ||||||
|  | @ -330,8 +330,8 @@ Tab::Tab() | ||||||
|     debug_menu.add_separator(); |     debug_menu.add_separator(); | ||||||
|     auto line_box_borders_action = GUI::Action::create_checkable( |     auto line_box_borders_action = GUI::Action::create_checkable( | ||||||
|         "Line box borders", [this](auto& action) { |         "Line box borders", [this](auto& action) { | ||||||
|             m_html_widget->set_should_show_line_box_borders(action.is_checked()); |             m_page_view->set_should_show_line_box_borders(action.is_checked()); | ||||||
|             m_html_widget->update(); |             m_page_view->update(); | ||||||
|         }, |         }, | ||||||
|         this); |         this); | ||||||
|     line_box_borders_action->set_checked(false); |     line_box_borders_action->set_checked(false); | ||||||
|  | @ -358,7 +358,7 @@ Tab::~Tab() | ||||||
| 
 | 
 | ||||||
| void Tab::load(const URL& url) | void Tab::load(const URL& url) | ||||||
| { | { | ||||||
|     m_html_widget->load(url); |     m_page_view->load(url); | ||||||
| } | } | ||||||
| 
 | 
 | ||||||
| void Tab::update_actions() | void Tab::update_actions() | ||||||
|  | @ -392,7 +392,7 @@ void Tab::did_become_active() | ||||||
|         if (modifiers & Mod_Ctrl) |         if (modifiers & Mod_Ctrl) | ||||||
|             on_tab_open_request(url); |             on_tab_open_request(url); | ||||||
|         else |         else | ||||||
|             m_html_widget->load(url); |             m_page_view->load(url); | ||||||
|     }; |     }; | ||||||
| 
 | 
 | ||||||
|     BookmarksBarWidget::the().on_bookmark_hover = [this](auto&, auto& url) { |     BookmarksBarWidget::the().on_bookmark_hover = [this](auto&, auto& url) { | ||||||
|  |  | ||||||
|  | @ -60,7 +60,7 @@ private: | ||||||
|     void update_bookmark_button(const String& url); |     void update_bookmark_button(const String& url); | ||||||
| 
 | 
 | ||||||
|     History<URL> m_history; |     History<URL> m_history; | ||||||
|     RefPtr<Web::HtmlView> m_html_widget; |     RefPtr<Web::PageView> m_page_view; | ||||||
|     RefPtr<GUI::Action> m_go_back_action; |     RefPtr<GUI::Action> m_go_back_action; | ||||||
|     RefPtr<GUI::Action> m_go_forward_action; |     RefPtr<GUI::Action> m_go_forward_action; | ||||||
|     RefPtr<GUI::Action> m_reload_action; |     RefPtr<GUI::Action> m_reload_action; | ||||||
|  |  | ||||||
|  | @ -42,7 +42,7 @@ | ||||||
| #include <LibGUI/TreeView.h> | #include <LibGUI/TreeView.h> | ||||||
| #include <LibGUI/Window.h> | #include <LibGUI/Window.h> | ||||||
| #include <LibMarkdown/Document.h> | #include <LibMarkdown/Document.h> | ||||||
| #include <LibWeb/HtmlView.h> | #include <LibWeb/PageView.h> | ||||||
| #include <LibWeb/Layout/LayoutNode.h> | #include <LibWeb/Layout/LayoutNode.h> | ||||||
| #include <LibWeb/Parser/CSSParser.h> | #include <LibWeb/Parser/CSSParser.h> | ||||||
| #include <LibWeb/Parser/HTMLParser.h> | #include <LibWeb/Parser/HTMLParser.h> | ||||||
|  | @ -97,7 +97,7 @@ int main(int argc, char* argv[]) | ||||||
|     tree_view.set_size_policy(GUI::SizePolicy::Fixed, GUI::SizePolicy::Fill); |     tree_view.set_size_policy(GUI::SizePolicy::Fixed, GUI::SizePolicy::Fill); | ||||||
|     tree_view.set_preferred_size(200, 500); |     tree_view.set_preferred_size(200, 500); | ||||||
| 
 | 
 | ||||||
|     auto& html_view = splitter.add<Web::HtmlView>(); |     auto& page_view = splitter.add<Web::PageView>(); | ||||||
| 
 | 
 | ||||||
|     History history; |     History history; | ||||||
| 
 | 
 | ||||||
|  | @ -111,7 +111,7 @@ int main(int argc, char* argv[]) | ||||||
| 
 | 
 | ||||||
|     auto open_page = [&](const String& path) { |     auto open_page = [&](const String& path) { | ||||||
|         if (path.is_null()) { |         if (path.is_null()) { | ||||||
|             html_view.set_document(nullptr); |             page_view.set_document(nullptr); | ||||||
|             return; |             return; | ||||||
|         } |         } | ||||||
| 
 | 
 | ||||||
|  | @ -134,7 +134,7 @@ int main(int argc, char* argv[]) | ||||||
| 
 | 
 | ||||||
|         String html = md_document.render_to_html(); |         String html = md_document.render_to_html(); | ||||||
|         auto html_document = Web::parse_html_document(html); |         auto html_document = Web::parse_html_document(html); | ||||||
|         html_view.set_document(html_document); |         page_view.set_document(html_document); | ||||||
| 
 | 
 | ||||||
|         String page_and_section = model->page_and_section(tree_view.selection().first()); |         String page_and_section = model->page_and_section(tree_view.selection().first()); | ||||||
|         window->set_title(String::format("%s - Help", page_and_section.characters())); |         window->set_title(String::format("%s - Help", page_and_section.characters())); | ||||||
|  | @ -143,7 +143,7 @@ int main(int argc, char* argv[]) | ||||||
|     tree_view.on_selection_change = [&] { |     tree_view.on_selection_change = [&] { | ||||||
|         String path = model->page_path(tree_view.selection().first()); |         String path = model->page_path(tree_view.selection().first()); | ||||||
|         if (path.is_null()) { |         if (path.is_null()) { | ||||||
|             html_view.set_document(nullptr); |             page_view.set_document(nullptr); | ||||||
|             return; |             return; | ||||||
|         } |         } | ||||||
|         history.push(path); |         history.push(path); | ||||||
|  | @ -151,7 +151,7 @@ int main(int argc, char* argv[]) | ||||||
|         open_page(path); |         open_page(path); | ||||||
|     }; |     }; | ||||||
| 
 | 
 | ||||||
|     html_view.on_link_click = [&](const String& href, auto&, unsigned) { |     page_view.on_link_click = [&](const String& href, auto&, unsigned) { | ||||||
|         char* current_path = strdup(history.current().characters()); |         char* current_path = strdup(history.current().characters()); | ||||||
|         char* dir_path = dirname(current_path); |         char* dir_path = dirname(current_path); | ||||||
|         char* path = realpath(String::format("%s/%s", dir_path, href.characters()).characters(), nullptr); |         char* path = realpath(String::format("%s/%s", dir_path, href.characters()).characters(), nullptr); | ||||||
|  |  | ||||||
|  | @ -39,7 +39,7 @@ | ||||||
| #include <LibGUI/TextBox.h> | #include <LibGUI/TextBox.h> | ||||||
| #include <LibGUI/TextEditor.h> | #include <LibGUI/TextEditor.h> | ||||||
| #include <LibGUI/Window.h> | #include <LibGUI/Window.h> | ||||||
| #include <LibWeb/HtmlView.h> | #include <LibWeb/PageView.h> | ||||||
| 
 | 
 | ||||||
| IRCWindow::IRCWindow(IRCClient& client, void* owner, Type type, const String& name) | IRCWindow::IRCWindow(IRCClient& client, void* owner, Type type, const String& name) | ||||||
|     : m_client(client) |     : m_client(client) | ||||||
|  | @ -52,7 +52,7 @@ IRCWindow::IRCWindow(IRCClient& client, void* owner, Type type, const String& na | ||||||
|     // Make a container for the log buffer view + (optional) member list.
 |     // Make a container for the log buffer view + (optional) member list.
 | ||||||
|     auto& container = add<GUI::HorizontalSplitter>(); |     auto& container = add<GUI::HorizontalSplitter>(); | ||||||
| 
 | 
 | ||||||
|     m_html_view = container.add<Web::HtmlView>(); |     m_page_view = container.add<Web::PageView>(); | ||||||
| 
 | 
 | ||||||
|     if (m_type == Channel) { |     if (m_type == Channel) { | ||||||
|         auto& member_view = container.add<GUI::TableView>(); |         auto& member_view = container.add<GUI::TableView>(); | ||||||
|  | @ -215,7 +215,7 @@ IRCWindow::~IRCWindow() | ||||||
| void IRCWindow::set_log_buffer(const IRCLogBuffer& log_buffer) | void IRCWindow::set_log_buffer(const IRCLogBuffer& log_buffer) | ||||||
| { | { | ||||||
|     m_log_buffer = &log_buffer; |     m_log_buffer = &log_buffer; | ||||||
|     m_html_view->set_document(const_cast<Web::Document*>(&log_buffer.document())); |     m_page_view->set_document(const_cast<Web::Document*>(&log_buffer.document())); | ||||||
| } | } | ||||||
| 
 | 
 | ||||||
| bool IRCWindow::is_active() const | bool IRCWindow::is_active() const | ||||||
|  | @ -263,7 +263,7 @@ void IRCWindow::did_add_message(const String& name, const String& message) | ||||||
|         m_client.aid_update_window_list(); |         m_client.aid_update_window_list(); | ||||||
|         return; |         return; | ||||||
|     } |     } | ||||||
|     m_html_view->scroll_to_bottom(); |     m_page_view->scroll_to_bottom(); | ||||||
| } | } | ||||||
| 
 | 
 | ||||||
| void IRCWindow::clear_unread_count() | void IRCWindow::clear_unread_count() | ||||||
|  |  | ||||||
|  | @ -74,7 +74,7 @@ private: | ||||||
|     void* m_owner { nullptr }; |     void* m_owner { nullptr }; | ||||||
|     Type m_type; |     Type m_type; | ||||||
|     String m_name; |     String m_name; | ||||||
|     RefPtr<Web::HtmlView> m_html_view; |     RefPtr<Web::PageView> m_page_view; | ||||||
|     RefPtr<GUI::TextBox> m_text_box; |     RefPtr<GUI::TextBox> m_text_box; | ||||||
|     RefPtr<IRCLogBuffer> m_log_buffer; |     RefPtr<IRCLogBuffer> m_log_buffer; | ||||||
|     RefPtr<GUI::Menu> m_context_menu; |     RefPtr<GUI::Menu> m_context_menu; | ||||||
|  |  | ||||||
|  | @ -51,7 +51,7 @@ | ||||||
| #include <LibGUI/ToolBarContainer.h> | #include <LibGUI/ToolBarContainer.h> | ||||||
| #include <LibGfx/Font.h> | #include <LibGfx/Font.h> | ||||||
| #include <LibMarkdown/Document.h> | #include <LibMarkdown/Document.h> | ||||||
| #include <LibWeb/HtmlView.h> | #include <LibWeb/PageView.h> | ||||||
| #include <LibWeb/Parser/HTMLParser.h> | #include <LibWeb/Parser/HTMLParser.h> | ||||||
| #include <string.h> | #include <string.h> | ||||||
| 
 | 
 | ||||||
|  | @ -87,8 +87,8 @@ TextEditorWidget::TextEditorWidget() | ||||||
|             update_title(); |             update_title(); | ||||||
|     }; |     }; | ||||||
| 
 | 
 | ||||||
|     m_html_view = splitter.add<Web::HtmlView>(); |     m_page_view = splitter.add<Web::PageView>(); | ||||||
|     m_html_view->set_visible(false); |     m_page_view->set_visible(false); | ||||||
| 
 | 
 | ||||||
|     m_find_replace_widget = add<GUI::Widget>(); |     m_find_replace_widget = add<GUI::Widget>(); | ||||||
|     m_find_replace_widget->set_fill_with_background_color(true); |     m_find_replace_widget->set_fill_with_background_color(true); | ||||||
|  | @ -553,7 +553,7 @@ void TextEditorWidget::set_markdown_preview_enabled(bool enabled) | ||||||
|         return; |         return; | ||||||
|     m_markdown_preview_enabled = enabled; |     m_markdown_preview_enabled = enabled; | ||||||
|     m_markdown_preview_action->set_checked(enabled); |     m_markdown_preview_action->set_checked(enabled); | ||||||
|     m_html_view->set_visible(enabled); |     m_page_view->set_visible(enabled); | ||||||
|     if (enabled) |     if (enabled) | ||||||
|         update_markdown_preview(); |         update_markdown_preview(); | ||||||
| } | } | ||||||
|  | @ -564,6 +564,6 @@ void TextEditorWidget::update_markdown_preview() | ||||||
|     if (document.parse(m_editor->text())) { |     if (document.parse(m_editor->text())) { | ||||||
|         auto html = document.render_to_html(); |         auto html = document.render_to_html(); | ||||||
|         auto html_document = Web::parse_html_document(html, URL::create_with_file_protocol(m_path)); |         auto html_document = Web::parse_html_document(html, URL::create_with_file_protocol(m_path)); | ||||||
|         m_html_view->set_document(html_document); |         m_page_view->set_document(html_document); | ||||||
|     } |     } | ||||||
| } | } | ||||||
|  |  | ||||||
|  | @ -90,7 +90,7 @@ private: | ||||||
|     RefPtr<GUI::Action> m_js_highlight; |     RefPtr<GUI::Action> m_js_highlight; | ||||||
|     RefPtr<GUI::Action> m_ini_highlight; |     RefPtr<GUI::Action> m_ini_highlight; | ||||||
| 
 | 
 | ||||||
|     RefPtr<Web::HtmlView> m_html_view; |     RefPtr<Web::PageView> m_page_view; | ||||||
| 
 | 
 | ||||||
|     bool m_document_dirty { false }; |     bool m_document_dirty { false }; | ||||||
|     bool m_document_opening { false }; |     bool m_document_opening { false }; | ||||||
|  |  | ||||||
|  | @ -40,7 +40,7 @@ | ||||||
| #include <LibWeb/DOM/ElementFactory.h> | #include <LibWeb/DOM/ElementFactory.h> | ||||||
| #include <LibWeb/DOM/HTMLHeadElement.h> | #include <LibWeb/DOM/HTMLHeadElement.h> | ||||||
| #include <LibWeb/DOM/Text.h> | #include <LibWeb/DOM/Text.h> | ||||||
| #include <LibWeb/HtmlView.h> | #include <LibWeb/PageView.h> | ||||||
| #include <LibWeb/Parser/HTMLParser.h> | #include <LibWeb/Parser/HTMLParser.h> | ||||||
| 
 | 
 | ||||||
| // #define EDITOR_DEBUG
 | // #define EDITOR_DEBUG
 | ||||||
|  | @ -50,7 +50,7 @@ Editor::Editor() | ||||||
|     m_documentation_tooltip_window = GUI::Window::construct(); |     m_documentation_tooltip_window = GUI::Window::construct(); | ||||||
|     m_documentation_tooltip_window->set_rect(0, 0, 500, 400); |     m_documentation_tooltip_window->set_rect(0, 0, 500, 400); | ||||||
|     m_documentation_tooltip_window->set_window_type(GUI::WindowType::Tooltip); |     m_documentation_tooltip_window->set_window_type(GUI::WindowType::Tooltip); | ||||||
|     m_documentation_html_view = m_documentation_tooltip_window->set_main_widget<Web::HtmlView>(); |     m_documentation_page_view = m_documentation_tooltip_window->set_main_widget<Web::PageView>(); | ||||||
| } | } | ||||||
| 
 | 
 | ||||||
| Editor::~Editor() | Editor::~Editor() | ||||||
|  | @ -194,7 +194,7 @@ void Editor::show_documentation_tooltip_if_available(const String& hovered_token | ||||||
|     ASSERT(head_element); |     ASSERT(head_element); | ||||||
|     head_element->append_child(style_element); |     head_element->append_child(style_element); | ||||||
| 
 | 
 | ||||||
|     m_documentation_html_view->set_document(html_document); |     m_documentation_page_view->set_document(html_document); | ||||||
|     m_documentation_tooltip_window->move_to(screen_location.translated(4, 4)); |     m_documentation_tooltip_window->move_to(screen_location.translated(4, 4)); | ||||||
|     m_documentation_tooltip_window->show(); |     m_documentation_tooltip_window->show(); | ||||||
| 
 | 
 | ||||||
|  |  | ||||||
|  | @ -71,7 +71,7 @@ private: | ||||||
|     explicit Editor(); |     explicit Editor(); | ||||||
| 
 | 
 | ||||||
|     RefPtr<GUI::Window> m_documentation_tooltip_window; |     RefPtr<GUI::Window> m_documentation_tooltip_window; | ||||||
|     RefPtr<Web::HtmlView> m_documentation_html_view; |     RefPtr<Web::PageView> m_documentation_page_view; | ||||||
|     String m_last_parsed_token; |     String m_last_parsed_token; | ||||||
|     GUI::TextPosition m_previous_text_position { 0, 0 }; |     GUI::TextPosition m_previous_text_position { 0, 0 }; | ||||||
|     bool m_hovering_editor { false }; |     bool m_hovering_editor { false }; | ||||||
|  |  | ||||||
|  | @ -57,13 +57,12 @@ set(SOURCES | ||||||
|     DOM/Node.cpp |     DOM/Node.cpp | ||||||
|     DOM/ParentNode.cpp |     DOM/ParentNode.cpp | ||||||
|     DOM/Text.cpp |     DOM/Text.cpp | ||||||
|     DOMTreeModel.cpp |  | ||||||
|     DOM/Window.cpp |     DOM/Window.cpp | ||||||
|     DOM/XMLHttpRequest.cpp |     DOM/XMLHttpRequest.cpp | ||||||
|  |     DOMTreeModel.cpp | ||||||
|     Dump.cpp |     Dump.cpp | ||||||
|     FontCache.cpp |     FontCache.cpp | ||||||
|     Frame.cpp |     Frame.cpp | ||||||
|     HtmlView.cpp |  | ||||||
|     Layout/BoxModelMetrics.cpp |     Layout/BoxModelMetrics.cpp | ||||||
|     Layout/LayoutBlock.cpp |     Layout/LayoutBlock.cpp | ||||||
|     Layout/LayoutBox.cpp |     Layout/LayoutBox.cpp | ||||||
|  | @ -76,14 +75,15 @@ set(SOURCES | ||||||
|     Layout/LayoutListItemMarker.cpp |     Layout/LayoutListItemMarker.cpp | ||||||
|     Layout/LayoutNode.cpp |     Layout/LayoutNode.cpp | ||||||
|     Layout/LayoutReplaced.cpp |     Layout/LayoutReplaced.cpp | ||||||
|     Layout/LayoutTableCell.cpp |  | ||||||
|     Layout/LayoutTable.cpp |     Layout/LayoutTable.cpp | ||||||
|  |     Layout/LayoutTableCell.cpp | ||||||
|     Layout/LayoutTableRow.cpp |     Layout/LayoutTableRow.cpp | ||||||
|     Layout/LayoutText.cpp |     Layout/LayoutText.cpp | ||||||
|     Layout/LayoutTreeBuilder.cpp |     Layout/LayoutTreeBuilder.cpp | ||||||
|     Layout/LayoutWidget.cpp |     Layout/LayoutWidget.cpp | ||||||
|     Layout/LineBox.cpp |     Layout/LineBox.cpp | ||||||
|     Layout/LineBoxFragment.cpp |     Layout/LineBoxFragment.cpp | ||||||
|  |     PageView.cpp | ||||||
|     Parser/CSSParser.cpp |     Parser/CSSParser.cpp | ||||||
|     Parser/Entities.cpp |     Parser/Entities.cpp | ||||||
|     Parser/HTMLDocumentParser.cpp |     Parser/HTMLDocumentParser.cpp | ||||||
|  |  | ||||||
|  | @ -31,7 +31,7 @@ | ||||||
| #include <LibWeb/CSS/StyleValue.h> | #include <LibWeb/CSS/StyleValue.h> | ||||||
| #include <LibWeb/DOM/Document.h> | #include <LibWeb/DOM/Document.h> | ||||||
| #include <LibWeb/Frame.h> | #include <LibWeb/Frame.h> | ||||||
| #include <LibWeb/HtmlView.h> | #include <LibWeb/PageView.h> | ||||||
| #include <LibWeb/ResourceLoader.h> | #include <LibWeb/ResourceLoader.h> | ||||||
| 
 | 
 | ||||||
| namespace Web { | namespace Web { | ||||||
|  | @ -170,7 +170,7 @@ Color IdentifierStyleValue::to_color(const Document& document) const | ||||||
|     if (id() == CSS::ValueID::VendorSpecificLink) |     if (id() == CSS::ValueID::VendorSpecificLink) | ||||||
|         return document.link_color(); |         return document.link_color(); | ||||||
| 
 | 
 | ||||||
|     auto palette = document.frame()->html_view()->palette(); |     auto palette = document.frame()->page_view()->palette(); | ||||||
|     switch (id()) { |     switch (id()) { | ||||||
|     case CSS::ValueID::VendorSpecificPaletteDesktopBackground: |     case CSS::ValueID::VendorSpecificPaletteDesktopBackground: | ||||||
|         return palette.color(ColorRole::DesktopBackground); |         return palette.color(ColorRole::DesktopBackground); | ||||||
|  |  | ||||||
|  | @ -51,7 +51,7 @@ | ||||||
| #include <LibWeb/DOM/Window.h> | #include <LibWeb/DOM/Window.h> | ||||||
| #include <LibWeb/Dump.h> | #include <LibWeb/Dump.h> | ||||||
| #include <LibWeb/Frame.h> | #include <LibWeb/Frame.h> | ||||||
| #include <LibWeb/HtmlView.h> | #include <LibWeb/PageView.h> | ||||||
| #include <LibWeb/Layout/LayoutDocument.h> | #include <LibWeb/Layout/LayoutDocument.h> | ||||||
| #include <LibWeb/Layout/LayoutTreeBuilder.h> | #include <LibWeb/Layout/LayoutTreeBuilder.h> | ||||||
| #include <LibWeb/Origin.h> | #include <LibWeb/Origin.h> | ||||||
|  | @ -368,7 +368,7 @@ Color Document::link_color() const | ||||||
|         return m_link_color.value(); |         return m_link_color.value(); | ||||||
|     if (!frame()) |     if (!frame()) | ||||||
|         return Color::Blue; |         return Color::Blue; | ||||||
|     return frame()->html_view()->palette().link(); |     return frame()->page_view()->palette().link(); | ||||||
| } | } | ||||||
| 
 | 
 | ||||||
| Color Document::active_link_color() const | Color Document::active_link_color() const | ||||||
|  | @ -377,7 +377,7 @@ Color Document::active_link_color() const | ||||||
|         return m_active_link_color.value(); |         return m_active_link_color.value(); | ||||||
|     if (!frame()) |     if (!frame()) | ||||||
|         return Color::Red; |         return Color::Red; | ||||||
|     return frame()->html_view()->palette().active_link(); |     return frame()->page_view()->palette().active_link(); | ||||||
| } | } | ||||||
| 
 | 
 | ||||||
| Color Document::visited_link_color() const | Color Document::visited_link_color() const | ||||||
|  | @ -386,7 +386,7 @@ Color Document::visited_link_color() const | ||||||
|         return m_visited_link_color.value(); |         return m_visited_link_color.value(); | ||||||
|     if (!frame()) |     if (!frame()) | ||||||
|         return Color::Magenta; |         return Color::Magenta; | ||||||
|     return frame()->html_view()->palette().visited_link(); |     return frame()->page_view()->palette().visited_link(); | ||||||
| } | } | ||||||
| 
 | 
 | ||||||
| JS::Interpreter& Document::interpreter() | JS::Interpreter& Document::interpreter() | ||||||
|  |  | ||||||
|  | @ -28,7 +28,7 @@ | ||||||
| #include <LibWeb/DOM/HTMLFormElement.h> | #include <LibWeb/DOM/HTMLFormElement.h> | ||||||
| #include <LibWeb/DOM/HTMLInputElement.h> | #include <LibWeb/DOM/HTMLInputElement.h> | ||||||
| #include <LibWeb/Frame.h> | #include <LibWeb/Frame.h> | ||||||
| #include <LibWeb/HtmlView.h> | #include <LibWeb/PageView.h> | ||||||
| #include <LibWeb/URLEncoder.h> | #include <LibWeb/URLEncoder.h> | ||||||
| 
 | 
 | ||||||
| namespace Web { | namespace Web { | ||||||
|  | @ -72,7 +72,7 @@ void HTMLFormElement::submit(RefPtr<HTMLInputElement> submitter) | ||||||
|     url.set_query(url_encode(parameters)); |     url.set_query(url_encode(parameters)); | ||||||
| 
 | 
 | ||||||
|     // FIXME: We shouldn't let the form just do this willy-nilly.
 |     // FIXME: We shouldn't let the form just do this willy-nilly.
 | ||||||
|     document().frame()->html_view()->load(url); |     document().frame()->page_view()->load(url); | ||||||
| } | } | ||||||
| 
 | 
 | ||||||
| } | } | ||||||
|  |  | ||||||
|  | @ -31,7 +31,7 @@ | ||||||
| #include <LibWeb/DOM/HTMLFormElement.h> | #include <LibWeb/DOM/HTMLFormElement.h> | ||||||
| #include <LibWeb/DOM/HTMLInputElement.h> | #include <LibWeb/DOM/HTMLInputElement.h> | ||||||
| #include <LibWeb/Frame.h> | #include <LibWeb/Frame.h> | ||||||
| #include <LibWeb/HtmlView.h> | #include <LibWeb/PageView.h> | ||||||
| #include <LibWeb/Layout/LayoutWidget.h> | #include <LibWeb/Layout/LayoutWidget.h> | ||||||
| 
 | 
 | ||||||
| namespace Web { | namespace Web { | ||||||
|  | @ -49,15 +49,15 @@ RefPtr<LayoutNode> HTMLInputElement::create_layout_node(const StyleProperties*) | ||||||
| { | { | ||||||
|     ASSERT(document().frame()); |     ASSERT(document().frame()); | ||||||
|     auto& frame = *document().frame(); |     auto& frame = *document().frame(); | ||||||
|     ASSERT(frame.html_view()); |     ASSERT(frame.page_view()); | ||||||
|     auto& html_view = const_cast<HtmlView&>(*frame.html_view()); |     auto& page_view = const_cast<PageView&>(*frame.page_view()); | ||||||
| 
 | 
 | ||||||
|     if (type() == "hidden") |     if (type() == "hidden") | ||||||
|         return nullptr; |         return nullptr; | ||||||
| 
 | 
 | ||||||
|     RefPtr<GUI::Widget> widget; |     RefPtr<GUI::Widget> widget; | ||||||
|     if (type() == "submit") { |     if (type() == "submit") { | ||||||
|         auto& button = html_view.add<GUI::Button>(value()); |         auto& button = page_view.add<GUI::Button>(value()); | ||||||
|         int text_width = Gfx::Font::default_font().width(value()); |         int text_width = Gfx::Font::default_font().width(value()); | ||||||
|         button.set_relative_rect(0, 0, text_width + 20, 20); |         button.set_relative_rect(0, 0, text_width + 20, 20); | ||||||
|         button.on_click = [this](auto) { |         button.on_click = [this](auto) { | ||||||
|  | @ -68,7 +68,7 @@ RefPtr<LayoutNode> HTMLInputElement::create_layout_node(const StyleProperties*) | ||||||
|         }; |         }; | ||||||
|         widget = button; |         widget = button; | ||||||
|     } else { |     } else { | ||||||
|         auto& text_box = html_view.add<GUI::TextBox>(); |         auto& text_box = page_view.add<GUI::TextBox>(); | ||||||
|         text_box.set_text(value()); |         text_box.set_text(value()); | ||||||
|         text_box.on_change = [this] { |         text_box.on_change = [this] { | ||||||
|             auto& widget = to<LayoutWidget>(layout_node())->widget(); |             auto& widget = to<LayoutWidget>(layout_node())->widget(); | ||||||
|  |  | ||||||
|  | @ -33,7 +33,7 @@ | ||||||
| #include <LibWeb/DOM/Document.h> | #include <LibWeb/DOM/Document.h> | ||||||
| #include <LibWeb/DOM/Window.h> | #include <LibWeb/DOM/Window.h> | ||||||
| #include <LibWeb/Frame.h> | #include <LibWeb/Frame.h> | ||||||
| #include <LibWeb/HtmlView.h> | #include <LibWeb/PageView.h> | ||||||
| 
 | 
 | ||||||
| namespace Web { | namespace Web { | ||||||
| 
 | 
 | ||||||
|  | @ -115,7 +115,7 @@ void Window::did_set_location_href(Badge<Bindings::LocationObject>, const String | ||||||
|     auto* frame = document().frame(); |     auto* frame = document().frame(); | ||||||
|     if (!frame) |     if (!frame) | ||||||
|         return; |         return; | ||||||
|     auto* view = frame->html_view(); |     auto* view = frame->page_view(); | ||||||
|     if (!view) |     if (!view) | ||||||
|         return; |         return; | ||||||
|     view->load(new_href); |     view->load(new_href); | ||||||
|  | @ -126,7 +126,7 @@ void Window::did_call_location_reload(Badge<Bindings::LocationObject>) | ||||||
|     auto* frame = document().frame(); |     auto* frame = document().frame(); | ||||||
|     if (!frame) |     if (!frame) | ||||||
|         return; |         return; | ||||||
|     auto* view = frame->html_view(); |     auto* view = frame->page_view(); | ||||||
|     if (!view) |     if (!view) | ||||||
|         return; |         return; | ||||||
|     view->reload(); |     view->reload(); | ||||||
|  |  | ||||||
|  | @ -44,7 +44,7 @@ class HTMLHeadElement; | ||||||
| class HTMLHtmlElement; | class HTMLHtmlElement; | ||||||
| class HTMLImageElement; | class HTMLImageElement; | ||||||
| class HTMLScriptElement; | class HTMLScriptElement; | ||||||
| class HtmlView; | class PageView; | ||||||
| class ImageData; | class ImageData; | ||||||
| class LayoutDocument; | class LayoutDocument; | ||||||
| class LayoutNode; | class LayoutNode; | ||||||
|  |  | ||||||
|  | @ -26,13 +26,13 @@ | ||||||
| 
 | 
 | ||||||
| #include <LibWeb/DOM/Document.h> | #include <LibWeb/DOM/Document.h> | ||||||
| #include <LibWeb/Frame.h> | #include <LibWeb/Frame.h> | ||||||
| #include <LibWeb/HtmlView.h> | #include <LibWeb/PageView.h> | ||||||
| #include <LibWeb/Layout/LayoutDocument.h> | #include <LibWeb/Layout/LayoutDocument.h> | ||||||
| 
 | 
 | ||||||
| namespace Web { | namespace Web { | ||||||
| 
 | 
 | ||||||
| Frame::Frame(HtmlView& html_view) | Frame::Frame(PageView& page_view) | ||||||
|     : m_html_view(html_view.make_weak_ptr()) |     : m_page_view(page_view.make_weak_ptr()) | ||||||
| { | { | ||||||
| } | } | ||||||
| 
 | 
 | ||||||
|  |  | ||||||
|  | @ -37,11 +37,11 @@ | ||||||
| namespace Web { | namespace Web { | ||||||
| 
 | 
 | ||||||
| class Document; | class Document; | ||||||
| class HtmlView; | class PageView; | ||||||
| 
 | 
 | ||||||
| class Frame : public TreeNode<Frame> { | class Frame : public TreeNode<Frame> { | ||||||
| public: | public: | ||||||
|     static NonnullRefPtr<Frame> create(HtmlView& html_view) { return adopt(*new Frame(html_view)); } |     static NonnullRefPtr<Frame> create(PageView& page_view) { return adopt(*new Frame(page_view)); } | ||||||
|     ~Frame(); |     ~Frame(); | ||||||
| 
 | 
 | ||||||
|     const Document* document() const { return m_document; } |     const Document* document() const { return m_document; } | ||||||
|  | @ -49,8 +49,8 @@ public: | ||||||
| 
 | 
 | ||||||
|     void set_document(Document*); |     void set_document(Document*); | ||||||
| 
 | 
 | ||||||
|     HtmlView* html_view() { return m_html_view; } |     PageView* page_view() { return m_page_view; } | ||||||
|     const HtmlView* html_view() const { return m_html_view; } |     const PageView* page_view() const { return m_page_view; } | ||||||
| 
 | 
 | ||||||
|     const Gfx::Size& size() const { return m_size; } |     const Gfx::Size& size() const { return m_size; } | ||||||
|     void set_size(const Gfx::Size&); |     void set_size(const Gfx::Size&); | ||||||
|  | @ -62,9 +62,9 @@ public: | ||||||
|     Gfx::Rect viewport_rect() const { return m_viewport_rect; } |     Gfx::Rect viewport_rect() const { return m_viewport_rect; } | ||||||
| 
 | 
 | ||||||
| private: | private: | ||||||
|     explicit Frame(HtmlView&); |     explicit Frame(PageView&); | ||||||
| 
 | 
 | ||||||
|     WeakPtr<HtmlView> m_html_view; |     WeakPtr<PageView> m_page_view; | ||||||
|     RefPtr<Document> m_document; |     RefPtr<Document> m_document; | ||||||
|     Gfx::Size m_size; |     Gfx::Size m_size; | ||||||
|     Gfx::Rect m_viewport_rect; |     Gfx::Rect m_viewport_rect; | ||||||
|  |  | ||||||
|  | @ -44,7 +44,7 @@ | ||||||
| #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/HtmlView.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/Parser/HTMLDocumentParser.h> | #include <LibWeb/Parser/HTMLDocumentParser.h> | ||||||
|  | @ -57,7 +57,7 @@ | ||||||
| 
 | 
 | ||||||
| namespace Web { | namespace Web { | ||||||
| 
 | 
 | ||||||
| HtmlView::HtmlView() | PageView::PageView() | ||||||
|     : m_main_frame(Web::Frame::create(*this)) |     : m_main_frame(Web::Frame::create(*this)) | ||||||
| { | { | ||||||
|     main_frame().on_set_needs_display = [this](auto& content_rect) { |     main_frame().on_set_needs_display = [this](auto& content_rect) { | ||||||
|  | @ -74,11 +74,11 @@ HtmlView::HtmlView() | ||||||
|     set_background_role(ColorRole::Base); |     set_background_role(ColorRole::Base); | ||||||
| } | } | ||||||
| 
 | 
 | ||||||
| HtmlView::~HtmlView() | PageView::~PageView() | ||||||
| { | { | ||||||
| } | } | ||||||
| 
 | 
 | ||||||
| void HtmlView::set_document(Document* new_document) | void PageView::set_document(Document* new_document) | ||||||
| { | { | ||||||
|     RefPtr<Document> old_document = document(); |     RefPtr<Document> old_document = document(); | ||||||
| 
 | 
 | ||||||
|  | @ -111,7 +111,7 @@ void HtmlView::set_document(Document* new_document) | ||||||
|     update(); |     update(); | ||||||
| } | } | ||||||
| 
 | 
 | ||||||
| void HtmlView::layout_and_sync_size() | void PageView::layout_and_sync_size() | ||||||
| { | { | ||||||
|     if (!document()) |     if (!document()) | ||||||
|         return; |         return; | ||||||
|  | @ -139,13 +139,13 @@ void HtmlView::layout_and_sync_size() | ||||||
| #endif | #endif | ||||||
| } | } | ||||||
| 
 | 
 | ||||||
| void HtmlView::resize_event(GUI::ResizeEvent& event) | void PageView::resize_event(GUI::ResizeEvent& event) | ||||||
| { | { | ||||||
|     GUI::ScrollableWidget::resize_event(event); |     GUI::ScrollableWidget::resize_event(event); | ||||||
|     layout_and_sync_size(); |     layout_and_sync_size(); | ||||||
| } | } | ||||||
| 
 | 
 | ||||||
| void HtmlView::paint_event(GUI::PaintEvent& event) | void PageView::paint_event(GUI::PaintEvent& event) | ||||||
| { | { | ||||||
|     GUI::Frame::paint_event(event); |     GUI::Frame::paint_event(event); | ||||||
| 
 | 
 | ||||||
|  | @ -173,7 +173,7 @@ void HtmlView::paint_event(GUI::PaintEvent& event) | ||||||
|     layout_root()->render(context); |     layout_root()->render(context); | ||||||
| } | } | ||||||
| 
 | 
 | ||||||
| void HtmlView::mousemove_event(GUI::MouseEvent& event) | void PageView::mousemove_event(GUI::MouseEvent& event) | ||||||
| { | { | ||||||
|     if (!layout_root()) |     if (!layout_root()) | ||||||
|         return GUI::ScrollableWidget::mousemove_event(event); |         return GUI::ScrollableWidget::mousemove_event(event); | ||||||
|  | @ -191,7 +191,7 @@ void HtmlView::mousemove_event(GUI::MouseEvent& event) | ||||||
|             hovered_link_element = node->enclosing_link_element(); |             hovered_link_element = node->enclosing_link_element(); | ||||||
|             if (hovered_link_element) { |             if (hovered_link_element) { | ||||||
| #ifdef HTML_DEBUG | #ifdef HTML_DEBUG | ||||||
|                 dbg() << "HtmlView: hovering over a link to " << hovered_link_element->href(); |                 dbg() << "PageView: hovering over a link to " << hovered_link_element->href(); | ||||||
| #endif | #endif | ||||||
|                 is_hovering_link = true; |                 is_hovering_link = true; | ||||||
|             } |             } | ||||||
|  | @ -224,7 +224,7 @@ void HtmlView::mousemove_event(GUI::MouseEvent& event) | ||||||
|     event.accept(); |     event.accept(); | ||||||
| } | } | ||||||
| 
 | 
 | ||||||
| void HtmlView::mousedown_event(GUI::MouseEvent& event) | void PageView::mousedown_event(GUI::MouseEvent& event) | ||||||
| { | { | ||||||
|     if (!layout_root()) |     if (!layout_root()) | ||||||
|         return GUI::ScrollableWidget::mousemove_event(event); |         return GUI::ScrollableWidget::mousemove_event(event); | ||||||
|  | @ -239,7 +239,7 @@ void HtmlView::mousedown_event(GUI::MouseEvent& event) | ||||||
|             auto offset = compute_mouse_event_offset(event.position(), *result.layout_node); |             auto offset = compute_mouse_event_offset(event.position(), *result.layout_node); | ||||||
|             node->dispatch_event(MouseEvent::create("mousedown", offset.x(), offset.y())); |             node->dispatch_event(MouseEvent::create("mousedown", offset.x(), offset.y())); | ||||||
|             if (RefPtr<HTMLAnchorElement> link = node->enclosing_link_element()) { |             if (RefPtr<HTMLAnchorElement> link = node->enclosing_link_element()) { | ||||||
|                 dbg() << "HtmlView: clicking on a link to " << link->href(); |                 dbg() << "PageView: clicking on a link to " << link->href(); | ||||||
| 
 | 
 | ||||||
|                 if (event.button() == GUI::MouseButton::Left) { |                 if (event.button() == GUI::MouseButton::Left) { | ||||||
|                     if (link->href().starts_with("javascript:")) { |                     if (link->href().starts_with("javascript:")) { | ||||||
|  | @ -270,7 +270,7 @@ void HtmlView::mousedown_event(GUI::MouseEvent& event) | ||||||
|     event.accept(); |     event.accept(); | ||||||
| } | } | ||||||
| 
 | 
 | ||||||
| void HtmlView::mouseup_event(GUI::MouseEvent& event) | void PageView::mouseup_event(GUI::MouseEvent& event) | ||||||
| { | { | ||||||
|     if (!layout_root()) |     if (!layout_root()) | ||||||
|         return GUI::ScrollableWidget::mouseup_event(event); |         return GUI::ScrollableWidget::mouseup_event(event); | ||||||
|  | @ -289,7 +289,7 @@ void HtmlView::mouseup_event(GUI::MouseEvent& event) | ||||||
|     } |     } | ||||||
| } | } | ||||||
| 
 | 
 | ||||||
| void HtmlView::keydown_event(GUI::KeyEvent& event) | void PageView::keydown_event(GUI::KeyEvent& event) | ||||||
| { | { | ||||||
|     if (event.modifiers() == 0) { |     if (event.modifiers() == 0) { | ||||||
|         switch (event.key()) { |         switch (event.key()) { | ||||||
|  | @ -325,7 +325,7 @@ void HtmlView::keydown_event(GUI::KeyEvent& event) | ||||||
|     event.accept(); |     event.accept(); | ||||||
| } | } | ||||||
| 
 | 
 | ||||||
| void HtmlView::reload() | void PageView::reload() | ||||||
| { | { | ||||||
|     load(main_frame().document()->url()); |     load(main_frame().document()->url()); | ||||||
| } | } | ||||||
|  | @ -432,7 +432,7 @@ static String guess_mime_type_based_on_filename(const URL& url) | ||||||
|     return "text/plain"; |     return "text/plain"; | ||||||
| } | } | ||||||
| 
 | 
 | ||||||
| RefPtr<Document> HtmlView::create_document_from_mime_type(const ByteBuffer& data, const URL& url, const String& mime_type, const String& encoding) | RefPtr<Document> PageView::create_document_from_mime_type(const ByteBuffer& data, const URL& url, const String& mime_type, const String& encoding) | ||||||
| { | { | ||||||
|     if (mime_type.starts_with("image/")) |     if (mime_type.starts_with("image/")) | ||||||
|         return create_image_document(data, url); |         return create_image_document(data, url); | ||||||
|  | @ -453,9 +453,9 @@ RefPtr<Document> HtmlView::create_document_from_mime_type(const ByteBuffer& data | ||||||
|     return nullptr; |     return nullptr; | ||||||
| } | } | ||||||
| 
 | 
 | ||||||
| void HtmlView::load(const URL& url) | void PageView::load(const URL& url) | ||||||
| { | { | ||||||
|     dbg() << "HtmlView::load: " << url; |     dbg() << "PageView::load: " << url; | ||||||
| 
 | 
 | ||||||
|     if (!url.is_valid()) { |     if (!url.is_valid()) { | ||||||
|         load_error_page(url, "Invalid URL"); |         load_error_page(url, "Invalid URL"); | ||||||
|  | @ -537,7 +537,7 @@ void HtmlView::load(const URL& url) | ||||||
|     this->scroll_to_top(); |     this->scroll_to_top(); | ||||||
| } | } | ||||||
| 
 | 
 | ||||||
| void HtmlView::load_error_page(const URL& failed_url, const String& error) | void PageView::load_error_page(const URL& failed_url, const String& error) | ||||||
| { | { | ||||||
|     auto error_page_url = "file:///res/html/error.html"; |     auto error_page_url = "file:///res/html/error.html"; | ||||||
|     ResourceLoader::the().load( |     ResourceLoader::the().load( | ||||||
|  | @ -560,19 +560,19 @@ void HtmlView::load_error_page(const URL& failed_url, const String& error) | ||||||
|         }); |         }); | ||||||
| } | } | ||||||
| 
 | 
 | ||||||
| const LayoutDocument* HtmlView::layout_root() const | const LayoutDocument* PageView::layout_root() const | ||||||
| { | { | ||||||
|     return document() ? document()->layout_node() : nullptr; |     return document() ? document()->layout_node() : nullptr; | ||||||
| } | } | ||||||
| 
 | 
 | ||||||
| LayoutDocument* HtmlView::layout_root() | LayoutDocument* PageView::layout_root() | ||||||
| { | { | ||||||
|     if (!document()) |     if (!document()) | ||||||
|         return nullptr; |         return nullptr; | ||||||
|     return const_cast<LayoutDocument*>(document()->layout_node()); |     return const_cast<LayoutDocument*>(document()->layout_node()); | ||||||
| } | } | ||||||
| 
 | 
 | ||||||
| void HtmlView::scroll_to_anchor(const StringView& name) | void PageView::scroll_to_anchor(const StringView& name) | ||||||
| { | { | ||||||
|     if (!document()) |     if (!document()) | ||||||
|         return; |         return; | ||||||
|  | @ -589,11 +589,11 @@ void HtmlView::scroll_to_anchor(const StringView& name) | ||||||
|     } |     } | ||||||
| 
 | 
 | ||||||
|     if (!element) { |     if (!element) { | ||||||
|         dbg() << "HtmlView::scroll_to_anchor(): Anchor not found: '" << name << "'"; |         dbg() << "PageView::scroll_to_anchor(): Anchor not found: '" << name << "'"; | ||||||
|         return; |         return; | ||||||
|     } |     } | ||||||
|     if (!element->layout_node()) { |     if (!element->layout_node()) { | ||||||
|         dbg() << "HtmlView::scroll_to_anchor(): Anchor found but without layout node: '" << name << "'"; |         dbg() << "PageView::scroll_to_anchor(): Anchor found but without layout node: '" << name << "'"; | ||||||
|         return; |         return; | ||||||
|     } |     } | ||||||
|     auto& layout_node = *element->layout_node(); |     auto& layout_node = *element->layout_node(); | ||||||
|  | @ -602,17 +602,17 @@ void HtmlView::scroll_to_anchor(const StringView& name) | ||||||
|     window()->set_override_cursor(GUI::StandardCursor::None); |     window()->set_override_cursor(GUI::StandardCursor::None); | ||||||
| } | } | ||||||
| 
 | 
 | ||||||
| Document* HtmlView::document() | Document* PageView::document() | ||||||
| { | { | ||||||
|     return main_frame().document(); |     return main_frame().document(); | ||||||
| } | } | ||||||
| 
 | 
 | ||||||
| const Document* HtmlView::document() const | const Document* PageView::document() const | ||||||
| { | { | ||||||
|     return main_frame().document(); |     return main_frame().document(); | ||||||
| } | } | ||||||
| 
 | 
 | ||||||
| void HtmlView::dump_selection(const char* event_name) | void PageView::dump_selection(const char* event_name) | ||||||
| { | { | ||||||
|     UNUSED_PARAM(event_name); |     UNUSED_PARAM(event_name); | ||||||
| #ifdef SELECTION_DEBUG | #ifdef SELECTION_DEBUG | ||||||
|  | @ -622,12 +622,12 @@ void HtmlView::dump_selection(const char* event_name) | ||||||
| #endif | #endif | ||||||
| } | } | ||||||
| 
 | 
 | ||||||
| void HtmlView::did_scroll() | void PageView::did_scroll() | ||||||
| { | { | ||||||
|     main_frame().set_viewport_rect(viewport_rect_in_content_coordinates()); |     main_frame().set_viewport_rect(viewport_rect_in_content_coordinates()); | ||||||
| } | } | ||||||
| 
 | 
 | ||||||
| Gfx::Point HtmlView::compute_mouse_event_offset(const Gfx::Point& event_position, const LayoutNode& layout_node) const | Gfx::Point PageView::compute_mouse_event_offset(const Gfx::Point& event_position, const LayoutNode& layout_node) const | ||||||
| { | { | ||||||
|     auto content_event_position = to_content_position(event_position); |     auto content_event_position = to_content_position(event_position); | ||||||
|     auto top_left_of_layout_node = layout_node.box_type_agnostic_position(); |     auto top_left_of_layout_node = layout_node.box_type_agnostic_position(); | ||||||
|  | @ -638,7 +638,7 @@ Gfx::Point HtmlView::compute_mouse_event_offset(const Gfx::Point& event_position | ||||||
|     }; |     }; | ||||||
| } | } | ||||||
| 
 | 
 | ||||||
| void HtmlView::run_javascript_url(const String& url) | void PageView::run_javascript_url(const String& url) | ||||||
| { | { | ||||||
|     ASSERT(url.starts_with("javascript:")); |     ASSERT(url.starts_with("javascript:")); | ||||||
|     if (!document()) |     if (!document()) | ||||||
|  | @ -649,7 +649,7 @@ void HtmlView::run_javascript_url(const String& url) | ||||||
|     document()->run_javascript(source); |     document()->run_javascript(source); | ||||||
| } | } | ||||||
| 
 | 
 | ||||||
| void HtmlView::drop_event(GUI::DropEvent& event) | void PageView::drop_event(GUI::DropEvent& event) | ||||||
| { | { | ||||||
|     if (event.mime_data().has_urls()) { |     if (event.mime_data().has_urls()) { | ||||||
|         if (on_url_drop) { |         if (on_url_drop) { | ||||||
|  | @ -33,10 +33,10 @@ namespace Web { | ||||||
| 
 | 
 | ||||||
| class Frame; | class Frame; | ||||||
| 
 | 
 | ||||||
| class HtmlView : public GUI::ScrollableWidget { | class PageView : public GUI::ScrollableWidget { | ||||||
|     C_OBJECT(HtmlView) |     C_OBJECT(PageView) | ||||||
| public: | public: | ||||||
|     virtual ~HtmlView() 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_new_parser(bool use_new_parser) { m_use_new_parser = use_new_parser; } | ||||||
|  | @ -73,7 +73,7 @@ public: | ||||||
|     virtual bool accepts_focus() const override { return true; } |     virtual bool accepts_focus() const override { return true; } | ||||||
| 
 | 
 | ||||||
| protected: | protected: | ||||||
|     HtmlView(); |     PageView(); | ||||||
| 
 | 
 | ||||||
|     virtual void resize_event(GUI::ResizeEvent&) override; |     virtual void resize_event(GUI::ResizeEvent&) override; | ||||||
|     virtual void paint_event(GUI::PaintEvent&) override; |     virtual void paint_event(GUI::PaintEvent&) override; | ||||||
|  | @ -35,7 +35,7 @@ | ||||||
| #include <LibWeb/CSS/StyleResolver.h> | #include <LibWeb/CSS/StyleResolver.h> | ||||||
| #include <LibWeb/DOM/Element.h> | #include <LibWeb/DOM/Element.h> | ||||||
| #include <LibWeb/Dump.h> | #include <LibWeb/Dump.h> | ||||||
| #include <LibWeb/HtmlView.h> | #include <LibWeb/PageView.h> | ||||||
| #include <LibWeb/Layout/LayoutBlock.h> | #include <LibWeb/Layout/LayoutBlock.h> | ||||||
| #include <LibWeb/Layout/LayoutInline.h> | #include <LibWeb/Layout/LayoutInline.h> | ||||||
| #include <LibWeb/Layout/LayoutNode.h> | #include <LibWeb/Layout/LayoutNode.h> | ||||||
|  | @ -64,7 +64,7 @@ int main(int argc, char** argv) | ||||||
|     auto document = Web::parse_html_document(html); |     auto document = Web::parse_html_document(html); | ||||||
| 
 | 
 | ||||||
|     auto window = GUI::Window::construct(); |     auto window = GUI::Window::construct(); | ||||||
|     auto& widget = window->set_main_widget<Web::HtmlView>(); |     auto& widget = window->set_main_widget<Web::PageView>(); | ||||||
|     widget.set_document(document); |     widget.set_document(document); | ||||||
|     if (!widget.document()->title().is_null()) |     if (!widget.document()->title().is_null()) | ||||||
|         window->set_title(String::format("%s - HTML", widget.document()->title().characters())); |         window->set_title(String::format("%s - HTML", widget.document()->title().characters())); | ||||||
|  |  | ||||||
		Loading…
	
	Add table
		Add a link
		
	
		Reference in a new issue
	
	 Andreas Kling
						Andreas Kling