mirror of
https://github.com/RGBCube/serenity
synced 2025-07-26 19:07:36 +00:00
LibWeb: Add a way to ask if a PercentageOr<T> value contains percentages
Values that contain percentages require special treatment in various parts of layout. Previously we had no way of peeking into calc() values to see if their expression contains one or more percentages. That's the bulk of what we're adding here.
This commit is contained in:
parent
3dd11a007f
commit
55ad9591df
3 changed files with 65 additions and 0 deletions
|
@ -609,6 +609,7 @@ public:
|
|||
String to_string() const;
|
||||
Optional<ResolvedType> resolved_type() const;
|
||||
CalculationResult resolve(Layout::Node const*, PercentageBasis const& percentage_basis) const;
|
||||
bool contains_percentage() const;
|
||||
};
|
||||
|
||||
// This represents that: https://www.w3.org/TR/css-values-3/#calc-syntax
|
||||
|
@ -623,6 +624,8 @@ public:
|
|||
String to_string() const;
|
||||
Optional<ResolvedType> resolved_type() const;
|
||||
CalculationResult resolve(Layout::Node const*, PercentageBasis const& percentage_basis) const;
|
||||
|
||||
bool contains_percentage() const;
|
||||
};
|
||||
|
||||
struct CalcNumberSum {
|
||||
|
@ -645,6 +648,7 @@ public:
|
|||
String to_string() const;
|
||||
Optional<ResolvedType> resolved_type() const;
|
||||
CalculationResult resolve(Layout::Node const*, PercentageBasis const& percentage_basis) const;
|
||||
bool contains_percentage() const;
|
||||
};
|
||||
|
||||
struct CalcSumPartWithOperator {
|
||||
|
@ -658,6 +662,7 @@ public:
|
|||
String to_string() const;
|
||||
Optional<ResolvedType> resolved_type() const;
|
||||
CalculationResult resolve(Layout::Node const*, PercentageBasis const& percentage_basis) const;
|
||||
bool contains_percentage() const;
|
||||
};
|
||||
|
||||
struct CalcProductPartWithOperator {
|
||||
|
@ -667,6 +672,8 @@ public:
|
|||
String to_string() const;
|
||||
Optional<ResolvedType> resolved_type() const;
|
||||
CalculationResult resolve(Layout::Node const*, PercentageBasis const& percentage_basis) const;
|
||||
|
||||
bool contains_percentage() const;
|
||||
};
|
||||
|
||||
struct CalcNumberProduct {
|
||||
|
@ -734,6 +741,8 @@ public:
|
|||
Optional<float> resolve_number();
|
||||
Optional<i64> resolve_integer();
|
||||
|
||||
bool contains_percentage() const;
|
||||
|
||||
private:
|
||||
explicit CalculatedStyleValue(NonnullOwnPtr<CalcSum> calc_sum, ResolvedType resolved_type)
|
||||
: StyleValue(Type::Calculated)
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue