Skip to content

Commit 73002db

Browse files
committed
parse: properties: utils: hsl: Alpha can be percentage
1 parent bf5ec81 commit 73002db

File tree

1 file changed

+13
-5
lines changed

1 file changed

+13
-5
lines changed

src/parse/properties/utils.c

Lines changed: 13 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -618,19 +618,27 @@ static bool parse_hsl(
618618
consumeWhitespace(vector, ctx);
619619

620620
token = parserutils_vector_iterate(vector, ctx);
621-
if ((token == NULL) || (token->type != CSS_TOKEN_NUMBER))
621+
if ((token == NULL) ||
622+
(token->type != CSS_TOKEN_NUMBER &&
623+
token->type != CSS_TOKEN_PERCENTAGE)) {
622624
return false;
625+
}
623626

624627
alpha = css__number_from_lwc_string(token->idata, false, &consumed);
625-
if (consumed != lwc_string_length(token->idata))
626-
return false; /* failed to consume the whole string as a number */
628+
if (consumed != lwc_string_length(token->idata)) {
629+
/* failed to consume the whole string as a number */
630+
return false;
631+
}
627632

628-
alpha = FIXTOINT(FMUL(alpha, F_255));
633+
if (token->type != CSS_TOKEN_NUMBER) {
634+
alpha = FIXTOINT(FMUL(alpha, F_255));
635+
} else {
636+
alpha = FIXTOINT(FDIV(FMUL(alpha, F_255), F_100));
637+
}
629638

630639
consumeWhitespace(vector, ctx);
631640

632641
token = parserutils_vector_iterate(vector, ctx);
633-
634642
}
635643

636644
if (!tokenIsChar(token, ')'))

0 commit comments

Comments
 (0)