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

LibWeb: Stop handling impossible Percentage return values

When a `calc()` is resolved, it can only return a Percentage value if
the requested type is Percentage. In all other cases, it returns a
concrete value.

eg, a `calc()` with Lengths and Percentages in will always resolve to a
Length, never a Percentage. This means we can just return Length
directly instead of LengthPercentage, which simplifies things in a few
places.
This commit is contained in:
Sam Atkins 2022-07-20 13:03:30 +01:00 committed by Andreas Kling
parent cf6e49350e
commit 93c999ce00
3 changed files with 23 additions and 35 deletions

View file

@ -677,14 +677,14 @@ public:
NonnullOwnPtr<CalcSum> const& expression() const { return m_expression; }
Optional<Angle> resolve_angle() const;
Optional<AnglePercentage> resolve_angle_percentage(Angle const& percentage_basis) const;
Optional<Angle> resolve_angle_percentage(Angle const& percentage_basis) const;
Optional<Frequency> resolve_frequency() const;
Optional<FrequencyPercentage> resolve_frequency_percentage(Frequency const& percentage_basis) const;
Optional<Frequency> resolve_frequency_percentage(Frequency const& percentage_basis) const;
Optional<Length> resolve_length(Layout::Node const& layout_node) const;
Optional<LengthPercentage> resolve_length_percentage(Layout::Node const&, Length const& percentage_basis) const;
Optional<Length> resolve_length_percentage(Layout::Node const&, Length const& percentage_basis) const;
Optional<Percentage> resolve_percentage() const;
Optional<Time> resolve_time() const;
Optional<TimePercentage> resolve_time_percentage(Time const& percentage_basis) const;
Optional<Time> resolve_time_percentage(Time const& percentage_basis) const;
Optional<float> resolve_number();
Optional<i64> resolve_integer();