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>
|
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-12-01 17:18:40 +00:00
|
|
|
WebContentView(WebContentOptions const&, StringView webdriver_content_ipc_path);
|
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-12-13 18:10:05 +00:00
|
|
|
void set_device_pixel_ratio(double);
|
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-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-12-01 17:18:40 +00:00
|
|
|
virtual void create_client() override;
|
2023-01-12 19:49:49 +00:00
|
|
|
virtual void update_zoom() override;
|
2023-12-14 06:17:00 +00:00
|
|
|
virtual Web::DevicePixelRect 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-08-23 14:43:27 +00:00
|
|
|
void update_cursor(Gfx::StandardCursor cursor);
|
2023-05-14 16:57:14 +00:00
|
|
|
|
2022-10-05 13:23:41 +00:00
|
|
|
bool m_should_show_line_box_borders { false };
|
|
|
|
|
|
|
|
Gfx::IntRect m_viewport_rect;
|
|
|
|
|
2023-12-01 17:18:40 +00:00
|
|
|
WebContentOptions m_web_content_options;
|
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
|
|
|
|
|
|
|
}
|