Truly independent web browser
LibWeb: Join fieldset border corners next to a legend
Andreas Kling6e7c1cd526e8
diff --git a/Libraries/LibWeb/Rust/src/painting/record/paint/fieldset.rs b/Libraries/LibWeb/Rust/src/painting/record/paint/fieldset.rsindex bdda5aadd81..9fd05d92bac 100644--- a/Libraries/LibWeb/Rust/src/painting/record/paint/fieldset.rs+++ b/Libraries/LibWeb/Rust/src/painting/record/paint/fieldset.rs@@ -61,22 +61,16 @@ pub(crate) fn visual_border_box_rect(arena: &impl PaintRead, fieldset: NodeSlotIrect}-pub(crate) struct FieldsetBordersData {- pub without_top: BordersDataDevicePixels,- pub top_only: BordersDataDevicePixels,-}-pub(crate) fn fieldset_borders_data(style: ComputedValuesView<'_>,converter: &DevicePixelConverter,-) -> FieldsetBordersData {+) -> BordersDataDevicePixels {let side = |color: u32, line_style: u8, width: CssPixels| BorderDataDevicePixels {color: Color(color),line_style,width: converter.enclosing_device_pixels(width),};- let none = BorderDataDevicePixels::default();- let all = BordersDataDevicePixels {+ BordersDataDevicePixels {force_dark_role: ForceDarkRole::Border,top: side(style.border_top_color(),@@ -98,15 +92,6 @@ pub(crate) fn fieldset_borders_data(style.border_left_style(),style.border_left_width(),),- };- FieldsetBordersData {- without_top: BordersDataDevicePixels { top: none, ..all },- top_only: BordersDataDevicePixels {- right: none,- bottom: none,- left: none,- ..all- },}}@@ -132,21 +117,11 @@ pub(crate) fn paint_border<O: Observer>(recorder: &mut PaintRecorder<'_, O>, fielet device_border_rect = converter.rounded_device_rect(visual_border_box_rect(recorder.source, fieldset));let corners = recorder.border_radii(fieldset).as_corners(&converter);let borders = fieldset_borders_data(style, &converter);- paint_all_borders(- &mut recorder.recorder,- device_border_rect,- corners,- &borders.without_top,- );// The top border is not expected to be painted behind the border box of the legend.+ // NB: The cutout only covers the top border band, so all the borders are painted together and their corners join+ // as they would without a legend.let top_border = converter.enclosing_device_pixels(css_border_top_width(recorder.source, fieldset));- let top_border_band = IntRect::new(- device_border_rect.x,- device_border_rect.y,- device_border_rect.width,- top_border,- );let legend_border_rect = converter.rounded_device_rect(absolute_border_box_rect(recorder.source, legend));let legend_cutout = IntRect::new(legend_border_rect.x,@@ -154,11 +129,8 @@ pub(crate) fn paint_border<O: Observer>(recorder: &mut PaintRecorder<'_, O>, fielegend_border_rect.width,top_border,);- let top_border_inline_clips = [- PendingInlineClip::intersecting_float_rect(top_border_band.to_float()),- PendingInlineClip::subtracting_rect(legend_cutout.to_float()),- ];- recorder.record_with_inline_clips(&top_border_inline_clips, |recorder| {- paint_all_borders(&mut recorder.recorder, device_border_rect, corners, &borders.top_only);+ let legend_cutout_clip = [PendingInlineClip::subtracting_rect(legend_cutout.to_float())];+ recorder.record_with_inline_clips(&legend_cutout_clip, |recorder| {+ paint_all_borders(&mut recorder.recorder, device_border_rect, corners, &borders);});}diff --git a/Tests/LibWeb/Text/expected/display_list/fieldset-background-with-legend.txt b/Tests/LibWeb/Text/expected/display_list/fieldset-background-with-legend.txtindex dc5482bce16..cabfaae6457 100644--- a/Tests/LibWeb/Text/expected/display_list/fieldset-background-with-legend.txt+++ b/Tests/LibWeb/Text/expected/display_list/fieldset-background-with-legend.txt@@ -7,14 +7,14 @@ AccumulatedVisualContext Tree:DisplayList:FillRect@s1/e0 rect=[10,8 780x50] color=rgb(0, 0, 255) inline_clips=[clip=[10,15 780x43]]-FillPath@s1/e0 path_bounding_rect=[789,15 1x43]-FillPath@s1/e0 path_bounding_rect=[788,14 1x43]-FillPath@s1/e0 path_bounding_rect=[10,57 780x1]-FillPath@s1/e0 path_bounding_rect=[11,56 778x1]-FillPath@s1/e0 path_bounding_rect=[10,15 1x43]-FillPath@s1/e0 path_bounding_rect=[11,14 1x43]-FillPath@s1/e0 path_bounding_rect=[10,15 780x1] inline_clips=[clip=[10,15 780x2], clip=[24,15 57x2] mode=difference]-FillPath@s1/e0 path_bounding_rect=[9,16 782x1] inline_clips=[clip=[10,15 780x2], clip=[24,15 57x2] mode=difference]+FillPath@s1/e0 path_bounding_rect=[10,15 780x1] inline_clips=[clip=[24,15 57x2] mode=difference]+FillPath@s1/e0 path_bounding_rect=[11,16 778x1] inline_clips=[clip=[24,15 57x2] mode=difference]+FillPath@s1/e0 path_bounding_rect=[789,15 1x43] inline_clips=[clip=[24,15 57x2] mode=difference]+FillPath@s1/e0 path_bounding_rect=[788,16 1x41] inline_clips=[clip=[24,15 57x2] mode=difference]+FillPath@s1/e0 path_bounding_rect=[10,57 780x1] inline_clips=[clip=[24,15 57x2] mode=difference]+FillPath@s1/e0 path_bounding_rect=[11,56 778x1] inline_clips=[clip=[24,15 57x2] mode=difference]+FillPath@s1/e0 path_bounding_rect=[10,15 1x43] inline_clips=[clip=[24,15 57x2] mode=difference]+FillPath@s1/e0 path_bounding_rect=[11,16 1x41] inline_clips=[clip=[24,15 57x2] mode=difference]DrawGlyphRun@s1/e0 rect=[26,8 54x16] translation=[26,20.796875] color=rgb(0, 0, 0)DrawGlyphRun@s1/e0 rect=[24,29 63x16] translation=[24,42.390625] color=rgb(0, 0, 0)diff --git a/Tests/LibWeb/Text/expected/display_list/fieldset-legend-rounded-dashed-border.txt b/Tests/LibWeb/Text/expected/display_list/fieldset-legend-rounded-dashed-border.txtnew file mode 100644index 00000000000..0b265673334--- /dev/null+++ b/Tests/LibWeb/Text/expected/display_list/fieldset-legend-rounded-dashed-border.txt@@ -0,0 +1,12 @@+AccumulatedVisualContext Tree:+ spatial:+ [s0] transform=[1,0,0,1,0,0] origin=(0,0) (Viewport<#document>)+ [s1] scroll (Viewport<#document>)+ effects:+ [e0 in s0] effects=[]++DisplayList:+StrokePath@s1/e0 path_bounding_rect=[10,15 230x44] thickness=3 color=rgb(0, 0, 255) dash_array_size=2 dash_offset=9.03 inline_clips=[clip=[25,15 57x3] mode=difference]+DrawGlyphRun@s1/e0 rect=[27,8 54x16] translation=[27,20.796875] color=rgb(0, 0, 0)+DrawGlyphRun@s1/e0 rect=[25,29 63x16] translation=[25,42.390625] color=rgb(0, 0, 0)+diff --git a/Tests/LibWeb/Text/input/display_list/fieldset-legend-rounded-dashed-border.html b/Tests/LibWeb/Text/input/display_list/fieldset-legend-rounded-dashed-border.htmlnew file mode 100644index 00000000000..9fb3e4814cf--- /dev/null+++ b/Tests/LibWeb/Text/input/display_list/fieldset-legend-rounded-dashed-border.html@@ -0,0 +1,15 @@+<!DOCTYPE html>+<script src="../include.js"></script>+<style>+ fieldset {+ border: 3px dashed blue;+ border-radius: 12px;+ width: 200px;+ }+</style>+<fieldset><legend>Legend</legend>Content</fieldset>+<script>+ test(() => {+ println(internals.dumpDisplayList());+ });+</script>