1
Fork 0
mirror of https://github.com/RGBCube/serenity synced 2025-07-26 12:07:45 +00:00

LibWeb: Implement Flex and FlexStyleValue types

This commit is contained in:
Sam Atkins 2023-09-28 15:18:14 +01:00 committed by Sam Atkins
parent f1d7ea67c0
commit b0317bb3a1
15 changed files with 258 additions and 6 deletions

View file

@ -12,6 +12,7 @@
#include <AK/Function.h>
#include <LibWeb/CSS/Angle.h>
#include <LibWeb/CSS/CSSNumericType.h>
#include <LibWeb/CSS/Flex.h>
#include <LibWeb/CSS/Frequency.h>
#include <LibWeb/CSS/Length.h>
#include <LibWeb/CSS/Percentage.h>
@ -26,6 +27,7 @@ class CalculatedStyleValue : public StyleValue {
public:
enum class ResolvedType {
Angle,
Flex,
Frequency,
Integer,
Length,
@ -43,11 +45,11 @@ public:
Divide,
};
using PercentageBasis = Variant<Empty, Angle, Frequency, Length, Time>;
using PercentageBasis = Variant<Empty, Angle, Flex, Frequency, Length, Time>;
class CalculationResult {
public:
using Value = Variant<Number, Angle, Frequency, Length, Percentage, Time>;
using Value = Variant<Number, Angle, Flex, Frequency, Length, Percentage, Time>;
CalculationResult(Value value)
: m_value(move(value))
{
@ -79,6 +81,9 @@ public:
Optional<Angle> resolve_angle() const;
Optional<Angle> resolve_angle_percentage(Angle const& percentage_basis) const;
bool resolves_to_flex() const { return m_resolved_type.matches_flex(); }
Optional<Flex> resolve_flex() const;
bool resolves_to_frequency() const { return m_resolved_type.matches_frequency(); }
bool resolves_to_frequency_percentage() const { return m_resolved_type.matches_frequency_percentage(); }
Optional<Frequency> resolve_frequency() const;