LibWeb: Only require NodeWithStyle for gradient size resolution

None of the code here actually needs a NodeWithStyleAndBoxModelMetrics,
and we'll need to be able to resolve images from inside
NodeWithStyle::apply_style().
This commit is contained in:
Sam Atkins 2025-02-18 16:13:37 +00:00 committed by Andreas Kling
commit 9cbd8a82c7
Notes: github-actions[bot] 2025-02-28 12:51:49 +00:00
9 changed files with 14 additions and 14 deletions

View file

@ -33,7 +33,7 @@ public:
} }
virtual void load_any_resources(DOM::Document&) { } virtual void load_any_resources(DOM::Document&) { }
virtual void resolve_for_size(Layout::NodeWithStyleAndBoxModelMetrics const&, CSSPixelSize) const { } virtual void resolve_for_size(Layout::NodeWithStyle const&, CSSPixelSize) const { }
virtual bool is_paintable() const = 0; virtual bool is_paintable() const = 0;
virtual void paint(PaintContext& context, DevicePixelRect const& dest_rect, ImageRendering) const = 0; virtual void paint(PaintContext& context, DevicePixelRect const& dest_rect, ImageRendering) const = 0;

View file

@ -36,7 +36,7 @@ String ConicGradientStyleValue::to_string(SerializationMode mode) const
return MUST(builder.to_string()); return MUST(builder.to_string());
} }
void ConicGradientStyleValue::resolve_for_size(Layout::NodeWithStyleAndBoxModelMetrics const& node, CSSPixelSize size) const void ConicGradientStyleValue::resolve_for_size(Layout::NodeWithStyle const& node, CSSPixelSize size) const
{ {
ResolvedDataCacheKey cache_key { ResolvedDataCacheKey cache_key {
.length_resolution_context = Length::ResolutionContext::for_layout_node(node), .length_resolution_context = Length::ResolutionContext::for_layout_node(node),

View file

@ -38,7 +38,7 @@ public:
bool is_paintable() const override { return true; } bool is_paintable() const override { return true; }
void resolve_for_size(Layout::NodeWithStyleAndBoxModelMetrics const&, CSSPixelSize) const override; void resolve_for_size(Layout::NodeWithStyle const&, CSSPixelSize) const override;
virtual ~ConicGradientStyleValue() override = default; virtual ~ConicGradientStyleValue() override = default;

View file

@ -104,7 +104,7 @@ float LinearGradientStyleValue::angle_degrees(CSSPixelSize gradient_size) const
}); });
} }
void LinearGradientStyleValue::resolve_for_size(Layout::NodeWithStyleAndBoxModelMetrics const& node, CSSPixelSize size) const void LinearGradientStyleValue::resolve_for_size(Layout::NodeWithStyle const& node, CSSPixelSize size) const
{ {
ResolvedDataCacheKey cache_key { ResolvedDataCacheKey cache_key {
.length_resolution_context = Length::ResolutionContext::for_layout_node(node), .length_resolution_context = Length::ResolutionContext::for_layout_node(node),

View file

@ -57,7 +57,7 @@ public:
float angle_degrees(CSSPixelSize gradient_size) const; float angle_degrees(CSSPixelSize gradient_size) const;
void resolve_for_size(Layout::NodeWithStyleAndBoxModelMetrics const&, CSSPixelSize) const override; void resolve_for_size(Layout::NodeWithStyle const&, CSSPixelSize) const override;
bool is_paintable() const override { return true; } bool is_paintable() const override { return true; }
void paint(PaintContext& context, DevicePixelRect const& dest_rect, CSS::ImageRendering image_rendering) const override; void paint(PaintContext& context, DevicePixelRect const& dest_rect, CSS::ImageRendering image_rendering) const override;

View file

@ -201,7 +201,7 @@ CSSPixelSize RadialGradientStyleValue::resolve_size(Layout::Node const& node, CS
return resolved_size; return resolved_size;
} }
void RadialGradientStyleValue::resolve_for_size(Layout::NodeWithStyleAndBoxModelMetrics const& node, CSSPixelSize paint_size) const void RadialGradientStyleValue::resolve_for_size(Layout::NodeWithStyle const& node, CSSPixelSize paint_size) const
{ {
CSSPixelRect gradient_box { { 0, 0 }, paint_size }; CSSPixelRect gradient_box { { 0, 0 }, paint_size };
auto center = m_properties.position->resolved(node, gradient_box); auto center = m_properties.position->resolved(node, gradient_box);

View file

@ -62,7 +62,7 @@ public:
bool is_paintable() const override { return true; } bool is_paintable() const override { return true; }
void resolve_for_size(Layout::NodeWithStyleAndBoxModelMetrics const&, CSSPixelSize) const override; void resolve_for_size(Layout::NodeWithStyle const&, CSSPixelSize) const override;
CSSPixelSize resolve_size(Layout::Node const&, CSSPixelPoint, CSSPixelRect const&) const; CSSPixelSize resolve_size(Layout::Node const&, CSSPixelPoint, CSSPixelRect const&) const;

View file

@ -15,7 +15,7 @@
namespace Web::Painting { namespace Web::Painting {
static ColorStopData resolve_color_stop_positions(Layout::NodeWithStyleAndBoxModelMetrics const& node, auto const& color_stop_list, auto resolve_position_to_float, bool repeating) static ColorStopData resolve_color_stop_positions(Layout::NodeWithStyle const& node, auto const& color_stop_list, auto resolve_position_to_float, bool repeating)
{ {
VERIFY(!color_stop_list.is_empty()); VERIFY(!color_stop_list.is_empty());
ColorStopList resolved_color_stops; ColorStopList resolved_color_stops;
@ -110,7 +110,7 @@ static ColorStopData resolve_color_stop_positions(Layout::NodeWithStyleAndBoxMod
return { resolved_color_stops, repeat_length }; return { resolved_color_stops, repeat_length };
} }
LinearGradientData resolve_linear_gradient_data(Layout::NodeWithStyleAndBoxModelMetrics const& node, CSSPixelSize gradient_size, CSS::LinearGradientStyleValue const& linear_gradient) LinearGradientData resolve_linear_gradient_data(Layout::NodeWithStyle const& node, CSSPixelSize gradient_size, CSS::LinearGradientStyleValue const& linear_gradient)
{ {
auto gradient_angle = linear_gradient.angle_degrees(gradient_size); auto gradient_angle = linear_gradient.angle_degrees(gradient_size);
auto gradient_length_px = Gfx::calculate_gradient_length(gradient_size.to_type<float>(), gradient_angle); auto gradient_length_px = Gfx::calculate_gradient_length(gradient_size.to_type<float>(), gradient_angle);
@ -124,7 +124,7 @@ LinearGradientData resolve_linear_gradient_data(Layout::NodeWithStyleAndBoxModel
return { gradient_angle, resolved_color_stops }; return { gradient_angle, resolved_color_stops };
} }
ConicGradientData resolve_conic_gradient_data(Layout::NodeWithStyleAndBoxModelMetrics const& node, CSS::ConicGradientStyleValue const& conic_gradient) ConicGradientData resolve_conic_gradient_data(Layout::NodeWithStyle const& node, CSS::ConicGradientStyleValue const& conic_gradient)
{ {
CSS::Angle one_turn(360.0f, CSS::Angle::Type::Deg); CSS::Angle one_turn(360.0f, CSS::Angle::Type::Deg);
auto resolved_color_stops = resolve_color_stop_positions( auto resolved_color_stops = resolve_color_stop_positions(
@ -135,7 +135,7 @@ ConicGradientData resolve_conic_gradient_data(Layout::NodeWithStyleAndBoxModelMe
return { conic_gradient.angle_degrees(), resolved_color_stops }; return { conic_gradient.angle_degrees(), resolved_color_stops };
} }
RadialGradientData resolve_radial_gradient_data(Layout::NodeWithStyleAndBoxModelMetrics const& node, CSSPixelSize gradient_size, CSS::RadialGradientStyleValue const& radial_gradient) RadialGradientData resolve_radial_gradient_data(Layout::NodeWithStyle const& node, CSSPixelSize gradient_size, CSS::RadialGradientStyleValue const& radial_gradient)
{ {
// Start center, goes right to ending point, where the gradient line intersects the ending shape // Start center, goes right to ending point, where the gradient line intersects the ending shape
auto resolved_color_stops = resolve_color_stop_positions( auto resolved_color_stops = resolve_color_stop_positions(

View file

@ -16,8 +16,8 @@
namespace Web::Painting { namespace Web::Painting {
LinearGradientData resolve_linear_gradient_data(Layout::NodeWithStyleAndBoxModelMetrics const&, CSSPixelSize, CSS::LinearGradientStyleValue const&); LinearGradientData resolve_linear_gradient_data(Layout::NodeWithStyle const&, CSSPixelSize, CSS::LinearGradientStyleValue const&);
ConicGradientData resolve_conic_gradient_data(Layout::NodeWithStyleAndBoxModelMetrics const&, CSS::ConicGradientStyleValue const&); ConicGradientData resolve_conic_gradient_data(Layout::NodeWithStyle const&, CSS::ConicGradientStyleValue const&);
RadialGradientData resolve_radial_gradient_data(Layout::NodeWithStyleAndBoxModelMetrics const&, CSSPixelSize, CSS::RadialGradientStyleValue const&); RadialGradientData resolve_radial_gradient_data(Layout::NodeWithStyle const&, CSSPixelSize, CSS::RadialGradientStyleValue const&);
} }