servo: Add css::compute, for computing styles from Node + SelectResult

Source-Repo: https://github.com/servo/servo
Source-Revision: 5fd318be80000510dcdc683b68ced5978fad8b32
This commit is contained in:
Brian Anderson 2012-10-31 16:07:27 -07:00
parent 00ec4f01e0
commit 7a618492f6
3 changed files with 19 additions and 7 deletions

View File

@ -0,0 +1,16 @@
/*!
Calculate styles for nodes based on SelectResults
*/
use dom::node::Node;
use newcss::color::{Color, rgba};
pub trait ComputeStyles {
fn compute_background_color() -> Color;
}
impl Node: ComputeStyles {
fn compute_background_color() -> Color {
rgba(255, 0, 255, 1.0)
}
}

View File

@ -9,6 +9,7 @@ use core::dvec::DVec;
use core::to_str::ToStr;
use core::rand;
use css::styles::SpecifiedStyle;
use css::compute::ComputeStyles;
use newcss::values::{BoxSizing, Length, Px, CSSDisplay, Specified, BgColor, BgColorTransparent};
use newcss::values::{BdrColor, PosAbsolute};
use newcss::color::{Color, rgba};
@ -428,13 +429,7 @@ impl RenderBox : RenderBoxMethods {
fn add_bgcolor_to_list(list: &mut DisplayList, abs_bounds: &Rect<Au>) {
use std::cmp::FuzzyEq;
// FIXME
/*let boxed_bgcolor = self.d().node.style().background_color;
let bgcolor = match boxed_bgcolor {
Specified(BgColor(c)) => c,
Specified(BgColorTransparent) | _ => rgba(0,0,0,0.0)
};*/
let bgcolor = rgba(0,0,0,0.0);
let bgcolor = self.d().node.compute_background_color();
if !bgcolor.alpha.fuzzy_eq(&0.0) {
list.append_item(~DisplayItem::new_SolidColor(abs_bounds, bgcolor.red, bgcolor.green, bgcolor.blue));
}

View File

@ -49,6 +49,7 @@ pub mod css {
mod apply;
mod matching;
priv mod select_handler;
pub mod compute;
}
pub mod layout {