1
Fork 0
mirror of https://github.com/RGBCube/serenity synced 2025-07-27 01:17:35 +00:00

LibWeb: Distinguish between Integer and Number calc() values

This commit is contained in:
Sam Atkins 2022-02-02 12:34:32 +00:00 committed by Andreas Kling
parent e4251f3327
commit 714832e705
3 changed files with 74 additions and 38 deletions

View file

@ -673,9 +673,14 @@ public:
Divide,
};
struct Number {
bool is_integer;
float value;
};
class CalculationResult {
public:
CalculationResult(Variant<float, Length, Percentage> value)
CalculationResult(Variant<Number, Length, Percentage> value)
: m_value(move(value))
{
}
@ -684,11 +689,11 @@ public:
void multiply_by(CalculationResult const& other, Layout::Node const*);
void divide_by(CalculationResult const& other, Layout::Node const*);
Variant<float, Length, Percentage> const& value() const { return m_value; }
Variant<Number, Length, Percentage> const& value() const { return m_value; }
private:
void add_or_subtract_internal(SumOperation op, CalculationResult const& other, Layout::Node const*, Length const& percentage_basis);
Variant<float, Length, Percentage> m_value;
Variant<Number, Length, Percentage> m_value;
};
struct CalcSum;
@ -701,13 +706,13 @@ public:
struct CalcNumberProductPartWithOperator;
struct CalcNumberValue {
Variant<float, NonnullOwnPtr<CalcNumberSum>> value;
Variant<Number, NonnullOwnPtr<CalcNumberSum>> value;
Optional<ResolvedType> resolved_type() const;
CalculationResult resolve(Layout::Node const*, Length const& percentage_basis) const;
};
struct CalcValue {
Variant<float, Length, Percentage, NonnullOwnPtr<CalcSum>> value;
Variant<Number, Length, Percentage, NonnullOwnPtr<CalcSum>> value;
Optional<ResolvedType> resolved_type() const;
CalculationResult resolve(Layout::Node const*, Length const& percentage_basis) const;
};