From 00b6210519df33a87b9b21bf9bdb03985b69ae11 Mon Sep 17 00:00:00 2001 From: Simon Sapin Date: Tue, 21 Jun 2016 17:35:26 +0200 Subject: [PATCH] Make the style crate almost build on stable Rust. `discriminant_value` will need to be replaced with something else later. --- components/servo/Cargo.lock | 1 - components/servo/Cargo.toml | 2 +- components/style/Cargo.toml | 26 +-- components/style/attr.rs | 9 +- components/style/custom_properties.rs | 6 +- components/style/data.rs | 2 +- components/style/dom.rs | 3 +- components/style/element_state.rs | 2 +- components/style/error_reporting.rs | 2 +- components/style/font_face.rs | 12 +- components/style/lib.rs | 19 +-- components/style/logical_geometry.rs | 3 +- components/style/media_queries.rs | 24 ++- components/style/parallel.rs | 6 +- .../properties/longhand/background.mako.rs | 24 ++- .../style/properties/longhand/border.mako.rs | 3 +- .../style/properties/longhand/box.mako.rs | 37 +++-- .../style/properties/longhand/column.mako.rs | 18 +- .../properties/longhand/counters.mako.rs | 9 +- .../style/properties/longhand/effects.mako.rs | 66 +++++--- .../style/properties/longhand/font.mako.rs | 15 +- .../properties/longhand/inherited_box.mako.rs | 6 +- .../longhand/inherited_table.mako.rs | 6 +- .../longhand/inherited_text.mako.rs | 33 ++-- .../style/properties/longhand/list.mako.rs | 9 +- .../style/properties/longhand/outline.mako.rs | 3 +- .../properties/longhand/pointing.mako.rs | 3 +- .../properties/longhand/position.mako.rs | 3 +- .../style/properties/longhand/text.mako.rs | 3 +- .../style/properties/properties.mako.rs | 27 +-- components/style/restyle_hints.rs | 12 +- components/style/selector_impl.rs | 9 +- components/style/selector_matching.rs | 16 +- components/style/stylesheets.rs | 15 +- components/style/traversal.rs | 4 +- components/style/values.rs | 116 ++++++++----- components/style/viewport.rs | 12 +- components/util/Cargo.toml | 4 +- components/util/lib.rs | 8 +- components/util/thread.rs | 13 +- ports/geckolib/Cargo.lock | 154 ------------------ 41 files changed, 370 insertions(+), 375 deletions(-) diff --git a/components/servo/Cargo.lock b/components/servo/Cargo.lock index 872f9dddaaf..eff5e11ef3b 100644 --- a/components/servo/Cargo.lock +++ b/components/servo/Cargo.lock @@ -2215,7 +2215,6 @@ dependencies = [ "log 0.3.6 (registry+https://github.com/rust-lang/crates.io-index)", "matches 0.1.2 (registry+https://github.com/rust-lang/crates.io-index)", "num-traits 0.1.32 (registry+https://github.com/rust-lang/crates.io-index)", - "plugins 0.0.1", "rustc-serialize 0.3.19 (registry+https://github.com/rust-lang/crates.io-index)", "selectors 0.6.0 (registry+https://github.com/rust-lang/crates.io-index)", "serde 0.7.10 (registry+https://github.com/rust-lang/crates.io-index)", diff --git a/components/servo/Cargo.toml b/components/servo/Cargo.toml index ba363a8f2aa..0229c2c61d5 100644 --- a/components/servo/Cargo.toml +++ b/components/servo/Cargo.toml @@ -59,7 +59,7 @@ script_traits = {path = "../script_traits"} layout = {path = "../layout"} layout_thread = {path = "../layout_thread"} gfx = {path = "../gfx"} -style = {path = "../style"} +style = {path = "../style", features = ["servo"]} canvas = {path = "../canvas"} canvas_traits = {path = "../canvas_traits"} devtools = {path = "../devtools"} diff --git a/components/style/Cargo.toml b/components/style/Cargo.toml index 4208b10a364..f82b0ddb44c 100644 --- a/components/style/Cargo.toml +++ b/components/style/Cargo.toml @@ -12,32 +12,32 @@ path = "lib.rs" [features] gecko = ["gecko_bindings"] +servo = ["serde", "serde_macros", "heapsize", "heapsize_plugin", "style_traits/heap_size"] [dependencies] -app_units = {version = "0.2.3", features = ["plugins"]} +app_units = "0.2.3" bitflags = "0.7" -cssparser = {version = "0.5.5", features = ["heap_size", "serde-serialization"]} +cssparser = "0.5.5" encoding = "0.2" -euclid = {version = "0.6.4", features = ["plugins"]} +euclid = "0.6.4" fnv = "1.0" gecko_bindings = {path = "../../ports/geckolib/gecko_bindings", optional = true} -heapsize = "0.3.0" -heapsize_plugin = "0.1.2" +heapsize = {version = "0.3.0", optional = true} +heapsize_plugin = {version = "0.1.2", optional = true} lazy_static = "0.2" log = "0.3.5" matches = "0.1" num-traits = "0.1.32" -plugins = {path = "../plugins"} rustc-serialize = "0.3" -selectors = {version = "0.6", features = ["heap_size", "unstable"]} -serde = {version = "0.7", features = ["nightly"]} -serde_macros = "0.7" +selectors = "0.6" +serde = {version = "0.7", optional = true} +serde_macros = {version = "0.7", optional = true} smallvec = "0.1" -string_cache = {version = "0.2.20", features = ["heap_size"]} -style_traits = {path = "../style_traits", features = ["heap_size"]} +string_cache = "0.2.20" +style_traits = {path = "../style_traits"} time = "0.1" -url = {version = "1.0.0", features = ["heap_size"]} -util = {path = "../util", features = ["servo"]} +url = "1.0.0" +util = {path = "../util"} [build-dependencies] walkdir = "0.1" diff --git a/components/style/attr.rs b/components/style/attr.rs index 42fdbbc853b..e16591f6c37 100644 --- a/components/style/attr.rs +++ b/components/style/attr.rs @@ -17,14 +17,16 @@ use values::specified::Length; // Duplicated from script::dom::values. const UNSIGNED_LONG_MAX: u32 = 2147483647; -#[derive(Clone, Copy, Debug, HeapSizeOf, PartialEq)] +#[derive(Clone, Copy, Debug, PartialEq)] +#[cfg_attr(feature = "servo", derive(HeapSizeOf))] pub enum LengthOrPercentageOrAuto { Auto, Percentage(f32), Length(Au), } -#[derive(PartialEq, Clone, HeapSizeOf)] +#[derive(PartialEq, Clone)] +#[cfg_attr(feature = "servo", derive(HeapSizeOf))] pub enum AttrValue { String(String), TokenList(String, Vec), @@ -538,7 +540,8 @@ pub fn parse_length(mut value: &str) -> LengthOrPercentageOrAuto { } } -#[derive(Clone, HeapSizeOf, Debug)] +#[derive(Clone, Debug)] +#[cfg_attr(feature = "servo", derive(HeapSizeOf))] pub struct AttrIdentifier { pub local_name: Atom, pub name: Atom, diff --git a/components/style/custom_properties.rs b/components/style/custom_properties.rs index 80aed5c10c3..957e5899486 100644 --- a/components/style/custom_properties.rs +++ b/components/style/custom_properties.rs @@ -23,7 +23,8 @@ pub fn parse_name(s: &str) -> Result<&str, ()> { } } -#[derive(Clone, PartialEq, Debug, HeapSizeOf)] +#[derive(Clone, PartialEq, Debug)] +#[cfg_attr(feature = "servo", derive(HeapSizeOf))] pub struct SpecifiedValue { css: String, @@ -41,7 +42,8 @@ pub struct BorrowedSpecifiedValue<'a> { references: Option<&'a HashSet>, } -#[derive(Clone, HeapSizeOf, Debug)] +#[derive(Clone, Debug)] +#[cfg_attr(feature = "servo", derive(HeapSizeOf))] pub struct ComputedValue { css: String, first_token_type: TokenSerializationType, diff --git a/components/style/data.rs b/components/style/data.rs index 3698eeddf5b..ee0975c3737 100644 --- a/components/style/data.rs +++ b/components/style/data.rs @@ -33,7 +33,7 @@ impl PrivateStyleData, } -#[derive(Debug, HeapSizeOf, PartialEq, Eq)] +#[derive(Debug, PartialEq, Eq)] +#[cfg_attr(feature = "servo", derive(HeapSizeOf))] pub struct FontFaceRule { pub family: FontFamily, pub sources: Vec, @@ -59,7 +62,8 @@ pub fn parse_font_face_block(context: &ParserContext, input: &mut Parser) } } -#[derive(Clone, Debug, Deserialize, Serialize)] +#[derive(Clone, Debug)] +#[cfg_attr(feature = "servo", derive(Deserialize, Serialize))] pub struct EffectiveSources(Vec); impl FontFaceRule { diff --git a/components/style/lib.rs b/components/style/lib.rs index 4ec45e45e04..28e2963f4ff 100644 --- a/components/style/lib.rs +++ b/components/style/lib.rs @@ -2,17 +2,14 @@ * 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(box_syntax)] -#![feature(box_patterns)] -#![feature(concat_idents)] +// FIXME: replace discriminant_value with per-enum methods that use `match`? #![feature(core_intrinsics)] -#![feature(custom_attribute)] -#![feature(custom_derive)] -#![feature(plugin)] -#![plugin(heapsize_plugin)] -#![plugin(plugins)] -#![plugin(serde_macros)] +#![cfg_attr(feature = "servo", feature(custom_attribute))] +#![cfg_attr(feature = "servo", feature(custom_derive))] +#![cfg_attr(feature = "servo", feature(plugin))] +#![cfg_attr(feature = "servo", plugin(heapsize_plugin))] +#![cfg_attr(feature = "servo", plugin(serde_macros))] #![deny(unsafe_code)] @@ -30,7 +27,7 @@ extern crate euclid; extern crate fnv; #[cfg(feature = "gecko")] extern crate gecko_bindings; -extern crate heapsize; +#[cfg(feature = "servo")] extern crate heapsize; #[allow(unused_extern_crates)] #[macro_use] extern crate lazy_static; @@ -42,7 +39,7 @@ extern crate matches; extern crate num_traits; extern crate rustc_serialize; extern crate selectors; -extern crate serde; +#[cfg(feature = "servo")] extern crate serde; extern crate smallvec; #[macro_use(atom, ns)] extern crate string_cache; #[macro_use] diff --git a/components/style/logical_geometry.rs b/components/style/logical_geometry.rs index 849fcc97f8d..2b41b512910 100644 --- a/components/style/logical_geometry.rs +++ b/components/style/logical_geometry.rs @@ -23,7 +23,8 @@ pub enum InlineBaseDirection { } bitflags!( - #[derive(HeapSizeOf, RustcEncodable)] + #[derive(RustcEncodable)] + #[cfg_attr(feature = "servo", derive(HeapSizeOf))] pub flags WritingMode: u8 { const FLAG_RTL = 1 << 0, const FLAG_VERTICAL = 1 << 1, diff --git a/components/style/media_queries.rs b/components/style/media_queries.rs index 859b86ea963..87ae0c77722 100644 --- a/components/style/media_queries.rs +++ b/components/style/media_queries.rs @@ -10,12 +10,14 @@ use util::geometry::ViewportPx; use values::specified; -#[derive(Debug, HeapSizeOf, PartialEq)] +#[derive(Debug, PartialEq)] +#[cfg_attr(feature = "servo", derive(HeapSizeOf))] pub struct MediaQueryList { pub media_queries: Vec } -#[derive(PartialEq, Eq, Copy, Clone, Debug, HeapSizeOf)] +#[derive(PartialEq, Eq, Copy, Clone, Debug)] +#[cfg_attr(feature = "servo", derive(HeapSizeOf))] pub enum Range { Min(T), Max(T), @@ -58,20 +60,23 @@ impl Range { } /// http://dev.w3.org/csswg/mediaqueries-3/#media1 -#[derive(PartialEq, Copy, Clone, Debug, HeapSizeOf)] +#[derive(PartialEq, Copy, Clone, Debug)] +#[cfg_attr(feature = "servo", derive(HeapSizeOf))] pub enum Expression { /// http://dev.w3.org/csswg/mediaqueries-3/#width Width(Range), } /// http://dev.w3.org/csswg/mediaqueries-3/#media0 -#[derive(PartialEq, Eq, Copy, Clone, Debug, HeapSizeOf)] +#[derive(PartialEq, Eq, Copy, Clone, Debug)] +#[cfg_attr(feature = "servo", derive(HeapSizeOf))] pub enum Qualifier { Only, Not, } -#[derive(Debug, HeapSizeOf, PartialEq)] +#[derive(Debug, PartialEq)] +#[cfg_attr(feature = "servo", derive(HeapSizeOf))] pub struct MediaQuery { pub qualifier: Option, pub media_type: MediaQueryType, @@ -90,20 +95,23 @@ impl MediaQuery { } /// http://dev.w3.org/csswg/mediaqueries-3/#media0 -#[derive(PartialEq, Eq, Copy, Clone, Debug, HeapSizeOf)] +#[derive(PartialEq, Eq, Copy, Clone, Debug)] +#[cfg_attr(feature = "servo", derive(HeapSizeOf))] pub enum MediaQueryType { All, // Always true MediaType(MediaType), } -#[derive(PartialEq, Eq, Copy, Clone, Debug, HeapSizeOf)] +#[derive(PartialEq, Eq, Copy, Clone, Debug)] +#[cfg_attr(feature = "servo", derive(HeapSizeOf))] pub enum MediaType { Screen, Print, Unknown, } -#[derive(Debug, HeapSizeOf)] +#[derive(Debug)] +#[cfg_attr(feature = "servo", derive(HeapSizeOf))] pub struct Device { pub media_type: MediaType, pub viewport_size: TypedSize2D, diff --git a/components/style/parallel.rs b/components/style/parallel.rs index 0700986ee10..e967c3839fd 100644 --- a/components/style/parallel.rs +++ b/components/style/parallel.rs @@ -17,7 +17,7 @@ use util::workqueue::{WorkQueue, WorkUnit, WorkerProxy}; #[allow(dead_code)] fn static_assertion(node: UnsafeNode) { unsafe { - let _: UnsafeNodeList = ::std::intrinsics::transmute(node); + let _: UnsafeNodeList = mem::transmute(node); } } @@ -46,7 +46,7 @@ pub fn traverse_dom(root: N, run_queue_with_custom_work_data_type(queue, |queue| { queue.push(WorkUnit { fun: top_down_dom::, - data: (box vec![root.to_unsafe()], root.opaque()), + data: (Box::new(vec![root.to_unsafe()]), root.opaque()), }); }, queue_data); } @@ -89,7 +89,7 @@ fn top_down_dom(unsafe_nodes: UnsafeNodeList, for chunk in discovered_child_nodes.chunks(CHUNK_SIZE) { proxy.push(WorkUnit { fun: top_down_dom::, - data: (box chunk.iter().cloned().collect(), unsafe_nodes.1), + data: (Box::new(chunk.iter().cloned().collect()), unsafe_nodes.1), }); } } diff --git a/components/style/properties/longhand/background.mako.rs b/components/style/properties/longhand/background.mako.rs index 77be57aa097..aaac791c0e8 100644 --- a/components/style/properties/longhand/background.mako.rs +++ b/components/style/properties/longhand/background.mako.rs @@ -17,7 +17,8 @@ ${helpers.predefined_type( pub mod computed_value { use values::computed; - #[derive(Debug, Clone, PartialEq, HeapSizeOf)] + #[derive(Debug, Clone, PartialEq)] + #[cfg_attr(feature = "servo", derive(HeapSizeOf))] pub struct T(pub Option); } @@ -32,7 +33,8 @@ ${helpers.predefined_type( } } - #[derive(Debug, Clone, PartialEq, HeapSizeOf)] + #[derive(Debug, Clone, PartialEq)] + #[cfg_attr(feature = "servo", derive(HeapSizeOf))] pub struct SpecifiedValue(pub Option); impl ToCss for SpecifiedValue { @@ -77,14 +79,16 @@ ${helpers.predefined_type( pub mod computed_value { use values::computed::LengthOrPercentage; - #[derive(PartialEq, Copy, Clone, Debug, HeapSizeOf)] + #[derive(PartialEq, Copy, Clone, Debug)] + #[cfg_attr(feature = "servo", derive(HeapSizeOf))] pub struct T { pub horizontal: LengthOrPercentage, pub vertical: LengthOrPercentage, } } - #[derive(Debug, Clone, PartialEq, Copy, HeapSizeOf)] + #[derive(Debug, Clone, PartialEq, Copy)] + #[cfg_attr(feature = "servo", derive(HeapSizeOf))] pub struct SpecifiedValue { pub horizontal: specified::LengthOrPercentage, pub vertical: specified::LengthOrPercentage, @@ -198,13 +202,15 @@ ${helpers.single_keyword("background-origin", "padding-box border-box content-bo pub mod computed_value { use values::computed::LengthOrPercentageOrAuto; - #[derive(PartialEq, Clone, Debug, HeapSizeOf)] + #[derive(PartialEq, Clone, Debug)] + #[cfg_attr(feature = "servo", derive(HeapSizeOf))] pub struct ExplicitSize { pub width: LengthOrPercentageOrAuto, pub height: LengthOrPercentageOrAuto, } - #[derive(PartialEq, Clone, Debug, HeapSizeOf)] + #[derive(PartialEq, Clone, Debug)] + #[cfg_attr(feature = "servo", derive(HeapSizeOf))] pub enum T { Explicit(ExplicitSize), Cover, @@ -222,7 +228,8 @@ ${helpers.single_keyword("background-origin", "padding-box border-box content-bo } } - #[derive(Clone, PartialEq, Debug, HeapSizeOf)] + #[derive(Clone, PartialEq, Debug)] + #[cfg_attr(feature = "servo", derive(HeapSizeOf))] pub struct SpecifiedExplicitSize { pub width: specified::LengthOrPercentageOrAuto, pub height: specified::LengthOrPercentageOrAuto, @@ -245,7 +252,8 @@ ${helpers.single_keyword("background-origin", "padding-box border-box content-bo } - #[derive(Clone, PartialEq, Debug, HeapSizeOf)] + #[derive(Clone, PartialEq, Debug)] + #[cfg_attr(feature = "servo", derive(HeapSizeOf))] pub enum SpecifiedValue { Explicit(SpecifiedExplicitSize), Cover, diff --git a/components/style/properties/longhand/border.mako.rs b/components/style/properties/longhand/border.mako.rs index fac233a6924..96656861583 100644 --- a/components/style/properties/longhand/border.mako.rs +++ b/components/style/properties/longhand/border.mako.rs @@ -34,7 +34,8 @@ -> Result { specified::parse_border_width(input).map(SpecifiedValue) } - #[derive(Debug, Clone, PartialEq, HeapSizeOf)] + #[derive(Debug, Clone, PartialEq)] + #[cfg_attr(feature = "servo", derive(HeapSizeOf))] pub struct SpecifiedValue(pub specified::Length); pub mod computed_value { use app_units::Au; diff --git a/components/style/properties/longhand/box.mako.rs b/components/style/properties/longhand/box.mako.rs index 800cf276a1a..eddc2da5053 100644 --- a/components/style/properties/longhand/box.mako.rs +++ b/components/style/properties/longhand/box.mako.rs @@ -28,8 +28,8 @@ pub mod computed_value { #[allow(non_camel_case_types)] - #[derive(Clone, Eq, PartialEq, Copy, Hash, RustcEncodable, Debug, HeapSizeOf)] - #[derive(Deserialize, Serialize)] + #[derive(Clone, Eq, PartialEq, Copy, Hash, RustcEncodable, Debug)] + #[cfg_attr(feature = "servo", derive(HeapSizeOf, Deserialize, Serialize))] pub enum T { % for value in values: ${to_rust_ident(value)}, @@ -136,7 +136,8 @@ ${helpers.single_keyword("clear", "none left right both", gecko_ffi_name="mBreak <% vertical_align_keywords = vertical_align.keyword.values_for(product) %> #[allow(non_camel_case_types)] - #[derive(Debug, Clone, PartialEq, Copy, HeapSizeOf)] + #[derive(Debug, Clone, PartialEq, Copy)] + #[cfg_attr(feature = "servo", derive(HeapSizeOf))] pub enum SpecifiedValue { % for keyword in vertical_align_keywords: ${to_rust_ident(keyword)}, @@ -174,7 +175,8 @@ ${helpers.single_keyword("clear", "none left right both", gecko_ffi_name="mBreak use values::AuExtensionMethods; use values::{CSSFloat, computed}; #[allow(non_camel_case_types)] - #[derive(PartialEq, Copy, Clone, HeapSizeOf, Debug)] + #[derive(PartialEq, Copy, Clone, Debug)] + #[cfg_attr(feature = "servo", derive(HeapSizeOf))] pub enum T { % for keyword in vertical_align_keywords: ${to_rust_ident(keyword)}, @@ -243,7 +245,8 @@ ${helpers.single_keyword("overflow-x", "visible hidden scroll auto", need_clone= } pub mod computed_value { - #[derive(Debug, Clone, Copy, PartialEq, HeapSizeOf)] + #[derive(Debug, Clone, Copy, PartialEq)] + #[cfg_attr(feature = "servo", derive(HeapSizeOf))] pub struct T(pub super::super::overflow_x::computed_value::T); } @@ -279,7 +282,8 @@ ${helpers.single_keyword("overflow-x", "visible hidden scroll auto", need_clone= pub use values::computed::Time as SingleComputedValue; - #[derive(Debug, Clone, PartialEq, HeapSizeOf)] + #[derive(Debug, Clone, PartialEq)] + #[cfg_attr(feature = "servo", derive(HeapSizeOf))] pub struct T(pub Vec); impl ToComputedValue for T { @@ -385,7 +389,8 @@ ${helpers.single_keyword("overflow-x", "visible hidden scroll auto", need_clone= pub use self::TransitionTimingFunction as SingleComputedValue; - #[derive(Copy, Clone, Debug, PartialEq, HeapSizeOf)] + #[derive(Copy, Clone, Debug, PartialEq)] + #[cfg_attr(feature = "servo", derive(HeapSizeOf))] pub enum TransitionTimingFunction { CubicBezier(Point2D, Point2D), Steps(u32, StartEnd), @@ -416,7 +421,8 @@ ${helpers.single_keyword("overflow-x", "visible hidden scroll auto", need_clone= } } - #[derive(Copy, Clone, Debug, PartialEq, HeapSizeOf)] + #[derive(Copy, Clone, Debug, PartialEq)] + #[cfg_attr(feature = "servo", derive(HeapSizeOf))] pub enum StartEnd { Start, End, @@ -431,7 +437,8 @@ ${helpers.single_keyword("overflow-x", "visible hidden scroll auto", need_clone= } } - #[derive(Clone, Debug, PartialEq, HeapSizeOf)] + #[derive(Clone, Debug, PartialEq)] + #[cfg_attr(feature = "servo", derive(HeapSizeOf))] pub struct T(pub Vec); impl ToCss for T { @@ -537,7 +544,8 @@ ${helpers.single_keyword("overflow-x", "visible hidden scroll auto", need_clone= pub use self::TransitionProperty as SingleComputedValue; - #[derive(Copy, Clone, Debug, PartialEq, HeapSizeOf)] + #[derive(Copy, Clone, Debug, PartialEq)] + #[cfg_attr(feature = "servo", derive(HeapSizeOf))] pub enum TransitionProperty { All, BackgroundColor, @@ -688,7 +696,8 @@ ${helpers.single_keyword("overflow-x", "visible hidden scroll auto", need_clone= } } - #[derive(Clone, Debug, PartialEq, HeapSizeOf)] + #[derive(Clone, Debug, PartialEq)] + #[cfg_attr(feature = "servo", derive(HeapSizeOf))] pub struct T(pub Vec); impl ToCss for T { @@ -863,14 +872,16 @@ ${helpers.single_keyword("-moz-appearance", use url::Url; use values::computed::ComputedValueAsSpecified; - #[derive(PartialEq, Clone, Debug, HeapSizeOf)] + #[derive(PartialEq, Clone, Debug)] + #[cfg_attr(feature = "servo", derive(HeapSizeOf))] pub struct UrlExtraData { pub base: GeckoArcURI, pub referrer: GeckoArcURI, pub principal: GeckoArcPrincipal, } - #[derive(PartialEq, Clone, Debug, HeapSizeOf)] + #[derive(PartialEq, Clone, Debug)] + #[cfg_attr(feature = "servo", derive(HeapSizeOf))] pub enum SpecifiedValue { Url(Url, UrlExtraData), None, diff --git a/components/style/properties/longhand/column.mako.rs b/components/style/properties/longhand/column.mako.rs index b040b9bd41e..cf24613496e 100644 --- a/components/style/properties/longhand/column.mako.rs +++ b/components/style/properties/longhand/column.mako.rs @@ -11,7 +11,8 @@ use std::fmt; use values::AuExtensionMethods; - #[derive(Debug, Clone, Copy, PartialEq, HeapSizeOf)] + #[derive(Debug, Clone, Copy, PartialEq)] + #[cfg_attr(feature = "servo", derive(HeapSizeOf))] pub enum SpecifiedValue { Auto, Specified(specified::Length), @@ -28,7 +29,8 @@ pub mod computed_value { use app_units::Au; - #[derive(Debug, Clone, PartialEq, HeapSizeOf)] + #[derive(Debug, Clone, PartialEq)] + #[cfg_attr(feature = "servo", derive(HeapSizeOf))] pub struct T(pub Option); } @@ -72,7 +74,8 @@ use cssparser::ToCss; use std::fmt; - #[derive(Debug, Clone, Copy, PartialEq, HeapSizeOf)] + #[derive(Debug, Clone, Copy, PartialEq)] + #[cfg_attr(feature = "servo", derive(HeapSizeOf))] pub enum SpecifiedValue { Auto, Specified(u32), @@ -88,7 +91,8 @@ } pub mod computed_value { - #[derive(Debug, Clone, PartialEq, HeapSizeOf)] + #[derive(Debug, Clone, PartialEq)] + #[cfg_attr(feature = "servo", derive(HeapSizeOf))] pub struct T(pub Option); } @@ -138,7 +142,8 @@ use std::fmt; use values::AuExtensionMethods; - #[derive(Debug, Clone, Copy, PartialEq, HeapSizeOf)] + #[derive(Debug, Clone, Copy, PartialEq)] + #[cfg_attr(feature = "servo", derive(HeapSizeOf))] pub enum SpecifiedValue { Normal, Specified(specified::Length), @@ -155,7 +160,8 @@ pub mod computed_value { use app_units::Au; - #[derive(Debug, Clone, PartialEq, HeapSizeOf)] + #[derive(Debug, Clone, PartialEq)] + #[cfg_attr(feature = "servo", derive(HeapSizeOf))] pub struct T(pub Option); } diff --git a/components/style/properties/longhand/counters.mako.rs b/components/style/properties/longhand/counters.mako.rs index 1f881b8e9ce..6dd97da6032 100644 --- a/components/style/properties/longhand/counters.mako.rs +++ b/components/style/properties/longhand/counters.mako.rs @@ -24,7 +24,8 @@ use cssparser::{self, ToCss}; use std::fmt; - #[derive(Debug, PartialEq, Eq, Clone, HeapSizeOf)] + #[derive(Debug, PartialEq, Eq, Clone)] + #[cfg_attr(feature = "servo", derive(HeapSizeOf))] pub enum ContentItem { /// Literal string content. String(String), @@ -73,7 +74,8 @@ } #[allow(non_camel_case_types)] - #[derive(Debug, PartialEq, Eq, Clone, HeapSizeOf)] + #[derive(Debug, PartialEq, Eq, Clone)] + #[cfg_attr(feature = "servo", derive(HeapSizeOf))] pub enum T { normal, none, @@ -180,7 +182,8 @@ pub use self::computed_value::T as SpecifiedValue; pub mod computed_value { - #[derive(Debug, Clone, PartialEq, HeapSizeOf)] + #[derive(Debug, Clone, PartialEq)] + #[cfg_attr(feature = "servo", derive(HeapSizeOf))] pub struct T(pub Vec<(String,i32)>); } diff --git a/components/style/properties/longhand/effects.mako.rs b/components/style/properties/longhand/effects.mako.rs index 96f832bb782..005d3576acd 100644 --- a/components/style/properties/longhand/effects.mako.rs +++ b/components/style/properties/longhand/effects.mako.rs @@ -16,10 +16,12 @@ ${helpers.predefined_type("opacity", use std::fmt; use values::AuExtensionMethods; - #[derive(Debug, Clone, PartialEq, HeapSizeOf)] + #[derive(Debug, Clone, PartialEq)] + #[cfg_attr(feature = "servo", derive(HeapSizeOf))] pub struct SpecifiedValue(Vec); - #[derive(Debug, Clone, PartialEq, HeapSizeOf)] + #[derive(Debug, Clone, PartialEq)] + #[cfg_attr(feature = "servo", derive(HeapSizeOf))] pub struct SpecifiedBoxShadow { pub offset_x: specified::Length, pub offset_y: specified::Length, @@ -72,10 +74,12 @@ ${helpers.predefined_type("opacity", use std::fmt; use values::computed; - #[derive(Clone, PartialEq, HeapSizeOf, Debug)] + #[derive(Clone, PartialEq, Debug)] + #[cfg_attr(feature = "servo", derive(HeapSizeOf))] pub struct T(pub Vec); - #[derive(Clone, PartialEq, Copy, HeapSizeOf, Debug)] + #[derive(Clone, PartialEq, Copy, Debug)] + #[cfg_attr(feature = "servo", derive(HeapSizeOf))] pub struct BoxShadow { pub offset_x: Au, pub offset_y: Au, @@ -229,7 +233,8 @@ ${helpers.predefined_type("opacity", pub mod computed_value { use app_units::Au; - #[derive(Clone, PartialEq, Eq, Copy, Debug, HeapSizeOf)] + #[derive(Clone, PartialEq, Eq, Copy, Debug)] + #[cfg_attr(feature = "servo", derive(HeapSizeOf))] pub struct ClipRect { pub top: Au, pub right: Option, @@ -237,7 +242,8 @@ ${helpers.predefined_type("opacity", pub left: Au, } - #[derive(Debug, Clone, PartialEq, HeapSizeOf)] + #[derive(Debug, Clone, PartialEq)] + #[cfg_attr(feature = "servo", derive(HeapSizeOf))] pub struct T(pub Option); } @@ -271,7 +277,8 @@ ${helpers.predefined_type("opacity", } } - #[derive(Clone, Debug, PartialEq, Copy, HeapSizeOf)] + #[derive(Clone, Debug, PartialEq, Copy)] + #[cfg_attr(feature = "servo", derive(HeapSizeOf))] pub struct SpecifiedClipRect { pub top: specified::Length, pub right: Option, @@ -279,7 +286,8 @@ ${helpers.predefined_type("opacity", pub left: specified::Length, } - #[derive(Clone, Debug, PartialEq, Copy, HeapSizeOf)] + #[derive(Clone, Debug, PartialEq, Copy)] + #[cfg_attr(feature = "servo", derive(HeapSizeOf))] pub struct SpecifiedValue(Option); impl ToCss for SpecifiedClipRect { @@ -394,11 +402,13 @@ ${helpers.predefined_type("opacity", use values::CSSFloat; use values::specified::{Angle, Length}; - #[derive(Debug, Clone, PartialEq, HeapSizeOf)] + #[derive(Debug, Clone, PartialEq)] + #[cfg_attr(feature = "servo", derive(HeapSizeOf))] pub struct SpecifiedValue(Vec); // TODO(pcwalton): `drop-shadow` - #[derive(Clone, PartialEq, Debug, HeapSizeOf)] + #[derive(Clone, PartialEq, Debug)] + #[cfg_attr(feature = "servo", derive(HeapSizeOf))] pub enum SpecifiedFilter { Blur(Length), Brightness(CSSFloat), @@ -416,7 +426,8 @@ ${helpers.predefined_type("opacity", use values::CSSFloat; use values::specified::{Angle}; - #[derive(Clone, PartialEq, Debug, HeapSizeOf, Deserialize, Serialize)] + #[derive(Clone, PartialEq, Debug)] + #[cfg_attr(feature = "servo", derive(HeapSizeOf, Deserialize, Serialize))] pub enum Filter { Blur(Au), Brightness(CSSFloat), @@ -429,7 +440,8 @@ ${helpers.predefined_type("opacity", Sepia(CSSFloat), } - #[derive(Clone, PartialEq, Debug, HeapSizeOf, Deserialize, Serialize)] + #[derive(Clone, PartialEq, Debug)] + #[cfg_attr(feature = "servo", derive(HeapSizeOf, Deserialize, Serialize))] pub struct T { pub filters: Vec } impl T { @@ -629,7 +641,8 @@ ${helpers.predefined_type("opacity", use values::CSSFloat; use values::computed; - #[derive(Clone, Copy, Debug, PartialEq, HeapSizeOf)] + #[derive(Clone, Copy, Debug, PartialEq)] + #[cfg_attr(feature = "servo", derive(HeapSizeOf))] pub struct ComputedMatrix { pub m11: CSSFloat, pub m12: CSSFloat, pub m13: CSSFloat, pub m14: CSSFloat, pub m21: CSSFloat, pub m22: CSSFloat, pub m23: CSSFloat, pub m24: CSSFloat, @@ -648,7 +661,8 @@ ${helpers.predefined_type("opacity", } } - #[derive(Clone, Debug, PartialEq, HeapSizeOf)] + #[derive(Clone, Debug, PartialEq)] + #[cfg_attr(feature = "servo", derive(HeapSizeOf))] pub enum ComputedOperation { Matrix(ComputedMatrix), Skew(computed::Angle, computed::Angle), @@ -660,7 +674,8 @@ ${helpers.predefined_type("opacity", Perspective(computed::Length), } - #[derive(Clone, Debug, PartialEq, HeapSizeOf)] + #[derive(Clone, Debug, PartialEq)] + #[cfg_attr(feature = "servo", derive(HeapSizeOf))] pub struct T(pub Option>); } @@ -695,7 +710,8 @@ ${helpers.predefined_type("opacity", Ok((first, second)) } - #[derive(Copy, Clone, Debug, PartialEq, HeapSizeOf)] + #[derive(Copy, Clone, Debug, PartialEq)] + #[cfg_attr(feature = "servo", derive(HeapSizeOf))] enum TranslateKind { Translate, TranslateX, @@ -704,7 +720,8 @@ ${helpers.predefined_type("opacity", Translate3D, } - #[derive(Clone, Debug, PartialEq, HeapSizeOf)] + #[derive(Clone, Debug, PartialEq)] + #[cfg_attr(feature = "servo", derive(HeapSizeOf))] enum SpecifiedOperation { Matrix(SpecifiedMatrix), Skew(specified::Angle, specified::Angle), @@ -783,7 +800,8 @@ ${helpers.predefined_type("opacity", } } - #[derive(Clone, Debug, PartialEq, HeapSizeOf)] + #[derive(Clone, Debug, PartialEq)] + #[cfg_attr(feature = "servo", derive(HeapSizeOf))] pub struct SpecifiedValue(Vec); impl ToCss for SpecifiedValue { @@ -1173,7 +1191,8 @@ ${helpers.single_keyword("transform-style", "auto flat preserve-3d")} pub mod computed_value { use values::computed::{Length, LengthOrPercentage}; - #[derive(Clone, Copy, Debug, PartialEq, HeapSizeOf)] + #[derive(Clone, Copy, Debug, PartialEq)] + #[cfg_attr(feature = "servo", derive(HeapSizeOf))] pub struct T { pub horizontal: LengthOrPercentage, pub vertical: LengthOrPercentage, @@ -1181,7 +1200,8 @@ ${helpers.single_keyword("transform-style", "auto flat preserve-3d")} } } - #[derive(Clone, Copy, Debug, PartialEq, HeapSizeOf)] + #[derive(Clone, Copy, Debug, PartialEq)] + #[cfg_attr(feature = "servo", derive(HeapSizeOf))] pub struct SpecifiedValue { horizontal: LengthOrPercentage, vertical: LengthOrPercentage, @@ -1253,7 +1273,8 @@ ${helpers.predefined_type("perspective", pub mod computed_value { use values::computed::LengthOrPercentage; - #[derive(Clone, Copy, Debug, PartialEq, HeapSizeOf)] + #[derive(Clone, Copy, Debug, PartialEq)] + #[cfg_attr(feature = "servo", derive(HeapSizeOf))] pub struct T { pub horizontal: LengthOrPercentage, pub vertical: LengthOrPercentage, @@ -1268,7 +1289,8 @@ ${helpers.predefined_type("perspective", } } - #[derive(Clone, Copy, Debug, PartialEq, HeapSizeOf)] + #[derive(Clone, Copy, Debug, PartialEq)] + #[cfg_attr(feature = "servo", derive(HeapSizeOf))] pub struct SpecifiedValue { horizontal: LengthOrPercentage, vertical: LengthOrPercentage, diff --git a/components/style/properties/longhand/font.mako.rs b/components/style/properties/longhand/font.mako.rs index aeef47c94fb..cf63c578adb 100644 --- a/components/style/properties/longhand/font.mako.rs +++ b/components/style/properties/longhand/font.mako.rs @@ -19,7 +19,8 @@ use std::fmt; use string_cache::Atom; - #[derive(Debug, PartialEq, Eq, Clone, Hash, HeapSizeOf, Deserialize, Serialize)] + #[derive(Debug, PartialEq, Eq, Clone, Hash)] + #[cfg_attr(feature = "servo", derive(HeapSizeOf, Deserialize, Serialize))] pub enum FontFamily { FamilyName(Atom), Generic(Atom), @@ -73,7 +74,8 @@ Ok(()) } } - #[derive(Debug, Clone, PartialEq, Eq, Hash, HeapSizeOf)] + #[derive(Debug, Clone, PartialEq, Eq, Hash)] + #[cfg_attr(feature = "servo", derive(HeapSizeOf))] pub struct T(pub Vec); } @@ -122,7 +124,8 @@ ${helpers.single_keyword("font-variant", "normal small-caps")} use cssparser::ToCss; use std::fmt; - #[derive(Debug, Clone, PartialEq, Eq, Copy, HeapSizeOf)] + #[derive(Debug, Clone, PartialEq, Eq, Copy)] + #[cfg_attr(feature = "servo", derive(HeapSizeOf))] pub enum SpecifiedValue { Bolder, Lighter, @@ -169,7 +172,8 @@ ${helpers.single_keyword("font-variant", "normal small-caps")} } pub mod computed_value { use std::fmt; - #[derive(PartialEq, Eq, Copy, Clone, Hash, Deserialize, Serialize, HeapSizeOf, Debug)] + #[derive(PartialEq, Eq, Copy, Clone, Hash, Debug)] + #[cfg_attr(feature = "servo", derive(HeapSizeOf, Deserialize, Serialize))] #[repr(u16)] pub enum T { % for weight in range(100, 901, 100): @@ -250,7 +254,8 @@ ${helpers.single_keyword("font-variant", "normal small-caps")} } } - #[derive(Debug, Clone, PartialEq, HeapSizeOf)] + #[derive(Debug, Clone, PartialEq)] + #[cfg_attr(feature = "servo", derive(HeapSizeOf))] pub struct SpecifiedValue(pub specified::LengthOrPercentage); pub mod computed_value { use app_units::Au; diff --git a/components/style/properties/longhand/inherited_box.mako.rs b/components/style/properties/longhand/inherited_box.mako.rs index 655d9dac674..482780f3a6e 100644 --- a/components/style/properties/longhand/inherited_box.mako.rs +++ b/components/style/properties/longhand/inherited_box.mako.rs @@ -40,7 +40,8 @@ ${helpers.single_keyword("color-adjust", "economy exact", products="gecko")} use cssparser::ToCss; use std::fmt; - #[derive(Copy, Clone, Debug, PartialEq, HeapSizeOf, Deserialize, Serialize)] + #[derive(Copy, Clone, Debug, PartialEq)] + #[cfg_attr(feature = "servo", derive(HeapSizeOf, Deserialize, Serialize))] pub enum T { Auto, CrispEdges, @@ -96,7 +97,8 @@ ${helpers.single_keyword("color-adjust", "economy exact", products="gecko")} use std::fmt; use values::computed::ComputedValueAsSpecified; - #[derive(Copy, Clone, Debug, Eq, PartialEq, HeapSizeOf, Serialize, Deserialize)] + #[derive(Copy, Clone, Debug, Eq, PartialEq)] + #[cfg_attr(feature = "servo", derive(HeapSizeOf, Deserialize, Serialize))] pub struct SpecifiedValue(pub bool); pub mod computed_value { diff --git a/components/style/properties/longhand/inherited_table.mako.rs b/components/style/properties/longhand/inherited_table.mako.rs index 2a45b2fd43a..8837412cd9a 100644 --- a/components/style/properties/longhand/inherited_table.mako.rs +++ b/components/style/properties/longhand/inherited_table.mako.rs @@ -20,14 +20,16 @@ ${helpers.single_keyword("caption-side", "top bottom", extra_gecko_values="right pub mod computed_value { use app_units::Au; - #[derive(Clone, Copy, Debug, PartialEq, RustcEncodable, HeapSizeOf)] + #[derive(Clone, Copy, Debug, PartialEq, RustcEncodable)] + #[cfg_attr(feature = "servo", derive(HeapSizeOf))] pub struct T { pub horizontal: Au, pub vertical: Au, } } - #[derive(Clone, Debug, PartialEq, HeapSizeOf)] + #[derive(Clone, Debug, PartialEq)] + #[cfg_attr(feature = "servo", derive(HeapSizeOf))] pub struct SpecifiedValue { pub horizontal: specified::Length, pub vertical: specified::Length, diff --git a/components/style/properties/longhand/inherited_text.mako.rs b/components/style/properties/longhand/inherited_text.mako.rs index dedc6e60102..358d260459a 100644 --- a/components/style/properties/longhand/inherited_text.mako.rs +++ b/components/style/properties/longhand/inherited_text.mako.rs @@ -12,7 +12,8 @@ use values::AuExtensionMethods; use values::CSSFloat; - #[derive(Debug, Clone, PartialEq, Copy, HeapSizeOf)] + #[derive(Debug, Clone, PartialEq, Copy)] + #[cfg_attr(feature = "servo", derive(HeapSizeOf))] pub enum SpecifiedValue { Normal, % if product == "gecko": @@ -61,7 +62,8 @@ use app_units::Au; use std::fmt; use values::CSSFloat; - #[derive(PartialEq, Copy, Clone, HeapSizeOf, Debug)] + #[derive(PartialEq, Copy, Clone, Debug)] + #[cfg_attr(feature = "servo", derive(HeapSizeOf))] pub enum T { Normal, % if product == "gecko": @@ -182,7 +184,8 @@ use std::fmt; use values::AuExtensionMethods; - #[derive(Debug, Clone, Copy, PartialEq, HeapSizeOf)] + #[derive(Debug, Clone, Copy, PartialEq)] + #[cfg_attr(feature = "servo", derive(HeapSizeOf))] pub enum SpecifiedValue { Normal, Specified(specified::Length), @@ -199,7 +202,8 @@ pub mod computed_value { use app_units::Au; - #[derive(Debug, Clone, PartialEq, HeapSizeOf)] + #[derive(Debug, Clone, PartialEq)] + #[cfg_attr(feature = "servo", derive(HeapSizeOf))] pub struct T(pub Option); } @@ -244,7 +248,8 @@ use std::fmt; use values::AuExtensionMethods; - #[derive(Debug, Clone, Copy, PartialEq, HeapSizeOf)] + #[derive(Debug, Clone, Copy, PartialEq)] + #[cfg_attr(feature = "servo", derive(HeapSizeOf))] pub enum SpecifiedValue { Normal, Specified(specified::Length), // FIXME(SimonSapin) support percentages @@ -261,7 +266,8 @@ pub mod computed_value { use app_units::Au; - #[derive(Debug, Clone, PartialEq, HeapSizeOf)] + #[derive(Debug, Clone, PartialEq)] + #[cfg_attr(feature = "servo", derive(HeapSizeOf))] pub struct T(pub Option); } @@ -332,7 +338,8 @@ ${helpers.single_keyword("text-justify", impl ComputedValueAsSpecified for SpecifiedValue {} - #[derive(Clone, PartialEq, Copy, Debug, HeapSizeOf)] + #[derive(Clone, PartialEq, Copy, Debug)] + #[cfg_attr(feature = "servo", derive(HeapSizeOf))] pub struct SpecifiedValue { pub underline: Option, pub overline: Option, @@ -446,10 +453,12 @@ ${helpers.single_keyword("text-justify", use std::fmt; use values::AuExtensionMethods; - #[derive(Clone, PartialEq, Debug, HeapSizeOf)] + #[derive(Clone, PartialEq, Debug)] + #[cfg_attr(feature = "servo", derive(HeapSizeOf))] pub struct SpecifiedValue(Vec); - #[derive(Clone, PartialEq, Debug, HeapSizeOf)] + #[derive(Clone, PartialEq, Debug)] + #[cfg_attr(feature = "servo", derive(HeapSizeOf))] pub struct SpecifiedTextShadow { pub offset_x: specified::Length, pub offset_y: specified::Length, @@ -461,10 +470,12 @@ ${helpers.single_keyword("text-justify", use app_units::Au; use cssparser::Color; - #[derive(Clone, PartialEq, Debug, HeapSizeOf)] + #[derive(Clone, PartialEq, Debug)] + #[cfg_attr(feature = "servo", derive(HeapSizeOf))] pub struct T(pub Vec); - #[derive(Clone, PartialEq, Debug, HeapSizeOf)] + #[derive(Clone, PartialEq, Debug)] + #[cfg_attr(feature = "servo", derive(HeapSizeOf))] pub struct TextShadow { pub offset_x: Au, pub offset_y: Au, diff --git a/components/style/properties/longhand/list.mako.rs b/components/style/properties/longhand/list.mako.rs index 309e248c2dd..298f387cf13 100644 --- a/components/style/properties/longhand/list.mako.rs +++ b/components/style/properties/longhand/list.mako.rs @@ -31,7 +31,8 @@ ${helpers.single_keyword("list-style-type", """ use url::Url; use values::LocalToCss; - #[derive(Debug, Clone, PartialEq, Eq, HeapSizeOf)] + #[derive(Debug, Clone, PartialEq, Eq)] + #[cfg_attr(feature = "servo", derive(HeapSizeOf))] pub enum SpecifiedValue { None, Url(Url), @@ -52,7 +53,8 @@ ${helpers.single_keyword("list-style-type", """ use url::Url; use values::LocalToCss; - #[derive(Debug, Clone, PartialEq, HeapSizeOf)] + #[derive(Debug, Clone, PartialEq)] + #[cfg_attr(feature = "servo", derive(HeapSizeOf))] pub struct T(pub Option); impl ToCss for T { @@ -100,7 +102,8 @@ ${helpers.single_keyword("list-style-type", """ pub use self::computed_value::T as SpecifiedValue; pub mod computed_value { - #[derive(Debug, Clone, PartialEq, HeapSizeOf)] + #[derive(Debug, Clone, PartialEq)] + #[cfg_attr(feature = "servo", derive(HeapSizeOf))] pub struct T(pub Vec<(String,String)>); } diff --git a/components/style/properties/longhand/outline.mako.rs b/components/style/properties/longhand/outline.mako.rs index afa2c9a06c7..ee91fc06499 100644 --- a/components/style/properties/longhand/outline.mako.rs +++ b/components/style/properties/longhand/outline.mako.rs @@ -41,7 +41,8 @@ ${helpers.predefined_type("outline-color", "CSSColor", "::cssparser::Color::Curr pub fn parse(_context: &ParserContext, input: &mut Parser) -> Result { specified::parse_border_width(input).map(SpecifiedValue) } - #[derive(Debug, Clone, PartialEq, HeapSizeOf)] + #[derive(Debug, Clone, PartialEq)] + #[cfg_attr(feature = "servo", derive(HeapSizeOf))] pub struct SpecifiedValue(pub specified::Length); pub mod computed_value { use app_units::Au; diff --git a/components/style/properties/longhand/pointing.mako.rs b/components/style/properties/longhand/pointing.mako.rs index 7068a951b0e..c2ad1502a9e 100644 --- a/components/style/properties/longhand/pointing.mako.rs +++ b/components/style/properties/longhand/pointing.mako.rs @@ -17,7 +17,8 @@ use std::fmt; use style_traits::cursor::Cursor; - #[derive(Clone, PartialEq, Eq, Copy, Debug, HeapSizeOf)] + #[derive(Clone, PartialEq, Eq, Copy, Debug)] + #[cfg_attr(feature = "servo", derive(HeapSizeOf))] pub enum T { AutoCursor, SpecifiedCursor(Cursor), diff --git a/components/style/properties/longhand/position.mako.rs b/components/style/properties/longhand/position.mako.rs index bc93a6614e5..5ce0b83f87d 100644 --- a/components/style/properties/longhand/position.mako.rs +++ b/components/style/properties/longhand/position.mako.rs @@ -20,7 +20,8 @@ use cssparser::ToCss; use std::fmt; - #[derive(PartialEq, Clone, Eq, Copy, Debug, HeapSizeOf)] + #[derive(PartialEq, Clone, Eq, Copy, Debug)] + #[cfg_attr(feature = "servo", derive(HeapSizeOf))] pub enum T { Auto, Number(i32), diff --git a/components/style/properties/longhand/text.mako.rs b/components/style/properties/longhand/text.mako.rs index 9bf491a4546..2e34a0c6243 100644 --- a/components/style/properties/longhand/text.mako.rs +++ b/components/style/properties/longhand/text.mako.rs @@ -24,7 +24,8 @@ ${helpers.single_keyword("unicode-bidi", "normal embed isolate bidi-override iso impl ComputedValueAsSpecified for SpecifiedValue {} - #[derive(PartialEq, Eq, Copy, Clone, Debug, HeapSizeOf)] + #[derive(PartialEq, Eq, Copy, Clone, Debug)] + #[cfg_attr(feature = "servo", derive(HeapSizeOf))] pub struct SpecifiedValue { pub underline: bool, pub overline: bool, diff --git a/components/style/properties/properties.mako.rs b/components/style/properties/properties.mako.rs index a65c9fb713c..6d57a635748 100644 --- a/components/style/properties/properties.mako.rs +++ b/components/style/properties/properties.mako.rs @@ -261,11 +261,12 @@ use std::slice; /// Overridden declarations are skipped. // FIXME (https://github.com/servo/servo/issues/3426) -#[derive(Debug, PartialEq, HeapSizeOf)] +#[derive(Debug, PartialEq)] +#[cfg_attr(feature = "servo", derive(HeapSizeOf))] pub struct PropertyDeclarationBlock { - #[ignore_heap_size_of = "#7038"] + #[cfg_attr(feature = "servo", ignore_heap_size_of = "#7038")] pub important: Arc>, - #[ignore_heap_size_of = "#7038"] + #[cfg_attr(feature = "servo", ignore_heap_size_of = "#7038")] pub normal: Arc>, } @@ -616,7 +617,8 @@ impl CSSWideKeyword { } } -#[derive(Clone, Copy, Eq, PartialEq, Debug, HeapSizeOf)] +#[derive(Clone, Copy, Eq, PartialEq, Debug)] +#[cfg_attr(feature = "servo", derive(HeapSizeOf))] pub enum Shorthand { % for property in data.shorthands: ${property.camel_case}, @@ -722,7 +724,8 @@ impl Shorthand { } } -#[derive(Clone, PartialEq, Eq, Debug, HeapSizeOf)] +#[derive(Clone, PartialEq, Eq, Debug)] +#[cfg_attr(feature = "servo", derive(HeapSizeOf))] pub enum DeclaredValue { Value(T), WithVariables { @@ -753,7 +756,8 @@ impl ToCss for DeclaredValue { } } -#[derive(PartialEq, Clone, Debug, HeapSizeOf)] +#[derive(PartialEq, Clone, Debug)] +#[cfg_attr(feature = "servo", derive(HeapSizeOf))] pub enum PropertyDeclaration { % for property in data.longhands: ${property.camel_case}(DeclaredValue), @@ -1064,9 +1068,11 @@ pub mod style_structs { % for style_struct in data.active_style_structs(): % if style_struct.trait_name == "Font": - #[derive(Clone, HeapSizeOf, Debug)] + #[derive(Clone, Debug)] + #[cfg_attr(feature = "servo", derive(HeapSizeOf))] % else: - #[derive(PartialEq, Clone, HeapSizeOf)] + #[derive(PartialEq, Clone)] + #[cfg_attr(feature = "servo", derive(HeapSizeOf))] % endif pub struct ${style_struct.servo_struct_name} { % for longhand in style_struct.longhands: @@ -1233,7 +1239,8 @@ pub trait ComputedValues : Clone + Send + Sync + 'static { fn is_multicol(&self) -> bool; } -#[derive(Clone, HeapSizeOf)] +#[derive(Clone)] +#[cfg_attr(feature = "servo", derive(HeapSizeOf))] pub struct ServoComputedValues { % for style_struct in data.active_style_structs(): ${style_struct.ident}: Arc, @@ -1692,7 +1699,7 @@ pub fn make_cascade_vec() -> Vec> % for property in style_struct.longhands: let discriminant; unsafe { - let variant = PropertyDeclaration::${property.camel_case}(intrinsics::uninit()); + let variant = PropertyDeclaration::${property.camel_case}(mem::uninitialized()); discriminant = intrinsics::discriminant_value(&variant) as usize; mem::forget(variant); } diff --git a/components/style/restyle_hints.rs b/components/style/restyle_hints.rs index 3a90852c13a..361d7110d04 100644 --- a/components/style/restyle_hints.rs +++ b/components/style/restyle_hints.rs @@ -50,7 +50,8 @@ bitflags! { /// now to reduce complexity, but it's worth measuring the performance impact (if any) of the /// mStateMask approach. -#[derive(HeapSizeOf, Clone)] +#[derive(Clone)] +#[cfg_attr(feature = "servo", derive(HeapSizeOf))] pub struct ElementSnapshot { pub state: Option, pub attrs: Option>, @@ -225,7 +226,8 @@ fn combinator_to_restyle_hint(combinator: Option) -> RestyleHint { } } -#[derive(Debug, HeapSizeOf)] +#[derive(Debug)] +#[cfg_attr(feature = "servo", derive(HeapSizeOf))] struct Sensitivities { pub states: ElementState, pub attrs: bool, @@ -262,14 +264,16 @@ impl Sensitivities { // us to quickly scan through the dependency sites of all style rules and determine the // maximum effect that a given state or attribute change may have on the style of // elements in the document. -#[derive(Debug, HeapSizeOf)] +#[derive(Debug)] +#[cfg_attr(feature = "servo", derive(HeapSizeOf))] struct Dependency { selector: Arc>, combinator: Option, sensitivities: Sensitivities, } -#[derive(Debug, HeapSizeOf)] +#[derive(Debug)] +#[cfg_attr(feature = "servo", derive(HeapSizeOf))] pub struct DependencySet { deps: Vec>, } diff --git a/components/style/selector_impl.rs b/components/style/selector_impl.rs index 14e6b366690..6125415df78 100644 --- a/components/style/selector_impl.rs +++ b/components/style/selector_impl.rs @@ -95,7 +95,8 @@ pub trait SelectorImplExt : SelectorImpl + Sized { fn get_quirks_mode_stylesheet() -> Option<&'static Stylesheet>; } -#[derive(Clone, Debug, PartialEq, Eq, HeapSizeOf, Hash)] +#[derive(Clone, Debug, PartialEq, Eq, Hash)] +#[cfg_attr(feature = "servo", derive(HeapSizeOf))] pub enum PseudoElement { Before, After, @@ -117,7 +118,8 @@ impl PseudoElement { } } -#[derive(Clone, Debug, PartialEq, Eq, HeapSizeOf, Hash)] +#[derive(Clone, Debug, PartialEq, Eq, Hash)] +#[cfg_attr(feature = "servo", derive(HeapSizeOf))] pub enum NonTSPseudoClass { AnyLink, Link, @@ -158,7 +160,8 @@ impl NonTSPseudoClass { } } -#[derive(Clone, Debug, PartialEq, HeapSizeOf)] +#[derive(Clone, Debug, PartialEq)] +#[cfg_attr(feature = "servo", derive(HeapSizeOf))] pub struct ServoSelectorImpl; impl SelectorImpl for ServoSelectorImpl { diff --git a/components/style/selector_matching.rs b/components/style/selector_matching.rs index 79f590f5482..50bbf7dab49 100644 --- a/components/style/selector_matching.rs +++ b/components/style/selector_matching.rs @@ -44,7 +44,7 @@ lazy_static! { None, None, Origin::UserAgent, - box StdoutErrorReporter, + Box::new(StdoutErrorReporter), ParserContextExtraData::default()); stylesheets.push(ua_stylesheet); } @@ -56,7 +56,7 @@ lazy_static! { } for &(ref contents, ref url) in &opts::get().user_stylesheets { stylesheets.push(Stylesheet::from_bytes( - &contents, url.clone(), None, None, Origin::User, box StdoutErrorReporter, + &contents, url.clone(), None, None, Origin::User, Box::new(StdoutErrorReporter), ParserContextExtraData::default())); } stylesheets @@ -73,7 +73,7 @@ lazy_static! { None, None, Origin::UserAgent, - box StdoutErrorReporter, + Box::new(StdoutErrorReporter), ParserContextExtraData::default()) }, Err(..) => { @@ -100,7 +100,7 @@ lazy_static! { /// `ServoSelectorImpl`, the implementation used by Servo's layout system in /// regular builds, or `GeckoSelectorImpl`, the implementation used in the /// geckolib port. -#[derive(HeapSizeOf)] +#[cfg_attr(feature = "servo", derive(HeapSizeOf))] pub struct Stylist { /// Device that the stylist is currently evaluating against. pub device: Device, @@ -269,7 +269,7 @@ impl Stylist { properties::cascade(self.device.au_viewport_size(), &declarations, false, parent.map(|p| &**p), None, - box StdoutErrorReporter); + Box::new(StdoutErrorReporter)); Some(Arc::new(computed)) } else { parent.map(|p| p.clone()) @@ -302,7 +302,7 @@ impl Stylist { properties::cascade(self.device.au_viewport_size(), &declarations, false, Some(&**parent), None, - box StdoutErrorReporter); + Box::new(StdoutErrorReporter)); Some(Arc::new(computed)) } @@ -438,7 +438,7 @@ impl Stylist { } /// Map that contains the CSS rules for a given origin. -#[derive(HeapSizeOf)] +#[cfg_attr(feature = "servo", derive(HeapSizeOf))] struct PerOriginSelectorMap { /// Rules that contains at least one property declararion with /// normal importance. @@ -460,7 +460,7 @@ impl PerOriginSelectorMap { /// Map that contains the CSS rules for a specific PseudoElement /// (or lack of PseudoElement). -#[derive(HeapSizeOf)] +#[cfg_attr(feature = "servo", derive(HeapSizeOf))] struct PerPseudoElementSelectorMap { /// Rules from user agent stylesheets user_agent: PerOriginSelectorMap, diff --git a/components/style/stylesheets.rs b/components/style/stylesheets.rs index 4de57e81d40..53990e7f84f 100644 --- a/components/style/stylesheets.rs +++ b/components/style/stylesheets.rs @@ -24,7 +24,8 @@ use viewport::ViewportRule; /// Each style rule has an origin, which determines where it enters the cascade. /// /// http://dev.w3.org/csswg/css-cascade/#cascading-origins -#[derive(Clone, PartialEq, Eq, Copy, Debug, HeapSizeOf)] +#[derive(Clone, PartialEq, Eq, Copy, Debug)] +#[cfg_attr(feature = "servo", derive(HeapSizeOf))] pub enum Origin { /// http://dev.w3.org/csswg/css-cascade/#cascade-origin-ua UserAgent, @@ -37,7 +38,8 @@ pub enum Origin { } -#[derive(Debug, HeapSizeOf, PartialEq)] +#[derive(Debug, PartialEq)] +#[cfg_attr(feature = "servo", derive(HeapSizeOf))] pub struct Stylesheet { /// List of rules in the order they were found (important for /// cascading order) @@ -49,7 +51,8 @@ pub struct Stylesheet { } -#[derive(Debug, HeapSizeOf, PartialEq)] +#[derive(Debug, PartialEq)] +#[cfg_attr(feature = "servo", derive(HeapSizeOf))] pub enum CSSRule { Charset(String), Namespace(Option, Namespace), @@ -59,7 +62,8 @@ pub enum CSSRule { Viewport(ViewportRule), } -#[derive(Debug, HeapSizeOf, PartialEq)] +#[derive(Debug, PartialEq)] +#[cfg_attr(feature = "servo", derive(HeapSizeOf))] pub struct MediaRule { pub media_queries: MediaQueryList, pub rules: Vec>, @@ -72,7 +76,8 @@ impl MediaRule { } } -#[derive(Debug, HeapSizeOf, PartialEq)] +#[derive(Debug, PartialEq)] +#[cfg_attr(feature = "servo", derive(HeapSizeOf))] pub struct StyleRule { pub selectors: Vec>, pub declarations: PropertyDeclarationBlock, diff --git a/components/style/traversal.rs b/components/style/traversal.rs index 1afdcbb34c7..d383cc5f706 100644 --- a/components/style/traversal.rs +++ b/components/style/traversal.rs @@ -53,11 +53,11 @@ fn take_thread_local_bloom_filter(parent_node: Option< // Root node. Needs new bloom filter. (None, _ ) => { debug!("[{}] No parent, but new bloom filter!", tid()); - box BloomFilter::new() + Box::new(BloomFilter::new()) } // No bloom filter for this thread yet. (Some(parent), None) => { - let mut bloom_filter = box BloomFilter::new(); + let mut bloom_filter = Box::new(BloomFilter::new()); insert_ancestors_into_bloom_filter(&mut bloom_filter, parent, root); bloom_filter } diff --git a/components/style/values.rs b/components/style/values.rs index a6c73977d44..6d62d69357e 100644 --- a/components/style/values.rs +++ b/components/style/values.rs @@ -41,8 +41,8 @@ macro_rules! define_numbered_css_keyword_enum { }; ($name: ident: $( $css: expr => $variant: ident = $value: expr ),+) => { #[allow(non_camel_case_types)] - #[derive(Clone, Eq, PartialEq, PartialOrd, Ord, Copy, RustcEncodable, Debug, HeapSizeOf)] - #[derive(Deserialize, Serialize)] + #[derive(Clone, Eq, PartialEq, PartialOrd, Ord, Copy, RustcEncodable, Debug)] + #[cfg_attr(feature = "servo", derive(HeapSizeOf, Deserialize, Serialize))] pub enum $name { $( $variant = $value ),+ } @@ -104,7 +104,8 @@ pub mod specified { use super::{CSSFloat, FONT_MEDIUM_PX}; use url::Url; - #[derive(Clone, PartialEq, Debug, HeapSizeOf)] + #[derive(Clone, PartialEq, Debug)] + #[cfg_attr(feature = "servo", derive(HeapSizeOf))] pub struct CSSColor { pub parsed: cssparser::Color, pub authored: Option, @@ -133,7 +134,8 @@ pub mod specified { } } - #[derive(Clone, PartialEq, Debug, HeapSizeOf)] + #[derive(Clone, PartialEq, Debug)] + #[cfg_attr(feature = "servo", derive(HeapSizeOf))] pub struct CSSRGBA { pub parsed: cssparser::RGBA, pub authored: Option, @@ -148,7 +150,8 @@ pub mod specified { } } - #[derive(Clone, PartialEq, Copy, Debug, HeapSizeOf)] + #[derive(Clone, PartialEq, Copy, Debug)] + #[cfg_attr(feature = "servo", derive(HeapSizeOf))] pub enum FontRelativeLength { Em(CSSFloat), Ex(CSSFloat), @@ -185,7 +188,8 @@ pub mod specified { } } - #[derive(Clone, PartialEq, Copy, Debug, HeapSizeOf)] + #[derive(Clone, PartialEq, Copy, Debug)] + #[cfg_attr(feature = "servo", derive(HeapSizeOf))] pub enum ViewportPercentageLength { Vw(CSSFloat), Vh(CSSFloat), @@ -226,7 +230,8 @@ pub mod specified { } } - #[derive(Clone, PartialEq, Copy, Debug, HeapSizeOf)] + #[derive(Clone, PartialEq, Copy, Debug)] + #[cfg_attr(feature = "servo", derive(HeapSizeOf))] pub struct CharacterWidth(pub i32); impl CharacterWidth { @@ -241,7 +246,8 @@ pub mod specified { } } - #[derive(Clone, PartialEq, Copy, Debug, HeapSizeOf)] + #[derive(Clone, PartialEq, Copy, Debug)] + #[cfg_attr(feature = "servo", derive(HeapSizeOf))] pub enum Length { Absolute(Au), // application units FontRelative(FontRelativeLength), @@ -439,9 +445,9 @@ pub mod specified { SimplifiedValueNode::Angle(Angle(a)) => SimplifiedValueNode::Angle(Angle(a * scalar)), SimplifiedValueNode::Time(Time(t)) => SimplifiedValueNode::Time(Time(t * scalar)), SimplifiedValueNode::Number(n) => SimplifiedValueNode::Number(n * scalar), - SimplifiedValueNode::Sum(box ref s) => { - let sum = s * scalar; - SimplifiedValueNode::Sum(box sum) + SimplifiedValueNode::Sum(ref s) => { + let sum = &**s * scalar; + SimplifiedValueNode::Sum(Box::new(sum)) } } } @@ -507,7 +513,8 @@ pub mod specified { Time, } - #[derive(Clone, PartialEq, Copy, Debug, HeapSizeOf)] + #[derive(Clone, PartialEq, Copy, Debug)] + #[cfg_attr(feature = "servo", derive(HeapSizeOf))] pub struct CalcLengthOrPercentage { pub absolute: Option, pub vw: Option, @@ -589,7 +596,7 @@ pub mod specified { Ok(CalcValueNode::Percentage(value.unit_value)), (Token::ParenthesisBlock, _) => { input.parse_nested_block(|i| CalcLengthOrPercentage::parse_sum(i, expected_unit)) - .map(|result| CalcValueNode::Sum(box result)) + .map(|result| CalcValueNode::Sum(Box::new(result))) }, _ => Err(()) } @@ -598,7 +605,7 @@ pub mod specified { fn simplify_value_to_number(node: &CalcValueNode) -> Option { match *node { CalcValueNode::Number(number) => Some(number), - CalcValueNode::Sum(box ref sum) => CalcLengthOrPercentage::simplify_sum_to_number(sum), + CalcValueNode::Sum(ref sum) => CalcLengthOrPercentage::simplify_sum_to_number(sum), _ => None } } @@ -629,7 +636,7 @@ pub mod specified { let mut simplified = Vec::new(); for product in &node.products { match try!(CalcLengthOrPercentage::simplify_product(product)) { - SimplifiedValueNode::Sum(box sum) => simplified.extend_from_slice(&sum.values), + SimplifiedValueNode::Sum(ref sum) => simplified.extend_from_slice(&sum.values), val => simplified.push(val), } } @@ -637,7 +644,7 @@ pub mod specified { if simplified.len() == 1 { Ok(simplified[0].clone()) } else { - Ok(SimplifiedValueNode::Sum(box SimplifiedSumNode { values: simplified } )) + Ok(SimplifiedValueNode::Sum(Box::new(SimplifiedSumNode { values: simplified }))) } } @@ -649,7 +656,7 @@ pub mod specified { Some(number) => multiplier *= number, _ if node_with_unit.is_none() => { node_with_unit = Some(match *node { - CalcValueNode::Sum(box ref sum) => + CalcValueNode::Sum(ref sum) => try!(CalcLengthOrPercentage::simplify_products_in_sum(sum)), CalcValueNode::Length(l) => SimplifiedValueNode::Length(l), CalcValueNode::Angle(a) => SimplifiedValueNode::Angle(a), @@ -855,7 +862,8 @@ pub mod specified { } } - #[derive(Clone, PartialEq, Copy, Debug, HeapSizeOf)] + #[derive(Clone, PartialEq, Copy, Debug)] + #[cfg_attr(feature = "servo", derive(HeapSizeOf))] pub struct Percentage(pub CSSFloat); // [0 .. 100%] maps to [0.0 .. 1.0] impl ToCss for Percentage { @@ -864,7 +872,8 @@ pub mod specified { } } - #[derive(Clone, PartialEq, Copy, Debug, HeapSizeOf)] + #[derive(Clone, PartialEq, Copy, Debug)] + #[cfg_attr(feature = "servo", derive(HeapSizeOf))] pub enum LengthOrPercentage { Length(Length), Percentage(Percentage), @@ -912,7 +921,8 @@ pub mod specified { } } - #[derive(Clone, PartialEq, Copy, Debug, HeapSizeOf)] + #[derive(Clone, PartialEq, Copy, Debug)] + #[cfg_attr(feature = "servo", derive(HeapSizeOf))] pub enum LengthOrPercentageOrAuto { Length(Length), Percentage(Percentage), @@ -961,7 +971,8 @@ pub mod specified { } } - #[derive(Clone, PartialEq, Copy, Debug, HeapSizeOf)] + #[derive(Clone, PartialEq, Copy, Debug)] + #[cfg_attr(feature = "servo", derive(HeapSizeOf))] pub enum LengthOrPercentageOrNone { Length(Length), Percentage(Percentage), @@ -1009,7 +1020,8 @@ pub mod specified { } } - #[derive(Clone, PartialEq, Copy, Debug, HeapSizeOf)] + #[derive(Clone, PartialEq, Copy, Debug)] + #[cfg_attr(feature = "servo", derive(HeapSizeOf))] pub enum LengthOrNone { Length(Length), None, @@ -1049,7 +1061,8 @@ pub mod specified { } } - #[derive(Clone, PartialEq, Copy, Debug, HeapSizeOf)] + #[derive(Clone, PartialEq, Copy, Debug)] + #[cfg_attr(feature = "servo", derive(HeapSizeOf))] pub enum LengthOrPercentageOrAutoOrContent { Length(Length), Percentage(Percentage), @@ -1093,7 +1106,8 @@ pub mod specified { } } - #[derive(Clone, PartialEq, Copy, Debug, HeapSizeOf)] + #[derive(Clone, PartialEq, Copy, Debug)] + #[cfg_attr(feature = "servo", derive(HeapSizeOf))] pub struct BorderRadiusSize(pub Size2D); impl BorderRadiusSize { @@ -1169,7 +1183,8 @@ pub mod specified { } } - #[derive(Clone, PartialEq, PartialOrd, Copy, Debug, HeapSizeOf, Deserialize, Serialize)] + #[derive(Clone, PartialEq, PartialOrd, Copy, Debug)] + #[cfg_attr(feature = "servo", derive(HeapSizeOf, Deserialize, Serialize))] pub struct Angle(pub CSSFloat); impl ToCss for Angle { @@ -1215,7 +1230,8 @@ pub mod specified { } /// Specified values for an image according to CSS-IMAGES. - #[derive(Clone, PartialEq, Debug, HeapSizeOf)] + #[derive(Clone, PartialEq, Debug)] + #[cfg_attr(feature = "servo", derive(HeapSizeOf))] pub enum Image { Url(Url), LinearGradient(LinearGradient), @@ -1250,7 +1266,8 @@ pub mod specified { } /// Specified values for a CSS linear gradient. - #[derive(Clone, PartialEq, Debug, HeapSizeOf)] + #[derive(Clone, PartialEq, Debug)] + #[cfg_attr(feature = "servo", derive(HeapSizeOf))] pub struct LinearGradient { /// The angle or corner of the gradient. pub angle_or_corner: AngleOrCorner, @@ -1273,7 +1290,8 @@ pub mod specified { } /// Specified values for an angle or a corner in a linear gradient. - #[derive(Clone, PartialEq, Copy, Debug, HeapSizeOf)] + #[derive(Clone, PartialEq, Copy, Debug)] + #[cfg_attr(feature = "servo", derive(HeapSizeOf))] pub enum AngleOrCorner { Angle(Angle), Corner(HorizontalDirection, VerticalDirection), @@ -1295,7 +1313,8 @@ pub mod specified { } /// Specified values for one color stop in a linear gradient. - #[derive(Clone, PartialEq, Debug, HeapSizeOf)] + #[derive(Clone, PartialEq, Debug)] + #[cfg_attr(feature = "servo", derive(HeapSizeOf))] pub struct ColorStop { /// The color of this stop. pub color: CSSColor, @@ -1424,7 +1443,8 @@ pub mod specified { } /// A time in seconds according to CSS-VALUES ยง 6.2. - #[derive(Clone, Copy, Debug, PartialEq, PartialOrd, HeapSizeOf)] + #[derive(Clone, Copy, Debug, PartialEq, PartialOrd)] + #[cfg_attr(feature = "servo", derive(HeapSizeOf))] pub struct Time(pub CSSFloat); impl Time { @@ -1473,7 +1493,8 @@ pub mod specified { } } - #[derive(Clone, Copy, Debug, PartialEq, PartialOrd, HeapSizeOf)] + #[derive(Clone, Copy, Debug, PartialEq, PartialOrd)] + #[cfg_attr(feature = "servo", derive(HeapSizeOf))] pub struct Number(pub CSSFloat); impl Number { @@ -1510,7 +1531,8 @@ pub mod specified { } } - #[derive(Clone, Copy, Debug, PartialEq, PartialOrd, HeapSizeOf)] + #[derive(Clone, Copy, Debug, PartialEq, PartialOrd)] + #[cfg_attr(feature = "servo", derive(HeapSizeOf))] pub struct Opacity(pub CSSFloat); impl Opacity { @@ -1630,7 +1652,8 @@ pub mod computed { } } - #[derive(Clone, PartialEq, Copy, Debug, HeapSizeOf)] + #[derive(Clone, PartialEq, Copy, Debug)] + #[cfg_attr(feature = "servo", derive(HeapSizeOf))] pub struct CalcLengthOrPercentage { pub length: Option, pub percentage: Option, @@ -1734,7 +1757,8 @@ pub mod computed { } - #[derive(PartialEq, Clone, Copy, HeapSizeOf)] + #[derive(PartialEq, Clone, Copy)] + #[cfg_attr(feature = "servo", derive(HeapSizeOf))] pub struct BorderRadiusSize(pub Size2D); impl BorderRadiusSize { @@ -1762,7 +1786,8 @@ pub mod computed { } } - #[derive(PartialEq, Clone, Copy, HeapSizeOf)] + #[derive(PartialEq, Clone, Copy)] + #[cfg_attr(feature = "servo", derive(HeapSizeOf))] pub enum LengthOrPercentage { Length(Au), Percentage(CSSFloat), @@ -1827,7 +1852,8 @@ pub mod computed { } } - #[derive(PartialEq, Clone, Copy, HeapSizeOf)] + #[derive(PartialEq, Clone, Copy)] + #[cfg_attr(feature = "servo", derive(HeapSizeOf))] pub enum LengthOrPercentageOrAuto { Length(Au), Percentage(CSSFloat), @@ -1894,7 +1920,8 @@ pub mod computed { } } - #[derive(PartialEq, Clone, Copy, HeapSizeOf)] + #[derive(PartialEq, Clone, Copy)] + #[cfg_attr(feature = "servo", derive(HeapSizeOf))] pub enum LengthOrPercentageOrAutoOrContent { Length(Au), Percentage(CSSFloat), @@ -1952,7 +1979,8 @@ pub mod computed { } } - #[derive(PartialEq, Clone, Copy, HeapSizeOf)] + #[derive(PartialEq, Clone, Copy)] + #[cfg_attr(feature = "servo", derive(HeapSizeOf))] pub enum LengthOrPercentageOrNone { Length(Au), Percentage(CSSFloat), @@ -2004,7 +2032,8 @@ pub mod computed { } } - #[derive(PartialEq, Clone, Copy, HeapSizeOf)] + #[derive(PartialEq, Clone, Copy)] + #[cfg_attr(feature = "servo", derive(HeapSizeOf))] pub enum LengthOrNone { Length(Au), None, @@ -2062,7 +2091,8 @@ pub mod computed { /// Computed values for an image according to CSS-IMAGES. - #[derive(Clone, PartialEq, HeapSizeOf)] + #[derive(Clone, PartialEq)] + #[cfg_attr(feature = "servo", derive(HeapSizeOf))] pub enum Image { Url(Url), LinearGradient(LinearGradient), @@ -2078,7 +2108,8 @@ pub mod computed { } /// Computed values for a CSS linear gradient. - #[derive(Clone, PartialEq, HeapSizeOf)] + #[derive(Clone, PartialEq)] + #[cfg_attr(feature = "servo", derive(HeapSizeOf))] pub struct LinearGradient { /// The angle or corner of the gradient. pub angle_or_corner: AngleOrCorner, @@ -2111,7 +2142,8 @@ pub mod computed { } /// Computed values for one color stop in a linear gradient. - #[derive(Clone, PartialEq, Copy, HeapSizeOf)] + #[derive(Clone, PartialEq, Copy)] + #[cfg_attr(feature = "servo", derive(HeapSizeOf))] pub struct ColorStop { /// The color of this stop. pub color: CSSColor, diff --git a/components/style/viewport.rs b/components/style/viewport.rs index e9308f5403a..ec7e1f8aa4a 100644 --- a/components/style/viewport.rs +++ b/components/style/viewport.rs @@ -21,7 +21,8 @@ use util::geometry::ViewportPx; use values::computed::{Context, ToComputedValue}; use values::specified::{Length, LengthOrPercentageOrAuto, ViewportPercentageLength}; -#[derive(Copy, Clone, Debug, HeapSizeOf, PartialEq)] +#[derive(Copy, Clone, Debug, PartialEq)] +#[cfg_attr(feature = "servo", derive(HeapSizeOf))] pub enum ViewportDescriptor { MinWidth(ViewportLength), MaxWidth(ViewportLength), @@ -45,7 +46,8 @@ trait FromMeta: Sized { // See: // * http://dev.w3.org/csswg/css-device-adapt/#min-max-width-desc // * http://dev.w3.org/csswg/css-device-adapt/#extend-to-zoom -#[derive(Copy, Clone, Debug, HeapSizeOf, PartialEq)] +#[derive(Copy, Clone, Debug, PartialEq)] +#[cfg_attr(feature = "servo", derive(HeapSizeOf))] pub enum ViewportLength { Specified(LengthOrPercentageOrAuto), ExtendToZoom @@ -133,7 +135,8 @@ struct ViewportRuleParser<'a, 'b: 'a> { context: &'a ParserContext<'b> } -#[derive(Copy, Clone, Debug, HeapSizeOf, PartialEq)] +#[derive(Copy, Clone, Debug, PartialEq)] +#[cfg_attr(feature = "servo", derive(HeapSizeOf))] pub struct ViewportDescriptorDeclaration { pub origin: Origin, pub descriptor: ViewportDescriptor, @@ -228,7 +231,8 @@ impl<'a, 'b> DeclarationParser for ViewportRuleParser<'a, 'b> { } } -#[derive(Debug, HeapSizeOf, PartialEq)] +#[derive(Debug, PartialEq)] +#[cfg_attr(feature = "servo", derive(HeapSizeOf))] pub struct ViewportRule { pub declarations: Vec } diff --git a/components/util/Cargo.toml b/components/util/Cargo.toml index 334e474f56b..3e810df69cb 100644 --- a/components/util/Cargo.toml +++ b/components/util/Cargo.toml @@ -10,12 +10,12 @@ path = "lib.rs" [features] # servo as opposed to geckolib -servo = ["serde", "serde_macros", "backtrace", "ipc-channel", "bitflags"] +servo = ["serde", "serde_macros", "backtrace", "ipc-channel"] [dependencies] app_units = {version = "0.2.3"} backtrace = {version = "0.2.1", optional = true} -bitflags = {version = "0.7", optional = true} +bitflags = "0.7" deque = "0.3.1" euclid = {version = "0.6.4"} getopts = "0.2.11" diff --git a/components/util/lib.rs b/components/util/lib.rs index 8fe46dd6f7a..ff1a18ab712 100644 --- a/components/util/lib.rs +++ b/components/util/lib.rs @@ -13,7 +13,7 @@ extern crate app_units; #[cfg(feature = "servo")] extern crate backtrace; -#[cfg(feature = "servo")] #[allow(unused_extern_crates)] #[macro_use] extern crate bitflags; +#[allow(unused_extern_crates)] #[macro_use] extern crate bitflags; extern crate deque; extern crate euclid; extern crate getopts; @@ -46,12 +46,12 @@ pub mod prefs; #[cfg(feature = "servo")] pub mod print_tree; pub mod resource_files; pub mod str; -#[cfg(feature = "servo")] pub mod thread; -#[cfg(feature = "servo")] pub mod thread_state; +pub mod thread; +pub mod thread_state; pub mod tid; #[cfg(feature = "servo")] pub mod time; pub mod vec; -#[cfg(feature = "servo")] #[allow(unsafe_code)] pub mod workqueue; +#[allow(unsafe_code)] pub mod workqueue; #[cfg(feature = "servo")] #[allow(unsafe_code)] diff --git a/components/util/thread.rs b/components/util/thread.rs index 87d8954dcf9..571d3529d9f 100644 --- a/components/util/thread.rs +++ b/components/util/thread.rs @@ -2,13 +2,13 @@ * 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 backtrace::Backtrace; -use ipc_channel::ipc::IpcSender; -use panicking; -use serde::Serialize; -use std::any::Any; +#[cfg(feature = "servo")] use backtrace::Backtrace; +#[cfg(feature = "servo")] use ipc_channel::ipc::IpcSender; +#[cfg(feature = "servo")] use panicking; +#[cfg(feature = "servo")] use serde::Serialize; +#[cfg(feature = "servo")] use std::any::Any; +#[cfg(feature = "servo")] use thread_state; use std::thread; -use thread_state; pub fn spawn_named(name: String, f: F) where F: FnOnce() + Send + 'static @@ -17,6 +17,7 @@ pub fn spawn_named(name: String, f: F) } /// Arrange to send a particular message to a channel if the thread fails. +#[cfg(feature = "servo")] pub fn spawn_named_with_send_on_panic(name: String, state: thread_state::ThreadState, f: F, diff --git a/ports/geckolib/Cargo.lock b/ports/geckolib/Cargo.lock index 7f01cec464f..0e59eb55446 100644 --- a/ports/geckolib/Cargo.lock +++ b/ports/geckolib/Cargo.lock @@ -39,50 +39,7 @@ version = "0.2.4" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ "euclid 0.6.6 (registry+https://github.com/rust-lang/crates.io-index)", - "heapsize 0.3.6 (registry+https://github.com/rust-lang/crates.io-index)", - "heapsize_plugin 0.1.5 (registry+https://github.com/rust-lang/crates.io-index)", "rustc-serialize 0.3.19 (registry+https://github.com/rust-lang/crates.io-index)", - "serde 0.7.10 (registry+https://github.com/rust-lang/crates.io-index)", - "serde_macros 0.7.10 (registry+https://github.com/rust-lang/crates.io-index)", -] - -[[package]] -name = "aster" -version = "0.18.0" -source = "registry+https://github.com/rust-lang/crates.io-index" - -[[package]] -name = "backtrace" -version = "0.2.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -dependencies = [ - "backtrace-sys 0.1.4 (registry+https://github.com/rust-lang/crates.io-index)", - "cfg-if 0.1.0 (registry+https://github.com/rust-lang/crates.io-index)", - "dbghelp-sys 0.2.0 (registry+https://github.com/rust-lang/crates.io-index)", - "kernel32-sys 0.2.1 (registry+https://github.com/rust-lang/crates.io-index)", - "libc 0.2.11 (registry+https://github.com/rust-lang/crates.io-index)", - "rustc-demangle 0.1.0 (registry+https://github.com/rust-lang/crates.io-index)", - "winapi 0.2.7 (registry+https://github.com/rust-lang/crates.io-index)", -] - -[[package]] -name = "backtrace-sys" -version = "0.1.4" -source = "registry+https://github.com/rust-lang/crates.io-index" -dependencies = [ - "gcc 0.3.28 (registry+https://github.com/rust-lang/crates.io-index)", - "libc 0.2.11 (registry+https://github.com/rust-lang/crates.io-index)", -] - -[[package]] -name = "bincode" -version = "0.5.6" -source = "registry+https://github.com/rust-lang/crates.io-index" -dependencies = [ - "byteorder 0.5.3 (registry+https://github.com/rust-lang/crates.io-index)", - "num-traits 0.1.32 (registry+https://github.com/rust-lang/crates.io-index)", - "rustc-serialize 0.3.19 (registry+https://github.com/rust-lang/crates.io-index)", - "serde 0.7.10 (registry+https://github.com/rust-lang/crates.io-index)", ] [[package]] @@ -90,36 +47,13 @@ name = "bitflags" version = "0.7.0" source = "registry+https://github.com/rust-lang/crates.io-index" -[[package]] -name = "byteorder" -version = "0.5.3" -source = "registry+https://github.com/rust-lang/crates.io-index" - -[[package]] -name = "cfg-if" -version = "0.1.0" -source = "registry+https://github.com/rust-lang/crates.io-index" - [[package]] name = "cssparser" version = "0.5.6" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ "encoding 0.2.32 (registry+https://github.com/rust-lang/crates.io-index)", - "heapsize 0.3.6 (registry+https://github.com/rust-lang/crates.io-index)", - "heapsize_plugin 0.1.5 (registry+https://github.com/rust-lang/crates.io-index)", "matches 0.1.2 (registry+https://github.com/rust-lang/crates.io-index)", - "serde 0.7.10 (registry+https://github.com/rust-lang/crates.io-index)", - "serde_macros 0.7.10 (registry+https://github.com/rust-lang/crates.io-index)", -] - -[[package]] -name = "dbghelp-sys" -version = "0.2.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -dependencies = [ - "winapi 0.2.7 (registry+https://github.com/rust-lang/crates.io-index)", - "winapi-build 0.1.1 (registry+https://github.com/rust-lang/crates.io-index)", ] [[package]] @@ -201,13 +135,9 @@ name = "euclid" version = "0.6.6" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ - "heapsize 0.3.6 (registry+https://github.com/rust-lang/crates.io-index)", - "heapsize_plugin 0.1.5 (registry+https://github.com/rust-lang/crates.io-index)", "log 0.3.6 (registry+https://github.com/rust-lang/crates.io-index)", "num-traits 0.1.32 (registry+https://github.com/rust-lang/crates.io-index)", "rustc-serialize 0.3.19 (registry+https://github.com/rust-lang/crates.io-index)", - "serde 0.7.10 (registry+https://github.com/rust-lang/crates.io-index)", - "serde_macros 0.7.10 (registry+https://github.com/rust-lang/crates.io-index)", ] [[package]] @@ -215,11 +145,6 @@ name = "fnv" version = "1.0.2" source = "registry+https://github.com/rust-lang/crates.io-index" -[[package]] -name = "gcc" -version = "0.3.28" -source = "registry+https://github.com/rust-lang/crates.io-index" - [[package]] name = "gecko_bindings" version = "0.0.1" @@ -255,20 +180,6 @@ dependencies = [ "unicode-normalization 0.1.2 (registry+https://github.com/rust-lang/crates.io-index)", ] -[[package]] -name = "ipc-channel" -version = "0.2.3" -source = "git+https://github.com/servo/ipc-channel#48137d69955f5460da586c552de275ecdc3f4efe" -dependencies = [ - "bincode 0.5.6 (registry+https://github.com/rust-lang/crates.io-index)", - "lazy_static 0.2.1 (registry+https://github.com/rust-lang/crates.io-index)", - "libc 0.2.11 (registry+https://github.com/rust-lang/crates.io-index)", - "rand 0.3.14 (registry+https://github.com/rust-lang/crates.io-index)", - "serde 0.7.10 (registry+https://github.com/rust-lang/crates.io-index)", - "serde_macros 0.7.10 (registry+https://github.com/rust-lang/crates.io-index)", - "uuid 0.2.2 (registry+https://github.com/rust-lang/crates.io-index)", -] - [[package]] name = "kernel32-sys" version = "0.2.1" @@ -326,27 +237,6 @@ dependencies = [ "tenacious 0.2.1 (registry+https://github.com/rust-lang/crates.io-index)", ] -[[package]] -name = "quasi" -version = "0.12.0" -source = "registry+https://github.com/rust-lang/crates.io-index" - -[[package]] -name = "quasi_codegen" -version = "0.12.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -dependencies = [ - "aster 0.18.0 (registry+https://github.com/rust-lang/crates.io-index)", -] - -[[package]] -name = "quasi_macros" -version = "0.12.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -dependencies = [ - "quasi_codegen 0.12.0 (registry+https://github.com/rust-lang/crates.io-index)", -] - [[package]] name = "quickersort" version = "2.0.1" @@ -381,11 +271,6 @@ name = "regex-syntax" version = "0.3.3" source = "registry+https://github.com/rust-lang/crates.io-index" -[[package]] -name = "rustc-demangle" -version = "0.1.0" -source = "registry+https://github.com/rust-lang/crates.io-index" - [[package]] name = "rustc-serialize" version = "0.3.19" @@ -399,8 +284,6 @@ dependencies = [ "bitflags 0.7.0 (registry+https://github.com/rust-lang/crates.io-index)", "cssparser 0.5.6 (registry+https://github.com/rust-lang/crates.io-index)", "fnv 1.0.2 (registry+https://github.com/rust-lang/crates.io-index)", - "heapsize 0.3.6 (registry+https://github.com/rust-lang/crates.io-index)", - "heapsize_plugin 0.1.5 (registry+https://github.com/rust-lang/crates.io-index)", "matches 0.1.2 (registry+https://github.com/rust-lang/crates.io-index)", "quickersort 2.0.1 (registry+https://github.com/rust-lang/crates.io-index)", "smallvec 0.1.7 (registry+https://github.com/rust-lang/crates.io-index)", @@ -412,24 +295,6 @@ name = "serde" version = "0.7.10" source = "registry+https://github.com/rust-lang/crates.io-index" -[[package]] -name = "serde_codegen" -version = "0.7.10" -source = "registry+https://github.com/rust-lang/crates.io-index" -dependencies = [ - "aster 0.18.0 (registry+https://github.com/rust-lang/crates.io-index)", - "quasi 0.12.0 (registry+https://github.com/rust-lang/crates.io-index)", - "quasi_macros 0.12.0 (registry+https://github.com/rust-lang/crates.io-index)", -] - -[[package]] -name = "serde_macros" -version = "0.7.10" -source = "registry+https://github.com/rust-lang/crates.io-index" -dependencies = [ - "serde_codegen 0.7.10 (registry+https://github.com/rust-lang/crates.io-index)", -] - [[package]] name = "smallvec" version = "0.1.7" @@ -462,17 +327,12 @@ dependencies = [ "euclid 0.6.6 (registry+https://github.com/rust-lang/crates.io-index)", "fnv 1.0.2 (registry+https://github.com/rust-lang/crates.io-index)", "gecko_bindings 0.0.1", - "heapsize 0.3.6 (registry+https://github.com/rust-lang/crates.io-index)", - "heapsize_plugin 0.1.5 (registry+https://github.com/rust-lang/crates.io-index)", "lazy_static 0.2.1 (registry+https://github.com/rust-lang/crates.io-index)", "log 0.3.6 (registry+https://github.com/rust-lang/crates.io-index)", "matches 0.1.2 (registry+https://github.com/rust-lang/crates.io-index)", "num-traits 0.1.32 (registry+https://github.com/rust-lang/crates.io-index)", - "plugins 0.0.1", "rustc-serialize 0.3.19 (registry+https://github.com/rust-lang/crates.io-index)", "selectors 0.6.0 (registry+https://github.com/rust-lang/crates.io-index)", - "serde 0.7.10 (registry+https://github.com/rust-lang/crates.io-index)", - "serde_macros 0.7.10 (registry+https://github.com/rust-lang/crates.io-index)", "smallvec 0.1.7 (registry+https://github.com/rust-lang/crates.io-index)", "string_cache 0.2.20 (registry+https://github.com/rust-lang/crates.io-index)", "style_traits 0.0.1", @@ -488,12 +348,7 @@ version = "0.0.1" dependencies = [ "cssparser 0.5.6 (registry+https://github.com/rust-lang/crates.io-index)", "euclid 0.6.6 (registry+https://github.com/rust-lang/crates.io-index)", - "heapsize 0.3.6 (registry+https://github.com/rust-lang/crates.io-index)", - "heapsize_plugin 0.1.5 (registry+https://github.com/rust-lang/crates.io-index)", - "plugins 0.0.1", "rustc-serialize 0.3.19 (registry+https://github.com/rust-lang/crates.io-index)", - "serde 0.7.10 (registry+https://github.com/rust-lang/crates.io-index)", - "serde_macros 0.7.10 (registry+https://github.com/rust-lang/crates.io-index)", "util 0.0.1", ] @@ -557,12 +412,9 @@ version = "1.1.1" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ "encoding 0.2.32 (registry+https://github.com/rust-lang/crates.io-index)", - "heapsize 0.3.6 (registry+https://github.com/rust-lang/crates.io-index)", - "heapsize_plugin 0.1.5 (registry+https://github.com/rust-lang/crates.io-index)", "idna 0.1.0 (registry+https://github.com/rust-lang/crates.io-index)", "matches 0.1.2 (registry+https://github.com/rust-lang/crates.io-index)", "rustc-serialize 0.3.19 (registry+https://github.com/rust-lang/crates.io-index)", - "serde 0.7.10 (registry+https://github.com/rust-lang/crates.io-index)", ] [[package]] @@ -575,25 +427,19 @@ name = "util" version = "0.0.1" dependencies = [ "app_units 0.2.4 (registry+https://github.com/rust-lang/crates.io-index)", - "backtrace 0.2.2 (registry+https://github.com/rust-lang/crates.io-index)", "bitflags 0.7.0 (registry+https://github.com/rust-lang/crates.io-index)", "deque 0.3.1 (registry+https://github.com/rust-lang/crates.io-index)", "euclid 0.6.6 (registry+https://github.com/rust-lang/crates.io-index)", "getopts 0.2.14 (registry+https://github.com/rust-lang/crates.io-index)", "heapsize 0.3.6 (registry+https://github.com/rust-lang/crates.io-index)", - "heapsize_plugin 0.1.5 (registry+https://github.com/rust-lang/crates.io-index)", - "ipc-channel 0.2.3 (git+https://github.com/servo/ipc-channel)", "kernel32-sys 0.2.1 (registry+https://github.com/rust-lang/crates.io-index)", "lazy_static 0.2.1 (registry+https://github.com/rust-lang/crates.io-index)", "libc 0.2.11 (registry+https://github.com/rust-lang/crates.io-index)", "log 0.3.6 (registry+https://github.com/rust-lang/crates.io-index)", "num-traits 0.1.32 (registry+https://github.com/rust-lang/crates.io-index)", "num_cpus 0.2.12 (registry+https://github.com/rust-lang/crates.io-index)", - "plugins 0.0.1", "rand 0.3.14 (registry+https://github.com/rust-lang/crates.io-index)", "rustc-serialize 0.3.19 (registry+https://github.com/rust-lang/crates.io-index)", - "serde 0.7.10 (registry+https://github.com/rust-lang/crates.io-index)", - "serde_macros 0.7.10 (registry+https://github.com/rust-lang/crates.io-index)", "smallvec 0.1.7 (registry+https://github.com/rust-lang/crates.io-index)", "url 1.1.1 (registry+https://github.com/rust-lang/crates.io-index)", "xdg 2.0.0 (registry+https://github.com/rust-lang/crates.io-index)",