mirror of
https://github.com/LadybirdBrowser/ladybird.git
synced 2025-07-30 20:59:16 +00:00
LibWeb/CSS: Use CalcSV's context to determine what percentages are
This lets us implement the `matches_number()` and `matches_dimension()` methods of `CSSNumericType` to spec, instead of being an ad-hoc hack.
This commit is contained in:
parent
6f60c258ce
commit
4e1aa96dce
Notes:
github-actions[bot]
2025-01-13 11:00:10 +00:00
Author: https://github.com/AtkinsSJ
Commit: 4e1aa96dce
Pull-request: https://github.com/LadybirdBrowser/ladybird/pull/3198
5 changed files with 98 additions and 79 deletions
|
@ -69,23 +69,23 @@ public:
|
|||
virtual String to_string(SerializationMode) const override;
|
||||
virtual bool equals(CSSStyleValue const& other) const override;
|
||||
|
||||
bool resolves_to_angle() const { return m_resolved_type.matches_angle(); }
|
||||
bool resolves_to_angle_percentage() const { return m_resolved_type.matches_angle_percentage(); }
|
||||
bool resolves_to_angle() const { return m_resolved_type.matches_angle(m_context.percentages_resolve_as); }
|
||||
bool resolves_to_angle_percentage() const { return m_resolved_type.matches_angle_percentage(m_context.percentages_resolve_as); }
|
||||
Optional<Angle> resolve_angle() const;
|
||||
Optional<Angle> resolve_angle(Layout::Node const& layout_node) const;
|
||||
Optional<Angle> resolve_angle(Length::ResolutionContext const& context) const;
|
||||
Optional<Angle> resolve_angle_percentage(Angle const& percentage_basis) const;
|
||||
|
||||
bool resolves_to_flex() const { return m_resolved_type.matches_flex(); }
|
||||
bool resolves_to_flex() const { return m_resolved_type.matches_flex(m_context.percentages_resolve_as); }
|
||||
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(); }
|
||||
bool resolves_to_frequency() const { return m_resolved_type.matches_frequency(m_context.percentages_resolve_as); }
|
||||
bool resolves_to_frequency_percentage() const { return m_resolved_type.matches_frequency_percentage(m_context.percentages_resolve_as); }
|
||||
Optional<Frequency> resolve_frequency() const;
|
||||
Optional<Frequency> resolve_frequency_percentage(Frequency const& percentage_basis) const;
|
||||
|
||||
bool resolves_to_length() const { return m_resolved_type.matches_length(); }
|
||||
bool resolves_to_length_percentage() const { return m_resolved_type.matches_length_percentage(); }
|
||||
bool resolves_to_length() const { return m_resolved_type.matches_length(m_context.percentages_resolve_as); }
|
||||
bool resolves_to_length_percentage() const { return m_resolved_type.matches_length_percentage(m_context.percentages_resolve_as); }
|
||||
Optional<Length> resolve_length(Length::ResolutionContext const&) const;
|
||||
Optional<Length> resolve_length(Layout::Node const& layout_node) const;
|
||||
Optional<Length> resolve_length_percentage(Layout::Node const&, Length const& percentage_basis) const;
|
||||
|
@ -95,15 +95,15 @@ public:
|
|||
bool resolves_to_percentage() const { return m_resolved_type.matches_percentage(); }
|
||||
Optional<Percentage> resolve_percentage() const;
|
||||
|
||||
bool resolves_to_resolution() const { return m_resolved_type.matches_resolution(); }
|
||||
bool resolves_to_resolution() const { return m_resolved_type.matches_resolution(m_context.percentages_resolve_as); }
|
||||
Optional<Resolution> resolve_resolution() const;
|
||||
|
||||
bool resolves_to_time() const { return m_resolved_type.matches_time(); }
|
||||
bool resolves_to_time_percentage() const { return m_resolved_type.matches_time_percentage(); }
|
||||
bool resolves_to_time() const { return m_resolved_type.matches_time(m_context.percentages_resolve_as); }
|
||||
bool resolves_to_time_percentage() const { return m_resolved_type.matches_time_percentage(m_context.percentages_resolve_as); }
|
||||
Optional<Time> resolve_time() const;
|
||||
Optional<Time> resolve_time_percentage(Time const& percentage_basis) const;
|
||||
|
||||
bool resolves_to_number() const { return m_resolved_type.matches_number(); }
|
||||
bool resolves_to_number() const { return m_resolved_type.matches_number(m_context.percentages_resolve_as); }
|
||||
Optional<double> resolve_number() const;
|
||||
Optional<double> resolve_number(Length::ResolutionContext const&) const;
|
||||
Optional<double> resolve_number(Layout::Node const& layout_node) const;
|
||||
|
@ -126,6 +126,8 @@ private:
|
|||
{
|
||||
}
|
||||
|
||||
Optional<ValueType> percentage_resolved_type() const;
|
||||
|
||||
CSSNumericType m_resolved_type;
|
||||
NonnullOwnPtr<CalculationNode> m_calculation;
|
||||
CalculationContext m_context;
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue