Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions src/parse/properties/utils.c
Original file line number Diff line number Diff line change
Expand Up @@ -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));
Expand Down Expand Up @@ -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));
Expand Down
1 change: 1 addition & 0 deletions test/data/parse/INDEX
Original file line number Diff line number Diff line change
Expand Up @@ -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
139 changes: 139 additions & 0 deletions test/data/parse/colours-hsl.dat
Original file line number Diff line number Diff line change
Expand Up @@ -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%) }
Expand All @@ -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%) }
Expand Down
136 changes: 136 additions & 0 deletions test/data/parse/colours-hwb.dat
Original file line number Diff line number Diff line change
@@ -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
8 changes: 8 additions & 0 deletions test/data/parse/colours.dat
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
12 changes: 8 additions & 4 deletions test/parse-auto.c
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
Loading