diff options
author | bptato <nincsnevem662@gmail.com> | 2024-02-08 00:38:30 +0100 |
---|---|---|
committer | bptato <nincsnevem662@gmail.com> | 2024-02-08 00:38:30 +0100 |
commit | 6faf5cff21f8c1d382ffa605b7aa56be30ff54db (patch) | |
tree | 12a4fccdc7141490a5eece9ae313a2666c05b7b7 /src/server | |
parent | eda44e258b719a4d1e50272e1c447fcfcc1d219f (diff) | |
download | chawan-6faf5cff21f8c1d382ffa605b7aa56be30ff54db.tar.gz |
dom: reduce tagType use
tagType is now a function call, but usually it's enough to just test for the object type.
Diffstat (limited to 'src/server')
-rw-r--r-- | src/server/buffer.nim | 15 |
1 files changed, 7 insertions, 8 deletions
diff --git a/src/server/buffer.nim b/src/server/buffer.nim index b3b7f4a6..919604c7 100644 --- a/src/server/buffer.nim +++ b/src/server/buffer.nim @@ -310,7 +310,7 @@ func isClickable(styledNode: StyledNode): bool = if styledNode.computed{"visibility"} != VISIBILITY_VISIBLE: return false let element = Element(styledNode.node) - if element.tagType == TAG_A: + if element of HTMLAnchorElement: return HTMLAnchorElement(element).href != "" return element.tagType in ClickableElements @@ -328,12 +328,11 @@ func canSubmitOnClick(fae: FormAssociatedElement): bool = return false if fae.form.canSubmitImplicitly(): return true - if fae.tagType == TAG_BUTTON: - if HTMLButtonElement(fae).ctype == BUTTON_SUBMIT: - return true - if fae.tagType == TAG_INPUT: - if HTMLInputElement(fae).inputType in {INPUT_SUBMIT, INPUT_BUTTON}: - return true + if fae of HTMLButtonElement and HTMLButtonElement(fae).ctype == BUTTON_SUBMIT: + return true + if fae of HTMLInputElement and + HTMLInputElement(fae).inputType in {INPUT_SUBMIT, INPUT_BUTTON}: + return true return false proc getClickHover(styledNode: StyledNode): string = @@ -1668,7 +1667,7 @@ proc click*(buffer: Buffer, cursorx, cursory: int): ClickResult {.proxy.} = proc select*(buffer: Buffer, selected: seq[int]): ClickResult {.proxy.} = if buffer.document.focus != nil and - buffer.document.focus.tagType == TAG_SELECT: + buffer.document.focus of HTMLSelectElement: let select = HTMLSelectElement(buffer.document.focus) var i = 0 var j = 0 |