mirror of
https://github.com/servo/servo.git
synced 2025-08-08 23:15:33 +01:00
libservo: Start moving WindowMethods
to WebViewDelegate
(#36223)
`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>
This commit is contained in:
parent
520a7f7bc5
commit
b925c31424
17 changed files with 235 additions and 183 deletions
|
@ -636,3 +636,22 @@ pub struct NotificationAction {
|
|||
/// Icon's raw image data and metadata.
|
||||
pub icon_resource: Option<Arc<Image>>,
|
||||
}
|
||||
|
||||
/// Information about a `WebView`'s screen geometry and offset. This is used
|
||||
/// for the [Screen](https://drafts.csswg.org/cssom-view/#the-screen-interface)
|
||||
/// CSSOM APIs and `window.screenLeft` / `window.screenTop`.
|
||||
#[derive(Clone, Copy, Debug, Default)]
|
||||
pub struct ScreenGeometry {
|
||||
/// The size of the screen in device pixels. This will be converted to
|
||||
/// CSS pixels based on the pixel scaling of the `WebView`.
|
||||
pub size: DeviceIntSize,
|
||||
/// The available size of the screen in device pixels. This size is the size
|
||||
/// available for web content on the screen, and should be `size` minus any system
|
||||
/// toolbars, docks, and interface elements of the browser. This will be converted to
|
||||
/// CSS pixels based on the pixel scaling of the `WebView`.
|
||||
pub available_size: DeviceIntSize,
|
||||
/// The offset of the `WebView` in device pixels for the purposes of the `window.screenLeft`
|
||||
/// and `window.screenTop` APIs. This will be converted to CSS pixels based on the pixel scaling
|
||||
/// of the `WebView`.
|
||||
pub offset: DeviceIntPoint,
|
||||
}
|
||||
|
|
|
@ -14,6 +14,7 @@ use std::sync::{Arc, Mutex};
|
|||
use base::id::WebViewId;
|
||||
use constellation_traits::CompositorHitTestResult;
|
||||
use display_list::CompositorDisplayListInfo;
|
||||
use embedder_traits::ScreenGeometry;
|
||||
use euclid::default::Size2D as UntypedSize2D;
|
||||
use ipc_channel::ipc::{self, IpcSender, IpcSharedMemory};
|
||||
use log::warn;
|
||||
|
@ -82,12 +83,12 @@ pub enum CrossProcessCompositorMessage {
|
|||
RemoveFonts(Vec<FontKey>, Vec<FontInstanceKey>),
|
||||
|
||||
/// Get the client window size and position.
|
||||
GetClientWindowRect(IpcSender<DeviceIndependentIntRect>),
|
||||
GetClientWindowRect(WebViewId, IpcSender<DeviceIndependentIntRect>),
|
||||
/// Get the size of the screen that the client window inhabits.
|
||||
GetScreenSize(IpcSender<DeviceIndependentIntSize>),
|
||||
GetScreenSize(WebViewId, IpcSender<DeviceIndependentIntSize>),
|
||||
/// Get the available screen size (without toolbars and docks) for the screen
|
||||
/// the client window inhabits.
|
||||
GetAvailableScreenSize(IpcSender<DeviceIndependentIntSize>),
|
||||
GetAvailableScreenSize(WebViewId, IpcSender<DeviceIndependentIntSize>),
|
||||
}
|
||||
|
||||
impl fmt::Debug for CrossProcessCompositorMessage {
|
||||
|
@ -478,3 +479,11 @@ impl From<SerializableImageData> for ImageData {
|
|||
}
|
||||
}
|
||||
}
|
||||
|
||||
/// A trait that exposes the embedding layer's `WebView` to the Servo renderer.
|
||||
/// This is to prevent a dependency cycle between the renderer and the embedding
|
||||
/// layer.
|
||||
pub trait RendererWebView {
|
||||
fn id(&self) -> WebViewId;
|
||||
fn screen_geometry(&self) -> Option<ScreenGeometry>;
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue