From 42243d2e06a28bd2da0420eea49d84cb31bb1a9a Mon Sep 17 00:00:00 2001 From: Andreas Kling Date: Thu, 28 May 2020 18:21:22 +0200 Subject: [PATCH] LibWeb: Rename Web::HtmlView => Web::PageView This widget doesn't just view HTML, it views a web page. :^) --- Applications/Browser/BrowserConsoleClient.h | 2 +- Applications/Browser/ConsoleWidget.cpp | 2 +- Applications/Browser/ConsoleWidget.h | 4 +- Applications/Browser/Tab.cpp | 84 +++++++++---------- Applications/Browser/Tab.h | 2 +- Applications/Help/main.cpp | 12 +-- Applications/IRCClient/IRCWindow.cpp | 8 +- Applications/IRCClient/IRCWindow.h | 2 +- Applications/TextEditor/TextEditorWidget.cpp | 10 +-- Applications/TextEditor/TextEditorWidget.h | 2 +- DevTools/HackStudio/Editor.cpp | 6 +- DevTools/HackStudio/Editor.h | 2 +- Libraries/LibWeb/CMakeLists.txt | 6 +- Libraries/LibWeb/CSS/StyleValue.cpp | 4 +- Libraries/LibWeb/DOM/Document.cpp | 8 +- Libraries/LibWeb/DOM/HTMLFormElement.cpp | 4 +- Libraries/LibWeb/DOM/HTMLInputElement.cpp | 10 +-- Libraries/LibWeb/DOM/Window.cpp | 6 +- Libraries/LibWeb/Forward.h | 2 +- Libraries/LibWeb/Frame.cpp | 6 +- Libraries/LibWeb/Frame.h | 12 +-- .../LibWeb/{HtmlView.cpp => PageView.cpp} | 60 ++++++------- Libraries/LibWeb/{HtmlView.h => PageView.h} | 8 +- Userland/html.cpp | 4 +- 24 files changed, 133 insertions(+), 133 deletions(-) rename Libraries/LibWeb/{HtmlView.cpp => PageView.cpp} (93%) rename Libraries/LibWeb/{HtmlView.h => PageView.h} (96%) diff --git a/Applications/Browser/BrowserConsoleClient.h b/Applications/Browser/BrowserConsoleClient.h index faef20a5120..d8c62d428c1 100644 --- a/Applications/Browser/BrowserConsoleClient.h +++ b/Applications/Browser/BrowserConsoleClient.h @@ -28,7 +28,7 @@ #include #include #include -#include +#include namespace Browser { diff --git a/Applications/Browser/ConsoleWidget.cpp b/Applications/Browser/ConsoleWidget.cpp index 13626b65ad3..d67178a8243 100644 --- a/Applications/Browser/ConsoleWidget.cpp +++ b/Applications/Browser/ConsoleWidget.cpp @@ -56,7 +56,7 @@ ConsoleWidget::ConsoleWidget() html_element->append_child(body_element); m_output_container = body_element; - m_output_view = add(); + m_output_view = add(); m_output_view->set_document(base_document); m_input = add(); diff --git a/Applications/Browser/ConsoleWidget.h b/Applications/Browser/ConsoleWidget.h index 9f5f27be2a8..a21880136af 100644 --- a/Applications/Browser/ConsoleWidget.h +++ b/Applications/Browser/ConsoleWidget.h @@ -29,7 +29,7 @@ #include "History.h" #include #include -#include +#include namespace Browser { @@ -47,7 +47,7 @@ private: ConsoleWidget(); RefPtr m_input; - RefPtr m_output_view; + RefPtr m_output_view; RefPtr m_output_container; WeakPtr m_interpreter; OwnPtr m_console_client; diff --git a/Applications/Browser/Tab.cpp b/Applications/Browser/Tab.cpp index a52c9f197e2..b404fe846cf 100644 --- a/Applications/Browser/Tab.cpp +++ b/Applications/Browser/Tab.cpp @@ -49,7 +49,7 @@ #include #include #include -#include +#include #include #include #include @@ -69,34 +69,34 @@ Tab::Tab() m_toolbar_container = widget.add(); auto& toolbar = m_toolbar_container->add(); - m_html_widget = widget.add(); + m_page_view = widget.add(); - 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_history.go_back(); update_actions(); TemporaryChange change(m_should_push_loads_to_history, false); - m_html_widget->load(m_history.current()); + m_page_view->load(m_history.current()); }, this); m_go_forward_action = GUI::CommonActions::make_go_forward_action([this](auto&) { m_history.go_forward(); update_actions(); TemporaryChange change(m_should_push_loads_to_history, false); - m_html_widget->load(m_history.current()); + m_page_view->load(m_history.current()); }, this); toolbar.add_action(*m_go_back_action); toolbar.add_action(*m_go_forward_action); 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)); m_reload_action = GUI::CommonActions::make_reload_action([this](auto&) { TemporaryChange change(m_should_push_loads_to_history, false); - m_html_widget->reload(); + m_page_view->reload(); }, this); toolbar.add_action(*m_reload_action); @@ -114,8 +114,8 @@ Tab::Tab() location = builder.build(); } - m_html_widget->load(location); - m_html_widget->set_focus(true); + m_page_view->load(location); + m_page_view->set_focus(true); }; 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->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)) { BookmarksBarWidget::the().remove_bookmark(url); } else { @@ -139,7 +139,7 @@ Tab::Tab() 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()); if (m_should_push_loads_to_history) m_history.push(url); @@ -147,36 +147,36 @@ Tab::Tab() 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) { - auto url = m_html_widget->document()->complete_url(href); + auto url = m_page_view->document()->complete_url(href); on_tab_open_request(url); } else { if (href.starts_with("#")) { auto anchor = href.substring_view(1, href.length() - 1); - m_html_widget->scroll_to_anchor(anchor); + m_page_view->scroll_to_anchor(anchor); } else { - auto url = m_html_widget->document()->complete_url(href); - m_html_widget->load(url); + auto url = m_page_view->document()->complete_url(href); + m_page_view->load(url); } } }; m_link_context_menu = GUI::Menu::construct(); 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_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&) { - 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_action(GUI::Action::create("Download", [this](auto&) { auto window = GUI::Window::construct(); 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_resizable(false); window->set_main_widget(url); @@ -184,18 +184,18 @@ Tab::Tab() (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->popup(screen_position); }; - m_html_widget->on_link_middle_click = [this](auto& href) { - m_html_widget->on_link_click(href, "_blank", 0); + m_page_view->on_link_middle_click = [this](auto& href) { + 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()) { - m_title = m_html_widget->main_frame().document()->url().to_string(); + m_title = m_page_view->main_frame().document()->url().to_string(); } else { m_title = title; } @@ -203,13 +203,13 @@ Tab::Tab() 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; if (on_favicon_change) 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) { auto* console_widget = static_cast(m_console_window->main_widget()); console_widget->set_interpreter(document->interpreter().make_weak_ptr()); @@ -225,12 +225,12 @@ Tab::Tab() m_statusbar = widget.add(); - m_html_widget->on_link_hover = [this](auto& href) { + m_page_view->on_link_hover = [this](auto& href) { m_statusbar->set_text(href); }; - m_html_widget->on_url_drop = [this](auto& url) { - m_html_widget->load(url); + m_page_view->on_url_drop = [this](auto& url) { + m_page_view->load(url); }; m_menubar = GUI::MenuBar::construct(); @@ -265,9 +265,9 @@ Tab::Tab() auto& inspect_menu = m_menubar->add_menu("Inspect"); inspect_menu.add_action(GUI::Action::create( "View source", { Mod_Ctrl, Key_U }, [this](auto&) { - ASSERT(m_html_widget->document()); - auto url = m_html_widget->document()->url().to_string(); - auto source = m_html_widget->document()->source(); + ASSERT(m_page_view->document()); + auto url = m_page_view->document()->url().to_string(); + auto source = m_page_view->document()->source(); auto window = GUI::Window::construct(); auto& editor = window->set_main_widget(); editor.set_text(source); @@ -288,7 +288,7 @@ Tab::Tab() m_dom_inspector_window->set_main_widget(); } auto* inspector_widget = static_cast(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->move_to_front(); }, @@ -303,7 +303,7 @@ Tab::Tab() m_console_window->set_main_widget(); } auto* console_widget = static_cast(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->move_to_front(); }, @@ -312,17 +312,17 @@ Tab::Tab() auto& debug_menu = m_menubar->add_menu("Debug"); debug_menu.add_action(GUI::Action::create( "Dump DOM tree", [this](auto&) { - Web::dump_tree(*m_html_widget->document()); + Web::dump_tree(*m_page_view->document()); }, this)); debug_menu.add_action(GUI::Action::create( "Dump Layout tree", [this](auto&) { - Web::dump_tree(*m_html_widget->document()->layout_node()); + Web::dump_tree(*m_page_view->document()->layout_node()); }, this)); debug_menu.add_action(GUI::Action::create( "Dump Style sheets", [this](auto&) { - for (auto& sheet : m_html_widget->document()->stylesheets()) { + for (auto& sheet : m_page_view->document()->stylesheets()) { dump_sheet(sheet); } }, @@ -330,8 +330,8 @@ Tab::Tab() debug_menu.add_separator(); auto line_box_borders_action = GUI::Action::create_checkable( "Line box borders", [this](auto& action) { - m_html_widget->set_should_show_line_box_borders(action.is_checked()); - m_html_widget->update(); + m_page_view->set_should_show_line_box_borders(action.is_checked()); + m_page_view->update(); }, this); line_box_borders_action->set_checked(false); @@ -358,7 +358,7 @@ Tab::~Tab() void Tab::load(const URL& url) { - m_html_widget->load(url); + m_page_view->load(url); } void Tab::update_actions() @@ -392,7 +392,7 @@ void Tab::did_become_active() if (modifiers & Mod_Ctrl) on_tab_open_request(url); else - m_html_widget->load(url); + m_page_view->load(url); }; BookmarksBarWidget::the().on_bookmark_hover = [this](auto&, auto& url) { diff --git a/Applications/Browser/Tab.h b/Applications/Browser/Tab.h index 2846c4ed0cc..c473d168394 100644 --- a/Applications/Browser/Tab.h +++ b/Applications/Browser/Tab.h @@ -60,7 +60,7 @@ private: void update_bookmark_button(const String& url); History m_history; - RefPtr m_html_widget; + RefPtr m_page_view; RefPtr m_go_back_action; RefPtr m_go_forward_action; RefPtr m_reload_action; diff --git a/Applications/Help/main.cpp b/Applications/Help/main.cpp index 5178e191dfc..3455d9e7d91 100644 --- a/Applications/Help/main.cpp +++ b/Applications/Help/main.cpp @@ -42,7 +42,7 @@ #include #include #include -#include +#include #include #include #include @@ -97,7 +97,7 @@ int main(int argc, char* argv[]) tree_view.set_size_policy(GUI::SizePolicy::Fixed, GUI::SizePolicy::Fill); tree_view.set_preferred_size(200, 500); - auto& html_view = splitter.add(); + auto& page_view = splitter.add(); History history; @@ -111,7 +111,7 @@ int main(int argc, char* argv[]) auto open_page = [&](const String& path) { if (path.is_null()) { - html_view.set_document(nullptr); + page_view.set_document(nullptr); return; } @@ -134,7 +134,7 @@ int main(int argc, char* argv[]) String html = md_document.render_to_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()); 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 = [&] { String path = model->page_path(tree_view.selection().first()); if (path.is_null()) { - html_view.set_document(nullptr); + page_view.set_document(nullptr); return; } history.push(path); @@ -151,7 +151,7 @@ int main(int argc, char* argv[]) 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* dir_path = dirname(current_path); char* path = realpath(String::format("%s/%s", dir_path, href.characters()).characters(), nullptr); diff --git a/Applications/IRCClient/IRCWindow.cpp b/Applications/IRCClient/IRCWindow.cpp index e4f9f6aa214..8dbf3009d4f 100644 --- a/Applications/IRCClient/IRCWindow.cpp +++ b/Applications/IRCClient/IRCWindow.cpp @@ -39,7 +39,7 @@ #include #include #include -#include +#include IRCWindow::IRCWindow(IRCClient& client, void* owner, Type type, const String& name) : 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. auto& container = add(); - m_html_view = container.add(); + m_page_view = container.add(); if (m_type == Channel) { auto& member_view = container.add(); @@ -215,7 +215,7 @@ IRCWindow::~IRCWindow() void IRCWindow::set_log_buffer(const IRCLogBuffer& log_buffer) { m_log_buffer = &log_buffer; - m_html_view->set_document(const_cast(&log_buffer.document())); + m_page_view->set_document(const_cast(&log_buffer.document())); } 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(); return; } - m_html_view->scroll_to_bottom(); + m_page_view->scroll_to_bottom(); } void IRCWindow::clear_unread_count() diff --git a/Applications/IRCClient/IRCWindow.h b/Applications/IRCClient/IRCWindow.h index 3f36f631e49..bd60df54a3c 100644 --- a/Applications/IRCClient/IRCWindow.h +++ b/Applications/IRCClient/IRCWindow.h @@ -74,7 +74,7 @@ private: void* m_owner { nullptr }; Type m_type; String m_name; - RefPtr m_html_view; + RefPtr m_page_view; RefPtr m_text_box; RefPtr m_log_buffer; RefPtr m_context_menu; diff --git a/Applications/TextEditor/TextEditorWidget.cpp b/Applications/TextEditor/TextEditorWidget.cpp index d4c0bc33cdf..6884335e2cc 100644 --- a/Applications/TextEditor/TextEditorWidget.cpp +++ b/Applications/TextEditor/TextEditorWidget.cpp @@ -51,7 +51,7 @@ #include #include #include -#include +#include #include #include @@ -87,8 +87,8 @@ TextEditorWidget::TextEditorWidget() update_title(); }; - m_html_view = splitter.add(); - m_html_view->set_visible(false); + m_page_view = splitter.add(); + m_page_view->set_visible(false); m_find_replace_widget = add(); m_find_replace_widget->set_fill_with_background_color(true); @@ -553,7 +553,7 @@ void TextEditorWidget::set_markdown_preview_enabled(bool enabled) return; m_markdown_preview_enabled = enabled; m_markdown_preview_action->set_checked(enabled); - m_html_view->set_visible(enabled); + m_page_view->set_visible(enabled); if (enabled) update_markdown_preview(); } @@ -564,6 +564,6 @@ void TextEditorWidget::update_markdown_preview() if (document.parse(m_editor->text())) { auto html = document.render_to_html(); 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); } } diff --git a/Applications/TextEditor/TextEditorWidget.h b/Applications/TextEditor/TextEditorWidget.h index c3bdcd44826..cb21db1bc39 100644 --- a/Applications/TextEditor/TextEditorWidget.h +++ b/Applications/TextEditor/TextEditorWidget.h @@ -90,7 +90,7 @@ private: RefPtr m_js_highlight; RefPtr m_ini_highlight; - RefPtr m_html_view; + RefPtr m_page_view; bool m_document_dirty { false }; bool m_document_opening { false }; diff --git a/DevTools/HackStudio/Editor.cpp b/DevTools/HackStudio/Editor.cpp index fdbaa09651c..6383cb90cdd 100644 --- a/DevTools/HackStudio/Editor.cpp +++ b/DevTools/HackStudio/Editor.cpp @@ -40,7 +40,7 @@ #include #include #include -#include +#include #include // #define EDITOR_DEBUG @@ -50,7 +50,7 @@ Editor::Editor() m_documentation_tooltip_window = GUI::Window::construct(); m_documentation_tooltip_window->set_rect(0, 0, 500, 400); m_documentation_tooltip_window->set_window_type(GUI::WindowType::Tooltip); - m_documentation_html_view = m_documentation_tooltip_window->set_main_widget(); + m_documentation_page_view = m_documentation_tooltip_window->set_main_widget(); } Editor::~Editor() @@ -194,7 +194,7 @@ void Editor::show_documentation_tooltip_if_available(const String& hovered_token ASSERT(head_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->show(); diff --git a/DevTools/HackStudio/Editor.h b/DevTools/HackStudio/Editor.h index b1b986d18ff..69561b39ce9 100644 --- a/DevTools/HackStudio/Editor.h +++ b/DevTools/HackStudio/Editor.h @@ -71,7 +71,7 @@ private: explicit Editor(); RefPtr m_documentation_tooltip_window; - RefPtr m_documentation_html_view; + RefPtr m_documentation_page_view; String m_last_parsed_token; GUI::TextPosition m_previous_text_position { 0, 0 }; bool m_hovering_editor { false }; diff --git a/Libraries/LibWeb/CMakeLists.txt b/Libraries/LibWeb/CMakeLists.txt index a8ff0b319d4..4e976a2dad0 100644 --- a/Libraries/LibWeb/CMakeLists.txt +++ b/Libraries/LibWeb/CMakeLists.txt @@ -57,13 +57,12 @@ set(SOURCES DOM/Node.cpp DOM/ParentNode.cpp DOM/Text.cpp - DOMTreeModel.cpp DOM/Window.cpp DOM/XMLHttpRequest.cpp + DOMTreeModel.cpp Dump.cpp FontCache.cpp Frame.cpp - HtmlView.cpp Layout/BoxModelMetrics.cpp Layout/LayoutBlock.cpp Layout/LayoutBox.cpp @@ -76,14 +75,15 @@ set(SOURCES Layout/LayoutListItemMarker.cpp Layout/LayoutNode.cpp Layout/LayoutReplaced.cpp - Layout/LayoutTableCell.cpp Layout/LayoutTable.cpp + Layout/LayoutTableCell.cpp Layout/LayoutTableRow.cpp Layout/LayoutText.cpp Layout/LayoutTreeBuilder.cpp Layout/LayoutWidget.cpp Layout/LineBox.cpp Layout/LineBoxFragment.cpp + PageView.cpp Parser/CSSParser.cpp Parser/Entities.cpp Parser/HTMLDocumentParser.cpp diff --git a/Libraries/LibWeb/CSS/StyleValue.cpp b/Libraries/LibWeb/CSS/StyleValue.cpp index f58d6d19da6..7d3fbff9fa1 100644 --- a/Libraries/LibWeb/CSS/StyleValue.cpp +++ b/Libraries/LibWeb/CSS/StyleValue.cpp @@ -31,7 +31,7 @@ #include #include #include -#include +#include #include namespace Web { @@ -170,7 +170,7 @@ Color IdentifierStyleValue::to_color(const Document& document) const if (id() == CSS::ValueID::VendorSpecificLink) return document.link_color(); - auto palette = document.frame()->html_view()->palette(); + auto palette = document.frame()->page_view()->palette(); switch (id()) { case CSS::ValueID::VendorSpecificPaletteDesktopBackground: return palette.color(ColorRole::DesktopBackground); diff --git a/Libraries/LibWeb/DOM/Document.cpp b/Libraries/LibWeb/DOM/Document.cpp index 2b2d242f13d..51e68f80b9a 100644 --- a/Libraries/LibWeb/DOM/Document.cpp +++ b/Libraries/LibWeb/DOM/Document.cpp @@ -51,7 +51,7 @@ #include #include #include -#include +#include #include #include #include @@ -368,7 +368,7 @@ Color Document::link_color() const return m_link_color.value(); if (!frame()) return Color::Blue; - return frame()->html_view()->palette().link(); + return frame()->page_view()->palette().link(); } Color Document::active_link_color() const @@ -377,7 +377,7 @@ Color Document::active_link_color() const return m_active_link_color.value(); if (!frame()) return Color::Red; - return frame()->html_view()->palette().active_link(); + return frame()->page_view()->palette().active_link(); } Color Document::visited_link_color() const @@ -386,7 +386,7 @@ Color Document::visited_link_color() const return m_visited_link_color.value(); if (!frame()) return Color::Magenta; - return frame()->html_view()->palette().visited_link(); + return frame()->page_view()->palette().visited_link(); } JS::Interpreter& Document::interpreter() diff --git a/Libraries/LibWeb/DOM/HTMLFormElement.cpp b/Libraries/LibWeb/DOM/HTMLFormElement.cpp index cabb282d3e1..e4eef82a584 100644 --- a/Libraries/LibWeb/DOM/HTMLFormElement.cpp +++ b/Libraries/LibWeb/DOM/HTMLFormElement.cpp @@ -28,7 +28,7 @@ #include #include #include -#include +#include #include namespace Web { @@ -72,7 +72,7 @@ void HTMLFormElement::submit(RefPtr submitter) url.set_query(url_encode(parameters)); // FIXME: We shouldn't let the form just do this willy-nilly. - document().frame()->html_view()->load(url); + document().frame()->page_view()->load(url); } } diff --git a/Libraries/LibWeb/DOM/HTMLInputElement.cpp b/Libraries/LibWeb/DOM/HTMLInputElement.cpp index df87b91ddc1..a35c4ab7bf2 100644 --- a/Libraries/LibWeb/DOM/HTMLInputElement.cpp +++ b/Libraries/LibWeb/DOM/HTMLInputElement.cpp @@ -31,7 +31,7 @@ #include #include #include -#include +#include #include namespace Web { @@ -49,15 +49,15 @@ RefPtr HTMLInputElement::create_layout_node(const StyleProperties*) { ASSERT(document().frame()); auto& frame = *document().frame(); - ASSERT(frame.html_view()); - auto& html_view = const_cast(*frame.html_view()); + ASSERT(frame.page_view()); + auto& page_view = const_cast(*frame.page_view()); if (type() == "hidden") return nullptr; RefPtr widget; if (type() == "submit") { - auto& button = html_view.add(value()); + auto& button = page_view.add(value()); int text_width = Gfx::Font::default_font().width(value()); button.set_relative_rect(0, 0, text_width + 20, 20); button.on_click = [this](auto) { @@ -68,7 +68,7 @@ RefPtr HTMLInputElement::create_layout_node(const StyleProperties*) }; widget = button; } else { - auto& text_box = html_view.add(); + auto& text_box = page_view.add(); text_box.set_text(value()); text_box.on_change = [this] { auto& widget = to(layout_node())->widget(); diff --git a/Libraries/LibWeb/DOM/Window.cpp b/Libraries/LibWeb/DOM/Window.cpp index b1c90372296..55dce4c5e3f 100644 --- a/Libraries/LibWeb/DOM/Window.cpp +++ b/Libraries/LibWeb/DOM/Window.cpp @@ -33,7 +33,7 @@ #include #include #include -#include +#include namespace Web { @@ -115,7 +115,7 @@ void Window::did_set_location_href(Badge, const String auto* frame = document().frame(); if (!frame) return; - auto* view = frame->html_view(); + auto* view = frame->page_view(); if (!view) return; view->load(new_href); @@ -126,7 +126,7 @@ void Window::did_call_location_reload(Badge) auto* frame = document().frame(); if (!frame) return; - auto* view = frame->html_view(); + auto* view = frame->page_view(); if (!view) return; view->reload(); diff --git a/Libraries/LibWeb/Forward.h b/Libraries/LibWeb/Forward.h index 7b475d0fc7b..00149973de8 100644 --- a/Libraries/LibWeb/Forward.h +++ b/Libraries/LibWeb/Forward.h @@ -44,7 +44,7 @@ class HTMLHeadElement; class HTMLHtmlElement; class HTMLImageElement; class HTMLScriptElement; -class HtmlView; +class PageView; class ImageData; class LayoutDocument; class LayoutNode; diff --git a/Libraries/LibWeb/Frame.cpp b/Libraries/LibWeb/Frame.cpp index ca1645d1de0..94feac2e79a 100644 --- a/Libraries/LibWeb/Frame.cpp +++ b/Libraries/LibWeb/Frame.cpp @@ -26,13 +26,13 @@ #include #include -#include +#include #include namespace Web { -Frame::Frame(HtmlView& html_view) - : m_html_view(html_view.make_weak_ptr()) +Frame::Frame(PageView& page_view) + : m_page_view(page_view.make_weak_ptr()) { } diff --git a/Libraries/LibWeb/Frame.h b/Libraries/LibWeb/Frame.h index 9f91a928a10..97e2e3854a9 100644 --- a/Libraries/LibWeb/Frame.h +++ b/Libraries/LibWeb/Frame.h @@ -37,11 +37,11 @@ namespace Web { class Document; -class HtmlView; +class PageView; class Frame : public TreeNode { public: - static NonnullRefPtr create(HtmlView& html_view) { return adopt(*new Frame(html_view)); } + static NonnullRefPtr create(PageView& page_view) { return adopt(*new Frame(page_view)); } ~Frame(); const Document* document() const { return m_document; } @@ -49,8 +49,8 @@ public: void set_document(Document*); - HtmlView* html_view() { return m_html_view; } - const HtmlView* html_view() const { return m_html_view; } + PageView* page_view() { return m_page_view; } + const PageView* page_view() const { return m_page_view; } const Gfx::Size& size() const { return m_size; } void set_size(const Gfx::Size&); @@ -62,9 +62,9 @@ public: Gfx::Rect viewport_rect() const { return m_viewport_rect; } private: - explicit Frame(HtmlView&); + explicit Frame(PageView&); - WeakPtr m_html_view; + WeakPtr m_page_view; RefPtr m_document; Gfx::Size m_size; Gfx::Rect m_viewport_rect; diff --git a/Libraries/LibWeb/HtmlView.cpp b/Libraries/LibWeb/PageView.cpp similarity index 93% rename from Libraries/LibWeb/HtmlView.cpp rename to Libraries/LibWeb/PageView.cpp index 2fc4b8f048d..e5b13981662 100644 --- a/Libraries/LibWeb/HtmlView.cpp +++ b/Libraries/LibWeb/PageView.cpp @@ -44,7 +44,7 @@ #include #include #include -#include +#include #include #include #include @@ -57,7 +57,7 @@ namespace Web { -HtmlView::HtmlView() +PageView::PageView() : m_main_frame(Web::Frame::create(*this)) { main_frame().on_set_needs_display = [this](auto& content_rect) { @@ -74,11 +74,11 @@ HtmlView::HtmlView() set_background_role(ColorRole::Base); } -HtmlView::~HtmlView() +PageView::~PageView() { } -void HtmlView::set_document(Document* new_document) +void PageView::set_document(Document* new_document) { RefPtr old_document = document(); @@ -111,7 +111,7 @@ void HtmlView::set_document(Document* new_document) update(); } -void HtmlView::layout_and_sync_size() +void PageView::layout_and_sync_size() { if (!document()) return; @@ -139,13 +139,13 @@ void HtmlView::layout_and_sync_size() #endif } -void HtmlView::resize_event(GUI::ResizeEvent& event) +void PageView::resize_event(GUI::ResizeEvent& event) { GUI::ScrollableWidget::resize_event(event); layout_and_sync_size(); } -void HtmlView::paint_event(GUI::PaintEvent& event) +void PageView::paint_event(GUI::PaintEvent& event) { GUI::Frame::paint_event(event); @@ -173,7 +173,7 @@ void HtmlView::paint_event(GUI::PaintEvent& event) layout_root()->render(context); } -void HtmlView::mousemove_event(GUI::MouseEvent& event) +void PageView::mousemove_event(GUI::MouseEvent& event) { if (!layout_root()) return GUI::ScrollableWidget::mousemove_event(event); @@ -191,7 +191,7 @@ void HtmlView::mousemove_event(GUI::MouseEvent& event) hovered_link_element = node->enclosing_link_element(); if (hovered_link_element) { #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 is_hovering_link = true; } @@ -224,7 +224,7 @@ void HtmlView::mousemove_event(GUI::MouseEvent& event) event.accept(); } -void HtmlView::mousedown_event(GUI::MouseEvent& event) +void PageView::mousedown_event(GUI::MouseEvent& event) { if (!layout_root()) 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); node->dispatch_event(MouseEvent::create("mousedown", offset.x(), offset.y())); if (RefPtr 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 (link->href().starts_with("javascript:")) { @@ -270,7 +270,7 @@ void HtmlView::mousedown_event(GUI::MouseEvent& event) event.accept(); } -void HtmlView::mouseup_event(GUI::MouseEvent& event) +void PageView::mouseup_event(GUI::MouseEvent& event) { if (!layout_root()) 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) { switch (event.key()) { @@ -325,7 +325,7 @@ void HtmlView::keydown_event(GUI::KeyEvent& event) event.accept(); } -void HtmlView::reload() +void PageView::reload() { load(main_frame().document()->url()); } @@ -432,7 +432,7 @@ static String guess_mime_type_based_on_filename(const URL& url) return "text/plain"; } -RefPtr HtmlView::create_document_from_mime_type(const ByteBuffer& data, const URL& url, const String& mime_type, const String& encoding) +RefPtr 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/")) return create_image_document(data, url); @@ -453,9 +453,9 @@ RefPtr HtmlView::create_document_from_mime_type(const ByteBuffer& data 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()) { load_error_page(url, "Invalid URL"); @@ -537,7 +537,7 @@ void HtmlView::load(const URL& url) 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"; 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; } -LayoutDocument* HtmlView::layout_root() +LayoutDocument* PageView::layout_root() { if (!document()) return nullptr; return const_cast(document()->layout_node()); } -void HtmlView::scroll_to_anchor(const StringView& name) +void PageView::scroll_to_anchor(const StringView& name) { if (!document()) return; @@ -589,11 +589,11 @@ void HtmlView::scroll_to_anchor(const StringView& name) } if (!element) { - dbg() << "HtmlView::scroll_to_anchor(): Anchor not found: '" << name << "'"; + dbg() << "PageView::scroll_to_anchor(): Anchor not found: '" << name << "'"; return; } 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; } 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); } -Document* HtmlView::document() +Document* PageView::document() { return main_frame().document(); } -const Document* HtmlView::document() const +const Document* PageView::document() const { return main_frame().document(); } -void HtmlView::dump_selection(const char* event_name) +void PageView::dump_selection(const char* event_name) { UNUSED_PARAM(event_name); #ifdef SELECTION_DEBUG @@ -622,12 +622,12 @@ void HtmlView::dump_selection(const char* event_name) #endif } -void HtmlView::did_scroll() +void PageView::did_scroll() { 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 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:")); if (!document()) @@ -649,7 +649,7 @@ void HtmlView::run_javascript_url(const String& url) 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 (on_url_drop) { diff --git a/Libraries/LibWeb/HtmlView.h b/Libraries/LibWeb/PageView.h similarity index 96% rename from Libraries/LibWeb/HtmlView.h rename to Libraries/LibWeb/PageView.h index 008279abecf..7f53ac3be5d 100644 --- a/Libraries/LibWeb/HtmlView.h +++ b/Libraries/LibWeb/PageView.h @@ -33,10 +33,10 @@ namespace Web { class Frame; -class HtmlView : public GUI::ScrollableWidget { - C_OBJECT(HtmlView) +class PageView : public GUI::ScrollableWidget { + C_OBJECT(PageView) public: - virtual ~HtmlView() override; + virtual ~PageView() override; // 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; } @@ -73,7 +73,7 @@ public: virtual bool accepts_focus() const override { return true; } protected: - HtmlView(); + PageView(); virtual void resize_event(GUI::ResizeEvent&) override; virtual void paint_event(GUI::PaintEvent&) override; diff --git a/Userland/html.cpp b/Userland/html.cpp index 9fe2b1a363e..27d90cd2b7a 100644 --- a/Userland/html.cpp +++ b/Userland/html.cpp @@ -35,7 +35,7 @@ #include #include #include -#include +#include #include #include #include @@ -64,7 +64,7 @@ int main(int argc, char** argv) auto document = Web::parse_html_document(html); auto window = GUI::Window::construct(); - auto& widget = window->set_main_widget(); + auto& widget = window->set_main_widget(); widget.set_document(document); if (!widget.document()->title().is_null()) window->set_title(String::format("%s - HTML", widget.document()->title().characters()));