mirror of
https://github.com/fergalmoran/ladybird.git
synced 2025-12-22 09:19:03 +00:00
LibWeb/CSS: Remove unnecessary CalculatedStyleValue const-casts
This commit is contained in:
committed by
Andreas Kling
parent
69a0f28d04
commit
0149f7d4e4
@@ -407,7 +407,7 @@ int CSSStyleValue::to_font_weight() const
|
|||||||
return round_to<int>(as_number().number());
|
return round_to<int>(as_number().number());
|
||||||
}
|
}
|
||||||
if (is_calculated()) {
|
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())
|
if (maybe_weight.has_value())
|
||||||
return maybe_weight.value();
|
return maybe_weight.value();
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -138,7 +138,7 @@ Variant<LengthPercentage, NormalGap> StyleProperties::gap_value(CSS::PropertyID
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (value.is_calculated())
|
if (value.is_calculated())
|
||||||
return LengthPercentage { const_cast<CalculatedStyleValue&>(value.as_calculated()) };
|
return LengthPercentage { value.as_calculated() };
|
||||||
|
|
||||||
if (value.is_percentage())
|
if (value.is_percentage())
|
||||||
return LengthPercentage { value.as_percentage().percentage() };
|
return LengthPercentage { value.as_percentage().percentage() };
|
||||||
@@ -170,7 +170,7 @@ CSS::Size StyleProperties::size_value(CSS::PropertyID id) const
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (value.is_calculated())
|
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())
|
if (value.is_percentage())
|
||||||
return CSS::Size::make_percentage(value.as_percentage().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);
|
auto const& value = property(id);
|
||||||
|
|
||||||
if (value.is_calculated())
|
if (value.is_calculated())
|
||||||
return LengthPercentage { const_cast<CalculatedStyleValue&>(value.as_calculated()) };
|
return LengthPercentage { value.as_calculated() };
|
||||||
|
|
||||||
if (value.is_percentage())
|
if (value.is_percentage())
|
||||||
return value.as_percentage().percentage();
|
return value.as_percentage().percentage();
|
||||||
@@ -318,7 +318,7 @@ float StyleProperties::resolve_opacity_value(CSSStyleValue const& value)
|
|||||||
else
|
else
|
||||||
dbgln("Unable to resolve calc() as opacity (percentage): {}", value.to_string(CSSStyleValue::SerializationMode::Normal));
|
dbgln("Unable to resolve calc() as opacity (percentage): {}", value.to_string(CSSStyleValue::SerializationMode::Normal));
|
||||||
} else if (calculated.resolves_to_number()) {
|
} 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())
|
if (maybe_number.has_value())
|
||||||
unclamped_opacity = maybe_number.value();
|
unclamped_opacity = maybe_number.value();
|
||||||
else
|
else
|
||||||
@@ -636,7 +636,7 @@ static Optional<LengthPercentage> length_percentage_for_style_value(CSSStyleValu
|
|||||||
if (value.is_percentage())
|
if (value.is_percentage())
|
||||||
return value.as_percentage().percentage();
|
return value.as_percentage().percentage();
|
||||||
if (value.is_calculated())
|
if (value.is_calculated())
|
||||||
return LengthPercentage { const_cast<CalculatedStyleValue&>(value.as_calculated()) };
|
return LengthPercentage { value.as_calculated() };
|
||||||
return {};
|
return {};
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -1168,7 +1168,7 @@ Variant<CSS::VerticalAlign, CSS::LengthPercentage> StyleProperties::vertical_ali
|
|||||||
return CSS::LengthPercentage(value.as_percentage().percentage());
|
return CSS::LengthPercentage(value.as_percentage().percentage());
|
||||||
|
|
||||||
if (value.is_calculated())
|
if (value.is_calculated())
|
||||||
return LengthPercentage { const_cast<CalculatedStyleValue&>(value.as_calculated()) };
|
return LengthPercentage { value.as_calculated() };
|
||||||
|
|
||||||
VERIFY_NOT_REACHED();
|
VERIFY_NOT_REACHED();
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -2470,7 +2470,7 @@ bool CalculatedStyleValue::equals(CSSStyleValue const& other) const
|
|||||||
if (type() != other.type())
|
if (type() != other.type())
|
||||||
return false;
|
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
|
Optional<Angle> CalculatedStyleValue::resolve_angle() const
|
||||||
|
|||||||
Reference in New Issue
Block a user