libservo: Move size handling to RenderContext from WindowMethods (#35621)

This is the first step toward removing `WindowMethods`, which will
gradually be integrated into the `WebView` and `WebViewDelegate`. Sizing
of the `WebView` is now handled by the a size associated with a
`RenderingContext`. `WebView`s will eventually just paint the entire
size of their `RenderingContext`. Notes:

- This is transitionary step so now there is a `WebView::resize` and a
  `WebView::move_resize`. The first is the future which will resize the
  `WebView` and its associated `RenderingContext`. The second is a
  function that the virtual `WebView`s that will soon be replaced by a
  the one-`WebView` per `WebView` model.
- We do not need to call `WebView::move_resize` at as much any longer
  because the default size of the `WebView` is to take up the whole
  `RenderingContext`.
- `SurfmanRenderingContext` is no longer exposed in the API, as a
  surfman context doesn't naturally have a size unless a surface is
  bound to it.

Signed-off-by: Martin Robinson <mrobinson@igalia.com>
This commit is contained in:
Martin Robinson 2025-02-25 16:03:53 +01:00 committed by GitHub
parent ebb19bcd60
commit 23524a5413
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
19 changed files with 200 additions and 312 deletions

View file

@ -7,14 +7,14 @@ use std::collections::HashMap;
use std::path::PathBuf;
use std::rc::Rc;
use euclid::Vector2D;
use euclid::{Point2D, Vector2D};
use image::{DynamicImage, ImageFormat};
use keyboard_types::{Key, KeyboardEvent, Modifiers, ShortcutMatcher};
use log::{error, info};
use servo::base::id::WebViewId;
use servo::config::pref;
use servo::ipc_channel::ipc::IpcSender;
use servo::webrender_api::units::{DeviceIntPoint, DeviceIntSize};
use servo::webrender_api::units::{DeviceIntPoint, DeviceIntRect, DeviceIntSize};
use servo::webrender_api::ScrollLocation;
use servo::{
AllowOrDenyRequest, AuthenticationRequest, FilterPattern, GamepadHapticEffectType, LoadStatus,
@ -130,13 +130,8 @@ impl RunningAppState {
};
let inner = self.inner();
let viewport_rect = inner
.window
.get_coordinates()
.viewport
.to_rect()
.to_untyped()
.to_u32();
let size = inner.window.rendering_context().size2d().to_i32();
let viewport_rect = DeviceIntRect::from_origin_and_size(Point2D::origin(), size);
let Some(image) = inner
.window
.rendering_context()
@ -467,17 +462,8 @@ impl WebViewDelegate for RunningAppState {
}
fn notify_ready_to_show(&self, webview: servo::WebView) {
let rect = self
.inner()
.window
.get_coordinates()
.get_viewport()
.to_f32();
webview.focus();
webview.move_resize(rect);
webview.raise_to_top(true);
webview.notify_rendering_context_resized();
}
fn notify_closed(&self, webview: servo::WebView) {