зеркало из https://github.com/mozilla/gecko-dev.git
servo: Merge #15700 - Introduce CSSPixel as a replacement for ViewportPx and PagePx (from glennw:zoom-wip-2); r=mbrubeck
Source-Repo: https://github.com/servo/servo Source-Revision: 1d13e6a2df42af3cce427a0b2062ac70d28c05d0 --HG-- extra : subtree_source : https%3A//hg.mozilla.org/projects/converted-servo-linear extra : subtree_revision : 65cadddcb0ce3aac92adcdbdc9c76b15c88f543d
This commit is contained in:
Родитель
cc5638514c
Коммит
528abf02e1
|
@ -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) {
|
||||
|
|
|
@ -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>,
|
||||
}
|
||||
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -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 {
|
||||
|
|
|
@ -59,7 +59,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, RepeatMode, ScrollPolicy};
|
||||
|
@ -138,7 +138,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> {
|
||||
|
|
|
@ -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!();
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -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)
|
||||
}
|
||||
|
||||
|
|
|
@ -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.
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -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
|
||||
}
|
||||
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -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]
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -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))
|
||||
}
|
||||
|
|
|
@ -3,7 +3,6 @@
|
|||
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
|
||||
|
||||
use cssparser::Parser;
|
||||
use euclid::scale_factor::ScaleFactor;
|
||||
use euclid::size::TypedSize2D;
|
||||
use media_queries::CSSErrorReporterTest;
|
||||
use servo_config::prefs::{PREFS, PrefValue};
|
||||
|
@ -16,6 +15,7 @@ use style::values::specified::LengthOrPercentageOrAuto::{self, Auto};
|
|||
use style::values::specified::NoCalcLength::{self, ViewportPercentage};
|
||||
use style::values::specified::ViewportPercentageLength::Vw;
|
||||
use style::viewport::*;
|
||||
use style_traits::PinchZoomFactor;
|
||||
use style_traits::viewport::*;
|
||||
|
||||
macro_rules! stylesheet {
|
||||
|
@ -295,7 +295,7 @@ fn constrain_viewport() {
|
|||
Some(ViewportConstraints {
|
||||
size: initial_viewport,
|
||||
|
||||
initial_zoom: ScaleFactor::new(1.),
|
||||
initial_zoom: PinchZoomFactor::new(1.),
|
||||
min_zoom: None,
|
||||
max_zoom: None,
|
||||
|
||||
|
@ -307,7 +307,7 @@ fn constrain_viewport() {
|
|||
Some(ViewportConstraints {
|
||||
size: initial_viewport,
|
||||
|
||||
initial_zoom: ScaleFactor::new(1.),
|
||||
initial_zoom: PinchZoomFactor::new(1.),
|
||||
min_zoom: None,
|
||||
max_zoom: None,
|
||||
|
||||
|
@ -322,7 +322,7 @@ fn constrain_viewport() {
|
|||
Some(ViewportConstraints {
|
||||
size: initial_viewport,
|
||||
|
||||
initial_zoom: ScaleFactor::new(1.),
|
||||
initial_zoom: PinchZoomFactor::new(1.),
|
||||
min_zoom: None,
|
||||
max_zoom: None,
|
||||
|
||||
|
@ -336,7 +336,7 @@ fn constrain_viewport() {
|
|||
Some(ViewportConstraints {
|
||||
size: TypedSize2D::new(320., 240.),
|
||||
|
||||
initial_zoom: ScaleFactor::new(1.),
|
||||
initial_zoom: PinchZoomFactor::new(1.),
|
||||
min_zoom: None,
|
||||
max_zoom: None,
|
||||
|
||||
|
|
Загрузка…
Ссылка в новой задаче