mirror of
https://github.com/servo/servo
synced 2026-04-25 17:15:48 +02:00
This change adds a full implementation of pinch zoom, including center-aware zooming. Before this kind of pinch zooming was only enabled on OpenHarmony. Now all pinch zooms must come with a focal point, which determines the center point of the zoom. This enables full pinch zoom on Android and has OpenHarmony use the same system for pinch zoom. Every WebView now has a `PinchZoom` which describes the viewport of the pinch zoom and handles panning with proper chaining of zoom viewport panning to scroll layer scrolling. In addition, the collection of touch actions is simplified by storing an array and turning each into a ScrollZoomEvent when appropriate. Caveats: - We've noticed some hard to diagnose bugs with clamping the panning viewport, but we'll tackle those later once we figure out how to reliably reproduce them. - Keyboard scroll events currently do not properly pan the pinch zoom viewport. This will be handled in a followup. Testing: There are currently no tests for this kind of touch interaction as there's no way to read the pinch zoom from a WebView. It's processed asynchronously. Once that API is added, we should be able to add some simple tests, but many things are still unaccessible such as the pan position in the pinch zoom viewport. Fixes #4224. Signed-off-by: Martin Robinson <mrobinson@igalia.com> Co-authored-by: Rakhi Sharma <atbrakhi@igalia.com>
63 lines
2.4 KiB
Rust
63 lines
2.4 KiB
Rust
/* This Source Code Form is subject to the terms of the Mozilla Public
|
|
* License, v. 2.0. If a copy of the MPL was not distributed with this
|
|
* file, You can obtain one at https://mozilla.org/MPL/2.0/. */
|
|
|
|
#![deny(unsafe_code)]
|
|
|
|
use std::cell::Cell;
|
|
use std::path::PathBuf;
|
|
use std::rc::Rc;
|
|
|
|
use base::generic_channel::RoutedReceiver;
|
|
use compositing_traits::rendering_context::RenderingContext;
|
|
use compositing_traits::{CompositorMsg, CompositorProxy, WebrenderExternalImageHandlers};
|
|
use constellation_traits::EmbedderToConstellationMessage;
|
|
use crossbeam_channel::Sender;
|
|
use embedder_traits::{EventLoopWaker, RefreshDriver, ShutdownState};
|
|
use profile_traits::{mem, time};
|
|
|
|
pub use crate::compositor::{IOCompositor, WebRenderDebugOption};
|
|
|
|
#[macro_use]
|
|
mod tracing;
|
|
|
|
mod compositor;
|
|
mod pinch_zoom;
|
|
mod refresh_driver;
|
|
mod render_notifier;
|
|
mod screenshot;
|
|
mod touch;
|
|
mod webview_manager;
|
|
mod webview_renderer;
|
|
|
|
/// Data used to construct a compositor.
|
|
pub struct InitialCompositorState {
|
|
/// A channel to the compositor.
|
|
pub sender: CompositorProxy,
|
|
/// A port on which messages inbound to the compositor can be received.
|
|
pub receiver: RoutedReceiver<CompositorMsg>,
|
|
/// A channel to the constellation.
|
|
pub constellation_chan: Sender<EmbedderToConstellationMessage>,
|
|
/// A channel to the time profiler thread.
|
|
pub time_profiler_chan: time::ProfilerChan,
|
|
/// A channel to the memory profiler thread.
|
|
pub mem_profiler_chan: mem::ProfilerChan,
|
|
/// A shared state which tracks whether Servo has started or has finished
|
|
/// shutting down.
|
|
pub shutdown_state: Rc<Cell<ShutdownState>>,
|
|
/// The target [`RenderingContext`] of this renderer.
|
|
pub rendering_context: Rc<dyn RenderingContext>,
|
|
#[cfg(feature = "webxr")]
|
|
pub webxr_main_thread: webxr::MainThreadRegistry,
|
|
/// An [`EventLoopWaker`] used in order to wake up the embedder when it is
|
|
/// time to paint.
|
|
pub event_loop_waker: Box<dyn EventLoopWaker>,
|
|
/// An optional [`RefreshDriver`] provided by the embedder.
|
|
pub refresh_driver: Option<Rc<dyn RefreshDriver>>,
|
|
/// A [`PathBuf`] which can be used to override WebRender shaders.
|
|
pub shaders_path: Option<PathBuf>,
|
|
/// [`WebrenderExternalImageHandlers`] for the renderer.
|
|
/// TODO: This should be managed from inside the renderer.
|
|
pub external_image_handlers: Box<WebrenderExternalImageHandlers>,
|
|
}
|