mirror of
https://github.com/servo/servo.git
synced 2025-08-03 12:40:06 +01:00
Begin working on background color
This commit is contained in:
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
|
|
@ -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
|
||||||
}
|
}
|
||||||
}
|
}
|
3
src/test/test_bg_color_simple.css
Normal file
3
src/test/test_bg_color_simple.css
Normal file
|
@ -0,0 +1,3 @@
|
||||||
|
div {
|
||||||
|
background-color: blue;
|
||||||
|
}
|
8
src/test/test_bg_color_simple.html
Normal file
8
src/test/test_bg_color_simple.html
Normal file
|
@ -0,0 +1,8 @@
|
||||||
|
<head>
|
||||||
|
<link rel="stylesheet" href="test_bg_color_simple.css" />
|
||||||
|
</head>
|
||||||
|
<body>
|
||||||
|
<div>
|
||||||
|
Test
|
||||||
|
</div>
|
||||||
|
</body>
|
Loading…
Add table
Add a link
Reference in a new issue