@@ -4,7 +4,7 @@ import pkg/[pixie, vmath]
44import ../../ bindings/ yoga
55import ../../ components/ parsers/ html/ document
66import ../../ components/ parsers/ css/ [parser, anb, types]
7- import ../../ components/ style/ [selector_engine, style_matcher]
7+ import ../../ components/ style/ [selector_engine, style_matcher, functions ]
88import ../../ components/ shared/ sugar
99import ../../ components/ ipc/ [client/ prelude, shared]
1010
1616 position* : Vec2
1717 dimensions* : Vec2
1818 fontSize* : float32
19+ color* : ColorRGBA
1920
2021 LayoutNode * = object
2122 parent* : ptr LayoutNode
@@ -91,7 +92,14 @@ proc traverse*(layout: Layout, node: var LayoutNode) =
9192 let fontSize =
9293 toPixels (& layout.stylesheet.getProperty (node.element, Property .FontSize ))
9394 # The font-size attribute
95+
96+ let color =
97+ evaluateRGBXFunction (& layout.stylesheet.getProperty (node.element, Property .Color ))
98+
99+ failCond * color
100+ # FIXME: Use a more fault-tolerant approach. Currently we just skip the entire node and its children upon this basic failure.
94101 node.processed.fontSize = fontSize
102+ node.processed.color = & color
95103 node.font.size = fontSize
96104
97105 let bounds = node.font.layoutBounds (text)
@@ -104,8 +112,36 @@ proc traverse*(layout: Layout, node: var LayoutNode) =
104112 let text = & node.element.text ()
105113 let fontSize =
106114 toPixels (& layout.stylesheet.getProperty (node.element, Property .FontSize ))
115+ let color =
116+ evaluateRGBXFunction (& layout.stylesheet.getProperty (node.element, Property .Color ))
117+
118+ failCond * color
119+ # FIXME: Use a more fault-tolerant approach. Currently we just skip the entire node and its children upon this basic failure.
120+ node.font.size = fontSize
121+ node.processed.fontSize = fontSize
122+ node.processed.color = & color
123+ let bounds = node.font.layoutBounds (text)
124+
125+ inlineElem
126+ node.processed.dimensions = bounds
127+ of TAG_A :
128+ let text =
129+ if * node.element.text:
130+ & node.element.text ()
131+ else :
132+ newString (0 )
133+
134+ let fontSize =
135+ toPixels (& layout.stylesheet.getProperty (node.element, Property .FontSize ))
136+ let color =
137+ evaluateRGBXFunction (& layout.stylesheet.getProperty (node.element, Property .Color ))
138+
139+ failCond * color
140+ # FIXME: Use a more fault-tolerant approach. Currently we just skip the entire node and its children upon this basic failure.
141+
107142 node.font.size = fontSize
108143 node.processed.fontSize = fontSize
144+ node.processed.color = & color
109145 let bounds = node.font.layoutBounds (text)
110146
111147 inlineElem
0 commit comments