mirror of
https://github.com/LadybirdBrowser/ladybird.git
synced 2025-10-16 21:20:18 +00:00
LibWeb/CSS: Replace resolve_number_deprecated() with resolve_number()
This commit is contained in:
parent
d9a386fa81
commit
0dba531772
Notes:
github-actions[bot]
2025-09-24 15:36:31 +00:00
Author: https://github.com/AtkinsSJ
Commit: 0dba531772
Pull-request: https://github.com/LadybirdBrowser/ladybird/pull/6290
Reviewed-by: https://github.com/tcl3 ✅
8 changed files with 6 additions and 22 deletions
|
@ -96,7 +96,7 @@ LengthOrCalculated LengthOrAutoOrCalculated::without_auto() const
|
||||||
|
|
||||||
Optional<double> NumberOrCalculated::resolve_calculated(NonnullRefPtr<CalculatedStyleValue const> const& calculated, CalculationResolutionContext const& context) const
|
Optional<double> NumberOrCalculated::resolve_calculated(NonnullRefPtr<CalculatedStyleValue const> const& calculated, CalculationResolutionContext const& context) const
|
||||||
{
|
{
|
||||||
return calculated->resolve_number_deprecated(context);
|
return calculated->resolve_number(context);
|
||||||
}
|
}
|
||||||
|
|
||||||
NonnullRefPtr<StyleValue const> NumberOrCalculated::create_style_value() const
|
NonnullRefPtr<StyleValue const> NumberOrCalculated::create_style_value() const
|
||||||
|
|
|
@ -411,7 +411,7 @@ Optional<int> ComputedProperties::z_index() const
|
||||||
}
|
}
|
||||||
|
|
||||||
if (value.is_calculated()) {
|
if (value.is_calculated()) {
|
||||||
auto maybe_double = value.as_calculated().resolve_number_deprecated({});
|
auto maybe_double = value.as_calculated().resolve_number({});
|
||||||
if (maybe_double.has_value()) {
|
if (maybe_double.has_value()) {
|
||||||
if (*maybe_double >= NumericLimits<int>::max())
|
if (*maybe_double >= NumericLimits<int>::max())
|
||||||
return NumericLimits<int>::max();
|
return NumericLimits<int>::max();
|
||||||
|
|
|
@ -190,7 +190,7 @@ ParsedFontFace ParsedFontFace::from_descriptors(CSSFontFaceDescriptors const& de
|
||||||
if (setting_value->is_number()) {
|
if (setting_value->is_number()) {
|
||||||
settings.set(variation_tag->as_open_type_tagged().tag(), setting_value->as_number().number());
|
settings.set(variation_tag->as_open_type_tagged().tag(), setting_value->as_number().number());
|
||||||
} else if (setting_value->is_calculated() && setting_value->as_calculated().resolves_to_number()) {
|
} else if (setting_value->is_calculated() && setting_value->as_calculated().resolves_to_number()) {
|
||||||
if (auto number = setting_value->as_calculated().resolve_number_deprecated({}); number.has_value()) {
|
if (auto number = setting_value->as_calculated().resolve_number({}); number.has_value()) {
|
||||||
settings.set(variation_tag->as_open_type_tagged().tag(), *number);
|
settings.set(variation_tag->as_open_type_tagged().tag(), *number);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -368,7 +368,7 @@ Optional<Ratio> Parser::parse_ratio(TokenStream<ComponentValue>& tokens)
|
||||||
return maybe_calc->as_number().number();
|
return maybe_calc->as_number().number();
|
||||||
if (!maybe_calc->is_calculated() || !maybe_calc->as_calculated().resolves_to_number())
|
if (!maybe_calc->is_calculated() || !maybe_calc->as_calculated().resolves_to_number())
|
||||||
return {};
|
return {};
|
||||||
if (auto resolved_number = maybe_calc->as_calculated().resolve_number_deprecated({}); resolved_number.has_value() && resolved_number.value() >= 0) {
|
if (auto resolved_number = maybe_calc->as_calculated().resolve_number({}); resolved_number.has_value() && resolved_number.value() >= 0) {
|
||||||
return resolved_number.value();
|
return resolved_number.value();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -3067,21 +3067,6 @@ Optional<Time> CalculatedStyleValue::resolve_time(CalculationResolutionContext c
|
||||||
return {};
|
return {};
|
||||||
}
|
}
|
||||||
|
|
||||||
Optional<double> CalculatedStyleValue::resolve_number_deprecated(CalculationResolutionContext const& context) const
|
|
||||||
{
|
|
||||||
auto result = m_calculation->resolve(context);
|
|
||||||
if (!result.type().has_value() || !result.type()->matches_number(m_context.percentages_resolve_as))
|
|
||||||
return {};
|
|
||||||
|
|
||||||
// https://drafts.csswg.org/css-values/#calc-ieee
|
|
||||||
// NaN does not escape a top-level calculation; it’s censored into a zero value.
|
|
||||||
auto value = result.value();
|
|
||||||
if (isnan(value))
|
|
||||||
return 0.;
|
|
||||||
|
|
||||||
return value;
|
|
||||||
}
|
|
||||||
|
|
||||||
Optional<double> CalculatedStyleValue::resolve_number(CalculationResolutionContext const& context) const
|
Optional<double> CalculatedStyleValue::resolve_number(CalculationResolutionContext const& context) const
|
||||||
{
|
{
|
||||||
auto result = resolve_value(context);
|
auto result = resolve_value(context);
|
||||||
|
|
|
@ -103,7 +103,6 @@ public:
|
||||||
Optional<Time> resolve_time(CalculationResolutionContext const&) const;
|
Optional<Time> resolve_time(CalculationResolutionContext const&) const;
|
||||||
|
|
||||||
bool resolves_to_number() const { return m_resolved_type.matches_number(m_context.percentages_resolve_as); }
|
bool resolves_to_number() const { return m_resolved_type.matches_number(m_context.percentages_resolve_as); }
|
||||||
Optional<double> resolve_number_deprecated(CalculationResolutionContext const&) const;
|
|
||||||
Optional<double> resolve_number(CalculationResolutionContext const&) const;
|
Optional<double> resolve_number(CalculationResolutionContext const&) const;
|
||||||
Optional<i64> resolve_integer(CalculationResolutionContext const&) const;
|
Optional<i64> resolve_integer(CalculationResolutionContext const&) const;
|
||||||
|
|
||||||
|
|
|
@ -34,7 +34,7 @@ float FilterOperation::Color::resolved_amount() const
|
||||||
if (amount.is_calculated()) {
|
if (amount.is_calculated()) {
|
||||||
CalculationResolutionContext context {};
|
CalculationResolutionContext context {};
|
||||||
if (amount.calculated()->resolves_to_number())
|
if (amount.calculated()->resolves_to_number())
|
||||||
return amount.calculated()->resolve_number_deprecated(context).value();
|
return amount.calculated()->resolve_number(context).value();
|
||||||
|
|
||||||
if (amount.calculated()->resolves_to_percentage())
|
if (amount.calculated()->resolves_to_percentage())
|
||||||
return amount.calculated()->resolve_percentage_deprecated(context)->as_fraction();
|
return amount.calculated()->resolve_percentage_deprecated(context)->as_fraction();
|
||||||
|
|
|
@ -80,7 +80,7 @@ String TransformationStyleValue::to_string(SerializationMode mode) const
|
||||||
if (value->is_number())
|
if (value->is_number())
|
||||||
return value->as_number().number();
|
return value->as_number().number();
|
||||||
if (value->is_calculated() && value->as_calculated().resolves_to_number())
|
if (value->is_calculated() && value->as_calculated().resolves_to_number())
|
||||||
return value->as_calculated().resolve_number_deprecated({});
|
return value->as_calculated().resolve_number({});
|
||||||
|
|
||||||
VERIFY_NOT_REACHED();
|
VERIFY_NOT_REACHED();
|
||||||
};
|
};
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue