servo: Expose display, position, float, width, height CSS properties
authorBrian Anderson <banderson@mozilla.com>
Sun, 04 Nov 2012 17:13:32 -0800
changeset 333205 b55628397c506eba3ba2c261dc0f49a3de1051de
parent 333204 d26663535d49b2f1f9eb754af785473eadef53f9
child 333206 21ea69c5e7374e0edc9807fdc0059a59b04b4043
push id31307
push usergszorc@mozilla.com
push dateSat, 04 Feb 2017 00:59:06 +0000
treeherdermozilla-central@94079d43835f [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
servo: Expose display, position, float, width, height CSS properties Source-Repo: https://github.com/servo/servo Source-Revision: 853f0474eaf13890f76832640d19962a98dbcb2f
servo/src/servo/css/node_style.rs
--- a/servo/src/servo/css/node_style.rs
+++ b/servo/src/servo/css/node_style.rs
@@ -6,16 +6,21 @@ The only exception is that this is where
 */
 
 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::values::{CSSDisplay, CSSDisplayBlock};
+use newcss::values::{CSSPosition, CSSPositionRelative};
+use newcss::values::{CSSFloat, CSSFloatNone};
+use newcss::values::{CSSWidth, CSSWidthLength};
+use newcss::values::{CSSHeight, CSSHeightLength};
 use newcss::computed::ComputedStyle;
 
 /// Node mixin providing `style` method that returns a `NodeStyle`
 trait StyledNode {
     fn style(&self) -> NodeStyle/&self;
 }
 
 impl Node: StyledNode {
@@ -32,19 +37,17 @@ pub struct NodeStyle {
 impl NodeStyle {
 
     static fn new(node: &r/Node) -> NodeStyle/&r {
         NodeStyle {
             node: node
         }
     }
 
-    fn background_color(&self) -> Color {
-        resolve(self, rgba(0, 0, 0, 0.0), |cs| cs.background_color() )
-    }
+    // CSS 2.1, Section 8 - Box model
 
     fn margin_top(&self) -> CSSMargin {
         resolve(self, CSSMarginLength(Px(0.0)), |cs| cs.margin_top() )
     }
 
     fn margin_right(&self) -> CSSMargin {
         resolve(self, CSSMarginLength(Px(0.0)), |cs| cs.margin_right() )
     }
@@ -84,16 +87,61 @@ impl NodeStyle {
     fn border_bottom_color(&self) -> Color {
         resolve(self, rgba(255, 255, 255, 0.0), |cs| cs.border_bottom_color() )
     }
 
     fn border_left_color(&self) -> Color {
         resolve(self, rgba(255, 255, 255, 0.0), |cs| cs.border_left_color() )
     }
 
+    // CSS 2.1, Section 9 - Visual formatting model
+
+    fn display(&self) -> CSSDisplay {
+        // FIXME: Shouldn't be passing false here
+        resolve(self, CSSDisplayBlock, |cs| cs.display(false) )
+    }
+
+    fn position(&self) -> CSSPosition {
+        resolve(self, CSSPositionRelative, |cs| cs.position() )
+    }
+
+    fn float(&self) -> CSSFloat {
+        resolve(self, CSSFloatNone, |cs| cs.float() )
+    }
+
+    // CSS 2.1, Section 10 - Visual formatting model details
+
+    fn width(&self) -> CSSWidth {
+        resolve(self, CSSWidthLength(Px(0.0)), |cs| cs.width() )
+    }
+
+    fn height(&self) -> CSSHeight {
+        resolve(self, CSSHeightLength(Px(0.0)), |cs| cs.height() )
+    }
+
+    // CSS 2.1, Section 11 - Visual effects
+
+    // CSS 2.1, Section 12 - Generated content, automatic numbering, and lists
+
+    // CSS 2.1, Section 13 - Paged media
+
+    // CSS 2.1, Section 14 - Colors and Backgrounds
+
+    fn background_color(&self) -> Color {
+        resolve(self, rgba(0, 0, 0, 0.0), |cs| cs.background_color() )
+    }
+
+    // CSS 2.1, Section 15 - Fonts
+
+    // CSS 2.1, Section 16 - Text
+
+    // CSS 2.1, Section 17 - Tables
+
+    // CSS 2.1, Section 18 - User interface
+
 }
 
 fn resolve<T>(node_style: &NodeStyle, default: T, get: &fn(cs: ComputedStyle) -> CSSValue<T>) -> T {
     let node = node_style.node;
     let select_res = node.get_css_select_results();
     let computed = select_res.computed_style();
     let value = get(computed);
     match move value {