Truly independent web browser
Compositor: Keep pinch steps at the scale limit in the compositor
Andreas Klingb7ceb385641e
diff --git a/Services/Compositor/ContextState.cpp b/Services/Compositor/ContextState.cppindex 5d55751abeb..9786e208e43 100644--- a/Services/Compositor/ContextState.cpp+++ b/Services/Compositor/ContextState.cpp@@ -685,9 +685,11 @@ ContextState::ContextUpdateResult ContextState::handle_pinch_event(Web::PinchEveif (!m_scene.visual_context_tree().has_value())return {};+ // NB: A step with nothing to zoom, as at a limit of the scale, is the compositor's all the same: the main thread,+ // whose scale may lag behind, must not zoom for it.auto scale = 1.0 + event.scale_delta;if (scale == 1.0)- return {};+ return { .accepted = true };auto transform = m_scene.visual_viewport_transform();auto old_scale = transform.matrix[0, 0];@@ -697,7 +699,7 @@ ContextState::ContextUpdateResult ContextState::handle_pinch_event(Web::PinchEveauto new_scale = clamp(static_cast<double>(old_scale) * scale, 1.0, 5.0);auto applied_scale = static_cast<float>(new_scale / old_scale);if (applied_scale == 1.0f)- return {};+ return { .accepted = true };auto position = Gfx::FloatPoint {static_cast<float>(event.position.x().value()),diff --git a/Tests/Compositor/TestContextState.cpp b/Tests/Compositor/TestContextState.cppindex a9f239d79e8..3fdad8e495a 100644--- a/Tests/Compositor/TestContextState.cpp+++ b/Tests/Compositor/TestContextState.cpp@@ -70,8 +70,10 @@ TEST_CASE(pinch_zoom_of_a_page_without_scroll_nodes_survives_a_display_list_updaEXPECT(context.handle_pinch_event(pinch_event(4.0)).accepted);install_display_list_without_scroll_nodes(context);- // The zoom is still at its maximum, so zooming in further does nothing.- EXPECT(!context.handle_pinch_event(pinch_event(1.0)).accepted);+ // The zoom is still at its maximum, so zooming in further has nothing to present.+ auto result = context.handle_pinch_event(pinch_event(1.0));+ EXPECT(result.accepted);+ EXPECT(!result.frame_to_present.has_value());}TEST_CASE(pinch_zoom_is_reported_on_the_visual_viewport)@@ -103,7 +105,9 @@ TEST_CASE(pinch_zoom_is_presented_until_the_main_thread_asks_for_another)// A display list the main thread recorded without the zoom keeps it at its maximum.EXPECT(context.handle_pinch_event(pinch_event(4.0)).accepted);install_display_list_without_scroll_nodes(context);- EXPECT(!context.handle_pinch_event(pinch_event(1.0)).accepted);+ auto result_at_maximum = context.handle_pinch_event(pinch_event(1.0));+ EXPECT(result_at_maximum.accepted);+ EXPECT(!result_at_maximum.frame_to_present.has_value());// A request of the main thread's own, such as resetting the zoom, is what moves the visual viewport from there.Compositing::ScrollRequest reset_zoom {@@ -118,7 +122,7 @@ TEST_CASE(pinch_zoom_is_presented_until_the_main_thread_asks_for_another).takes_over_from_momentum = false,};(void)context.apply_scroll_requests({ &reset_zoom, 1 });- EXPECT(context.handle_pinch_event(pinch_event(1.0)).accepted);+ EXPECT(context.handle_pinch_event(pinch_event(1.0)).frame_to_present.has_value());}TEST_CASE(wheel_pans_the_zoomed_visual_viewport_of_a_page_without_scroll_nodes)diff --git a/Tests/LibWeb/Text/expected/async-scrolling/pinch-past-the-scale-limit-beside-a-busy-task.txt b/Tests/LibWeb/Text/expected/async-scrolling/pinch-past-the-scale-limit-beside-a-busy-task.txtindex 69a497d25f8..87db846483b 100644--- a/Tests/LibWeb/Text/expected/async-scrolling/pinch-past-the-scale-limit-beside-a-busy-task.txt+++ b/Tests/LibWeb/Text/expected/async-scrolling/pinch-past-the-scale-limit-beside-a-busy-task.txt@@ -1,2 +1,2 @@-compositor scale beside the task: 1-main thread scale after the task: 1+compositor scale beside the task: 2.25+main thread scale after the task: 2.25