mirror of
https://github.com/fergalmoran/ladybird.git
synced 2026-01-06 16:45:03 +00:00
Browser: Implement zoom :^)
Largely based on the Ladybird implementation in 0cc151b.
This commit is contained in:
@@ -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);
|
||||
|
||||
Reference in New Issue
Block a user