diff --git a/Libraries/LibWeb/Painting/PaintableBox.cpp b/Libraries/LibWeb/Painting/PaintableBox.cpp index 60d66492fe6..7d0fd9939ef 100644 --- a/Libraries/LibWeb/Painting/PaintableBox.cpp +++ b/Libraries/LibWeb/Painting/PaintableBox.cpp @@ -934,6 +934,10 @@ void paint_text_fragment(DisplayListRecordingContext& context, TextPaintable con if (!glyph_run) return; + auto selection_rect = context.enclosing_device_rect(fragment.selection_rect()).to_type(); + if (!selection_rect.is_empty()) + painter.fill_rect(selection_rect, CSS::SystemColor::highlight(paintable.computed_values().color_scheme())); + auto scale = context.device_pixels_per_css_pixel(); auto baseline_start = Gfx::FloatPoint { fragment_absolute_rect.x().to_float(), @@ -941,14 +945,6 @@ void paint_text_fragment(DisplayListRecordingContext& context, TextPaintable con } * scale; painter.draw_glyph_run(baseline_start, *glyph_run, paintable.computed_values().webkit_text_fill_color(), fragment_enclosing_device_rect, scale, fragment.orientation()); - auto selection_rect = context.enclosing_device_rect(fragment.selection_rect()).to_type(); - if (!selection_rect.is_empty()) { - painter.fill_rect(selection_rect, CSS::SystemColor::highlight(paintable.computed_values().color_scheme())); - DisplayListRecorderStateSaver saver(painter); - painter.add_clip_rect(selection_rect); - painter.draw_glyph_run(baseline_start, *glyph_run, CSS::SystemColor::highlight_text(paintable.computed_values().color_scheme()), fragment_enclosing_device_rect, scale, fragment.orientation()); - } - paint_text_decoration(context, paintable, fragment); paint_cursor_if_needed(context, paintable, fragment); } diff --git a/Tests/LibWeb/Screenshot/expected/selection-text-color-ref.html b/Tests/LibWeb/Screenshot/expected/selection-text-color-ref.html new file mode 100644 index 00000000000..38686b74121 --- /dev/null +++ b/Tests/LibWeb/Screenshot/expected/selection-text-color-ref.html @@ -0,0 +1,7 @@ + + + diff --git a/Tests/LibWeb/Screenshot/images/selection-start-in-end-node-ref.png b/Tests/LibWeb/Screenshot/images/selection-start-in-end-node-ref.png index 7fc8f2747c6..2cc75b61167 100644 Binary files a/Tests/LibWeb/Screenshot/images/selection-start-in-end-node-ref.png and b/Tests/LibWeb/Screenshot/images/selection-start-in-end-node-ref.png differ diff --git a/Tests/LibWeb/Screenshot/images/selection-text-color-ref.png b/Tests/LibWeb/Screenshot/images/selection-text-color-ref.png new file mode 100644 index 00000000000..4156880ce97 Binary files /dev/null and b/Tests/LibWeb/Screenshot/images/selection-text-color-ref.png differ diff --git a/Tests/LibWeb/Screenshot/input/selection-start-in-end-node-2.html b/Tests/LibWeb/Screenshot/input/selection-start-in-end-node-2.html index 41f113a5203..cc98a8ebce8 100644 --- a/Tests/LibWeb/Screenshot/input/selection-start-in-end-node-2.html +++ b/Tests/LibWeb/Screenshot/input/selection-start-in-end-node-2.html @@ -1,6 +1,6 @@ - + End Node Start Node NOT SELECTED