diff --git a/src/servo/css/compute.rs b/src/servo/css/compute.rs index e53fba62586..0afe1f89a0c 100644 --- a/src/servo/css/compute.rs +++ b/src/servo/css/compute.rs @@ -1,5 +1,8 @@ /*! -Calculate styles for Nodes based on SelectResults, resolving inherited values +Calculates computed Node styles, based on CSS SelectResults. + +These methods mostly defer to the Node's ComputedStyle object. +The only exception is that this is where inheritance is resolved. */ use dom::node::Node; @@ -17,27 +20,27 @@ pub trait ComputeStyles { impl Node: ComputeStyles { fn compute_background_color(&self) -> Color { - compute(self, rgba(0, 0, 0, 0.0), |cs| cs.background_color() ) + resolve(self, rgba(0, 0, 0, 0.0), |cs| cs.background_color() ) } fn compute_border_top_width(&self) -> CSSBorderWidth { - compute(self, BdrWidthLength(Px(0.0)), |cs| cs.border_top_width() ) + resolve(self, BdrWidthLength(Px(0.0)), |cs| cs.border_top_width() ) } fn compute_border_right_width(&self) -> CSSBorderWidth { - compute(self, BdrWidthLength(Px(0.0)), |cs| cs.border_right_width() ) + resolve(self, BdrWidthLength(Px(0.0)), |cs| cs.border_right_width() ) } fn compute_border_bottom_width(&self) -> CSSBorderWidth { - compute(self, BdrWidthLength(Px(0.0)), |cs| cs.border_bottom_width() ) + resolve(self, BdrWidthLength(Px(0.0)), |cs| cs.border_bottom_width() ) } fn compute_border_left_width(&self) -> CSSBorderWidth { - compute(self, BdrWidthLength(Px(0.0)), |cs| cs.border_left_width() ) + resolve(self, BdrWidthLength(Px(0.0)), |cs| cs.border_left_width() ) } } -fn compute(node: &Node, default: T, get: &fn(cs: ComputedStyle) -> CSSValue) -> T { +fn resolve(node: &Node, default: T, get: &fn(cs: ComputedStyle) -> CSSValue) -> T { let style = node.get_style(); let computed = style.computed_style(); let value = get(computed);