diff --git a/src/components/style/properties.rs.mako b/src/components/style/properties.rs.mako index d7d72d593ad..cf941fae432 100644 --- a/src/components/style/properties.rs.mako +++ b/src/components/style/properties.rs.mako @@ -5,7 +5,6 @@ // This file is a Mako template: http://www.makotemplates.org/ use std::ascii::StrAsciiExt; -use std::at_vec; pub use std::iterator; pub use cssparser::*; pub use errors::{ErrorLoggerIterator, log_css_error}; @@ -810,8 +809,8 @@ pub mod shorthands { pub struct PropertyDeclarationBlock { - important: @[PropertyDeclaration], - normal: @[PropertyDeclaration], + important: ~[PropertyDeclaration], + normal: ~[PropertyDeclaration], } @@ -837,9 +836,8 @@ pub fn parse_property_declaration_list>(input: I) -> PropertyD } } PropertyDeclarationBlock { - // TODO avoid copying? - important: at_vec::to_managed_move(important), - normal: at_vec::to_managed_move(normal), + important: important, + normal: normal, } } @@ -872,6 +870,7 @@ pub enum DeclaredValue { CSSWideKeyword(CSSWideKeyword), } +#[deriving(Clone)] pub enum PropertyDeclaration { % for property in LONGHANDS: ${property.ident}_declaration(DeclaredValue), @@ -961,7 +960,7 @@ fn get_initial_values() -> ComputedValues { // Most specific/important declarations last -pub fn cascade(applicable_declarations: &[@[PropertyDeclaration]], +pub fn cascade(applicable_declarations: &[~[PropertyDeclaration]], parent_style: Option< &ComputedValues>) -> ComputedValues { let initial_keep_alive; diff --git a/src/components/style/selector_matching.rs b/src/components/style/selector_matching.rs index 10de6d6117f..490d15c68ac 100644 --- a/src/components/style/selector_matching.rs +++ b/src/components/style/selector_matching.rs @@ -2,6 +2,7 @@ * 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 std::at_vec; use std::ascii::StrAsciiExt; use extra::sort::tim_sort; @@ -50,9 +51,10 @@ impl Stylist { if style_rule.declarations.$priority.len() > 0 { $flag = true; for selector in style_rule.selectors.iter() { + // TODO: avoid copying? rules.$priority.push(Rule { - selector: *selector, - declarations: style_rule.declarations.$priority, + selector: @(*selector).clone(), + declarations:at_vec::to_managed(style_rule.declarations.$priority), }) } } @@ -99,10 +101,12 @@ impl Stylist { // Style attributes have author origin but higher specificity than style rules. append!(self.author_rules.normal); - style_attribute.map(|sa| applicable_declarations.push(sa.normal)); + // TODO: avoid copying? + style_attribute.map(|sa| applicable_declarations.push(at_vec::to_managed(sa.normal))); append!(self.author_rules.important); - style_attribute.map(|sa| applicable_declarations.push(sa.important)); + // TODO: avoid copying? + style_attribute.map(|sa| applicable_declarations.push(at_vec::to_managed(sa.important))); append!(self.user_rules.important); append!(self.ua_rules.important); diff --git a/src/components/style/selectors.rs b/src/components/style/selectors.rs index e5d5666c40c..4a2ed8caed3 100644 --- a/src/components/style/selectors.rs +++ b/src/components/style/selectors.rs @@ -8,6 +8,7 @@ use cssparser::*; use namespaces::NamespaceMap; +#[deriving(Clone)] pub struct Selector { compound_selectors: CompoundSelector, pseudo_element: Option, @@ -17,7 +18,7 @@ pub struct Selector { pub static STYLE_ATTRIBUTE_SPECIFICITY: u32 = 1 << 31; -#[deriving(Eq)] +#[deriving(Eq, Clone)] pub enum PseudoElement { Before, After, @@ -26,11 +27,13 @@ pub enum PseudoElement { } +#[deriving(Clone)] pub struct CompoundSelector { simple_selectors: ~[SimpleSelector], next: Option<(~CompoundSelector, Combinator)>, // c.next is left of c } +#[deriving(Eq, Clone)] pub enum Combinator { Child, // > Descendant, // space @@ -38,6 +41,7 @@ pub enum Combinator { LaterSibling, // ~ } +#[deriving(Clone)] pub enum SimpleSelector { IDSelector(~str), ClassSelector(~str), @@ -62,6 +66,7 @@ pub enum SimpleSelector { // ... } +#[deriving(Clone)] pub struct AttrSelector { name: ~str, namespace: Option<~str>, @@ -73,7 +78,7 @@ type Iter = iterator::Peekable // None means invalid selector pub fn parse_selector_list(input: ~[ComponentValue], namespaces: &NamespaceMap) - -> Option<~[@Selector]> { + -> Option<~[Selector]> { let iter = &mut input.move_iter().peekable(); let first = match parse_selector(iter, namespaces) { None => return None, @@ -99,7 +104,7 @@ pub fn parse_selector_list(input: ~[ComponentValue], namespaces: &NamespaceMap) // None means invalid selector fn parse_selector(iter: &mut Iter, namespaces: &NamespaceMap) - -> Option<@Selector> { + -> Option { let (first, pseudo_element) = match parse_simple_selectors(iter, namespaces) { None => return None, Some(result) => result @@ -130,7 +135,7 @@ fn parse_selector(iter: &mut Iter, namespaces: &NamespaceMap) } } } - Some(@Selector { + Some(Selector { specificity: compute_specificity(&compound, &pseudo_element), compound_selectors: compound, pseudo_element: pseudo_element, diff --git a/src/components/style/stylesheets.rs b/src/components/style/stylesheets.rs index c6a210f5ff4..e3c8d5a6ad8 100644 --- a/src/components/style/stylesheets.rs +++ b/src/components/style/stylesheets.rs @@ -27,7 +27,7 @@ pub enum CSSRule { pub struct StyleRule { - selectors: ~[@selectors::Selector], + selectors: ~[selectors::Selector], declarations: properties::PropertyDeclarationBlock, }