mirror of
https://github.com/LadybirdBrowser/ladybird.git
synced 2025-04-22 04:25:13 +00:00
LibWeb/CSS: Remove unnecessary CalculatedStyleValue const-casts
This commit is contained in:
parent
69a0f28d04
commit
0149f7d4e4
Notes:
github-actions[bot]
2024-12-21 17:15:50 +00:00
Author: https://github.com/AtkinsSJ Commit: https://github.com/LadybirdBrowser/ladybird/commit/0149f7d4e4c Pull-request: https://github.com/LadybirdBrowser/ladybird/pull/2966
3 changed files with 8 additions and 8 deletions
|
@ -407,7 +407,7 @@ int CSSStyleValue::to_font_weight() const
|
|||
return round_to<int>(as_number().number());
|
||||
}
|
||||
if (is_calculated()) {
|
||||
auto maybe_weight = const_cast<CalculatedStyleValue&>(as_calculated()).resolve_integer();
|
||||
auto maybe_weight = as_calculated().resolve_integer();
|
||||
if (maybe_weight.has_value())
|
||||
return maybe_weight.value();
|
||||
}
|
||||
|
|
|
@ -138,7 +138,7 @@ Variant<LengthPercentage, NormalGap> StyleProperties::gap_value(CSS::PropertyID
|
|||
}
|
||||
|
||||
if (value.is_calculated())
|
||||
return LengthPercentage { const_cast<CalculatedStyleValue&>(value.as_calculated()) };
|
||||
return LengthPercentage { value.as_calculated() };
|
||||
|
||||
if (value.is_percentage())
|
||||
return LengthPercentage { value.as_percentage().percentage() };
|
||||
|
@ -170,7 +170,7 @@ CSS::Size StyleProperties::size_value(CSS::PropertyID id) const
|
|||
}
|
||||
|
||||
if (value.is_calculated())
|
||||
return CSS::Size::make_calculated(const_cast<CalculatedStyleValue&>(value.as_calculated()));
|
||||
return CSS::Size::make_calculated(value.as_calculated());
|
||||
|
||||
if (value.is_percentage())
|
||||
return CSS::Size::make_percentage(value.as_percentage().percentage());
|
||||
|
@ -197,7 +197,7 @@ Optional<LengthPercentage> StyleProperties::length_percentage(CSS::PropertyID id
|
|||
auto const& value = property(id);
|
||||
|
||||
if (value.is_calculated())
|
||||
return LengthPercentage { const_cast<CalculatedStyleValue&>(value.as_calculated()) };
|
||||
return LengthPercentage { value.as_calculated() };
|
||||
|
||||
if (value.is_percentage())
|
||||
return value.as_percentage().percentage();
|
||||
|
@ -318,7 +318,7 @@ float StyleProperties::resolve_opacity_value(CSSStyleValue const& value)
|
|||
else
|
||||
dbgln("Unable to resolve calc() as opacity (percentage): {}", value.to_string(CSSStyleValue::SerializationMode::Normal));
|
||||
} else if (calculated.resolves_to_number()) {
|
||||
auto maybe_number = const_cast<CalculatedStyleValue&>(value.as_calculated()).resolve_number();
|
||||
auto maybe_number = value.as_calculated().resolve_number();
|
||||
if (maybe_number.has_value())
|
||||
unclamped_opacity = maybe_number.value();
|
||||
else
|
||||
|
@ -636,7 +636,7 @@ static Optional<LengthPercentage> length_percentage_for_style_value(CSSStyleValu
|
|||
if (value.is_percentage())
|
||||
return value.as_percentage().percentage();
|
||||
if (value.is_calculated())
|
||||
return LengthPercentage { const_cast<CalculatedStyleValue&>(value.as_calculated()) };
|
||||
return LengthPercentage { value.as_calculated() };
|
||||
return {};
|
||||
}
|
||||
|
||||
|
@ -1168,7 +1168,7 @@ Variant<CSS::VerticalAlign, CSS::LengthPercentage> StyleProperties::vertical_ali
|
|||
return CSS::LengthPercentage(value.as_percentage().percentage());
|
||||
|
||||
if (value.is_calculated())
|
||||
return LengthPercentage { const_cast<CalculatedStyleValue&>(value.as_calculated()) };
|
||||
return LengthPercentage { value.as_calculated() };
|
||||
|
||||
VERIFY_NOT_REACHED();
|
||||
}
|
||||
|
|
|
@ -2470,7 +2470,7 @@ bool CalculatedStyleValue::equals(CSSStyleValue const& other) const
|
|||
if (type() != other.type())
|
||||
return false;
|
||||
|
||||
return m_calculation->equals(*static_cast<CalculatedStyleValue const&>(other).m_calculation);
|
||||
return m_calculation->equals(*other.as_calculated().m_calculation);
|
||||
}
|
||||
|
||||
Optional<Angle> CalculatedStyleValue::resolve_angle() const
|
||||
|
|
Loading…
Add table
Reference in a new issue