diff options
author | bptato <nincsnevem662@gmail.com> | 2021-12-29 21:12:28 +0100 |
---|---|---|
committer | bptato <nincsnevem662@gmail.com> | 2021-12-29 21:12:28 +0100 |
commit | 7bea2f7026ed69737abdb09ccc73ff920d75c525 (patch) | |
tree | d868356b54d89fd0532d5d9266f62456c1991435 /src | |
parent | f5ef866c455d0f2c61c7796e5b777ad3b208cd5f (diff) | |
download | chawan-7bea2f7026ed69737abdb09ccc73ff920d75c525.tar.gz |
Refactor
Diffstat (limited to 'src')
-rw-r--r-- | src/css/values.nim | 16 | ||||
-rw-r--r-- | src/html/dom.nim | 2 | ||||
-rw-r--r-- | src/html/tags.nim | 4 |
3 files changed, 11 insertions, 11 deletions
diff --git a/src/css/values.nim b/src/css/values.nim index 0d6f2ae6..6992b9d2 100644 --- a/src/css/values.nim +++ b/src/css/values.nim @@ -103,9 +103,9 @@ type liststyletype*: CSSListStyleType of VALUE_NONE: discard - CSSSpecifiedValues* = ref array[low(CSSPropertyType)..high(CSSPropertyType), CSSSpecifiedValue] + CSSSpecifiedValues* = ref array[CSSPropertyType, CSSSpecifiedValue] - CSSValues* = array[low(PseudoElem)..high(PseudoElem), CSSSpecifiedValues] + CSSValues* = array[PseudoElem, CSSSpecifiedValues] CSSValueError* = object of ValueError @@ -166,8 +166,8 @@ const InheritedProperties = { PROPERTY_LIST_STYLE_TYPE } -func getPropInheritedArray(): array[low(CSSPropertyType)..high(CSSPropertyType), bool] = - for prop in low(CSSPropertyType)..high(CSSPropertyType): +func getPropInheritedArray(): array[CSSPropertyType, bool] = + for prop in CSSPropertyType: if prop in InheritedProperties: result[prop] = true else: @@ -662,7 +662,7 @@ func calcInitial(t: CSSPropertyType): CSSSpecifiedValue = nv = CSSSpecifiedValue(t: t, v: v) return nv -func getInitialTable(): array[low(CSSPropertyType)..high(CSSPropertyType), CSSSpecifiedValue] = +func getInitialTable(): array[CSSPropertyType, CSSSpecifiedValue] = for i in low(result)..high(result): result[i] = calcInitial(i) @@ -712,7 +712,7 @@ proc applyValue*(vals, parent: CSSSpecifiedValues, d: CSSDeclaration) = of PROPERTY_ALL: let global = cssGlobal(d) if global != VALUE_NOGLOBAL: - for t in low(CSSPropertyType)..high(CSSPropertyType): + for t in CSSPropertyType: vals.applyValue(parent, t, nil, global) of PROPERTY_MARGIN: let left = CSSSpecifiedValue(t: PROPERTY_MARGIN_LEFT, v: VALUE_LENGTH, length: val.length) @@ -731,7 +731,7 @@ proc applyValue*(vals, parent: CSSSpecifiedValues, d: CSSDeclaration) = func inheritProperties*(parent: CSSSpecifiedValues): CSSSpecifiedValues = new(result) - for prop in low(CSSPropertyType)..high(CSSPropertyType): + for prop in CSSPropertyType: if inherited(prop) and parent[prop] != nil: result[prop] = parent[prop] else: @@ -739,5 +739,5 @@ func inheritProperties*(parent: CSSSpecifiedValues): CSSSpecifiedValues = func rootProperties*(): CSSSpecifiedValues = new(result) - for prop in low(CSSPropertyType)..high(CSSPropertyType): + for prop in CSSPropertyType: result[prop] = getDefault(prop) diff --git a/src/html/dom.nim b/src/html/dom.nim index 064682e7..49618a58 100644 --- a/src/html/dom.nim +++ b/src/html/dom.nim @@ -35,7 +35,7 @@ type Document* = ref DocumentObj DocumentObj = object of NodeObj location*: Uri - type_elements*: array[low(TagType)..high(TagType), seq[Element]] + type_elements*: array[TagType, seq[Element]] id_elements*: Table[string, seq[Element]] class_elements*: Table[string, seq[Element]] all_elements*: seq[Element] diff --git a/src/html/tags.nim b/src/html/tags.nim index 4ffff21b..9e356444 100644 --- a/src/html/tags.nim +++ b/src/html/tags.nim @@ -45,13 +45,13 @@ type TAG_DIR, TAG_FONT, TAG_FRAME, TAG_NOFRAMES, TAG_FRAMESET, TAG_STRIKE, TAG_TT func getTagTypeMap(): Table[string, TagType] = - for i in low(TagType) .. high(TagType): + for i in TagType: let enumname = $TagType(i) let tagname = enumname.split('_')[1..^1].join("_").tolower() result[tagname] = TagType(i) func getInputTypeMap(): Table[string, InputType] = - for i in low(InputType) .. high(InputType): + for i in InputType: let enumname = $InputType(i) let tagname = enumname.split('_')[1..^1].join("_").tolower() result[tagname] = InputType(i) |