Begin working on background color

This commit is contained in:
Brian Anderson 2012-10-31 17:39:27 -07:00
parent 5c606a8dbb
commit 4ae8ca5d29
5 changed files with 30 additions and 6 deletions

@ -1 +1 @@
Subproject commit a52c721657cf6ea7b76ddbd4787bf8590978c365 Subproject commit 0762606995ef70980d4013185244e89cd3903f92

@ -1 +1 @@
Subproject commit 31697a75038e7aa8c5e5b5e86002c4e42dc19712 Subproject commit eda424500739f1474b6e4a7c0fbc165d5a92a51f

View file

@ -1,16 +1,29 @@
/*! /*!
Calculate styles for nodes based on SelectResults Calculate styles for Nodes based on SelectResults
*/ */
use dom::node::Node; use dom::node::Node;
use newcss::color::{Color, rgba}; use newcss::color::{Color, rgba};
use newcss::values::{CSSValue, Specified, Inherit};
use newcss::ComputedStyle;
pub trait ComputeStyles { pub trait ComputeStyles {
fn compute_background_color() -> Color; fn compute_background_color(&self) -> Color;
} }
impl Node: ComputeStyles { impl Node: ComputeStyles {
fn compute_background_color() -> Color { fn compute_background_color(&self) -> Color {
rgba(255, 0, 255, 1.0) compute(self, |cs| cs.background_color(), rgba(0, 0, 0, 0.0))
}
}
fn compute<T>(node: &Node, get: &fn(cs: ComputedStyle) -> CSSValue<T>, default: T) -> T {
let style = node.get_style();
let computed = style.computed_style();
let value = get(computed);
match move value {
Inherit => /* FIXME */ move default,
Specified(move value) => move value,
_ => fail
} }
} }

View file

@ -0,0 +1,3 @@
div {
background-color: blue;
}

View file

@ -0,0 +1,8 @@
<head>
<link rel="stylesheet" href="test_bg_color_simple.css" />
</head>
<body>
<div>
Test
</div>
</body>