Skip to content

Truly independent web browser

LibCompositing+LibWeb: Compute record bounding rects from payloads

Aliaksandr Kalenikdbce1ede8147
diff --git a/Libraries/LibCompositing/Rust/src/display_list/builder.rs b/Libraries/LibCompositing/Rust/src/display_list/builder.rs
index 01caad2d669..3f81d19cf91 100644
--- a/Libraries/LibCompositing/Rust/src/display_list/builder.rs
+++ b/Libraries/LibCompositing/Rust/src/display_list/builder.rs
@@ -103,15 +103,40 @@ impl PendingInlineClip {
}
}
- fn header_bounding_rect_restriction(&self) -> Option<IntRect> {
- if self.space.is_some() {
- return None;
- }
- match self.mode {
- ClipMode::Intersect => Some(enclosing_int_rect(self.clip_rect_or_path_device_bounds)),
- ClipMode::Difference => None,
- }
+ fn rect_confining_the_command(&self) -> Option<FloatRect> {
+ (self.space.is_none() && self.mode == ClipMode::Intersect).then_some(self.clip_rect_or_path_device_bounds)
+ }
+}
+
+fn rect_of_inline_clip_confining_its_command(clip: &DisplayListInlineClip) -> Option<FloatRect> {
+ (!clip.has_own_space && clip.mode == ClipMode::Intersect).then_some(clip.clip_rect_or_path_device_bounds)
+}
+
+fn record_bounding_rect(
+ command_bounding_rect: Option<IntRect>,
+ inline_transform: Option<AffineTransform>,
+ rects_of_inline_clips_confining_the_command: impl IntoIterator<Item = FloatRect>,
+) -> Option<IntRect> {
+ let mut bounding_rect = command_bounding_rect;
+ if let (Some(transform), Some(rect)) = (inline_transform, bounding_rect) {
+ bounding_rect = Some(enclosing_int_rect(transform.map_rect(rect.to_float())));
+ }
+ for clip_rect in rects_of_inline_clips_confining_the_command {
+ let restriction = enclosing_int_rect(clip_rect);
+ bounding_rect = Some(match bounding_rect {
+ Some(rect) => rect.intersected(restriction),
+ None => restriction,
+ });
}
+ bounding_rect
+}
+
+pub fn bounding_rect_computed_from_payload(header: &DisplayListCommandHeader, payload: &[u8]) -> Option<IntRect> {
+ record_bounding_rect(
+ command_bounding_rect_computed_from_payload(header.command_type, payload),
+ inline_transform_of(header, payload),
+ inline_clips_of(header, payload).filter_map(|clip| rect_of_inline_clip_confining_its_command(&clip)),
+ )
}
// A finished tape together with the run table summarizing it and the chunks it is cut into.
@@ -471,18 +496,13 @@ impl DisplayListBuilder {
) -> DisplayListCommandHeader {
const { assert!(std::mem::align_of::<C>() <= COMMAND_ALIGNMENT) };
let inline_clip_count = u8::try_from(inline_clips.len()).expect("too many inline clips on one command");
- let mut bounding_rect = command.bounding_rect();
- if let (Some(transform), Some(rect)) = (inline_transform, bounding_rect) {
- bounding_rect = Some(enclosing_int_rect(transform.map_rect(rect.to_float())));
- }
- for clip in inline_clips {
- if let Some(restriction) = clip.header_bounding_rect_restriction() {
- bounding_rect = Some(match bounding_rect {
- Some(rect) => rect.intersected(restriction),
- None => restriction,
- });
- }
- }
+ let bounding_rect = record_bounding_rect(
+ command.bounding_rect(),
+ inline_transform,
+ inline_clips
+ .iter()
+ .filter_map(PendingInlineClip::rect_confining_the_command),
+ );
DisplayListCommandHeader {
command_type: C::COMMAND_TYPE,
has_bounding_rect: bounding_rect.is_some(),
diff --git a/Libraries/LibCompositing/Rust/src/display_list/commands.rs b/Libraries/LibCompositing/Rust/src/display_list/commands.rs
index 3c8293b71c8..e6213c62ac7 100644
--- a/Libraries/LibCompositing/Rust/src/display_list/commands.rs
+++ b/Libraries/LibCompositing/Rust/src/display_list/commands.rs
@@ -4,6 +4,7 @@
* SPDX-License-Identifier: BSD-2-Clause
*/
+use super::builder::read_command;
use crate::display_list::ffi_bytes::FfiBytes;
use crate::ffi_bytes_fields;
use crate::ffi_enum_bytes;
@@ -691,6 +692,67 @@ pub trait DisplayListCommand: Copy + FfiBytes {
}
}
+pub fn command_bounding_rect_computed_from_payload(
+ command_type: DisplayListCommandType,
+ payload: &[u8],
+) -> Option<IntRect> {
+ fn of<C: DisplayListCommand>(payload: &[u8]) -> Option<IntRect> {
+ read_command::<C>(payload).bounding_rect()
+ }
+ use DisplayListCommandType as T;
+ match command_type {
+ T::DrawGlyphRun => of::<DrawGlyphRun>(payload),
+ T::FillRect => of::<FillRect>(payload),
+ T::PaintCaret => of::<PaintCaret>(payload),
+ T::DrawScaledDecodedImageFrame => of::<DrawScaledDecodedImageFrame>(payload),
+ T::DrawRepeatedDecodedImageFrame => of::<DrawRepeatedDecodedImageFrame>(payload),
+ T::DrawRepeatedTile => of::<DrawRepeatedTile>(payload),
+ T::DrawTiledDecodedImageFrame => of::<DrawTiledDecodedImageFrame>(payload),
+ T::DrawCompositedContext => of::<DrawCompositedContext>(payload),
+ T::DrawCanvas => of::<DrawCanvas>(payload),
+ T::DrawVideoFrame => of::<DrawVideoFrame>(payload),
+ T::PaintLinearGradient => of::<PaintLinearGradient>(payload),
+ T::PaintRadialGradient => of::<PaintRadialGradient>(payload),
+ T::PaintConicGradient => of::<PaintConicGradient>(payload),
+ T::PaintOuterBoxShadow => of::<PaintOuterBoxShadow>(payload),
+ T::PaintInnerBoxShadow => of::<PaintInnerBoxShadow>(payload),
+ T::PaintPathBoxShadow => of::<PaintPathBoxShadow>(payload),
+ T::PaintTextShadow => of::<PaintTextShadow>(payload),
+ T::FillRectWithRoundedCorners => of::<FillRectWithRoundedCorners>(payload),
+ T::FillRoundedRectRing => of::<FillRoundedRectRing>(payload),
+ T::FillPath => of::<FillPath>(payload),
+ T::StrokePath => of::<StrokePath>(payload),
+ T::DrawEllipse => of::<DrawEllipse>(payload),
+ T::DrawLine => of::<DrawLine>(payload),
+ T::BackdropFilterRegion => of::<BackdropFilterRegion>(payload),
+ T::DrawRect => of::<DrawRect>(payload),
+ T::PaintVectorImage => of::<PaintVectorImage>(payload),
+ T::DrawIsolatedGroup => of::<DrawIsolatedGroup>(payload),
+ T::DeclareMaskContent => of::<DeclareMaskContent>(payload),
+ T::CompositorWheelHitTestTarget => of::<CompositorWheelHitTestTarget>(payload),
+ T::CompositorWheelHitTestTargetWithCornerRadii => of::<CompositorWheelHitTestTargetWithCornerRadii>(payload),
+ T::CompositorMainThreadWheelEventRegion => of::<CompositorMainThreadWheelEventRegion>(payload),
+ T::CompositorScrollbar => of::<CompositorScrollbar>(payload),
+ T::CompositorBlockingWheelEventRegion => of::<CompositorBlockingWheelEventRegion>(payload),
+ T::PaintScrollBar => of::<PaintScrollBar>(payload),
+ T::CompositorNestedContextWheelRegion => of::<CompositorNestedContextWheelRegion>(payload),
+ T::Canvas2DFillPath => of::<Canvas2DFillPath>(payload),
+ T::Canvas2DStrokePath => of::<Canvas2DStrokePath>(payload),
+ T::Canvas2DDrawGlyphRuns => of::<Canvas2DDrawGlyphRuns>(payload),
+ T::Canvas2DClearRect => of::<Canvas2DClearRect>(payload),
+ T::Canvas2DDrawImageFrame => of::<Canvas2DDrawImageFrame>(payload),
+ T::Canvas2DDrawCanvas => of::<Canvas2DDrawCanvas>(payload),
+ T::Canvas2DDrawVideoFrame => of::<Canvas2DDrawVideoFrame>(payload),
+ T::Canvas2DSetTransform => of::<Canvas2DSetTransform>(payload),
+ T::Canvas2DSave => of::<Canvas2DSave>(payload),
+ T::Canvas2DRestore => of::<Canvas2DRestore>(payload),
+ T::Canvas2DClipPath => of::<Canvas2DClipPath>(payload),
+ T::Canvas2DReset => of::<Canvas2DReset>(payload),
+ T::Canvas2DClearCanvas => of::<Canvas2DClearCanvas>(payload),
+ T::Canvas2DPutImageFrame => of::<Canvas2DPutImageFrame>(payload),
+ }
+}
+
#[derive(Clone, Copy, Debug, PartialEq)]
#[repr(C)]
pub struct DrawGlyphRun {
diff --git a/Libraries/LibCompositing/Rust/src/display_list/damage.rs b/Libraries/LibCompositing/Rust/src/display_list/damage.rs
index 7f8a424ce9b..7a08bd0f59c 100644
--- a/Libraries/LibCompositing/Rust/src/display_list/damage.rs
+++ b/Libraries/LibCompositing/Rust/src/display_list/damage.rs
@@ -11,7 +11,8 @@ use super::layers::{LayerKind, LayerPlan};
use super::replay::{OwnSpaceClipExtent, own_space_clip_extent};
use super::summary::{DisplayListSummary, LiveContent};
use crate::display_list::builder::{
- HEADER_SIZE, for_each_command, has_inline_clip_in_its_own_space, inline_clips_of, read_header,
+ HEADER_SIZE, bounding_rect_computed_from_payload, for_each_command, has_inline_clip_in_its_own_space,
+ inline_clips_of, read_header,
};
use crate::display_list::commands::{
CanvasId, ClipMode, ClipNodeIndex, CompositorContextId, ContextRef, DisplayListCommandHeader,
@@ -452,17 +453,15 @@ impl<'a> SideGeometry<'a> {
// Where a command's inline clips in spaces of their own let it draw on one side of the comparison.
fn own_space_clip_extent_of(&self, record: &RecordOnTape<'_>) -> Option<OwnSpaceClipExtent> {
- if record.header.inline_clip_count == 0
- || !record.header.has_bounding_rect
- || !has_inline_clip_in_its_own_space(&record.header, record.payload)
- {
+ if record.header.inline_clip_count == 0 || !has_inline_clip_in_its_own_space(&record.header, record.payload) {
return None;
}
+ let bounding_rect = bounding_rect_computed_from_payload(&record.header, record.payload)?;
let world = self.world();
own_space_clip_extent(
&record.header,
record.payload,
- record.header.bounding_rect.to_float(),
+ bounding_rect.to_float(),
world.draw_matrix_if_known(record.context.spatial)?,
|space| world.draw_matrix_if_known(space),
)
@@ -630,14 +629,15 @@ impl DamageAccumulator<'_> {
if side.geometry.culling().context_culls_everything(record.context) {
return;
}
- // Only compositor metadata, which draws nothing, has no bounding rect.
- if !record.header.has_bounding_rect {
+ if record.header.command_type.is_compositor_metadata() {
return;
}
// The bounds of a command leave out its inline clips in spaces of their own, so they limit it here.
let rect = match side.geometry.own_space_clip_extent_of(record) {
Some(OwnSpaceClipExtent::Within(rect)) => rect,
- _ => record.header.bounding_rect.to_float(),
+ _ => bounding_rect_computed_from_payload(&record.header, record.payload)
+ .unwrap_or_default()
+ .to_float(),
};
if rect.is_empty() {
return;
@@ -1036,8 +1036,9 @@ pub fn animated_content_may_affect_viewport(
may_affect_viewport = true;
return;
}
- let mut rect = header.bounding_rect.to_float();
- if has_inline_clip_in_its_own_space && header.has_bounding_rect {
+ let bounding_rect = bounding_rect_computed_from_payload(header, payload);
+ let mut rect = bounding_rect.unwrap_or_default().to_float();
+ if has_inline_clip_in_its_own_space && bounding_rect.is_some() {
let world =
world.get_or_init(|| WorldTransforms::new(tree, scroll_offsets, Some(FloatMatrix4x4::identity())));
if let Some(command_to_root) = world.draw_matrix_if_known(run.context.spatial)
diff --git a/Libraries/LibCompositing/Rust/src/display_list/layers.rs b/Libraries/LibCompositing/Rust/src/display_list/layers.rs
index 5b5b433444d..4008fc54d30 100644
--- a/Libraries/LibCompositing/Rust/src/display_list/layers.rs
+++ b/Libraries/LibCompositing/Rust/src/display_list/layers.rs
@@ -4,7 +4,9 @@
* SPDX-License-Identifier: BSD-2-Clause
*/
-use crate::display_list::builder::{HEADER_SIZE, for_each_command, read_command, read_header};
+use crate::display_list::builder::{
+ HEADER_SIZE, bounding_rect_computed_from_payload, for_each_command, read_command, read_header,
+};
use crate::display_list::commands::{
ClipMode, ClipNodeIndex, DeclareMaskContent, DisplayListCommandRun, DisplayListCommandType, EffectNodeIndex,
};
@@ -602,7 +604,10 @@ fn media_layer_rejection(
if !bounds.world.draw_matrix(run.context.spatial).is_2d_affine() {
return Some(MediaLayerRejection::UnderTransformThatIsNot2DAffine);
}
- if bounds.ink_device_rect(run, header.bounding_rect).is_empty() {
+ let payload_start = record_offset as usize + HEADER_SIZE;
+ let payload = &inputs.tape[payload_start..payload_start + header.payload_size as usize];
+ let bounding_rect = bounding_rect_computed_from_payload(&header, payload).unwrap_or_default();
+ if bounds.ink_device_rect(run, bounding_rect).is_empty() {
return Some(MediaLayerRejection::DrawsNothingVisible);
}
if !run_is_a_chunk_of_its_own(run_index) {
@@ -760,17 +765,19 @@ fn place_records_in_layers(
if let Some((media_index, candidate)) =
media_iter.next_if(|(_, candidate)| candidate.record_offset == begin_offset)
{
- let media_bounds = bounds.ink_device_rect(run, header.bounding_rect);
+ let bounding_rect = bounding_rect_computed_from_payload(header, payload).unwrap_or_default();
+ let media_bounds = bounds.ink_device_rect(run, bounding_rect);
let window_server_shows_content = !matches!(candidate.content, LiveContent::CompositedContext(_));
let placement = window_server_shows_content.then(|| {
window_server_placement(inputs.tree, &bounds.world, inputs.viewport_rect, run, header, payload)
});
planned.add_media_layer(media_index, candidate.content, span, media_bounds, placement);
layer_of_previous_painted_record = LayersBeingPlanned::BASE_LAYER_INDEX;
- } else if !header.has_bounding_rect {
+ } else if header.command_type.is_compositor_metadata() {
planned.append_records_to_layer(layer_of_previous_painted_record, span);
} else {
- let record_bounds = bounds.ink_device_rect(run, header.bounding_rect);
+ let bounding_rect = bounding_rect_computed_from_payload(header, payload).unwrap_or_default();
+ let record_bounds = bounds.ink_device_rect(run, bounding_rect);
layer_of_previous_painted_record = planned.place_painted_records(span, record_bounds);
}
});
diff --git a/Libraries/LibCompositing/Rust/src/display_list/replay.rs b/Libraries/LibCompositing/Rust/src/display_list/replay.rs
index f8a5a50dc70..76de236d14a 100644
--- a/Libraries/LibCompositing/Rust/src/display_list/replay.rs
+++ b/Libraries/LibCompositing/Rust/src/display_list/replay.rs
@@ -5,7 +5,8 @@
*/
use crate::display_list::builder::{
- for_each_command, has_inline_clip_in_its_own_space, inline_clips_of, inline_transform_of, read_command,
+ bounding_rect_computed_from_payload, for_each_command, has_inline_clip_in_its_own_space, inline_clips_of,
+ inline_transform_of, read_command,
};
use crate::display_list::commands::{
ClipMode, ClipNodeIndex, DeclareMaskContent, DisplayListCommandHeader, DisplayListCommandRun,
@@ -557,10 +558,11 @@ pub fn replay_records<'t, Painter: ReplayPainter + ?Sized>(
if header.command_type.is_compositor_metadata() {
return;
}
- if replays_nested_records_where_it_plays(header.command_type, payload)
- && (header.bounding_rect.is_empty() || painter.would_be_fully_clipped_by_painter(header.bounding_rect))
- {
- return;
+ if replays_nested_records_where_it_plays(header.command_type, payload) {
+ let bounding_rect = bounding_rect_computed_from_payload(header, payload).unwrap_or_default();
+ if bounding_rect.is_empty() || painter.would_be_fully_clipped_by_painter(bounding_rect) {
+ return;
+ }
}
// The matrix of the command's space, while an inline clip in a space of its own has the canvas in another.
let mut command_space_matrix = None;
@@ -571,7 +573,9 @@ pub fn replay_records<'t, Painter: ReplayPainter + ?Sized>(
if let Some(OwnSpaceClipExtent::Within(rect)) = own_space_clip_extent(
header,
payload,
- header.bounding_rect.to_float(),
+ bounding_rect_computed_from_payload(header, payload)
+ .unwrap_or_default()
+ .to_float(),
command_to_root,
clip_space_matrix,
) && (rect.is_empty() || painter.would_be_fully_clipped_by_painter(enclosing_int_rect(rect)))
diff --git a/Libraries/LibCompositing/Rust/src/scrolling/display_list.rs b/Libraries/LibCompositing/Rust/src/scrolling/display_list.rs
index dbe1d44f787..76dbb74780c 100644
--- a/Libraries/LibCompositing/Rust/src/scrolling/display_list.rs
+++ b/Libraries/LibCompositing/Rust/src/scrolling/display_list.rs
@@ -7,7 +7,7 @@
//! Everything about a list that travels alongside its tape when it is sent to the Compositor.
use super::ContextRef;
-use crate::display_list::builder::read_command;
+use crate::display_list::builder::{bounding_rect_computed_from_payload, read_command};
use crate::display_list::commands::{DisplayListCommandType, PaintCaret};
use crate::display_list::storage::DisplayListStorage;
use crate::display_list::summary::{for_each_compositor_metadata, for_each_indexed_record};
@@ -96,7 +96,11 @@ impl DisplayList {
&self.storage.summary().carets,
|context, header, payload| {
let command = read_command::<PaintCaret>(payload);
- visit(context, header.bounding_rect, &command);
+ visit(
+ context,
+ bounding_rect_computed_from_payload(header, payload).unwrap_or_default(),
+ &command,
+ );
},
);
}
diff --git a/Libraries/LibWeb/Rust/src/painting/record/ink_bounds.rs b/Libraries/LibWeb/Rust/src/painting/record/ink_bounds.rs
index b4b3773f609..bf65273a718 100644
--- a/Libraries/LibWeb/Rust/src/painting/record/ink_bounds.rs
+++ b/Libraries/LibWeb/Rust/src/painting/record/ink_bounds.rs
@@ -12,9 +12,9 @@ use super::trace::Observer;
use crate::css::css_pixels::{CssPixelRect, CssPixels};
use crate::fast_hash::FastMap;
use crate::layout::node_data::{NodeKind, NodeSlotId};
-use crate::painting::display_list::builder::for_each_command;
+use crate::painting::display_list::builder::{bounding_rect_computed_from_payload, for_each_command};
use crate::painting::display_list::commands::{
- ClipMode, ClipNodeIndex, ContextRef, DisplayListCommandHeader, DisplayListCommandType, SpatialNodeIndex,
+ ClipMode, ClipNodeIndex, ContextRef, DisplayListCommandType, SpatialNodeIndex,
};
use crate::painting::display_list::device_pixels::DevicePixelConverter;
use crate::painting::ink_overflow::{InkOverflow, ScopeInkBound, own_ink_overflow, scope_ink_bound};
@@ -143,14 +143,15 @@ fn command_draws_inputs_driven_ink(
converter: DevicePixelConverter,
owner: NodeSlotId,
inputs_ink_in_device_pixels: Option<IntRect>,
- header: &DisplayListCommandHeader,
+ command_type: DisplayListCommandType,
+ bounding_rect: IntRect,
) -> bool {
- inputs_ink_in_device_pixels.is_some_and(|rect| rect.contains_rect(header.bounding_rect))
- && (header.command_type == DisplayListCommandType::PaintCaret
- || (header.command_type == DisplayListCommandType::FillRect
+ inputs_ink_in_device_pixels.is_some_and(|rect| rect.contains_rect(bounding_rect))
+ && (command_type == DisplayListCommandType::PaintCaret
+ || (command_type == DisplayListCommandType::FillRect
&& inputs.caret.is_some_and(|caret| {
caret.target == CaretTarget::EmptyInline(owner)
- && converter.rounded_device_rect(caret.rect) == header.bounding_rect
+ && converter.rounded_device_rect(caret.rect) == bounding_rect
})))
}
@@ -273,30 +274,44 @@ impl<O: Observer> PaintRecorder<'_, O> {
let runs = self.recorder.command_runs();
let mut run_index = runs.partition_point(|run| (run.offset + run.size) as usize <= bytes.start);
let mut counts = [false; COUNT_NAMES.len()];
- for_each_command(&self.recorder.bytes()[bytes.clone()], |header, offset, _| {
+ for_each_command(&self.recorder.bytes()[bytes.clone()], |header, offset, payload| {
let absolute_offset = bytes.start + offset;
while absolute_offset >= (runs[run_index].offset + runs[run_index].size) as usize {
run_index += 1;
}
let spatial = runs[run_index].context.spatial;
- let reason = if header.command_type.is_compositor_metadata() || !header.has_bounding_rect {
- Count::MetadataOrCanvas
- } else if spatial != own_spatial && spatial != descendants_spatial {
- Count::OtherSpatialNode
- } else if command_draws_inputs_driven_ink(self.inputs, self.converter, owner, inputs_ink, header) {
- Count::InputDriven
- } else if !header.bounding_rect.is_empty() && !estimate_device.contains_rect(header.bounding_rect) {
- panic!(
- "Paint ink bounds violation: {kind:?} of {:?} {owner:?}, border box {:?}, recorded {} {:?} outside own estimate {:?} (device pixels, including 2px comparison slack; CSS estimate {:?})",
- self.source.node_kind_if_live(owner),
- crate::painting::paintable_geometry::absolute_border_box_rect(self.source, owner),
- header.command_type.name(),
- header.bounding_rect,
- estimate_device,
- estimate.rect
- );
+ let bounding_rect = if header.command_type.is_compositor_metadata() {
+ None
} else {
- Count::Checked
+ bounding_rect_computed_from_payload(header, payload)
+ };
+ let reason = match bounding_rect {
+ None => Count::MetadataOrCanvas,
+ Some(_) if spatial != own_spatial && spatial != descendants_spatial => Count::OtherSpatialNode,
+ Some(bounding_rect)
+ if command_draws_inputs_driven_ink(
+ self.inputs,
+ self.converter,
+ owner,
+ inputs_ink,
+ header.command_type,
+ bounding_rect,
+ ) =>
+ {
+ Count::InputDriven
+ }
+ Some(bounding_rect) if !bounding_rect.is_empty() && !estimate_device.contains_rect(bounding_rect) => {
+ panic!(
+ "Paint ink bounds violation: {kind:?} of {:?} {owner:?}, border box {:?}, recorded {} {:?} outside own estimate {:?} (device pixels, including 2px comparison slack; CSS estimate {:?})",
+ self.source.node_kind_if_live(owner),
+ crate::painting::paintable_geometry::absolute_border_box_rect(self.source, owner),
+ header.command_type.name(),
+ bounding_rect,
+ estimate_device,
+ estimate.rect
+ );
+ }
+ Some(_) => Count::Checked,
};
counts[reason as usize] = true;
});
@@ -454,23 +469,30 @@ impl<O: Observer> PaintRecorder<'_, O> {
};
let runs = self.recorder.command_runs();
let mut run_index = runs.partition_point(|run| (run.offset + run.size) as usize <= bytes.start);
- for_each_command(&self.recorder.bytes()[bytes.clone()], |header, offset, _| {
+ for_each_command(&self.recorder.bytes()[bytes.clone()], |header, offset, payload| {
let absolute_offset = bytes.start + offset;
while absolute_offset >= (runs[run_index].offset + runs[run_index].size) as usize {
run_index += 1;
}
- if header.command_type.is_compositor_metadata()
- || !header.has_bounding_rect
- || header.bounding_rect.is_empty()
- || command_draws_inputs_driven_ink(inputs, converter, owner, inputs_ink, header)
+ if header.command_type.is_compositor_metadata() {
+ return;
+ }
+ let Some(bounding_rect) = bounding_rect_computed_from_payload(header, payload) else {
+ return;
+ };
+ if bounding_rect.is_empty()
+ || command_draws_inputs_driven_ink(
+ inputs,
+ converter,
+ owner,
+ inputs_ink,
+ header.command_type,
+ bounding_rect,
+ )
{
return;
}
- require_inside_open_scopes(
- &header.command_type.name(),
- header.bounding_rect,
- runs[run_index].context,
- );
+ require_inside_open_scopes(&header.command_type.name(), bounding_rect, runs[run_index].context);
});
if checked {
self.ink_bounds_audit.count(Count::CheckedAgainstScopes);
diff --git a/Libraries/LibWeb/Rust/src/painting/record/traversal.rs b/Libraries/LibWeb/Rust/src/painting/record/traversal.rs
index 178027f3707..e9368216474 100644
--- a/Libraries/LibWeb/Rust/src/painting/record/traversal.rs
+++ b/Libraries/LibWeb/Rust/src/painting/record/traversal.rs
@@ -268,7 +268,7 @@ fn require_only_what_misses_the_window_is_left_out(
of_whole_document: &RecordingOutput,
spaces: &WindowSpaces<'_>,
) {
- use crate::painting::display_list::builder::for_each_command;
+ use crate::painting::display_list::builder::{bounding_rect_computed_from_payload, for_each_command};
use crate::painting::display_list::chunks::chunks_of;
let (windowed, whole) = (&of_window.display_list, &of_whole_document.display_list);
let mut chunks_of_window = chunks_of(&windowed.bytes, &windowed.command_runs, &windowed.chunks).peekable();
@@ -288,15 +288,18 @@ fn require_only_what_misses_the_window_is_left_out(
for run in runs {
let run_start = (run.offset - chunk_start) as usize;
let run_bytes = &bytes[run_start..run_start + run.size as usize];
- for_each_command(run_bytes, |header, _, _| {
- if header.command_type.is_compositor_metadata() || !header.has_bounding_rect {
+ for_each_command(run_bytes, |header, _, payload| {
+ if header.command_type.is_compositor_metadata() {
return;
}
+ let Some(bounding_rect) = bounding_rect_computed_from_payload(header, payload) else {
+ return;
+ };
assert!(
- spaces.shows_in_window(header.bounding_rect.to_float(), run.context) != Some(true),
+ spaces.shows_in_window(bounding_rect.to_float(), run.context) != Some(true),
"A recording of a window left out {} at {:?} under {:?}, which shows in the window",
header.command_type.name(),
- header.bounding_rect,
+ bounding_rect,
run.context
);
});
@@ -339,7 +342,7 @@ fn reused_output_is_verified() -> bool {
/// Requires a recording that reused clean output of the published one to be the recording the same frame gives when
/// everything is recorded: a difference is output that was reused though what it shows changed.
fn require_same_recording(assembled: &RecordingOutput, from_scratch: &RecordingOutput) {
- use crate::painting::display_list::builder::for_each_command;
+ use crate::painting::display_list::builder::{bounding_rect_computed_from_payload, for_each_command};
use crate::painting::display_list::chunks::{chunk_id, chunks_of};
let (assembled_list, scratch_list) = (&assembled.display_list, &from_scratch.display_list);
let assembled_bytes = without_vector_image_ids(&assembled_list.bytes);
@@ -352,9 +355,13 @@ fn require_same_recording(assembled: &RecordingOutput, from_scratch: &RecordingO
.unwrap_or(assembled_bytes.len().min(scratch_bytes.len()));
let command_at = |bytes: &[u8]| {
let mut found = None;
- for_each_command(bytes, |header, offset, _| {
+ for_each_command(bytes, |header, offset, payload| {
if offset <= first_differing_byte {
- found = Some((offset, header.command_type.name(), header.bounding_rect));
+ found = Some((
+ offset,
+ header.command_type.name(),
+ bounding_rect_computed_from_payload(header, payload),
+ ));
}
});
found