From 346257437f1d061bc10299da825fb4577266bf04 Mon Sep 17 00:00:00 2001 From: Ms2ger Date: Mon, 11 Jul 2016 03:17:55 -0700 Subject: [PATCH] servo: Merge #12381 - Move some unit type definitions to style_traits (from Ms2ger:units); r=nox Source-Repo: https://github.com/servo/servo Source-Revision: 1c7bec4b493174742c579b67ddb6f5411892d3d2 --- servo/components/compositing/compositor.rs | 3 +- servo/components/compositing/lib.rs | 2 +- .../components/constellation/constellation.rs | 2 +- servo/components/constellation/pipeline.rs | 2 +- servo/components/gfx/paint_context.rs | 3 +- servo/components/script_traits/lib.rs | 2 +- servo/components/servo/Cargo.lock | 1 - servo/components/style/media_queries.rs | 2 +- servo/components/style/viewport.rs | 2 +- servo/components/style_traits/Cargo.toml | 3 +- servo/components/style_traits/lib.rs | 29 +++++++++++++++++- servo/components/style_traits/viewport.rs | 2 +- servo/components/util/geometry.rs | 30 +------------------ servo/ports/cef/Cargo.lock | 1 - servo/ports/geckolib/Cargo.lock | 1 - servo/ports/geckolib/data.rs | 2 +- 16 files changed, 42 insertions(+), 45 deletions(-) diff --git a/servo/components/compositing/compositor.rs b/servo/components/compositing/compositor.rs index 8041fd7f1df4..5e5b305ca88c 100644 --- a/servo/components/compositing/compositor.rs +++ b/servo/components/compositing/compositor.rs @@ -45,11 +45,12 @@ use std::mem as std_mem; use std::rc::Rc; use std::sync::mpsc::Sender; use style_traits::viewport::ViewportConstraints; +use style_traits::{PagePx, ViewportPx}; use surface_map::SurfaceMap; use time::{precise_time_ns, precise_time_s}; use touch::{TouchHandler, TouchAction}; use url::Url; -use util::geometry::{PagePx, ScreenPx, ViewportPx}; +use util::geometry::ScreenPx; use util::opts; use util::prefs::PREFS; use webrender; diff --git a/servo/components/compositing/lib.rs b/servo/components/compositing/lib.rs index c76d163feb97..1f510d39e8d3 100644 --- a/servo/components/compositing/lib.rs +++ b/servo/components/compositing/lib.rs @@ -43,7 +43,7 @@ use ipc_channel::ipc::IpcSender; use msg::constellation_msg::PipelineId; use script_traits::{ConstellationControlMsg, LayoutControlMsg}; use std::sync::mpsc::Sender; -use util::geometry::PagePx; +use style_traits::PagePx; mod compositor; mod compositor_layer; diff --git a/servo/components/constellation/constellation.rs b/servo/components/constellation/constellation.rs index 0920a4a523fe..699b77ba1f1e 100644 --- a/servo/components/constellation/constellation.rs +++ b/servo/components/constellation/constellation.rs @@ -53,11 +53,11 @@ use std::marker::PhantomData; use std::mem::replace; use std::process; use std::sync::mpsc::{Sender, channel, Receiver}; +use style_traits::PagePx; use style_traits::cursor::Cursor; use style_traits::viewport::ViewportConstraints; use timer_scheduler::TimerScheduler; use url::Url; -use util::geometry::PagePx; use util::opts; use util::prefs::PREFS; use util::thread::spawn_named; diff --git a/servo/components/constellation/pipeline.rs b/servo/components/constellation/pipeline.rs index 5c472dc250e6..bd9988364a24 100644 --- a/servo/components/constellation/pipeline.rs +++ b/servo/components/constellation/pipeline.rs @@ -31,9 +31,9 @@ use std::collections::HashMap; use std::io::Error as IOError; use std::process; use std::sync::mpsc::{Sender, channel}; +use style_traits::{PagePx, ViewportPx}; use url::Url; use util; -use util::geometry::{PagePx, ViewportPx}; use util::ipc::OptionalIpcSender; use util::opts::{self, Opts}; use util::prefs::{PREFS, Pref}; diff --git a/servo/components/gfx/paint_context.rs b/servo/components/gfx/paint_context.rs index 5a8d8580bd6b..2614e77fc821 100644 --- a/servo/components/gfx/paint_context.rs +++ b/servo/components/gfx/paint_context.rs @@ -32,9 +32,10 @@ use range::Range; use std::default::Default; use std::{f32, mem, ptr}; use style::computed_values::{border_style, filter, image_rendering, mix_blend_mode}; +use style_traits::PagePx; use text::TextRun; use text::glyph::ByteIndex; -use util::geometry::{self, MAX_RECT, PagePx, ScreenPx}; +use util::geometry::{self, MAX_RECT, ScreenPx}; use util::opts; pub struct PaintContext<'a> { diff --git a/servo/components/script_traits/lib.rs b/servo/components/script_traits/lib.rs index 5c6064a3d3eb..ab1a7d7ee523 100644 --- a/servo/components/script_traits/lib.rs +++ b/servo/components/script_traits/lib.rs @@ -61,8 +61,8 @@ use profile_traits::mem; use serde::{Deserialize, Deserializer, Serialize, Serializer}; use std::collections::HashMap; use std::sync::mpsc::{Sender, Receiver}; +use style_traits::{PagePx, ViewportPx}; use url::Url; -use util::geometry::{PagePx, ViewportPx}; use util::ipc::OptionalOpaqueIpcSender; use webdriver_msg::{LoadStatus, WebDriverScriptCommand}; diff --git a/servo/components/servo/Cargo.lock b/servo/components/servo/Cargo.lock index dad006a243ca..9d43557ece1f 100644 --- a/servo/components/servo/Cargo.lock +++ b/servo/components/servo/Cargo.lock @@ -2282,7 +2282,6 @@ dependencies = [ "rustc-serialize 0.3.19 (registry+https://github.com/rust-lang/crates.io-index)", "serde 0.7.11 (registry+https://github.com/rust-lang/crates.io-index)", "serde_macros 0.7.11 (registry+https://github.com/rust-lang/crates.io-index)", - "util 0.0.1", ] [[package]] diff --git a/servo/components/style/media_queries.rs b/servo/components/style/media_queries.rs index a32237533501..59c1a24e3550 100644 --- a/servo/components/style/media_queries.rs +++ b/servo/components/style/media_queries.rs @@ -10,7 +10,7 @@ use app_units::Au; use cssparser::{Delimiter, Parser, Token}; use euclid::size::{Size2D, TypedSize2D}; use properties::longhands; -use util::geometry::ViewportPx; +use style_traits::ViewportPx; use values::specified; diff --git a/servo/components/style/viewport.rs b/servo/components/style/viewport.rs index 064114259224..175165a2864d 100644 --- a/servo/components/style/viewport.rs +++ b/servo/components/style/viewport.rs @@ -18,9 +18,9 @@ use std::ascii::AsciiExt; use std::fmt; use std::iter::Enumerate; use std::str::Chars; +use style_traits::ViewportPx; use style_traits::viewport::{Orientation, UserZoom, ViewportConstraints, Zoom}; use stylesheets::Origin; -use util::geometry::ViewportPx; use values::computed::{Context, ToComputedValue}; use values::specified::{Length, LengthOrPercentageOrAuto, ViewportPercentageLength}; diff --git a/servo/components/style_traits/Cargo.toml b/servo/components/style_traits/Cargo.toml index 4d55194fd900..18f05f72d0a1 100644 --- a/servo/components/style_traits/Cargo.toml +++ b/servo/components/style_traits/Cargo.toml @@ -10,7 +10,7 @@ path = "lib.rs" [features] servo = ["heapsize", "heapsize_plugin", "serde", "serde_macros", "euclid/plugins", - "cssparser/heap_size", "cssparser/serde-serialization", "util/servo"] + "cssparser/heap_size", "cssparser/serde-serialization"] [dependencies] cssparser = "0.5.4" @@ -20,4 +20,3 @@ heapsize_plugin = {version = "0.1.2", optional = true} rustc-serialize = "0.3" serde = {version = "0.7.11", optional = true} serde_macros = {version = "0.7.11", optional = true} -util = {path = "../util"} diff --git a/servo/components/style_traits/lib.rs b/servo/components/style_traits/lib.rs index 3b68e412d36c..c55447d301a8 100644 --- a/servo/components/style_traits/lib.rs +++ b/servo/components/style_traits/lib.rs @@ -22,7 +22,34 @@ extern crate euclid; #[cfg(feature = "servo")] extern crate heapsize; extern crate rustc_serialize; #[cfg(feature = "servo")] extern crate serde; -extern crate util; + +/// 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 ScreenPx 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 ScreenPx. 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 {} + +// In summary, the hierarchy of pixel units and the factors to convert from one to the next: +// +// DevicePixel +// / hidpi_ratio => ScreenPx +// / desktop_zoom => ViewportPx +// / pinch_zoom => PagePx pub mod cursor; #[macro_use] diff --git a/servo/components/style_traits/viewport.rs b/servo/components/style_traits/viewport.rs index 96075f7a5e3e..deac9d68905b 100644 --- a/servo/components/style_traits/viewport.rs +++ b/servo/components/style_traits/viewport.rs @@ -7,8 +7,8 @@ use euclid::scale_factor::ScaleFactor; use euclid::size::TypedSize2D; use std::ascii::AsciiExt; use std::fmt; -use util::geometry::{PagePx, ViewportPx}; use values::specified::AllowedNumericType; +use {PagePx, ViewportPx}; define_css_keyword_enum!(UserZoom: "zoom" => Zoom, diff --git a/servo/components/util/geometry.rs b/servo/components/util/geometry.rs index d750131f151f..95b6194a14ef 100644 --- a/servo/components/util/geometry.rs +++ b/servo/components/util/geometry.rs @@ -26,35 +26,7 @@ use std::i32; #[derive(Clone, Copy, Debug)] pub enum ScreenPx {} -/// 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 ScreenPx 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 ScreenPx. 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 {} - -known_heap_size!(0, ScreenPx, ViewportPx, PagePx); - -// In summary, the hierarchy of pixel units and the factors to convert from one to the next: -// -// DevicePixel -// / hidpi_ratio => ScreenPx -// / desktop_zoom => ViewportPx -// / pinch_zoom => PagePx +known_heap_size!(0, ScreenPx); // An Au is an "App Unit" and represents 1/60th of a CSS pixel. It was // originally proposed in 2002 as a standard unit of measure in Gecko. diff --git a/servo/ports/cef/Cargo.lock b/servo/ports/cef/Cargo.lock index 019f1b0d4840..d5a48dc268ee 100644 --- a/servo/ports/cef/Cargo.lock +++ b/servo/ports/cef/Cargo.lock @@ -2151,7 +2151,6 @@ dependencies = [ "rustc-serialize 0.3.19 (registry+https://github.com/rust-lang/crates.io-index)", "serde 0.7.11 (registry+https://github.com/rust-lang/crates.io-index)", "serde_macros 0.7.11 (registry+https://github.com/rust-lang/crates.io-index)", - "util 0.0.1", ] [[package]] diff --git a/servo/ports/geckolib/Cargo.lock b/servo/ports/geckolib/Cargo.lock index d5a0608dde34..56ddf17d9a5d 100644 --- a/servo/ports/geckolib/Cargo.lock +++ b/servo/ports/geckolib/Cargo.lock @@ -340,7 +340,6 @@ dependencies = [ "cssparser 0.5.6 (registry+https://github.com/rust-lang/crates.io-index)", "euclid 0.7.1 (registry+https://github.com/rust-lang/crates.io-index)", "rustc-serialize 0.3.19 (registry+https://github.com/rust-lang/crates.io-index)", - "util 0.0.1", ] [[package]] diff --git a/servo/ports/geckolib/data.rs b/servo/ports/geckolib/data.rs index 02fdece24113..e50f98261d52 100644 --- a/servo/ports/geckolib/data.rs +++ b/servo/ports/geckolib/data.rs @@ -16,7 +16,7 @@ use style::dom::OpaqueNode; use style::media_queries::{Device, MediaType}; use style::parallel::WorkQueueData; use style::workqueue::WorkQueue; -use util::geometry::ViewportPx; +use style_traits::ViewportPx; use util::thread_state; pub struct PerDocumentStyleData {