about summary refs log tree commit diff stats
path: root/src/html
diff options
context:
space:
mode:
Diffstat (limited to 'src/html')
-rw-r--r--src/html/dom.nim21
1 files changed, 12 insertions, 9 deletions
diff --git a/src/html/dom.nim b/src/html/dom.nim
index 2279725f..c7d3a650 100644
--- a/src/html/dom.nim
+++ b/src/html/dom.nim
@@ -468,10 +468,12 @@ proc applyRules*(document: Document, rules: CSSStylesheet): seq[tuple[e:Element,
       let decls = parseCSSListOfDeclarations(oblock.value)
       for item in decls:
         if item of CSSDeclaration:
-          if ((CSSDeclaration)item).important:
-            result.add((elem, CSSDeclaration(item)))
+          let decl = CSSDeclaration(item)
+          if decl.important:
+            result.add((elem, decl))
           else:
-            elem.style.applyProperty(CSSDeclaration(item))
+            elem.style.applyProperty(decl)
+            elem.cssvalues.add(getComputedValue(decl))
 
     for child in elem.children:
       stack.add(child)
@@ -492,12 +494,13 @@ proc generateBox*(elem: Element, x: int, y: int, w: int, h: int) =
     if child.nodeType == ELEMENT_NODE:
       let elem = Element(child)
       elem.generateBox(rx, ry, w, h)
-      box.innerEdge.x2 += elem.box.size().w
-      box.innerEdge.y2 += elem.box.size().h
-      rx = x
-      lx = x
-      ry += elem.box.size().h
-      box.children.add(elem.box)
+      if elem.box != nil:
+        box.innerEdge.x2 += elem.box.size().w
+        box.innerEdge.y2 += elem.box.size().h
+        rx = x
+        lx = x
+        ry += elem.box.size().h
+        box.children.add(elem.box)
     elif child.nodeType == TEXT_NODE:
       let text = Text(child)
       let runes = text.data.toRunes()