--- original +++ modified @@ -22,7 +22,7 @@ use std::sync::Arc; use base::generic_channel::{GenericCallback, GenericSender, GenericSharedMemory, SendResult}; -use base::id::{PipelineId, WebViewId}; +use base::id::{BrowsingContextId, PipelineId, WebViewId}; use crossbeam_channel::Sender; use euclid::{Box2D, Point2D, Scale, Size2D, Vector2D}; use http::{HeaderMap, Method, StatusCode}; @@ -31,6 +31,7 @@ use malloc_size_of_derive::MallocSizeOf; use pixels::SharedRasterImage; use serde::{Deserialize, Deserializer, Serialize, Serializer}; +use servo_config::pref_util::PrefValue; use servo_geometry::{DeviceIndependentIntRect, DeviceIndependentIntSize}; use servo_url::ServoUrl; use strum::{EnumMessage, IntoStaticStr}; @@ -65,6 +66,31 @@ Self::Page(point) => *point * scale, } } + + /// Scale the point by the given factor (divides coordinates by scale). + /// Used for converting coordinates to account for page zoom. + pub fn scale_by(&self, scale: f32) -> Self { + match self { + Self::Device(point) => Self::Device(DevicePoint::new(point.x / scale, point.y / scale)), + Self::Page(point) => Self::Page(Point2D::new(point.x / scale, point.y / scale)), + } + } + + /// Get the x coordinate regardless of coordinate space. + pub fn x(&self) -> f32 { + match self { + Self::Device(point) => point.x, + Self::Page(point) => point.x, + } + } + + /// Get the y coordinate regardless of coordinate space. + pub fn y(&self) -> f32 { + match self { + Self::Device(point) => point.y, + Self::Page(point) => point.y, + } + } } impl From for WebViewPoint { @@ -307,9 +333,16 @@ /// The size of the layout viewport. pub size: Size2D, - /// The scale factor to use to account for HiDPI scaling. This does not take into account - /// any page or pinch zoom applied by `Paint` to the contents. + /// The scale factor to use to account for HiDPI scaling. For top-level webviews, this + /// includes the page zoom factor. For embedded webviews, this is just the device HiDPI + /// and page zoom is passed separately via `page_zoom_for_rendering`. pub hidpi_scale_factor: Scale, + + /// Page zoom to apply during display list building (for embedded webviews only). + /// For top-level webviews this is `None` because zoom is applied externally in the + /// painter as a WebRender reference frame transform. For embedded webviews, the zoom + /// must be applied inside the webview's own display list. + pub page_zoom_for_rendering: Option, } impl ViewportDetails { @@ -329,7 +362,7 @@ } /// An opaque identifier for a single history traversal operation. -#[derive(Clone, Deserialize, Eq, Hash, PartialEq, Serialize)] +#[derive(Clone, Debug, Deserialize, Eq, Hash, PartialEq, Serialize)] pub struct TraversalId(String); impl TraversalId { @@ -339,6 +372,12 @@ } } +impl std::fmt::Display for TraversalId { + fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result { + write!(f, "{}", self.0) + } +} + #[derive(Clone, Copy, Deserialize, Eq, Hash, PartialEq, Serialize)] pub enum PixelFormat { /// Luminance channel only @@ -411,6 +450,12 @@ } } +#[derive(Deserialize, Serialize)] +pub struct NewOSWindowParams { + pub url: ServoUrl, + pub features: String, +} + /// Messages towards the embedder. #[derive(Deserialize, IntoStaticStr, Serialize)] pub enum EmbedderMsg { @@ -436,6 +481,21 @@ ), /// Whether or not to allow script to open a new tab/browser AllowOpeningWebView(WebViewId, GenericSender>), + /// Whether or not to allow an iframe with "embed" attribute to create an embedded webview. + AllowOpeningEmbeddedWebView(WebViewId, GenericSender>), + /// An embedded webview has opened a new embedded webview via `window.open()`. + /// The constellation has already created the new webview and pipeline. + /// The parent webview (browserhtml shell) should create an `