Truly independent web browser
LibCompositing+Compositor: Give each caret a layer
Aliaksandr Kalenikeacac6c22009
diff --git a/Libraries/LibCompositing/Rust/src/display_list/builder.rs b/Libraries/LibCompositing/Rust/src/display_list/builder.rsindex 0779c5842b6..06e2ea40a18 100644--- a/Libraries/LibCompositing/Rust/src/display_list/builder.rs+++ b/Libraries/LibCompositing/Rust/src/display_list/builder.rs@@ -179,6 +179,28 @@ pub fn bounding_rect_computed_from_payload(header: &DisplayListCommandHeader, pa)}+/// Whether a record whose bounds meet `rect` can paint within it. A ring paints nothing where `rect` lies inside its+/// inner edge, as the focus ring of a field does nowhere over the field's caret.+pub fn record_can_paint_within(header: &DisplayListCommandHeader, payload: &[u8], rect: IntRect) -> bool {+ if header.command_type != DisplayListCommandType::FillRoundedRectRing || header.has_inline_transform {+ return true;+ }+ let ring = read_command::<FillRoundedRectRing>(payload);+ let inner = ring+ .rect+ .shrunken(ring.top_width, ring.right_width, ring.bottom_width, ring.left_width);+ // The rounded corners of the inner edge reach into it no farther than the largest radius, so a rect clear of+ // those corners lies inside the inner rect made that much narrower or that much shorter.+ let radii = ring.corner_radii;+ let corner = [radii.top_left, radii.top_right, radii.bottom_right, radii.bottom_left]+ .iter()+ .map(|radius| radius.horizontal_radius.max(radius.vertical_radius).max(0))+ .max()+ .unwrap_or(0);+ !inner.shrunken(0, corner, 0, corner).contains_rect(rect)+ && !inner.shrunken(corner, 0, corner, 0).contains_rect(rect)+}+// A finished tape together with the run table summarizing it and the chunks it is cut into.#[derive(Clone, Default)]pub struct RecordedDisplayList {diff --git a/Libraries/LibCompositing/Rust/src/display_list/commands.rs b/Libraries/LibCompositing/Rust/src/display_list/commands.rsindex 8d4ab0ebbfc..946a4b599bc 100644--- a/Libraries/LibCompositing/Rust/src/display_list/commands.rs+++ b/Libraries/LibCompositing/Rust/src/display_list/commands.rs@@ -94,13 +94,17 @@ impl DisplayListCommandType {)}- /// A top-level record of this command is the only record of its run: a canvas, video or nested context, which the- /// compositor can give a layer of its own between the records around it, and a scroll bar, which draws what the- /// frame shows of its scroller rather than what the list holds.+ /// A top-level record of this command is the only record of its run: a canvas, video, nested context or caret,+ /// which the compositor can give a layer of its own between the records around it, and a scroll bar, which draws+ /// what the frame shows of its scroller rather than what the list holds.pub const fn is_alone_in_its_run(self) -> bool {matches!(self,- Self::DrawCanvas | Self::DrawVideoFrame | Self::DrawCompositedContext | Self::PaintScrollBar+ Self::DrawCanvas+ | Self::DrawVideoFrame+ | Self::DrawCompositedContext+ | Self::PaintCaret+ | Self::PaintScrollBar)}diff --git a/Libraries/LibCompositing/Rust/src/display_list/layers.rs b/Libraries/LibCompositing/Rust/src/display_list/layers.rsindex 09800128ec1..c42f57a338b 100644--- a/Libraries/LibCompositing/Rust/src/display_list/layers.rs+++ b/Libraries/LibCompositing/Rust/src/display_list/layers.rs@@ -10,11 +10,13 @@//! Content is rastered in the space of the scroll node, sticky box or node whose transform the compositor animates//! that it moves with, and its raster is composited within the clips it leaves to apply then (its composite clips), and//! inside the effects the compositor applies to it: content of one space, one set of composite clips and at most one-//! composited effect makes a placement node. The records of a node are cut into bands. Within a band, a canvas, video-//! or nested context that is a layer of its own, and each band of a node nested in it, sits between the band's records-//! as a barrier. A barrier cuts the band's tiles that it can show in, or for an effect that reads what is composited-//! below it, that it reads, at its paint position: there, the band's records painted before the barrier go into the-//! layer below the cut and those painted after it into the layer above the cut. Elsewhere it cuts nothing.+//! composited effect makes a placement node. The records of a node are cut into bands. Within a band, a canvas, video,+//! nested context or caret that is a layer of its own, and each band of a node nested in it, sits between the band's+//! records as a barrier. A barrier cuts the band's tiles that it can show in, or for an effect that reads what is+//! composited below it, that it reads, at its paint position: there, the band's records painted before the barrier go+//! into the layer below the cut and those painted after it into the layer above the cut. Elsewhere it cuts nothing. A+//! canvas, video, nested context or caret cuts no tile where no record of its band painted after it can show where it+//! can.use crate::display_list::commands::ClipNodeIndex;use crate::display_list::commands::{EffectNodeIndex, SpatialNodeIndex};@@ -69,6 +71,7 @@ pub(crate) fn media_name(content: LiveContent) -> &'static str {LiveContent::VideoFrame(_) => "video",LiveContent::ImageFrame(_) => "image",LiveContent::CompositedContext(_) => "composited context",+ LiveContent::Caret => "caret",}}@@ -169,7 +172,7 @@ pub struct PlacementNodeIdentity(pub u64);#[derive(Clone, Copy, Debug, PartialEq, Eq, Hash)]pub enum BarrierIdentity {- /// The `ordinal`th drawing of a canvas, video or nested context in paint order.+ /// The `ordinal`th drawing of a canvas, video, nested context or caret in paint order.Media { content: LiveContent, ordinal: u32 },/// The `band_ordinal_in_node`th band of content of a node, counted over the whole list.NestedNodeBand {@@ -362,8 +365,8 @@ pub enum BarrierCutsOfCell {pub enum LayerContent {/// The records of a band that the layer holds in some of its tiles.Painted,- /// A canvas, video or nested context, replayed or shown by the window server, whose content the identity of the- /// layer names.+ /// A canvas, video, nested context or caret, replayed or shown by the window server, whose content the identity of+ /// the layer names.Media { record_span: ListSpan },}@@ -681,13 +684,15 @@ struct CutOfPlan {#[derive(Clone, Copy, Debug)]enum BarrierOfPlan {- /// A canvas, video or nested context that is a layer of its own, the `ordinal`th drawing of its content in paint- /// order, which cuts the tiles its reach touches.+ /// A canvas, video, nested context or caret that is a layer of its own, the `ordinal`th drawing of its content in+ /// paint order. Where `cuts_band` is set, it cuts the tiles its reach touches, and otherwise no tile, as no record+ /// of the band painted after it can show where it can.Media {content: LiveContent,ordinal: u32,record_span: ListSpan,reach: IntRect,+ cuts_band: bool,},/// The next band of the walk, which is of a node in the band's node and cuts the tiles that node reaches.NestedBand,@@ -784,8 +789,8 @@ impl LayerStack {/// The stack of a plan of more than one layer, as the planner and the compositor both work it out. The layers come/// in the order of the walk of the bands: a band's layer below all cuts, then per cut the layers of its barrier,- /// which are a canvas, video or nested context or those of the nested band, and the layer above the cut. The- /// ordinal of a band in its node counts the bands of the node before it in the walk. The base layer is the first+ /// which are a canvas, video, nested context or caret or those of the nested band, and the layer above the cut.+ /// The ordinal of a band in its node counts the bands of the node before it in the walk. The base layer is the first/// layer that can hold content where that is the layer below all cuts of a band of a node that covers the viewport,/// and the first layer otherwise.///@@ -854,6 +859,7 @@ impl LayerStack {ordinal,record_span,reach,+ cuts_band,},reach_of_layer_above_cut,}) => {@@ -870,7 +876,11 @@ impl LayerStack {layers.push(layer);bands[band_index.0].cuts.push(BarrierCut {barrier_first_record_position: record_span.begin,- cut_reach: Reach::Within(reach),+ cut_reach: if cuts_band {+ Reach::Within(reach)+ } else {+ Reach::Nothing+ },layer_above_cut: LayerIndex(layers.len() - 1),});}@@ -1464,7 +1474,7 @@ impl LayerStack {viewport_rect: IntRect,) -> WindowServerPlacementsOfMedia {let window_server_may_show_content =- |content: &LiveContent| !matches!(content, LiveContent::CompositedContext(_));+ |content: &LiveContent| !matches!(content, LiveContent::CompositedContext(_) | LiveContent::Caret);let has_media_the_window_server_may_show = self.layers.iter().any(|layer| {matches!(&layer.identity, LayerIdentity::Media { content, .. } if window_server_may_show_content(content))});@@ -1532,7 +1542,7 @@ impl LayerStack {name}- // The layer right below a layer above a cut is the layer of the cut's canvas, video or nested context, or the+ // The layer right below a layer above a cut is the layer of the cut's canvas, video, nested context or caret, or the// topmost layer of the cut's nested band.fn name_of_barrier_below(&self, layer_index: LayerIndex, node_namer: &dyn VisualContextNodeNamer) -> String {let layer_below = &self.layers[layer_index.0 - 1];diff --git a/Libraries/LibCompositing/Rust/src/display_list/layers/planning.rs b/Libraries/LibCompositing/Rust/src/display_list/layers/planning.rsindex 7c1101e5ab8..109f0885136 100644--- a/Libraries/LibCompositing/Rust/src/display_list/layers/planning.rs+++ b/Libraries/LibCompositing/Rust/src/display_list/layers/planning.rs@@ -22,17 +22,18 @@ use super::{WhyCompositorCannotCompositeEffect, WhyListIsOneLayer, media_name,};use crate::display_list::animated_transform_spaces::{effect_reads_below_it, spatial_nodes_under_transform_animations};+use crate::display_list::builder::{bounding_rect_computed_from_payload, record_can_paint_within};use crate::display_list::commands::{DisplayListCommandType, EffectNodeIndex, SpatialNodeIndex};use crate::display_list::effect_geometry::{FiltersOfEffects, KeyframeFiltersOfEffects, backdrop_filter_read_reach, filter_may_spread_at_some_sample,filter_read_reach_in_device_pixels,};use crate::display_list::placement::{- CompositeClip, FiltersAndClipsOfList, RasterSpace, RasterSpaceAnchorKind, RasterSpaceGeometry, RasterSpaceIndex,- RunGroupIndex, RunGroups, enclosing_int_rect_within_extent_limit, is_finite_rect,+ ANTIALIASING_MARGIN_IN_DEVICE_PIXELS, CompositeClip, FiltersAndClipsOfList, RasterSpace, RasterSpaceAnchorKind,+ RasterSpaceIndex, RunGroupIndex, RunGroups, enclosing_int_rect_within_extent_limit, is_finite_rect,};use crate::display_list::reach::Reach;-use crate::display_list::storage::{DisplayListStorage, ListPosition, ListSpan, RunIndexInList};+use crate::display_list::storage::{DisplayListStorage, ListPosition, ListSpan, RunIndexInChunk, RunIndexInList};use crate::display_list::summary::{IndexedRecord, LiveContent};use crate::display_list::tiles::{CellRange, reaches_too_many_cells_to_follow_one_by_one, tile_coords_touching};use crate::visual_context::queries::{BackdropReader, NestingOfLiveEffects, backdrop_reader_by_reading_effect_index};@@ -107,6 +108,8 @@ pub enum WhyMediaHasNoLayer {MoreMediaThanLayersFor,SortedByDepthInA3DSortingContext,InsideAnEffectTheCompositorCannotComposite(WhyCompositorCannotCompositeEffect),+ InsideAnEffectThatPushesALayerAtReplay,+ MovesWithinItsSpace,}impl std::fmt::Display for WhyMediaHasNoLayer {@@ -120,6 +123,10 @@ impl std::fmt::Display for WhyMediaHasNoLayer {WhyMediaHasNoLayer::InsideAnEffectTheCompositorCannotComposite(why) => {return write!(formatter, "inside a {why}");}+ WhyMediaHasNoLayer::InsideAnEffectThatPushesALayerAtReplay => {+ "inside an effect that pushes a layer at replay"+ }+ WhyMediaHasNoLayer::MovesWithinItsSpace => "moves within its space",})}}@@ -275,7 +282,7 @@ pub struct PlacedEffect {pub why_composited_regardless_of_layer_content: Option<WhyEffectIsComposited>,}-/// A canvas, video or nested context that is a layer of its own, alone in its run.+/// A canvas, video, nested context or caret that is a layer of its own, alone in its run.#[derive(Clone, Copy, Debug, PartialEq)]pub struct PlacedMedia {pub content: LiveContent,@@ -285,6 +292,10 @@ pub struct PlacedMedia {pub run_index: RunIndexInList,/// Where it can show, in the raster coordinates of the space of its run's group.pub reach: IntRect,+ /// Whether a record painted after it can show where it can, so that it cuts the tiles it touches. Where none can, it+ /// cuts none, and the records of its band painted after it stay in the layers below it, such as the base layer,+ /// where text takes LCD antialiasing.+ pub cuts_band: bool,}/// Where each part of a list is placed at the spaces a tree offers, under the values a frame shows. What it decides@@ -898,10 +909,9 @@ impl<'a> ListBeingPlaced<'a> {Some(WhyMediaHasNoLayer::SortedByDepthInA3DSortingContext)} else {self.why_media_has_no_layer(- &self.geometries[self.space_of_run(runs, run_index as usize).0].raster,- run_index,- record_position,- runs.reach_of_run_by_run_index[run_index as usize],+ runs,+ content,+ record,spatial_node_is_under_transform_animation_leaving_plane.get(list.run(run_index as usize).context.spatial.0 as usize).copied()@@ -913,23 +923,28 @@ impl<'a> ListBeingPlaced<'a> {let record_span = list.span_of_run(run_index as usize);debug_assert_eq!(record_position, record_span.begin,- "a canvas, video or nested context is alone in its run"+ "a canvas, video, nested context or caret is alone in its run");+ let reach = runs.reach_of_run_by_run_index[run_index as usize];placed_media.push(PlacedMedia {content,ordinal: 0,record_span,run_index: RunIndexInList(run_index),- reach: runs.reach_of_run_by_run_index[run_index as usize],+ reach,+ cuts_band: self.record_painted_after_can_show_over(runs, run_index as usize, reach),});}Some(why_no_layer) => media_without_layers.push((content, why_no_layer)),}}if placed_media.len() > MAXIMUM_MEDIA_LAYER_COUNT {- let nested_contexts_after_canvases_and_videos =- |media: &PlacedMedia| matches!(media.content, LiveContent::CompositedContext(_));- placed_media.sort_by_key(nested_contexts_after_canvases_and_videos);+ let canvases_and_videos_then_nested_contexts_then_carets = |media: &PlacedMedia| match media.content {+ LiveContent::CompositedContext(_) => 1,+ LiveContent::Caret => 2,+ _ => 0,+ };+ placed_media.sort_by_key(canvases_and_videos_then_nested_contexts_then_carets);for media_past_limit in placed_media.drain(MAXIMUM_MEDIA_LAYER_COUNT..) {media_without_layers.push((media_past_limit.content, WhyMediaHasNoLayer::MoreMediaThanLayersFor));}@@ -945,38 +960,91 @@ impl<'a> ListBeingPlaced<'a> {}// Under a transform animation that leaves the plane, a sample can draw the media through a matrix that is not 2D- // affine, whatever the tree holds.+ // affine, whatever the tree holds. A caret does not get the effects around it composited, as the other media do:+ // it has no layer inside an effect that a replay draws into a layer of its own.fn why_media_has_no_layer(&self,- geometry: &RasterSpaceGeometry,- run_index: u32,- media_record_position: ListPosition,- reach_of_run_holding_only_media: IntRect,+ runs: &RunGroupsPlaced,+ content: LiveContent,+ record: IndexedRecord,is_under_transform_animation_leaving_plane: bool,) -> Option<WhyMediaHasNoLayer> {- let (header, _) = self.list.record_at(media_record_position);+ let run_index = record.run_index as usize;+ let (header, _) = self.list.record_at(record.position);if !matches!(header.command_type,DisplayListCommandType::DrawCanvas| DisplayListCommandType::DrawVideoFrame| DisplayListCommandType::DrawCompositedContext+ | DisplayListCommandType::PaintCaret) {return Some(WhyMediaHasNoLayer::DrawnInsideAnotherCommand);}- let run = self.list.run(run_index as usize);+ let run = self.list.run(run_index);+ let geometry = &self.geometries[self.space_of_run(runs, run_index).0].raster;if is_under_transform_animation_leaving_plane || !geometry.world.draw_matrix(run.context.spatial).is_2d_affine(){return Some(WhyMediaHasNoLayer::UnderTransformThatIsNot2DAffine);}- if let Some(why) = self.why_compositor_cannot_composite_effect_or_effects_around(run.context.effect) {+ if content == LiveContent::Caret {+ if !self+ .tree+ .content_under_effect_composites_into_root_group(run.context.effect)+ {+ return Some(WhyMediaHasNoLayer::InsideAnEffectThatPushesALayerAtReplay);+ }+ // Its reach is then wherever its fixed clips let it show.+ if runs.run_moves_within_space_by_run_index[run_index] {+ return Some(WhyMediaHasNoLayer::MovesWithinItsSpace);+ }+ } else if let Some(why) = self.why_compositor_cannot_composite_effect_or_effects_around(run.context.effect) {return Some(WhyMediaHasNoLayer::InsideAnEffectTheCompositorCannotComposite(why));}- if reach_of_run_holding_only_media.is_empty() {+ if runs.reach_of_run_by_run_index[run_index].is_empty() {return Some(WhyMediaHasNoLayer::DrawsNothingVisible);}None}+ // Whether a record painted after the media alone in run `run_index`, which can show within `reach`, can show where+ // the media can, so that the media cuts the tiles of its band that it touches. Records of other spaces go into+ // other bands. A record of a run on the same spatial node can show where its bounds meet those of the media, and+ // one of a run on another node wherever its run can.+ fn record_painted_after_can_show_over(&self, runs: &RunGroupsPlaced, run_index: usize, reach: IntRect) -> bool {+ let list = self.list;+ let space = self.space_of_run(runs, run_index);+ let spatial = list.run(run_index).context.spatial;+ let (header, payload) = list.record_at(list.span_of_run(run_index).begin);+ let Some(bounds) = bounding_rect_computed_from_payload(&header, payload) else {+ return true;+ };+ let margin = ANTIALIASING_MARGIN_IN_DEVICE_PIXELS;+ let bounds = bounds.inflated_edges(margin, margin, margin, margin);+ (run_index + 1..list.run_count()).any(|later_run_index| {+ if self.space_of_run(runs, later_run_index) != space+ || runs.reach_of_run_by_run_index[later_run_index]+ .intersected(reach)+ .is_empty()+ {+ return false;+ }+ if list.run(later_run_index).context.spatial != spatial {+ return true;+ }+ let (chunk_index, run_index_in_chunk) = list.chunk_of_run(later_run_index);+ let chunk = list.chunk(chunk_index);+ let table = chunk.record_table();+ table+ .records_in(table.record_indices_of_run(RunIndexInChunk(run_index_in_chunk as u32)))+ .iter()+ .any(|record| {+ let (header, payload) = chunk.record_at(record.offset);+ !record.bounding_rect.intersected(bounds).is_empty()+ && record_can_paint_within(&header, payload, bounds)+ })+ })+ }+fn effects_composited_regardless_of_layer_content(&self,runs: &RunGroupsPlaced,@@ -1903,12 +1971,14 @@ impl StackBeingBuilt<'_> {ordinal: media.ordinal,record_span: media_stretch.record_span,reach: media_stretch.reach,+ cuts_band: media.cuts_band,};- (- barrier_of_plan,- media_stretch.record_span.begin,- Reach::Within(media_stretch.reach),- )+ let cut_reach = if media.cuts_band {+ Reach::Within(media_stretch.reach)+ } else {+ Reach::Nothing+ };+ (barrier_of_plan, media_stretch.record_span.begin, cut_reach)}BarrierBeingBuilt::NestedNodeBand {band_being_built_index: nested_band_being_built_index,@@ -2284,14 +2354,15 @@ impl InputsOfLayerPlan {#[cfg(test)]mod tests {use super::*;- use crate::display_list::commands::{CanvasId, ContextRef};+ use crate::display_list::commands::{CanvasId, ContextRef, FillRoundedRectRing};use crate::display_list::layers::{- CutsOfCell, LayerIdentity, NodeNamesFromIndices, WindowServerPresentationOfMedia, media_name,+ BarrierCut, BarrierIdentity, CutsOfCell, LayerIdentity, NodeNamesFromIndices, WindowServerPresentationOfMedia,+ media_name,};use crate::display_list::test_fixtures::{- GREEN, ListOfOneChunk, VIEWPORT, animation_of, canvas, effects, fill, frosted_glass, opacity_animation_of,- scroll_node, scroll_record, spinning, transform, transform_animation_of, tree_with_document_scroll,- tree_with_root_isolation_effect,+ GREEN, ListOfOneChunk, VIEWPORT, animation_of, canvas, caret, effects, fill, frosted_glass,+ opacity_animation_of, scroll_node, scroll_record, spinning, transform, transform_animation_of,+ tree_with_document_scroll, tree_with_root_isolation_effect,};use crate::display_list::tiles::TILE_SIZE_IN_DEVICE_PIXELS;use crate::node_slot_id::NodeSlotId;@@ -2734,6 +2805,187 @@ mod tests {);}+ // The cut of the band at the layer of the first drawing of `content`.+ fn cut_of_media<'a>(stack: &'a LayerStack, content: LiveContent) -> &'a BarrierCut {+ stack+ .bands+ .iter()+ .flat_map(|band| &band.cuts)+ .find(|cut| {+ matches!(stack.layers[cut.layer_above_cut.0 - 1].identity,+ LayerIdentity::Media { content: layer_content, .. } if layer_content == content)+ })+ .expect("the media is a barrier of a band")+ }++ #[test]+ fn a_caret_gets_a_layer_of_its_own() {+ let (tree, _, document) = tree_with_document_scroll();+ let planned = ListOfOneChunk::default()+ .with(fill(IntRect::new(0, 0, 800, 2600), GREEN), document)+ .with(caret(IntRect::new(20, 20, 2, 16)), document)+ .planned(&tree, &[]);+ assert!(planned.placement.media_without_layers.is_empty());+ assert_eq!(+ kinds_of_layers_from_base_up_that_may_hold_content(&planned.stack),+ ["base document band 0", "caret #0 document"]+ );+ }++ #[test]+ fn records_painted_after_a_caret_go_above_it_in_the_tiles_it_touches() {+ let (tree, _, document) = tree_with_document_scroll();+ let stack = ListOfOneChunk::default()+ .with(fill(IntRect::new(0, 0, 800, 2600), GREEN), document)+ .with(caret(IntRect::new(20, 20, 2, 16)), document)+ .with(fill(IntRect::new(10, 10, 100, 40), GREEN), document)+ .with(fill(IntRect::new(10, 1500, 100, 40), GREEN), document)+ .stack(&tree, &[]);+ assert_eq!(+ kinds_of_layers_from_base_up_that_may_hold_content(&stack),+ [+ "base document band 0",+ "caret #0 document",+ "painted document band 0 above L2"+ ]+ );+ let layer_above_caret = stack+ .layers+ .iter()+ .find(|layer| {+ matches!(+ layer.identity,+ LayerIdentity::Painted {+ above_barrier: Some(BarrierIdentity::Media {+ content: LiveContent::Caret,+ ..+ }),+ ..+ }+ )+ })+ .expect("a layer is above the caret");+ assert!(+ crate::display_list::tiles::TileCoord::new(0, 0)+ .cell_rect()+ .contains_rect(layer_above_caret.reach),+ "only the records in the tiles the caret touches go above it"+ );+ }++ // Text painted after a caret that it does not overlap stays in the base layer, where it takes LCD antialiasing.+ #[test]+ fn records_painted_after_a_caret_that_cannot_show_where_it_can_stay_below_it() {+ let (tree, _, document) = tree_with_document_scroll();+ let stack = ListOfOneChunk::default()+ .with(fill(IntRect::new(0, 0, 800, 2600), GREEN), document)+ .with(caret(IntRect::new(20, 20, 2, 16)), document)+ .with(fill(IntRect::new(10, 100, 100, 40), GREEN), document)+ .stack(&tree, &[]);+ assert_eq!(+ kinds_of_layers_from_base_up_that_may_hold_content(&stack),+ ["base document band 0", "caret #0 document"]+ );+ assert_eq!(cut_of_media(&stack, LiveContent::Caret).cut_reach, Reach::Nothing);+ }++ // A focused text field draws its focus ring after its caret, around it.+ #[test]+ fn a_focus_ring_around_a_caret_keeps_text_painted_after_both_below_the_caret() {+ let (tree, _, document) = tree_with_document_scroll();+ let focus_ring = FillRoundedRectRing {+ rect: IntRect::new(-2, -2, 74, 24),+ corner_radii: libgfx_rust::CornerRadii::uniform(4),+ top_width: 2,+ right_width: 2,+ bottom_width: 2,+ left_width: 2,+ color: GREEN,+ };+ let stack = ListOfOneChunk::default()+ .with(fill(IntRect::new(0, 0, 800, 2600), GREEN), document)+ .with(caret(IntRect::new(19, 3, 1, 14)), document)+ .with(focus_ring, document)+ .with(fill(IntRect::new(0, 23, 24, 16), GREEN), document)+ .stack(&tree, &[]);+ assert_eq!(+ kinds_of_layers_from_base_up_that_may_hold_content(&stack),+ ["base document band 0", "caret #0 document"]+ );+ }++ #[test]+ fn a_focus_ring_whose_rounded_corner_can_show_over_a_caret_goes_above_it() {+ let (tree, _, document) = tree_with_document_scroll();+ let focus_ring = FillRoundedRectRing {+ rect: IntRect::new(-2, -2, 74, 24),+ corner_radii: libgfx_rust::CornerRadii::uniform(12),+ top_width: 2,+ right_width: 2,+ bottom_width: 2,+ left_width: 2,+ color: GREEN,+ };+ let stack = ListOfOneChunk::default()+ .with(fill(IntRect::new(0, 0, 800, 2600), GREEN), document)+ .with(caret(IntRect::new(4, 3, 1, 14)), document)+ .with(focus_ring, document)+ .stack(&tree, &[]);+ assert_ne!(cut_of_media(&stack, LiveContent::Caret).cut_reach, Reach::Nothing);+ }++ #[test]+ fn carets_are_numbered_by_the_carets_painted_before_them() {+ let (tree, _, document) = tree_with_document_scroll();+ let stack = ListOfOneChunk::default()+ .with(fill(IntRect::new(0, 0, 800, 2600), GREEN), document)+ .with(caret(IntRect::new(20, 20, 2, 16)), document)+ .with(caret(IntRect::new(20, 1000, 2, 16)), document)+ .stack(&tree, &[]);+ assert_eq!(+ kinds_of_layers_from_base_up_that_may_hold_content(&stack),+ ["base document band 0", "caret #0 document", "caret #1 document"]+ );+ }++ // Unlike a canvas, a caret does not get the effects around it composited.+ #[test]+ fn a_caret_inside_an_opacity_group_stays_in_the_tiles_around_it() {+ let (mut tree, _, document) = tree_with_document_scroll();+ let faded = tree.append_effect_node_under(document, effects(0.5, CompositingAndBlendingOperator::Normal));+ let planned = ListOfOneChunk::default()+ .with(fill(IntRect::new(0, 0, 800, 2600), GREEN), document)+ .with(caret(IntRect::new(20, 20, 2, 16)), faded)+ .planned(&tree, &[]);+ assert!(planned.placement.placed_media.is_empty());+ assert_eq!(+ planned.placement.media_without_layers,+ [(+ LiveContent::Caret,+ WhyMediaHasNoLayer::InsideAnEffectThatPushesALayerAtReplay+ )]+ );+ assert!(planned.stack.composited_effects.is_empty());+ }++ #[test]+ fn a_canvas_that_no_record_painted_after_it_overlaps_cuts_no_tile() {+ let (tree, _, document) = tree_with_document_scroll();+ let stack = ListOfOneChunk::default()+ .with(fill(IntRect::new(0, 0, 800, 2600), GREEN), document)+ .with(canvas(IntRect::new(20, 20, 100, 100), 1), document)+ .with(fill(IntRect::new(20, 200, 100, 40), GREEN), document)+ .stack(&tree, &[]);+ assert_eq!(+ kinds_of_layers_from_base_up_that_may_hold_content(&stack),+ ["base document band 0", "canvas #0 document"]+ );+ assert_eq!(+ cut_of_media(&stack, LiveContent::Canvas(CanvasId(1))).cut_reach,+ Reach::Nothing+ );+ }+#[test]fn a_fade_over_an_earlier_canvas_stays_in_the_tiles_around_it() {let (mut tree, viewport) = tree_with_root_isolation_effect(1.0);diff --git a/Libraries/LibCompositing/Rust/src/display_list/layers/planning/lines_of_plan.rs b/Libraries/LibCompositing/Rust/src/display_list/layers/planning/lines_of_plan.rsindex cde472adf59..2d043311211 100644--- a/Libraries/LibCompositing/Rust/src/display_list/layers/planning/lines_of_plan.rs+++ b/Libraries/LibCompositing/Rust/src/display_list/layers/planning/lines_of_plan.rs@@ -96,7 +96,7 @@ impl PlannedLayers {})}- /// What the dump says of each canvas, video or nested context that was not given a layer, and why.+ /// What the dump says of each canvas, video, nested context or caret that was not given a layer, and why.pub fn lines_of_media_without_layers(&self) -> impl Iterator<Item = String> + '_ {self.placement.media_without_layers@@ -105,8 +105,9 @@ impl PlannedLayers {}/// The lines the overlay of layers shows of the stack past its layers, which WebContent sends with the plan: those- /// of the effects the compositor composites, of the canvases, videos and nested contexts without layers, and of the- /// effects that read only their own layer, with nodes named by their indices, as many and as long as a plan holds.+ /// of the effects the compositor composites, of the canvases, videos, nested contexts and carets without layers,+ /// and of the effects that read only their own layer, with nodes named by their indices, as many and as long as a+ /// plan holds./// A stack of one layer that replays the whole list has none.pub fn note_lines_for_layers_overlay(&self) -> Vec<String> {if self.stack.replays_whole_list() {@@ -141,8 +142,8 @@ impl PlannedLayers {/// line per layer, bottom to top: its index, what it holds, the space it is rastered in, what it sits above, the/// records `describe_records` names for it, what it is clipped to as it is composited, and whether the window/// server that `presentation` is of can show it. A layer below the base layer, or one that can hold nothing, is- /// left out. Then a line for each effect the compositor composites, each canvas, video or nested context without a- /// layer, each animation without a layer, and each effect that reads only its own layer.+ /// left out. Then a line for each effect the compositor composites, each canvas, video, nested context or caret+ /// without a layer, each animation without a layer, and each effect that reads only its own layer.pub fn layer_lines(&self,presentation: &WindowServerPresentationOfMedia,diff --git a/Libraries/LibCompositing/Rust/src/display_list/layers/wire.rs b/Libraries/LibCompositing/Rust/src/display_list/layers/wire.rsindex d8590da40cb..399989eaa42 100644--- a/Libraries/LibCompositing/Rust/src/display_list/layers/wire.rs+++ b/Libraries/LibCompositing/Rust/src/display_list/layers/wire.rs@@ -186,6 +186,7 @@ const LIVE_CONTENT_KIND_CANVAS: u8 = 0;const LIVE_CONTENT_KIND_VIDEO_FRAME: u8 = 1;const LIVE_CONTENT_KIND_IMAGE_FRAME: u8 = 2;const LIVE_CONTENT_KIND_COMPOSITED_CONTEXT: u8 = 3;+const LIVE_CONTENT_KIND_CARET: u8 = 4;impl Encode for LiveContent {fn encode(&self, encoder: &mut Encoder) -> Result<(), EncodeError> {@@ -194,6 +195,7 @@ impl Encode for LiveContent {LiveContent::VideoFrame(id) => (LIVE_CONTENT_KIND_VIDEO_FRAME, id.0),LiveContent::ImageFrame(id) => (LIVE_CONTENT_KIND_IMAGE_FRAME, id.0),LiveContent::CompositedContext(id) => (LIVE_CONTENT_KIND_COMPOSITED_CONTEXT, id.0),+ LiveContent::Caret => (LIVE_CONTENT_KIND_CARET, 0),};encoder.encode(&kind)?;encoder.encode(&id)@@ -211,6 +213,7 @@ impl Decode for LiveContent {LIVE_CONTENT_KIND_VIDEO_FRAME => LiveContent::VideoFrame(VideoSinkHandle(id)),LIVE_CONTENT_KIND_IMAGE_FRAME => LiveContent::ImageFrame(ImageFrameResourceId(id)),LIVE_CONTENT_KIND_COMPOSITED_CONTEXT => LiveContent::CompositedContext(CompositorContextId(id)),+ LIVE_CONTENT_KIND_CARET if id == 0 => LiveContent::Caret,_ => return Err(DecodeError::InvalidValue("LiveContent")),})}@@ -268,6 +271,7 @@ impl Decode for CutOfPlan {ordinal: decoder.decode()?,record_span: decoder.decode()?,reach: decoder.decode()?,+ cuts_band: decoder.decode()?,},BARRIER_KIND_NESTED_BAND => BarrierOfPlan::NestedBand,_ => return Err(DecodeError::InvalidValue("BarrierOfPlan")),@@ -386,8 +390,9 @@ impl Decode for StackOnWire {// A stack of one layer that replays the whole list goes as why it is one layer. A stack of more layers goes as its// plan: its nodes without their identities, and its bands in the order of the walk that its layers are in, each with-// what only it knows of its layers. In that order, the layer of a canvas, video or nested context comes right below the-// layer above its cut, and the last layer of a nested band comes right below the layer above the cut that enters it.+// what only it knows of its layers. In that order, the layer of a canvas, video, nested context or caret comes right+// below the layer above its cut, and the last layer of a nested band comes right below the layer above the cut that+// enters it.impl Encode for LayerStack {fn encode(&self, encoder: &mut Encoder) -> Result<(), EncodeError> {if let Some(why_list_is_one_layer) = self.why_list_is_one_layer {@@ -422,6 +427,7 @@ impl Encode for LayerStack {encoder.encode(ordinal)?;encoder.encode(record_span)?;encoder.encode(reach)?;+ encoder.encode(&(cut.cut_reach != Reach::Nothing))?;}_ => encoder.encode(&BARRIER_KIND_NESTED_BAND)?,}@@ -508,8 +514,8 @@ fn span_is_of_whole_runs(list: &DisplayListStorage, span: ListSpan) -> bool {span.begin <= span.end && position_starts_run(list, span.begin) && position_ends_run(list, span.end)}-// The span of a canvas, video or nested context with a layer is one run of the list, which starts with a record that-// draws that content.+// The span of a canvas, video, nested context or caret with a layer is one run of the list, which starts with a record+// that draws that content.fn span_is_run_drawing_content(list: &DisplayListStorage, span: ListSpan, content: LiveContent) -> bool {if matches!(content, LiveContent::ImageFrame(_)) {return false;@@ -732,10 +738,12 @@ fn check_bands(plan: &LayeredPlan, list: &DisplayListStorage) -> Result<(), &'st..} => {if !span_is_run_drawing_content(list, record_span, content) {- return Err("a canvas, video or nested context is not a run of the list that draws it");+ return Err("a canvas, video, nested context or caret is not a run of the list that draws it");}if media_of_layers.len() == MAXIMUM_MEDIA_LAYER_COUNT {- return Err("the stack holds more canvas, video and nested context layers than a plan makes");+ return Err(+ "the stack holds more canvas, video, nested context and caret layers than a plan makes",+ );}media_of_layers.push((record_span.begin, content, ordinal));}@@ -749,8 +757,8 @@ fn check_bands(plan: &LayeredPlan, list: &DisplayListStorage) -> Result<(), &'stcheck_ordinals_of_media(media_of_layers)}-// A plan numbers the drawings of a canvas, video or nested context that have layers in paint order: each has as its-// ordinal how many of them with the same content are painted before it. The window server tells the media apart by+// A plan numbers the drawings of a canvas, video, nested context or caret that have layers in paint order: each has as+// its ordinal how many of them with the same content are painted before it. The window server tells the media apart by// their ordinals.fn check_ordinals_of_media(mut media_of_layers: Vec<(ListPosition, LiveContent, u32)>) -> Result<(), &'static str> {media_of_layers.sort_unstable_by_key(|(position, _, _)| *position);@@ -760,15 +768,17 @@ fn check_ordinals_of_media(mut media_of_layers: Vec<(ListPosition, LiveContent,.filter(|(_, earlier_content, _)| earlier_content == content).count();if *ordinal as usize != count_of_same_content_painted_before {- return Err("a canvas, video or nested context is not numbered by the drawings of it painted before it");+ return Err(+ "a canvas, video, nested context or caret is not numbered by the drawings of it painted before it",+ );}}Ok(())}-// A plan puts each stretch of records into one band, or for a canvas, video or nested context with a layer, into that-// layer, and a stretch holds at least one run. So no record is in two spans, and a stack holds no more spans than the-// list holds runs.+// A plan puts each stretch of records into one band, or for a canvas, video, nested context or caret with a layer, into+// that layer, and a stretch holds at least one run. So no record is in two spans, and a stack holds no more spans than+// the list holds runs.fn check_no_record_is_held_twice(plan: &LayeredPlan) -> Result<(), &'static str> {let spans_of_media_layers = plan.bands@@ -836,8 +846,8 @@ fn check_stack_of_plan(stack: &LayerStack) -> Result<(), &'static str> {/// without a bound. Each index names an item of the stack, the list or the tree, and each rect lies within twice the/// extent limit of a plan. The nodes, bands, cuts and spans nest and follow each other as a plan makes them, the spans/// are of whole runs, and no record is in two spans. So the stack holds no more spans than the list holds runs, no-/// more canvas, video and nested context layers than a plan makes, and its nodes nest no deeper than its spaces plus-/// `MAXIMUM_NESTING_OF_COMPOSITED_EFFECTS`. The layers of a band are next to each other, so a frame that composites+/// more canvas, video, nested context and caret layers than a plan makes, and its nodes nest no deeper than its spaces+/// plus `MAXIMUM_NESTING_OF_COMPOSITED_EFFECTS`. The layers of a band are next to each other, so a frame that composites/// the layers in order enters each composited band once. The base layer is never of a space whose anchor the/// compositor animates, and no two layers share an identity.///@@ -922,7 +932,7 @@ mod tests {};use crate::display_list::placement::{RasterSpace, RasterSpaceGeometry, WhatEverySpaceOfTreeShares};use crate::display_list::test_fixtures::{- GREEN, ListOfOneChunk, NO_FRAME_STATE, VIEWPORT, canvas, chunk_of, effects, fill, frosted_glass,+ GREEN, ListOfOneChunk, NO_FRAME_STATE, VIEWPORT, canvas, caret, chunk_of, effects, fill, frosted_glass,opacity_animation_of, raster_settings_hash_by_layer, scroll_node, scroll_record, spinning, transform,tree_with_document_scroller, tree_with_root_isolation_effect,};@@ -1236,6 +1246,21 @@ mod tests {}}+ // Two carets, the first under a box painted over it.+ fn page_with_carets() -> Page {+ let (tree, _, contexts) = tree_with_document_scroller(&[]);+ let document = contexts[0];+ let list = ListOfOneChunk::default()+ .with(fill(IntRect::new(0, 0, 800, 2600), GREEN), document)+ .with(caret(IntRect::new(20, 420, 2, 16)), document)+ .with(caret(IntRect::new(20, 1420, 2, 16)), document)+ .with(fill(IntRect::new(0, 400, 800, 50), GREEN), document);+ Page {+ tree,+ list: list.storage(),+ }+ }+// A spinner in a group scaled up eighty times, whose space a plan rasters at that scale.fn page_with_spinner_in_large_scale() -> Page {let (mut tree, viewport) = tree_with_root_isolation_effect(1.0);@@ -1300,6 +1325,7 @@ mod tests {("no records", page_without_records()),("records that draw nothing", page_whose_records_draw_nothing()),("frosted glass", page_with_frosted_glass()),+ ("carets", page_with_carets()),]}@@ -1401,6 +1427,24 @@ mod tests {assert!(nothing_drawn.why_list_is_one_layer.is_none());assert_eq!(nothing_drawn.bands.len(), 1);assert!(nothing_drawn.bands[0].record_spans.is_empty() && nothing_drawn.bands[0].cuts.is_empty());+ let carets = stack_of(page_with_carets());+ let caret_layers: Vec<(LayerIdentity, bool)> = carets+ .bands+ .iter()+ .flat_map(|band| &band.cuts)+ .map(|cut| {+ (+ carets.layers[cut.layer_above_cut.0 - 1].identity,+ cut.cut_reach != Reach::Nothing,+ )+ })+ .filter(|(identity, _)| matches!(identity, LayerIdentity::Media { .. }))+ .collect();+ let caret = |ordinal| LayerIdentity::Media {+ content: LiveContent::Caret,+ ordinal,+ };+ assert_eq!(caret_layers, [(caret(0), true), (caret(1), false)]);let crowded = stack_of(page_with_many_nested_scrollers());assert_eq!(kinds_of_anchors(&crowded)[2..], ["scroller"; 6]);let nested_scrollers_without_spaces = NESTED_SCROLLER_COUNT_OF_CROWDED_PAGE as usize - 6;@@ -1757,6 +1801,7 @@ mod tests {ordinal,record_span,reach,+ ..} = &mut plan.bands[band_index].cuts[cut_index].barrierelse {unreachable!()@@ -1820,6 +1865,7 @@ mod tests {ordinal: 0,record_span: span_of_last_canvas,reach,+ cuts_band: true,},reach_of_layer_above_cut: IntRect::default(),});diff --git a/Libraries/LibCompositing/Rust/src/display_list/summary.rs b/Libraries/LibCompositing/Rust/src/display_list/summary.rsindex f458b6fbd89..186d5d8623a 100644--- a/Libraries/LibCompositing/Rust/src/display_list/summary.rs+++ b/Libraries/LibCompositing/Rust/src/display_list/summary.rs@@ -40,6 +40,8 @@ pub enum LiveContent {VideoFrame(VideoSinkHandle),ImageFrame(ImageFrameResourceId),CompositedContext(CompositorContextId),+ /// A caret, which blinks.+ Caret,}/// A top-level record that draws live content, itself or in a record nested in it.@@ -99,6 +101,7 @@ pub(crate) fn live_content_of(command_type: DisplayListCommandType, payload: &[uT::DrawCompositedContext => Some(LiveContent::CompositedContext(read_command::<DrawCompositedContext>(payload).child_context_id,)),+ T::PaintCaret => Some(LiveContent::Caret),_ => None,}}diff --git a/Libraries/LibCompositing/Rust/src/display_list/test_fixtures.rs b/Libraries/LibCompositing/Rust/src/display_list/test_fixtures.rsindex d370094fd75..a9efdb422cf 100644--- a/Libraries/LibCompositing/Rust/src/display_list/test_fixtures.rs+++ b/Libraries/LibCompositing/Rust/src/display_list/test_fixtures.rs@@ -9,7 +9,7 @@use crate::display_list::builder::DisplayListBuilder;use crate::display_list::commands::{CanvasId, ClipNodeIndex, CompositorContextId, ContextRef, DisplayListCommand, DrawCanvas, EffectNodeIndex,- FillRect, ImageFrameResourceId, SpatialNodeIndex, VISUAL_VIEWPORT_NODE_INDEX, VideoSinkHandle,+ FillRect, ImageFrameResourceId, PaintCaret, SpatialNodeIndex, VISUAL_VIEWPORT_NODE_INDEX, VideoSinkHandle,};use crate::display_list::layers::LayerStack;use crate::display_list::layers::planning::{LayerStackInputs, PlannedLayers, plan_layer_stack};@@ -197,6 +197,15 @@ pub fn canvas(rect: IntRect, id: u64) -> DrawCanvas {}}+pub fn caret(rect: IntRect) -> PaintCaret {+ PaintCaret {+ rect,+ color: Color::from_rgb(0, 0, 0),+ blink_cycle_start_time_ns: 0,+ should_blink: true,+ }+}+pub fn frosted_glass(tree: &mut VisualContextTree, parent: ContextRef, region: IntRect) -> ContextRef {tree.append_effect_node_under(parent,diff --git a/Libraries/LibCompositing/Rust/src/display_list/tile_keys.rs b/Libraries/LibCompositing/Rust/src/display_list/tile_keys.rsindex af2468b026a..0d830022d2b 100644--- a/Libraries/LibCompositing/Rust/src/display_list/tile_keys.rs+++ b/Libraries/LibCompositing/Rust/src/display_list/tile_keys.rs@@ -278,6 +278,8 @@ fn version_of_live_content(live_content: &dyn LiveContentVersions, content: LiveLiveContent::CompositedContext(nested_context) => live_content.nested_context_frame_generation(nested_context).unwrap_or(u64::MAX),+ // The blink phase of a caret is hashed from its record.+ LiveContent::Caret => 0,}}@@ -1562,6 +1564,7 @@ impl<'a> TileKeyingOfRasterSpace<'a> {LiveContent::VideoFrame(_) => 2,LiveContent::ImageFrame(_) => 3,LiveContent::CompositedContext(_) => 4,+ LiveContent::Caret => 5,});hasher.write_u64(version_of_live_content(frame_state.live_content, content));if matches!(content, LiveContent::CompositedContext(_)) {diff --git a/Services/Compositor/Rust/src/presenting/window_server.rs b/Services/Compositor/Rust/src/presenting/window_server.rsindex 4871d329260..aadc489d49f 100644--- a/Services/Compositor/Rust/src/presenting/window_server.rs+++ b/Services/Compositor/Rust/src/presenting/window_server.rs@@ -130,6 +130,7 @@ impl std::fmt::Display for WhyMediaIsReplayed {WhyMediaIsReplayed::NoPlacement(LiveMedia::CompositedContext(_)) => {"the window server does not show nested contexts"}+ WhyMediaIsReplayed::NoPlacement(LiveMedia::Caret) => "the window server does not show carets",WhyMediaIsReplayed::NoPlacement(_) => "where the window server would show it is not worked out",WhyMediaIsReplayed::CanvasHasNoPresentableSurface => "the canvas has no surface the window server can show",WhyMediaIsReplayed::VideoHasNoFrame => "the video has no frame",@@ -297,7 +298,7 @@ impl ContextPresenting {}(MediaKind::Video, id.0)}- LiveMedia::ImageFrame(_) | LiveMedia::CompositedContext(_) => {+ LiveMedia::ImageFrame(_) | LiveMedia::CompositedContext(_) | LiveMedia::Caret => {return Some(WhyMediaIsReplayed::NoPlacement(*content));}};@@ -711,7 +712,7 @@ impl ContextPresenting {.get(&id.0).is_some_and(|sink| sink.has_frame && sink.frame_has_surface),),- LiveMedia::ImageFrame(_) | LiveMedia::CompositedContext(_) => continue,+ LiveMedia::ImageFrame(_) | LiveMedia::CompositedContext(_) | LiveMedia::Caret => continue,};if !has_content {continue;diff --git a/Tests/LibWeb/Text/expected/display_list/contenteditable-caret.txt b/Tests/LibWeb/Text/expected/display_list/contenteditable-caret.txtindex 8331530a8d8..84d8549fe90 100644--- a/Tests/LibWeb/Text/expected/display_list/contenteditable-caret.txt+++ b/Tests/LibWeb/Text/expected/display_list/contenteditable-caret.txt@@ -6,9 +6,11 @@ AccumulatedVisualContext Tree:[e0 in s0] effects=[]Layers (for a window server that shows tiles and filters what is below layers):- [L0] base space=viewport+ [L0] base space=viewport held by the frame: it is under a layer the frame holds+ [L1] caret #0 space=viewport region=[5,5 7x22]+ [L2] painted space=viewport above L1DisplayList:-L0 PaintCaret@s1/e0 rect=[8,8 1x16] color=rgb(0, 0, 0) blink_cycle_start_time_ns=t1 owner=BlockContainer<DIV> phase=foreground-L0 FillRoundedRectRing@s1/e0 rect=[6,6 104x24] top_width=2 right_width=2 bottom_width=2 left_width=2 color=rgb(61, 174, 233) owner=BlockContainer<DIV> phase=outline+L1 PaintCaret@s1/e0 rect=[8,8 1x16] color=rgb(0, 0, 0) blink_cycle_start_time_ns=t1 owner=BlockContainer<DIV> phase=foreground+L2 FillRoundedRectRing@s1/e0 rect=[6,6 104x24] top_width=2 right_width=2 bottom_width=2 left_width=2 color=rgb(61, 174, 233) owner=BlockContainer<DIV> phase=outlinediff --git a/Tests/LibWeb/Text/expected/display_list/input-caret.txt b/Tests/LibWeb/Text/expected/display_list/input-caret.txtindex aad32c81734..2d90dad0672 100644--- a/Tests/LibWeb/Text/expected/display_list/input-caret.txt+++ b/Tests/LibWeb/Text/expected/display_list/input-caret.txt@@ -9,12 +9,14 @@ AccumulatedVisualContext Tree:[e0 in s0] effects=[]Layers (for a window server that shows tiles and filters what is below layers):- [L0] base space=viewport+ [L0] base space=viewport held by the frame: it is under a layer the frame holds+ [L1] caret #0 space=viewport region=[10,8 7x20]+ [L2] painted space=viewport above L1DisplayList:L0 FillRectWithRoundedCorners@s1/e0 rect=[8,8 110x20] color=rgb(255, 255, 255) corner_radii=[4x4,4x4,4x4,4x4] owner=TextInputBox<INPUT> phase=backgroundL0 FillRoundedRectRing@s1/e0 rect=[8,8 110x20] corner_radii=[4x4,4x4,4x4,4x4] top_width=1 right_width=1 bottom_width=1 left_width=1 color=rgb(118, 118, 118) owner=TextInputBox<INPUT> phase=borderL0 DrawGlyphRun@s1/c1/e0 font_id=font1 glyphs=5 rect=[13,11 31x14] glyph_bounding_rect=[13,12 33x12] translation=[13,22] color=rgb(0, 0, 0) text="hello" owner=BlockContainer<DIV> phase=foreground-L0 PaintCaret@s1/c1/e0 rect=[13,11 1x14] color=rgb(0, 0, 0) blink_cycle_start_time_ns=t1 owner=BlockContainer<DIV> phase=foreground-L0 FillRoundedRectRing@s1/e0 rect=[6,6 114x24] corner_radii=[6x6,6x6,6x6,6x6] top_width=2 right_width=2 bottom_width=2 left_width=2 color=rgb(61, 174, 233) owner=TextInputBox<INPUT> phase=outline+L1 PaintCaret@s1/c1/e0 rect=[13,11 1x14] color=rgb(0, 0, 0) blink_cycle_start_time_ns=t1 owner=BlockContainer<DIV> phase=foreground+L2 FillRoundedRectRing@s1/e0 rect=[6,6 114x24] corner_radii=[6x6,6x6,6x6,6x6] top_width=2 right_width=2 bottom_width=2 left_width=2 color=rgb(61, 174, 233) owner=TextInputBox<INPUT> phase=outlinediff --git a/Tests/LibWeb/Text/expected/display_list/input-focus-switch-selection-and-caret.txt b/Tests/LibWeb/Text/expected/display_list/input-focus-switch-selection-and-caret.txtindex 0f0a55f8c55..f1cfadd8a25 100644--- a/Tests/LibWeb/Text/expected/display_list/input-focus-switch-selection-and-caret.txt+++ b/Tests/LibWeb/Text/expected/display_list/input-focus-switch-selection-and-caret.txt@@ -11,7 +11,9 @@ AccumulatedVisualContext Tree:[e0 in s0] effects=[]Layers (for a window server that shows tiles and filters what is below layers):- [L0] base space=viewport+ [L0] base space=viewport held by the frame: it is under a layer the frame holds+ [L1] caret #0 space=viewport region=[196,8 7x20]+ [L2] painted space=viewport above L1DisplayList:L0 FillRectWithRoundedCorners@s1/e0 rect=[8,8 178x20] color=rgb(255, 255, 255) corner_radii=[4x4,4x4,4x4,4x4] owner=TextInputBox<INPUT>#foo phase=background@@ -21,6 +23,6 @@ L0 DrawGlyphRun@s1/e0 font_id=font2 glyphs=1 rect=[185,9 9x16] glyph_bounding_reL0 FillRectWithRoundedCorners@s1/e0 rect=[194,8 177x20] color=rgb(255, 255, 255) corner_radii=[4x4,4x4,4x4,4x4] owner=TextInputBox<INPUT>#bar phase=backgroundL0 FillRoundedRectRing@s1/e0 rect=[194,8 177x20] corner_radii=[4x4,4x4,4x4,4x4] top_width=1 right_width=1 bottom_width=1 left_width=1 color=rgb(118, 118, 118) owner=TextInputBox<INPUT>#bar phase=borderL0 DrawGlyphRun@s1/c3/e0 font_id=font1 glyphs=3 rect=[198,11 24x14] glyph_bounding_rect=[199,12 27x12] translation=[198.6875,22] color=rgb(0, 0, 0) text="bar" owner=BlockContainer<DIV> phase=foreground-L0 PaintCaret@s1/c3/e0 rect=[199,11 1x14] color=rgb(0, 0, 0) blink_cycle_start_time_ns=t1 owner=BlockContainer<DIV> phase=foreground-L0 FillRoundedRectRing@s1/e0 rect=[192,6 181x24] corner_radii=[6x6,6x6,6x6,6x6] top_width=2 right_width=2 bottom_width=2 left_width=2 color=rgb(61, 174, 233) owner=TextInputBox<INPUT>#bar phase=outline+L1 PaintCaret@s1/c3/e0 rect=[199,11 1x14] color=rgb(0, 0, 0) blink_cycle_start_time_ns=t1 owner=BlockContainer<DIV> phase=foreground+L2 FillRoundedRectRing@s1/e0 rect=[192,6 181x24] corner_radii=[6x6,6x6,6x6,6x6] top_width=2 right_width=2 bottom_width=2 left_width=2 color=rgb(61, 174, 233) owner=TextInputBox<INPUT>#bar phase=outlinediff --git a/Tests/LibWeb/Text/expected/display_list/jsonl-dump-is-one-json-object-per-line.txt b/Tests/LibWeb/Text/expected/display_list/jsonl-dump-is-one-json-object-per-line.txtindex e3445967919..54399a09dda 100644--- a/Tests/LibWeb/Text/expected/display_list/jsonl-dump-is-one-json-object-per-line.txt+++ b/Tests/LibWeb/Text/expected/display_list/jsonl-dump-is-one-json-object-per-line.txt@@ -1,4 +1,4 @@-types: {"header":1,"node":5,"layer":3,"chunk":1,"record":6}+types: {"header":1,"node":5,"layer":2,"chunk":1,"record":6}header: ladybird-display-list-dump version 1 viewport [0,0,800,600] print-order 6 recordsrecord ids count up from 1: true{"type":"node","kind":"spatial","name":"s0","raw":0,"depth":0,"description":"transform=[1,0,0,1,0,0] origin=(0,0)","owner":"Viewport<#document>"}@@ -6,9 +6,8 @@ record ids count up from 1: true{"type":"node","kind":"spatial","name":"s2","raw":2,"depth":2,"parent":"s1","description":"transform=[0.70710677,-0.70710677,0.70710677,0.70710677,0,0] origin=(625,45) bounds=[600,20 50x50]","owner":"BlockContainer<DIV>#transformed"}{"type":"node","kind":"effect","name":"e0","raw":0,"depth":0,"space":"s0","description":"effects=[]"}{"type":"node","kind":"effect","name":"e1","raw":1,"depth":1,"parent":"e0","space":"s1","description":"mask=[700,20 50x50] kind=alpha origin=css-mask-layers","owner":"BlockContainer<DIV>#masked"}-{"type":"layer","name":"L0","line":"[L0] base space=viewport","records":[[2,5]]}+{"type":"layer","name":"L0","line":"[L0] base space=viewport","records":[[2,6]]}{"type":"layer","name":"L1","line":"[L1] canvas #0 space=viewport region=[17,17 206x126] can be shown by the window server: clip=[0,0 800x600]","records":[[1,1]]}-{"type":"layer","name":"L2","line":"[L2] painted space=viewport above L1","records":[[6,6]]}{"type":"record","id":2,"op":"FillRect","depth":0,"layer":"L0","chunk":"k1","context":{"spatial":{"name":"s2","raw":2},"effect":{"name":"e0","raw":0}},"fields":{"rect":[600,20,50,50],"color":"#008000ff"},"owner":"BlockContainer<DIV>#transformed","phase":"background"}{"type":"record","id":3,"op":"DeclareMaskContent","depth":0,"layer":"L0","chunk":"k1","context":{"spatial":{"name":"s1","raw":1},"effect":{"name":"e1","raw":1}},"fields":{"rect":[700,20,50,50],"effect":{"name":"e1","raw":1}},"owner":"BlockContainer<DIV>#masked","phase":"preamble"}{"type":"record","id":4,"op":"PaintLinearGradient","depth":1,"parent":3,"role":"mask-content","layer":"L0","chunk":"k1","context":{"spatial":{"name":"s1","raw":1},"effect":{"name":"e1","raw":1}},"fields":{"gradient_rect":[700,20,50,50],"gradient_angle":180,"color_stops":[{"color":"#000000ff","position":0},{"color":"#00000000","position":1}],"repeat_length":1,"interpolation_method":{"rectangular_color_space":"Srgb"}},"inline_clips":[{"kind":"Rect","rect":[700,20,50,50]}],"owner":"BlockContainer<DIV>#masked","phase":"preamble"}diff --git a/Tests/LibWeb/Text/expected/display_list/page-focus-rendering.txt b/Tests/LibWeb/Text/expected/display_list/page-focus-rendering.txtindex 7b32584838f..d3599b8cba8 100644--- a/Tests/LibWeb/Text/expected/display_list/page-focus-rendering.txt+++ b/Tests/LibWeb/Text/expected/display_list/page-focus-rendering.txt@@ -95,13 +95,14 @@ AccumulatedVisualContext Tree:[e0 in s0] effects=[]Layers (for a window server that shows tiles and filters what is below layers):- [L0] base space=viewport+ [L0] base space=viewport held by the frame: it is under a layer the frame holds+ [L1] caret #0 space=viewport region=[16,0 7x20]DisplayList:L0 FillRectWithRoundedCorners@s1/e0 rect=[0,0 70x20] color=rgb(255, 255, 255) corner_radii=[4x4,4x4,4x4,4x4] owner=TextAreaBox<TEXTAREA>#ta phase=backgroundL0 FillRoundedRectRing@s1/e0 rect=[0,0 70x20] corner_radii=[4x4,4x4,4x4,4x4] top_width=1 right_width=1 bottom_width=1 left_width=1 color=rgb(118, 118, 118) owner=TextAreaBox<TEXTAREA>#ta phase=borderL0 DrawGlyphRun@s1/c0/e0 font_id=font1 glyphs=3 rect=[3,3 24x14] glyph_bounding_rect=[3,4 27x12] translation=[3,14] color=rgb(0, 0, 0) text="abc" owner=BlockContainer<DIV> phase=foreground-L0 PaintCaret@s1/c0/e0 rect=[19,3 1x14] color=rgb(0, 0, 0) blink_cycle_start_time_ns=t1 owner=BlockContainer<DIV> phase=foreground+L1 PaintCaret@s1/c0/e0 rect=[19,3 1x14] color=rgb(0, 0, 0) blink_cycle_start_time_ns=t1 owner=BlockContainer<DIV> phase=foregroundL0 FillRoundedRectRing@s1/e0 rect=[-2,-2 74x24] corner_radii=[6x6,6x6,6x6,6x6] top_width=2 right_width=2 bottom_width=2 left_width=2 color=rgb(61, 174, 233) owner=TextAreaBox<TEXTAREA>#ta phase=outlineL0 DrawLine@s1/e0 color=rgba(255, 255, 255, 0.392) from=[65,17] to=[67,15] thickness=1 owner=TextAreaBox<TEXTAREA>#ta phase=overlayL0 DrawLine@s1/e0 color=rgba(0, 0, 0, 0.392) from=[64,17] to=[67,14] thickness=1 owner=TextAreaBox<TEXTAREA>#ta phase=overlay@@ -147,13 +148,14 @@ AccumulatedVisualContext Tree:[e0 in s0] effects=[]Layers (for a window server that shows tiles and filters what is below layers):- [L0] base space=viewport+ [L0] base space=viewport held by the frame: it is under a layer the frame holds+ [L1] caret #0 space=viewport region=[16,0 7x20]DisplayList:L0 FillRectWithRoundedCorners@s1/e0 rect=[0,0 70x20] color=rgb(255, 255, 255) corner_radii=[4x4,4x4,4x4,4x4] owner=TextAreaBox<TEXTAREA>#ta phase=backgroundL0 FillRoundedRectRing@s1/e0 rect=[0,0 70x20] corner_radii=[4x4,4x4,4x4,4x4] top_width=1 right_width=1 bottom_width=1 left_width=1 color=rgb(118, 118, 118) owner=TextAreaBox<TEXTAREA>#ta phase=borderL0 DrawGlyphRun@s1/c0/e0 font_id=font1 glyphs=3 rect=[3,3 24x14] glyph_bounding_rect=[3,4 27x12] translation=[3,14] color=rgb(0, 0, 0) text="abc" owner=BlockContainer<DIV> phase=foreground-L0 PaintCaret@s1/c0/e0 rect=[19,3 1x14] color=rgb(0, 0, 0) blink_cycle_start_time_ns=t1 owner=BlockContainer<DIV> phase=foreground+L1 PaintCaret@s1/c0/e0 rect=[19,3 1x14] color=rgb(0, 0, 0) blink_cycle_start_time_ns=t1 owner=BlockContainer<DIV> phase=foregroundL0 FillRoundedRectRing@s1/e0 rect=[-2,-2 74x24] corner_radii=[6x6,6x6,6x6,6x6] top_width=2 right_width=2 bottom_width=2 left_width=2 color=rgb(61, 174, 233) owner=TextAreaBox<TEXTAREA>#ta phase=outlineL0 DrawLine@s1/e0 color=rgba(255, 255, 255, 0.392) from=[65,17] to=[67,15] thickness=1 owner=TextAreaBox<TEXTAREA>#ta phase=overlayL0 DrawLine@s1/e0 color=rgba(0, 0, 0, 0.392) from=[64,17] to=[67,14] thickness=1 owner=TextAreaBox<TEXTAREA>#ta phase=overlaydiff --git a/Tests/LibWeb/Text/expected/display_list/textarea-caret.txt b/Tests/LibWeb/Text/expected/display_list/textarea-caret.txtindex c023788155a..cd29177677f 100644--- a/Tests/LibWeb/Text/expected/display_list/textarea-caret.txt+++ b/Tests/LibWeb/Text/expected/display_list/textarea-caret.txt@@ -8,18 +8,20 @@ AccumulatedVisualContext Tree:[e0 in s0] effects=[]Layers (for a window server that shows tiles and filters what is below layers):- [L0] base space=viewport+ [L0] base space=viewport held by the frame: it is under a layer the frame holds+ [L1] caret #0 space=viewport region=[8,8 7x20]+ [L2] painted space=viewport above L1DisplayList:L0 FillRectWithRoundedCorners@s1/e0 rect=[8,8 106x34] color=rgb(255, 255, 255) corner_radii=[4x4,4x4,4x4,4x4] owner=TextAreaBox<TEXTAREA> phase=backgroundL0 FillRoundedRectRing@s1/e0 rect=[8,8 106x34] corner_radii=[4x4,4x4,4x4,4x4] top_width=1 right_width=1 bottom_width=1 left_width=1 color=rgb(118, 118, 118) owner=TextAreaBox<TEXTAREA> phase=borderL0 DrawGlyphRun@s1/c0/e0 font_id=font1 glyphs=5 rect=[11,11 31x14] glyph_bounding_rect=[11,12 33x12] translation=[11,22] color=rgb(0, 0, 0) text="hello" owner=BlockContainer<DIV> phase=foreground-L0 PaintCaret@s1/c0/e0 rect=[11,11 1x14] color=rgb(0, 0, 0) blink_cycle_start_time_ns=t1 owner=BlockContainer<DIV> phase=foreground-L0 FillRoundedRectRing@s1/e0 rect=[6,6 110x38] corner_radii=[6x6,6x6,6x6,6x6] top_width=2 right_width=2 bottom_width=2 left_width=2 color=rgb(61, 174, 233) owner=TextAreaBox<TEXTAREA> phase=outline-L0 DrawLine@s1/e0 color=rgba(255, 255, 255, 0.392) from=[109,39] to=[111,37] thickness=1 owner=TextAreaBox<TEXTAREA> phase=overlay-L0 DrawLine@s1/e0 color=rgba(0, 0, 0, 0.392) from=[108,39] to=[111,36] thickness=1 owner=TextAreaBox<TEXTAREA> phase=overlay-L0 DrawLine@s1/e0 color=rgba(255, 255, 255, 0.392) from=[106,39] to=[111,34] thickness=1 owner=TextAreaBox<TEXTAREA> phase=overlay-L0 DrawLine@s1/e0 color=rgba(0, 0, 0, 0.392) from=[105,39] to=[111,33] thickness=1 owner=TextAreaBox<TEXTAREA> phase=overlay-L0 DrawLine@s1/e0 color=rgba(255, 255, 255, 0.392) from=[103,39] to=[111,31] thickness=1 owner=TextAreaBox<TEXTAREA> phase=overlay-L0 DrawLine@s1/e0 color=rgba(0, 0, 0, 0.392) from=[102,39] to=[111,30] thickness=1 owner=TextAreaBox<TEXTAREA> phase=overlay+L1 PaintCaret@s1/c0/e0 rect=[11,11 1x14] color=rgb(0, 0, 0) blink_cycle_start_time_ns=t1 owner=BlockContainer<DIV> phase=foreground+L2 FillRoundedRectRing@s1/e0 rect=[6,6 110x38] corner_radii=[6x6,6x6,6x6,6x6] top_width=2 right_width=2 bottom_width=2 left_width=2 color=rgb(61, 174, 233) owner=TextAreaBox<TEXTAREA> phase=outline+L2 DrawLine@s1/e0 color=rgba(255, 255, 255, 0.392) from=[109,39] to=[111,37] thickness=1 owner=TextAreaBox<TEXTAREA> phase=overlay+L2 DrawLine@s1/e0 color=rgba(0, 0, 0, 0.392) from=[108,39] to=[111,36] thickness=1 owner=TextAreaBox<TEXTAREA> phase=overlay+L2 DrawLine@s1/e0 color=rgba(255, 255, 255, 0.392) from=[106,39] to=[111,34] thickness=1 owner=TextAreaBox<TEXTAREA> phase=overlay+L2 DrawLine@s1/e0 color=rgba(0, 0, 0, 0.392) from=[105,39] to=[111,33] thickness=1 owner=TextAreaBox<TEXTAREA> phase=overlay+L2 DrawLine@s1/e0 color=rgba(255, 255, 255, 0.392) from=[103,39] to=[111,31] thickness=1 owner=TextAreaBox<TEXTAREA> phase=overlay+L2 DrawLine@s1/e0 color=rgba(0, 0, 0, 0.392) from=[102,39] to=[111,30] thickness=1 owner=TextAreaBox<TEXTAREA> phase=overlay