mirror of
https://github.com/servo/servo.git
synced 2025-07-30 10:40:27 +01:00
`WindowMethods` is used by the embedding layer to get information from the embedder. This change moves the functionality for getting screen size and `WebView` offsets to `WebViewDelegate`. This is important because `WebView`s might be on different screens or have different offsets on the screen itself, so it makes sense for this to be per-`WebView` and not global to the embedder. HiDPI and animation state functionality will move to the embedder in subsequent changes. Signed-off-by: Martin Robinson <mrobinson@igalia.com> <!-- Please describe your changes on the following line: --> --- <!-- Thank you for contributing to Servo! Please replace each `[ ]` by `[X]` when the step is complete, and replace `___` with appropriate data: --> - [x] `./mach build -d` does not report any errors - [x] `./mach test-tidy` does not report any errors - [x] These changes do not require tests because they just modify the `WebView` API surface a bit. <!-- Also, please make sure that "Allow edits from maintainers" checkbox is checked, so that we can help you if you get stuck somewhere along the way.--> <!-- Pull requests that do not address these steps are welcome, but they will require additional verification as part of the review process. --> Signed-off-by: Martin Robinson <mrobinson@igalia.com>
69 lines
2.3 KiB
Rust
69 lines
2.3 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/. */
|
|
|
|
//! Abstract windowing methods. The concrete implementations of these can be found in `platform/`.
|
|
|
|
use std::fmt::Debug;
|
|
|
|
use embedder_traits::{EventLoopWaker, MouseButton};
|
|
use euclid::Scale;
|
|
use net::protocols::ProtocolRegistry;
|
|
use servo_geometry::DeviceIndependentPixel;
|
|
use webrender_api::units::{DevicePixel, DevicePoint};
|
|
|
|
#[derive(Clone)]
|
|
pub enum MouseWindowEvent {
|
|
Click(MouseButton, DevicePoint),
|
|
MouseDown(MouseButton, DevicePoint),
|
|
MouseUp(MouseButton, DevicePoint),
|
|
}
|
|
|
|
/// Various debug and profiling flags that WebRender supports.
|
|
#[derive(Clone)]
|
|
pub enum WebRenderDebugOption {
|
|
Profiler,
|
|
TextureCacheDebug,
|
|
RenderTargetDebug,
|
|
}
|
|
|
|
#[derive(Clone, Copy, Debug, PartialEq)]
|
|
pub enum AnimationState {
|
|
Idle,
|
|
Animating,
|
|
}
|
|
|
|
// TODO: this trait assumes that the window is responsible
|
|
// for creating the GL context, making it current, buffer
|
|
// swapping, etc. Really that should all be done by surfman.
|
|
pub trait WindowMethods {
|
|
/// Get the HighDPI factor of the native window, the screen and the framebuffer.
|
|
/// TODO(martin): Move this to `RendererWebView` when possible.
|
|
fn hidpi_factor(&self) -> Scale<f32, DeviceIndependentPixel, DevicePixel>;
|
|
/// Set whether the application is currently animating.
|
|
/// Typically, when animations are active, the window
|
|
/// will want to avoid blocking on UI events, and just
|
|
/// run the event loop at the vsync interval.
|
|
/// TODO(martin): Move this to `RendererWebView` when possible.
|
|
fn set_animation_state(&self, _state: AnimationState);
|
|
}
|
|
|
|
pub trait EmbedderMethods {
|
|
/// Returns a thread-safe object to wake up the window's event loop.
|
|
fn create_event_loop_waker(&mut self) -> Box<dyn EventLoopWaker>;
|
|
|
|
#[cfg(feature = "webxr")]
|
|
/// Register services with a WebXR Registry.
|
|
fn register_webxr(
|
|
&mut self,
|
|
_: &mut webxr::MainThreadRegistry,
|
|
_: embedder_traits::EmbedderProxy,
|
|
) {
|
|
}
|
|
|
|
/// Returns the protocol handlers implemented by that embedder.
|
|
/// They will be merged with the default internal ones.
|
|
fn get_protocol_handlers(&self) -> ProtocolRegistry {
|
|
ProtocolRegistry::default()
|
|
}
|
|
}
|