2015-09-04 15:46:11 +03:00
|
|
|
/* This Source Code Form is subject to the terms of the Mozilla Public
|
|
|
|
* License, v. 2.0. If a copy of the MPL was not distributed with this
|
|
|
|
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
|
|
|
|
|
|
|
|
//! This module contains shared types and messages for use by devtools/script.
|
|
|
|
//! The traits are here instead of in script so that the devtools crate can be
|
|
|
|
//! modified independently of the rest of Servo.
|
|
|
|
|
|
|
|
#![crate_name = "style_traits"]
|
|
|
|
#![crate_type = "rlib"]
|
2016-06-22 17:43:20 +03:00
|
|
|
|
2016-12-31 14:19:02 +03:00
|
|
|
#![deny(unsafe_code, missing_docs)]
|
2015-09-04 15:46:11 +03:00
|
|
|
|
2016-06-22 17:43:20 +03:00
|
|
|
#![cfg_attr(feature = "servo", feature(plugin))]
|
|
|
|
|
2016-09-02 19:10:01 +03:00
|
|
|
extern crate app_units;
|
2017-02-26 13:19:32 +03:00
|
|
|
#[macro_use] extern crate cssparser;
|
2015-09-04 15:46:11 +03:00
|
|
|
extern crate euclid;
|
2016-06-22 17:43:20 +03:00
|
|
|
#[cfg(feature = "servo")] extern crate heapsize;
|
2016-11-03 05:49:08 +03:00
|
|
|
#[cfg(feature = "servo")] #[macro_use] extern crate heapsize_derive;
|
2016-10-10 04:12:38 +03:00
|
|
|
#[cfg(feature = "servo")] #[macro_use] extern crate serde_derive;
|
2016-07-11 13:17:55 +03:00
|
|
|
|
2016-10-12 10:08:37 +03:00
|
|
|
/// Opaque type stored in type-unsafe work queues for parallel layout.
|
2016-11-14 15:59:35 +03:00
|
|
|
/// Must be transmutable to and from `TNode`.
|
2016-10-12 10:08:37 +03:00
|
|
|
pub type UnsafeNode = (usize, usize);
|
|
|
|
|
2017-02-24 03:01:16 +03:00
|
|
|
/// 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
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2016-07-11 13:17:55 +03:00
|
|
|
/// One CSS "px" in the coordinate system of the "initial viewport":
|
|
|
|
/// http://www.w3.org/TR/css-device-adapt/#initial-viewport
|
|
|
|
///
|
2017-02-24 03:01:16 +03:00
|
|
|
/// `CSSPixel` is equal to `DeviceIndependentPixel` times a "page zoom" factor controlled by the user. This is
|
2016-07-11 13:17:55 +03:00
|
|
|
/// the desktop-style "full page" zoom that enlarges content but then reflows the layout viewport
|
|
|
|
/// so it still exactly fits the visible area.
|
|
|
|
///
|
2017-02-24 03:01:16 +03:00
|
|
|
/// At the default zoom level of 100%, one `CSSPixel` is equal to one `DeviceIndependentPixel`. However, if the
|
2016-07-11 13:17:55 +03:00
|
|
|
/// document is zoomed in or out then this scale may be larger or smaller.
|
|
|
|
#[derive(Clone, Copy, Debug)]
|
2017-02-24 03:01:16 +03:00
|
|
|
pub enum CSSPixel {}
|
2016-07-11 13:17:55 +03:00
|
|
|
|
|
|
|
// In summary, the hierarchy of pixel units and the factors to convert from one to the next:
|
|
|
|
//
|
|
|
|
// DevicePixel
|
2017-02-22 07:45:20 +03:00
|
|
|
// / hidpi_ratio => DeviceIndependentPixel
|
2017-02-24 03:01:16 +03:00
|
|
|
// / desktop_zoom => CSSPixel
|
2015-09-04 15:46:11 +03:00
|
|
|
|
2016-02-16 14:20:20 +03:00
|
|
|
pub mod cursor;
|
2015-09-04 15:46:11 +03:00
|
|
|
#[macro_use]
|
|
|
|
pub mod values;
|
|
|
|
pub mod viewport;
|
2015-11-27 01:26:08 +03:00
|
|
|
|
2017-02-03 16:09:30 +03:00
|
|
|
pub use values::{ToCss, OneOrMoreCommaSeparated};
|