aboutsummaryrefslogtreecommitdiffstats
path: root/src/components/style/selector_matching.rs
diff options
context:
space:
mode:
authorbors-servo <release+servo@mozilla.com>2013-10-18 14:25:34 -0700
committerbors-servo <release+servo@mozilla.com>2013-10-18 14:25:34 -0700
commit8f7f70cb5c26c6787e322fdff729b3e5054398bd (patch)
treef88dbc964ebb91fc027bb84c5121cc58c8a41472 /src/components/style/selector_matching.rs
parent284ad5ee8eb43274036b05ae400fccb823313d15 (diff)
parentec711dac78750a8417c181cba0285f0753e82ff8 (diff)
downloadservo-8f7f70cb5c26c6787e322fdff729b3e5054398bd.tar.gz
servo-8f7f70cb5c26c6787e322fdff729b3e5054398bd.zip
auto merge of #1087 : SimonSapin/servo/newnewcss, r=kmcallister
This is still not the big switch yet, but preparatory changes contained to the 'style' crate. The current status of the actual port can be seen here: https://github.com/SimonSapin/servo/compare/newnewcss...break-all-the-things (moving as I push and rebase stuff.)
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);