diff --git a/Tests/LibWeb/Ref/corner-clip-inside-scrollable.html b/Tests/LibWeb/Ref/corner-clip-inside-scrollable.html index 1cb355961b..a175ba9ea4 100644 --- a/Tests/LibWeb/Ref/corner-clip-inside-scrollable.html +++ b/Tests/LibWeb/Ref/corner-clip-inside-scrollable.html @@ -8,7 +8,6 @@ .box { width: 100px; height: 100px; - border: 5px solid black; border-radius: 50%; overflow: hidden; box-sizing: border-box; diff --git a/Tests/LibWeb/Ref/reference/corner-clip-inside-scrollable-ref.html b/Tests/LibWeb/Ref/reference/corner-clip-inside-scrollable-ref.html index 864eb34af3..b89bfdeda6 100644 --- a/Tests/LibWeb/Ref/reference/corner-clip-inside-scrollable-ref.html +++ b/Tests/LibWeb/Ref/reference/corner-clip-inside-scrollable-ref.html @@ -3,7 +3,6 @@ .box { width: 100px; height: 100px; - border: 5px solid black; border-radius: 50%; overflow: hidden; box-sizing: border-box; diff --git a/Tests/LibWeb/Ref/reference/images/css-background-clip-text.png b/Tests/LibWeb/Ref/reference/images/css-background-clip-text.png index ed6617f9bd..35b50ac077 100644 Binary files a/Tests/LibWeb/Ref/reference/images/css-background-clip-text.png and b/Tests/LibWeb/Ref/reference/images/css-background-clip-text.png differ diff --git a/Userland/Libraries/LibWeb/Painting/BorderPainting.cpp b/Userland/Libraries/LibWeb/Painting/BorderPainting.cpp index 4fbfce27da..adb2a19791 100644 --- a/Userland/Libraries/LibWeb/Painting/BorderPainting.cpp +++ b/Userland/Libraries/LibWeb/Painting/BorderPainting.cpp @@ -61,7 +61,7 @@ Gfx::Color border_color(BorderEdge edge, BordersDataDevicePixels const& borders_ return border_data.color; } -void paint_border(Gfx::Painter& painter, BorderEdge edge, DevicePixelRect const& rect, Gfx::AntiAliasingPainter::CornerRadius const& radius, Gfx::AntiAliasingPainter::CornerRadius const& opposite_radius, BordersDataDevicePixels const& borders_data, Gfx::Path& path, bool last) +void paint_border(RecordingPainter& painter, BorderEdge edge, DevicePixelRect const& rect, Gfx::AntiAliasingPainter::CornerRadius const& radius, Gfx::AntiAliasingPainter::CornerRadius const& opposite_radius, BordersDataDevicePixels const& borders_data, Gfx::Path& path, bool last) { auto const& border_data = [&] { switch (edge) { @@ -189,8 +189,9 @@ void paint_border(Gfx::Painter& painter, BorderEdge edge, DevicePixelRect const& // If joined borders have the same color, combine them to draw together. if (ready_to_draw) { path.close_all_subpaths(); - Gfx::AntiAliasingPainter aa_painter(painter); - aa_painter.fill_path(path, color, Gfx::Painter::WindingRule::EvenOdd); + painter.fill_path({ .path = path, + .color = color, + .winding_rule = Gfx::Painter::WindingRule::EvenOdd }); path.clear(); } }; @@ -490,7 +491,7 @@ void paint_border(Gfx::Painter& painter, BorderEdge edge, DevicePixelRect const& } } -void paint_all_borders(Gfx::Painter& painter, DevicePixelRect const& border_rect, CornerRadii const& corner_radii, BordersDataDevicePixels const& borders_data) +void paint_all_borders(RecordingPainter& painter, DevicePixelRect const& border_rect, CornerRadii const& corner_radii, BordersDataDevicePixels const& borders_data) { if (borders_data.top.width <= 0 && borders_data.right.width <= 0 && borders_data.left.width <= 0 && borders_data.bottom.width <= 0) return; diff --git a/Userland/Libraries/LibWeb/Painting/BorderPainting.h b/Userland/Libraries/LibWeb/Painting/BorderPainting.h index dbc7ef4f6a..196641d0a5 100644 --- a/Userland/Libraries/LibWeb/Painting/BorderPainting.h +++ b/Userland/Libraries/LibWeb/Painting/BorderPainting.h @@ -26,8 +26,8 @@ enum class BorderEdge { // Returns OptionalNone if there is no outline to paint. Optional borders_data_for_outline(Layout::Node const&, Color outline_color, CSS::OutlineStyle outline_style, CSSPixels outline_width); -void paint_border(Gfx::Painter& painter, BorderEdge edge, DevicePixelRect const& rect, Gfx::AntiAliasingPainter::CornerRadius const& radius, Gfx::AntiAliasingPainter::CornerRadius const& opposite_radius, BordersDataDevicePixels const& borders_data, Gfx::Path& path, bool last); -void paint_all_borders(Gfx::Painter& painter, DevicePixelRect const& border_rect, CornerRadii const& corner_radii, BordersDataDevicePixels const&); +void paint_border(RecordingPainter& painter, BorderEdge edge, DevicePixelRect const& rect, Gfx::AntiAliasingPainter::CornerRadius const& radius, Gfx::AntiAliasingPainter::CornerRadius const& opposite_radius, BordersDataDevicePixels const& borders_data, Gfx::Path& path, bool last); +void paint_all_borders(RecordingPainter& painter, DevicePixelRect const& border_rect, CornerRadii const& corner_radii, BordersDataDevicePixels const&); Gfx::Color border_color(BorderEdge edge, BordersDataDevicePixels const& borders_data); diff --git a/Userland/Libraries/LibWeb/Painting/Command.h b/Userland/Libraries/LibWeb/Painting/Command.h index d8c79586fb..bd90d2ec0a 100644 --- a/Userland/Libraries/LibWeb/Painting/Command.h +++ b/Userland/Libraries/LibWeb/Painting/Command.h @@ -379,19 +379,6 @@ struct BlitCornerClipping { void translate_by(Gfx::IntPoint const& offset) { border_rect.translate_by(offset); } }; -struct PaintBorders { - DevicePixelRect border_rect; - CornerRadii corner_radii; - BordersDataDevicePixels borders_data; - - [[nodiscard]] Gfx::IntRect bounding_rect() const { return border_rect.to_type(); } - - void translate_by(Gfx::IntPoint const& offset) - { - border_rect.translate_by(offset.to_type()); - } -}; - using Command = Variant< DrawGlyphRun, DrawText, @@ -421,7 +408,6 @@ using Command = Variant< DrawRect, DrawTriangleWave, SampleUnderCorners, - BlitCornerClipping, - PaintBorders>; + BlitCornerClipping>; } diff --git a/Userland/Libraries/LibWeb/Painting/CommandExecutorCPU.cpp b/Userland/Libraries/LibWeb/Painting/CommandExecutorCPU.cpp index 346b8d6a71..9fe7e1d09a 100644 --- a/Userland/Libraries/LibWeb/Painting/CommandExecutorCPU.cpp +++ b/Userland/Libraries/LibWeb/Painting/CommandExecutorCPU.cpp @@ -473,12 +473,6 @@ CommandResult CommandExecutorCPU::blit_corner_clipping(BlitCornerClipping const& return CommandResult::Continue; } -CommandResult CommandExecutorCPU::paint_borders(PaintBorders const& command) -{ - paint_all_borders(painter(), command.border_rect, command.corner_radii, command.borders_data); - return CommandResult::Continue; -} - bool CommandExecutorCPU::would_be_fully_clipped_by_painter(Gfx::IntRect rect) const { return !painter().clip_rect().intersects(rect.translated(painter().translation())); diff --git a/Userland/Libraries/LibWeb/Painting/CommandExecutorCPU.h b/Userland/Libraries/LibWeb/Painting/CommandExecutorCPU.h index 6e7fb173c4..aceba4441e 100644 --- a/Userland/Libraries/LibWeb/Painting/CommandExecutorCPU.h +++ b/Userland/Libraries/LibWeb/Painting/CommandExecutorCPU.h @@ -42,7 +42,6 @@ public: CommandResult draw_triangle_wave(DrawTriangleWave const&) override; CommandResult sample_under_corners(SampleUnderCorners const&) override; CommandResult blit_corner_clipping(BlitCornerClipping const&) override; - CommandResult paint_borders(PaintBorders const&) override; bool would_be_fully_clipped_by_painter(Gfx::IntRect) const override; diff --git a/Userland/Libraries/LibWeb/Painting/CommandExecutorGPU.cpp b/Userland/Libraries/LibWeb/Painting/CommandExecutorGPU.cpp index d534e479cf..1bac7f07ab 100644 --- a/Userland/Libraries/LibWeb/Painting/CommandExecutorGPU.cpp +++ b/Userland/Libraries/LibWeb/Painting/CommandExecutorGPU.cpp @@ -378,50 +378,6 @@ CommandResult CommandExecutorGPU::blit_corner_clipping(BlitCornerClipping const& return CommandResult::Continue; } -CommandResult CommandExecutorGPU::paint_borders(PaintBorders const& command) -{ - // FIXME: Add support for corner radiuses - - auto const& border_rect = command.border_rect; - auto const& borders_data = command.borders_data; - - Gfx::IntRect top_border_rect = { - border_rect.x(), - border_rect.y(), - border_rect.width(), - borders_data.top.width - }; - Gfx::IntRect right_border_rect = { - border_rect.x() + (border_rect.width() - borders_data.right.width), - border_rect.y(), - borders_data.right.width, - border_rect.height() - }; - Gfx::IntRect bottom_border_rect = { - border_rect.x(), - border_rect.y() + (border_rect.height() - borders_data.bottom.width), - border_rect.width(), - borders_data.bottom.width - }; - Gfx::IntRect left_border_rect = { - border_rect.x(), - border_rect.y(), - borders_data.left.width, - border_rect.height() - }; - - if (borders_data.top.width > 0) - painter().fill_rect(top_border_rect, borders_data.top.color); - if (borders_data.right.width > 0) - painter().fill_rect(right_border_rect, borders_data.right.color); - if (borders_data.bottom.width > 0) - painter().fill_rect(bottom_border_rect, borders_data.bottom.color); - if (borders_data.left.width > 0) - painter().fill_rect(left_border_rect, borders_data.left.color); - - return CommandResult::Continue; -} - bool CommandExecutorGPU::would_be_fully_clipped_by_painter(Gfx::IntRect rect) const { auto translation = painter().transform().translation().to_type(); diff --git a/Userland/Libraries/LibWeb/Painting/CommandExecutorGPU.h b/Userland/Libraries/LibWeb/Painting/CommandExecutorGPU.h index cb51d19ee0..33481a9a60 100644 --- a/Userland/Libraries/LibWeb/Painting/CommandExecutorGPU.h +++ b/Userland/Libraries/LibWeb/Painting/CommandExecutorGPU.h @@ -43,7 +43,6 @@ public: CommandResult draw_triangle_wave(DrawTriangleWave const&) override; CommandResult sample_under_corners(SampleUnderCorners const&) override; CommandResult blit_corner_clipping(BlitCornerClipping const&) override; - CommandResult paint_borders(PaintBorders const&) override; bool would_be_fully_clipped_by_painter(Gfx::IntRect) const override; diff --git a/Userland/Libraries/LibWeb/Painting/CommandList.cpp b/Userland/Libraries/LibWeb/Painting/CommandList.cpp index b48f761c6f..4435edb727 100644 --- a/Userland/Libraries/LibWeb/Painting/CommandList.cpp +++ b/Userland/Libraries/LibWeb/Painting/CommandList.cpp @@ -176,7 +176,6 @@ void CommandList::execute(CommandExecutor& executor) else HANDLE_COMMAND(DrawTriangleWave, draw_triangle_wave) else HANDLE_COMMAND(SampleUnderCorners, sample_under_corners) else HANDLE_COMMAND(BlitCornerClipping, blit_corner_clipping) - else HANDLE_COMMAND(PaintBorders, paint_borders) else VERIFY_NOT_REACHED(); // clang-format on diff --git a/Userland/Libraries/LibWeb/Painting/CommandList.h b/Userland/Libraries/LibWeb/Painting/CommandList.h index 16d70ce79d..959cb19cd4 100644 --- a/Userland/Libraries/LibWeb/Painting/CommandList.h +++ b/Userland/Libraries/LibWeb/Painting/CommandList.h @@ -76,7 +76,6 @@ public: virtual CommandResult draw_triangle_wave(DrawTriangleWave const&) = 0; virtual CommandResult sample_under_corners(SampleUnderCorners const&) = 0; virtual CommandResult blit_corner_clipping(BlitCornerClipping const&) = 0; - virtual CommandResult paint_borders(PaintBorders const&) = 0; virtual bool would_be_fully_clipped_by_painter(Gfx::IntRect) const = 0; virtual bool needs_prepare_glyphs_texture() const { return false; } virtual void prepare_glyph_texture(HashMap> const& unique_glyphs) = 0; diff --git a/Userland/Libraries/LibWeb/Painting/InlinePaintable.cpp b/Userland/Libraries/LibWeb/Painting/InlinePaintable.cpp index de4152f75f..4f230494cd 100644 --- a/Userland/Libraries/LibWeb/Painting/InlinePaintable.cpp +++ b/Userland/Libraries/LibWeb/Painting/InlinePaintable.cpp @@ -141,9 +141,9 @@ void InlinePaintable::paint(PaintContext& context, PaintPhase phase) const border_radii_data.inflate(outline_data->top.width + outline_offset_y, outline_data->right.width + outline_offset_x, outline_data->bottom.width + outline_offset_y, outline_data->left.width + outline_offset_x); borders_rect.inflate(outline_data->top.width + outline_offset_y, outline_data->right.width + outline_offset_x, outline_data->bottom.width + outline_offset_y, outline_data->left.width + outline_offset_x); - context.recording_painter().paint_borders(context.rounded_device_rect(borders_rect), border_radii_data.as_corners(context), outline_data->to_device_pixels(context)); + paint_all_borders(context.recording_painter(), context.rounded_device_rect(borders_rect), border_radii_data.as_corners(context), outline_data->to_device_pixels(context)); } else { - context.recording_painter().paint_borders(context.rounded_device_rect(borders_rect), border_radii_data.as_corners(context), borders_data.to_device_pixels(context)); + paint_all_borders(context.recording_painter(), context.rounded_device_rect(borders_rect), border_radii_data.as_corners(context), borders_data.to_device_pixels(context)); } return IterationDecision::Continue; diff --git a/Userland/Libraries/LibWeb/Painting/RecordingPainter.cpp b/Userland/Libraries/LibWeb/Painting/RecordingPainter.cpp index a3a5c64b81..3424ffccc6 100644 --- a/Userland/Libraries/LibWeb/Painting/RecordingPainter.cpp +++ b/Userland/Libraries/LibWeb/Painting/RecordingPainter.cpp @@ -419,11 +419,4 @@ void RecordingPainter::draw_triangle_wave(Gfx::IntPoint a_p1, Gfx::IntPoint a_p2 .thickness = thickness }); } -void RecordingPainter::paint_borders(DevicePixelRect const& border_rect, CornerRadii const& corner_radii, BordersDataDevicePixels const& borders_data) -{ - if (borders_data.top.width == 0 && borders_data.right.width == 0 && borders_data.bottom.width == 0 && borders_data.left.width == 0) - return; - append(PaintBorders { border_rect, corner_radii, borders_data }); -} - } diff --git a/Userland/Libraries/LibWeb/Painting/RecordingPainter.h b/Userland/Libraries/LibWeb/Painting/RecordingPainter.h index 4f1e9d646b..9798cefd28 100644 --- a/Userland/Libraries/LibWeb/Painting/RecordingPainter.h +++ b/Userland/Libraries/LibWeb/Painting/RecordingPainter.h @@ -141,8 +141,6 @@ public: void draw_triangle_wave(Gfx::IntPoint a_p1, Gfx::IntPoint a_p2, Color color, int amplitude, int thickness); - void paint_borders(DevicePixelRect const& border_rect, CornerRadii const& corner_radii, BordersDataDevicePixels const& borders_data); - RecordingPainter(CommandList& commands_list); ~RecordingPainter(); diff --git a/Userland/Libraries/LibWeb/Painting/TableBordersPainting.cpp b/Userland/Libraries/LibWeb/Painting/TableBordersPainting.cpp index 1a06ddc14c..f4bdda158f 100644 --- a/Userland/Libraries/LibWeb/Painting/TableBordersPainting.cpp +++ b/Userland/Libraries/LibWeb/Painting/TableBordersPainting.cpp @@ -351,7 +351,7 @@ static void paint_separate_cell_borders(PaintableBox const& cell_box, HashMaprow_index, cell_box.table_cell_coordinates()->column_index }).value(); - context.recording_painter().paint_borders(cell_rect, cell_box.normalized_border_radii_data().as_corners(context), borders_data.to_device_pixels(context)); + paint_all_borders(context.recording_painter(), cell_rect, cell_box.normalized_border_radii_data().as_corners(context), borders_data.to_device_pixels(context)); } void paint_table_borders(PaintContext& context, PaintableBox const& table_paintable) @@ -436,7 +436,7 @@ void paint_table_borders(PaintContext& context, PaintableBox const& table_painta .bottom = cell_box.box_model().border.bottom == 0 ? CSS::BorderData() : cell_box.computed_values().border_bottom(), .left = cell_box.box_model().border.left == 0 ? CSS::BorderData() : cell_box.computed_values().border_left(), }; - context.recording_painter().paint_borders(context.rounded_device_rect(cell_box.absolute_border_box_rect()), cell_box.normalized_border_radii_data().as_corners(context), borders_data.to_device_pixels(context)); + paint_all_borders(context.recording_painter(), context.rounded_device_rect(cell_box.absolute_border_box_rect()), cell_box.normalized_border_radii_data().as_corners(context), borders_data.to_device_pixels(context)); } } }