Skip to content

Commit bc814d4

Browse files
committed
parse: properties: utils: hsl: Alpha can be percentage
1 parent 1911bbe commit bc814d4

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
@@ -617,19 +617,27 @@ static bool parse_hsl(
617617
consumeWhitespace(vector, ctx);
618618

619619
token = parserutils_vector_iterate(vector, ctx);
620-
if ((token == NULL) || (token->type != CSS_TOKEN_NUMBER))
620+
if ((token == NULL) ||
621+
(token->type != CSS_TOKEN_NUMBER &&
622+
token->type != CSS_TOKEN_PERCENTAGE)) {
621623
return false;
624+
}
622625

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

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

629638
consumeWhitespace(vector, ctx);
630639

631640
token = parserutils_vector_iterate(vector, ctx);
632-
633641
}
634642

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

0 commit comments

Comments
 (0)