summaryrefslogtreecommitdiff
path: root/Userland
diff options
context:
space:
mode:
authorTimothy Flynn <trflynn89@pm.me>2023-05-17 10:12:13 -0400
committerAndreas Kling <kling@serenityos.org>2023-05-17 19:47:05 +0200
commit2d51b8c286400aa5ef3f3872aa0596880885b7f2 (patch)
tree87624ca2961fcc87bcc9ea1f61d7b8398230356e /Userland
parent31d7565cf327767c4a986a5c2500798fc6104010 (diff)
downloadserenity-2d51b8c286400aa5ef3f3872aa0596880885b7f2.zip
Browser+Ladybird+LibWebView: Virtualize computing content/widget points
This will allow moving some copy-pasted functionality from web view implementations to the base LibWebView class.
Diffstat (limited to 'Userland')
-rw-r--r--Userland/Libraries/LibWebView/OutOfProcessWebView.cpp10
-rw-r--r--Userland/Libraries/LibWebView/OutOfProcessWebView.h2
-rw-r--r--Userland/Libraries/LibWebView/ViewImplementation.h2
-rw-r--r--Userland/Utilities/headless-browser.cpp2
4 files changed, 16 insertions, 0 deletions
diff --git a/Userland/Libraries/LibWebView/OutOfProcessWebView.cpp b/Userland/Libraries/LibWebView/OutOfProcessWebView.cpp
index a65256f91b..484206e6d9 100644
--- a/Userland/Libraries/LibWebView/OutOfProcessWebView.cpp
+++ b/Userland/Libraries/LibWebView/OutOfProcessWebView.cpp
@@ -90,6 +90,16 @@ Gfx::IntRect OutOfProcessWebView::viewport_rect() const
return visible_content_rect();
}
+Gfx::IntPoint OutOfProcessWebView::to_content_position(Gfx::IntPoint widget_position) const
+{
+ return GUI::AbstractScrollableWidget::to_content_position(widget_position);
+}
+
+Gfx::IntPoint OutOfProcessWebView::to_widget_position(Gfx::IntPoint content_position) const
+{
+ return GUI::AbstractScrollableWidget::to_widget_position(content_position);
+}
+
void OutOfProcessWebView::update_zoom()
{
client().async_set_device_pixels_per_css_pixel(m_device_pixel_ratio * m_zoom_level);
diff --git a/Userland/Libraries/LibWebView/OutOfProcessWebView.h b/Userland/Libraries/LibWebView/OutOfProcessWebView.h
index 1be13f44a7..8fef61e714 100644
--- a/Userland/Libraries/LibWebView/OutOfProcessWebView.h
+++ b/Userland/Libraries/LibWebView/OutOfProcessWebView.h
@@ -179,6 +179,8 @@ private:
virtual void notify_server_did_finish_handling_input_event(bool event_was_accepted) override;
virtual Gfx::IntRect viewport_rect() const override;
+ virtual Gfx::IntPoint to_content_position(Gfx::IntPoint widget_position) const override;
+ virtual Gfx::IntPoint to_widget_position(Gfx::IntPoint content_position) const override;
using InputEvent = Variant<GUI::KeyEvent, GUI::MouseEvent>;
void enqueue_input_event(InputEvent const&);
diff --git a/Userland/Libraries/LibWebView/ViewImplementation.h b/Userland/Libraries/LibWebView/ViewImplementation.h
index 75ca656d5b..3af0c8f097 100644
--- a/Userland/Libraries/LibWebView/ViewImplementation.h
+++ b/Userland/Libraries/LibWebView/ViewImplementation.h
@@ -136,6 +136,8 @@ public:
virtual void notify_server_did_finish_handling_input_event(bool event_was_accepted) = 0;
virtual Gfx::IntRect viewport_rect() const = 0;
+ virtual Gfx::IntPoint to_content_position(Gfx::IntPoint widget_position) const = 0;
+ virtual Gfx::IntPoint to_widget_position(Gfx::IntPoint content_position) const = 0;
protected:
static constexpr auto ZOOM_MIN_LEVEL = 0.3f;
diff --git a/Userland/Utilities/headless-browser.cpp b/Userland/Utilities/headless-browser.cpp
index 75a1ffa299..a0ab097a7a 100644
--- a/Userland/Utilities/headless-browser.cpp
+++ b/Userland/Utilities/headless-browser.cpp
@@ -158,6 +158,8 @@ private:
void create_client(WebView::EnableCallgrindProfiling) override { }
virtual Gfx::IntRect viewport_rect() const override { return m_viewport_rect; }
+ virtual Gfx::IntPoint to_content_position(Gfx::IntPoint widget_position) const override { return widget_position; }
+ virtual Gfx::IntPoint to_widget_position(Gfx::IntPoint content_position) const override { return content_position; }
private:
Gfx::IntRect m_viewport_rect;