mirror of
https://github.com/servo/servo.git
synced 2025-08-03 20:50:07 +01:00
constellation: Stop assuming that the viewport is shared by all WebViews (#36312)
The `Constellation` previously held a `window_size` member, but this assumes that all `WebView`s have the same size. This change removes that assumption as well as making sure that all `WebView`s pass their size and HiDIP scaling to the `Constellation` when they are created. In addition - `WindowSizeData` is renamed to `ViewportDetails`, as it was holding more than just the size and it didn't necessarily correspond to a "window." It's used for tracking viewport data, whether for an `<iframe>` or the main `WebView` viewport. - `ViewportDetails` is stored more consistently so that conceptually an `<iframe>` can also have its own HiDPI scaling. This isn't something we necessarily want, but it makes everything conceptually simpler. The goal with this change is to work toward allowing per-`WebView` HiDPI scaling and sizing. There are still some corresponding changes in the compositor to make that happen, but they will in a subsequent change. Testing: This is covered by existing tests. There should be no behavior changes. Fixes: This is part of #36232. Signed-off-by: Martin Robinson <mrobinson@igalia.com> Signed-off-by: Martin Robinson <mrobinson@igalia.com>
This commit is contained in:
parent
7c89e24f34
commit
fb344ba4e9
26 changed files with 272 additions and 256 deletions
|
@ -19,6 +19,7 @@ use std::sync::Arc;
|
|||
|
||||
use base::id::{PipelineId, WebViewId};
|
||||
use crossbeam_channel::Sender;
|
||||
use euclid::{Scale, Size2D};
|
||||
use http::{HeaderMap, Method, StatusCode};
|
||||
use ipc_channel::ipc::IpcSender;
|
||||
pub use keyboard_types::{KeyboardEvent, Modifiers};
|
||||
|
@ -29,8 +30,9 @@ use pixels::Image;
|
|||
use serde::{Deserialize, Serialize};
|
||||
use servo_url::ServoUrl;
|
||||
use strum_macros::IntoStaticStr;
|
||||
use style_traits::CSSPixel;
|
||||
use url::Url;
|
||||
use webrender_api::units::{DeviceIntPoint, DeviceIntRect, DeviceIntSize};
|
||||
use webrender_api::units::{DeviceIntPoint, DeviceIntRect, DeviceIntSize, DevicePixel};
|
||||
|
||||
pub use crate::input_events::*;
|
||||
pub use crate::webdriver::*;
|
||||
|
@ -224,7 +226,6 @@ pub enum AllowOrDeny {
|
|||
}
|
||||
|
||||
#[derive(Clone, Debug, Deserialize, Serialize)]
|
||||
|
||||
pub struct SelectElementOption {
|
||||
/// A unique identifier for the option that can be used to select it.
|
||||
pub id: usize,
|
||||
|
@ -244,6 +245,18 @@ pub enum SelectElementOptionOrOptgroup {
|
|||
},
|
||||
}
|
||||
|
||||
/// Data about a `WebView` or `<iframe>` viewport: its size and also the
|
||||
/// HiDPI scale factor to use when rendering the contents.
|
||||
#[derive(Clone, Copy, Debug, Default, Deserialize, MallocSizeOf, PartialEq, Serialize)]
|
||||
pub struct ViewportDetails {
|
||||
/// The size of the layout viewport.
|
||||
pub size: Size2D<f32, CSSPixel>,
|
||||
|
||||
/// The scale factor to use to account for HiDPI scaling. This does not take into account
|
||||
/// any page or pinch zoom applied by the compositor to the contents.
|
||||
pub hidpi_scale_factor: Scale<f32, CSSPixel, DevicePixel>,
|
||||
}
|
||||
|
||||
#[derive(Deserialize, IntoStaticStr, Serialize)]
|
||||
pub enum EmbedderMsg {
|
||||
/// A status message to be displayed by the browser chrome.
|
||||
|
@ -275,7 +288,7 @@ pub enum EmbedderMsg {
|
|||
/// Whether or not to allow a pipeline to load a url.
|
||||
AllowNavigationRequest(WebViewId, PipelineId, ServoUrl),
|
||||
/// Whether or not to allow script to open a new tab/browser
|
||||
AllowOpeningWebView(WebViewId, IpcSender<Option<WebViewId>>),
|
||||
AllowOpeningWebView(WebViewId, IpcSender<Option<(WebViewId, ViewportDetails)>>),
|
||||
/// A webview was destroyed.
|
||||
WebViewClosed(WebViewId),
|
||||
/// A webview gained focus for keyboard events.
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue