diff options
author | bptato <nincsnevem662@gmail.com> | 2024-08-02 01:51:59 +0200 |
---|---|---|
committer | bptato <nincsnevem662@gmail.com> | 2024-08-02 01:53:01 +0200 |
commit | cd276934fc86c7cb6c7ebc69cf0a6c27445bad0d (patch) | |
tree | 6d22bb3d73dc19dd7c512f4590c7aa48e7e3179d /src/css | |
parent | 8f88e5f05b76dd9b16ba91c9e28f07bd1549ae93 (diff) | |
download | chawan-cd276934fc86c7cb6c7ebc69cf0a6c27445bad0d.tar.gz |
cssvalues, sheet: fix some more case sensitivity bugs
Diffstat (limited to 'src/css')
-rw-r--r-- | src/css/cssvalues.nim | 4 | ||||
-rw-r--r-- | src/css/mediaquery.nim | 15 | ||||
-rw-r--r-- | src/css/sheet.nim | 5 |
3 files changed, 6 insertions, 18 deletions
diff --git a/src/css/cssvalues.nim b/src/css/cssvalues.nim index 9bb063b3..19b50966 100644 --- a/src/css/cssvalues.nim +++ b/src/css/cssvalues.nim @@ -1091,7 +1091,7 @@ func cssLineHeight(cval: CSSComponentValue): Opt[CSSLength] = of cttNumber: return cssLength(tok.nvalue * 100, "%") of cttIdent: - if tok.value == "normal": + if tok.value.equalsIgnoreCase("normal"): return ok(CSSLengthAuto) else: return cssLength(tok, has_auto = false) @@ -1161,7 +1161,7 @@ func cssImage(cval: CSSComponentValue): Opt[CSSContent] = if isToken(cval): #TODO bg-image only let tok = getToken(cval) - if tok.tokenType == cttIdent and tok.value == "none": + if tok.tokenType == cttIdent and tok.value.equalsIgnoreCase("none"): return ok(CSSContent(t: ContentImage, s: "")) let url = cssURL(cval) if url.isSome: diff --git a/src/css/mediaquery.nim b/src/css/mediaquery.nim index 277813b4..73649e8f 100644 --- a/src/css/mediaquery.nim +++ b/src/css/mediaquery.nim @@ -79,23 +79,12 @@ func `$`*(mf: MediaFeature): string = return "hover: " & $mf.b of mftPrefersColorScheme: return "prefers-color-scheme: " & $mf.b - of mftWidth: - result &= $mf.lengthrange.s.a - result &= " <" - if mf.lengthrange.aeq: - result &= "=" - result &= " width <" - if mf.lengthrange.beq: - result &= "=" - result &= " " - result &= $mf.lengthrange.s.b - of mftHeight: + of mftWidth, mftHeight: result &= $mf.lengthrange.s.a result &= " <" if mf.lengthrange.aeq: result &= "=" - result &= " width " - result &= "<" + result &= ' ' & $mf.t & " <" if mf.lengthrange.beq: result &= "=" result &= " " diff --git a/src/css/sheet.nim b/src/css/sheet.nim index 579e7f9e..bbf5e572 100644 --- a/src/css/sheet.nim +++ b/src/css/sheet.nim @@ -5,6 +5,7 @@ import css/cssvalues import css/mediaquery import css/selectorparser import html/catom +import utils/twtstr type CSSRuleBase* = ref object of RootObj @@ -193,8 +194,7 @@ proc addRule(stylesheet: CSSStylesheet; rule: CSSQualifiedRule) = inc stylesheet.len proc addAtRule(stylesheet: CSSStylesheet; atrule: CSSAtRule) = - case atrule.name - of "media": + if atrule.name.equalsIgnoreCase("media"): if atrule.oblock == nil: # invalid at-rule return @@ -212,7 +212,6 @@ proc addAtRule(stylesheet: CSSStylesheet; atrule: CSSAtRule) = media.children.addRule(CSSQualifiedRule(rule)) stylesheet.mqList.add(media) stylesheet.len = media.children.len - else: discard #TODO proc parseStylesheet*(ibuf: string; factory: CAtomFactory): CSSStylesheet = let raw = parseStylesheet(ibuf) |