diff options
author | bptato <nincsnevem662@gmail.com> | 2022-11-28 19:52:10 +0100 |
---|---|---|
committer | bptato <nincsnevem662@gmail.com> | 2022-11-28 23:00:06 +0100 |
commit | eb2e57c97eb67eec19f068e294a8f6d1375c82f5 (patch) | |
tree | 87156c515f6ee9a63f58dc080184bd3127ce6836 /src/css | |
parent | 8af10b8b74fd29fe4c9debcd5cbecfaddf53a7b5 (diff) | |
download | chawan-eb2e57c97eb67eec19f068e294a8f6d1375c82f5.tar.gz |
Add textarea
Editing is implemented using an external editor (like vi).
Diffstat (limited to 'src/css')
-rw-r--r-- | src/css/cascade.nim | 23 | ||||
-rw-r--r-- | src/css/selectorparser.nim | 2 |
2 files changed, 19 insertions, 6 deletions
diff --git a/src/css/cascade.nim b/src/css/cascade.nim index 851e6f83..273ba4cb 100644 --- a/src/css/cascade.nim +++ b/src/css/cascade.nim @@ -109,6 +109,10 @@ func calcPresentationalHints(element: Element): CSSComputedValues = map_width of TAG_BODY: map_bgcolor + of TAG_TEXTAREA: + let textarea = HTMLTextAreaElement(element) + set_cv(PROPERTY_WIDTH, length, CSSLength(unit: UNIT_CH, num: float64(textarea.cols))) + set_cv(PROPERTY_HEIGHT, length, CSSLength(unit: UNIT_EM, num: float64(textarea.rows))) else: discard proc applyDeclarations(styledNode: StyledNode, parent: CSSComputedValues, ua, user: DeclarationList, author: seq[DeclarationList]) = @@ -225,6 +229,12 @@ proc applyRules(document: Document, ua, user: CSSStylesheet, cachedTree: StyledN let styledText = styledParent.newStyledText(content) styledText.pseudo = pseudo styledParent.children.add(styledText) + of PSEUDO_TEXTAREA_TEXT: + let content = HTMLTextAreaElement(styledParent.node).textAreaString() + if content.len > 0: + let styledText = styledParent.newStyledText(content) + styledText.pseudo = pseudo + styledParent.children.add(styledText) of PSEUDO_NONE: discard else: assert child != nil @@ -299,12 +309,15 @@ proc applyRules(document: Document, ua, user: CSSStylesheet, cachedTree: StyledN stack_append styledChild, PSEUDO_AFTER - for i in countdown(elem.childNodes.high, 0): - if elem.childNodes[i].nodeType in {ELEMENT_NODE, TEXT_NODE}: - stack_append styledChild, elem.childNodes[i] + if elem.tagType != TAG_TEXTAREA: + for i in countdown(elem.childNodes.high, 0): + if elem.childNodes[i].nodeType in {ELEMENT_NODE, TEXT_NODE}: + stack_append styledChild, elem.childNodes[i] + if elem.tagType == TAG_INPUT: + stack_append styledChild, PSEUDO_INPUT_TEXT + else: + stack_append styledChild, PSEUDO_TEXTAREA_TEXT - if elem.tagType == TAG_INPUT: - stack_append styledChild, PSEUDO_INPUT_TEXT stack_append styledChild, PSEUDO_BEFORE proc applyStylesheets*(document: Document, uass, userss: CSSStylesheet, previousStyled: StyledNode): StyledNode = diff --git a/src/css/selectorparser.nim b/src/css/selectorparser.nim index f8abc7f7..97c6f029 100644 --- a/src/css/selectorparser.nim +++ b/src/css/selectorparser.nim @@ -19,7 +19,7 @@ type PseudoElem* = enum PSEUDO_NONE, PSEUDO_BEFORE, PSEUDO_AFTER, # internal - PSEUDO_INPUT_TEXT + PSEUDO_INPUT_TEXT, PSEUDO_TEXTAREA_TEXT PseudoClass* = enum PSEUDO_FIRST_CHILD, PSEUDO_LAST_CHILD, PSEUDO_ONLY_CHILD, PSEUDO_HOVER, |