diff options
author | Andreas Kling <kling@serenityos.org> | 2023-01-09 18:55:22 +0100 |
---|---|---|
committer | Linus Groh <mail@linusgroh.de> | 2023-01-09 22:34:57 +0000 |
commit | ed3c2cbdf6e29e545fabfb862bbbbfaf05bb1ad6 (patch) | |
tree | 8602edbc0a427ceaea12682006fe6ae8c4f0372f | |
parent | c55739bbc02f01bef58849c844eb8d3c3ce74fcf (diff) | |
download | serenity-ed3c2cbdf6e29e545fabfb862bbbbfaf05bb1ad6.zip |
LibWebView: Add OOPWV "content scales to viewport" hint
By setting this hint, you indicate to OOPWV that the content inside will
scale itself to the viewport size. In such situations, it's fine for
OOPWV to reuse a scaled version of an outdated backing store while the
view is being resized.
-rw-r--r-- | Userland/Libraries/LibWebView/OutOfProcessWebView.cpp | 10 | ||||
-rw-r--r-- | Userland/Libraries/LibWebView/OutOfProcessWebView.h | 6 |
2 files changed, 15 insertions, 1 deletions
diff --git a/Userland/Libraries/LibWebView/OutOfProcessWebView.cpp b/Userland/Libraries/LibWebView/OutOfProcessWebView.cpp index 1f0dd054f1..c00662ae96 100644 --- a/Userland/Libraries/LibWebView/OutOfProcessWebView.cpp +++ b/Userland/Libraries/LibWebView/OutOfProcessWebView.cpp @@ -106,7 +106,10 @@ void OutOfProcessWebView::paint_event(GUI::PaintEvent& event) if (auto* bitmap = m_client_state.has_usable_bitmap ? m_client_state.front_bitmap.bitmap.ptr() : m_backup_bitmap.ptr()) { painter.add_clip_rect(frame_inner_rect()); painter.translate(frame_thickness(), frame_thickness()); - painter.blit({ 0, 0 }, *bitmap, bitmap->rect()); + if (m_content_scales_to_viewport) + painter.draw_scaled_bitmap(rect(), *bitmap, bitmap->rect()); + else + painter.blit({ 0, 0 }, *bitmap, bitmap->rect()); return; } @@ -841,4 +844,9 @@ void OutOfProcessWebView::notify_server_did_get_accessibility_tree(DeprecatedStr on_get_accessibility_tree(accessibility_tree); } +void OutOfProcessWebView::set_content_scales_to_viewport(bool b) +{ + m_content_scales_to_viewport = b; +} + } diff --git a/Userland/Libraries/LibWebView/OutOfProcessWebView.h b/Userland/Libraries/LibWebView/OutOfProcessWebView.h index f7f761e29d..935af25e89 100644 --- a/Userland/Libraries/LibWebView/OutOfProcessWebView.h +++ b/Userland/Libraries/LibWebView/OutOfProcessWebView.h @@ -80,6 +80,10 @@ public: Gfx::ShareableBitmap take_screenshot() const; Gfx::ShareableBitmap take_document_screenshot(); + // This is a hint that tells OOPWV that the content will scale to the viewport size. + // In practice, this means that OOPWV may render scaled stale versions of the content while resizing. + void set_content_scales_to_viewport(bool); + Function<void(Gfx::IntPoint screen_position)> on_context_menu_request; Function<void(const AK::URL&, DeprecatedString const& target, unsigned modifiers)> on_link_click; Function<void(const AK::URL&, Gfx::IntPoint screen_position)> on_link_context_menu_request; @@ -225,6 +229,8 @@ private: bool m_is_awaiting_response_for_input_event { false }; Queue<InputEvent> m_pending_input_events; + + bool m_content_scales_to_viewport { false }; }; } |