1
Fork 0
mirror of https://github.com/RGBCube/serenity synced 2025-05-26 01:55:08 +00:00

Browser: Implement zoom :^)

Largely based on the Ladybird implementation in 0cc151b.
This commit is contained in:
Linus Groh 2023-01-12 18:31:14 +00:00
parent 966d808135
commit 36866730ce
3 changed files with 60 additions and 0 deletions

View file

@ -159,6 +159,35 @@ void OutOfProcessWebView::handle_resize()
request_repaint();
}
void OutOfProcessWebView::zoom_in()
{
if (m_zoom_level >= ZOOM_MAX_LEVEL)
return;
m_zoom_level += ZOOM_STEP;
update_zoom();
}
void OutOfProcessWebView::zoom_out()
{
if (m_zoom_level <= ZOOM_MIN_LEVEL)
return;
m_zoom_level -= ZOOM_STEP;
update_zoom();
}
void OutOfProcessWebView::reset_zoom()
{
m_zoom_level = 1.0f;
update_zoom();
}
void OutOfProcessWebView::update_zoom()
{
client().async_set_device_pixels_per_css_pixel(m_device_pixel_ratio * m_zoom_level);
// FIXME: Refactor this into separate update_viewport_rect() + request_repaint() like in Ladybird
handle_resize();
}
void OutOfProcessWebView::keydown_event(GUI::KeyEvent& event)
{
enqueue_input_event(event);