mirror of
https://github.com/LadybirdBrowser/ladybird.git
synced 2024-12-04 05:20:30 +00:00
Ladybird: Rename WebView to SimpleWebView
This will allow us to share code with LibWebView from SerenityOS. (This would otherwise not work, since its "WebView" namespace collides with our "WebView" class.) Also, we should eventually move towards a more sophisticated multi-process WebView like OOPWV.
This commit is contained in:
parent
eecee7369f
commit
2a021084e5
Notes:
sideshowbarker
2024-07-17 06:09:44 +09:00
Author: https://github.com/awesomekling Commit: https://github.com/SerenityOS/serenity/commit/2a021084e5 Pull-request: https://github.com/SerenityOS/serenity/pull/16583 Reviewed-by: https://github.com/ADKaster Reviewed-by: https://github.com/linusg
12 changed files with 54 additions and 54 deletions
|
@ -9,7 +9,7 @@
|
|||
#include "BrowserWindow.h"
|
||||
#include "Settings.h"
|
||||
#include "SettingsDialog.h"
|
||||
#include "WebView.h"
|
||||
#include "SimpleWebView.h"
|
||||
#include <AK/TypeCasts.h>
|
||||
#include <QAction>
|
||||
#include <QActionGroup>
|
||||
|
|
|
@ -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*);
|
||||
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -9,7 +9,7 @@
|
|||
|
||||
#include "ConsoleClient.h"
|
||||
#include "ConsoleGlobalObject.h"
|
||||
#include "WebView.h"
|
||||
#include "SimpleWebView.h"
|
||||
#include <LibJS/Interpreter.h>
|
||||
#include <LibJS/MarkupGenerator.h>
|
||||
#include <LibWeb/HTML/Scripting/ClassicScript.h>
|
||||
|
@ -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)
|
||||
|
|
|
@ -17,13 +17,13 @@
|
|||
#include <LibJS/Forward.h>
|
||||
#include <LibWeb/Forward.h>
|
||||
|
||||
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<JS::Value> printer(JS::Console::LogLevel log_level, PrinterArguments) override;
|
||||
|
||||
WebView& m_view;
|
||||
SimpleWebView& m_view;
|
||||
|
||||
WeakPtr<JS::Interpreter> m_interpreter;
|
||||
JS::Handle<ConsoleGlobalObject> m_console_global_object;
|
||||
|
|
|
@ -7,8 +7,8 @@
|
|||
#define AK_DONT_REPLACE_STD
|
||||
|
||||
#include "PageClientLadybird.h"
|
||||
#include "SimpleWebView.h"
|
||||
#include "Utilities.h"
|
||||
#include "WebView.h"
|
||||
#include <LibCore/System.h>
|
||||
#include <LibGfx/Painter.h>
|
||||
#include <LibJS/Runtime/ConsoleObject.h>
|
||||
|
@ -23,12 +23,12 @@
|
|||
|
||||
namespace Ladybird {
|
||||
|
||||
NonnullOwnPtr<PageClientLadybird> PageClientLadybird::create(WebView& view)
|
||||
NonnullOwnPtr<PageClientLadybird> PageClientLadybird::create(SimpleWebView& view)
|
||||
{
|
||||
return adopt_own(*new PageClientLadybird(view));
|
||||
}
|
||||
|
||||
PageClientLadybird::PageClientLadybird(WebView& view)
|
||||
PageClientLadybird::PageClientLadybird(SimpleWebView& view)
|
||||
: m_view(view)
|
||||
, m_page(make<Web::Page>(*this))
|
||||
{
|
||||
|
|
|
@ -11,13 +11,13 @@
|
|||
#include <LibGfx/Rect.h>
|
||||
#include <LibWeb/Page/Page.h>
|
||||
|
||||
class WebView;
|
||||
class SimpleWebView;
|
||||
|
||||
namespace Ladybird {
|
||||
|
||||
class PageClientLadybird final : public Web::PageClient {
|
||||
public:
|
||||
static NonnullOwnPtr<PageClientLadybird> create(WebView&);
|
||||
static NonnullOwnPtr<PageClientLadybird> 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<Web::Page> m_page;
|
||||
Browser::CookieJar m_cookie_jar;
|
||||
|
||||
|
|
|
@ -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<Web::DOM::Document*>(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<String>, Vector<String> messages)
|
||||
void SimpleWebView::did_get_js_console_messages(i32, Vector<String>, Vector<String> messages)
|
||||
{
|
||||
ensure_js_console_widget();
|
||||
for (auto& message : messages) {
|
||||
|
@ -562,7 +562,7 @@ void WebView::did_get_js_console_messages(i32, Vector<String>, Vector<String> 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);
|
|
@ -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();
|
|
@ -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);
|
||||
|
|
|
@ -10,7 +10,7 @@
|
|||
#define AK_DONT_REPLACE_STD
|
||||
|
||||
#include "History.h"
|
||||
#include "WebView.h"
|
||||
#include "SimpleWebView.h"
|
||||
#include <QBoxLayout>
|
||||
#include <QLabel>
|
||||
#include <QLineEdit>
|
||||
|
@ -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;
|
||||
|
|
|
@ -6,7 +6,7 @@
|
|||
|
||||
#include "BrowserWindow.h"
|
||||
#include "Settings.h"
|
||||
#include "WebView.h"
|
||||
#include "SimpleWebView.h"
|
||||
#include <LibCore/ArgsParser.h>
|
||||
#include <LibCore/Timer.h>
|
||||
#include <LibMain/Main.h>
|
||||
|
|
Loading…
Reference in a new issue