mirror of
https://github.com/RGBCube/serenity
synced 2025-07-26 01:37:35 +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 <LibJS/Console.h>
|
||||
#include <LibJS/Forward.h>
|
||||
#include <LibWeb/HtmlView.h>
|
||||
#include <LibWeb/PageView.h>
|
||||
|
||||
namespace Browser {
|
||||
|
||||
|
|
|
@ -56,7 +56,7 @@ ConsoleWidget::ConsoleWidget()
|
|||
html_element->append_child(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_input = add<GUI::TextBox>();
|
||||
|
|
|
@ -29,7 +29,7 @@
|
|||
#include "History.h"
|
||||
#include <LibGUI/Widget.h>
|
||||
#include <LibJS/Forward.h>
|
||||
#include <LibWeb/HtmlView.h>
|
||||
#include <LibWeb/PageView.h>
|
||||
|
||||
namespace Browser {
|
||||
|
||||
|
@ -47,7 +47,7 @@ private:
|
|||
ConsoleWidget();
|
||||
|
||||
RefPtr<GUI::TextBox> m_input;
|
||||
RefPtr<Web::HtmlView> m_output_view;
|
||||
RefPtr<Web::PageView> m_output_view;
|
||||
RefPtr<Web::Element> m_output_container;
|
||||
WeakPtr<JS::Interpreter> m_interpreter;
|
||||
OwnPtr<BrowserConsoleClient> m_console_client;
|
||||
|
|
|
@ -49,7 +49,7 @@
|
|||
#include <LibWeb/DOMTreeModel.h>
|
||||
#include <LibWeb/Dump.h>
|
||||
#include <LibWeb/Frame.h>
|
||||
#include <LibWeb/HtmlView.h>
|
||||
#include <LibWeb/PageView.h>
|
||||
#include <LibWeb/Layout/LayoutBlock.h>
|
||||
#include <LibWeb/Layout/LayoutDocument.h>
|
||||
#include <LibWeb/Layout/LayoutInline.h>
|
||||
|
@ -69,34 +69,34 @@ Tab::Tab()
|
|||
|
||||
m_toolbar_container = widget.add<GUI::ToolBarContainer>();
|
||||
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_history.go_back();
|
||||
update_actions();
|
||||
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);
|
||||
|
||||
m_go_forward_action = GUI::CommonActions::make_go_forward_action([this](auto&) {
|
||||
m_history.go_forward();
|
||||
update_actions();
|
||||
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);
|
||||
|
||||
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<bool> 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<DownloadWidget>(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<ConsoleWidget*>(m_console_window->main_widget());
|
||||
console_widget->set_interpreter(document->interpreter().make_weak_ptr());
|
||||
|
@ -225,12 +225,12 @@ Tab::Tab()
|
|||
|
||||
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_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<GUI::TextEditor>();
|
||||
editor.set_text(source);
|
||||
|
@ -288,7 +288,7 @@ Tab::Tab()
|
|||
m_dom_inspector_window->set_main_widget<InspectorWidget>();
|
||||
}
|
||||
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->move_to_front();
|
||||
},
|
||||
|
@ -303,7 +303,7 @@ Tab::Tab()
|
|||
m_console_window->set_main_widget<ConsoleWidget>();
|
||||
}
|
||||
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->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) {
|
||||
|
|
|
@ -60,7 +60,7 @@ private:
|
|||
void update_bookmark_button(const String& url);
|
||||
|
||||
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_forward_action;
|
||||
RefPtr<GUI::Action> m_reload_action;
|
||||
|
|
|
@ -42,7 +42,7 @@
|
|||
#include <LibGUI/TreeView.h>
|
||||
#include <LibGUI/Window.h>
|
||||
#include <LibMarkdown/Document.h>
|
||||
#include <LibWeb/HtmlView.h>
|
||||
#include <LibWeb/PageView.h>
|
||||
#include <LibWeb/Layout/LayoutNode.h>
|
||||
#include <LibWeb/Parser/CSSParser.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_preferred_size(200, 500);
|
||||
|
||||
auto& html_view = splitter.add<Web::HtmlView>();
|
||||
auto& page_view = splitter.add<Web::PageView>();
|
||||
|
||||
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);
|
||||
|
|
|
@ -39,7 +39,7 @@
|
|||
#include <LibGUI/TextBox.h>
|
||||
#include <LibGUI/TextEditor.h>
|
||||
#include <LibGUI/Window.h>
|
||||
#include <LibWeb/HtmlView.h>
|
||||
#include <LibWeb/PageView.h>
|
||||
|
||||
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<GUI::HorizontalSplitter>();
|
||||
|
||||
m_html_view = container.add<Web::HtmlView>();
|
||||
m_page_view = container.add<Web::PageView>();
|
||||
|
||||
if (m_type == Channel) {
|
||||
auto& member_view = container.add<GUI::TableView>();
|
||||
|
@ -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<Web::Document*>(&log_buffer.document()));
|
||||
m_page_view->set_document(const_cast<Web::Document*>(&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()
|
||||
|
|
|
@ -74,7 +74,7 @@ private:
|
|||
void* m_owner { nullptr };
|
||||
Type m_type;
|
||||
String m_name;
|
||||
RefPtr<Web::HtmlView> m_html_view;
|
||||
RefPtr<Web::PageView> m_page_view;
|
||||
RefPtr<GUI::TextBox> m_text_box;
|
||||
RefPtr<IRCLogBuffer> m_log_buffer;
|
||||
RefPtr<GUI::Menu> m_context_menu;
|
||||
|
|
|
@ -51,7 +51,7 @@
|
|||
#include <LibGUI/ToolBarContainer.h>
|
||||
#include <LibGfx/Font.h>
|
||||
#include <LibMarkdown/Document.h>
|
||||
#include <LibWeb/HtmlView.h>
|
||||
#include <LibWeb/PageView.h>
|
||||
#include <LibWeb/Parser/HTMLParser.h>
|
||||
#include <string.h>
|
||||
|
||||
|
@ -87,8 +87,8 @@ TextEditorWidget::TextEditorWidget()
|
|||
update_title();
|
||||
};
|
||||
|
||||
m_html_view = splitter.add<Web::HtmlView>();
|
||||
m_html_view->set_visible(false);
|
||||
m_page_view = splitter.add<Web::PageView>();
|
||||
m_page_view->set_visible(false);
|
||||
|
||||
m_find_replace_widget = add<GUI::Widget>();
|
||||
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);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -90,7 +90,7 @@ private:
|
|||
RefPtr<GUI::Action> m_js_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_opening { false };
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue