diff options
author | bptato <nincsnevem662@gmail.com> | 2021-12-14 23:10:22 +0100 |
---|---|---|
committer | bptato <nincsnevem662@gmail.com> | 2021-12-14 23:10:22 +0100 |
commit | 7707d87c9a35a5915e59cfcbd21cd7c33f575a07 (patch) | |
tree | 97fc83ff66c673aeea2115761e4b811084547ea9 /src | |
parent | 148d6ce5154c2e8c6126509f39ae0cd2f019a0c0 (diff) | |
download | chawan-7707d87c9a35a5915e59cfcbd21cd7c33f575a07.tar.gz |
DL support and BR fixes
Diffstat (limited to 'src')
-rw-r--r-- | src/css/style.nim | 1 | ||||
-rw-r--r-- | src/layout/engine.nim | 21 |
2 files changed, 10 insertions, 12 deletions
diff --git a/src/css/style.nim b/src/css/style.nim index e5b8414d..1b73fe71 100644 --- a/src/css/style.nim +++ b/src/css/style.nim @@ -41,6 +41,7 @@ func pseudoSelectorMatches(elem: Element, sel: Selector): bool = case sel.pseudo of "first-child": return elem.parentNode.firstElementChild == elem of "last-child": return elem.parentNode.lastElementChild == elem + of "only-child": return elem.parentNode.firstElementChild == elem and elem.parentNode.lastElementChild == elem of "hover": return elem.hover of "root": return elem == elem.ownerDocument.root else: return false diff --git a/src/layout/engine.nim b/src/layout/engine.nim index 2e84003d..646b5824 100644 --- a/src/layout/engine.nim +++ b/src/layout/engine.nim @@ -47,7 +47,7 @@ func newBlockBox(state: var LayoutState, parent: CSSBox, vals: CSSComputedValues parent.flushLines() let mtop = vals[PROPERTY_MARGIN_TOP].length.cells_h(state, parent.bcontext.width) - if mtop > parent.bcontext.margin_done: + if mtop > parent.bcontext.margin_done or mtop < 0: let diff = mtop - parent.bcontext.margin_done parent.icontext.fromy += diff parent.bcontext.margin_done += diff @@ -308,15 +308,6 @@ func isBlock(node: Node): bool = return elem.cssvalues[PROPERTY_DISPLAY].display == DISPLAY_BLOCK or elem.cssvalues[PROPERTY_DISPLAY].display == DISPLAY_LIST_ITEM -func isInline(node: Node): bool = - if node.nodeType == TEXT_NODE: - return true - if node.nodeType == ELEMENT_NODE: - let elem = Element(node) - return elem.cssvalues[PROPERTY_DISPLAY].display == DISPLAY_INLINE or - elem.cssvalues[PROPERTY_DISPLAY].display == DISPLAY_INLINE_BLOCK - return false - proc processComputedValueBox(state: var LayoutState, parent: CSSBox, values: CSSComputedValues): CSSBox = case values[PROPERTY_DISPLAY].display of DISPLAY_BLOCK: @@ -332,16 +323,22 @@ proc processComputedValueBox(state: var LayoutState, parent: CSSBox, values: CSS else: return nil -proc processElemBox(state: var LayoutState, parent: CSSBox, elem: Element): CSSBox = - if elem.tagType == TAG_BR: +proc processBr(state: var LayoutState, parent: CSSBox, vals: CSSComputedValues) = + if vals[PROPERTY_DISPLAY].display == DISPLAY_INLINE: if parent.icontext.conty: inc parent.height inc parent.icontext.fromy parent.icontext.conty = false else: inc parent.icontext.fromy + parent.icontext.whitespace = true + parent.icontext.ws_initial = true parent.icontext.fromx = parent.x +proc processElemBox(state: var LayoutState, parent: CSSBox, elem: Element): CSSBox = + if elem.tagType == TAG_BR: + state.processBr(parent, elem.cssvalues) + result = state.processComputedValueBox(parent, elem.cssvalues) if result != nil: result.node = elem |