1
Fork 0
mirror of https://github.com/RGBCube/serenity synced 2025-07-28 13:37:45 +00:00

Ladybird+LibWebView: Migrate layout notification to LibWebView callbacks

This commit is contained in:
Timothy Flynn 2023-08-23 10:33:26 -04:00 committed by Tim Flynn
parent 682a5f9b70
commit bf464665a7
10 changed files with 19 additions and 34 deletions

View file

@ -164,9 +164,9 @@ struct HideCursor {
- (void)setWebViewCallbacks
{
m_web_view_bridge->on_layout = [self](auto content_size) {
auto ns_content_size = Ladybird::gfx_size_to_ns_size(content_size);
[[self documentView] setFrameSize:ns_content_size];
m_web_view_bridge->on_did_layout = [self](auto content_size) {
auto inverse_device_pixel_ratio = m_web_view_bridge->inverse_device_pixel_ratio();
[[self documentView] setFrameSize:NSMakeSize(content_size.width() * inverse_device_pixel_ratio, content_size.height() * inverse_device_pixel_ratio)];
};
m_web_view_bridge->on_ready_to_paint = [self]() {

View file

@ -104,14 +104,6 @@ Optional<WebViewBridge::Paintable> WebViewBridge::paintable()
return Paintable { *bitmap, bitmap_size };
}
void WebViewBridge::notify_server_did_layout(Badge<WebView::WebContentClient>, Gfx::IntSize content_size)
{
if (on_layout) {
content_size = scale_for_device(content_size, m_inverse_device_pixel_ratio);
on_layout(content_size);
}
}
void WebViewBridge::notify_server_did_request_cursor_change(Badge<WebView::WebContentClient>, Gfx::StandardCursor cursor)
{
if (on_cursor_change)

View file

@ -49,8 +49,6 @@ public:
};
Optional<Paintable> paintable();
Function<void(Gfx::IntSize)> on_layout;
Function<void(Gfx::IntPoint)> on_scroll;
Function<void(Gfx::StandardCursor)> on_cursor_change;
@ -61,7 +59,6 @@ public:
private:
WebViewBridge(Vector<Gfx::IntRect> screen_rects, float device_pixel_ratio, Optional<StringView> webdriver_content_ipc_path);
virtual void notify_server_did_layout(Badge<WebView::WebContentClient>, Gfx::IntSize content_size) override;
virtual void notify_server_did_request_cursor_change(Badge<WebView::WebContentClient>, Gfx::StandardCursor cursor) override;
virtual void notify_server_did_request_scroll(Badge<WebView::WebContentClient>, i32, i32) override;
virtual void notify_server_did_request_scroll_to(Badge<WebView::WebContentClient>, Gfx::IntPoint) override;