about summary refs log tree commit diff stats
path: root/src/server
diff options
context:
space:
mode:
authorbptato <nincsnevem662@gmail.com>2025-01-16 20:20:03 +0100
committerbptato <nincsnevem662@gmail.com>2025-01-16 20:20:03 +0100
commit9c03cdd883e4fafabddfa355cdaf675d56596b0c (patch)
treedf22b51e735dd5e478f8d7af804386c9dab6af36 /src/server
parent37bbe760b9b7c9c6aee8323c7766574a7ef55389 (diff)
downloadchawan-9c03cdd883e4fafabddfa355cdaf675d56596b0c.tar.gz
css: reduce StyledNode use
Eventually the tree should be collapsed into the DOM, and StyledNode
should be created on the stack.
Diffstat (limited to 'src/server')
-rw-r--r--src/server/buffer.nim17
1 files changed, 3 insertions, 14 deletions
diff --git a/src/server/buffer.nim b/src/server/buffer.nim
index b5fc6629..c80f1b07 100644
--- a/src/server/buffer.nim
+++ b/src/server/buffer.nim
@@ -345,11 +345,6 @@ proc getClickable(element: Element): Element =
       return element
   return nil
 
-proc getClickable(styledNode: StyledNode): Element =
-  if styledNode == nil:
-    return nil
-  return styledNode.element.getClickable()
-
 func canSubmitOnClick(fae: FormAssociatedElement): bool =
   if fae.form == nil:
     return false
@@ -414,18 +409,12 @@ proc getCachedImageHover(buffer: Buffer; element: Element): string =
       return $image.bitmap.cacheId & ' ' & image.bitmap.contentType
   ""
 
-func getCursorStyledNode(buffer: Buffer; cursorx, cursory: int): StyledNode =
+func getCursorElement(buffer: Buffer; cursorx, cursory: int): Element =
   let i = buffer.lines[cursory].findFormatN(cursorx) - 1
   if i >= 0:
     return buffer.lines[cursory].formats[i].node
   return nil
 
-func getCursorElement(buffer: Buffer; cursorx, cursory: int): Element =
-  let styledNode = buffer.getCursorStyledNode(cursorx, cursory)
-  if styledNode == nil:
-    return nil
-  return styledNode.element
-
 proc getCursorClickable(buffer: Buffer; cursorx, cursory: int): Element =
   let element = buffer.getCursorElement(cursorx, cursory)
   if element != nil:
@@ -690,7 +679,7 @@ proc findAnchor(box: InlineBox; anchor: Element): Offset =
       let off = child.findAnchor(anchor)
       if off.y >= 0:
         return off
-  if box.node != nil and box.node.element == anchor:
+  if box.node == anchor:
     return box.render.offset
   return offset(-1, -1)
 
@@ -703,7 +692,7 @@ proc findAnchor(box: BlockBox; anchor: Element): Offset =
     let off = child.findAnchor(anchor)
     if off.y >= 0:
       return off
-  if box.node != nil and box.node.element == anchor:
+  if box.node == anchor:
     return box.render.offset
   return offset(-1, -1)