diff --git a/src/parse/properties/utils.c b/src/parse/properties/utils.c index 42daa45..9e4ef08 100644 --- a/src/parse/properties/utils.c +++ b/src/parse/properties/utils.c @@ -710,7 +710,7 @@ static bool parse_hsl( return false; } - if (token->type != CSS_TOKEN_NUMBER) { + if (token->type == CSS_TOKEN_NUMBER) { alpha = FIXTOINT(FMUL(alpha, F_255)); } else { alpha = FIXTOINT(FDIV(FMUL(alpha, F_255), F_100)); @@ -890,7 +890,7 @@ static bool parse_hwb( return false; } - if (token->type != CSS_TOKEN_NUMBER) { + if (token->type == CSS_TOKEN_NUMBER) { alpha = FIXTOINT(FMUL(alpha, F_255)); } else { alpha = FIXTOINT(FDIV(FMUL(alpha, F_255), F_100)); diff --git a/test/data/parse/INDEX b/test/data/parse/INDEX index ced33a3..65cad10 100644 --- a/test/data/parse/INDEX +++ b/test/data/parse/INDEX @@ -7,5 +7,6 @@ selectors.dat Selectors atrules.dat @-rules colours.dat Colour values colours-hsl.dat HSL Colour values +colours-hwb.dat HWB Colour values nth.dat :nth-* expressions properties.dat Properties diff --git a/test/data/parse/colours-hsl.dat b/test/data/parse/colours-hsl.dat index 2a98ba9..b6e9223 100644 --- a/test/data/parse/colours-hsl.dat +++ b/test/data/parse/colours-hsl.dat @@ -9,6 +9,136 @@ | 0x02000018 0xffff0000 #reset +#data +* { color: hsl(0 100% 50%) } +#errors +#expected +| 1 * +| 0x02000018 0xffff0000 +#reset + +#data +* { color: hsl(0, 100%, 50%, 100%) } +#errors +#expected +| 1 * +| 0x02000018 0xffff0000 +#reset + +#data +* { color: hsl(0 100% 50% / 0.5) } +#errors +#expected +| 1 * +| 0x02000018 0x7fff0000 +#reset + +#data +* { color: hsl(0 100% 50%/0.5) } +#errors +#expected +| 1 * +| 0x02000018 0x7fff0000 +#reset + +#data +* { color: hsl(0 100% 50/0.5) } +#errors +#expected +| 1 * +| 0x02000018 0x7fff0000 +#reset + +#data +* { color: hsl(0 100% 50% / 50%) } +#errors +#expected +| 1 * +| 0x02000018 0x7fff0000 +#reset + +#data +* { color: hsla(0 100% 50% / 50%) } +#errors +#expected +| 1 * +| 0x02000018 0x7fff0000 +#reset + +#data +* { color: hsl(0 100% 50% / 1) } +#errors +#expected +| 1 * +| 0x02000018 0xffff0000 +#reset + +#data +* { color: hsl(0 100% 50%, 1) } +#errors +#expected +| 1 * +#reset + +#data +* { color: hsl(0 , 100% , 50% , 1) } +#errors +#expected +| 1 * +| 0x02000018 0xffff0000 +#reset + +#data +* { color: hsla(0 , 100% , 50% , 1) } +#errors +#expected +| 1 * +| 0x02000018 0xffff0000 +#reset + +#data +* { color: hsl(0 , 100% , 50% , 1 ,) } +#errors +#expected +| 1 * +#reset + +#data +* { color: hsl(0 , 100% , 50% ,) } +#errors +#expected +| 1 * +#reset + +#data +* { color: hsl(0,100%,50%) } +#errors +#expected +| 1 * +| 0x02000018 0xffff0000 +#reset + +#data +* { color: hsl(0, 100% 50%) } +#errors +#expected +| 1 * +#reset + +#data +* { color: hsl(0 100%, 50%) } +#errors +#expected +| 1 * +#reset + +#data +* { color: hsla(0 100%, 50%) } +#errors +#expected +| 1 * +#reset + ## yellow #data * { color: hsl(60, 100%, 50%) } @@ -18,6 +148,15 @@ | 0x02000018 0xffffff00 #reset +## yellow +#data +* { color: hsl(60deg, 100%, 50%) } +#errors +#expected +| 1 * +| 0x02000018 0xffffff00 +#reset + ## green #data * { color: hsl(120, 100%, 50%) } diff --git a/test/data/parse/colours-hwb.dat b/test/data/parse/colours-hwb.dat new file mode 100644 index 0000000..2dac90d --- /dev/null +++ b/test/data/parse/colours-hwb.dat @@ -0,0 +1,136 @@ +## simple hwb color values + +## red +#data +* { color: hwb(0, 100%, 50%) } +#errors +#expected +| 1 * +#reset + +#data +* { color: hwba(0 100% 50% / 50%) } +#errors +#expected +| 1 * +#reset + +#data +* { color: hwb(0 100% 50%) } +#errors +#expected +| 1 * +| 0x02000018 0xffaaaaaa +#reset + +#data +* { color: hwb(0, 100%, 50%, 100%) } +#errors +#expected +| 1 * +#reset + +#data +* { color: hwb(0 100%, 50%, 100%) } +#errors +#expected +| 1 * +#reset + +#data +* { color: hwb(0 100%, 50%) } +#errors +#expected +| 1 * +#reset + +#data +* { color: hwb(0 100% 50% 100%) } +#errors +#expected +| 1 * +#reset + +#data +* { color: hwb(0 100% 50% / 0.5) } +#errors +#expected +| 1 * +| 0x02000018 0x7faaaaaa +#reset + +#data +* { color: hwb(0 100% 50% / 50%) } +#errors +#expected +| 1 * +| 0x02000018 0x7faaaaaa +#reset + +#data +* { color: hwb(0 100% 50% / 1) } +#errors +#expected +| 1 * +| 0x02000018 0xffaaaaaa +#reset + +#data +* { color: hwb(0 100% 50%, 1) } +#errors +#expected +| 1 * +#reset + +#data +* { color: hwb(0 , 100% , 50% , 1) } +#errors +#expected +| 1 * +#reset + +#data +* { color: hwb(0 , 100% , 50% , 1 ,) } +#errors +#expected +| 1 * +#reset + +#data +* { color: hwb(0 , 100% , 50% ,) } +#errors +#expected +| 1 * +#reset + +#data +* { color: hwb(267 19% 60%) } +#errors +#expected +| 1 * +| 0x02000018 0xff483066 +#reset + +#data +* { color: hwb(267 19% 60% / 0.5) } +#errors +#expected +| 1 * +| 0x02000018 0x7f483066 +#reset + +#data +* { color: hwb(267 19% 60% / 50%) } +#errors +#expected +| 1 * +| 0x02000018 0x7f483066 +#reset + +#data +* { color: hwb(267 19% 60%/50%) } +#errors +#expected +| 1 * +| 0x02000018 0x7f483066 +#reset diff --git a/test/data/parse/colours.dat b/test/data/parse/colours.dat index 312845e..15dae8b 100644 --- a/test/data/parse/colours.dat +++ b/test/data/parse/colours.dat @@ -80,6 +80,14 @@ | 0x02000018 0x7f0000ff #reset +#data +* { color: rgb(none 0% 255/0.5) } +#errors +#expected +| 1 * +| 0x02000018 0x7f0000ff +#reset + #data * { color: rgb(none 0% 255 none) } #errors diff --git a/test/parse-auto.c b/test/parse-auto.c index 5f926e3..18fae0e 100644 --- a/test/parse-auto.c +++ b/test/parse-auto.c @@ -553,10 +553,14 @@ bool validate_rule_selector(css_rule_selector *s, exp_entry *e) printf("FAIL Bytecode differs\n" " Bytecode differs at %u\n ", (int) i); - while (i < e->bcused) { - printf("%.2x ", - ((uint8_t *) s->style->bytecode)[i]); - i++; + for (unsigned a = 0; a < e->bcused; a++) { + if (a == i) { + printf("[%.2x] ", + ((uint8_t *) s->style->bytecode)[a]); + } else { + printf("%.2x ", + ((uint8_t *) s->style->bytecode)[a]); + } } printf("\n"); return true;