2022-10-05 13:23:41 +00:00
|
|
|
/*
|
2023-05-14 16:57:14 +00:00
|
|
|
* Copyright (c) 2022-2023, Andreas Kling <kling@serenityos.org>
|
2023-01-12 14:39:05 +00:00
|
|
|
* Copyright (c) 2023, Linus Groh <linusg@serenityos.org>
|
2022-10-05 13:23:41 +00:00
|
|
|
*
|
|
|
|
* SPDX-License-Identifier: BSD-2-Clause
|
|
|
|
*/
|
|
|
|
|
|
|
|
#pragma once
|
|
|
|
|
2022-12-04 18:43:54 +00:00
|
|
|
#include <AK/DeprecatedString.h>
|
2022-10-05 13:23:41 +00:00
|
|
|
#include <AK/Function.h>
|
|
|
|
#include <AK/HashMap.h>
|
|
|
|
#include <AK/OwnPtr.h>
|
|
|
|
#include <AK/URL.h>
|
2023-08-05 16:42:26 +00:00
|
|
|
#include <Ladybird/Types.h>
|
2022-10-05 13:23:41 +00:00
|
|
|
#include <LibGfx/Forward.h>
|
|
|
|
#include <LibGfx/Rect.h>
|
|
|
|
#include <LibGfx/StandardCursor.h>
|
2023-01-12 18:27:34 +00:00
|
|
|
#include <LibWeb/CSS/PreferredColorScheme.h>
|
2022-12-18 00:50:53 +00:00
|
|
|
#include <LibWeb/CSS/Selector.h>
|
2022-10-05 13:23:41 +00:00
|
|
|
#include <LibWeb/Forward.h>
|
2023-03-20 22:39:20 +00:00
|
|
|
#include <LibWeb/HTML/ActivateTab.h>
|
2023-01-31 13:45:11 +00:00
|
|
|
#include <LibWebView/ViewImplementation.h>
|
2022-10-05 13:23:41 +00:00
|
|
|
#include <QAbstractScrollArea>
|
|
|
|
#include <QPointer>
|
2023-04-29 14:49:18 +00:00
|
|
|
#include <QUrl>
|
2022-10-05 13:23:41 +00:00
|
|
|
|
|
|
|
class QTextEdit;
|
|
|
|
class QLineEdit;
|
|
|
|
|
|
|
|
namespace WebView {
|
|
|
|
class WebContentClient;
|
|
|
|
}
|
|
|
|
|
|
|
|
using WebView::WebContentClient;
|
|
|
|
|
2023-08-02 17:52:59 +00:00
|
|
|
namespace Ladybird {
|
|
|
|
|
2022-10-05 13:23:41 +00:00
|
|
|
class Tab;
|
|
|
|
|
|
|
|
class WebContentView final
|
|
|
|
: public QAbstractScrollArea
|
|
|
|
, public WebView::ViewImplementation {
|
|
|
|
Q_OBJECT
|
|
|
|
public:
|
2023-08-07 14:44:20 +00:00
|
|
|
explicit WebContentView(StringView webdriver_content_ipc_path, WebView::EnableCallgrindProfiling, UseLagomNetworking);
|
2022-10-05 13:23:41 +00:00
|
|
|
virtual ~WebContentView() override;
|
|
|
|
|
2023-03-23 00:24:15 +00:00
|
|
|
Function<String(const AK::URL&, Web::HTML::ActivateTab)> on_tab_open_request;
|
2022-10-05 13:23:41 +00:00
|
|
|
|
|
|
|
virtual void paintEvent(QPaintEvent*) override;
|
|
|
|
virtual void resizeEvent(QResizeEvent*) override;
|
2023-07-01 06:12:42 +00:00
|
|
|
virtual void wheelEvent(QWheelEvent*) override;
|
2022-10-05 13:23:41 +00:00
|
|
|
virtual void mouseMoveEvent(QMouseEvent*) override;
|
|
|
|
virtual void mousePressEvent(QMouseEvent*) override;
|
|
|
|
virtual void mouseReleaseEvent(QMouseEvent*) override;
|
2023-05-13 14:55:10 +00:00
|
|
|
virtual void mouseDoubleClickEvent(QMouseEvent*) override;
|
2023-01-07 16:40:04 +00:00
|
|
|
virtual void dragEnterEvent(QDragEnterEvent*) override;
|
|
|
|
virtual void dropEvent(QDropEvent*) override;
|
2022-10-05 13:23:41 +00:00
|
|
|
virtual void keyPressEvent(QKeyEvent* event) override;
|
|
|
|
virtual void keyReleaseEvent(QKeyEvent* event) override;
|
|
|
|
virtual void showEvent(QShowEvent*) override;
|
|
|
|
virtual void hideEvent(QHideEvent*) override;
|
2022-10-11 09:38:03 +00:00
|
|
|
virtual void focusInEvent(QFocusEvent*) override;
|
|
|
|
virtual void focusOutEvent(QFocusEvent*) override;
|
2022-10-11 15:17:49 +00:00
|
|
|
virtual bool event(QEvent*) override;
|
2022-10-05 13:23:41 +00:00
|
|
|
|
2023-01-27 09:41:24 +00:00
|
|
|
ErrorOr<String> dump_layout_tree();
|
|
|
|
|
2023-01-30 20:38:19 +00:00
|
|
|
void set_viewport_rect(Gfx::IntRect);
|
2023-03-08 20:57:24 +00:00
|
|
|
void set_window_size(Gfx::IntSize);
|
|
|
|
void set_window_position(Gfx::IntPoint);
|
2023-01-30 20:38:19 +00:00
|
|
|
|
2023-04-23 01:57:08 +00:00
|
|
|
enum class PaletteMode {
|
|
|
|
Default,
|
|
|
|
Dark,
|
|
|
|
};
|
|
|
|
void update_palette(PaletteMode = PaletteMode::Default);
|
|
|
|
|
2022-12-06 21:58:17 +00:00
|
|
|
virtual void notify_server_did_layout(Badge<WebContentClient>, Gfx::IntSize content_size) override;
|
2023-05-14 16:53:29 +00:00
|
|
|
virtual void notify_server_did_paint(Badge<WebContentClient>, i32 bitmap_id, Gfx::IntSize) override;
|
2022-10-05 13:23:41 +00:00
|
|
|
virtual void notify_server_did_invalidate_content_rect(Badge<WebContentClient>, Gfx::IntRect const&) override;
|
|
|
|
virtual void notify_server_did_change_selection(Badge<WebContentClient>) override;
|
|
|
|
virtual void notify_server_did_request_cursor_change(Badge<WebContentClient>, Gfx::StandardCursor cursor) override;
|
|
|
|
virtual void notify_server_did_request_scroll(Badge<WebContentClient>, i32, i32) override;
|
2022-12-06 22:00:08 +00:00
|
|
|
virtual void notify_server_did_request_scroll_to(Badge<WebContentClient>, Gfx::IntPoint) override;
|
2022-10-05 13:23:41 +00:00
|
|
|
virtual void notify_server_did_request_scroll_into_view(Badge<WebContentClient>, Gfx::IntRect const&) override;
|
2022-12-06 22:00:08 +00:00
|
|
|
virtual void notify_server_did_enter_tooltip_area(Badge<WebContentClient>, Gfx::IntPoint, DeprecatedString const&) override;
|
2022-10-05 13:23:41 +00:00
|
|
|
virtual void notify_server_did_leave_tooltip_area(Badge<WebContentClient>) override;
|
2023-03-13 21:30:51 +00:00
|
|
|
virtual void notify_server_did_request_alert(Badge<WebContentClient>, String const& message) override;
|
|
|
|
virtual void notify_server_did_request_confirm(Badge<WebContentClient>, String const& message) override;
|
|
|
|
virtual void notify_server_did_request_prompt(Badge<WebContentClient>, String const& message, String const& default_) override;
|
|
|
|
virtual void notify_server_did_request_set_prompt_text(Badge<WebContentClient>, String const& message) override;
|
2022-11-16 14:06:47 +00:00
|
|
|
virtual void notify_server_did_request_accept_dialog(Badge<WebContentClient>) override;
|
|
|
|
virtual void notify_server_did_request_dismiss_dialog(Badge<WebContentClient>) override;
|
2022-12-04 18:43:54 +00:00
|
|
|
virtual void notify_server_did_request_file(Badge<WebContentClient>, DeprecatedString const& path, i32) override;
|
2022-11-21 16:36:26 +00:00
|
|
|
virtual void notify_server_did_finish_handling_input_event(bool event_was_accepted) override;
|
2022-10-05 13:23:41 +00:00
|
|
|
|
|
|
|
signals:
|
2023-01-07 16:40:04 +00:00
|
|
|
void urls_dropped(QList<QUrl> const&);
|
2022-10-05 13:23:41 +00:00
|
|
|
|
|
|
|
private:
|
2023-01-12 19:27:17 +00:00
|
|
|
// ^WebView::ViewImplementation
|
2023-07-22 10:41:25 +00:00
|
|
|
virtual void create_client(WebView::EnableCallgrindProfiling = WebView::EnableCallgrindProfiling::No) override;
|
2023-01-12 19:49:49 +00:00
|
|
|
virtual void update_zoom() override;
|
2023-05-15 05:59:51 +00:00
|
|
|
virtual Gfx::IntRect viewport_rect() const override;
|
2023-05-17 14:12:13 +00:00
|
|
|
virtual Gfx::IntPoint to_content_position(Gfx::IntPoint widget_position) const override;
|
|
|
|
virtual Gfx::IntPoint to_widget_position(Gfx::IntPoint content_position) const override;
|
2023-01-12 19:27:17 +00:00
|
|
|
|
2022-10-05 13:23:41 +00:00
|
|
|
void update_viewport_rect();
|
2023-05-14 16:57:14 +00:00
|
|
|
|
2022-10-05 13:23:41 +00:00
|
|
|
qreal m_inverse_pixel_scaling_ratio { 1.0 };
|
|
|
|
bool m_should_show_line_box_borders { false };
|
2023-08-01 20:39:19 +00:00
|
|
|
UseLagomNetworking m_use_lagom_networking {};
|
2022-10-05 13:23:41 +00:00
|
|
|
|
2022-11-16 14:06:47 +00:00
|
|
|
QPointer<QDialog> m_dialog;
|
2022-10-05 13:23:41 +00:00
|
|
|
|
|
|
|
Gfx::IntRect m_viewport_rect;
|
|
|
|
|
2022-12-15 14:18:52 +00:00
|
|
|
StringView m_webdriver_content_ipc_path;
|
2022-10-05 13:23:41 +00:00
|
|
|
};
|
2023-08-02 17:52:59 +00:00
|
|
|
|
|
|
|
}
|