about summary refs log tree commit diff stats
path: root/src/css/values.nim
diff options
context:
space:
mode:
authorbptato <nincsnevem662@gmail.com>2021-12-13 11:52:13 +0100
committerbptato <nincsnevem662@gmail.com>2021-12-13 11:59:54 +0100
commite1194507b4f6240cb15c1783240f8a21d359bc16 (patch)
tree0076a000e8a00cb3605ef8b275bdcc66e9768d51 /src/css/values.nim
parente46f0a4cb9b6a843e900dbb3abd5ce9684f47016 (diff)
downloadchawan-e1194507b4f6240cb15c1783240f8a21d359bc16.tar.gz
Support ::before, ::after pseudo elements
Diffstat (limited to 'src/css/values.nim')
-rw-r--r--src/css/values.nim13
1 files changed, 8 insertions, 5 deletions
diff --git a/src/css/values.nim b/src/css/values.nim
index b3a5d0d4..e68d7d15 100644
--- a/src/css/values.nim
+++ b/src/css/values.nim
@@ -41,7 +41,7 @@ type
       wordbreak*: CSSWordBreak
     of VALUE_NONE: discard
 
-  CSSComputedValues* = array[low(CSSPropertyType)..high(CSSPropertyType), CSSComputedValue]
+  CSSComputedValues* = ref array[low(CSSPropertyType)..high(CSSPropertyType), CSSComputedValue]
 
   CSSSpecifiedValue* = object of CSSComputedValue
     globalValue: CSSGlobalValueType
@@ -605,13 +605,16 @@ func getComputedValue*(prop: CSSSpecifiedValue, current: CSSComputedValues): CSS
 func getComputedValue*(d: CSSDeclaration, current: CSSComputedValues): CSSComputedValue =
   return getComputedValue(getSpecifiedValue(d), current)
 
+proc rootProperties*(vals: var CSSComputedValues) =
+  new(vals)
+  for prop in low(CSSPropertyType)..high(CSSPropertyType):
+    vals[prop] = getDefault(prop)
+
 proc inheritProperties*(vals: var CSSComputedValues, parent: CSSComputedValues) =
+  if vals == nil:
+    new(vals)
   for prop in low(CSSPropertyType)..high(CSSPropertyType):
     if vals[prop] == nil:
       vals[prop] = getDefault(prop)
     if inherited(prop) and parent[prop] != nil and vals[prop] == getDefault(prop):
       vals[prop] = parent[prop]
-
-proc rootProperties*(vals: var CSSComputedValues) =
-  for prop in low(CSSPropertyType)..high(CSSPropertyType):
-    vals[prop] = getDefault(prop)