summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorSam Atkins <atkinssj@serenityos.org>2022-07-20 13:39:13 +0100
committerAndreas Kling <kling@serenityos.org>2022-07-21 16:36:08 +0200
commit10ee29a8b324c5ecc3df2e47034fe996afb981e0 (patch)
treef1959bebce3f31e87e2a228a727aaec5f0f6184f
parent93c999ce00c7ce44cdd3090e1774d00f4a184612 (diff)
downloadserenity-10ee29a8b324c5ecc3df2e47034fe996afb981e0.zip
LibWeb: Add helper methods for checking a calc()'s resolved type
-rw-r--r--Userland/Libraries/LibWeb/CSS/StyleValue.h12
1 files changed, 12 insertions, 0 deletions
diff --git a/Userland/Libraries/LibWeb/CSS/StyleValue.h b/Userland/Libraries/LibWeb/CSS/StyleValue.h
index a439dabe49..3bfccc5eec 100644
--- a/Userland/Libraries/LibWeb/CSS/StyleValue.h
+++ b/Userland/Libraries/LibWeb/CSS/StyleValue.h
@@ -676,15 +676,27 @@ public:
ResolvedType resolved_type() const { return m_resolved_type; }
NonnullOwnPtr<CalcSum> const& expression() const { return m_expression; }
+ bool resolves_to_angle() const { return m_resolved_type == ResolvedType::Angle; }
Optional<Angle> resolve_angle() const;
Optional<Angle> resolve_angle_percentage(Angle const& percentage_basis) const;
+
+ bool resolves_to_frequency() const { return m_resolved_type == ResolvedType::Frequency; }
Optional<Frequency> resolve_frequency() const;
Optional<Frequency> resolve_frequency_percentage(Frequency const& percentage_basis) const;
+
+ bool resolves_to_length() const { return m_resolved_type == ResolvedType::Length; }
Optional<Length> resolve_length(Layout::Node const& layout_node) const;
Optional<Length> resolve_length_percentage(Layout::Node const&, Length const& percentage_basis) const;
+
+ bool resolves_to_percentage() const { return m_resolved_type == ResolvedType::Percentage; }
Optional<Percentage> resolve_percentage() const;
+
+ bool resolves_to_time() const { return m_resolved_type == ResolvedType::Time; }
Optional<Time> resolve_time() const;
Optional<Time> resolve_time_percentage(Time const& percentage_basis) const;
+
+ bool resolves_to_integer() const { return m_resolved_type == ResolvedType::Integer; }
+ bool resolves_to_number() const { return resolves_to_integer() || m_resolved_type == ResolvedType::Number; }
Optional<float> resolve_number();
Optional<i64> resolve_integer();