aboutsummaryrefslogtreecommitdiffstats
path: root/src/components/style/selector_matching.rs
diff options
context:
space:
mode:
Diffstat (limited to 'src/components/style/selector_matching.rs')
-rw-r--r--src/components/style/selector_matching.rs17
1 files changed, 10 insertions, 7 deletions
diff --git a/src/components/style/selector_matching.rs b/src/components/style/selector_matching.rs
index f40cfe5c8e6..490d15c68ac 100644
--- a/src/components/style/selector_matching.rs
+++ b/src/components/style/selector_matching.rs
@@ -2,11 +2,12 @@
* 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;
use selectors::*;
-use stylesheets::parse_stylesheet;
+use stylesheets::Stylesheet;
use media_queries::{Device, Screen};
use properties::{PropertyDeclaration, PropertyDeclarationBlock};
use servo_util::tree::{TreeNodeRefAsElement, TreeNode, ElementLike};
@@ -36,8 +37,7 @@ impl Stylist {
}
}
- pub fn add_stylesheet(&mut self, css_source: &str, origin: StylesheetOrigin) {
- let stylesheet = parse_stylesheet(css_source);
+ pub fn add_stylesheet(&mut self, stylesheet: Stylesheet, origin: StylesheetOrigin) {
let rules = match origin {
UserAgentOrigin => &mut self.ua_rules,
AuthorOrigin => &mut self.author_rules,
@@ -51,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),
})
}
}
@@ -100,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);