mirror of
https://github.com/RGBCube/serenity
synced 2025-07-28 05:47:34 +00:00
LibWeb: Change calc node representation from float to double
This commit is contained in:
parent
f5da6d61b4
commit
421559d725
22 changed files with 75 additions and 75 deletions
|
@ -513,7 +513,7 @@ void CalculatedStyleValue::CalculationResult::add_or_subtract_internal(SumOperat
|
|||
void CalculatedStyleValue::CalculationResult::multiply_by(CalculationResult const& other, Layout::Node const* layout_node)
|
||||
{
|
||||
// We know from validation when resolving the type, that at least one side must be a <number> or <integer>.
|
||||
// Both of these are represented as a float.
|
||||
// Both of these are represented as a double.
|
||||
VERIFY(m_value.has<Number>() || other.m_value.has<Number>());
|
||||
bool other_is_number = other.m_value.has<Number>();
|
||||
|
||||
|
@ -552,7 +552,7 @@ void CalculatedStyleValue::CalculationResult::divide_by(CalculationResult const&
|
|||
// Both of these are represented as a Number.
|
||||
auto denominator = other.m_value.get<Number>().value();
|
||||
// FIXME: Dividing by 0 is invalid, and should be caught during parsing.
|
||||
VERIFY(denominator != 0.0f);
|
||||
VERIFY(denominator != 0.0);
|
||||
|
||||
m_value.visit(
|
||||
[&](Number const& number) {
|
||||
|
@ -745,7 +745,7 @@ Optional<Time> CalculatedStyleValue::resolve_time_percentage(Time const& percent
|
|||
});
|
||||
}
|
||||
|
||||
Optional<float> CalculatedStyleValue::resolve_number() const
|
||||
Optional<double> CalculatedStyleValue::resolve_number() const
|
||||
{
|
||||
auto result = m_calculation->resolve(nullptr, {});
|
||||
if (result.value().has<Number>())
|
||||
|
|
|
@ -94,7 +94,7 @@ public:
|
|||
|
||||
bool resolves_to_integer() const { return m_resolved_type == ResolvedType::Integer; }
|
||||
bool resolves_to_number() const { return resolves_to_integer() || m_resolved_type == ResolvedType::Number; }
|
||||
Optional<float> resolve_number() const;
|
||||
Optional<double> resolve_number() const;
|
||||
Optional<i64> resolve_integer();
|
||||
|
||||
bool contains_percentage() const;
|
||||
|
|
|
@ -40,7 +40,7 @@ float Filter::HueRotate::angle_degrees() const
|
|||
// Default value when omitted is 0deg.
|
||||
if (!angle.has_value())
|
||||
return 0.0f;
|
||||
return angle->visit([&](Angle const& a) { return a.to_degrees(); }, [&](auto) { return 0.0f; });
|
||||
return angle->visit([&](Angle const& a) { return a.to_degrees(); }, [&](auto) { return 0.0; });
|
||||
}
|
||||
|
||||
float Filter::Color::resolved_amount() const
|
||||
|
|
|
@ -66,35 +66,35 @@ bool LinearGradientStyleValue::equals(StyleValue const& other_) const
|
|||
float LinearGradientStyleValue::angle_degrees(CSSPixelSize gradient_size) const
|
||||
{
|
||||
auto corner_angle_degrees = [&] {
|
||||
return static_cast<float>(atan2(gradient_size.height().value(), gradient_size.width().value())) * 180 / AK::Pi<float>;
|
||||
return atan2(gradient_size.height().value(), gradient_size.width().value()) * 180 / AK::Pi<double>;
|
||||
};
|
||||
return m_properties.direction.visit(
|
||||
[&](SideOrCorner side_or_corner) {
|
||||
auto angle = [&] {
|
||||
switch (side_or_corner) {
|
||||
case SideOrCorner::Top:
|
||||
return 0.0f;
|
||||
return 0.0;
|
||||
case SideOrCorner::Bottom:
|
||||
return 180.0f;
|
||||
return 180.0;
|
||||
case SideOrCorner::Left:
|
||||
return 270.0f;
|
||||
return 270.0;
|
||||
case SideOrCorner::Right:
|
||||
return 90.0f;
|
||||
return 90.0;
|
||||
case SideOrCorner::TopRight:
|
||||
return corner_angle_degrees();
|
||||
case SideOrCorner::BottomLeft:
|
||||
return corner_angle_degrees() + 180.0f;
|
||||
return corner_angle_degrees() + 180.0;
|
||||
case SideOrCorner::TopLeft:
|
||||
return -corner_angle_degrees();
|
||||
case SideOrCorner::BottomRight:
|
||||
return -(corner_angle_degrees() + 180.0f);
|
||||
return -(corner_angle_degrees() + 180.0);
|
||||
default:
|
||||
VERIFY_NOT_REACHED();
|
||||
}
|
||||
}();
|
||||
// Note: For unknowable reasons the angles are opposite on the -webkit- version
|
||||
if (m_properties.gradient_type == GradientType::WebKit)
|
||||
return angle + 180.0f;
|
||||
return angle + 180.0;
|
||||
return angle;
|
||||
},
|
||||
[&](Angle const& angle) {
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue