mirror of
https://github.com/LadybirdBrowser/ladybird.git
synced 2025-09-22 09:18:55 +00:00
LibWeb/CSS: Prepare Size for use in GridSize
Make it constructible from a LengthPercentage, report whether it contains a length-percentage, and add an equality operator.
This commit is contained in:
parent
d3e04c96d9
commit
ad5f7c56c1
Notes:
github-actions[bot]
2025-09-04 12:34:27 +00:00
Author: https://github.com/AtkinsSJ
Commit: ad5f7c56c1
Pull-request: https://github.com/LadybirdBrowser/ladybird/pull/6043
2 changed files with 16 additions and 0 deletions
|
@ -44,6 +44,18 @@ Size Size::make_calculated(NonnullRefPtr<CalculatedStyleValue const> calculated)
|
|||
return Size { Type::Calculated, move(calculated) };
|
||||
}
|
||||
|
||||
Size Size::make_length_percentage(LengthPercentage const& length_percentage)
|
||||
{
|
||||
if (length_percentage.is_auto())
|
||||
return make_auto();
|
||||
if (length_percentage.is_length())
|
||||
return make_length(length_percentage.length());
|
||||
if (length_percentage.is_percentage())
|
||||
return make_percentage(length_percentage.percentage());
|
||||
VERIFY(length_percentage.is_calculated());
|
||||
return make_calculated(length_percentage.calculated());
|
||||
}
|
||||
|
||||
Size Size::make_min_content()
|
||||
{
|
||||
return Size { Type::MinContent, Length::make_auto() };
|
||||
|
|
|
@ -30,6 +30,7 @@ public:
|
|||
static Size make_length(Length);
|
||||
static Size make_percentage(Percentage);
|
||||
static Size make_calculated(NonnullRefPtr<CalculatedStyleValue const>);
|
||||
static Size make_length_percentage(LengthPercentage const&);
|
||||
static Size make_min_content();
|
||||
static Size make_max_content();
|
||||
static Size make_fit_content(LengthPercentage available_space);
|
||||
|
@ -45,6 +46,8 @@ public:
|
|||
bool is_fit_content() const { return m_type == Type::FitContent; }
|
||||
bool is_none() const { return m_type == Type::None; }
|
||||
|
||||
bool is_length_percentage() const { return is_length() || is_percentage() || is_calculated(); }
|
||||
|
||||
[[nodiscard]] CSSPixels to_px(Layout::Node const&, CSSPixels reference_value) const;
|
||||
|
||||
bool contains_percentage() const;
|
||||
|
@ -74,6 +77,7 @@ public:
|
|||
}
|
||||
|
||||
String to_string(SerializationMode) const;
|
||||
bool operator==(Size const&) const = default;
|
||||
|
||||
private:
|
||||
Size(Type type, LengthPercentage);
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue