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:
Martin Robinson 2025-04-02 13:17:24 +02:00 committed by GitHub
parent 520a7f7bc5
commit b925c31424
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
17 changed files with 235 additions and 183 deletions

View file

@ -35,28 +35,34 @@ impl Screen {
}
fn screen_size(&self) -> Size2D<u32, CSSPixel> {
let (send, recv) =
let (sender, receiver) =
ipc::channel::<DeviceIndependentIntSize>(self.global().time_profiler_chan().clone())
.unwrap();
self.window
.compositor_api()
.sender()
.send(CrossProcessCompositorMessage::GetScreenSize(send))
.send(CrossProcessCompositorMessage::GetScreenSize(
self.window.webview_id(),
sender,
))
.unwrap();
let size = recv.recv().unwrap_or(Size2D::zero()).to_u32();
let size = receiver.recv().unwrap_or(Size2D::zero()).to_u32();
Size2D::new(size.width, size.height)
}
fn screen_avail_size(&self) -> Size2D<u32, CSSPixel> {
let (send, recv) =
let (sender, receiver) =
ipc::channel::<DeviceIndependentIntSize>(self.global().time_profiler_chan().clone())
.unwrap();
self.window
.compositor_api()
.sender()
.send(CrossProcessCompositorMessage::GetAvailableScreenSize(send))
.send(CrossProcessCompositorMessage::GetAvailableScreenSize(
self.window.webview_id(),
sender,
))
.unwrap();
let size = recv.recv().unwrap_or(Size2D::zero()).to_u32();
let size = receiver.recv().unwrap_or(Size2D::zero()).to_u32();
Size2D::new(size.width, size.height)
}
}

View file

@ -1859,13 +1859,15 @@ impl Window {
fn client_window(&self) -> (Size2D<u32, CSSPixel>, Point2D<i32, CSSPixel>) {
let timer_profile_chan = self.global().time_profiler_chan().clone();
let (send, recv) =
let (sender, receiver) =
ProfiledIpc::channel::<DeviceIndependentIntRect>(timer_profile_chan).unwrap();
let _ = self
.compositor_api
.sender()
.send(webrender_traits::CrossProcessCompositorMessage::GetClientWindowRect(send));
let rect = recv.recv().unwrap_or_default();
let _ = self.compositor_api.sender().send(
webrender_traits::CrossProcessCompositorMessage::GetClientWindowRect(
self.webview_id(),
sender,
),
);
let rect = receiver.recv().unwrap_or_default();
(
Size2D::new(rect.size().width as u32, rect.size().height as u32),
Point2D::new(rect.min.x, rect.min.y),