mirror of
https://github.com/LadybirdBrowser/ladybird.git
synced 2025-04-21 20:15:17 +00:00
LibWeb/CSS: Inline number/integer parsing
For simplicity in user code, the `parse_foo_value()` methods should parse anything that is a `<foo>`. In these cases, that means a number/integer or calculation that resolves to them. These uses in parse_css_value_for_properties() specifically only want a literal IntegerStyleValue/NumberStyleValue, as calc-parsing is done elsewhere. So, do the parsing for them locally.
This commit is contained in:
parent
9bc71ab1fe
commit
79bd942dd1
Notes:
github-actions[bot]
2024-08-21 09:52:54 +00:00
Author: https://github.com/AtkinsSJ Commit: https://github.com/LadybirdBrowser/ladybird/commit/79bd942dd12 Pull-request: https://github.com/LadybirdBrowser/ladybird/pull/1091
1 changed files with 7 additions and 7 deletions
|
@ -7389,17 +7389,17 @@ Optional<Parser::PropertyAndValue> Parser::parse_css_value_for_properties(Readon
|
|||
bool property_accepts_numeric = property_accepting_integer.has_value() || property_accepting_number.has_value();
|
||||
|
||||
if (peek_token.is(Token::Type::Number) && property_accepts_numeric) {
|
||||
if (property_accepting_integer.has_value()) {
|
||||
auto transaction = tokens.begin_transaction();
|
||||
if (auto integer = parse_integer_value(tokens); integer && property_accepts_integer(*property_accepting_integer, integer->as_integer().integer())) {
|
||||
transaction.commit();
|
||||
if (peek_token.token().number().is_integer() && property_accepting_integer.has_value()) {
|
||||
auto integer = IntegerStyleValue::create(peek_token.token().number().integer_value());
|
||||
if (property_accepts_integer(*property_accepting_integer, integer->as_integer().integer())) {
|
||||
(void)tokens.next_token(); // integer
|
||||
return PropertyAndValue { *property_accepting_integer, integer };
|
||||
}
|
||||
}
|
||||
if (property_accepting_number.has_value()) {
|
||||
auto transaction = tokens.begin_transaction();
|
||||
if (auto number = parse_number_value(tokens); number && property_accepts_number(*property_accepting_number, number->as_number().number())) {
|
||||
transaction.commit();
|
||||
auto number = NumberStyleValue::create(peek_token.token().number().value());
|
||||
if (property_accepts_number(*property_accepting_number, number->as_number().number())) {
|
||||
(void)tokens.next_token(); // number
|
||||
return PropertyAndValue { *property_accepting_number, number };
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Add table
Reference in a new issue