aboutsummaryrefslogtreecommitdiffstats
path: root/src/components/main/layout/layout_task.rs
diff options
context:
space:
mode:
authorbors-servo <release+servo@mozilla.com>2014-01-08 05:37:20 -0800
committerbors-servo <release+servo@mozilla.com>2014-01-08 05:37:20 -0800
commit99157c64128ad9317e4296b9e28fe4e10bc306f6 (patch)
tree45f5214475a624990543498ee7bf3dd9cc2149a0 /src/components/main/layout/layout_task.rs
parentde36f37ac76125be9b7bff02736d8f5c7b10e995 (diff)
parent62691cb6ef4ffe1c21ba46f102425c6c37050bce (diff)
downloadservo-99157c64128ad9317e4296b9e28fe4e10bc306f6.tar.gz
servo-99157c64128ad9317e4296b9e28fe4e10bc306f6.zip
auto merge of #1464 : parkjaeman/servo/pseudo-element-selectors-matching, r=SimonSapin
CSS parsing and selector matching for pseudo element :before and :after
Diffstat (limited to 'src/components/main/layout/layout_task.rs')
-rw-r--r--src/components/main/layout/layout_task.rs23
1 files changed, 18 insertions, 5 deletions
diff --git a/src/components/main/layout/layout_task.rs b/src/components/main/layout/layout_task.rs
index 8f5edcfb3ab..9ce50a0bf4c 100644
--- a/src/components/main/layout/layout_task.rs
+++ b/src/components/main/layout/layout_task.rs
@@ -51,6 +51,7 @@ use std::comm::Port;
use std::task;
use std::util;
use style::{AuthorOrigin, Stylesheet, Stylist};
+use style::{Before, After};
/// Information needed by the layout task.
struct LayoutTask {
@@ -81,7 +82,7 @@ struct LayoutTask {
/// A cached display list.
display_list: Option<Arc<DisplayList<OpaqueNode>>>,
- stylist: RWArc<Stylist>,
+ stylists: ~[RWArc<Stylist>],
/// The channel on which messages can be sent to the profiler.
profiler_chan: ProfilerChan,
@@ -236,6 +237,14 @@ impl LayoutTask {
profiler_chan: ProfilerChan)
-> LayoutTask {
+ let mut stylists = ~[];
+ // We implemented parsing/selector-matching only for Before and After.
+ // FirstLine and FirstLetter have to be added later.
+ let stylist_owners = ~[Some(Before), Some(After), None];
+ for pseudo_element in stylist_owners.iter() {
+ stylists.push(RWArc::new(new_stylist(*pseudo_element)));
+ }
+
LayoutTask {
id: id,
port: port,
@@ -248,7 +257,7 @@ impl LayoutTask {
display_list: None,
- stylist: RWArc::new(new_stylist()),
+ stylists: stylists,
profiler_chan: profiler_chan,
opts: opts.clone()
}
@@ -347,8 +356,12 @@ impl LayoutTask {
fn handle_add_stylesheet(&mut self, sheet: Stylesheet) {
let sheet = Cell::new(sheet);
- do self.stylist.write |stylist| {
- stylist.add_stylesheet(sheet.take(), AuthorOrigin)
+ for stylist in self.stylists.iter() {
+ do stylist.write |stylist| {
+ sheet.with_ref(|sheet|{
+ stylist.add_stylesheet(sheet, AuthorOrigin);
+ });
+ }
}
}
@@ -445,7 +458,7 @@ impl LayoutTask {
ReflowDocumentDamage => {}
_ => {
do profile(time::LayoutSelectorMatchCategory, self.profiler_chan.clone()) {
- node.match_subtree(self.stylist.clone());
+ node.match_subtree(self.stylists.clone());
node.cascade_subtree(None);
}
}