diff --git a/src/rust-css b/src/rust-css index 79a3ddccd05..75aba2d0e4b 160000 --- a/src/rust-css +++ b/src/rust-css @@ -1 +1 @@ -Subproject commit 79a3ddccd05742980c5e27e48755bec807d4bd46 +Subproject commit 75aba2d0e4b1224ce55ba11423c78bc7eceaed6c diff --git a/src/rust-netsurfcss b/src/rust-netsurfcss index 8b76c31e0d7..62225a3af2c 160000 --- a/src/rust-netsurfcss +++ b/src/rust-netsurfcss @@ -1 +1 @@ -Subproject commit 8b76c31e0d72b50630f56e5fb560eda4186c6796 +Subproject commit 62225a3af2c4d59da0d595287570cdfd71e7a4f6 diff --git a/src/servo/css/compute.rs b/src/servo/css/compute.rs index a3262c8497b..e53fba62586 100644 --- a/src/servo/css/compute.rs +++ b/src/servo/css/compute.rs @@ -4,15 +4,15 @@ Calculate styles for Nodes based on SelectResults, resolving inherited values use dom::node::Node; use newcss::color::{Color, rgba}; -use newcss::values::{CSSValue, Specified, Inherit, Length, Px}; +use newcss::values::{CSSValue, Specified, Inherit, Length, Px, CSSBorderWidth, BdrWidthLength}; use newcss::ComputedStyle; pub trait ComputeStyles { fn compute_background_color(&self) -> Color; - fn compute_border_top_width(&self) -> Length; - fn compute_border_right_width(&self) -> Length; - fn compute_border_bottom_width(&self) -> Length; - fn compute_border_left_width(&self) -> Length; + fn compute_border_top_width(&self) -> CSSBorderWidth; + fn compute_border_right_width(&self) -> CSSBorderWidth; + fn compute_border_bottom_width(&self) -> CSSBorderWidth; + fn compute_border_left_width(&self) -> CSSBorderWidth; } impl Node: ComputeStyles { @@ -20,20 +20,20 @@ impl Node: ComputeStyles { compute(self, rgba(0, 0, 0, 0.0), |cs| cs.background_color() ) } - fn compute_border_top_width(&self) -> Length { - compute(self, Px(0.0), |cs| cs.border_top_width() ) + fn compute_border_top_width(&self) -> CSSBorderWidth { + compute(self, BdrWidthLength(Px(0.0)), |cs| cs.border_top_width() ) } - fn compute_border_right_width(&self) -> Length { - compute(self, Px(0.0), |cs| cs.border_right_width() ) + fn compute_border_right_width(&self) -> CSSBorderWidth { + compute(self, BdrWidthLength(Px(0.0)), |cs| cs.border_right_width() ) } - fn compute_border_bottom_width(&self) -> Length { - compute(self, Px(0.0), |cs| cs.border_bottom_width() ) + fn compute_border_bottom_width(&self) -> CSSBorderWidth { + compute(self, BdrWidthLength(Px(0.0)), |cs| cs.border_bottom_width() ) } - fn compute_border_left_width(&self) -> Length { - compute(self, Px(0.0), |cs| cs.border_left_width() ) + fn compute_border_left_width(&self) -> CSSBorderWidth { + compute(self, BdrWidthLength(Px(0.0)), |cs| cs.border_left_width() ) } } diff --git a/src/servo/css/select_handler.rs b/src/servo/css/select_handler.rs index 0b48e08a5df..d0f58b37c16 100644 --- a/src/servo/css/select_handler.rs +++ b/src/servo/css/select_handler.rs @@ -1,5 +1,6 @@ -use dom::node::{Node, Doctype, Comment, Element, Text}; +use dom::node::{Node, NodeData, NodeTree, Doctype, Comment, Element, Text}; use newcss::SelectHandler; +use util::tree; pub struct NodeSelectHandler { node: Node @@ -10,15 +11,39 @@ fn unnamed_node(name: &str) -> ~str { fmt!("unnamed-%s", name) } +fn node_name(data: &NodeData) -> ~str { + match *data.kind { + Doctype(*) => unnamed_node("doctype"), + Comment(*) => unnamed_node("comment"), + Element(ref data) => copy data.tag_name, + Text(*) => unnamed_node("text") + } +} + impl NodeSelectHandler: SelectHandler { fn node_name(node: &Node) -> ~str { do node.read |data| { - match *data.kind { - Doctype(*) => unnamed_node("doctype"), - Comment(*) => unnamed_node("comment"), - Element(ref data) => copy data.tag_name, - Text(*) => unnamed_node("text") - } + node_name(data) } } + + fn named_parent_node(node: &Node, name: &str) -> Option { + let parent = tree::parent(&NodeTree, node); + match parent { + Some(parent) => { + do parent.read |data| { + if name == node_name(data) { + Some(parent) + } else { + None + } + } + } + None => None + } + } + + fn parent_node(node: &Node) -> Option { + tree::parent(&NodeTree, node) + } } \ No newline at end of file diff --git a/src/servo/layout/box.rs b/src/servo/layout/box.rs index 4a5ee7c4fa0..2fba8ef8b3c 100644 --- a/src/servo/layout/box.rs +++ b/src/servo/layout/box.rs @@ -11,6 +11,7 @@ use core::rand; use css::compute::ComputeStyles; use newcss::values::{BoxSizing, Length, Px, CSSDisplay, Specified, BgColor, BgColorTransparent}; use newcss::values::{BdrColor, PosAbsolute}; +use newcss::values::{BdrWidthLength, BdrWidthMedium}; use newcss::color::{Color, rgba}; use dom::element::{ElementKind, HTMLDivElement, HTMLImageElement}; use dom::node::{Element, Node, NodeData, NodeKind, NodeTree}; @@ -441,7 +442,10 @@ impl RenderBox : RenderBoxMethods { let left_width = self.d().node.compute_border_left_width(); match (top_width, right_width, bottom_width, left_width) { - (Px(top), Px(right), Px(bottom), Px(left)) => { + (BdrWidthLength(Px(top)), + BdrWidthLength(Px(right)), + BdrWidthLength(Px(bottom)), + BdrWidthLength(Px(left))) => { let top_au = au::from_frac_px(top); let right_au = au::from_frac_px(right); let bottom_au = au::from_frac_px(bottom); @@ -462,12 +466,19 @@ impl RenderBox : RenderBoxMethods { } }; let color = rgb(0, 128, 255).to_gfx_color(); // FIXME - //list.append_item(~DisplayItem::new_Border(&bounds, border_width, color)); + list.append_item(~DisplayItem::new_Border(&bounds, border_width, color)); } else { fail ~"unimplemented border widths"; } } + (BdrWidthMedium, + BdrWidthMedium, + BdrWidthMedium, + BdrWidthMedium) => { + // FIXME: This seems to be the default for non-root nodes. For now we'll ignore it + warn!("ignoring medium border widths"); + } _ => fail ~"unimplemented border widths" }