diff --git a/Ladybird/BrowserWindow.cpp b/Ladybird/BrowserWindow.cpp index 83fea005d07..2123ae28593 100644 --- a/Ladybird/BrowserWindow.cpp +++ b/Ladybird/BrowserWindow.cpp @@ -9,7 +9,7 @@ #include "BrowserWindow.h" #include "Settings.h" #include "SettingsDialog.h" -#include "WebView.h" +#include "SimpleWebView.h" #include #include #include diff --git a/Ladybird/BrowserWindow.h b/Ladybird/BrowserWindow.h index ac96cd1ca05..8e42557ac57 100644 --- a/Ladybird/BrowserWindow.h +++ b/Ladybird/BrowserWindow.h @@ -16,14 +16,14 @@ #pragma once -class WebView; +class SimpleWebView; class BrowserWindow : public QMainWindow { Q_OBJECT public: explicit BrowserWindow(); - WebView& view() const { return m_current_tab->view(); } + SimpleWebView& view() const { return m_current_tab->view(); } int tab_index(Tab*); diff --git a/Ladybird/CMakeLists.txt b/Ladybird/CMakeLists.txt index f0c3ecf7eb5..5dba4cfd517 100644 --- a/Ladybird/CMakeLists.txt +++ b/Ladybird/CMakeLists.txt @@ -57,10 +57,10 @@ set(SOURCES PageClientLadybird.cpp RequestManagerQt.cpp main.cpp - WebView.cpp History.cpp Settings.cpp SettingsDialog.cpp + SimpleWebView.cpp Tab.cpp TimerQt.cpp Utilities.cpp diff --git a/Ladybird/ConsoleClient.cpp b/Ladybird/ConsoleClient.cpp index 1a65859fc65..36cc43fda06 100644 --- a/Ladybird/ConsoleClient.cpp +++ b/Ladybird/ConsoleClient.cpp @@ -9,7 +9,7 @@ #include "ConsoleClient.h" #include "ConsoleGlobalObject.h" -#include "WebView.h" +#include "SimpleWebView.h" #include #include #include @@ -18,7 +18,7 @@ namespace Ladybird { -ConsoleClient::ConsoleClient(JS::Console& console, JS::Realm& realm, WebView& view) +ConsoleClient::ConsoleClient(JS::Console& console, JS::Realm& realm, SimpleWebView& view) : JS::ConsoleClient(console) , m_view(view) , m_realm(realm) diff --git a/Ladybird/ConsoleClient.h b/Ladybird/ConsoleClient.h index df4d9d6191a..30e91a5af1f 100644 --- a/Ladybird/ConsoleClient.h +++ b/Ladybird/ConsoleClient.h @@ -17,13 +17,13 @@ #include #include -class WebView; +class SimpleWebView; namespace Ladybird { class ConsoleClient final : public JS::ConsoleClient { public: - ConsoleClient(JS::Console&, JS::Realm&, WebView&); + ConsoleClient(JS::Console&, JS::Realm&, SimpleWebView&); void handle_input(String const& js_source); void send_messages(i32 start_index); @@ -32,7 +32,7 @@ private: virtual void clear() override; virtual JS::ThrowCompletionOr printer(JS::Console::LogLevel log_level, PrinterArguments) override; - WebView& m_view; + SimpleWebView& m_view; WeakPtr m_interpreter; JS::Handle m_console_global_object; diff --git a/Ladybird/PageClientLadybird.cpp b/Ladybird/PageClientLadybird.cpp index d151977d1a6..e245bc752d1 100644 --- a/Ladybird/PageClientLadybird.cpp +++ b/Ladybird/PageClientLadybird.cpp @@ -7,8 +7,8 @@ #define AK_DONT_REPLACE_STD #include "PageClientLadybird.h" +#include "SimpleWebView.h" #include "Utilities.h" -#include "WebView.h" #include #include #include @@ -23,12 +23,12 @@ namespace Ladybird { -NonnullOwnPtr PageClientLadybird::create(WebView& view) +NonnullOwnPtr PageClientLadybird::create(SimpleWebView& view) { return adopt_own(*new PageClientLadybird(view)); } -PageClientLadybird::PageClientLadybird(WebView& view) +PageClientLadybird::PageClientLadybird(SimpleWebView& view) : m_view(view) , m_page(make(*this)) { diff --git a/Ladybird/PageClientLadybird.h b/Ladybird/PageClientLadybird.h index a933488d3ef..c65ec08e3e6 100644 --- a/Ladybird/PageClientLadybird.h +++ b/Ladybird/PageClientLadybird.h @@ -11,13 +11,13 @@ #include #include -class WebView; +class SimpleWebView; namespace Ladybird { class PageClientLadybird final : public Web::PageClient { public: - static NonnullOwnPtr create(WebView&); + static NonnullOwnPtr create(SimpleWebView&); virtual ~PageClientLadybird() override; Web::Page& page() { return *m_page; } @@ -69,9 +69,9 @@ public: void set_should_show_line_box_borders(bool); - explicit PageClientLadybird(WebView&); + explicit PageClientLadybird(SimpleWebView&); - WebView& m_view; + SimpleWebView& m_view; NonnullOwnPtr m_page; Browser::CookieJar m_cookie_jar; diff --git a/Ladybird/WebView.cpp b/Ladybird/SimpleWebView.cpp similarity index 93% rename from Ladybird/WebView.cpp rename to Ladybird/SimpleWebView.cpp index 52ffbb2a080..8d55dfddc07 100644 --- a/Ladybird/WebView.cpp +++ b/Ladybird/SimpleWebView.cpp @@ -7,7 +7,7 @@ #define AK_DONT_REPLACE_STD -#include "WebView.h" +#include "SimpleWebView.h" #include "ConsoleClient.h" #include "CookieJar.h" #include "EventLoopPluginQt.h" @@ -68,7 +68,7 @@ String s_serenity_resource_root; -WebView::WebView() +SimpleWebView::SimpleWebView() { setMouseTracking(true); @@ -92,17 +92,17 @@ WebView::WebView() }); } -WebView::~WebView() +SimpleWebView::~SimpleWebView() { } -void WebView::reload() +void SimpleWebView::reload() { auto url = m_page_client->page().top_level_browsing_context().active_document()->url(); m_page_client->load(url); } -void WebView::load(String const& url) +void SimpleWebView::load(String const& url) { m_page_client->load(AK::URL(url)); } @@ -292,7 +292,7 @@ KeyCode get_keycode_from_qt_keyboard_event(QKeyEvent const& event) return Key_Invalid; } -void WebView::mouseMoveEvent(QMouseEvent* event) +void SimpleWebView::mouseMoveEvent(QMouseEvent* event) { Gfx::IntPoint position(event->position().x() / m_inverse_pixel_scaling_ratio, event->position().y() / m_inverse_pixel_scaling_ratio); auto buttons = get_buttons_from_qt_event(*event); @@ -300,7 +300,7 @@ void WebView::mouseMoveEvent(QMouseEvent* event) m_page_client->page().handle_mousemove(to_content(position), buttons, modifiers); } -void WebView::mousePressEvent(QMouseEvent* event) +void SimpleWebView::mousePressEvent(QMouseEvent* event) { Gfx::IntPoint position(event->position().x() / m_inverse_pixel_scaling_ratio, event->position().y() / m_inverse_pixel_scaling_ratio); auto button = get_button_from_qt_event(*event); @@ -314,7 +314,7 @@ void WebView::mousePressEvent(QMouseEvent* event) m_page_client->page().handle_mousedown(to_content(position), button, modifiers); } -void WebView::mouseReleaseEvent(QMouseEvent* event) +void SimpleWebView::mouseReleaseEvent(QMouseEvent* event) { Gfx::IntPoint position(event->position().x() / m_inverse_pixel_scaling_ratio, event->position().y() / m_inverse_pixel_scaling_ratio); auto button = get_button_from_qt_event(*event); @@ -328,7 +328,7 @@ void WebView::mouseReleaseEvent(QMouseEvent* event) m_page_client->page().handle_mouseup(to_content(position), button, modifiers); } -void WebView::keyPressEvent(QKeyEvent* event) +void SimpleWebView::keyPressEvent(QKeyEvent* event) { switch (event->key()) { case Qt::Key_Left: @@ -353,7 +353,7 @@ void WebView::keyPressEvent(QKeyEvent* event) m_page_client->page().handle_keydown(keycode, modifiers, point); } -void WebView::keyReleaseEvent(QKeyEvent* event) +void SimpleWebView::keyReleaseEvent(QKeyEvent* event) { auto text = event->text(); if (text.isEmpty()) { @@ -365,17 +365,17 @@ void WebView::keyReleaseEvent(QKeyEvent* event) m_page_client->page().handle_keyup(keycode, modifiers, point); } -Gfx::IntPoint WebView::to_content(Gfx::IntPoint viewport_position) const +Gfx::IntPoint SimpleWebView::to_content(Gfx::IntPoint viewport_position) const { return viewport_position.translated(horizontalScrollBar()->value(), verticalScrollBar()->value()); } -Gfx::IntPoint WebView::to_widget(Gfx::IntPoint content_position) const +Gfx::IntPoint SimpleWebView::to_widget(Gfx::IntPoint content_position) const { return content_position.translated(-horizontalScrollBar()->value(), -verticalScrollBar()->value()); } -void WebView::paintEvent(QPaintEvent* event) +void SimpleWebView::paintEvent(QPaintEvent* event) { QPainter painter(viewport()); painter.setClipRect(event->rect()); @@ -393,13 +393,13 @@ void WebView::paintEvent(QPaintEvent* event) painter.drawImage(QPoint(0, 0), q_image); } -void WebView::resizeEvent(QResizeEvent* event) +void SimpleWebView::resizeEvent(QResizeEvent* event) { QAbstractScrollArea::resizeEvent(event); update_viewport_rect(); } -void WebView::update_viewport_rect() +void SimpleWebView::update_viewport_rect() { auto scaled_width = int(size().width() / m_inverse_pixel_scaling_ratio); auto scaled_height = int(size().height() / m_inverse_pixel_scaling_ratio); @@ -446,7 +446,7 @@ void initialize_web_engine() Web::FrameLoader::set_error_page_url(String::formatted("file://{}/res/html/error.html", s_serenity_resource_root)); } -void WebView::debug_request(String const& request, String const& argument) +void SimpleWebView::debug_request(String const& request, String const& argument) { auto& page = m_page_client->page(); @@ -514,7 +514,7 @@ void WebView::debug_request(String const& request, String const& argument) m_page_client->dump_cookies(); } -String WebView::source() const +String SimpleWebView::source() const { auto* document = m_page_client->page().top_level_browsing_context().active_document(); if (!document) @@ -522,7 +522,7 @@ String WebView::source() const return document->source(); } -void WebView::run_javascript(String const& js_source) const +void SimpleWebView::run_javascript(String const& js_source) const { auto* active_document = const_cast(m_page_client->page().top_level_browsing_context().active_document()); @@ -549,12 +549,12 @@ void WebView::run_javascript(String const& js_source) const dbgln("Exception :("); } -void WebView::did_output_js_console_message(i32 message_index) +void SimpleWebView::did_output_js_console_message(i32 message_index) { m_page_client->m_console_client->send_messages(message_index); } -void WebView::did_get_js_console_messages(i32, Vector, Vector messages) +void SimpleWebView::did_get_js_console_messages(i32, Vector, Vector messages) { ensure_js_console_widget(); for (auto& message : messages) { @@ -562,7 +562,7 @@ void WebView::did_get_js_console_messages(i32, Vector, Vector me } } -void WebView::ensure_js_console_widget() +void SimpleWebView::ensure_js_console_widget() { if (!m_js_console_widget) { m_js_console_widget = new QWidget; @@ -588,14 +588,14 @@ void WebView::ensure_js_console_widget() } } -void WebView::show_js_console() +void SimpleWebView::show_js_console() { ensure_js_console_widget(); m_js_console_widget->show(); m_js_console_input_edit->setFocus(); } -void WebView::set_color_scheme(ColorScheme color_scheme) +void SimpleWebView::set_color_scheme(ColorScheme color_scheme) { switch (color_scheme) { case ColorScheme::Auto: @@ -612,13 +612,13 @@ void WebView::set_color_scheme(ColorScheme color_scheme) document->invalidate_style(); } -void WebView::showEvent(QShowEvent* event) +void SimpleWebView::showEvent(QShowEvent* event) { QAbstractScrollArea::showEvent(event); m_page_client->page().top_level_browsing_context().set_system_visibility_state(Web::HTML::VisibilityState::Visible); } -void WebView::hideEvent(QHideEvent* event) +void SimpleWebView::hideEvent(QHideEvent* event) { QAbstractScrollArea::hideEvent(event); m_page_client->page().top_level_browsing_context().set_system_visibility_state(Web::HTML::VisibilityState::Hidden); diff --git a/Ladybird/WebView.h b/Ladybird/SimpleWebView.h similarity index 94% rename from Ladybird/WebView.h rename to Ladybird/SimpleWebView.h index 2da9268d5f4..80d4bacefd0 100644 --- a/Ladybird/WebView.h +++ b/Ladybird/SimpleWebView.h @@ -27,11 +27,11 @@ enum class ColorScheme { Dark, }; -class WebView final : public QAbstractScrollArea { +class SimpleWebView final : public QAbstractScrollArea { Q_OBJECT public: - WebView(); - virtual ~WebView() override; + SimpleWebView(); + virtual ~SimpleWebView() override; void load(String const& url); void reload(); diff --git a/Ladybird/Tab.cpp b/Ladybird/Tab.cpp index 1f6fedb44dc..1df3aab2d9c 100644 --- a/Ladybird/Tab.cpp +++ b/Ladybird/Tab.cpp @@ -25,7 +25,7 @@ Tab::Tab(BrowserWindow* window) m_layout->setSpacing(0); m_layout->setContentsMargins(0, 0, 0, 0); - m_view = new WebView; + m_view = new SimpleWebView; m_toolbar = new QToolBar; m_location_edit = new QLineEdit; @@ -61,24 +61,24 @@ Tab::Tab(BrowserWindow* window) m_toolbar->addAction(m_home_action); m_toolbar->addWidget(m_location_edit); - QObject::connect(m_view, &WebView::link_hovered, [this](QString const& title) { + QObject::connect(m_view, &SimpleWebView::link_hovered, [this](QString const& title) { m_hover_label->setText(title); update_hover_label(); m_hover_label->show(); }); - QObject::connect(m_view, &WebView::link_unhovered, [this] { + QObject::connect(m_view, &SimpleWebView::link_unhovered, [this] { m_hover_label->hide(); }); - QObject::connect(m_view, &WebView::load_started, [this](const URL& url) { + QObject::connect(m_view, &SimpleWebView::load_started, [this](const URL& url) { m_location_edit->setText(url.to_string().characters()); m_history.push(url, m_title.toUtf8().data()); m_back_action->setEnabled(m_history.can_go_back()); m_forward_action->setEnabled(m_history.can_go_forward()); }); QObject::connect(m_location_edit, &QLineEdit::returnPressed, this, &Tab::location_edit_return_pressed); - QObject::connect(m_view, &WebView::title_changed, this, &Tab::page_title_changed); - QObject::connect(m_view, &WebView::favicon_changed, this, &Tab::page_favicon_changed); + QObject::connect(m_view, &SimpleWebView::title_changed, this, &Tab::page_title_changed); + QObject::connect(m_view, &SimpleWebView::favicon_changed, this, &Tab::page_favicon_changed); QObject::connect(m_back_action, &QAction::triggered, this, &Tab::back); QObject::connect(m_forward_action, &QAction::triggered, this, &Tab::forward); diff --git a/Ladybird/Tab.h b/Ladybird/Tab.h index 3a8373335db..8fd31322ae4 100644 --- a/Ladybird/Tab.h +++ b/Ladybird/Tab.h @@ -10,7 +10,7 @@ #define AK_DONT_REPLACE_STD #include "History.h" -#include "WebView.h" +#include "SimpleWebView.h" #include #include #include @@ -24,7 +24,7 @@ class Tab final : public QWidget { public: explicit Tab(BrowserWindow* window); - WebView& view() { return *m_view; } + SimpleWebView& view() { return *m_view; } void navigate(QString); @@ -52,7 +52,7 @@ private: QBoxLayout* m_layout; QToolBar* m_toolbar { nullptr }; QLineEdit* m_location_edit { nullptr }; - WebView* m_view { nullptr }; + SimpleWebView* m_view { nullptr }; BrowserWindow* m_window { nullptr }; Browser::History m_history; QString m_title; diff --git a/Ladybird/main.cpp b/Ladybird/main.cpp index 44bf96d0444..8d7c8112271 100644 --- a/Ladybird/main.cpp +++ b/Ladybird/main.cpp @@ -6,7 +6,7 @@ #include "BrowserWindow.h" #include "Settings.h" -#include "WebView.h" +#include "SimpleWebView.h" #include #include #include