mirror of
https://github.com/servo/servo.git
synced 2025-08-07 06:25:32 +01:00
Add css::compute, for computing styles from Node + SelectResult
This commit is contained in:
parent
2c2ad1018a
commit
5fd318be80
3 changed files with 19 additions and 7 deletions
16
src/servo/css/compute.rs
Normal file
16
src/servo/css/compute.rs
Normal 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)
|
||||||
|
}
|
||||||
|
}
|
|
@ -9,6 +9,7 @@ use core::dvec::DVec;
|
||||||
use core::to_str::ToStr;
|
use core::to_str::ToStr;
|
||||||
use core::rand;
|
use core::rand;
|
||||||
use css::styles::SpecifiedStyle;
|
use css::styles::SpecifiedStyle;
|
||||||
|
use css::compute::ComputeStyles;
|
||||||
use newcss::values::{BoxSizing, Length, Px, CSSDisplay, Specified, BgColor, BgColorTransparent};
|
use newcss::values::{BoxSizing, Length, Px, CSSDisplay, Specified, BgColor, BgColorTransparent};
|
||||||
use newcss::values::{BdrColor, PosAbsolute};
|
use newcss::values::{BdrColor, PosAbsolute};
|
||||||
use newcss::color::{Color, rgba};
|
use newcss::color::{Color, rgba};
|
||||||
|
@ -428,13 +429,7 @@ impl RenderBox : RenderBoxMethods {
|
||||||
|
|
||||||
fn add_bgcolor_to_list(list: &mut DisplayList, abs_bounds: &Rect<Au>) {
|
fn add_bgcolor_to_list(list: &mut DisplayList, abs_bounds: &Rect<Au>) {
|
||||||
use std::cmp::FuzzyEq;
|
use std::cmp::FuzzyEq;
|
||||||
// FIXME
|
let bgcolor = self.d().node.compute_background_color();
|
||||||
/*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);
|
|
||||||
if !bgcolor.alpha.fuzzy_eq(&0.0) {
|
if !bgcolor.alpha.fuzzy_eq(&0.0) {
|
||||||
list.append_item(~DisplayItem::new_SolidColor(abs_bounds, bgcolor.red, bgcolor.green, bgcolor.blue));
|
list.append_item(~DisplayItem::new_SolidColor(abs_bounds, bgcolor.red, bgcolor.green, bgcolor.blue));
|
||||||
}
|
}
|
||||||
|
|
|
@ -49,6 +49,7 @@ pub mod css {
|
||||||
mod apply;
|
mod apply;
|
||||||
mod matching;
|
mod matching;
|
||||||
priv mod select_handler;
|
priv mod select_handler;
|
||||||
|
pub mod compute;
|
||||||
}
|
}
|
||||||
|
|
||||||
pub mod layout {
|
pub mod layout {
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue