CSS parsing/selector-matching for pseudo elements

This commit is contained in:
Jaeman Park 2014-01-07 14:40:26 +09:00 committed by Sangeun Kim
parent daebaf1eea
commit 138e425607
6 changed files with 144 additions and 28 deletions

View file

@ -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,12 @@ impl LayoutTask {
profiler_chan: ProfilerChan)
-> LayoutTask {
let mut stylists = ~[];
let stylist_owners = ~[Some(Before), Some(After), None];
for i in range(0, stylist_owners.len()) {
stylists.push(RWArc::new(new_stylist(stylist_owners[i])));
}
LayoutTask {
id: id,
port: port,
@ -248,7 +255,7 @@ impl LayoutTask {
display_list: None,
stylist: RWArc::new(new_stylist()),
stylists: stylists,
profiler_chan: profiler_chan,
opts: opts.clone()
}
@ -347,8 +354,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 i in range(0, self.stylists.len()) {
do self.stylists[i].write |stylist| {
sheet.with_ref(|sheet|{
stylist.add_stylesheet(sheet, AuthorOrigin);
});
}
}
}
@ -445,7 +456,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);
}
}