summaryrefslogtreecommitdiff
path: root/Userland/Services/WebContent
diff options
context:
space:
mode:
authorSam Atkins <atkinssj@serenityos.org>2022-11-03 12:49:54 +0000
committerLinus Groh <mail@linusgroh.de>2023-01-05 17:42:31 +0100
commitaffc8a22ca32b177815c826ec4a3fc25843eaef4 (patch)
tree30e6ceed8fce2cbeab63bb4367cf82b4bd4d9f3f /Userland/Services/WebContent
parent8fb7c32ec32339b2c1890c9094ff9e6687a6b9e5 (diff)
downloadserenity-affc8a22ca32b177815c826ec4a3fc25843eaef4.zip
LibWeb+WebContent: Convert BrowsingContext to new pixel units
This fixes a few glitches. We no longer give the page double the width it should have, and we mark the correct area of the page as needing repainting.
Diffstat (limited to 'Userland/Services/WebContent')
-rw-r--r--Userland/Services/WebContent/ConnectionFromClient.cpp6
-rw-r--r--Userland/Services/WebContent/PageHost.cpp8
-rw-r--r--Userland/Services/WebContent/PageHost.h6
-rw-r--r--Userland/Services/WebContent/WebDriverConnection.cpp4
4 files changed, 12 insertions, 12 deletions
diff --git a/Userland/Services/WebContent/ConnectionFromClient.cpp b/Userland/Services/WebContent/ConnectionFromClient.cpp
index 8032dd58d9..b2e664667e 100644
--- a/Userland/Services/WebContent/ConnectionFromClient.cpp
+++ b/Userland/Services/WebContent/ConnectionFromClient.cpp
@@ -112,7 +112,7 @@ void ConnectionFromClient::load_html(DeprecatedString const& html, const URL& ur
void ConnectionFromClient::set_viewport_rect(Gfx::IntRect const& rect)
{
dbgln_if(SPAM_DEBUG, "handle: WebContentServer::SetViewportRect: rect={}", rect);
- m_page_host->set_viewport_rect(rect);
+ m_page_host->set_viewport_rect(rect.to_type<Web::DevicePixels>());
}
void ConnectionFromClient::add_backing_store(i32 backing_store_id, Gfx::ShareableBitmap const& bitmap)
@@ -532,12 +532,12 @@ void ConnectionFromClient::set_is_scripting_enabled(bool is_scripting_enabled)
void ConnectionFromClient::set_window_position(Gfx::IntPoint position)
{
- m_page_host->set_window_position(position);
+ m_page_host->set_window_position(position.to_type<Web::DevicePixels>());
}
void ConnectionFromClient::set_window_size(Gfx::IntSize size)
{
- m_page_host->set_window_size(size);
+ m_page_host->set_window_size(size.to_type<Web::DevicePixels>());
}
Messages::WebContentServer::GetLocalStorageEntriesResponse ConnectionFromClient::get_local_storage_entries()
diff --git a/Userland/Services/WebContent/PageHost.cpp b/Userland/Services/WebContent/PageHost.cpp
index 3134ece247..d64d893206 100644
--- a/Userland/Services/WebContent/PageHost.cpp
+++ b/Userland/Services/WebContent/PageHost.cpp
@@ -79,12 +79,12 @@ void PageHost::set_is_scripting_enabled(bool is_scripting_enabled)
page().set_is_scripting_enabled(is_scripting_enabled);
}
-void PageHost::set_window_position(Gfx::IntPoint position)
+void PageHost::set_window_position(Web::DevicePixelPoint position)
{
page().set_window_position(position);
}
-void PageHost::set_window_size(Gfx::IntSize size)
+void PageHost::set_window_size(Web::DevicePixelSize size)
{
page().set_window_size(size);
}
@@ -125,9 +125,9 @@ void PageHost::paint(Web::DevicePixelRect const& content_rect, Gfx::Bitmap& targ
layout_root->paint_all_phases(context);
}
-void PageHost::set_viewport_rect(Gfx::IntRect const& rect)
+void PageHost::set_viewport_rect(Web::DevicePixelRect const& rect)
{
- page().top_level_browsing_context().set_viewport_rect(rect);
+ page().top_level_browsing_context().set_viewport_rect(page().device_to_css_rect(rect));
}
void PageHost::page_did_invalidate(Web::CSSPixelRect const& content_rect)
diff --git a/Userland/Services/WebContent/PageHost.h b/Userland/Services/WebContent/PageHost.h
index fb0054226d..1950b4635c 100644
--- a/Userland/Services/WebContent/PageHost.h
+++ b/Userland/Services/WebContent/PageHost.h
@@ -30,15 +30,15 @@ public:
virtual void paint(Web::DevicePixelRect const& content_rect, Gfx::Bitmap&) override;
void set_palette_impl(Gfx::PaletteImpl const&);
- void set_viewport_rect(Gfx::IntRect const&);
+ void set_viewport_rect(Web::DevicePixelRect const&);
void set_screen_rects(Vector<Gfx::IntRect, 4> const& rects, size_t main_screen_index) { m_screen_rect = rects[main_screen_index].to_type<Web::DevicePixels>(); }
void set_screen_display_scale(float device_pixels_per_css_pixel) { m_screen_display_scale = device_pixels_per_css_pixel; }
void set_preferred_color_scheme(Web::CSS::PreferredColorScheme);
void set_should_show_line_box_borders(bool b) { m_should_show_line_box_borders = b; }
void set_has_focus(bool);
void set_is_scripting_enabled(bool);
- void set_window_position(Gfx::IntPoint);
- void set_window_size(Gfx::IntSize);
+ void set_window_position(Web::DevicePixelPoint);
+ void set_window_size(Web::DevicePixelSize);
Web::DevicePixelSize content_size() const { return m_content_size; }
diff --git a/Userland/Services/WebContent/WebDriverConnection.cpp b/Userland/Services/WebContent/WebDriverConnection.cpp
index 04a63f1b1b..b30b26d91b 100644
--- a/Userland/Services/WebContent/WebDriverConnection.cpp
+++ b/Userland/Services/WebContent/WebDriverConnection.cpp
@@ -606,7 +606,7 @@ Messages::WebDriverClient::SetWindowRectResponse WebDriverConnection::set_window
auto size = m_page_client.page_did_request_resize_window({ *width, *height });
window_rect.set_size(size);
} else {
- window_rect.set_size(m_page_client.page().window_size());
+ window_rect.set_size(m_page_client.page().window_size().to_type<int>());
}
// 12. If x and y are not null:
@@ -615,7 +615,7 @@ Messages::WebDriverClient::SetWindowRectResponse WebDriverConnection::set_window
auto position = m_page_client.page_did_request_reposition_window({ *x, *y });
window_rect.set_location(position);
} else {
- window_rect.set_location(m_page_client.page().window_position());
+ window_rect.set_location(m_page_client.page().window_position().to_type<int>());
}
// 14. Return success with data set to the WindowRect object for the current top-level browsing context.