Split Au type into separate crate, with minimal dependencies.

This commit is contained in:
Glenn Watson 2015-09-28 16:53:00 +10:00
parent fb6d0946cb
commit 339a3f869b
72 changed files with 376 additions and 235 deletions

View file

@ -0,0 +1,10 @@
[package]
name = "app_units"
version = "0.1.0"
authors = ["The Servo Project Developers"]
[dependencies]
serde = "0.6"
serde_macros = "0.5"
rustc-serialize = "0.3"
euclid = "0.2"

View file

@ -0,0 +1,154 @@
/* 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/. */
use euclid::num::Zero;
use rustc_serialize::{Encodable, Encoder};
use std::default::Default;
use std::fmt;
use std::i32;
use std::ops::{Add, Div, Mul, Neg, Rem, Sub};
/// The number of app units in a pixel.
pub const AU_PER_PX: i32 = 60;
#[derive(Clone, Copy, Hash, PartialEq, PartialOrd, Eq, Ord, Deserialize, Serialize)]
pub struct Au(pub i32);
impl Default for Au {
#[inline]
fn default() -> Au {
Au(0)
}
}
impl Zero for Au {
#[inline]
fn zero() -> Au {
Au(0)
}
}
pub const MIN_AU: Au = Au(i32::MIN);
pub const MAX_AU: Au = Au(i32::MAX);
impl Encodable for Au {
fn encode<S: Encoder>(&self, e: &mut S) -> Result<(), S::Error> {
e.emit_f64(self.to_f64_px())
}
}
impl fmt::Debug for Au {
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
write!(f, "{}px", self.to_f64_px())
}
}
impl Add for Au {
type Output = Au;
#[inline]
fn add(self, other: Au) -> Au {
Au(self.0.wrapping_add(other.0))
}
}
impl Sub for Au {
type Output = Au;
#[inline]
fn sub(self, other: Au) -> Au {
Au(self.0.wrapping_sub(other.0))
}
}
impl Mul<i32> for Au {
type Output = Au;
#[inline]
fn mul(self, other: i32) -> Au {
Au(self.0.wrapping_mul(other))
}
}
impl Div<i32> for Au {
type Output = Au;
#[inline]
fn div(self, other: i32) -> Au {
Au(self.0 / other)
}
}
impl Rem<i32> for Au {
type Output = Au;
#[inline]
fn rem(self, other: i32) -> Au {
Au(self.0 % other)
}
}
impl Neg for Au {
type Output = Au;
#[inline]
fn neg(self) -> Au {
Au(-self.0)
}
}
impl Au {
/// FIXME(pcwalton): Workaround for lack of cross crate inlining of newtype structs!
#[inline]
pub fn new(value: i32) -> Au {
Au(value)
}
#[inline]
pub fn scale_by(self, factor: f32) -> Au {
Au(((self.0 as f32) * factor) as i32)
}
#[inline]
pub fn from_px(px: i32) -> Au {
Au((px * AU_PER_PX) as i32)
}
/// Rounds this app unit down to the pixel towards zero and returns it.
#[inline]
pub fn to_px(self) -> i32 {
self.0 / AU_PER_PX
}
#[inline]
pub fn to_nearest_px(self) -> i32 {
((self.0 as f64) / (AU_PER_PX as f64)).round() as i32
}
#[inline]
pub fn to_nearest_pixel(self, pixels_per_px: f32) -> f32 {
((self.0 as f32) / (AU_PER_PX as f32) * pixels_per_px).round() / pixels_per_px
}
#[inline]
pub fn to_f32_px(self) -> f32 {
(self.0 as f32) / (AU_PER_PX as f32)
}
#[inline]
pub fn to_f64_px(self) -> f64 {
(self.0 as f64) / (AU_PER_PX as f64)
}
#[inline]
pub fn from_f32_px(px: f32) -> Au {
Au((px * (AU_PER_PX as f32)) as i32)
}
#[inline]
pub fn from_f64_px(px: f64) -> Au {
Au((px * (AU_PER_PX as f64)) as i32)
}
}

View file

@ -0,0 +1,16 @@
/* 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/. */
#![feature(custom_derive)]
#![feature(plugin)]
#![plugin(serde_macros)]
extern crate euclid;
extern crate rustc_serialize;
extern crate serde;
mod app_unit;
pub use app_unit::{Au, MIN_AU, MAX_AU, AU_PER_PX};

View file

@ -7,6 +7,9 @@ authors = ["The Servo Project Developers"]
name = "compositing" name = "compositing"
path = "lib.rs" path = "lib.rs"
[dependencies.app_units]
path = "../app_units"
[dependencies.gfx] [dependencies.gfx]
path = "../gfx" path = "../gfx"

View file

@ -2,6 +2,7 @@
* License, v. 2.0. If a copy of the MPL was not distributed with this * 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/. */ * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
use app_units::Au;
use compositor_layer::{CompositorData, CompositorLayer, RcCompositorLayer, WantsScrollEventsFlag}; use compositor_layer::{CompositorData, CompositorLayer, RcCompositorLayer, WantsScrollEventsFlag};
use compositor_task::{CompositorEventListener, CompositorProxy}; use compositor_task::{CompositorEventListener, CompositorProxy};
use compositor_task::{CompositorReceiver, InitialCompositorState, Msg}; use compositor_task::{CompositorReceiver, InitialCompositorState, Msg};
@ -46,7 +47,7 @@ use style_traits::viewport::ViewportConstraints;
use surface_map::SurfaceMap; use surface_map::SurfaceMap;
use time::{precise_time_ns, precise_time_s}; use time::{precise_time_ns, precise_time_s};
use url::Url; use url::Url;
use util::geometry::{Au, PagePx, ScreenPx, ViewportPx}; use util::geometry::{PagePx, ScreenPx, ViewportPx};
use util::opts; use util::opts;
use windowing::{self, MouseWindowEvent, WindowEvent, WindowMethods, WindowNavigateMsg}; use windowing::{self, MouseWindowEvent, WindowEvent, WindowMethods, WindowNavigateMsg};

View file

@ -11,6 +11,7 @@
#![deny(unsafe_code)] #![deny(unsafe_code)]
extern crate app_units;
#[macro_use] #[macro_use]
extern crate log; extern crate log;
#[macro_use] #[macro_use]

View file

@ -25,6 +25,9 @@ string_cache = "0.1"
time = "0.1.12" time = "0.1.12"
unicode-script = { version = "0.1", features = ["harfbuzz"] } unicode-script = { version = "0.1", features = ["harfbuzz"] }
[dependencies.app_units]
path = "../app_units"
[dependencies.plugins] [dependencies.plugins]
path = "../plugins" path = "../plugins"

View file

@ -14,6 +14,7 @@
//! They are therefore not exactly analogous to constructs like Skia pictures, which consist of //! They are therefore not exactly analogous to constructs like Skia pictures, which consist of
//! low-level drawing primitives. //! low-level drawing primitives.
use app_units::Au;
use azure::azure::AzFloat; use azure::azure::AzFloat;
use azure::azure_hl::{Color, DrawTarget}; use azure::azure_hl::{Color, DrawTarget};
use display_list::optimizer::DisplayListOptimizer; use display_list::optimizer::DisplayListOptimizer;
@ -40,7 +41,7 @@ use style::properties::ComputedValues;
use text::TextRun; use text::TextRun;
use text::glyph::CharIndex; use text::glyph::CharIndex;
use util::cursor::Cursor; use util::cursor::Cursor;
use util::geometry::{self, Au, MAX_RECT, ZERO_RECT}; use util::geometry::{self, MAX_RECT, ZERO_RECT};
use util::linked_list::prepend_from; use util::linked_list::prepend_from;
use util::mem::HeapSizeOf; use util::mem::HeapSizeOf;
use util::opts; use util::opts;

View file

