mirror of
https://github.com/RGBCube/serenity
synced 2025-07-27 04:47:35 +00:00
LibWeb: Distinguish between integer and float in NumericStyleValue
We have this information when parsing, and some properties specifically only allow integers, so it makes sense to keep that around.
This commit is contained in:
parent
450b782c18
commit
78e57096e2
7 changed files with 55 additions and 30 deletions
|
@ -2060,11 +2060,11 @@ RefPtr<StyleValue> Parser::parse_numeric_value(ParsingContext const&, StyleCompo
|
|||
if (component_value.is(Token::Type::Number)) {
|
||||
auto number = component_value.token();
|
||||
if (number.m_number_type == Token::NumberType::Integer) {
|
||||
return NumericStyleValue::create(number.to_integer());
|
||||
return NumericStyleValue::create_integer(number.to_integer());
|
||||
} else {
|
||||
auto float_value = try_parse_float(number.m_value.string_view());
|
||||
if (float_value.has_value())
|
||||
return NumericStyleValue::create(float_value.value());
|
||||
return NumericStyleValue::create_float(float_value.value());
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -2626,11 +2626,11 @@ RefPtr<StyleValue> Parser::parse_flex_value(ParsingContext const& context, Vecto
|
|||
|
||||
switch (value->to_identifier()) {
|
||||
case ValueID::Auto: {
|
||||
auto one = NumericStyleValue::create(1);
|
||||
auto one = NumericStyleValue::create_integer(1);
|
||||
return FlexStyleValue::create(one, one, IdentifierStyleValue::create(ValueID::Auto));
|
||||
}
|
||||
case ValueID::None: {
|
||||
auto zero = NumericStyleValue::create(0);
|
||||
auto zero = NumericStyleValue::create_integer(0);
|
||||
return FlexStyleValue::create(zero, zero, IdentifierStyleValue::create(ValueID::Auto));
|
||||
}
|
||||
default:
|
||||
|
|
|
@ -105,7 +105,7 @@ public:
|
|||
VERIFY(m_type == Type::Number);
|
||||
return m_value.string_view();
|
||||
}
|
||||
int to_integer() const
|
||||
i64 to_integer() const
|
||||
{
|
||||
VERIFY(m_type == Type::Number && m_number_type == NumberType::Integer);
|
||||
return number_string_value().to_int().value();
|
||||
|
@ -122,7 +122,7 @@ public:
|
|||
VERIFY(m_type == Type::Dimension);
|
||||
return m_value.string_view();
|
||||
}
|
||||
int dimension_value_int() const { return dimension_value().to_int().value(); }
|
||||
i64 dimension_value_int() const { return dimension_value().to_int().value(); }
|
||||
|
||||
NumberType number_type() const
|
||||
{
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue