Truly independent web browser
LibCompositing+Compositor: Clean up after caret and scroll bar layers
Aliaksandr Kalenik9a096edb073e
diff --git a/Libraries/LibCompositing/Rust/src/display_list/builder.rs b/Libraries/LibCompositing/Rust/src/display_list/builder.rsindex 06e2ea40a18..b8587aa0cc8 100644--- a/Libraries/LibCompositing/Rust/src/display_list/builder.rs+++ b/Libraries/LibCompositing/Rust/src/display_list/builder.rs@@ -185,13 +185,12 @@ pub fn record_can_paint_within(header: &DisplayListCommandHeader, payload: &[u8]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);+ let Some(inner) = read_command::<FillRoundedRectRing>(payload).unfilled_inner_rect() else {+ return true;+ };// 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 radii = read_command::<FillRoundedRectRing>(payload).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))diff --git a/Libraries/LibCompositing/Rust/src/display_list/commands.rs b/Libraries/LibCompositing/Rust/src/display_list/commands.rsindex a40f1bc6781..ab0bea1e861 100644--- a/Libraries/LibCompositing/Rust/src/display_list/commands.rs+++ b/Libraries/LibCompositing/Rust/src/display_list/commands.rs@@ -1268,6 +1268,30 @@ display_list_record_fields!(FillRoundedRectRing {color});+impl FillRoundedRectRing {+ /// The widths of the top, right, bottom and left edges, each cut to what the rect holds besides the edge across from+ /// it.+ pub fn widths_within_rect(&self) -> [i32; 4] {+ let top = self.top_width.clamp(0, self.rect.height.max(0));+ let bottom = self.bottom_width.clamp(0, (self.rect.height - top).max(0));+ let left = self.left_width.clamp(0, self.rect.width.max(0));+ let right = self.right_width.clamp(0, (self.rect.width - left).max(0));+ [top, right, bottom, left]+ }++ /// The rect inside the inner edge of the ring as if its corners were square, which the ring leaves unfilled. None+ /// where it lies past the coordinates a rect holds.+ pub fn unfilled_inner_rect(&self) -> Option<IntRect> {+ let [top, right, bottom, left] = self.widths_within_rect();+ Some(IntRect::new(+ self.rect.x.checked_add(left)?,+ self.rect.y.checked_add(top)?,+ self.rect.width - left - right,+ self.rect.height - top - bottom,+ ))+ }+}+impl DisplayListCommand for FillRoundedRectRing {const COMMAND_TYPE: DisplayListCommandType = DisplayListCommandType::FillRoundedRectRing;fn bounding_rect(&self) -> Option<IntRect> {diff --git a/Libraries/LibCompositing/Rust/src/display_list/layers/planning.rs b/Libraries/LibCompositing/Rust/src/display_list/layers/planning.rsindex e0e506a6ecf..290a516e9d0 100644--- a/Libraries/LibCompositing/Rust/src/display_list/layers/planning.rs+++ b/Libraries/LibCompositing/Rust/src/display_list/layers/planning.rs@@ -23,7 +23,7 @@ use super::{};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::commands::{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,@@ -979,14 +979,8 @@ impl<'a> ListBeingPlaced<'a> {) -> Option<WhyMediaHasNoLayer> {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- | DisplayListCommandType::PaintScrollBar- ) {+ // Live content nested in another command is noted at the top-level record around it.+ if !header.command_type.is_alone_in_its_run() {return Some(WhyMediaHasNoLayer::DrawnInsideAnotherCommand);}let run = self.list.run(run_index);diff --git a/Libraries/LibCompositing/Rust/src/display_list/tile_keys/chunk_placement.rs b/Libraries/LibCompositing/Rust/src/display_list/tile_keys/chunk_placement.rsindex 86f62f5ddf6..107d39aaac7 100644--- a/Libraries/LibCompositing/Rust/src/display_list/tile_keys/chunk_placement.rs+++ b/Libraries/LibCompositing/Rust/src/display_list/tile_keys/chunk_placement.rs@@ -302,25 +302,10 @@ impl TileKeyingOfRasterSpace<'_> {hasher.write_u32(ring.color.0);color = ring.color;draws_recorded_color_with_source_over = true;- let top_width = ring.top_width.clamp(0, ring.rect.height.max(0));- let bottom_width = ring.bottom_width.clamp(0, (ring.rect.height - top_width).max(0));- let left_width = ring.left_width.clamp(0, ring.rect.width.max(0));- let right_width = ring.right_width.clamp(0, (ring.rect.width - left_width).max(0));- for width in [top_width, right_width, bottom_width, left_width] {+ for width in ring.widths_within_rect() {hasher.write_i32(width);}- let (Some(unfilled_inner_x), Some(unfilled_inner_y)) =- (ring.rect.x.checked_add(left_width), ring.rect.y.checked_add(top_width))- else {- return None;- };- let unfilled_inner_rect = IntRect::new(- unfilled_inner_x,- unfilled_inner_y,- ring.rect.width - left_width - right_width,- ring.rect.height - top_width - bottom_width,- );- (ring.rect, ring.corner_radii, Some(unfilled_inner_rect))+ (ring.rect, ring.corner_radii, Some(ring.unfilled_inner_rect()?))}_ => return None,};diff --git a/Services/Compositor/Rust/src/presenting/layers.rs b/Services/Compositor/Rust/src/presenting/layers.rsindex 6d16b827878..fa0d7a6dd65 100644--- a/Services/Compositor/Rust/src/presenting/layers.rs+++ b/Services/Compositor/Rust/src/presenting/layers.rs@@ -1390,43 +1390,35 @@ impl ContextPresenting {PaintedLayerPresentation::HeldByFrame { why }},},- LayerContent::Media { .. } => ModelLayerContent::Media {+ LayerContent::Media { .. } | LayerContent::OwnSurface { .. } => ModelLayerContent::Media {reach: layer.reach,presentation: if window_server_shows_layers && compositing.shown_by_window_server {MediaPresentation::ShownByWindowServer} else {- let why = why_context_shows_no_media- .or_else(|| {- self.why_window_server_does_not_show_media_layer(+ let why = match why_context_shows_no_media {+ Some(why_context_shows_no_media) => why_context_shows_no_media.to_string(),+ // The compositor paints the surface of a caret or scroll bar, which the frame holds only+ // as it holds a painted layer.+ None if matches!(layer.content, LayerContent::OwnSurface { .. }) => self+ .why_frame_holds_layer(env, &layer_update.layers, layer_index, live_content)+ .to_string(),+ None => self+ .why_window_server_does_not_show_media_layer(env,&layer_update.layers.window_server_placements_of_media,layer_index,layer,live_content,)- })- .unwrap_or(if some_tiles_were_painted_straight {- WhyMediaIsReplayed::TilesWerePaintedStraightIntoTheFrame- } else if stack.layer_is_inside_composited_effects(layer_index) {- WhyMediaIsReplayed::InsideAnEffectTheCompositorComposites- } else {- WhyMediaIsReplayed::UnderALayerTheFrameHolds- });- MediaPresentation::Replayed { why: why.to_string() }- },- },- LayerContent::OwnSurface { .. } => ModelLayerContent::Media {- reach: layer.reach,- presentation: if window_server_shows_layers && compositing.shown_by_window_server {- MediaPresentation::ShownByWindowServer- } else {- let why = why_context_shows_no_media.map_or_else(- || {- self.why_frame_holds_layer(env, &layer_update.layers, layer_index, live_content)- .to_string()- },- |why| why.to_string(),- );+ .unwrap_or(if some_tiles_were_painted_straight {+ WhyMediaIsReplayed::TilesWerePaintedStraightIntoTheFrame+ } else if stack.layer_is_inside_composited_effects(layer_index) {+ WhyMediaIsReplayed::InsideAnEffectTheCompositorComposites+ } else {+ WhyMediaIsReplayed::UnderALayerTheFrameHolds+ })+ .to_string(),+ };MediaPresentation::Replayed { why }},},