1
Fork 0
mirror of https://github.com/RGBCube/serenity synced 2025-07-26 05:07:35 +00:00

Everywhere: Add -Wdouble-promotion warning

This warning informs of float-to-double conversions. The best solution
seems to be to do math *either* in 32-bit *or* in 64-bit, and only to
cross over when absolutely necessary.
This commit is contained in:
Nicholas-Baron 2021-04-15 00:36:14 -07:00 committed by Andreas Kling
parent 6606d70826
commit 73dd293ec4
26 changed files with 105 additions and 98 deletions

View file

@ -73,7 +73,7 @@ public:
if (is_undefined())
return fallback_for_undefined;
if (is_percentage())
return make_px(raw_value() / 100.0 * reference_for_percent);
return make_px(raw_value() / 100.0f * reference_for_percent);
if (is_relative())
return make_px(to_px(layout_node));
return *this;

View file

@ -189,7 +189,7 @@ void dump_tree(StringBuilder& builder, const Layout::Node& layout_node, bool sho
if (show_box_model) {
// Dump the horizontal box properties
builder.appendf(" [%g+%g+%g %g %g+%g+%g]",
builder.appendff(" [{}+{}+{} {} {}+{}+{}]",
box.box_model().margin.left,
box.box_model().border.left,
box.box_model().padding.left,
@ -199,7 +199,7 @@ void dump_tree(StringBuilder& builder, const Layout::Node& layout_node, bool sho
box.box_model().margin.right);
// And the vertical box properties
builder.appendf(" [%g+%g+%g %g %g+%g+%g]",
builder.appendff(" [{}+{}+{} {} {}+{}+{}]",
box.box_model().margin.top,
box.box_model().border.top,
box.box_model().padding.top,

View file

@ -219,13 +219,13 @@ DOM::ExceptionOr<void> CanvasRenderingContext2D::ellipse(float x, float y, float
if (radius_y < 0)
return DOM::IndexSizeError::create(String::formatted("The minor-axis radius provided ({}) is negative.", radius_y));
if ((!counter_clockwise && (end_angle - start_angle) >= M_TAU)
|| (counter_clockwise && (start_angle - end_angle) >= M_TAU)) {
if (constexpr float tau = M_TAU; (!counter_clockwise && (end_angle - start_angle) >= tau)
|| (counter_clockwise && (start_angle - end_angle) >= tau)) {
start_angle = 0;
end_angle = M_TAU;
end_angle = tau;
} else {
start_angle = fmodf(start_angle, M_TAU);
end_angle = fmodf(end_angle, M_TAU);
start_angle = fmodf(start_angle, tau);
end_angle = fmodf(end_angle, tau);
}
// Then, figure out where the ends of the arc are.
@ -263,7 +263,7 @@ DOM::ExceptionOr<void> CanvasRenderingContext2D::ellipse(float x, float y, float
m_path.move_to(start_point);
auto delta_theta = end_angle - start_angle;
double delta_theta = end_angle - start_angle;
// FIXME: This is still goofy for some values.
m_path.elliptical_arc_to(end_point, { radius_x, radius_y }, rotation, delta_theta > M_PI, !counter_clockwise);

View file

@ -516,7 +516,7 @@ Gfx::Path& SVGPathElement::get_path()
case PathInstructionType::EllipticalArc: {
double rx = data[0];
double ry = data[1];
double x_axis_rotation = data[2] * M_DEG2RAD;
double x_axis_rotation = double { data[2] } * M_DEG2RAD;
double large_arc_flag = data[3];
double sweep_flag = data[4];
auto& last_point = path.segments().last().point();