diff options
author | Glenn Watson <github@intuitionlibrary.com> | 2017-02-23 14:16:29 +1000 |
---|---|---|
committer | Glenn Watson <github@intuitionlibrary.com> | 2017-02-24 06:58:10 +1000 |
commit | 30ff2f8f0d37bb85e568cacaeac871458e4078ff (patch) | |
tree | ada188dc8f9fe2163d756023294d7b4452ff6906 /components | |
parent | 56a99577b31a942e340624f97377980b0e612088 (diff) | |
download | servo-30ff2f8f0d37bb85e568cacaeac871458e4078ff.tar.gz servo-30ff2f8f0d37bb85e568cacaeac871458e4078ff.zip |
Introduce CSSPixel as a replacement for ViewportPx and PagePx.
Diffstat (limited to 'components')
-rw-r--r-- | components/compositing/compositor.rs | 24 | ||||
-rw-r--r-- | components/compositing/lib.rs | 4 | ||||
-rw-r--r-- | components/constellation/constellation.rs | 16 | ||||
-rw-r--r-- | components/constellation/pipeline.rs | 13 | ||||
-rw-r--r-- | components/layout/display_list_builder.rs | 4 | ||||
-rw-r--r-- | components/script/dom/document.rs | 4 | ||||
-rw-r--r-- | components/script/dom/mediaquerylist.rs | 11 | ||||
-rw-r--r-- | components/script/dom/window.rs | 4 | ||||
-rw-r--r-- | components/script_traits/lib.rs | 9 | ||||
-rw-r--r-- | components/script_traits/script_msg.rs | 4 | ||||
-rw-r--r-- | components/style/servo/media_queries.rs | 10 | ||||
-rw-r--r-- | components/style/viewport.rs | 9 | ||||
-rw-r--r-- | components/style_traits/lib.rs | 36 | ||||
-rw-r--r-- | components/style_traits/viewport.rs | 11 | ||||
-rw-r--r-- | components/webdriver_server/lib.rs | 4 |
15 files changed, 76 insertions, 87 deletions
diff --git a/components/compositing/compositor.rs b/components/compositing/compositor.rs index b7eb2633e68..f31fa123075 100644 --- a/components/compositing/compositor.rs +++ b/components/compositing/compositor.rs @@ -34,7 +34,7 @@ use std::fs::File; use std::rc::Rc; use std::sync::mpsc::Sender; use std::time::{Duration, Instant}; -use style_traits::{PagePx, ViewportPx}; +use style_traits::{CSSPixel, PinchZoomFactor}; use style_traits::viewport::ViewportConstraints; use time::{precise_time_ns, precise_time_s}; use touch::{TouchHandler, TouchAction}; @@ -147,15 +147,14 @@ pub struct IOCompositor<Window: WindowMethods> { viewport: Option<(TypedPoint2D<u32, DevicePixel>, TypedSize2D<u32, DevicePixel>)>, /// "Mobile-style" zoom that does not reflow the page. - viewport_zoom: ScaleFactor<f32, PagePx, ViewportPx>, + viewport_zoom: PinchZoomFactor, /// Viewport zoom constraints provided by @viewport. - min_viewport_zoom: Option<ScaleFactor<f32, PagePx, ViewportPx>>, - max_viewport_zoom: Option<ScaleFactor<f32, PagePx, ViewportPx>>, + min_viewport_zoom: Option<PinchZoomFactor>, + max_viewport_zoom: Option<PinchZoomFactor>, /// "Desktop-style" zoom that resizes the viewport to fit the window. - /// See `ViewportPx` docs in util/geom.rs for details. - page_zoom: ScaleFactor<f32, ViewportPx, DeviceIndependentPixel>, + page_zoom: ScaleFactor<f32, CSSPixel, DeviceIndependentPixel>, /// The device pixel ratio for this window. scale_factor: ScaleFactor<f32, DeviceIndependentPixel, DevicePixel>, @@ -402,7 +401,7 @@ impl<Window: WindowMethods> IOCompositor<Window> { composite_target: composite_target, shutdown_state: ShutdownState::NotShuttingDown, page_zoom: ScaleFactor::new(1.0), - viewport_zoom: ScaleFactor::new(1.0), + viewport_zoom: PinchZoomFactor::new(1.0), min_viewport_zoom: None, max_viewport_zoom: None, zoom_action: false, @@ -758,11 +757,9 @@ impl<Window: WindowMethods> IOCompositor<Window> { fn send_window_size(&self, size_type: WindowSizeType) { let dppx = self.page_zoom * self.hidpi_factor(); let initial_viewport = self.window_size.to_f32() / dppx; - let visible_viewport = initial_viewport / self.viewport_zoom; let msg = ConstellationMsg::WindowSize(WindowSizeData { device_pixel_ratio: dppx, initial_viewport: initial_viewport, - visible_viewport: visible_viewport, }, size_type); if let Err(e) = self.constellation_chan.send(msg) { @@ -1282,8 +1279,6 @@ impl<Window: WindowMethods> IOCompositor<Window> { }); if is_root { - // TODO: actual viewport size - self.viewport_zoom = constraints.initial_zoom; self.min_viewport_zoom = constraints.min_zoom; self.max_viewport_zoom = constraints.max_zoom; @@ -1301,8 +1296,8 @@ impl<Window: WindowMethods> IOCompositor<Window> { } } - fn device_pixels_per_page_px(&self) -> ScaleFactor<f32, PagePx, DevicePixel> { - self.viewport_zoom * self.page_zoom * self.hidpi_factor() + fn device_pixels_per_page_px(&self) -> ScaleFactor<f32, CSSPixel, DevicePixel> { + self.page_zoom * self.hidpi_factor() } fn update_zoom_transform(&mut self) { @@ -1710,7 +1705,8 @@ impl<Window: WindowMethods> IOCompositor<Window> { } pub fn pinch_zoom_level(&self) -> f32 { - self.viewport_zoom.get() as f32 + // TODO(gw): Access via WR. + 1.0 } pub fn title_for_main_frame(&self) { diff --git a/components/compositing/lib.rs b/components/compositing/lib.rs index 645cf737877..9b3fb8d9cda 100644 --- a/components/compositing/lib.rs +++ b/components/compositing/lib.rs @@ -30,7 +30,7 @@ use euclid::size::TypedSize2D; use ipc_channel::ipc::IpcSender; use msg::constellation_msg::PipelineId; use script_traits::{ConstellationControlMsg, LayoutControlMsg}; -use style_traits::PagePx; +use style_traits::CSSPixel; mod compositor; pub mod compositor_thread; @@ -40,7 +40,7 @@ pub mod windowing; pub struct SendableFrameTree { pub pipeline: CompositionPipeline, - pub size: Option<TypedSize2D<f32, PagePx>>, + pub size: Option<TypedSize2D<f32, CSSPixel>>, pub children: Vec<SendableFrameTree>, } diff --git a/components/constellation/constellation.rs b/components/constellation/constellation.rs index 8d77d0584e1..9e182194eef 100644 --- a/components/constellation/constellation.rs +++ b/components/constellation/constellation.rs @@ -119,7 +119,7 @@ use std::sync::Arc; use std::sync::mpsc::{Receiver, Sender, channel}; use std::thread; use std::time::Instant; -use style_traits::PagePx; +use style_traits::CSSPixel; use style_traits::cursor::Cursor; use style_traits::viewport::ViewportConstraints; use timer_scheduler::TimerScheduler; @@ -534,8 +534,6 @@ impl<Message, LTF, STF> Constellation<Message, LTF, STF> time_profiler_chan: state.time_profiler_chan, mem_profiler_chan: state.mem_profiler_chan, window_size: WindowSizeData { - visible_viewport: opts::get().initial_window_size.to_f32() * - ScaleFactor::new(1.0), initial_viewport: opts::get().initial_window_size.to_f32() * ScaleFactor::new(1.0), device_pixel_ratio: @@ -588,7 +586,7 @@ impl<Message, LTF, STF> Constellation<Message, LTF, STF> pipeline_id: PipelineId, frame_id: FrameId, parent_info: Option<(PipelineId, FrameType)>, - initial_window_size: Option<TypedSize2D<f32, PagePx>>, + initial_window_size: Option<TypedSize2D<f32, CSSPixel>>, load_data: LoadData, sandbox: IFrameSandboxState, is_private: bool) { @@ -1335,7 +1333,7 @@ impl<Message, LTF, STF> Constellation<Message, LTF, STF> } fn handle_init_load(&mut self, url: ServoUrl) { - let window_size = self.window_size.visible_viewport; + let window_size = self.window_size.initial_viewport; let root_pipeline_id = PipelineId::new(); let root_frame_id = self.root_frame_id; let load_data = LoadData::new(url.clone(), None, None); @@ -1353,7 +1351,7 @@ impl<Message, LTF, STF> Constellation<Message, LTF, STF> } fn handle_frame_size_msg(&mut self, - iframe_sizes: Vec<(PipelineId, TypedSize2D<f32, PagePx>)>) { + iframe_sizes: Vec<(PipelineId, TypedSize2D<f32, CSSPixel>)>) { for (pipeline_id, size) in iframe_sizes { let result = { let pipeline = match self.pipelines.get_mut(&pipeline_id) { @@ -1367,8 +1365,7 @@ impl<Message, LTF, STF> Constellation<Message, LTF, STF> pipeline.size = Some(size); let msg = ConstellationControlMsg::Resize(pipeline_id, WindowSizeData { - visible_viewport: size, - initial_viewport: size * ScaleFactor::new(1.0), + initial_viewport: size, device_pixel_ratio: self.window_size.device_pixel_ratio, }, WindowSizeType::Initial); @@ -2212,8 +2209,7 @@ impl<Message, LTF, STF> Constellation<Message, LTF, STF> /// Called when the window is resized. fn handle_window_size_msg(&mut self, new_size: WindowSizeData, size_type: WindowSizeType) { - debug!("handle_window_size_msg: {:?} {:?}", new_size.initial_viewport.to_untyped(), - new_size.visible_viewport.to_untyped()); + debug!("handle_window_size_msg: {:?}", new_size.initial_viewport.to_untyped()); if let Some(frame) = self.frames.get(&self.root_frame_id) { // Send Resize (or ResizeInactive) messages to each diff --git a/components/constellation/pipeline.rs b/components/constellation/pipeline.rs index 19c68a2fefc..d0af8d534cc 100644 --- a/components/constellation/pipeline.rs +++ b/components/constellation/pipeline.rs @@ -35,7 +35,7 @@ use std::ffi::OsStr; use std::process; use std::rc::Rc; use std::sync::mpsc::Sender; -use style_traits::{PagePx, ViewportPx}; +use style_traits::CSSPixel; use webrender_traits; use webvr_traits::WebVRMsg; @@ -76,7 +76,7 @@ pub struct Pipeline { /// The size of the frame. /// TODO: move this field to `Frame`. - pub size: Option<TypedSize2D<f32, PagePx>>, + pub size: Option<TypedSize2D<f32, CSSPixel>>, /// Whether this pipeline is currently running animations. Pipelines that are running /// animations cause composites to be continually scheduled. @@ -149,10 +149,10 @@ pub struct InitialPipelineState { pub mem_profiler_chan: profile_mem::ProfilerChan, /// Information about the initial window size. - pub window_size: Option<TypedSize2D<f32, PagePx>>, + pub window_size: Option<TypedSize2D<f32, CSSPixel>>, /// Information about the device pixel ratio. - pub device_pixel_ratio: ScaleFactor<f32, ViewportPx, DevicePixel>, + pub device_pixel_ratio: ScaleFactor<f32, CSSPixel, DevicePixel>, /// The event loop to run in, if applicable. pub event_loop: Option<Rc<EventLoop>>, @@ -193,8 +193,7 @@ impl Pipeline { let device_pixel_ratio = state.device_pixel_ratio; let window_size = state.window_size.map(|size| { WindowSizeData { - visible_viewport: size, - initial_viewport: size * ScaleFactor::new(1.0), + initial_viewport: size, device_pixel_ratio: device_pixel_ratio, } }); @@ -307,7 +306,7 @@ impl Pipeline { compositor_proxy: Box<CompositorProxy + 'static + Send>, is_private: bool, url: ServoUrl, - size: Option<TypedSize2D<f32, PagePx>>, + size: Option<TypedSize2D<f32, CSSPixel>>, visible: bool) -> Pipeline { let pipeline = Pipeline { diff --git a/components/layout/display_list_builder.rs b/components/layout/display_list_builder.rs index 5eb4534a0c5..99ad8233c83 100644 --- a/components/layout/display_list_builder.rs +++ b/components/layout/display_list_builder.rs @@ -57,7 +57,7 @@ use style::servo::restyle_damage::REPAINT; use style::values::{RGBA, computed}; use style::values::computed::{AngleOrCorner, Gradient, GradientKind, LengthOrPercentage, LengthOrPercentageOrAuto}; use style::values::specified::{HorizontalDirection, VerticalDirection}; -use style_traits::PagePx; +use style_traits::CSSPixel; use style_traits::cursor::Cursor; use table_cell::CollapsedBordersForCell; use webrender_traits::{ColorF, GradientStop, ScrollPolicy}; @@ -110,7 +110,7 @@ pub struct DisplayListBuildState<'a> { /// Vector containing iframe sizes, used to inform the constellation about /// new iframe sizes - pub iframe_sizes: Vec<(PipelineId, TypedSize2D<f32, PagePx>)>, + pub iframe_sizes: Vec<(PipelineId, TypedSize2D<f32, CSSPixel>)>, } impl<'a> DisplayListBuildState<'a> { diff --git a/components/script/dom/document.rs b/components/script/dom/document.rs index c836a46f1da..4b693f0448d 100644 --- a/components/script/dom/document.rs +++ b/components/script/dom/document.rs @@ -3252,7 +3252,7 @@ impl DocumentMethods for Document { let y = *y as f32; let point = &Point2D::new(x, y); let window = window_from_node(self); - let viewport = window.window_size().unwrap().visible_viewport; + let viewport = window.window_size().unwrap().initial_viewport; if self.browsing_context().is_none() { return None; @@ -3285,7 +3285,7 @@ impl DocumentMethods for Document { let y = *y as f32; let point = &Point2D::new(x, y); let window = window_from_node(self); - let viewport = window.window_size().unwrap().visible_viewport; + let viewport = window.window_size().unwrap().initial_viewport; if self.browsing_context().is_none() { return vec!(); diff --git a/components/script/dom/mediaquerylist.rs b/components/script/dom/mediaquerylist.rs index 2545b911c7a..486f9f64fd3 100644 --- a/components/script/dom/mediaquerylist.rs +++ b/components/script/dom/mediaquerylist.rs @@ -18,12 +18,11 @@ use dom::document::Document; use dom::event::Event; use dom::eventtarget::EventTarget; use dom::mediaquerylistevent::MediaQueryListEvent; -use euclid::scale_factor::ScaleFactor; use js::jsapi::JSTracer; use std::cell::Cell; use std::rc::Rc; use style::media_queries::{Device, MediaList, MediaType}; -use style_traits::{PagePx, ToCss, ViewportPx}; +use style_traits::ToCss; pub enum MediaQueryListMatchState { Same(bool), @@ -75,12 +74,8 @@ impl MediaQueryList { pub fn evaluate(&self) -> bool { if let Some(window_size) = self.document.window().window_size() { - let viewport_size = window_size.visible_viewport; - // TODO: support real ViewportPx, including zoom level - // This information seems not to be tracked currently, so we assume - // ViewportPx == PagePx - let page_to_viewport: ScaleFactor<f32, PagePx, ViewportPx> = ScaleFactor::new(1.0); - let device = Device::new(MediaType::Screen, viewport_size * page_to_viewport); + let viewport_size = window_size.initial_viewport; + let device = Device::new(MediaType::Screen, viewport_size); self.media_query_list.evaluate(&device) } else { false diff --git a/components/script/dom/window.rs b/components/script/dom/window.rs index 93cdd1c31d0..919093c158c 100644 --- a/components/script/dom/window.rs +++ b/components/script/dom/window.rs @@ -774,7 +774,7 @@ impl WindowMethods for Window { //TODO Include Scrollbar fn InnerHeight(&self) -> i32 { self.window_size.get() - .and_then(|e| e.visible_viewport.height.to_i32()) + .and_then(|e| e.initial_viewport.height.to_i32()) .unwrap_or(0) } @@ -782,7 +782,7 @@ impl WindowMethods for Window { //TODO Include Scrollbar fn InnerWidth(&self) -> i32 { self.window_size.get() - .and_then(|e| e.visible_viewport.width.to_i32()) + .and_then(|e| e.initial_viewport.width.to_i32()) .unwrap_or(0) } diff --git a/components/script_traits/lib.rs b/components/script_traits/lib.rs index 7bf54dc841a..a1d97b8b232 100644 --- a/components/script_traits/lib.rs +++ b/components/script_traits/lib.rs @@ -67,7 +67,7 @@ use servo_url::ServoUrl; use std::collections::HashMap; use std::fmt; use std::sync::mpsc::{Receiver, Sender}; -use style_traits::{PagePx, UnsafeNode, ViewportPx}; +use style_traits::{CSSPixel, UnsafeNode}; use webdriver_msg::{LoadStatus, WebDriverScriptCommand}; use webvr_traits::{WebVRDisplayEvent, WebVRMsg}; @@ -663,13 +663,10 @@ pub enum DevicePixel {} pub struct WindowSizeData { /// The size of the initial layout viewport, before parsing an /// http://www.w3.org/TR/css-device-adapt/#initial-viewport - pub initial_viewport: TypedSize2D<f32, ViewportPx>, - - /// The "viewing area" in page px. See `PagePx` documentation for details. - pub visible_viewport: TypedSize2D<f32, PagePx>, + pub initial_viewport: TypedSize2D<f32, CSSPixel>, /// The resolution of the window in dppx, not including any "pinch zoom" factor. - pub device_pixel_ratio: ScaleFactor<f32, ViewportPx, DevicePixel>, + pub device_pixel_ratio: ScaleFactor<f32, CSSPixel, DevicePixel>, } /// The type of window size change. diff --git a/components/script_traits/script_msg.rs b/components/script_traits/script_msg.rs index d35e23a7bb9..8aa606c02c5 100644 --- a/components/script_traits/script_msg.rs +++ b/components/script_traits/script_msg.rs @@ -24,7 +24,7 @@ use net_traits::CoreResourceMsg; use net_traits::storage_thread::StorageType; use offscreen_gl_context::{GLContextAttributes, GLLimits}; use servo_url::ServoUrl; -use style_traits::PagePx; +use style_traits::CSSPixel; use style_traits::cursor::Cursor; use style_traits::viewport::ViewportConstraints; @@ -34,7 +34,7 @@ pub enum LayoutMsg { /// Indicates whether this pipeline is currently running animations. ChangeRunningAnimationsState(PipelineId, AnimationState), /// Inform the constellation of the size of the pipeline's viewport. - FrameSizes(Vec<(PipelineId, TypedSize2D<f32, PagePx>)>), + FrameSizes(Vec<(PipelineId, TypedSize2D<f32, CSSPixel>)>), /// Requests that the constellation inform the compositor of the a cursor change. SetCursor(Cursor), /// Notifies the constellation that the viewport has been constrained in some manner diff --git a/components/style/servo/media_queries.rs b/components/style/servo/media_queries.rs index 516bc02fcd1..d6c5f281946 100644 --- a/components/style/servo/media_queries.rs +++ b/components/style/servo/media_queries.rs @@ -10,7 +10,7 @@ use euclid::{Size2D, TypedSize2D}; use media_queries::MediaType; use properties::ComputedValues; use std::fmt; -use style_traits::{ToCss, ViewportPx}; +use style_traits::{CSSPixel, ToCss}; use style_traits::viewport::ViewportConstraints; use values::computed::{self, ToComputedValue}; use values::specified; @@ -23,14 +23,14 @@ use values::specified; pub struct Device { /// The current media type used by de device. media_type: MediaType, - /// The current viewport size, in viewport pixels. - viewport_size: TypedSize2D<f32, ViewportPx>, + /// The current viewport size, in CSS pixels. + viewport_size: TypedSize2D<f32, CSSPixel>, } impl Device { /// Trivially construct a new `Device`. pub fn new(media_type: MediaType, - viewport_size: TypedSize2D<f32, ViewportPx>) + viewport_size: TypedSize2D<f32, CSSPixel>) -> Device { Device { media_type: media_type, @@ -53,7 +53,7 @@ impl Device { /// Returns the viewport size in pixels. #[inline] - pub fn px_viewport_size(&self) -> TypedSize2D<f32, ViewportPx> { + pub fn px_viewport_size(&self) -> TypedSize2D<f32, CSSPixel> { self.viewport_size } diff --git a/components/style/viewport.rs b/components/style/viewport.rs index 30ba3c0e7ab..884a52611ca 100644 --- a/components/style/viewport.rs +++ b/components/style/viewport.rs @@ -12,7 +12,6 @@ use app_units::Au; use cssparser::{AtRuleParser, DeclarationListParser, DeclarationParser, Parser, parse_important}; use cssparser::ToCss as ParserToCss; -use euclid::scale_factor::ScaleFactor; use euclid::size::TypedSize2D; use media_queries::Device; use parser::{ParserContext, log_css_error}; @@ -21,7 +20,7 @@ use std::borrow::Cow; use std::fmt; use std::iter::Enumerate; use std::str::Chars; -use style_traits::ToCss; +use style_traits::{PinchZoomFactor, ToCss}; use style_traits::viewport::{Orientation, UserZoom, ViewportConstraints, Zoom}; use stylesheets::{Stylesheet, Origin}; use values::computed::{Context, ToComputedValue}; @@ -796,9 +795,9 @@ impl MaybeNew for ViewportConstraints { size: TypedSize2D::new(width.to_f32_px(), height.to_f32_px()), // TODO: compute a zoom factor for 'auto' as suggested by DEVICE-ADAPT § 10. - initial_zoom: ScaleFactor::new(initial_zoom.unwrap_or(1.)), - min_zoom: min_zoom.map(ScaleFactor::new), - max_zoom: max_zoom.map(ScaleFactor::new), + initial_zoom: PinchZoomFactor::new(initial_zoom.unwrap_or(1.)), + min_zoom: min_zoom.map(PinchZoomFactor::new), + max_zoom: max_zoom.map(PinchZoomFactor::new), user_zoom: user_zoom, orientation: orientation diff --git a/components/style_traits/lib.rs b/components/style_traits/lib.rs index 4ee378833a4..bc050e811ed 100644 --- a/components/style_traits/lib.rs +++ b/components/style_traits/lib.rs @@ -26,33 +26,41 @@ extern crate rustc_serialize; /// Must be transmutable to and from `TNode`. pub type UnsafeNode = (usize, usize); +/// Represents a mobile style pinch zoom factor. +/// TODO(gw): Once WR supports pinch zoom, use a type directly from webrender_traits. +#[derive(Clone, Copy, Debug, PartialEq)] +#[cfg_attr(feature = "servo", derive(Deserialize, Serialize, HeapSizeOf))] +pub struct PinchZoomFactor(f32); + +impl PinchZoomFactor { + /// Construct a new pinch zoom factor. + pub fn new(scale: f32) -> PinchZoomFactor { + PinchZoomFactor(scale) + } + + /// Get the pinch zoom factor as an untyped float. + pub fn get(&self) -> f32 { + self.0 + } +} + /// One CSS "px" in the coordinate system of the "initial viewport": /// http://www.w3.org/TR/css-device-adapt/#initial-viewport /// -/// `ViewportPx` is equal to `DeviceIndependentPixel` times a "page zoom" factor controlled by the user. This is +/// `CSSPixel` is equal to `DeviceIndependentPixel` times a "page zoom" factor controlled by the user. This is /// the desktop-style "full page" zoom that enlarges content but then reflows the layout viewport /// so it still exactly fits the visible area. /// -/// At the default zoom level of 100%, one `PagePx` is equal to one `DeviceIndependentPixel`. However, if the +/// At the default zoom level of 100%, one `CSSPixel` is equal to one `DeviceIndependentPixel`. However, if the /// document is zoomed in or out then this scale may be larger or smaller. #[derive(Clone, Copy, Debug)] -pub enum ViewportPx {} - -/// One CSS "px" in the root coordinate system for the content document. -/// -/// `PagePx` is equal to `ViewportPx` multiplied by a "viewport zoom" factor controlled by the user. -/// This is the mobile-style "pinch zoom" that enlarges content without reflowing it. When the -/// viewport zoom is not equal to 1.0, then the layout viewport is no longer the same physical size -/// as the viewable area. -#[derive(Clone, Copy, Debug)] -pub enum PagePx {} +pub enum CSSPixel {} // In summary, the hierarchy of pixel units and the factors to convert from one to the next: // // DevicePixel // / hidpi_ratio => DeviceIndependentPixel -// / desktop_zoom => ViewportPx -// / pinch_zoom => PagePx +// / desktop_zoom => CSSPixel pub mod cursor; #[macro_use] diff --git a/components/style_traits/viewport.rs b/components/style_traits/viewport.rs index 42083546ac1..be1df725125 100644 --- a/components/style_traits/viewport.rs +++ b/components/style_traits/viewport.rs @@ -4,9 +4,8 @@ //! Helper types for the `@viewport` rule. -use {PagePx, ViewportPx}; +use {CSSPixel, PinchZoomFactor}; use cssparser::{Parser, ToCss}; -use euclid::scale_factor::ScaleFactor; use euclid::size::TypedSize2D; use std::ascii::AsciiExt; use std::fmt; @@ -31,13 +30,13 @@ pub struct ViewportConstraints { /// Width and height: /// * https://drafts.csswg.org/css-device-adapt/#width-desc /// * https://drafts.csswg.org/css-device-adapt/#height-desc - pub size: TypedSize2D<f32, ViewportPx>, + pub size: TypedSize2D<f32, CSSPixel>, /// https://drafts.csswg.org/css-device-adapt/#zoom-desc - pub initial_zoom: ScaleFactor<f32, PagePx, ViewportPx>, + pub initial_zoom: PinchZoomFactor, /// https://drafts.csswg.org/css-device-adapt/#min-max-width-desc - pub min_zoom: Option<ScaleFactor<f32, PagePx, ViewportPx>>, + pub min_zoom: Option<PinchZoomFactor>, /// https://drafts.csswg.org/css-device-adapt/#min-max-width-desc - pub max_zoom: Option<ScaleFactor<f32, PagePx, ViewportPx>>, + pub max_zoom: Option<PinchZoomFactor>, /// https://drafts.csswg.org/css-device-adapt/#user-zoom-desc pub user_zoom: UserZoom, /// https://drafts.csswg.org/css-device-adapt/#orientation-desc diff --git a/components/webdriver_server/lib.rs b/components/webdriver_server/lib.rs index e243bc2b05e..831a8d323de 100644 --- a/components/webdriver_server/lib.rs +++ b/components/webdriver_server/lib.rs @@ -399,7 +399,7 @@ impl Handler { self.constellation_chan.send(ConstellationMsg::WebDriverCommand(cmd_msg)).unwrap(); let window_size = receiver.recv().unwrap(); - let vp = window_size.visible_viewport; + let vp = window_size.initial_viewport; let window_size_response = WindowSizeResponse::new(vp.width as u64, vp.height as u64); Ok(WebDriverResponse::WindowSize(window_size_response)) } @@ -423,7 +423,7 @@ impl Handler { }); let window_size = receiver.recv().unwrap(); - let vp = window_size.visible_viewport; + let vp = window_size.initial_viewport; let window_size_response = WindowSizeResponse::new(vp.width as u64, vp.height as u64); Ok(WebDriverResponse::WindowSize(window_size_response)) } |