1
Fork 0
mirror of https://github.com/RGBCube/serenity synced 2025-07-25 22:57:44 +00:00

Meta+Userland: Pass Gfx::FloatSize by value

Just two floats like Gfx::FloatPoint.
This commit is contained in:
MacDue 2022-12-06 21:44:49 +00:00 committed by Andreas Kling
parent 27fae78335
commit 1574f2c3f6
8 changed files with 21 additions and 21 deletions

View file

@ -69,7 +69,7 @@ static bool is_primitive_type(DeprecatedString const& type)
static bool is_simple_type(DeprecatedString const& type)
{
// Small types that it makes sense just to pass by value.
return type.is_one_of("Gfx::Color", "Gfx::IntPoint", "Gfx::FloatPoint", "Gfx::IntSize");
return type.is_one_of("Gfx::Color", "Gfx::IntPoint", "Gfx::FloatPoint", "Gfx::IntSize", "Gfx::FloatSize");
}
static bool is_primitive_or_simple_type(DeprecatedString const& type)

View file

@ -1827,7 +1827,7 @@ bool LinearGradientStyleValue::equals(StyleValue const& other_) const
&& m_color_stop_list == other.m_color_stop_list);
}
float LinearGradientStyleValue::angle_degrees(Gfx::FloatSize const& gradient_size) const
float LinearGradientStyleValue::angle_degrees(Gfx::FloatSize gradient_size) const
{
auto corner_angle_degrees = [&] {
return static_cast<float>(atan2(gradient_size.height(), gradient_size.width())) * 180 / AK::Pi<float>;
@ -1866,7 +1866,7 @@ float LinearGradientStyleValue::angle_degrees(Gfx::FloatSize const& gradient_siz
});
}
void LinearGradientStyleValue::resolve_for_size(Layout::Node const& node, Gfx::FloatSize const& size) const
void LinearGradientStyleValue::resolve_for_size(Layout::Node const& node, Gfx::FloatSize size) const
{
if (m_resolved.has_value() && m_resolved->size == size)
return;
@ -2150,7 +2150,7 @@ Gfx::FloatSize RadialGradientStyleValue::resolve_size(Layout::Node const& node,
return resolved_size;
}
void RadialGradientStyleValue::resolve_for_size(Layout::Node const& node, Gfx::FloatSize const& paint_size) const
void RadialGradientStyleValue::resolve_for_size(Layout::Node const& node, Gfx::FloatSize paint_size) const
{
Gfx::FloatRect gradient_box { { 0, 0 }, paint_size };
auto center = m_position.resolved(node, gradient_box);
@ -2204,7 +2204,7 @@ DeprecatedString ConicGradientStyleValue::to_deprecated_string() const
return builder.to_deprecated_string();
}
void ConicGradientStyleValue::resolve_for_size(Layout::Node const& node, Gfx::FloatSize const& size) const
void ConicGradientStyleValue::resolve_for_size(Layout::Node const& node, Gfx::FloatSize size) const
{
if (!m_resolved.has_value())
m_resolved = ResolvedData { Painting::resolve_conic_gradient_data(node, *this), {} };

View file

@ -1157,7 +1157,7 @@ public:
virtual Optional<int> natural_height() const { return {}; }
virtual void load_any_resources(DOM::Document&) {};
virtual void resolve_for_size(Layout::Node const&, Gfx::FloatSize const&) const {};
virtual void resolve_for_size(Layout::Node const&, Gfx::FloatSize) const {};
virtual bool is_paintable() const = 0;
virtual void paint(PaintContext& context, Gfx::IntRect const& dest_rect, CSS::ImageRendering image_rendering) const = 0;
@ -1251,7 +1251,7 @@ public:
bool is_paintable() const override { return true; }
void resolve_for_size(Layout::Node const&, Gfx::FloatSize const&) const override;
void resolve_for_size(Layout::Node const&, Gfx::FloatSize) const override;
Gfx::FloatSize resolve_size(Layout::Node const&, Gfx::FloatPoint, Gfx::FloatRect const&) const;
@ -1308,7 +1308,7 @@ public:
bool is_paintable() const override { return true; }
void resolve_for_size(Layout::Node const&, Gfx::FloatSize const&) const override;
void resolve_for_size(Layout::Node const&, Gfx::FloatSize) const override;
virtual ~ConicGradientStyleValue() override = default;
@ -1366,9 +1366,9 @@ public:
bool is_repeating() const { return m_repeating == GradientRepeating::Yes; }
float angle_degrees(Gfx::FloatSize const& gradient_size) const;
float angle_degrees(Gfx::FloatSize gradient_size) const;
void resolve_for_size(Layout::Node const&, Gfx::FloatSize const&) const override;
void resolve_for_size(Layout::Node const&, Gfx::FloatSize) const override;
bool is_paintable() const override { return true; }
void paint(PaintContext& context, Gfx::IntRect const& dest_rect, CSS::ImageRendering image_rendering) const override;

View file

@ -22,7 +22,7 @@ public:
Trailing,
};
LineBoxFragment(Node const& layout_node, int start, int length, Gfx::FloatPoint offset, Gfx::FloatSize const& size, float border_box_top, float border_box_bottom, Type type)
LineBoxFragment(Node const& layout_node, int start, int length, Gfx::FloatPoint offset, Gfx::FloatSize size, float border_box_top, float border_box_bottom, Type type)
: m_layout_node(layout_node)
, m_start(start)
, m_length(length)
@ -47,7 +47,7 @@ public:
void set_baseline(float y) { m_baseline = y; }
float baseline() const { return m_baseline; }
Gfx::FloatSize const& size() const { return m_size; }
Gfx::FloatSize size() const { return m_size; }
void set_width(float width) { m_size.set_width(width); }
void set_height(float height) { m_size.set_height(height); }
float width() const { return m_size.width(); }

View file

@ -129,7 +129,7 @@ static ColorStopData resolve_color_stop_positions(auto const& color_stop_list, a
return { resolved_color_stops, repeat_length };
}
LinearGradientData resolve_linear_gradient_data(Layout::Node const& node, Gfx::FloatSize const& gradient_size, CSS::LinearGradientStyleValue const& linear_gradient)
LinearGradientData resolve_linear_gradient_data(Layout::Node const& node, Gfx::FloatSize gradient_size, CSS::LinearGradientStyleValue const& linear_gradient)
{
auto gradient_angle = linear_gradient.angle_degrees(gradient_size);
auto gradient_length_px = calulate_gradient_length(gradient_size.to_rounded<int>(), gradient_angle);
@ -155,7 +155,7 @@ ConicGradientData resolve_conic_gradient_data(Layout::Node const& node, CSS::Con
return { conic_gradient.angle_degrees(), resolved_color_stops };
}
RadialGradientData resolve_radial_gradient_data(Layout::Node const& node, Gfx::FloatSize const& gradient_size, CSS::RadialGradientStyleValue const& radial_gradient)
RadialGradientData resolve_radial_gradient_data(Layout::Node const& node, Gfx::FloatSize gradient_size, CSS::RadialGradientStyleValue const& radial_gradient)
{
// Start center, goes right to ending point, where the gradient line intersects the ending shape
auto gradient_length = CSS::Length::make_px(gradient_size.width());
@ -302,7 +302,7 @@ void paint_conic_gradient(PaintContext& context, Gfx::IntRect const& gradient_re
});
}
void paint_radial_gradient(PaintContext& context, Gfx::IntRect const& gradient_rect, RadialGradientData const& data, Gfx::IntPoint center, Gfx::FloatSize const& size)
void paint_radial_gradient(PaintContext& context, Gfx::IntRect const& gradient_rect, RadialGradientData const& data, Gfx::IntPoint center, Gfx::FloatSize size)
{
// A conservative guesstimate on how many colors we need to generate:
auto max_dimension = max(gradient_rect.width(), gradient_rect.height());

View file

@ -41,12 +41,12 @@ struct RadialGradientData {
ColorStopData color_stops;
};
LinearGradientData resolve_linear_gradient_data(Layout::Node const&, Gfx::FloatSize const&, CSS::LinearGradientStyleValue const&);
LinearGradientData resolve_linear_gradient_data(Layout::Node const&, Gfx::FloatSize, CSS::LinearGradientStyleValue const&);
ConicGradientData resolve_conic_gradient_data(Layout::Node const&, CSS::ConicGradientStyleValue const&);
RadialGradientData resolve_radial_gradient_data(Layout::Node const&, Gfx::FloatSize const&, CSS::RadialGradientStyleValue const&);
RadialGradientData resolve_radial_gradient_data(Layout::Node const&, Gfx::FloatSize, CSS::RadialGradientStyleValue const&);
void paint_linear_gradient(PaintContext&, Gfx::IntRect const&, LinearGradientData const&);
void paint_conic_gradient(PaintContext&, Gfx::IntRect const&, ConicGradientData const&, Gfx::IntPoint position);
void paint_radial_gradient(PaintContext&, Gfx::IntRect const&, RadialGradientData const&, Gfx::IntPoint position, Gfx::FloatSize const& size);
void paint_radial_gradient(PaintContext&, Gfx::IntRect const&, RadialGradientData const&, Gfx::IntPoint position, Gfx::FloatSize size);
}

View file

@ -60,7 +60,7 @@ void PaintableBox::set_offset(Gfx::FloatPoint offset)
const_cast<Layout::Box&>(layout_box()).did_set_rect();
}
void PaintableBox::set_content_size(Gfx::FloatSize const& size)
void PaintableBox::set_content_size(Gfx::FloatSize size)
{
m_content_size = size;
// FIXME: This const_cast is gross.

View file

@ -38,8 +38,8 @@ public:
void set_offset(Gfx::FloatPoint);
void set_offset(float x, float y) { set_offset({ x, y }); }
Gfx::FloatSize const& content_size() const { return m_content_size; }
void set_content_size(Gfx::FloatSize const&);
Gfx::FloatSize content_size() const { return m_content_size; }
void set_content_size(Gfx::FloatSize);
void set_content_size(float width, float height) { set_content_size({ width, height }); }
void set_content_width(float width) { set_content_size(width, content_height()); }