mirror of
https://github.com/LadybirdBrowser/ladybird.git
synced 2025-09-22 09:18:55 +00:00
LibWeb/CSS: Use empty optional for stretch
in FitContentSV
...instead of using an `auto` Length.
This commit is contained in:
parent
f57ffc3655
commit
d10eaa996e
Notes:
github-actions[bot]
2025-09-04 12:33:28 +00:00
Author: https://github.com/AtkinsSJ
Commit: d10eaa996e
Pull-request: https://github.com/LadybirdBrowser/ladybird/pull/6043
3 changed files with 11 additions and 7 deletions
|
@ -198,7 +198,9 @@ Size ComputedProperties::size_value(PropertyID id) const
|
||||||
}
|
}
|
||||||
if (value.is_fit_content()) {
|
if (value.is_fit_content()) {
|
||||||
auto& fit_content = value.as_fit_content();
|
auto& fit_content = value.as_fit_content();
|
||||||
return Size::make_fit_content(fit_content.length_percentage());
|
if (auto length_percentage = fit_content.length_percentage(); length_percentage.has_value())
|
||||||
|
return Size::make_fit_content(length_percentage.release_value());
|
||||||
|
return Size::make_fit_content();
|
||||||
}
|
}
|
||||||
|
|
||||||
if (value.is_calculated())
|
if (value.is_calculated())
|
||||||
|
|
|
@ -3192,6 +3192,8 @@ RefPtr<FitContentStyleValue const> Parser::parse_fit_content_value(TokenStream<C
|
||||||
return nullptr;
|
return nullptr;
|
||||||
|
|
||||||
transaction.commit();
|
transaction.commit();
|
||||||
|
if (maybe_length->is_auto())
|
||||||
|
return FitContentStyleValue::create();
|
||||||
return FitContentStyleValue::create(maybe_length.release_value());
|
return FitContentStyleValue::create(maybe_length.release_value());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -15,7 +15,7 @@ class FitContentStyleValue final : public StyleValue {
|
||||||
public:
|
public:
|
||||||
static ValueComparingNonnullRefPtr<FitContentStyleValue const> create()
|
static ValueComparingNonnullRefPtr<FitContentStyleValue const> create()
|
||||||
{
|
{
|
||||||
return adopt_ref(*new (nothrow) FitContentStyleValue(LengthPercentage { Length::make_auto() }));
|
return adopt_ref(*new (nothrow) FitContentStyleValue());
|
||||||
}
|
}
|
||||||
static ValueComparingNonnullRefPtr<FitContentStyleValue const> create(LengthPercentage length_percentage)
|
static ValueComparingNonnullRefPtr<FitContentStyleValue const> create(LengthPercentage length_percentage)
|
||||||
{
|
{
|
||||||
|
@ -25,9 +25,9 @@ public:
|
||||||
|
|
||||||
virtual String to_string(SerializationMode mode) const override
|
virtual String to_string(SerializationMode mode) const override
|
||||||
{
|
{
|
||||||
if (m_length_percentage.is_auto())
|
if (!m_length_percentage.has_value())
|
||||||
return "fit-content"_string;
|
return "fit-content"_string;
|
||||||
return MUST(String::formatted("fit-content({})", m_length_percentage.to_string(mode)));
|
return MUST(String::formatted("fit-content({})", m_length_percentage->to_string(mode)));
|
||||||
}
|
}
|
||||||
|
|
||||||
bool equals(StyleValue const& other) const override
|
bool equals(StyleValue const& other) const override
|
||||||
|
@ -37,16 +37,16 @@ public:
|
||||||
return m_length_percentage == other.as_fit_content().m_length_percentage;
|
return m_length_percentage == other.as_fit_content().m_length_percentage;
|
||||||
}
|
}
|
||||||
|
|
||||||
[[nodiscard]] LengthPercentage const& length_percentage() const { return m_length_percentage; }
|
[[nodiscard]] Optional<LengthPercentage> const& length_percentage() const { return m_length_percentage; }
|
||||||
|
|
||||||
private:
|
private:
|
||||||
FitContentStyleValue(LengthPercentage length_percentage)
|
FitContentStyleValue(Optional<LengthPercentage> length_percentage = {})
|
||||||
: StyleValue(Type::FitContent)
|
: StyleValue(Type::FitContent)
|
||||||
, m_length_percentage(move(length_percentage))
|
, m_length_percentage(move(length_percentage))
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
LengthPercentage m_length_percentage;
|
Optional<LengthPercentage> m_length_percentage;
|
||||||
};
|
};
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue