mirror of
https://github.com/servo/servo.git
synced 2025-08-06 06:00:15 +01:00
Remove @pointers from Stylesheet to make it Sendable
… at the cost some extra copying. This fixes #1081.
This commit is contained in:
parent
e30a950e40
commit
acb11343ce
4 changed files with 24 additions and 16 deletions
|
@ -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<I: Iterator<Node>>(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<T> {
|
|||
CSSWideKeyword(CSSWideKeyword),
|
||||
}
|
||||
|
||||
#[deriving(Clone)]
|
||||
pub enum PropertyDeclaration {
|
||||
% for property in LONGHANDS:
|
||||
${property.ident}_declaration(DeclaredValue<longhands::${property.ident}::SpecifiedValue>),
|
||||
|
@ -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;
|
||||
|
|
|
@ -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);
|
||||
|
|
|
@ -8,6 +8,7 @@ use cssparser::*;
|
|||
use namespaces::NamespaceMap;
|
||||
|
||||
|
||||
#[deriving(Clone)]
|
||||
pub struct Selector {
|
||||
compound_selectors: CompoundSelector,
|
||||
pseudo_element: Option<PseudoElement>,
|
||||
|
@ -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<ComponentValue, vec::MoveIterator<ComponentValue>
|
|||
|
||||
// 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<Selector> {
|
||||
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,
|
||||
|
|
|
@ -27,7 +27,7 @@ pub enum CSSRule {
|
|||
|
||||
|
||||
pub struct StyleRule {
|
||||
selectors: ~[@selectors::Selector],
|
||||
selectors: ~[selectors::Selector],
|
||||
declarations: properties::PropertyDeclarationBlock,
|
||||
}
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue