about summary refs log tree commit diff stats
path: root/src/css/cascade.nim
diff options
context:
space:
mode:
authorbptato <nincsnevem662@gmail.com>2022-12-12 18:26:06 +0100
committerbptato <nincsnevem662@gmail.com>2022-12-12 18:36:17 +0100
commit77512303946a27d4f9b9ffc30f0aeb6c31f59e1c (patch)
tree5cc177ef52a3ad2c6f4e8757bbf547fb9deeb223 /src/css/cascade.nim
parent96824ecd8f66eeedcf8bd954b44ddb32c50c9256 (diff)
downloadchawan-77512303946a27d4f9b9ffc30f0aeb6c31f59e1c.tar.gz
Fix color contrast correction
Instead of just inverting the color and hoping for the best, convert it
to YUV and increase/decrease luminance based on results.
Diffstat (limited to 'src/css/cascade.nim')
-rw-r--r--src/css/cascade.nim5
1 files changed, 5 insertions, 0 deletions
diff --git a/src/css/cascade.nim b/src/css/cascade.nim
index cfb34e4e..4c782ded 100644
--- a/src/css/cascade.nim
+++ b/src/css/cascade.nim
@@ -109,6 +109,10 @@ func calcPresentationalHints(element: Element): CSSComputedValues =
     of "center", "middle": set_cv(PROPERTY_TEXT_ALIGN, textalign, TEXT_ALIGN_CHA_CENTER)
     of "left": set_cv(PROPERTY_TEXT_ALIGN, textalign, TEXT_ALIGN_CHA_LEFT)
     of "right": set_cv(PROPERTY_TEXT_ALIGN, textalign, TEXT_ALIGN_CHA_RIGHT)
+  template map_text =
+    let c = parseLegacyColor(element.attr("text"))
+    if c.isSome:
+      set_cv(PROPERTY_COLOR, color, c.get)
 
   case element.tagType
   of TAG_DIV:
@@ -132,6 +136,7 @@ func calcPresentationalHints(element: Element): CSSComputedValues =
     map_width
   of TAG_BODY:
     map_bgcolor
+    map_text
   of TAG_TEXTAREA:
     let textarea = HTMLTextAreaElement(element)
     set_cv(PROPERTY_WIDTH, length, CSSLength(unit: UNIT_CH, num: float64(textarea.cols)))