|
@@ -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) {
|