From 735ce3ba5adfa0edb36a38706793a31b06c62d06 Mon Sep 17 00:00:00 2001 From: Brian Anderson Date: Sun, 4 Nov 2012 02:41:57 -0800 Subject: [PATCH] Add margin style property --- src/rust-css | 2 +- src/rust-netsurfcss | 2 +- src/servo/css/compute.rs | 21 +++++++++++++++++++++ 3 files changed, 23 insertions(+), 2 deletions(-) diff --git a/src/rust-css b/src/rust-css index 41d232fe563..99082086717 160000 --- a/src/rust-css +++ b/src/rust-css @@ -1 +1 @@ -Subproject commit 41d232fe56314d0406a3d846b70182405811865b +Subproject commit 990820867176bb2fa4d92ee8aa385a8f1e1525af diff --git a/src/rust-netsurfcss b/src/rust-netsurfcss index 2865a928229..91c4b73e990 160000 --- a/src/rust-netsurfcss +++ b/src/rust-netsurfcss @@ -1 +1 @@ -Subproject commit 2865a9282299ee21f70e2ebf409e6804767db160 +Subproject commit 91c4b73e990971de5c9232a889787a7c5859eedd diff --git a/src/servo/css/compute.rs b/src/servo/css/compute.rs index 83f2ccc42d3..41d0441f1fb 100644 --- a/src/servo/css/compute.rs +++ b/src/servo/css/compute.rs @@ -9,11 +9,16 @@ use dom::node::Node; use newcss::color::{Color, rgba}; use newcss::units::{Length, Px}; use newcss::values::{CSSValue, Specified, Inherit}; +use newcss::values::{CSSMargin, CSSMarginLength}; use newcss::values::{CSSBorderWidth, CSSBorderWidthLength}; use newcss::computed::ComputedStyle; pub trait ComputeStyles { fn compute_background_color(&self) -> Color; + fn compute_margin_top(&self) -> CSSMargin; + fn compute_margin_right(&self) -> CSSMargin; + fn compute_margin_bottom(&self) -> CSSMargin; + fn compute_margin_left(&self) -> CSSMargin; fn compute_border_top_width(&self) -> CSSBorderWidth; fn compute_border_right_width(&self) -> CSSBorderWidth; fn compute_border_bottom_width(&self) -> CSSBorderWidth; @@ -29,6 +34,22 @@ impl Node: ComputeStyles { resolve(self, rgba(0, 0, 0, 0.0), |cs| cs.background_color() ) } + fn compute_margin_top(&self) -> CSSMargin { + resolve(self, CSSMarginLength(Px(0.0)), |cs| cs.margin_top() ) + } + + fn compute_margin_right(&self) -> CSSMargin { + resolve(self, CSSMarginLength(Px(0.0)), |cs| cs.margin_right() ) + } + + fn compute_margin_bottom(&self) -> CSSMargin { + resolve(self, CSSMarginLength(Px(0.0)), |cs| cs.margin_bottom() ) + } + + fn compute_margin_left(&self) -> CSSMargin { + resolve(self, CSSMarginLength(Px(0.0)), |cs| cs.margin_left() ) + } + fn compute_border_top_width(&self) -> CSSBorderWidth { resolve(self, CSSBorderWidthLength(Px(0.0)), |cs| cs.border_top_width() ) }