1
Fork 0
mirror of https://github.com/RGBCube/serenity synced 2025-05-31 19:38:12 +00:00

Ladybird: Implement content zooming in the AppKit chrome

This lets the user zoom in and out on a web page using the View menu or
keyboard shortcuts. This does not implement zooming with ctrl+scroll.

In the future, it'd be nice to embed the zoom level display inside the
location toolbar. But to do that, we will need to invent our own custom
search field and all of the UI classes (controller, cell, etc.) to draw
the field. So for now, this places the zoom level display to the right
of the location toolbar.
This commit is contained in:
Timothy Flynn 2023-10-07 17:21:00 -04:00 committed by Andreas Kling
parent af7b4609b6
commit 9d31fc3ea3
6 changed files with 105 additions and 1 deletions

View file

@ -70,7 +70,7 @@ WebViewBridge::~WebViewBridge() = default;
void WebViewBridge::set_device_pixel_ratio(float device_pixel_ratio)
{
m_device_pixel_ratio = device_pixel_ratio;
client().async_set_device_pixels_per_css_pixel(device_pixel_ratio);
client().async_set_device_pixels_per_css_pixel(m_device_pixel_ratio * m_zoom_level);
}
void WebViewBridge::set_system_visibility_state(bool is_visible)
@ -158,6 +158,10 @@ Optional<WebViewBridge::Paintable> WebViewBridge::paintable()
void WebViewBridge::update_zoom()
{
client().async_set_device_pixels_per_css_pixel(m_device_pixel_ratio * m_zoom_level);
if (on_zoom_level_changed)
on_zoom_level_changed();
}
Gfx::IntRect WebViewBridge::viewport_rect() const