@ -4,12 +4,13 @@
//! Transforms a display list to produce a visually-equivalent, but cheaper-to-paint, one. //! Transforms a display list to produce a visually-equivalent, but cheaper-to-paint, one.
use app_units::Au;
use display_list::{DisplayItem, DisplayList, StackingContext}; use display_list::{DisplayItem, DisplayList, StackingContext};
use euclid::rect::Rect; use euclid::rect::Rect;
use euclid::{Matrix2D, Matrix4}; use euclid::{Matrix2D, Matrix4};
use std::collections::linked_list::LinkedList; use std::collections::linked_list::LinkedList;
use std::sync::Arc; use std::sync::Arc;
use util::geometry::{self, Au}; use util::geometry;
/// Transforms a display list to produce a visually-equivalent, but cheaper-to-paint, one. /// Transforms a display list to produce a visually-equivalent, but cheaper-to-paint, one.
pub struct DisplayListOptimizer { pub struct DisplayListOptimizer {

View file

@ -4,13 +4,13 @@
//! CSS and SVG filter support. //! CSS and SVG filter support.
use app_units::Au;
use azure::AzFloat; use azure::AzFloat;
use azure::azure_hl::{ColorMatrixAttribute, ColorMatrixInput, CompositeInput, DrawTarget}; use azure::azure_hl::{ColorMatrixAttribute, ColorMatrixInput, CompositeInput, DrawTarget};
use azure::azure_hl::{FilterNode, FilterType, LinearTransferAttribute, LinearTransferInput}; use azure::azure_hl::{FilterNode, FilterType, LinearTransferAttribute, LinearTransferInput};
use azure::azure_hl::{GaussianBlurAttribute, GaussianBlurInput}; use azure::azure_hl::{GaussianBlurAttribute, GaussianBlurInput};
use azure::azure_hl::{Matrix5x4, TableTransferAttribute, TableTransferInput}; use azure::azure_hl::{Matrix5x4, TableTransferAttribute, TableTransferInput};
use style::computed_values::filter; use style::computed_values::filter;
use util::geometry::Au;
/// Creates a filter pipeline from a set of CSS filters. Returns the destination end of the filter /// Creates a filter pipeline from a set of CSS filters. Returns the destination end of the filter
/// pipeline and the opacity. /// pipeline and the opacity.

View file

@ -2,6 +2,7 @@
* License, v. 2.0. If a copy of the MPL was not distributed with this * 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/. */ * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
use app_units::Au;
use euclid::{Point2D, Rect, Size2D}; use euclid::{Point2D, Rect, Size2D};
use font_template::FontTemplateDescriptor; use font_template::FontTemplateDescriptor;
use platform::font::{FontHandle, FontTable}; use platform::font::{FontHandle, FontTable};
@ -20,7 +21,6 @@ use text::glyph::{GlyphId, GlyphStore};
use text::shaping::ShaperMethods; use text::shaping::ShaperMethods;
use unicode_script::Script; use unicode_script::Script;
use util::cache::HashCache; use util::cache::HashCache;
use util::geometry::Au;
// FontHandle encapsulates access to the platform's font API, // FontHandle encapsulates access to the platform's font API,
// e.g. quartz, FreeType. It provides access to metrics and tables // e.g. quartz, FreeType. It provides access to metrics and tables

View file

@ -2,6 +2,7 @@
* License, v. 2.0. If a copy of the MPL was not distributed with this * 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/. */ * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
use app_units::Au;
use azure::azure_hl::BackendType; use azure::azure_hl::BackendType;
#[cfg(any(target_os = "linux", target_os = "android"))] #[cfg(any(target_os = "linux", target_os = "android"))]
use azure::scaled_font::FontInfo; use azure::scaled_font::FontInfo;
@ -28,7 +29,6 @@ use std::sync::atomic::{AtomicUsize, Ordering, ATOMIC_USIZE_INIT};
use string_cache::Atom; use string_cache::Atom;
use style::computed_values::{font_style, font_variant}; use style::computed_values::{font_style, font_variant};
use util::cache::HashCache; use util::cache::HashCache;
use util::geometry::Au;
use util::mem::HeapSizeOf; use util::mem::HeapSizeOf;
#[cfg(any(target_os = "linux", target_os = "android"))] #[cfg(any(target_os = "linux", target_os = "android"))]

View file

@ -20,6 +20,7 @@
#![plugin(plugins)] #![plugin(plugins)]
#![plugin(serde_macros)] #![plugin(serde_macros)]
extern crate app_units;
#[macro_use] #[macro_use]
extern crate bitflags; extern crate bitflags;
#[macro_use] #[macro_use]

View file

@ -4,6 +4,7 @@
//! Painting of display lists using Moz2D/Azure. //! Painting of display lists using Moz2D/Azure.
use app_units::Au;
use azure::azure::AzIntSize; use azure::azure::AzIntSize;
use azure::azure_hl::{AntialiasMode, Color, ColorPattern, CompositionOp}; use azure::azure_hl::{AntialiasMode, Color, ColorPattern, CompositionOp};
use azure::azure_hl::{CapStyle, JoinStyle}; use azure::azure_hl::{CapStyle, JoinStyle};
@ -34,7 +35,7 @@ use std::{f32, mem, ptr};
use style::computed_values::{border_style, filter, image_rendering, mix_blend_mode}; use style::computed_values::{border_style, filter, image_rendering, mix_blend_mode};
use text::TextRun; use text::TextRun;
use text::glyph::CharIndex; use text::glyph::CharIndex;
use util::geometry::{self, Au, MAX_RECT, ZERO_POINT, ZERO_RECT}; use util::geometry::{self, MAX_RECT, ZERO_POINT, ZERO_RECT};
use util::opts; use util::opts;
use util::range::Range; use util::range::Range;

View file

@ -4,6 +4,7 @@
//! The task that handles all painting. //! The task that handles all painting.
use app_units::Au;
use azure::AzFloat; use azure::AzFloat;
use azure::azure_hl::{BackendType, Color, DrawTarget, SurfaceFormat}; use azure::azure_hl::{BackendType, Color, DrawTarget, SurfaceFormat};
use canvas_traits::CanvasMsg; use canvas_traits::CanvasMsg;
@ -33,7 +34,7 @@ use std::mem as std_mem;
use std::sync::Arc; use std::sync::Arc;
use std::sync::mpsc::{Receiver, Select, Sender, channel}; use std::sync::mpsc::{Receiver, Select, Sender, channel};
use url::Url; use url::Url;
use util::geometry::{Au, ZERO_POINT}; use util::geometry::ZERO_POINT;
use util::opts; use util::opts;
use util::task::spawn_named; use util::task::spawn_named;
use util::task::spawn_named_with_send_on_failure; use util::task::spawn_named_with_send_on_failure;

View file

@ -4,6 +4,7 @@
extern crate freetype; extern crate freetype;
use app_units::Au;
use font::{FontHandleMethods, FontMetrics, FontTableMethods}; use font::{FontHandleMethods, FontMetrics, FontTableMethods};
use font::{FontTableTag, FractionalPixel}; use font::{FontTableTag, FractionalPixel};
use freetype::freetype::{FTErrorMethods, FT_F26Dot6, FT_Face, FT_FaceRec}; use freetype::freetype::{FTErrorMethods, FT_F26Dot6, FT_Face, FT_FaceRec};
@ -24,7 +25,6 @@ use std::{mem, ptr};
use style::computed_values::{font_stretch, font_weight}; use style::computed_values::{font_stretch, font_weight};
use text::glyph::GlyphId; use text::glyph::GlyphId;
use text::util::{fixed_to_float, float_to_fixed}; use text::util::{fixed_to_float, float_to_fixed};
use util::geometry::Au;
use util::str::c_str_to_string; use util::str::c_str_to_string;
fn float_to_fixed_ft(f: f64) -> i32 { fn float_to_fixed_ft(f: f64) -> i32 {

View file

@ -8,6 +8,7 @@ extern crate core_foundation;
extern crate core_graphics; extern crate core_graphics;
extern crate core_text; extern crate core_text;
use app_units::Au;
use core_foundation::base::CFIndex; use core_foundation::base::CFIndex;
use core_foundation::data::CFData; use core_foundation::data::CFData;
use core_foundation::string::UniChar; use core_foundation::string::UniChar;
@ -25,7 +26,6 @@ use std::ptr;
use std::sync::Arc; use std::sync::Arc;
use style::computed_values::{font_stretch, font_weight}; use style::computed_values::{font_stretch, font_weight};
use text::glyph::GlyphId; use text::glyph::GlyphId;
use util::geometry::Au;
pub struct FontTable { pub struct FontTable {
data: CFData, data: CFData,

View file

@ -2,13 +2,13 @@
* License, v. 2.0. If a copy of the MPL was not distributed with this * 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/. */ * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
use app_units::Au;
use euclid::point::Point2D; use euclid::point::Point2D;
#[cfg(any(target_arch = "x86_64", target_arch = "aarch64"))] #[cfg(any(target_arch = "x86_64", target_arch = "aarch64"))]
use simd::u32x4; use simd::u32x4;
use std::cmp::{Ordering, PartialOrd}; use std::cmp::{Ordering, PartialOrd};
use std::vec::Vec; use std::vec::Vec;
use std::{fmt, mem, u16}; use std::{fmt, mem, u16};
use util::geometry::Au;
use util::range::{self, EachIndex, Range, RangeIndex}; use util::range::{self, EachIndex, Range, RangeIndex};
use util::vec::*; use util::vec::*;

View file

@ -2,6 +2,7 @@
* License, v. 2.0. If a copy of the MPL was not distributed with this * 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/. */ * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
use app_units::Au;
use euclid::Point2D; use euclid::Point2D;
use font::{DISABLE_KERNING_SHAPING_FLAG, Font, FontHandleMethods, FontTableMethods, FontTableTag}; use font::{DISABLE_KERNING_SHAPING_FLAG, Font, FontHandleMethods, FontTableMethods, FontTableTag};
use font::{IGNORE_LIGATURES_SHAPING_FLAG, RTL_FLAG, ShapingOptions}; use font::{IGNORE_LIGATURES_SHAPING_FLAG, RTL_FLAG, ShapingOptions};
@ -37,7 +38,6 @@ use std::{char, cmp, ptr};
use text::glyph::{CharIndex, GlyphData, GlyphId, GlyphStore}; use text::glyph::{CharIndex, GlyphData, GlyphId, GlyphStore};
use text::shaping::ShaperMethods; use text::shaping::ShaperMethods;
use text::util::{fixed_to_float, float_to_fixed, is_bidi_control}; use text::util::{fixed_to_float, float_to_fixed, is_bidi_control};
use util::geometry::Au;
use util::range::Range; use util::range::Range;
macro_rules! hb_tag { macro_rules! hb_tag {

View file

@ -2,6 +2,7 @@
* License, v. 2.0. If a copy of the MPL was not distributed with this * 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/. */ * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
use app_units::Au;
use font::{Font, FontHandleMethods, FontMetrics, IS_WHITESPACE_SHAPING_FLAG, RunMetrics}; use font::{Font, FontHandleMethods, FontMetrics, IS_WHITESPACE_SHAPING_FLAG, RunMetrics};
use font::{ShapingOptions}; use font::{ShapingOptions};
use platform::font_template::FontTemplateData; use platform::font_template::FontTemplateData;
@ -9,7 +10,6 @@ use std::cmp::{Ordering, max};
use std::slice::Iter; use std::slice::Iter;
use std::sync::Arc; use std::sync::Arc;
use text::glyph::{CharIndex, GlyphStore}; use text::glyph::{CharIndex, GlyphStore};
use util::geometry::Au;
use util::range::Range; use util::range::Range;
use util::vec::{Comparator, FullBinarySearchMethods}; use util::vec::{Comparator, FullBinarySearchMethods};

View file

@ -7,6 +7,9 @@ authors = ["The Servo Project Developers"]
name = "layout" name = "layout"
path = "lib.rs" path = "lib.rs"
[dependencies.app_units]
path = "../app_units"
[dependencies.azure] [dependencies.azure]
git = "https://github.com/servo/rust-azure" git = "https://github.com/servo/rust-azure"

View file

@ -27,6 +27,7 @@
#![deny(unsafe_code)] #![deny(unsafe_code)]
use app_units::{Au, MAX_AU};
use context::LayoutContext; use context::LayoutContext;
use display_list_builder::{BlockFlowDisplayListBuilding, BorderPaintingMode}; use display_list_builder::{BlockFlowDisplayListBuilding, BorderPaintingMode};
use display_list_builder::{FragmentDisplayListBuilding}; use display_list_builder::{FragmentDisplayListBuilding};
@ -60,7 +61,7 @@ use style::computed_values::{position, text_align, transform, transform_style};
use style::properties::ComputedValues; use style::properties::ComputedValues;
use style::values::computed::{LengthOrNone, LengthOrPercentageOrNone}; use style::values::computed::{LengthOrNone, LengthOrPercentageOrNone};
use style::values::computed::{LengthOrPercentage, LengthOrPercentageOrAuto}; use style::values::computed::{LengthOrPercentage, LengthOrPercentageOrAuto};
use util::geometry::{Au, MAX_AU, MAX_RECT}; use util::geometry::MAX_RECT;
use util::logical_geometry::{LogicalPoint, LogicalRect, LogicalSize, WritingMode}; use util::logical_geometry::{LogicalPoint, LogicalRect, LogicalSize, WritingMode};
use util::opts; use util::opts;
use wrapper::PseudoElementType; use wrapper::PseudoElementType;

View file

@ -6,6 +6,7 @@
#![deny(unsafe_code)] #![deny(unsafe_code)]
use app_units::Au;
use canvas_traits::CanvasMsg; use canvas_traits::CanvasMsg;
use css::matching::{ApplicableDeclarationsCache, StyleSharingCandidateCache}; use css::matching::{ApplicableDeclarationsCache, StyleSharingCandidateCache};
use euclid::{Rect, Size2D}; use euclid::{Rect, Size2D};
@ -28,7 +29,6 @@ use std::sync::Arc;
use std::sync::mpsc::{Sender, channel}; use std::sync::mpsc::{Sender, channel};
use style::selector_matching::Stylist; use style::selector_matching::Stylist;
use url::Url; use url::Url;
use util::geometry::Au;
use util::mem::HeapSizeOf; use util::mem::HeapSizeOf;
use util::opts; use util::opts;

View file

@ -10,6 +10,7 @@
#![deny(unsafe_code)] #![deny(unsafe_code)]
use app_units::{Au, AU_PER_PX};
use azure::azure_hl::Color; use azure::azure_hl::Color;
use block::BlockFlow; use block::BlockFlow;
use canvas_traits::{CanvasMsg, FromLayoutMsg}; use canvas_traits::{CanvasMsg, FromLayoutMsg};
@ -56,7 +57,7 @@ use style::values::specified::{AngleOrCorner, HorizontalDirection, VerticalDirec
use table_cell::CollapsedBordersForCell; use table_cell::CollapsedBordersForCell;
use url::Url; use url::Url;
use util::cursor::Cursor; use util::cursor::Cursor;
use util::geometry::{AU_PER_PX, Au, ZERO_POINT}; use util::geometry::ZERO_POINT;
use util::logical_geometry::{LogicalPoint, LogicalRect, LogicalSize, WritingMode}; use util::logical_geometry::{LogicalPoint, LogicalRect, LogicalSize, WritingMode};
use util::opts; use util::opts;
use util::range::Range; use util::range::Range;

View file

@ -6,6 +6,7 @@
#![deny(unsafe_code)] #![deny(unsafe_code)]
use app_units::Au;
use block::BlockFlow; use block::BlockFlow;
use context::LayoutContext; use context::LayoutContext;
use display_list_builder::FlexFlowDisplayListBuilding; use display_list_builder::FlexFlowDisplayListBuilding;
@ -30,7 +31,6 @@ use style::computed_values::{flex_direction, float};
use style::properties::ComputedValues; use style::properties::ComputedValues;
use style::properties::style_structs; use style::properties::style_structs;
use style::values::computed::LengthOrPercentageOrAuto; use style::values::computed::LengthOrPercentageOrAuto;
use util::geometry::Au;
use util::logical_geometry::LogicalSize; use util::logical_geometry::LogicalSize;
use util::opts; use util::opts;

View file

@ -2,11 +2,11 @@
* License, v. 2.0. If a copy of the MPL was not distributed with this * 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/. */ * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
use app_units::Au;
use std::cmp::{max, min}; use std::cmp::{max, min};
use std::fmt; use std::fmt;
use std::i32; use std::i32;
use style::computed_values::float; use style::computed_values::float;
use util::geometry::Au;
use util::logical_geometry::WritingMode; use util::logical_geometry::WritingMode;
use util::logical_geometry::{LogicalRect, LogicalSize}; use util::logical_geometry::{LogicalRect, LogicalSize};
use util::persistent_list::PersistentList; use util::persistent_list::PersistentList;

View file

@ -25,6 +25,7 @@
//! line breaks and mapping to CSS boxes, for the purpose of handling `getClientRects()` and //! line breaks and mapping to CSS boxes, for the purpose of handling `getClientRects()` and
//! similar methods. //! similar methods.
use app_units::Au;
use block::BlockFlow; use block::BlockFlow;
use context::LayoutContext; use context::LayoutContext;
use display_list_builder::DisplayListBuildingResult; use display_list_builder::DisplayListBuildingResult;
@ -57,7 +58,7 @@ use table_colgroup::TableColGroupFlow;
use table_row::TableRowFlow; use table_row::TableRowFlow;
use table_rowgroup::TableRowGroupFlow; use table_rowgroup::TableRowGroupFlow;
use table_wrapper::TableWrapperFlow; use table_wrapper::TableWrapperFlow;
use util::geometry::{Au, ZERO_RECT}; use util::geometry::ZERO_RECT;
use util::logical_geometry::{LogicalRect, LogicalSize, WritingMode}; use util::logical_geometry::{LogicalRect, LogicalSize, WritingMode};
use wrapper::{PseudoElementType, ThreadSafeLayoutNode}; use wrapper::{PseudoElementType, ThreadSafeLayoutNode};

View file

@ -6,6 +6,7 @@
#![deny(unsafe_code)] #![deny(unsafe_code)]
use app_units::Au;
use canvas_traits::CanvasMsg; use canvas_traits::CanvasMsg;
use context::LayoutContext; use context::LayoutContext;
use euclid::{Point2D, Rect, Size2D}; use euclid::{Point2D, Rect, Size2D};
@ -43,7 +44,7 @@ use text;
use text::TextRunScanner; use text::TextRunScanner;
use url::Url; use url::Url;
use util; use util;
use util::geometry::{Au, ZERO_POINT}; use util::geometry::ZERO_POINT;
use util::logical_geometry::{LogicalMargin, LogicalRect, LogicalSize, WritingMode}; use util::logical_geometry::{LogicalMargin, LogicalRect, LogicalSize, WritingMode};
use util::range::*; use util::range::*;
use util::str::{is_whitespace, slice_chars}; use util::str::{is_whitespace, slice_chars};

View file

@ -4,6 +4,7 @@
#![deny(unsafe_code)] #![deny(unsafe_code)]
use app_units::{Au, MAX_AU};
use block::{AbsoluteAssignBSizesTraversal, AbsoluteStoreOverflowTraversal}; use block::{AbsoluteAssignBSizesTraversal, AbsoluteStoreOverflowTraversal};
use context::LayoutContext; use context::LayoutContext;
use display_list_builder::{FragmentDisplayListBuilding, InlineFlowDisplayListBuilding}; use display_list_builder::{FragmentDisplayListBuilding, InlineFlowDisplayListBuilding};
@ -29,7 +30,7 @@ use style::properties::ComputedValues;
use text; use text;
use unicode_bidi; use unicode_bidi;
use util; use util;
use util::geometry::{Au, MAX_AU, ZERO_RECT}; use util::geometry::ZERO_RECT;
use util::logical_geometry::{LogicalRect, LogicalSize, WritingMode}; use util::logical_geometry::{LogicalRect, LogicalSize, WritingMode};
use util::range::{Range, RangeIndex}; use util::range::{Range, RangeIndex};
use wrapper::PseudoElementType; use wrapper::PseudoElementType;

View file

@ -8,6 +8,7 @@
#![allow(unsafe_code)] #![allow(unsafe_code)]
use animation; use animation;
use app_units::Au;
use azure::azure::AzColor; use azure::azure::AzColor;
use canvas_traits::CanvasMsg; use canvas_traits::CanvasMsg;
use construct::ConstructionResult; use construct::ConstructionResult;
@ -78,8 +79,9 @@ use style::properties::longhands::{display, position};
use style::properties::style_structs; use style::properties::style_structs;
use style::selector_matching::Stylist; use style::selector_matching::Stylist;
use style::stylesheets::{CSSRuleIteratorExt, Origin, Stylesheet}; use style::stylesheets::{CSSRuleIteratorExt, Origin, Stylesheet};
use style::values::AuExtensionMethods;
use url::Url; use url::Url;
use util::geometry::{Au, MAX_RECT, ZERO_POINT}; use util::geometry::{MAX_RECT, ZERO_POINT};
use util::ipc::OptionalIpcSender; use util::ipc::OptionalIpcSender;
use util::logical_geometry::LogicalPoint; use util::logical_geometry::LogicalPoint;
use util::mem::HeapSizeOf; use util::mem::HeapSizeOf;

View file

@ -18,6 +18,7 @@
#![plugin(string_cache_plugin)] #![plugin(string_cache_plugin)]
#![plugin(plugins)] #![plugin(plugins)]
extern crate app_units;
#[macro_use] #[macro_use]
extern crate bitflags; extern crate bitflags;
#[macro_use] #[macro_use]

View file

@ -7,6 +7,7 @@
#![deny(unsafe_code)] #![deny(unsafe_code)]
use app_units::Au;
use block::BlockFlow; use block::BlockFlow;
use context::LayoutContext; use context::LayoutContext;
use display_list_builder::ListItemFlowDisplayListBuilding; use display_list_builder::ListItemFlowDisplayListBuilding;
@ -22,7 +23,6 @@ use std::sync::Arc;
use style::computed_values::{list_style_type, position}; use style::computed_values::{list_style_type, position};
use style::properties::ComputedValues; use style::properties::ComputedValues;
use text; use text;
use util::geometry::Au;
use util::logical_geometry::LogicalSize; use util::logical_geometry::LogicalSize;
use util::opts; use util::opts;

View file

@ -6,6 +6,7 @@
#![deny(unsafe_code)] #![deny(unsafe_code)]
use app_units::Au;
use euclid::{Matrix4, SideOffsets2D, Size2D}; use euclid::{Matrix4, SideOffsets2D, Size2D};
use fragment::Fragment; use fragment::Fragment;
use std::cmp::{max, min}; use std::cmp::{max, min};
@ -14,7 +15,6 @@ use style::computed_values::transform::ComputedMatrix;
use style::properties::ComputedValues; use style::properties::ComputedValues;
use style::values::computed::{BorderRadiusSize, LengthOrPercentageOrAuto}; use style::values::computed::{BorderRadiusSize, LengthOrPercentageOrAuto};
use style::values::computed::{LengthOrPercentage, LengthOrPercentageOrNone}; use style::values::computed::{LengthOrPercentage, LengthOrPercentageOrNone};
use util::geometry::Au;
use util::logical_geometry::LogicalMargin; use util::logical_geometry::LogicalMargin;
/// A collapsible margin. See CSS 2.1 § 8.3.1. /// A collapsible margin. See CSS 2.1 § 8.3.1.

View file

@ -6,6 +6,7 @@
#![deny(unsafe_code)] #![deny(unsafe_code)]
use app_units::Au;
use block::BlockFlow; use block::BlockFlow;
use context::LayoutContext; use context::LayoutContext;
use euclid::{Point2D, Rect}; use euclid::{Point2D, Rect};
@ -15,7 +16,6 @@ use fragment::{Fragment, FragmentBorderBoxIterator};
use std::fmt; use std::fmt;
use std::sync::Arc; use std::sync::Arc;
use style::properties::ComputedValues; use style::properties::ComputedValues;
use util::geometry::Au;
use util::logical_geometry::LogicalSize; use util::logical_geometry::LogicalSize;
pub struct MulticolFlow { pub struct MulticolFlow {

View file

@ -4,6 +4,7 @@
//! Utilities for querying the layout, as needed by the layout task. //! Utilities for querying the layout, as needed by the layout task.
use app_units::Au;
use euclid::point::Point2D; use euclid::point::Point2D;
use euclid::rect::Rect; use euclid::rect::Rect;
use flow_ref::FlowRef; use flow_ref::FlowRef;
@ -19,7 +20,6 @@ use script::layout_interface::{ResolvedStyleResponse, ScriptLayoutChan, TrustedN
use sequential; use sequential;
use std::sync::{Arc, Mutex}; use std::sync::{Arc, Mutex};
use util::cursor::Cursor; use util::cursor::Cursor;
use util::geometry::Au;
use util::logical_geometry::WritingMode; use util::logical_geometry::WritingMode;
pub struct LayoutRPCImpl(pub Arc<Mutex<LayoutTaskData>>); pub struct LayoutRPCImpl(pub Arc<Mutex<LayoutTaskData>>);

View file

@ -4,6 +4,7 @@
//! Implements sequential traversals over the DOM and flow trees. //! Implements sequential traversals over the DOM and flow trees.
use app_units::Au;
use context::{LayoutContext, SharedLayoutContext}; use context::{LayoutContext, SharedLayoutContext};
use euclid::point::Point2D; use euclid::point::Point2D;
use flow::{PostorderFlowTraversal, PreorderFlowTraversal}; use flow::{PostorderFlowTraversal, PreorderFlowTraversal};
@ -16,7 +17,7 @@ use traversal::{AssignBSizesAndStoreOverflow, AssignISizes};
use traversal::{BubbleISizes, ConstructFlows, RecalcStyleForNode}; use traversal::{BubbleISizes, ConstructFlows, RecalcStyleForNode};
use traversal::{BuildDisplayList, ComputeAbsolutePositions}; use traversal::{BuildDisplayList, ComputeAbsolutePositions};
use traversal::{PostorderDomTraversal, PreorderDomTraversal}; use traversal::{PostorderDomTraversal, PreorderDomTraversal};
use util::geometry::{Au, ZERO_POINT}; use util::geometry::ZERO_POINT;
use util::opts; use util::opts;
use wrapper::LayoutNode; use wrapper::LayoutNode;

View file

@ -6,6 +6,7 @@
#![deny(unsafe_code)] #![deny(unsafe_code)]
use app_units::Au;
use block::{ISizeConstraintInput, ISizeConstraintSolution}; use block::{ISizeConstraintInput, ISizeConstraintSolution};
use block::{self, BlockFlow, CandidateBSizeIterator, ISizeAndMarginsComputer}; use block::{self, BlockFlow, CandidateBSizeIterator, ISizeAndMarginsComputer};
use context::LayoutContext; use context::LayoutContext;
@ -28,7 +29,6 @@ use style::values::computed::LengthOrPercentageOrAuto;
use table_row::{TableRowFlow}; use table_row::{TableRowFlow};
use table_row::{self, CellIntrinsicInlineSize, CollapsedBorder, CollapsedBorderProvenance}; use table_row::{self, CellIntrinsicInlineSize, CollapsedBorder, CollapsedBorderProvenance};
use table_wrapper::TableLayout; use table_wrapper::TableLayout;
use util::geometry::Au;
use util::logical_geometry::LogicalSize; use util::logical_geometry::LogicalSize;
/// A table flow corresponded to the table's internal table fragment under a table wrapper flow. /// A table flow corresponded to the table's internal table fragment under a table wrapper flow.

View file

@ -6,6 +6,7 @@
#![deny(unsafe_code)] #![deny(unsafe_code)]
use app_units::Au;
use block::BlockFlow; use block::BlockFlow;
use context::LayoutContext; use context::LayoutContext;
use euclid::{Point2D, Rect}; use euclid::{Point2D, Rect};
@ -14,7 +15,6 @@ use fragment::{Fragment, FragmentBorderBoxIterator};
use std::fmt; use std::fmt;
use std::sync::Arc; use std::sync::Arc;
use style::properties::ComputedValues; use style::properties::ComputedValues;
use util::geometry::Au;
use util::logical_geometry::LogicalSize; use util::logical_geometry::LogicalSize;
/// A table formatting context. /// A table formatting context.

View file

@ -6,6 +6,7 @@
#![deny(unsafe_code)] #![deny(unsafe_code)]
use app_units::Au;
use block::{BlockFlow, ISizeAndMarginsComputer, MarginsMayCollapseFlag}; use block::{BlockFlow, ISizeAndMarginsComputer, MarginsMayCollapseFlag};
use context::LayoutContext; use context::LayoutContext;
use cssparser::Color; use cssparser::Color;
@ -23,7 +24,6 @@ use style::legacy::UnsignedIntegerAttribute;
use style::properties::ComputedValues; use style::properties::ComputedValues;
use table::InternalTable; use table::InternalTable;
use table_row::{CollapsedBorder, CollapsedBorderProvenance}; use table_row::{CollapsedBorder, CollapsedBorderProvenance};
use util::geometry::Au;
use util::logical_geometry::{LogicalMargin, LogicalRect, LogicalSize, WritingMode}; use util::logical_geometry::{LogicalMargin, LogicalRect, LogicalSize, WritingMode};
use wrapper::ThreadSafeLayoutNode; use wrapper::ThreadSafeLayoutNode;

View file

@ -6,6 +6,7 @@
#![deny(unsafe_code)] #![deny(unsafe_code)]
use app_units::Au;
use context::LayoutContext; use context::LayoutContext;
use euclid::{Point2D, Rect}; use euclid::{Point2D, Rect};
use flow::{BaseFlow, Flow, FlowClass, ForceNonfloatedFlag, OpaqueFlow}; use flow::{BaseFlow, Flow, FlowClass, ForceNonfloatedFlag, OpaqueFlow};
@ -16,7 +17,7 @@ use std::fmt;
use std::sync::Arc; use std::sync::Arc;
use style::properties::ComputedValues; use style::properties::ComputedValues;
use style::values::computed::LengthOrPercentageOrAuto; use style::values::computed::LengthOrPercentageOrAuto;
use util::geometry::{Au, ZERO_RECT}; use util::geometry::ZERO_RECT;
use util::logical_geometry::LogicalSize; use util::logical_geometry::LogicalSize;
/// A table formatting context. /// A table formatting context.

View file

@ -6,6 +6,7 @@
#![deny(unsafe_code)] #![deny(unsafe_code)]
use app_units::Au;
use block::{BlockFlow, ISizeAndMarginsComputer}; use block::{BlockFlow, ISizeAndMarginsComputer};
use context::LayoutContext; use context::LayoutContext;
use cssparser::{Color, RGBA}; use cssparser::{Color, RGBA};
@ -27,7 +28,6 @@ use style::properties::ComputedValues;
use style::values::computed::LengthOrPercentageOrAuto; use style::values::computed::LengthOrPercentageOrAuto;
use table::{ColumnComputedInlineSize, ColumnIntrinsicInlineSize, InternalTable, VecExt}; use table::{ColumnComputedInlineSize, ColumnIntrinsicInlineSize, InternalTable, VecExt};
use table_cell::{CollapsedBordersForCell, TableCellFlow}; use table_cell::{CollapsedBordersForCell, TableCellFlow};
use util::geometry::Au;
use util::logical_geometry::{LogicalSize, PhysicalSide, WritingMode}; use util::logical_geometry::{LogicalSize, PhysicalSide, WritingMode};
/// A single row of a table. /// A single row of a table.

View file

@ -6,6 +6,7 @@
#![deny(unsafe_code)] #![deny(unsafe_code)]
use app_units::Au;
use block::{BlockFlow, ISizeAndMarginsComputer}; use block::{BlockFlow, ISizeAndMarginsComputer};
use context::LayoutContext; use context::LayoutContext;
use euclid::{Point2D, Rect}; use euclid::{Point2D, Rect};
@ -20,7 +21,6 @@ use style::computed_values::{border_collapse, border_spacing};
use style::properties::ComputedValues; use style::properties::ComputedValues;
use table::{ColumnComputedInlineSize, ColumnIntrinsicInlineSize, InternalTable, TableLikeFlow}; use table::{ColumnComputedInlineSize, ColumnIntrinsicInlineSize, InternalTable, TableLikeFlow};
use table_row::{self, CollapsedBordersForRow}; use table_row::{self, CollapsedBordersForRow};
use util::geometry::Au;
use util::logical_geometry::{LogicalSize, WritingMode}; use util::logical_geometry::{LogicalSize, WritingMode};
/// A table formatting context. /// A table formatting context.

View file

@ -13,6 +13,7 @@
#![deny(unsafe_code)] #![deny(unsafe_code)]
use app_units::Au;
use block::{AbsoluteNonReplaced, BlockFlow, FloatNonReplaced, ISizeAndMarginsComputer, ISizeConstraintInput}; use block::{AbsoluteNonReplaced, BlockFlow, FloatNonReplaced, ISizeAndMarginsComputer, ISizeConstraintInput};
use block::{ISizeConstraintSolution, MarginsMayCollapseFlag}; use block::{ISizeConstraintSolution, MarginsMayCollapseFlag};
use context::LayoutContext; use context::LayoutContext;
@ -32,7 +33,6 @@ use style::values::CSSFloat;
use style::values::computed::LengthOrPercentageOrAuto; use style::values::computed::LengthOrPercentageOrAuto;
use table::{ColumnComputedInlineSize, ColumnIntrinsicInlineSize}; use table::{ColumnComputedInlineSize, ColumnIntrinsicInlineSize};
use table_row; use table_row;
use util::geometry::Au;
use util::logical_geometry::LogicalSize; use util::logical_geometry::LogicalSize;
#[derive(Copy, Clone, RustcEncodable, Debug)] #[derive(Copy, Clone, RustcEncodable, Debug)]

View file

@ -6,6 +6,7 @@
#![deny(unsafe_code)] #![deny(unsafe_code)]
use app_units::Au;
use fragment::{Fragment, ScannedTextFragmentInfo, SpecificFragmentInfo, UnscannedTextFragmentInfo}; use fragment::{Fragment, ScannedTextFragmentInfo, SpecificFragmentInfo, UnscannedTextFragmentInfo};
use gfx::font::{DISABLE_KERNING_SHAPING_FLAG, FontMetrics, IGNORE_LIGATURES_SHAPING_FLAG}; use gfx::font::{DISABLE_KERNING_SHAPING_FLAG, FontMetrics, IGNORE_LIGATURES_SHAPING_FLAG};
use gfx::font::{RTL_FLAG, RunMetrics, ShapingFlags, ShapingOptions}; use gfx::font::{RTL_FLAG, RunMetrics, ShapingFlags, ShapingOptions};
@ -24,7 +25,6 @@ use style::properties::ComputedValues;
use style::properties::style_structs::Font as FontStyle; use style::properties::style_structs::Font as FontStyle;
use unicode_bidi::{is_rtl, process_text}; use unicode_bidi::{is_rtl, process_text};
use unicode_script::{get_script, Script}; use unicode_script::{get_script, Script};
use util::geometry::Au;
use util::linked_list::split_off_head; use util::linked_list::split_off_head;
use util::logical_geometry::{LogicalSize, WritingMode}; use util::logical_geometry::{LogicalSize, WritingMode};
use util::range::{Range, RangeIndex}; use util::range::{Range, RangeIndex};

View file

@ -7,6 +7,9 @@ authors = ["The Servo Project Developers"]
name = "msg" name = "msg"
path = "lib.rs" path = "lib.rs"
[dependencies.app_units]
path = "../app_units"
[dependencies.util] [dependencies.util]
path = "../util" path = "../util"

View file

@ -2,6 +2,7 @@
* License, v. 2.0. If a copy of the MPL was not distributed with this * 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/. */ * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
use app_units::Au;
use azure::azure_hl::Color; use azure::azure_hl::Color;
use constellation_msg::{Key, KeyModifiers, KeyState, PipelineId, SubpageId}; use constellation_msg::{Key, KeyModifiers, KeyState, PipelineId, SubpageId};
use euclid::{Matrix4, Point2D, Rect, Size2D}; use euclid::{Matrix4, Point2D, Rect, Size2D};
@ -9,7 +10,6 @@ use ipc_channel::ipc::IpcSender;
use layers::layers::{BufferRequest, LayerBufferSet}; use layers::layers::{BufferRequest, LayerBufferSet};
use layers::platform::surface::NativeDisplay; use layers::platform::surface::NativeDisplay;
use std::fmt::{self, Debug, Formatter}; use std::fmt::{self, Debug, Formatter};
use util::geometry::Au;
/// A newtype struct for denoting the age of messages; prevents race conditions. /// A newtype struct for denoting the age of messages; prevents race conditions.
#[derive(PartialEq, Eq, Debug, Copy, Clone, PartialOrd, Ord, Deserialize, Serialize)] #[derive(PartialEq, Eq, Debug, Copy, Clone, PartialOrd, Ord, Deserialize, Serialize)]

View file

@ -5,6 +5,7 @@
#![feature(custom_derive, plugin)] #![feature(custom_derive, plugin)]
#![plugin(serde_macros, plugins)] #![plugin(serde_macros, plugins)]
extern crate app_units;
#[macro_use] #[macro_use]
extern crate bitflags; extern crate bitflags;
extern crate azure; extern crate azure;

View file

@ -12,6 +12,9 @@ path = "lib.rs"
[features] [features]
debugmozjs = ['js/debugmozjs'] debugmozjs = ['js/debugmozjs']
[dependencies.app_units]
path = "../app_units"
[dependencies.plugins] [dependencies.plugins]
path = "../plugins" path = "../plugins"

View file

@ -2,6 +2,7 @@
* License, v. 2.0. If a copy of the MPL was not distributed with this * 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/. */ * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
use app_units::Au;
use dom::bindings::codegen::Bindings::DOMRectBinding; use dom::bindings::codegen::Bindings::DOMRectBinding;
use dom::bindings::codegen::Bindings::DOMRectBinding::DOMRectMethods; use dom::bindings::codegen::Bindings::DOMRectBinding::DOMRectMethods;
use dom::bindings::global::GlobalRef; use dom::bindings::global::GlobalRef;
@ -9,7 +10,6 @@ use dom::bindings::js::Root;
use dom::bindings::num::Finite; use dom::bindings::num::Finite;
use dom::bindings::utils::{Reflector, reflect_dom_object}; use dom::bindings::utils::{Reflector, reflect_dom_object};
use dom::window::Window; use dom::window::Window;
use util::geometry::Au;
#[dom_struct] #[dom_struct]
pub struct DOMRect { pub struct DOMRect {

View file

@ -4,6 +4,7 @@
//! Element nodes. //! Element nodes.
use app_units::Au;
use cssparser::Color; use cssparser::Color;
use devtools_traits::AttrInfo; use devtools_traits::AttrInfo;
use dom::activation::Activatable; use dom::activation::Activatable;
@ -75,7 +76,6 @@ use style::properties::{PropertyDeclaration, PropertyDeclarationBlock, parse_sty
use style::values::CSSFloat; use style::values::CSSFloat;
use style::values::specified::{self, CSSColor, CSSRGBA}; use style::values::specified::{self, CSSColor, CSSRGBA};
use url::UrlParser; use url::UrlParser;
use util::geometry::Au;
use util::str::{DOMString, LengthOrPercentageOrAuto}; use util::str::{DOMString, LengthOrPercentageOrAuto};
#[dom_struct] #[dom_struct]

View file

@ -4,6 +4,7 @@
//! The core DOM types. Defines the basic DOM hierarchy as well as all the HTML elements. //! The core DOM types. Defines the basic DOM hierarchy as well as all the HTML elements.
use app_units::Au;
use core::nonzero::NonZero; use core::nonzero::NonZero;
use devtools_traits::NodeInfo; use devtools_traits::NodeInfo;
use document_loader::DocumentLoader; use document_loader::DocumentLoader;
@ -64,7 +65,6 @@ use std::slice::ref_slice;
use std::sync::Arc; use std::sync::Arc;
use string_cache::{Atom, Namespace, QualName}; use string_cache::{Atom, Namespace, QualName};
use style::properties::ComputedValues; use style::properties::ComputedValues;
use util::geometry::Au;
use util::str::DOMString; use util::str::DOMString;
use util::task_state; use util::task_state;
use uuid; use uuid;

View file

@ -2,6 +2,7 @@
* License, v. 2.0. If a copy of the MPL was not distributed with this * 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/. */ * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
use app_units::Au;
use devtools_traits::{ScriptToDevtoolsControlMsg, TimelineMarker, TimelineMarkerType}; use devtools_traits::{ScriptToDevtoolsControlMsg, TimelineMarker, TimelineMarkerType};
use dom::bindings::callback::ExceptionHandling; use dom::bindings::callback::ExceptionHandling;
use dom::bindings::cell::DOMRefCell; use dom::bindings::cell::DOMRefCell;
@ -72,7 +73,7 @@ use string_cache::Atom;
use time; use time;
use timers::{IsInterval, TimerCallback, TimerId, TimerManager}; use timers::{IsInterval, TimerCallback, TimerId, TimerManager};
use url::Url; use url::Url;
use util::geometry::{self, Au, MAX_RECT}; use util::geometry::{self, MAX_RECT};
use util::str::{DOMString, HTML_SPACE_CHARACTERS}; use util::str::{DOMString, HTML_SPACE_CHARACTERS};
use util::{breakpoint, opts}; use util::{breakpoint, opts};
use webdriver_handlers::jsval_to_webdriver; use webdriver_handlers::jsval_to_webdriver;

View file

@ -6,6 +6,7 @@
//! interface helps reduce coupling between these two components, and enables //! interface helps reduce coupling between these two components, and enables
//! the DOM to be placed in a separate crate from layout. //! the DOM to be placed in a separate crate from layout.
use app_units::Au;
use dom::node::LayoutData; use dom::node::LayoutData;
use euclid::point::Point2D; use euclid::point::Point2D;
use euclid::rect::Rect; use euclid::rect::Rect;
@ -28,7 +29,6 @@ use style::animation::PropertyAnimation;
use style::media_queries::MediaQueryList; use style::media_queries::MediaQueryList;
use style::stylesheets::Stylesheet; use style::stylesheets::Stylesheet;
use url::Url; use url::Url;
use util::geometry::Au;
pub use dom::node::TrustedNodeAddress; pub use dom::node::TrustedNodeAddress;
/// Asynchronous messages that script can send to layout. /// Asynchronous messages that script can send to layout.

View file

@ -33,6 +33,7 @@
#![plugin(string_cache_plugin)] #![plugin(string_cache_plugin)]
#![plugin(plugins)] #![plugin(plugins)]
extern crate app_units;
#[macro_use] #[macro_use]
extern crate bitflags; extern crate bitflags;
#[macro_use] #[macro_use]

View file

@ -7,6 +7,9 @@ authors = ["The Servo Project Developers"]
name = "script_traits" name = "script_traits"
path = "lib.rs" path = "lib.rs"
[dependencies.app_units]
path = "../app_units"
[dependencies.msg] [dependencies.msg]
path = "../msg" path = "../msg"

View file

@ -10,6 +10,7 @@
#![plugin(plugins, serde_macros)] #![plugin(plugins, serde_macros)]
#![deny(missing_docs)] #![deny(missing_docs)]
extern crate app_units;
extern crate devtools_traits; extern crate devtools_traits;
extern crate euclid; extern crate euclid;
extern crate ipc_channel; extern crate ipc_channel;
@ -21,6 +22,7 @@ extern crate serde;
extern crate url; extern crate url;
extern crate util; extern crate util;
use app_units::Au;
use devtools_traits::ScriptToDevtoolsControlMsg; use devtools_traits::ScriptToDevtoolsControlMsg;
use euclid::point::Point2D; use euclid::point::Point2D;
use euclid::rect::Rect; use euclid::rect::Rect;
@ -38,7 +40,6 @@ use profile_traits::{mem, time};
use std::any::Any; use std::any::Any;
use std::sync::mpsc::{Receiver, Sender}; use std::sync::mpsc::{Receiver, Sender};
use url::Url; use url::Url;
use util::geometry::Au;
/// The address of a node. Layout sends these back. They must be validated via /// The address of a node. Layout sends these back. They must be validated via
/// `from_untrusted_node_address` before they can be used, because we do not trust layout. /// `from_untrusted_node_address` before they can be used, because we do not trust layout.

View file

@ -71,6 +71,16 @@ dependencies = [
"libc 0.1.10 (registry+https://github.com/rust-lang/crates.io-index)", "libc 0.1.10 (registry+https://github.com/rust-lang/crates.io-index)",
] ]
[[package]]
name = "app_units"
version = "0.1.0"
dependencies = [
"euclid 0.2.0 (registry+https://github.com/rust-lang/crates.io-index)",
"rustc-serialize 0.3.16 (registry+https://github.com/rust-lang/crates.io-index)",
"serde 0.6.0 (registry+https://github.com/rust-lang/crates.io-index)",
"serde_macros 0.5.3 (registry+https://github.com/rust-lang/crates.io-index)",
]
[[package]] [[package]]
name = "aster" name = "aster"
version = "0.4.7" version = "0.4.7"
@ -223,6 +233,7 @@ dependencies = [
name = "compositing" name = "compositing"
version = "0.0.1" version = "0.0.1"
dependencies = [ dependencies = [
"app_units 0.1.0",
"azure 0.1.0 (git+https://github.com/servo/rust-azure)", "azure 0.1.0 (git+https://github.com/servo/rust-azure)",
"canvas 0.0.1", "canvas 0.0.1",
"canvas_traits 0.0.1", "canvas_traits 0.0.1",
@ -580,6 +591,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index"
name = "gfx" name = "gfx"
version = "0.0.1" version = "0.0.1"
dependencies = [ dependencies = [
"app_units 0.1.0",
"azure 0.1.0 (git+https://github.com/servo/rust-azure)", "azure 0.1.0 (git+https://github.com/servo/rust-azure)",
"bitflags 0.3.2 (registry+https://github.com/rust-lang/crates.io-index)", "bitflags 0.3.2 (registry+https://github.com/rust-lang/crates.io-index)",
"canvas_traits 0.0.1", "canvas_traits 0.0.1",
@ -930,6 +942,7 @@ dependencies = [
name = "layout" name = "layout"
version = "0.0.1" version = "0.0.1"
dependencies = [ dependencies = [
"app_units 0.1.0",
"azure 0.1.0 (git+https://github.com/servo/rust-azure)", "azure 0.1.0 (git+https://github.com/servo/rust-azure)",
"bitflags 0.3.2 (registry+https://github.com/rust-lang/crates.io-index)", "bitflags 0.3.2 (registry+https://github.com/rust-lang/crates.io-index)",
"canvas 0.0.1", "canvas 0.0.1",
@ -1084,6 +1097,7 @@ dependencies = [
name = "msg" name = "msg"
version = "0.0.1" version = "0.0.1"
dependencies = [ dependencies = [
"app_units 0.1.0",
"azure 0.1.0 (git+https://github.com/servo/rust-azure)", "azure 0.1.0 (git+https://github.com/servo/rust-azure)",
"bitflags 0.3.2 (registry+https://github.com/rust-lang/crates.io-index)", "bitflags 0.3.2 (registry+https://github.com/rust-lang/crates.io-index)",
"canvas_traits 0.0.1", "canvas_traits 0.0.1",
@ -1439,6 +1453,7 @@ name = "script"
version = "0.0.1" version = "0.0.1"
dependencies = [ dependencies = [
"angle 0.1.0 (git+https://github.com/ecoal95/angle?branch=servo)", "angle 0.1.0 (git+https://github.com/ecoal95/angle?branch=servo)",
"app_units 0.1.0",
"bitflags 0.3.2 (registry+https://github.com/rust-lang/crates.io-index)", "bitflags 0.3.2 (registry+https://github.com/rust-lang/crates.io-index)",
"canvas 0.0.1", "canvas 0.0.1",
"canvas_traits 0.0.1", "canvas_traits 0.0.1",
@ -1489,6 +1504,7 @@ dependencies = [
name = "script_traits" name = "script_traits"
version = "0.0.1" version = "0.0.1"
dependencies = [ dependencies = [
"app_units 0.1.0",
"devtools_traits 0.0.1", "devtools_traits 0.0.1",
"euclid 0.2.0 (registry+https://github.com/rust-lang/crates.io-index)", "euclid 0.2.0 (registry+https://github.com/rust-lang/crates.io-index)",
"ipc-channel 0.1.0 (git+https://github.com/pcwalton/ipc-channel)", "ipc-channel 0.1.0 (git+https://github.com/pcwalton/ipc-channel)",
@ -1651,6 +1667,7 @@ dependencies = [
name = "style" name = "style"
version = "0.0.1" version = "0.0.1"
dependencies = [ dependencies = [
"app_units 0.1.0",
"bitflags 0.3.2 (registry+https://github.com/rust-lang/crates.io-index)", "bitflags 0.3.2 (registry+https://github.com/rust-lang/crates.io-index)",
"cssparser 0.3.9 (registry+https://github.com/rust-lang/crates.io-index)", "cssparser 0.3.9 (registry+https://github.com/rust-lang/crates.io-index)",
"encoding 0.2.32 (registry+https://github.com/rust-lang/crates.io-index)", "encoding 0.2.32 (registry+https://github.com/rust-lang/crates.io-index)",
@ -1677,6 +1694,7 @@ dependencies = [
name = "style_tests" name = "style_tests"
version = "0.0.1" version = "0.0.1"
dependencies = [ dependencies = [
"app_units 0.1.0",
"cssparser 0.3.9 (registry+https://github.com/rust-lang/crates.io-index)", "cssparser 0.3.9 (registry+https://github.com/rust-lang/crates.io-index)",
"euclid 0.2.0 (registry+https://github.com/rust-lang/crates.io-index)", "euclid 0.2.0 (registry+https://github.com/rust-lang/crates.io-index)",
"selectors 0.1.0 (git+https://github.com/servo/rust-selectors)", "selectors 0.1.0 (git+https://github.com/servo/rust-selectors)",
@ -1820,6 +1838,7 @@ dependencies = [
name = "util" name = "util"
version = "0.0.1" version = "0.0.1"
dependencies = [ dependencies = [
"app_units 0.1.0",
"azure 0.1.0 (git+https://github.com/servo/rust-azure)", "azure 0.1.0 (git+https://github.com/servo/rust-azure)",
"bitflags 0.3.2 (registry+https://github.com/rust-lang/crates.io-index)", "bitflags 0.3.2 (registry+https://github.com/rust-lang/crates.io-index)",
"cssparser 0.3.9 (registry+https://github.com/rust-lang/crates.io-index)", "cssparser 0.3.9 (registry+https://github.com/rust-lang/crates.io-index)",

View file

@ -30,6 +30,9 @@ features = [ "serde-serialization" ]
version = "0.2" version = "0.2"
features = [ "serde_serialization" ] features = [ "serde_serialization" ]
[dependencies.app_units]
path = "../app_units"
[dependencies] [dependencies]
log = "0.3" log = "0.3"
encoding = "0.2" encoding = "0.2"

View file

@ -2,6 +2,7 @@
* License, v. 2.0. If a copy of the MPL was not distributed with this * 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/. */ * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
use app_units::Au;
use cssparser::{Color, RGBA}; use cssparser::{Color, RGBA};
use euclid::point::Point2D; use euclid::point::Point2D;
use properties::ComputedValues; use properties::ComputedValues;
@ -25,7 +26,6 @@ use properties::longhands::z_index::computed_value::T as ZIndex;
use std::cmp::Ordering; use std::cmp::Ordering;
use std::iter::repeat; use std::iter::repeat;
use util::bezier::Bezier; use util::bezier::Bezier;
use util::geometry::Au;
use values::CSSFloat; use values::CSSFloat;
use values::computed::{Angle, LengthOrPercentageOrAuto, LengthOrPercentageOrNone}; use values::computed::{Angle, LengthOrPercentageOrAuto, LengthOrPercentageOrNone};
use values::computed::{Calc, Length, LengthOrPercentage, Time}; use values::computed::{Calc, Length, LengthOrPercentage, Time};

View file

@ -16,6 +16,7 @@
#![plugin(serde_macros)] #![plugin(serde_macros)]
#![plugin(plugins)] #![plugin(plugins)]
extern crate app_units;
#[macro_use] #[macro_use]
extern crate bitflags; extern crate bitflags;
#[macro_use] #[macro_use]

View file

@ -2,11 +2,12 @@
* License, v. 2.0. If a copy of the MPL was not distributed with this * 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/. */ * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
use app_units::Au;
use cssparser::{Delimiter, Parser, Token}; use cssparser::{Delimiter, Parser, Token};
use euclid::size::{Size2D, TypedSize2D}; use euclid::size::{Size2D, TypedSize2D};
use properties::longhands; use properties::longhands;
use std::ascii::AsciiExt; use std::ascii::AsciiExt;
use util::geometry::{Au, ViewportPx}; use util::geometry::ViewportPx;
use values::specified; use values::specified;

View file

@ -14,10 +14,10 @@ use std::intrinsics;
use std::mem; use std::mem;
use std::sync::Arc; use std::sync::Arc;
use app_units::Au;
use cssparser::{Parser, Color, RGBA, AtRuleParser, DeclarationParser, use cssparser::{Parser, Color, RGBA, AtRuleParser, DeclarationParser,
DeclarationListParser, parse_important, ToCss, TokenSerializationType}; DeclarationListParser, parse_important, ToCss, TokenSerializationType};
use url::Url; use url::Url;
use util::geometry::Au;
use util::logical_geometry::{LogicalMargin, PhysicalSide, WritingMode}; use util::logical_geometry::{LogicalMargin, PhysicalSide, WritingMode};
use euclid::SideOffsets2D; use euclid::SideOffsets2D;
use euclid::size::Size2D; use euclid::size::Size2D;
@ -28,6 +28,7 @@ use computed_values;
use parser::{ParserContext, log_css_error}; use parser::{ParserContext, log_css_error};
use selectors::matching::DeclarationBlock; use selectors::matching::DeclarationBlock;
use stylesheets::Origin; use stylesheets::Origin;
use values::AuExtensionMethods;
use values::computed::{self, ToComputedValue}; use values::computed::{self, ToComputedValue};
use values::specified::{Length, BorderStyle}; use values::specified::{Length, BorderStyle};
@ -274,7 +275,7 @@ pub mod longhands {
<%def name="predefined_type(name, type, initial_value, parse_method='parse')"> <%def name="predefined_type(name, type, initial_value, parse_method='parse')">
<%self:longhand name="${name}"> <%self:longhand name="${name}">
#[allow(unused_imports)] #[allow(unused_imports)]
use util::geometry::Au; use app_units::Au;
pub type SpecifiedValue = specified::${type}; pub type SpecifiedValue = specified::${type};
pub mod computed_value { pub mod computed_value {
pub use values::computed::${type} as T; pub use values::computed::${type} as T;
@ -317,9 +318,9 @@ pub mod longhands {
% for side in ["top", "right", "bottom", "left"]: % for side in ["top", "right", "bottom", "left"]:
<%self:longhand name="border-${side}-width"> <%self:longhand name="border-${side}-width">
use app_units::Au;
use cssparser::ToCss; use cssparser::ToCss;
use std::fmt; use std::fmt;
use util::geometry::Au;
use values::computed::Context; use values::computed::Context;
impl ToCss for SpecifiedValue { impl ToCss for SpecifiedValue {
@ -336,7 +337,7 @@ pub mod longhands {
#[derive(Clone, PartialEq)] #[derive(Clone, PartialEq)]
pub struct SpecifiedValue(pub specified::Length); pub struct SpecifiedValue(pub specified::Length);
pub mod computed_value { pub mod computed_value {
use util::geometry::Au; use app_units::Au;
pub type T = Au; pub type T = Au;
} }
#[inline] pub fn get_initial_value() -> computed_value::T { #[inline] pub fn get_initial_value() -> computed_value::T {
@ -385,9 +386,10 @@ pub mod longhands {
</%self:longhand> </%self:longhand>
<%self:longhand name="outline-width"> <%self:longhand name="outline-width">
use app_units::Au;
use cssparser::ToCss; use cssparser::ToCss;
use std::fmt; use std::fmt;
use util::geometry::Au; use values::AuExtensionMethods;
use values::computed::Context; use values::computed::Context;
impl ToCss for SpecifiedValue { impl ToCss for SpecifiedValue {
@ -402,7 +404,7 @@ pub mod longhands {
#[derive(Clone, PartialEq)] #[derive(Clone, PartialEq)]
pub struct SpecifiedValue(pub specified::Length); pub struct SpecifiedValue(pub specified::Length);
pub mod computed_value { pub mod computed_value {
use util::geometry::Au; use app_units::Au;
pub type T = Au; pub type T = Au;
} }
pub use super::border_top_width::get_initial_value; pub use super::border_top_width::get_initial_value;
@ -649,6 +651,7 @@ pub mod longhands {
<%self:longhand name="line-height"> <%self:longhand name="line-height">
use cssparser::ToCss; use cssparser::ToCss;
use std::fmt; use std::fmt;
use values::AuExtensionMethods;
use values::CSSFloat; use values::CSSFloat;
use values::computed::Context; use values::computed::Context;
@ -692,8 +695,8 @@ pub mod longhands {
} }
} }
pub mod computed_value { pub mod computed_value {
use app_units::Au;
use std::fmt; use std::fmt;
use util::geometry::Au;
use values::CSSFloat; use values::CSSFloat;
#[derive(PartialEq, Copy, Clone, HeapSizeOf)] #[derive(PartialEq, Copy, Clone, HeapSizeOf)]
pub enum T { pub enum T {
@ -791,8 +794,9 @@ pub mod longhands {
}) })
} }
pub mod computed_value { pub mod computed_value {
use app_units::Au;
use std::fmt; use std::fmt;
use util::geometry::Au; use values::AuExtensionMethods;
use values::{CSSFloat, computed}; use values::{CSSFloat, computed};
#[allow(non_camel_case_types)] #[allow(non_camel_case_types)]
#[derive(PartialEq, Copy, Clone, HeapSizeOf)] #[derive(PartialEq, Copy, Clone, HeapSizeOf)]
@ -1397,6 +1401,7 @@ pub mod longhands {
<%self:longhand name="background-position"> <%self:longhand name="background-position">
use cssparser::ToCss; use cssparser::ToCss;
use std::fmt; use std::fmt;
use values::AuExtensionMethods;
use values::computed::Context; use values::computed::Context;
pub mod computed_value { pub mod computed_value {
@ -1911,9 +1916,9 @@ pub mod longhands {
</%self:longhand> </%self:longhand>
<%self:longhand name="font-size"> <%self:longhand name="font-size">
use app_units::Au;
use cssparser::ToCss; use cssparser::ToCss;
use std::fmt; use std::fmt;
use util::geometry::Au;
use values::computed::Context; use values::computed::Context;
impl ToCss for SpecifiedValue { impl ToCss for SpecifiedValue {
@ -1925,7 +1930,7 @@ pub mod longhands {
#[derive(Clone, PartialEq)] #[derive(Clone, PartialEq)]
pub struct SpecifiedValue(pub specified::Length); // Percentages are the same as em. pub struct SpecifiedValue(pub specified::Length); // Percentages are the same as em.
pub mod computed_value { pub mod computed_value {
use util::geometry::Au; use app_units::Au;
pub type T = Au; pub type T = Au;
} }
const MEDIUM_PX: i32 = 16; const MEDIUM_PX: i32 = 16;
@ -2034,6 +2039,7 @@ pub mod longhands {
<%self:longhand name="letter-spacing"> <%self:longhand name="letter-spacing">
use cssparser::ToCss; use cssparser::ToCss;
use std::fmt; use std::fmt;
use values::AuExtensionMethods;
use values::computed::Context; use values::computed::Context;
#[derive(Clone, Copy, PartialEq)] #[derive(Clone, Copy, PartialEq)]
@ -2052,7 +2058,7 @@ pub mod longhands {
} }
pub mod computed_value { pub mod computed_value {
use util::geometry::Au; use app_units::Au;
#[derive(Clone, PartialEq, HeapSizeOf)] #[derive(Clone, PartialEq, HeapSizeOf)]
pub struct T(pub Option<Au>); pub struct T(pub Option<Au>);
} }
@ -2096,6 +2102,7 @@ pub mod longhands {
<%self:longhand name="word-spacing"> <%self:longhand name="word-spacing">
use cssparser::ToCss; use cssparser::ToCss;
use std::fmt; use std::fmt;
use values::AuExtensionMethods;
use values::computed::Context; use values::computed::Context;
#[derive(Clone, Copy, PartialEq)] #[derive(Clone, Copy, PartialEq)]
@ -2114,7 +2121,7 @@ pub mod longhands {
} }
pub mod computed_value { pub mod computed_value {
use util::geometry::Au; use app_units::Au;
#[derive(Clone, PartialEq, HeapSizeOf)] #[derive(Clone, PartialEq, HeapSizeOf)]
pub struct T(pub Option<Au>); pub struct T(pub Option<Au>);
} }
@ -2372,14 +2379,15 @@ pub mod longhands {
${single_keyword("caption-side", "top bottom")} ${single_keyword("caption-side", "top bottom")}
<%self:longhand name="border-spacing"> <%self:longhand name="border-spacing">
use app_units::Au;
use values::AuExtensionMethods;
use values::computed::Context; use values::computed::Context;
use cssparser::ToCss; use cssparser::ToCss;
use std::fmt; use std::fmt;
use util::geometry::Au;
pub mod computed_value { pub mod computed_value {
use util::geometry::Au; use app_units::Au;
#[derive(Clone, Copy, Debug, PartialEq, RustcEncodable, HeapSizeOf)] #[derive(Clone, Copy, Debug, PartialEq, RustcEncodable, HeapSizeOf)]
pub struct T { pub struct T {
@ -2536,6 +2544,7 @@ pub mod longhands {
<%self:longhand name="column-width" experimental="True"> <%self:longhand name="column-width" experimental="True">
use cssparser::ToCss; use cssparser::ToCss;
use std::fmt; use std::fmt;
use values::AuExtensionMethods;
use values::computed::Context; use values::computed::Context;
#[derive(Clone, Copy, PartialEq)] #[derive(Clone, Copy, PartialEq)]
@ -2554,7 +2563,7 @@ pub mod longhands {
} }
pub mod computed_value { pub mod computed_value {
use util::geometry::Au; use app_units::Au;
#[derive(Clone, PartialEq, HeapSizeOf)] #[derive(Clone, PartialEq, HeapSizeOf)]
pub struct T(pub Option<Au>); pub struct T(pub Option<Au>);
} }
@ -2664,6 +2673,7 @@ pub mod longhands {
<%self:longhand name="column-gap" experimental="True"> <%self:longhand name="column-gap" experimental="True">
use cssparser::ToCss; use cssparser::ToCss;
use std::fmt; use std::fmt;
use values::AuExtensionMethods;
use values::computed::Context; use values::computed::Context;
#[derive(Clone, Copy, PartialEq)] #[derive(Clone, Copy, PartialEq)]
@ -2682,7 +2692,7 @@ pub mod longhands {
} }
pub mod computed_value { pub mod computed_value {
use util::geometry::Au; use app_units::Au;
#[derive(Clone, PartialEq, HeapSizeOf)] #[derive(Clone, PartialEq, HeapSizeOf)]
pub struct T(pub Option<Au>); pub struct T(pub Option<Au>);
} }
@ -2771,6 +2781,7 @@ pub mod longhands {
<%self:longhand name="box-shadow"> <%self:longhand name="box-shadow">
use cssparser::{self, ToCss}; use cssparser::{self, ToCss};
use std::fmt; use std::fmt;
use values::AuExtensionMethods;
use values::computed::Context; use values::computed::Context;
#[derive(Clone, PartialEq)] #[derive(Clone, PartialEq)]
@ -2825,8 +2836,8 @@ pub mod longhands {
} }
pub mod computed_value { pub mod computed_value {
use app_units::Au;
use std::fmt; use std::fmt;
use util::geometry::Au;
use values::computed; use values::computed;
#[derive(Clone, PartialEq, HeapSizeOf)] #[derive(Clone, PartialEq, HeapSizeOf)]
@ -2927,7 +2938,7 @@ pub mod longhands {
} }
pub fn parse_one_box_shadow(input: &mut Parser) -> Result<SpecifiedBoxShadow, ()> { pub fn parse_one_box_shadow(input: &mut Parser) -> Result<SpecifiedBoxShadow, ()> {
use util::geometry::Au; use app_units::Au;
let mut lengths = [specified::Length::Absolute(Au(0)); 4]; let mut lengths = [specified::Length::Absolute(Au(0)); 4];
let mut lengths_parsed = false; let mut lengths_parsed = false;
let mut color = None; let mut color = None;
@ -2990,13 +3001,14 @@ pub mod longhands {
<%self:longhand name="clip"> <%self:longhand name="clip">
use cssparser::ToCss; use cssparser::ToCss;
use std::fmt; use std::fmt;
use values::AuExtensionMethods;
// NB: `top` and `left` are 0 if `auto` per CSS 2.1 11.1.2. // NB: `top` and `left` are 0 if `auto` per CSS 2.1 11.1.2.
use values::computed::Context; use values::computed::Context;
pub mod computed_value { pub mod computed_value {
use util::geometry::Au; use app_units::Au;
#[derive(Clone, PartialEq, Eq, Copy, Debug, HeapSizeOf)] #[derive(Clone, PartialEq, Eq, Copy, Debug, HeapSizeOf)]
pub struct ClipRect { pub struct ClipRect {
@ -3109,8 +3121,8 @@ pub mod longhands {
} }
pub fn parse(_context: &ParserContext, input: &mut Parser) -> Result<SpecifiedValue, ()> { pub fn parse(_context: &ParserContext, input: &mut Parser) -> Result<SpecifiedValue, ()> {
use app_units::Au;
use std::ascii::AsciiExt; use std::ascii::AsciiExt;
use util::geometry::Au;
use values::specified::Length; use values::specified::Length;
if input.try(|input| input.expect_ident_matching("auto")).is_ok() { if input.try(|input| input.expect_ident_matching("auto")).is_ok() {
@ -3144,7 +3156,7 @@ pub mod longhands {
<%self:longhand name="text-shadow"> <%self:longhand name="text-shadow">
use cssparser::{self, ToCss}; use cssparser::{self, ToCss};
use std::fmt; use std::fmt;
use values::AuExtensionMethods;
use values::computed::Context; use values::computed::Context;
#[derive(Clone, PartialEq)] #[derive(Clone, PartialEq)]
@ -3173,8 +3185,8 @@ pub mod longhands {
} }
pub mod computed_value { pub mod computed_value {
use app_units::Au;
use cssparser::Color; use cssparser::Color;
use util::geometry::Au;
#[derive(Clone, PartialEq, Debug, HeapSizeOf)] #[derive(Clone, PartialEq, Debug, HeapSizeOf)]
pub struct T(pub Vec<TextShadow>); pub struct T(pub Vec<TextShadow>);
@ -3265,7 +3277,7 @@ pub mod longhands {
} }
fn parse_one_text_shadow(input: &mut Parser) -> Result<SpecifiedTextShadow,()> { fn parse_one_text_shadow(input: &mut Parser) -> Result<SpecifiedTextShadow,()> {
use util::geometry::Au; use app_units::Au;
let mut lengths = [specified::Length::Absolute(Au(0)); 3]; let mut lengths = [specified::Length::Absolute(Au(0)); 3];
let mut lengths_parsed = false; let mut lengths_parsed = false;
let mut color = None; let mut color = None;
@ -3338,6 +3350,7 @@ pub mod longhands {
//pub use self::computed_value::T as SpecifiedValue; //pub use self::computed_value::T as SpecifiedValue;
use cssparser::ToCss; use cssparser::ToCss;
use std::fmt; use std::fmt;
use values::AuExtensionMethods;
use values::CSSFloat; use values::CSSFloat;
use values::specified::{Angle, Length}; use values::specified::{Angle, Length};
@ -3359,7 +3372,7 @@ pub mod longhands {
} }
pub mod computed_value { pub mod computed_value {
use util::geometry::Au; use app_units::Au;
use values::CSSFloat; use values::CSSFloat;
use values::specified::{Angle}; use values::specified::{Angle};
@ -3566,12 +3579,12 @@ pub mod longhands {
</%self:longhand> </%self:longhand>
<%self:longhand name="transform"> <%self:longhand name="transform">
use app_units::Au;
use values::CSSFloat; use values::CSSFloat;
use values::computed::Context; use values::computed::Context;
use cssparser::ToCss; use cssparser::ToCss;
use std::fmt; use std::fmt;
use util::geometry::Au;
pub mod computed_value { pub mod computed_value {
use values::CSSFloat; use values::CSSFloat;
@ -4109,12 +4122,13 @@ pub mod longhands {
${single_keyword("transform-style", "auto flat preserve-3d")} ${single_keyword("transform-style", "auto flat preserve-3d")}
<%self:longhand name="transform-origin"> <%self:longhand name="transform-origin">
use app_units::Au;
use values::AuExtensionMethods;
use values::computed::Context; use values::computed::Context;
use values::specified::{Length, LengthOrPercentage, Percentage}; use values::specified::{Length, LengthOrPercentage, Percentage};
use cssparser::ToCss; use cssparser::ToCss;
use std::fmt; use std::fmt;
use util::geometry::Au;
pub mod computed_value { pub mod computed_value {
use values::computed::{Length, LengthOrPercentage}; use values::computed::{Length, LengthOrPercentage};
@ -5171,7 +5185,7 @@ pub mod shorthands {
'border-%s-radius' % (corner) 'border-%s-radius' % (corner)
for corner in ['top-left', 'top-right', 'bottom-right', 'bottom-left'] for corner in ['top-left', 'top-right', 'bottom-right', 'bottom-left']
)}"> )}">
use util::geometry::Au; use app_units::Au;
use values::specified::{Length, LengthOrPercentage}; use values::specified::{Length, LengthOrPercentage};
use values::specified::BorderRadiusSize; use values::specified::BorderRadiusSize;

View file

@ -4,6 +4,34 @@
pub use cssparser::RGBA; pub use cssparser::RGBA;
use app_units::Au;
use std::fmt;
// This is a re-implementation of the ToCss trait in cssparser.
// It's done here because the app_units crate shouldn't depend
// on cssparser, and it's not possible to implement a trait when
// both the trait and the type are defined in different crates.
pub trait AuExtensionMethods {
/// Serialize `self` in CSS syntax, writing to `dest`.
fn to_css<W>(&self, dest: &mut W) -> fmt::Result where W: fmt::Write;
/// Serialize `self` in CSS syntax and return a string.
///
/// (This is a convenience wrapper for `to_css` and probably should not be overridden.)
#[inline]
fn to_css_string(&self) -> String {
let mut s = String::new();
self.to_css(&mut s).unwrap();
s
}
}
impl AuExtensionMethods for Au {
fn to_css<W>(&self, dest: &mut W) -> fmt::Result where W: fmt::Write {
write!(dest, "{}px", self.to_f64_px())
}
}
macro_rules! define_numbered_css_keyword_enum { macro_rules! define_numbered_css_keyword_enum {
($name: ident: $( $css: expr => $variant: ident = $value: expr ),+,) => { ($name: ident: $( $css: expr => $variant: ident = $value: expr ),+,) => {
define_numbered_css_keyword_enum!($name: $( $css => $variant = $value ),+); define_numbered_css_keyword_enum!($name: $( $css => $variant = $value ),+);
@ -40,6 +68,7 @@ pub type CSSFloat = f32;
pub mod specified { pub mod specified {
use app_units::Au;
use cssparser::{self, CssStringWriter, Parser, ToCss, Token}; use cssparser::{self, CssStringWriter, Parser, ToCss, Token};
use euclid::size::Size2D; use euclid::size::Size2D;
use parser::ParserContext; use parser::ParserContext;
@ -49,10 +78,9 @@ pub mod specified {
use std::fmt::{self, Write}; use std::fmt::{self, Write};
use std::ops::Mul; use std::ops::Mul;
use style_traits::values::specified::AllowedNumericType; use style_traits::values::specified::AllowedNumericType;
use super::AuExtensionMethods;
use super::CSSFloat; use super::CSSFloat;
use url::Url; use url::Url;
use util::geometry::Au;
#[derive(Clone, PartialEq, Debug, HeapSizeOf)] #[derive(Clone, PartialEq, Debug, HeapSizeOf)]
pub struct CSSColor { pub struct CSSColor {
@ -1209,13 +1237,14 @@ pub mod specified {
} }
pub mod computed { pub mod computed {
use app_units::Au;
use euclid::size::Size2D; use euclid::size::Size2D;
use properties::longhands; use properties::longhands;
use std::fmt; use std::fmt;
use super::AuExtensionMethods;
use super::specified::AngleOrCorner; use super::specified::AngleOrCorner;
use super::{CSSFloat, specified}; use super::{CSSFloat, specified};
use url::Url; use url::Url;
use util::geometry::Au;
pub use cssparser::Color as CSSColor; pub use cssparser::Color as CSSColor;
pub use super::specified::{Angle, BorderStyle, Time}; pub use super::specified::{Angle, BorderStyle, Time};

View file

@ -2,6 +2,7 @@
* License, v. 2.0. If a copy of the MPL was not distributed with this * 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/. */ * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
use app_units::Au;
use cssparser::{AtRuleParser, DeclarationListParser, DeclarationParser, Parser, parse_important}; use cssparser::{AtRuleParser, DeclarationListParser, DeclarationParser, Parser, parse_important};
use euclid::scale_factor::ScaleFactor; use euclid::scale_factor::ScaleFactor;
use euclid::size::{Size2D, TypedSize2D}; use euclid::size::{Size2D, TypedSize2D};
@ -12,7 +13,7 @@ use std::collections::hash_map::{Entry, HashMap};
use std::intrinsics; use std::intrinsics;
use style_traits::viewport::{Orientation, UserZoom, ViewportConstraints, Zoom}; use style_traits::viewport::{Orientation, UserZoom, ViewportConstraints, Zoom};
use stylesheets::Origin; use stylesheets::Origin;
use util::geometry::{Au, ViewportPx}; use util::geometry::ViewportPx;
use values::computed::{Context, ToComputedValue}; use values::computed::{Context, ToComputedValue};
use values::specified::LengthOrPercentageOrAuto; use values::specified::LengthOrPercentageOrAuto;

View file

@ -41,6 +41,9 @@ features = [ "serde_serialization" ]
[dependencies.selectors] [dependencies.selectors]
git = "https://github.com/servo/rust-selectors" git = "https://github.com/servo/rust-selectors"
[dependencies.app_units]
path = "../app_units"
[dependencies] [dependencies]
log = "0.3" log = "0.3"
bitflags = "0.3" bitflags = "0.3"

View file

@ -2,16 +2,12 @@
* License, v. 2.0. If a copy of the MPL was not distributed with this * 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/. */ * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
use cssparser::ToCss; use app_units::{Au, MAX_AU};
use euclid::num::Zero;
use euclid::point::Point2D; use euclid::point::Point2D;
use euclid::rect::Rect; use euclid::rect::Rect;
use euclid::size::Size2D; use euclid::size::Size2D;
use rustc_serialize::{Encodable, Encoder};
use std::default::Default;
use std::fmt;
use std::i32; use std::i32;
use std::ops::{Add, Div, Mul, Neg, Rem, Sub}; use std::ops::Add;
// Units for use with euclid::length and euclid::scale_factor. // Units for use with euclid::length and euclid::scale_factor.
@ -52,9 +48,6 @@ pub enum ViewportPx {}
#[derive(RustcEncodable, Debug, Copy, Clone)] #[derive(RustcEncodable, Debug, Copy, Clone)]
pub enum PagePx {} pub enum PagePx {}
/// The number of app units in a pixel.
pub const AU_PER_PX: i32 = 60;
// In summary, the hierarchy of pixel units and the factors to convert from one to the next: // In summary, the hierarchy of pixel units and the factors to convert from one to the next:
// //
// DevicePixel // DevicePixel
@ -65,24 +58,6 @@ pub const AU_PER_PX: i32 = 60;
// An Au is an "App Unit" and represents 1/60th of a CSS pixel. It was // 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. // originally proposed in 2002 as a standard unit of measure in Gecko.
// See https://bugzilla.mozilla.org/show_bug.cgi?id=177805 for more info. // See https://bugzilla.mozilla.org/show_bug.cgi?id=177805 for more info.
//
// FIXME: Implement Au using Length and ScaleFactor instead of a custom type.
#[derive(Clone, Copy, Hash, PartialEq, PartialOrd, Eq, Ord, Deserialize, Serialize)]
pub struct Au(pub i32);
impl Default for Au {
#[inline]
fn default() -> Au {
Au(0)
}
}
impl Zero for Au {
#[inline]
fn zero() -> Au {
Au(0)
}
}
pub static ZERO_POINT: Point2D<Au> = Point2D { pub static ZERO_POINT: Point2D<Au> = Point2D {
x: Au(0), x: Au(0),
@ -111,136 +86,6 @@ pub static MAX_RECT: Rect<Au> = Rect {
} }
}; };
pub const MIN_AU: Au = Au(i32::MIN);
pub const MAX_AU: Au = Au(i32::MAX);
impl Encodable for Au {
fn encode<S: Encoder>(&self, e: &mut S) -> Result<(), S::Error> {
e.emit_f64(self.to_f64_px())
}
}
impl fmt::Debug for Au {
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
write!(f, "{}px", self.to_f64_px())
}
}
impl ToCss for Au {
fn to_css<W>(&self, dest: &mut W) -> fmt::Result where W: fmt::Write {
write!(dest, "{}px", self.to_f64_px())
}
}
impl Add for Au {
type Output = Au;
#[inline]
fn add(self, other: Au) -> Au {
Au(self.0.wrapping_add(other.0))
}
}
impl Sub for Au {
type Output = Au;
#[inline]
fn sub(self, other: Au) -> Au {
Au(self.0.wrapping_sub(other.0))
}
}
impl Mul<i32> for Au {
type Output = Au;
#[inline]
fn mul(self, other: i32) -> Au {
Au(self.0.wrapping_mul(other))
}
}
impl Div<i32> for Au {
type Output = Au;
#[inline]
fn div(self, other: i32) -> Au {
Au(self.0 / other)
}
}
impl Rem<i32> for Au {
type Output = Au;
#[inline]
fn rem(self, other: i32) -> Au {
Au(self.0 % other)
}
}
impl Neg for Au {
type Output = Au;
#[inline]
fn neg(self) -> Au {
Au(-self.0)
}
}
impl Au {
/// FIXME(pcwalton): Workaround for lack of cross crate inlining of newtype structs!
#[inline]
pub fn new(value: i32) -> Au {
Au(value)
}
#[inline]
pub fn scale_by(self, factor: f32) -> Au {
Au(((self.0 as f32) * factor) as i32)
}
#[inline]
pub fn from_px(px: i32) -> Au {
Au((px * AU_PER_PX) as i32)
}
/// Rounds this app unit down to the pixel towards zero and returns it.
#[inline]
pub fn to_px(self) -> i32 {
self.0 / AU_PER_PX
}
#[inline]
pub fn to_nearest_px(self) -> i32 {
((self.0 as f64) / (AU_PER_PX as f64)).round() as i32
}
#[inline]
pub fn to_nearest_pixel(self, pixels_per_px: f32) -> f32 {
((self.0 as f32) / (AU_PER_PX as f32) * pixels_per_px).round() / pixels_per_px
}
#[inline]
pub fn to_f32_px(self) -> f32 {
(self.0 as f32) / (AU_PER_PX as f32)
}
#[inline]
pub fn to_f64_px(self) -> f64 {
(self.0 as f64) / (AU_PER_PX as f64)
}
#[inline]
pub fn from_f32_px(px: f32) -> Au {
Au((px * (AU_PER_PX as f32)) as i32)
}
#[inline]
pub fn from_f64_px(px: f64) -> Au {
Au((px * (AU_PER_PX as f64)) as i32)
}
}
/// Returns true if the rect contains the given point. Points on the top or left sides of the rect /// Returns true if the rect contains the given point. Points on the top or left sides of the rect
/// are considered inside the rectangle, while points on the right or bottom sides of the rect are /// are considered inside the rectangle, while points on the right or bottom sides of the rect are
/// not considered inside the rectangle. /// not considered inside the rectangle.

View file

@ -20,6 +20,7 @@
#![plugin(plugins, serde_macros)] #![plugin(plugins, serde_macros)]
extern crate app_units;
#[macro_use] #[macro_use]
extern crate bitflags; extern crate bitflags;
#[macro_use] #[macro_use]

View file

@ -4,6 +4,7 @@
//! Data structure measurement. //! Data structure measurement.
use app_units::Au;
use azure::azure_hl::Color; use azure::azure_hl::Color;
use cssparser::Color as CSSParserColor; use cssparser::Color as CSSParserColor;
use cssparser::{RGBA, TokenSerializationType}; use cssparser::{RGBA, TokenSerializationType};
@ -11,7 +12,7 @@ use cursor::Cursor;
use euclid::length::Length; use euclid::length::Length;
use euclid::scale_factor::ScaleFactor; use euclid::scale_factor::ScaleFactor;
use euclid::{Matrix2D, Matrix4, Point2D, Rect, SideOffsets2D, Size2D}; use euclid::{Matrix2D, Matrix4, Point2D, Rect, SideOffsets2D, Size2D};
use geometry::{Au, PagePx, ViewportPx}; use geometry::{PagePx, ViewportPx};
use html5ever::tree_builder::QuirksMode; use html5ever::tree_builder::QuirksMode;
use hyper::header::ContentType; use hyper::header::ContentType;
use hyper::http::RawStatus; use hyper::http::RawStatus;

View file

@ -2,8 +2,8 @@
* License, v. 2.0. If a copy of the MPL was not distributed with this * 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/. */ * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
use app_units::Au;
use cssparser::{self, Color, RGBA}; use cssparser::{self, Color, RGBA};
use geometry::Au;
use libc::c_char; use libc::c_char;
use num_lib::ToPrimitive; use num_lib::ToPrimitive;
use std::ascii::AsciiExt; use std::ascii::AsciiExt;

View file

@ -8,6 +8,9 @@ name = "style_tests"
path = "lib.rs" path = "lib.rs"
doctest = false doctest = false
[dependencies.app_units]
path = "../../../components/app_units"
[dependencies.style] [dependencies.style]
path = "../../../components/style" path = "../../../components/style"

View file

@ -5,6 +5,7 @@
#![feature(plugin)] #![feature(plugin)]
#![plugin(string_cache_plugin)] #![plugin(string_cache_plugin)]
extern crate app_units;
extern crate cssparser; extern crate cssparser;
extern crate euclid; extern crate euclid;
extern crate selectors; extern crate selectors;

View file

@ -2,13 +2,13 @@
* License, v. 2.0. If a copy of the MPL was not distributed with this * 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/. */ * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
use app_units::Au;
use euclid::size::Size2D; use euclid::size::Size2D;
use std::borrow::ToOwned; use std::borrow::ToOwned;
use style::media_queries::*; use style::media_queries::*;
use style::stylesheets::{Origin, Stylesheet, CSSRuleIteratorExt}; use style::stylesheets::{Origin, Stylesheet, CSSRuleIteratorExt};
use style::values::specified; use style::values::specified;
use url::Url; use url::Url;
use util::geometry::Au;
fn test_media_rule<F>(css: &str, callback: F) where F: Fn(&MediaQueryList, &str) { fn test_media_rule<F>(css: &str, callback: F) where F: Fn(&MediaQueryList, &str) {