about summary refs log tree commit diff stats
diff options
context:
space:
mode:
authorbptato <nincsnevem662@gmail.com>2023-06-18 15:44:23 +0200
committerbptato <nincsnevem662@gmail.com>2023-06-18 15:44:23 +0200
commite372bdaa0344b23c91aefa4da44c578fbf8f49e2 (patch)
tree8a19d778af0128005cb2de7b275109e1fbcd8806
parent8157678366345f9040fe146f354e743d41156867 (diff)
downloadchawan-e372bdaa0344b23c91aefa4da44c578fbf8f49e2.tar.gz
input size as presentational hint
-rw-r--r--src/css/cascade.nim8
-rw-r--r--src/html/tags.nim4
2 files changed, 12 insertions, 0 deletions
diff --git a/src/css/cascade.nim b/src/css/cascade.nim
index c4bdc0c0..60043089 100644
--- a/src/css/cascade.nim
+++ b/src/css/cascade.nim
@@ -109,6 +109,10 @@ func calcPresentationalHints(element: Element): CSSComputedValues =
     let c = parseLegacyColor(element.attr("bgcolor"))
     if c.isSome:
       set_cv "background-color", c.get
+  template map_size =
+    let s = element.attrul("size")
+    if s.isSome:
+      set_cv "width", CSSLength(num: float64(s.get), unit: UNIT_CH)
   template map_valign =
     case element.attr("valign").toLowerAscii()
     of "top": set_cv "vertical-align", CSSVerticalAlign(keyword: VERTICAL_ALIGN_TOP)
@@ -187,6 +191,10 @@ func calcPresentationalHints(element: Element): CSSComputedValues =
     set_cv "height", CSSLength(unit: UNIT_EM, num: float64(rows))
   of TAG_FONT:
     map_color
+  of TAG_INPUT:
+    let input = HTMLInputElement(element)
+    if input.inputType in InputTypeWithSize:
+      map_size
   else: discard
  
 proc applyDeclarations(styledNode: StyledNode, parent: CSSComputedValues, ua, user: DeclarationList, author: seq[DeclarationList]) =
diff --git a/src/html/tags.nim b/src/html/tags.nim
index c85fe2f7..9b60ec1f 100644
--- a/src/html/tags.nim
+++ b/src/html/tags.nim
@@ -151,6 +151,10 @@ const CharacterDataNodes* = {
   TEXT_NODE, CDATA_SECTION_NODE, PROCESSING_INSTRUCTION_NODE, COMMENT_NODE
 }
 
+const InputTypeWithSize* = {
+  INPUT_SEARCH, INPUT_TEXT, INPUT_EMAIL, INPUT_PASSWORD, INPUT_URL, INPUT_TEL
+}
+
 #https://html.spec.whatwg.org/multipage/parsing.html#the-stack-of-open-elements
 #NOTE MathML not implemented
 #TODO SVG foreignObject, SVG desc, SVG title