1
Fork 0
mirror of https://github.com/RGBCube/serenity synced 2025-07-27 03:07:36 +00:00

LibWeb: Refactor int types in WebContentServer to DevicePixels

This commit is contained in:
Bastiaan van der Plaat 2023-12-14 07:17:00 +01:00 committed by Alexander Kalenik
parent 8730e56f62
commit c069ab1ca0
18 changed files with 169 additions and 69 deletions

View file

@ -107,7 +107,7 @@ void ConnectionFromClient::update_system_fonts(DeprecatedString const& default_f
Gfx::FontDatabase::set_window_title_font_query(window_title_font_query);
}
void ConnectionFromClient::update_screen_rects(Vector<Gfx::IntRect> const& rects, u32 main_screen)
void ConnectionFromClient::update_screen_rects(Vector<Web::DevicePixelRect> const& rects, u32 main_screen)
{
page().set_screen_rects(rects, main_screen);
}
@ -135,10 +135,10 @@ void ConnectionFromClient::load_html(DeprecatedString const& html)
page().page().load_html(html);
}
void ConnectionFromClient::set_viewport_rect(Gfx::IntRect const& rect)
void ConnectionFromClient::set_viewport_rect(Web::DevicePixelRect const& rect)
{
dbgln_if(SPAM_DEBUG, "handle: WebContentServer::SetViewportRect: rect={}", rect);
page().set_viewport_rect(rect.to_type<Web::DevicePixels>());
page().set_viewport_rect(rect);
}
void ConnectionFromClient::add_backing_store(i32 backing_store_id, Gfx::ShareableBitmap const& bitmap)
@ -152,7 +152,7 @@ void ConnectionFromClient::remove_backing_store(i32 backing_store_id)
m_pending_paint_requests.remove_all_matching([backing_store_id](auto& pending_repaint_request) { return pending_repaint_request.bitmap_id == backing_store_id; });
}
void ConnectionFromClient::paint(Gfx::IntRect const& content_rect, i32 backing_store_id)
void ConnectionFromClient::paint(Web::DevicePixelRect const& content_rect, i32 backing_store_id)
{
for (auto& pending_paint : m_pending_paint_requests) {
if (pending_paint.bitmap_id == backing_store_id) {
@ -175,8 +175,8 @@ void ConnectionFromClient::paint(Gfx::IntRect const& content_rect, i32 backing_s
void ConnectionFromClient::flush_pending_paint_requests()
{
for (auto& pending_paint : m_pending_paint_requests) {
page().paint(pending_paint.content_rect.to_type<Web::DevicePixels>(), *pending_paint.bitmap);
async_did_paint(pending_paint.content_rect, pending_paint.bitmap_id);
page().paint(pending_paint.content_rect, *pending_paint.bitmap);
async_did_paint(pending_paint.content_rect.to_type<int>(), pending_paint.bitmap_id);
}
m_pending_paint_requests.clear();
}
@ -981,14 +981,14 @@ void ConnectionFromClient::set_device_pixels_per_css_pixel(float device_pixels_p
page().set_device_pixels_per_css_pixel(device_pixels_per_css_pixel);
}
void ConnectionFromClient::set_window_position(Gfx::IntPoint position)
void ConnectionFromClient::set_window_position(Web::DevicePixelPoint position)
{
page().set_window_position(position.to_type<Web::DevicePixels>());
page().set_window_position(position);
}
void ConnectionFromClient::set_window_size(Gfx::IntSize size)
void ConnectionFromClient::set_window_size(Web::DevicePixelSize size)
{
page().set_window_size(size.to_type<Web::DevicePixels>());
page().set_window_size(size);
}
Messages::WebContentServer::GetLocalStorageEntriesResponse ConnectionFromClient::get_local_storage_entries()

View file

@ -55,11 +55,11 @@ private:
virtual void connect_to_webdriver(DeprecatedString const& webdriver_ipc_path) override;
virtual void update_system_theme(Core::AnonymousBuffer const&) override;
virtual void update_system_fonts(DeprecatedString const&, DeprecatedString const&, DeprecatedString const&) override;
virtual void update_screen_rects(Vector<Gfx::IntRect> const&, u32) override;
virtual void update_screen_rects(Vector<Web::DevicePixelRect> const&, u32) override;
virtual void load_url(URL const&) override;
virtual void load_html(DeprecatedString const&) override;
virtual void paint(Gfx::IntRect const&, i32) override;
virtual void set_viewport_rect(Gfx::IntRect const&) override;
virtual void paint(Web::DevicePixelRect const&, i32) override;
virtual void set_viewport_rect(Web::DevicePixelRect const&) override;
virtual void mouse_down(Gfx::IntPoint, Gfx::IntPoint, unsigned, unsigned, unsigned) override;
virtual void mouse_move(Gfx::IntPoint, Gfx::IntPoint, unsigned, unsigned, unsigned) override;
virtual void mouse_up(Gfx::IntPoint, Gfx::IntPoint, unsigned, unsigned, unsigned) override;
@ -97,8 +97,8 @@ private:
virtual void set_has_focus(bool) override;
virtual void set_is_scripting_enabled(bool) override;
virtual void set_device_pixels_per_css_pixel(float) override;
virtual void set_window_position(Gfx::IntPoint) override;
virtual void set_window_size(Gfx::IntSize) override;
virtual void set_window_position(Web::DevicePixelPoint) override;
virtual void set_window_size(Web::DevicePixelSize) override;
virtual void handle_file_return(i32 error, Optional<IPC::File> const& file, i32 request_id) override;
virtual void set_system_visibility_state(bool visible) override;
@ -138,7 +138,7 @@ private:
NonnullOwnPtr<PageHost> m_page_host;
struct PaintRequest {
Gfx::IntRect content_rect;
Web::DevicePixelRect content_rect;
NonnullRefPtr<Gfx::Bitmap> bitmap;
i32 bitmap_id { -1 };
};

View file

@ -33,7 +33,7 @@ public:
void set_palette_impl(Gfx::PaletteImpl&);
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_rects(Vector<Web::DevicePixelRect, 4> const& rects, size_t main_screen_index) { m_screen_rect = rects[main_screen_index]; }
void set_device_pixels_per_css_pixel(float device_pixels_per_css_pixel) { m_device_pixels_per_css_pixel = 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; }

View file

@ -17,7 +17,7 @@ endpoint WebContentServer
update_system_theme(Core::AnonymousBuffer theme_buffer) =|
update_system_fonts(DeprecatedString default_font_query, DeprecatedString fixed_width_font_query, DeprecatedString window_title_font_query) =|
update_screen_rects(Vector<Gfx::IntRect> rects, u32 main_screen_index) =|
update_screen_rects(Vector<Web::DevicePixelRect> rects, u32 main_screen_index) =|
load_url(URL url) =|
load_html(DeprecatedString html) =|
@ -25,8 +25,8 @@ endpoint WebContentServer
add_backing_store(i32 backing_store_id, Gfx::ShareableBitmap bitmap) =|
remove_backing_store(i32 backing_store_id) =|
paint(Gfx::IntRect content_rect, i32 backing_store_id) =|
set_viewport_rect(Gfx::IntRect rect) =|
paint(Web::DevicePixelRect content_rect, i32 backing_store_id) =|
set_viewport_rect(Web::DevicePixelRect rect) =|
mouse_down(Gfx::IntPoint position, Gfx::IntPoint screen_position, unsigned button, unsigned buttons, unsigned modifiers) =|
mouse_move(Gfx::IntPoint position, Gfx::IntPoint screen_position, unsigned button, unsigned buttons, unsigned modifiers) =|
@ -79,8 +79,8 @@ endpoint WebContentServer
set_is_scripting_enabled(bool is_scripting_enabled) =|
set_device_pixels_per_css_pixel(float device_pixels_per_css_pixel) =|
set_window_position(Gfx::IntPoint position) =|
set_window_size(Gfx::IntSize size) =|
set_window_position(Web::DevicePixelPoint position) =|
set_window_size(Web::DevicePixelSize size) =|
get_local_storage_entries() => (OrderedHashMap<String,String> entries)
get_session_storage_entries() => (OrderedHashMap<String,String> entries)