aboutsummaryrefslogtreecommitdiffstats
path: root/src/html
diff options
context:
space:
mode:
authorbptato <nincsnevem662@gmail.com>2021-08-08 21:01:47 +0200
committerbptato <nincsnevem662@gmail.com>2021-08-08 21:01:47 +0200
commitd7cb6d7d610df886d028ca6d6aecf3d9a3ba54ff (patch)
tree5eb75d8b95ed9e6eab1e7f3d72b8afd1adc0e283 /src/html
parentfa4560f63e38886b2b7541642b9aa1656dc40508 (diff)
downloadchawan-d7cb6d7d610df886d028ca6d6aecf3d9a3ba54ff.tar.gz
Implement CSS display none in box renderer etc.
Other changes being bugfixes and a temporary implementation of "view source"
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()