mirror of
https://github.com/servo/servo.git
synced 2025-08-28 00:28:20 +01:00
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:
parent
ebb19bcd60
commit
23524a5413
19 changed files with 200 additions and 312 deletions
|
@ -7,6 +7,7 @@ use std::rc::Rc;
|
|||
use std::sync::Arc;
|
||||
use std::time::Instant;
|
||||
|
||||
use dpi::PhysicalSize;
|
||||
use egui::text::{CCursor, CCursorRange};
|
||||
use egui::text_edit::TextEditState;
|
||||
use egui::{
|
||||
|
@ -379,13 +380,11 @@ impl Minibrowser {
|
|||
// If the top parts of the GUI changed size, then update the size of the WebView and also
|
||||
// the size of its RenderingContext.
|
||||
let available_size = ui.available_size();
|
||||
let rect = Box2D::from_origin_and_size(
|
||||
Point2D::origin(),
|
||||
Size2D::new(available_size.x, available_size.y),
|
||||
) * scale;
|
||||
let size = Size2D::new(available_size.x, available_size.y) * scale;
|
||||
let rect = Box2D::from_origin_and_size(Point2D::origin(), size);
|
||||
if rect != webview.rect() {
|
||||
webview.move_resize(rect);
|
||||
rendering_context.resize(rect.size().to_i32().to_untyped());
|
||||
webview.resize(PhysicalSize::new(size.width as u32, size.height as u32))
|
||||
}
|
||||
|
||||
let min = ui.cursor().min;
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue