mirror of
https://github.com/mozilla/gecko-dev.git
synced 2024-10-08 19:04:45 +00:00
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:
parent
00ec4f01e0
commit
7a618492f6
16
servo/src/servo/css/compute.rs
Normal file
16
servo/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::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));
|
||||
}
|
||||
|
@ -49,6 +49,7 @@ pub mod css {
|
||||
mod apply;
|
||||
mod matching;
|
||||
priv mod select_handler;
|
||||
pub mod compute;
|
||||
}
|
||||
|
||||
pub mod layout {
|
||||
|
Loading…
Reference in New Issue
Block a user