mirror of
https://github.com/servo/servo.git
synced 2025-08-08 06:55:31 +01:00
Add the CSS SelectCtx to Layout
This commit is contained in:
parent
8c98b0e49c
commit
806517b9bb
3 changed files with 13 additions and 20 deletions
|
@ -6,7 +6,7 @@ use dom::node::{LayoutData, Node, Text};
|
||||||
use dom::element::ElementData;
|
use dom::element::ElementData;
|
||||||
|
|
||||||
use newcss::values::*;
|
use newcss::values::*;
|
||||||
use newcss::Stylesheet;
|
use newcss::SelectCtx;
|
||||||
use styles::{SpecifiedStyle};
|
use styles::{SpecifiedStyle};
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -196,7 +196,7 @@ impl Node : PrivStyleMethods {
|
||||||
}
|
}
|
||||||
|
|
||||||
trait MatchingMethods {
|
trait MatchingMethods {
|
||||||
fn match_css_style(styles : &Stylesheet);
|
fn match_css_style(styles : &SelectCtx);
|
||||||
}
|
}
|
||||||
|
|
||||||
impl Node : MatchingMethods {
|
impl Node : MatchingMethods {
|
||||||
|
@ -204,7 +204,7 @@ impl Node : MatchingMethods {
|
||||||
Compare an html element to a list of css rules and update its
|
Compare an html element to a list of css rules and update its
|
||||||
style according to the rules matching it.
|
style according to the rules matching it.
|
||||||
*/
|
*/
|
||||||
fn match_css_style(styles : &Stylesheet) {
|
fn match_css_style(styles : &SelectCtx) {
|
||||||
// Loop over each rule, see if our node matches what is
|
// Loop over each rule, see if our node matches what is
|
||||||
// described in the rule. If it matches, update its style. As
|
// described in the rule. If it matches, update its style. As
|
||||||
// we don't currently have priorities of style information,
|
// we don't currently have priorities of style information,
|
||||||
|
|
|
@ -5,7 +5,7 @@ use std::arc::{ARC, get, clone};
|
||||||
|
|
||||||
use core::dvec::DVec;
|
use core::dvec::DVec;
|
||||||
use newcss::values::*;
|
use newcss::values::*;
|
||||||
use newcss::Stylesheet;
|
use newcss::SelectCtx;
|
||||||
use dom::element::{HTMLDivElement, HTMLHeadElement, HTMLImageElement, UnknownElement, HTMLScriptElement};
|
use dom::element::{HTMLDivElement, HTMLHeadElement, HTMLImageElement, UnknownElement, HTMLScriptElement};
|
||||||
use dom::node::{Comment, Doctype, Element, Text,
|
use dom::node::{Comment, Doctype, Element, Text,
|
||||||
Node, NodeKind, NodeTree, LayoutData};
|
Node, NodeKind, NodeTree, LayoutData};
|
||||||
|
@ -107,7 +107,7 @@ trait StyleMethods {
|
||||||
|
|
||||||
fn style() -> SpecifiedStyle;
|
fn style() -> SpecifiedStyle;
|
||||||
fn initialize_style_for_subtree(ctx: &LayoutContext, refs: &DVec<@LayoutData>);
|
fn initialize_style_for_subtree(ctx: &LayoutContext, refs: &DVec<@LayoutData>);
|
||||||
fn recompute_style_for_subtree(ctx: &LayoutContext, styles : &Stylesheet);
|
fn recompute_style_for_subtree(ctx: &LayoutContext, styles : &SelectCtx);
|
||||||
}
|
}
|
||||||
|
|
||||||
impl Node : StyleMethods {
|
impl Node : StyleMethods {
|
||||||
|
@ -160,7 +160,7 @@ impl Node : StyleMethods {
|
||||||
* the node (the reader-auxiliary box in the COW model) with the
|
* the node (the reader-auxiliary box in the COW model) with the
|
||||||
* computed style.
|
* computed style.
|
||||||
*/
|
*/
|
||||||
fn recompute_style_for_subtree(ctx: &LayoutContext, styles : &Stylesheet) {
|
fn recompute_style_for_subtree(ctx: &LayoutContext, styles : &SelectCtx) {
|
||||||
let mut i = 0u;
|
let mut i = 0u;
|
||||||
|
|
||||||
// Compute the styles of each of our children in parallel
|
// Compute the styles of each of our children in parallel
|
||||||
|
|
|
@ -37,6 +37,7 @@ use layout::traverse::*;
|
||||||
use comm::*;
|
use comm::*;
|
||||||
use task::*;
|
use task::*;
|
||||||
use core::mutable::Mut;
|
use core::mutable::Mut;
|
||||||
|
use newcss::SelectCtx;
|
||||||
|
|
||||||
pub type LayoutTask = comm::Chan<Msg>;
|
pub type LayoutTask = comm::Chan<Msg>;
|
||||||
|
|
||||||
|
@ -82,7 +83,7 @@ struct Layout {
|
||||||
font_matcher: @FontMatcher,
|
font_matcher: @FontMatcher,
|
||||||
// This is used to root auxilliary RCU reader data
|
// This is used to root auxilliary RCU reader data
|
||||||
layout_refs: DVec<@LayoutData>,
|
layout_refs: DVec<@LayoutData>,
|
||||||
stylesheet: Mut<Option<Stylesheet>>
|
css_select_ctx: Mut<SelectCtx>,
|
||||||
}
|
}
|
||||||
|
|
||||||
fn Layout(render_task: RenderTask,
|
fn Layout(render_task: RenderTask,
|
||||||
|
@ -99,7 +100,7 @@ fn Layout(render_task: RenderTask,
|
||||||
font_matcher: @FontMatcher::new(fctx),
|
font_matcher: @FontMatcher::new(fctx),
|
||||||
font_cache: @FontCache::new(fctx),
|
font_cache: @FontCache::new(fctx),
|
||||||
layout_refs: DVec(),
|
layout_refs: DVec(),
|
||||||
stylesheet: Mut(None)
|
css_select_ctx: Mut(SelectCtx::new())
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -141,9 +142,8 @@ impl Layout {
|
||||||
|
|
||||||
fn handle_add_stylesheet(sheet: Stylesheet) {
|
fn handle_add_stylesheet(sheet: Stylesheet) {
|
||||||
let sheet = Cell(move sheet);
|
let sheet = Cell(move sheet);
|
||||||
do self.stylesheet.borrow_mut |mysheet| {
|
do self.css_select_ctx.borrow_mut |ctx| {
|
||||||
assert mysheet.is_none(); // FIXME: Support multiple sheets
|
ctx.append_sheet(sheet.take());
|
||||||
*mysheet = Some(sheet.take());
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -175,15 +175,8 @@ impl Layout {
|
||||||
let layout_root: @FlowContext = do time("layout: tree construction") {
|
let layout_root: @FlowContext = do time("layout: tree construction") {
|
||||||
// TODO: this is dumb. we don't need 3 separate traversals.
|
// TODO: this is dumb. we don't need 3 separate traversals.
|
||||||
node.initialize_style_for_subtree(&layout_ctx, &self.layout_refs);
|
node.initialize_style_for_subtree(&layout_ctx, &self.layout_refs);
|
||||||
do self.stylesheet.borrow_imm |sheet| {
|
do self.css_select_ctx.borrow_imm |ctx| {
|
||||||
match *sheet {
|
node.recompute_style_for_subtree(&layout_ctx, ctx);
|
||||||
Some(ref sheet) => {
|
|
||||||
unsafe {
|
|
||||||
node.recompute_style_for_subtree(&layout_ctx, sheet);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
None => ()
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
/* resolve styles (convert relative values) down the node tree */
|
/* resolve styles (convert relative values) down the node tree */
|
||||||
apply_style(&layout_ctx, *node);
|
apply_style(&layout_ctx, *node);
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue