Truly independent web browser
LibWeb: Record the caret of an empty inline as a caret
Aliaksandr Kalenik2a0959307010
diff --git a/Libraries/LibWeb/Rust/src/painting/record/paint/inline_box.rs b/Libraries/LibWeb/Rust/src/painting/record/paint/inline_box.rsindex 95708879ed8..a1fec7b2af7 100644--- a/Libraries/LibWeb/Rust/src/painting/record/paint/inline_box.rs+++ b/Libraries/LibWeb/Rust/src/painting/record/paint/inline_box.rs@@ -9,7 +9,6 @@ use crate::painting::record::trace::Observer;use crate::css::css_pixels::{CssPixelRect, CssPixels};use crate::layout::node_data::NodeSlotId;-use crate::painting::force_dark::ForceDarkRole;use crate::painting::record::paint::background_resolution::body_background_is_propagated_to_root;use crate::painting::record::paint::border::{ALL_PIECE_EDGES, paint_box_borders, present_css_border_widths, style_borders_data,@@ -269,7 +268,9 @@ fn paint_pieces<O: Observer>(let color = caret.color;if color.alpha() != 0 {let rect = recorder.converter.rounded_device_rect(caret.rect);- recorder.recorder.fill_rect(rect, color, ForceDarkRole::Foreground);+ recorder+ .recorder+ .paint_caret(rect, color, caret.blink_cycle_start_time_ns, caret.should_blink);}}}diff --git a/Tests/LibWeb/Text/expected/display_list/empty-inline-caret.txt b/Tests/LibWeb/Text/expected/display_list/empty-inline-caret.txtnew file mode 100644index 00000000000..d6ae1d0d913--- /dev/null+++ b/Tests/LibWeb/Text/expected/display_list/empty-inline-caret.txt@@ -0,0 +1,19 @@+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=[]++Layers (for a window server that shows tiles and filters what is below layers):+ [L0] base space=viewport held by the frame: it is under a layer the frame holds+ [L1] caret #0 space=viewport region=[71,5 7x22]+ [L2] painted space=viewport above L1++DisplayList:+L0 DrawGlyphRun@s1/e0 font_id=font1 glyphs=7 rect=[8,8 61x16] glyph_bounding_rect=[8,8 66x15] translation=[8,21] color=rgb(0, 0, 0) text="before " owner=BlockContainer<DIV> phase=text-fragment+L0 FillRoundedRectRing@s1/e0 rect=[69,7 10x18] top_width=1 right_width=1 bottom_width=1 left_width=1 color=rgb(0, 0, 0) owner=BlockContainer<DIV> phase=inline-piece+L0 DrawGlyphRun@s1/e0 font_id=font1 glyphs=5 rect=[78,8 41x16] glyph_bounding_rect=[79,8 45x15] translation=[78.53125,21] color=rgb(0, 0, 0) text="after" owner=BlockContainer<DIV> phase=text-fragment+L1 PaintCaret@s1/e0 rect=[74,8 1x16] color=rgb(0, 0, 0) blink_cycle_start_time_ns=t1 owner=InlineNode<SPAN> phase=foreground+L2 FillRoundedRectRing@s1/e0 rect=[67,5 14x22] top_width=2 right_width=2 bottom_width=2 left_width=2 color=rgb(61, 174, 233) owner=InlineNode<SPAN> phase=outline+diff --git a/Tests/LibWeb/Text/input/display_list/empty-inline-caret.html b/Tests/LibWeb/Text/input/display_list/empty-inline-caret.htmlnew file mode 100644index 00000000000..019a1322f2a--- /dev/null+++ b/Tests/LibWeb/Text/input/display_list/empty-inline-caret.html@@ -0,0 +1,9 @@+<!DOCTYPE html>+<script src="../include.js"></script>+<div>before <span contenteditable style="padding: 0 4px; border: 1px solid black"></span> after</div>+<script>+ test(() => {+ document.querySelector("span").focus();+ println(internals.dumpDisplayList());+ });+</script>