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

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