mirror of
https://github.com/LadybirdBrowser/ladybird.git
synced 2025-08-22 10:19:20 +00:00
LibWeb+UI: Add internals API to set browser zoom
This commit is contained in:
parent
f39433d6b0
commit
5cc9a5802d
Notes:
github-actions[bot]
2025-01-21 15:12:32 +00:00
Author: https://github.com/InvalidUsernameException
Commit: 5cc9a5802d
Pull-request: https://github.com/LadybirdBrowser/ladybird/pull/2982
Reviewed-by: https://github.com/AtkinsSJ
17 changed files with 78 additions and 3 deletions
|
@ -143,6 +143,12 @@ void ViewImplementation::zoom_out()
|
|||
update_zoom();
|
||||
}
|
||||
|
||||
void ViewImplementation::set_zoom(double zoom_level)
|
||||
{
|
||||
m_zoom_level = max(ZOOM_MIN_LEVEL, min(zoom_level, ZOOM_MAX_LEVEL));
|
||||
update_zoom();
|
||||
}
|
||||
|
||||
void ViewImplementation::reset_zoom()
|
||||
{
|
||||
m_zoom_level = 1.0f;
|
||||
|
|
|
@ -64,6 +64,7 @@ public:
|
|||
|
||||
void zoom_in();
|
||||
void zoom_out();
|
||||
void set_zoom(double zoom_level);
|
||||
void reset_zoom();
|
||||
float zoom_level() const { return m_zoom_level; }
|
||||
float device_pixel_ratio() const { return m_device_pixel_ratio; }
|
||||
|
@ -216,6 +217,7 @@ public:
|
|||
Function<void(Web::DragEvent const&)> on_finish_handling_drag_event;
|
||||
Function<void(String const&)> on_text_test_finish;
|
||||
Function<void(double milliseconds)> on_set_test_timeout;
|
||||
Function<void(double factor)> on_set_browser_zoom;
|
||||
Function<void(size_t current_match_index, Optional<size_t> const& total_match_count)> on_find_in_page;
|
||||
Function<void(Gfx::Color)> on_theme_color_change;
|
||||
Function<void(String const&, String const&, String const&)> on_insert_clipboard_entry;
|
||||
|
|
|
@ -101,6 +101,14 @@ void WebContentClient::did_set_test_timeout(u64 page_id, double milliseconds)
|
|||
}
|
||||
}
|
||||
|
||||
void WebContentClient::did_set_browser_zoom(u64 page_id, double factor)
|
||||
{
|
||||
if (auto view = view_for_page_id(page_id); view.has_value()) {
|
||||
if (view->on_set_browser_zoom)
|
||||
view->on_set_browser_zoom(factor);
|
||||
}
|
||||
}
|
||||
|
||||
void WebContentClient::did_find_in_page(u64 page_id, size_t current_match_index, Optional<size_t> const& total_match_count)
|
||||
{
|
||||
if (auto view = view_for_page_id(page_id); view.has_value()) {
|
||||
|
|
|
@ -109,6 +109,7 @@ private:
|
|||
virtual void did_finish_handling_input_event(u64 page_id, Web::EventResult event_result) override;
|
||||
virtual void did_finish_text_test(u64 page_id, String const& text) override;
|
||||
virtual void did_set_test_timeout(u64 page_id, double milliseconds) override;
|
||||
virtual void did_set_browser_zoom(u64 page_id, double factor) override;
|
||||
virtual void did_find_in_page(u64 page_id, size_t current_match_index, Optional<size_t> const& total_match_count) override;
|
||||
virtual void did_change_theme_color(u64 page_id, Gfx::Color color) override;
|
||||
virtual void did_insert_clipboard_entry(u64 page_id, String const& data, String const& presentation_style, String const& mime_type) override;
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue