Skip to content

Truly independent web browser

LibWeb: Trace visual context tree updates

Aliaksandr Kalenik1a9307b5db2b
diff --git a/Libraries/LibCompositing/DisplayList/AccumulatedVisualContext.cpp b/Libraries/LibCompositing/DisplayList/AccumulatedVisualContext.cpp
index 84793ceb3ad..b6446f258c2 100644
--- a/Libraries/LibCompositing/DisplayList/AccumulatedVisualContext.cpp
+++ b/Libraries/LibCompositing/DisplayList/AccumulatedVisualContext.cpp
@@ -87,16 +87,6 @@ ByteBuffer AccumulatedVisualContextTree::serialize_to_bytes() const
return bytes;
}
-size_t AccumulatedVisualContextTree::node_count() const
-{
- return Compositing::RustFFI::visual_context_tree_node_count(m_rust_tree);
-}
-
-size_t AccumulatedVisualContextTree::live_node_count() const
-{
- return Compositing::RustFFI::visual_context_tree_live_node_count(m_rust_tree);
-}
-
bool AccumulatedVisualContextTree::has_visual_animations() const
{
return Compositing::RustFFI::visual_context_tree_has_visual_animations(m_rust_tree);
diff --git a/Libraries/LibCompositing/DisplayList/AccumulatedVisualContext.h b/Libraries/LibCompositing/DisplayList/AccumulatedVisualContext.h
index abefe3febe4..06f75754471 100644
--- a/Libraries/LibCompositing/DisplayList/AccumulatedVisualContext.h
+++ b/Libraries/LibCompositing/DisplayList/AccumulatedVisualContext.h
@@ -48,9 +48,6 @@ public:
bool has_visual_animations() const;
VisualAnimationSummary visual_animation_summary() const;
- // Node counts cover all slots, live or dead, or only live slots.
- size_t node_count() const;
- size_t live_node_count() const;
// A copy whose nodes carry the values the animations take at the time.
AccumulatedVisualContextTree with_visual_animation_samples(i64 monotonic_time_ns) const;
// The sampled background color of a recorded fill's animation effect.
diff --git a/Libraries/LibCompositing/Rust/src/ffi.rs b/Libraries/LibCompositing/Rust/src/ffi.rs
index 72e3f60e102..f9d20dc773b 100644
--- a/Libraries/LibCompositing/Rust/src/ffi.rs
+++ b/Libraries/LibCompositing/Rust/src/ffi.rs
@@ -198,22 +198,6 @@ pub unsafe extern "C" fn visual_context_tree_deserialize(bytes: *const u8, lengt
}
}
-/// # Safety
-///
-/// `tree` must be a live retained tree handle. Every node slot, live or dead.
-#[unsafe(no_mangle)]
-pub unsafe extern "C" fn visual_context_tree_node_count(tree: *const c_void) -> usize {
- unsafe { tree_from_handle(tree) }.node_count()
-}
-
-/// # Safety
-///
-/// `tree` must be a live retained tree handle.
-#[unsafe(no_mangle)]
-pub unsafe extern "C" fn visual_context_tree_live_node_count(tree: *const c_void) -> usize {
- unsafe { tree_from_handle(tree) }.live_node_count()
-}
-
/// # Safety
///
/// `tree` must be a live retained tree handle and `storage` a live storage handle.
diff --git a/Libraries/LibWeb/Internals/Internals.cpp b/Libraries/LibWeb/Internals/Internals.cpp
index 12fdca614ef..64108ae9908 100644
--- a/Libraries/LibWeb/Internals/Internals.cpp
+++ b/Libraries/LibWeb/Internals/Internals.cpp
@@ -218,55 +218,44 @@ void Internals::force_incompatible_visual_context_tree_rebuild()
document.schedule_full_accumulated_visual_context_rebuild(Layout::RustFFI::VisualContextUpdateScope::FreshTree);
}
-u64 Internals::accumulated_visual_context_incremental_update_count()
+Utf16String Internals::dump_visual_context_nodes(DOM::Element& element)
{
auto& document = window().associated_document();
- if (!document.has_committed_viewport_box())
- return 0;
- return Layout::RustFFI::document_host_visual_context_tree_incremental_update_count(document.layout_node_arena().host());
-}
-
-u64 Internals::visual_context_tree_node_count()
-{
- // A script reads the render state, which waits for a frame in flight.
- Layout::ForcedReadScope read { window().associated_document() };
- auto& document = window().associated_document();
- if (!document.has_committed_viewport_box() || !document.paint_state().has_visual_context_tree(read))
- return 0;
- auto visual_context_tree = document.paint_state().visual_context_tree(document);
- return visual_context_tree.live_node_count();
-}
-
-u64 Internals::visual_context_tree_dead_node_count()
-{
- // A script reads the render state, which waits for a frame in flight.
- Layout::ForcedReadScope read { window().associated_document() };
- auto& document = window().associated_document();
- if (!document.has_committed_viewport_box() || !document.paint_state().has_visual_context_tree(read))
- return 0;
- auto visual_context_tree = document.paint_state().visual_context_tree(document);
- return visual_context_tree.node_count() - visual_context_tree.live_node_count();
-}
-
-u64 Internals::visual_context_tree_structural_epoch()
-{
- // A script reads the render state, which waits for a frame in flight.
- Layout::ForcedReadScope read { window().associated_document() };
- auto& document = window().associated_document();
- if (!document.has_committed_viewport_box() || !document.paint_state().has_visual_context_tree(read))
- return 0;
- return document.paint_state().visual_context_tree(document).structural_epoch();
-}
-
-u64 Internals::visual_context_tree_node_capacity()
-{
- // A script reads the render state, which waits for a frame in flight.
- Layout::ForcedReadScope read { window().associated_document() };
- auto& document = window().associated_document();
- if (!document.has_committed_viewport_box() || !document.paint_state().has_visual_context_tree(read))
- return 0;
- auto visual_context_tree = document.paint_state().visual_context_tree(document);
- return visual_context_tree.node_count();
+ Layout::ForcedReadScope read { document };
+ document.update_layout(DOM::UpdateLayoutReason::Debugging);
+ auto const* layout_node = element.layout_node(read);
+ if (!layout_node || !Painting::has_committed_box(*layout_node))
+ return "(no box)"_utf16;
+ struct Context {
+ Layout::BegunRead const& read;
+ GC::Ref<DOM::Document> document;
+ StringBuilder builder;
+ } context { read, document, {} };
+ Layout::RustFFI::render_state_dump_box_visual_context_nodes(layout_node->document_host(), Painting::committed_row_slot(*layout_node), &context,
+ [](void* raw_context, u8 kind, u32 index, u8 const* text, size_t length) {
+ auto& context = *static_cast<Context*>(raw_context);
+ context.builder.appendff("[{}{}] {}", kind == 0 ? 's' : kind == 1 ? 'c'
+ : 'e',
+ index, StringView { text, length });
+ if (kind == 2) {
+ Vector<Gfx::Color> keyframe_colors;
+ Layout::RustFFI::render_state_background_color_animation_keyframe_colors(context.document->layout_node_arena().host(), &context.read, index, &keyframe_colors, [](void* colors, Gfx::Color color) {
+ static_cast<Vector<Gfx::Color>*>(colors)->append(color);
+ });
+ if (!keyframe_colors.is_empty()) {
+ context.builder.append(" keyframes=["sv);
+ for (size_t i = 0; i < keyframe_colors.size(); ++i)
+ context.builder.appendff("{}{}", i ? ", "sv : ""sv, keyframe_colors[i].to_string());
+ context.builder.append(']');
+ }
+ }
+ context.builder.append('\n');
+ });
+ if (layout_node->needs_compositor_effects_layer())
+ context.builder.append("compositor effects layer\n"sv);
+ if (layout_node->needs_compositor_background_color_frame())
+ context.builder.append("compositor background-color frame\n"sv);
+ return Utf16String::from_utf8_without_validation(context.builder.string_view());
}
GC::Ref<JS::Object> Internals::visual_context_node_indices(DOM::Element& element)
@@ -1597,6 +1586,46 @@ Utf16String Internals::take_display_list_trace()
return Utf16String::from_utf8_without_validation(builder.string_view());
}
+void Internals::begin_visual_context_trace()
+{
+ Layout::RustFFI::render_state_begin_visual_context_trace(window().associated_document().layout_node_arena().host());
+}
+
+Utf16String Internals::take_visual_context_trace()
+{
+ auto& document = window().associated_document();
+ // A script reads the render state, which waits for a frame in flight.
+ Layout::ForcedReadScope read { document };
+ struct Context {
+ GC::Ref<CSS::StyleComputer> style_computer;
+ Utf16StringBuilder builder;
+ } context { document.style_computer(), {} };
+ Layout::RustFFI::render_state_take_visual_context_trace(document.layout_node_arena().host(), read, &context,
+ [](void* raw_context, bool indented, u32 element, u8 const* name, size_t name_length, u8 const* text, size_t text_length) {
+ auto& context = *static_cast<Context*>(raw_context);
+ if (indented)
+ context.builder.append_ascii(" "sv);
+ GC::Ptr<DOM::Element> dom_element;
+ if (element)
+ dom_element = context.style_computer->element_for_style_node(CSS::StyleNodeID { element });
+ if (dom_element)
+ context.builder.appendff("{}", dom_element->debug_description());
+ else
+ context.builder.append_ascii(StringView { name, name_length });
+ context.builder.append_ascii(StringView { text, text_length });
+ context.builder.append_ascii('\n');
+ });
+ return context.builder.to_string();
+}
+
+void Internals::update_visual_contexts_for_testing()
+{
+ auto& document = window().associated_document();
+ Layout::ForcedReadScope read { document };
+ document.update_layout(DOM::UpdateLayoutReason::Debugging);
+ Layout::RustFFI::render_state_prepare_paint_properties_for_testing(document.layout_node_arena().host(), read);
+}
+
void Internals::begin_input_trace()
{
page().input_trace().begin();
diff --git a/Libraries/LibWeb/Internals/Internals.h b/Libraries/LibWeb/Internals/Internals.h
index 647497775ce..77d470d60ad 100644
--- a/Libraries/LibWeb/Internals/Internals.h
+++ b/Libraries/LibWeb/Internals/Internals.h
@@ -56,12 +56,8 @@ public:
void set_force_dark_enabled(bool);
void set_show_line_box_borders(bool);
void set_force_dark_thresholds(i32, i32);
- u64 visual_context_tree_node_count();
- u64 accumulated_visual_context_incremental_update_count();
- u64 visual_context_tree_node_capacity();
- u64 visual_context_tree_dead_node_count();
- u64 visual_context_tree_structural_epoch();
GC::Ref<JS::Object> visual_context_node_indices(DOM::Element&);
+ Utf16String dump_visual_context_nodes(DOM::Element&);
void send_mismatched_visual_context_tree_update_to_compositor();
WebIDL::ExceptionOr<void> load_reference_test_metadata();
@@ -193,6 +189,9 @@ public:
Utf16String take_layout_trace();
WebIDL::UnsignedLongLong accumulated_visual_context_tree_build_count();
void begin_display_list_trace();
+ void begin_visual_context_trace();
+ Utf16String take_visual_context_trace();
+ void update_visual_contexts_for_testing();
Utf16String take_display_list_trace();
void begin_input_trace();
GC::Ref<JS::Object> take_input_trace();
diff --git a/Libraries/LibWeb/Internals/Internals.idl b/Libraries/LibWeb/Internals/Internals.idl
index 49b0752d148..16946f6a474 100644
--- a/Libraries/LibWeb/Internals/Internals.idl
+++ b/Libraries/LibWeb/Internals/Internals.idl
@@ -11,12 +11,10 @@ interface Internals {
undefined setForceDarkEnabled(boolean enabled);
undefined setShowLineBoxBorders(boolean enabled);
undefined setForceDarkThresholds(long foreground, long background);
- unsigned long long visualContextTreeNodeCount();
- unsigned long long accumulatedVisualContextIncrementalUpdateCount();
- unsigned long long visualContextTreeNodeCapacity();
- unsigned long long visualContextTreeDeadNodeCount();
- unsigned long long visualContextTreeStructuralEpoch();
object visualContextNodeIndices(Element element);
+ // The nodes of the visual context tree the box of the element owns, one per line as the tree dump describes them
+ // with their indices, then whether the box needs a compositor effects layer or a compositor background-color frame.
+ DOMString dumpVisualContextNodes(Element element);
undefined sendMismatchedVisualContextTreeUpdateToCompositor();
undefined loadReferenceTestMetadata();
@@ -202,6 +200,13 @@ interface Internals {
unsigned long long accumulatedVisualContextTreeBuildCount();
undefined beginDisplayListTrace();
DOMString takeDisplayListTrace();
+ // Traces what the updates of the visual context tree do until takeVisualContextTrace(), which answers one block per
+ // update: its scope, then a line per node of a box it allocated, repurposed, updated or released, and whether it
+ // gave the tree a new structural epoch or needs a new recording. Updates run by the render clock are not traced.
+ undefined beginVisualContextTrace();
+ DOMString takeVisualContextTrace();
+ // Lays out and brings the visual context tree up to date, as a read of paint properties does.
+ undefined updateVisualContextsForTesting();
// Records where the compositor and this process route each input event, and why, until takeInputTrace().
undefined beginInputTrace();
object takeInputTrace();
diff --git a/Libraries/LibWeb/Rust/src/painting/ffi.rs b/Libraries/LibWeb/Rust/src/painting/ffi.rs
index e7ba503cbb4..c46afa8af1b 100644
--- a/Libraries/LibWeb/Rust/src/painting/ffi.rs
+++ b/Libraries/LibWeb/Rust/src/painting/ffi.rs
@@ -195,14 +195,6 @@ pub extern "C" fn document_host_visual_context_tree_build_count(host: &DocumentH
host.paint_preparation().visual_context_tree_build_count.get()
}
-/// How many times the visual context tree of `host`'s document was updated in place.
-#[unsafe(no_mangle)]
-pub extern "C" fn document_host_visual_context_tree_incremental_update_count(host: &DocumentHost) -> u64 {
- host.paint_preparation()
- .visual_context_tree_incremental_update_count
- .get()
-}
-
/// Has `host` forget its document's scroll state and the visual context tree changes left for the compositor, as the
/// viewport's row or the document's paint state starts over.
#[unsafe(no_mangle)]
diff --git a/Libraries/LibWeb/Rust/src/painting/ffi/main_thread_entries.rs b/Libraries/LibWeb/Rust/src/painting/ffi/main_thread_entries.rs
index 6f2b06c2822..4d1c44680cb 100644
--- a/Libraries/LibWeb/Rust/src/painting/ffi/main_thread_entries.rs
+++ b/Libraries/LibWeb/Rust/src/painting/ffi/main_thread_entries.rs
@@ -544,6 +544,61 @@ pub unsafe extern "C" fn render_state_paintable_visual_context_copy_node_indices
out.into_slice()[..indices.len()].copy_from_slice(&indices);
}
+/// Hands `append_line` each node of the prepared visual context tree the box in `slot` owns, as the tree dump describes
+/// it: its kind (0 for spatial, 1 for clip, 2 for effect), its index and its description.
+///
+/// # Safety
+///
+/// `host` must be a live document host, on its document's thread, and `append_line` must copy the bytes synchronously.
+#[unsafe(no_mangle)]
+pub unsafe extern "C" fn render_state_dump_box_visual_context_nodes(
+ host: &crate::render_state::DocumentHost,
+ slot: NodeSlotId,
+ context: *mut std::ffi::c_void,
+ append_line: unsafe extern "C" fn(*mut std::ffi::c_void, u8, u32, *const u8, usize),
+) {
+ // SAFETY: Guaranteed by the caller.
+ unsafe { prepare_paint_properties(host, host.begun_read_of_held_node(super::node_read())) };
+ let lines = read_arena(host, super::node_read(), slot, |arena, slot| {
+ use crate::painting::visual_context::dump::VisualContextTreeDump;
+ let Some(tree) = arena.paint_state().visual_context.tree.clone() else {
+ return Vec::new();
+ };
+ arena.with_paintable_visual_context_node_handles(slot, |handles| {
+ let spatial = handles
+ .spatial
+ .iter()
+ .map(|&index| (0, index.0, tree.dump_spatial_node(index)));
+ let clips = handles
+ .clip_handles()
+ .map(|index| (1, index.0, tree.dump_clip_node(index)));
+ let effects = handles
+ .effects
+ .iter()
+ .map(|&index| (2, index.0, tree.dump_effect_node(index)));
+ spatial.chain(clips).chain(effects).collect::<Vec<_>>()
+ })
+ });
+ for (kind, index, text) in lines {
+ // SAFETY: Guaranteed by the caller.
+ unsafe { append_line(context, kind, index, text.as_ptr(), text.len()) };
+ }
+}
+
+/// Brings the paint and hit testing properties of `host`'s document up to date, for a test.
+///
+/// # Safety
+///
+/// `host` must be a live document host, on its document's thread.
+#[unsafe(no_mangle)]
+pub unsafe extern "C" fn render_state_prepare_paint_properties_for_testing(
+ host: &crate::render_state::DocumentHost,
+ read: &crate::render_state::BegunRead,
+) {
+ // SAFETY: Guaranteed by the caller.
+ unsafe { prepare_paint_properties(host, read) };
+}
+
/// Where the stacking context structure below the viewport of `host`'s document differs from what paint preparation
/// recorded, handed to `consume` unless it does not.
///
diff --git a/Libraries/LibWeb/Rust/src/painting/paint_changes.rs b/Libraries/LibWeb/Rust/src/painting/paint_changes.rs
index 4a4dbe5a8f7..e2e7b595a14 100644
--- a/Libraries/LibWeb/Rust/src/painting/paint_changes.rs
+++ b/Libraries/LibWeb/Rust/src/painting/paint_changes.rs
@@ -119,6 +119,8 @@ pub(crate) enum PaintChange {
SvgPaintResourcesChanged,
/// Whether the document's recordings are traced.
SetRecordingTraceEnabled(bool),
+ /// The updates of the document's visual context tree are traced from now on.
+ BeginVisualContextTrace,
/// The host published the recording `output` and takes it in as the document's last.
TakeInRecording {
output: Arc<super::record::RecordingOutput>,
@@ -237,6 +239,9 @@ impl PaintChange {
arena.svg_paint_resources_mut().note_changed();
}
Self::SetRecordingTraceEnabled(enabled) => arena.paint_state_mut().trace_recordings = enabled,
+ Self::BeginVisualContextTrace => {
+ arena.paint_state_mut().visual_context.trace = Some(Default::default());
+ }
Self::TakeInRecording {
output,
hit_test_list_changed,
@@ -614,3 +619,48 @@ pub extern "C" fn render_state_visual_context_request_full_rebuild(
pub extern "C" fn render_state_set_recording_trace_enabled(host: &DocumentHost, enabled: bool) {
queue(host, PaintChange::SetRecordingTraceEnabled(enabled));
}
+
+#[unsafe(no_mangle)]
+pub extern "C" fn render_state_begin_visual_context_trace(host: &DocumentHost) {
+ queue(host, PaintChange::BeginVisualContextTrace);
+}
+
+/// Hands `append_line` each line of what the updates of the visual context tree of `host`'s document did since the
+/// trace began, and stops tracing: whether the line is indented, the element of the box it is about or zero, the name
+/// of a box without an element, and the rest of the line.
+///
+/// # Safety
+///
+/// `host` must be a live document host, on its document's thread, and `append_line` must copy the bytes synchronously.
+#[unsafe(no_mangle)]
+pub unsafe extern "C" fn render_state_take_visual_context_trace(
+ host: &DocumentHost,
+ read: &crate::render_state::BegunRead,
+ context: *mut std::ffi::c_void,
+ append_line: unsafe extern "C" fn(*mut std::ffi::c_void, bool, u32, *const u8, usize, *const u8, usize),
+) {
+ let lines = crate::layout::shell_reads::read_arena(host, read, (), |arena, ()| {
+ arena
+ .paint_state_mut()
+ .visual_context
+ .trace
+ .take()
+ .map(|trace| trace.lines)
+ .unwrap_or_default()
+ });
+ for line in lines {
+ let name = line.name_without_element;
+ // SAFETY: Guaranteed by the caller.
+ unsafe {
+ append_line(
+ context,
+ line.indented,
+ line.element.map_or(0, |element| element.raw()),
+ name.as_ptr(),
+ name.len(),
+ line.text.as_ptr(),
+ line.text.len(),
+ );
+ };
+ }
+}
diff --git a/Libraries/LibWeb/Rust/src/painting/paint_passes.rs b/Libraries/LibWeb/Rust/src/painting/paint_passes.rs
index 0c553f4209c..a7c779e4166 100644
--- a/Libraries/LibWeb/Rust/src/painting/paint_passes.rs
+++ b/Libraries/LibWeb/Rust/src/painting/paint_passes.rs
@@ -346,10 +346,9 @@ pub(crate) struct PaintPreparationNotes {
pub(crate) visual_contexts_need_update: Cell<bool>,
/// Whether the visual context tree changed since a frame last took it to the compositor.
pub(crate) visual_context_tree_needs_compositor_update: Cell<bool>,
- /// How many times the preparations built the visual context tree anew, and updated it in place, which tests read
- /// through Internals as differences.
+ /// How many times the preparations built the visual context tree anew, which tests read through Internals as
+ /// differences.
pub(crate) visual_context_tree_build_count: Cell<u64>,
- pub(crate) visual_context_tree_incremental_update_count: Cell<u64>,
}
/// The document's viewport row, where its box is committed.
@@ -475,12 +474,10 @@ fn update_visual_contexts(
);
}
let notes = host.paint_preparation();
- let count = if outcome.performed_full_build {
- &notes.visual_context_tree_build_count
- } else {
- &notes.visual_context_tree_incremental_update_count
- };
- count.set(count.get() + 1);
+ if outcome.performed_full_build {
+ let count = &notes.visual_context_tree_build_count;
+ count.set(count.get() + 1);
+ }
if outcome.requires_display_list_recording || svg_paint_resources_changed {
callbacks.require_display_list_recording(main_thread, false);
}
@@ -650,11 +647,13 @@ pub(crate) fn update_accumulated_visual_contexts(
}
let mut state = std::mem::take(&mut arena.paint_state_mut().visual_context);
state.release_quarantined_slots_while_no_handle_is_retained();
+ let trace_header = state.trace.as_mut().map(|trace| trace.begin_update());
let mut scope = state.dirty_boxes.scope;
if state.tree.is_none() {
scope = VisualContextUpdateScope::FreshTree;
}
+ let asked_scope = scope;
let viewport_overflow = arena
.paintable_rows()
.node_style_if_live(viewport)
@@ -693,6 +692,11 @@ pub(crate) fn update_accumulated_visual_contexts(
}
state.dirty_boxes.clear();
state.last_tree_inputs = Some(inputs);
+ if let (Some(trace), Some(header)) = (state.trace.as_mut(), trace_header) {
+ trace.finish_update(header, asked_scope, scope, &outcome.delta, |slot| {
+ (arena.node_style_node(slot), slot == viewport)
+ });
+ }
let outcome = VisualContextUpdateOutcome {
performed_full_build,
structural_epoch_changed: outcome.delta.structural_epoch_changed,
@@ -711,6 +715,16 @@ pub(crate) fn update_accumulated_visual_contexts(
let outcome = fresh_visual_context_tree_build(arena, viewport, inputs, &mut state);
state.last_tree_inputs = Some(inputs);
+ if let (Some(trace), Some(header)) = (state.trace.as_mut(), trace_header) {
+ let delta = crate::painting::visual_context::delta::VisualContextTreeDelta {
+ structural_epoch_changed: outcome.structural_epoch_changed,
+ requires_display_list_recording: outcome.requires_display_list_recording,
+ tombstoned_any_node: false,
+ };
+ trace.finish_update(header, asked_scope, VisualContextUpdateScope::FreshTree, &delta, |_| {
+ (None, false)
+ });
+ }
arena.paint_state_mut().visual_context = state;
outcome
}
diff --git a/Libraries/LibWeb/Rust/src/painting/paint_state.rs b/Libraries/LibWeb/Rust/src/painting/paint_state.rs
index 89101b888de..11c64152cef 100644
--- a/Libraries/LibWeb/Rust/src/painting/paint_state.rs
+++ b/Libraries/LibWeb/Rust/src/painting/paint_state.rs
@@ -87,6 +87,7 @@ impl PaintState {
pub(crate) fn reset_visual_context_state(&mut self) {
self.visual_context = crate::painting::visual_context::VisualContextState {
needs_to_refresh_scroll_state: true,
+ trace: self.visual_context.trace.take(),
..Default::default()
};
self.visual_context
diff --git a/Libraries/LibWeb/Rust/src/painting/paintable_rows.rs b/Libraries/LibWeb/Rust/src/painting/paintable_rows.rs
index c59a9c26e13..b12f4c26394 100644
--- a/Libraries/LibWeb/Rust/src/painting/paintable_rows.rs
+++ b/Libraries/LibWeb/Rust/src/painting/paintable_rows.rs
@@ -750,6 +750,10 @@ impl LayoutNodeArena {
self.withdraw_stacking_context_state_of_reset_row(id, Some(record.stacking_context));
let former_paint_parent =
crate::painting::paint_order::paint_parent(&self.paintable_rows(), id).unwrap_or(NodeSlotId::INVALID);
+ let element = self.node_style_node(id);
+ if let Some(trace) = self.paint_state_mut().visual_context.trace.as_mut() {
+ trace.note_removed_box(id, element);
+ }
self.paint_state_mut()
.visual_context
.dirty_boxes
diff --git a/Libraries/LibWeb/Rust/src/painting/visual_context/incremental.rs b/Libraries/LibWeb/Rust/src/painting/visual_context/incremental.rs
index 12f575dd111..8a0b5a413eb 100644
--- a/Libraries/LibWeb/Rust/src/painting/visual_context/incremental.rs
+++ b/Libraries/LibWeb/Rust/src/painting/visual_context/incremental.rs
@@ -221,23 +221,41 @@ fn tombstone_removed_blocks(
tree: &mut VisualContextTree,
dirty: &VisualContextDirtySet,
delta: &mut VisualContextTreeDelta,
+ mut trace: Option<&mut super::trace::VisualContextTrace>,
) {
+ use super::reconcile::{NodeAction, NodeEvent, clip_role, effect_role, spatial_role};
for removed in &dirty.removed {
+ let mut events = Vec::new();
+ let mut released = |role: &'static str| {
+ events.push(NodeEvent {
+ role,
+ action: NodeAction::Released,
+ });
+ };
for index in &removed.node_handles.spatial {
+ let role = spatial_role(&tree.spatial_nodes[index.0 as usize].data);
if tree.tombstone_spatial_slot(*index) {
delta.note_tombstoned();
+ released(role);
}
}
for index in removed.node_handles.clip_handles() {
+ let role = clip_role(&tree.clip_nodes[index.0 as usize].data);
if tree.tombstone_clip_slot(index) {
delta.note_tombstoned();
+ released(role);
}
}
for index in &removed.node_handles.effects {
+ let role = effect_role(&tree.effect_nodes[index.0 as usize].data);
if tree.tombstone_effect_slot(*index) {
delta.note_tombstoned();
+ released(role);
}
}
+ if let Some(trace) = trace.as_deref_mut() {
+ trace.note_removed_box_events(removed.slot, &events);
+ }
}
}
@@ -449,7 +467,12 @@ pub(crate) fn update_visual_context_tree<Arena: PaintableRowsWrite>(
scope != VisualContextUpdateScope::FreshTree || state.dirty_boxes.removed.is_empty(),
"removed handles name nodes of the discarded tree"
);
- tombstone_removed_blocks(std::sync::Arc::make_mut(tree), &state.dirty_boxes, &mut delta);
+ tombstone_removed_blocks(
+ std::sync::Arc::make_mut(tree),
+ &state.dirty_boxes,
+ &mut delta,
+ state.trace.as_mut(),
+ );
if scope.rebuilds_every_box() {
state.offset_path_boxes.clear();
}
@@ -555,6 +578,9 @@ pub(crate) fn update_visual_context_tree<Arena: PaintableRowsWrite>(
let tree = std::sync::Arc::make_mut(state.tree.as_mut().expect("the tree exists throughout the pass"));
let existing_handles = layout_arena.paintable_visual_context_node_handles(slot);
let mut writer = BoxNodeWriter::new(tree, existing_handles, &mut delta);
+ if state.trace.is_some() && scope != VisualContextUpdateScope::FreshTree {
+ writer.note_events();
+ }
let environment = BoxBuildEnvironment {
layout_arena: &*layout_arena,
pixel_ratio: tree_inputs.device_pixels_per_css_pixel,
@@ -571,6 +597,12 @@ pub(crate) fn update_visual_context_tree<Arena: PaintableRowsWrite>(
},
);
let (handles, reconcile) = writer.finish();
+ let events = writer.take_events();
+ if !events.is_empty()
+ && let Some(trace) = state.trace.as_mut()
+ {
+ trace.note_box_events(slot, &events);
+ }
if layout_arena
.node_style_if_live(slot)
.is_some_and(|style| style.transform().has_offset_path)
diff --git a/Libraries/LibWeb/Rust/src/painting/visual_context/mod.rs b/Libraries/LibWeb/Rust/src/painting/visual_context/mod.rs
index 50bbb1ceb82..f0a730d03e1 100644
--- a/Libraries/LibWeb/Rust/src/painting/visual_context/mod.rs
+++ b/Libraries/LibWeb/Rust/src/painting/visual_context/mod.rs
@@ -21,6 +21,7 @@ pub mod reconcile;
pub mod records;
pub mod refresh;
pub mod shape;
+pub(crate) mod trace;
pub use dump::VisualContextTreeDump;
pub use libcompositing_rust::visual_context::*;
diff --git a/Libraries/LibWeb/Rust/src/painting/visual_context/reconcile.rs b/Libraries/LibWeb/Rust/src/painting/visual_context/reconcile.rs
index 7005aaf52a0..3c8ebaa63aa 100644
--- a/Libraries/LibWeb/Rust/src/painting/visual_context/reconcile.rs
+++ b/Libraries/LibWeb/Rust/src/painting/visual_context/reconcile.rs
@@ -20,6 +20,7 @@ pub(crate) struct BoxNodeWriter<'a> {
delta: &'a mut VisualContextTreeDelta,
outcome: ReconcileOutcome,
building_descendants: bool,
+ events: Option<Vec<NodeEvent>>,
}
impl<'a> BoxNodeWriter<'a> {
@@ -35,9 +36,19 @@ impl<'a> BoxNodeWriter<'a> {
delta,
outcome: ReconcileOutcome::default(),
building_descendants: false,
+ events: None,
}
}
+ /// Notes what the writer does to each node of the box, for a trace.
+ pub(crate) fn note_events(&mut self) {
+ self.events = Some(Vec::new());
+ }
+
+ pub(crate) fn take_events(&mut self) -> Vec<NodeEvent> {
+ self.events.take().unwrap_or_default()
+ }
+
pub(crate) fn begin_descendants(&mut self) {
debug_assert!(!self.building_descendants);
self.building_descendants = true;
@@ -60,16 +71,18 @@ impl<'a> BoxNodeWriter<'a> {
EffectNode::new(data, parent, spatial, local_clip),
self.delta,
&mut self.outcome,
+ &mut self.events,
)
}
- pub(crate) fn finish(mut self) -> (BoxVisualContextNodeHandles, ReconcileOutcome) {
+ pub(crate) fn finish(&mut self) -> (BoxVisualContextNodeHandles, ReconcileOutcome) {
retire_surplus::<SpatialNode>(
self.tree,
&self.existing.spatial,
self.handles.spatial.len(),
self.delta,
&mut self.outcome,
+ &mut self.events,
);
retire_surplus::<ClipNode>(
self.tree,
@@ -77,6 +90,7 @@ impl<'a> BoxNodeWriter<'a> {
self.handles.chain_clips.len(),
self.delta,
&mut self.outcome,
+ &mut self.events,
);
retire_surplus::<ClipNode>(
self.tree,
@@ -84,6 +98,7 @@ impl<'a> BoxNodeWriter<'a> {
self.handles.descendant_clips.len(),
self.delta,
&mut self.outcome,
+ &mut self.events,
);
retire_surplus::<EffectNode>(
self.tree,
@@ -91,8 +106,9 @@ impl<'a> BoxNodeWriter<'a> {
self.handles.effects.len(),
self.delta,
&mut self.outcome,
+ &mut self.events,
);
- (self.handles, self.outcome)
+ (std::mem::take(&mut self.handles), self.outcome)
}
}
@@ -106,6 +122,7 @@ impl VisualContextNodeSink for BoxNodeWriter<'_> {
SpatialNode { data, parent },
self.delta,
&mut self.outcome,
+ &mut self.events,
)
}
@@ -129,6 +146,7 @@ impl VisualContextNodeSink for BoxNodeWriter<'_> {
ClipNode::new(data, parent, spatial),
self.delta,
&mut self.outcome,
+ &mut self.events,
)
}
@@ -146,6 +164,50 @@ pub(crate) struct ReconcileOutcome {
pub shape_changed: bool,
}
+/// What a walk did to one node of a box.
+#[derive(Clone, Copy)]
+pub(crate) enum NodeAction {
+ Allocated { freed_slot: bool },
+ Repurposed,
+ Updated,
+ Released,
+}
+
+#[derive(Clone, Copy)]
+pub(crate) struct NodeEvent {
+ pub(crate) role: &'static str,
+ pub(crate) action: NodeAction,
+}
+
+pub(crate) fn spatial_role(data: &SpatialData) -> &'static str {
+ match data {
+ SpatialData::Scroll(_) => "scroll",
+ SpatialData::Sticky(_) => "sticky",
+ SpatialData::Transform(_) => "transform",
+ SpatialData::Perspective(_) => "perspective",
+ SpatialData::BackfaceVisibility(_) => "backface-visibility",
+ SpatialData::AnchorScrollShift(_) => "anchor shift",
+ SpatialData::Dead => "dead",
+ }
+}
+
+pub(crate) fn clip_role(data: &ClipNodeData) -> &'static str {
+ match data {
+ ClipNodeData::Rect(_) => "clip",
+ ClipNodeData::Path(_) => "clip-path",
+ ClipNodeData::Dead => "dead",
+ }
+}
+
+pub(crate) fn effect_role(data: &EffectNodeData) -> &'static str {
+ match data {
+ EffectNodeData::Effects(_) => "effects",
+ EffectNodeData::Mask(_) => "mask",
+ EffectNodeData::BackgroundColorAnimation => "background-color animation",
+ EffectNodeData::Dead => "dead",
+ }
+}
+
// A slot whose shape differs is repurposed, one whose payload differs is patched, and
// surplus slots the box no longer needs are tombstoned.
trait ReconciledNode: SlotNode {
@@ -155,6 +217,7 @@ trait ReconciledNode: SlotNode {
fn same_payload(&self, other: &Self) -> bool;
fn replace(tree: &mut VisualContextTree, index: Self::Index, node: Self) -> bool;
fn tombstone_slot(tree: &mut VisualContextTree, index: Self::Index) -> bool;
+ fn role(&self) -> &'static str;
fn patch_requires_recording(&self) -> bool {
false
}
@@ -179,6 +242,9 @@ impl ReconciledNode for SpatialNode {
fn tombstone_slot(tree: &mut VisualContextTree, index: SpatialNodeIndex) -> bool {
tree.tombstone_spatial_slot(index)
}
+ fn role(&self) -> &'static str {
+ spatial_role(&self.data)
+ }
}
impl ReconciledNode for ClipNode {
@@ -200,6 +266,9 @@ impl ReconciledNode for ClipNode {
fn tombstone_slot(tree: &mut VisualContextTree, index: ClipNodeIndex) -> bool {
tree.tombstone_clip_slot(index)
}
+ fn role(&self) -> &'static str {
+ clip_role(&self.data)
+ }
}
impl ReconciledNode for EffectNode {
@@ -221,6 +290,9 @@ impl ReconciledNode for EffectNode {
fn tombstone_slot(tree: &mut VisualContextTree, index: EffectNodeIndex) -> bool {
tree.tombstone_effect_slot(index)
}
+ fn role(&self) -> &'static str {
+ effect_role(&self.data)
+ }
// A mask's content is recorded per display list, so a changed mask needs a recording.
fn patch_requires_recording(&self) -> bool {
matches!(self.data, EffectNodeData::Mask(_))
@@ -234,12 +306,15 @@ fn write_node<N: ReconciledNode>(
node: N,
delta: &mut VisualContextTreeDelta,
outcome: &mut ReconcileOutcome,
+ events: &mut Option<Vec<NodeEvent>>,
) -> N::Index {
+ let mut allocated = None;
let handle = match existing.get(handles.len()) {
Some(&handle) => handle,
None => {
let (handle, reused) = N::allocate(tree);
delta.note_allocated(reused);
+ allocated = Some(reused);
handle
}
};
@@ -253,6 +328,20 @@ fn write_node<N: ReconciledNode>(
delta.note_repurposed_in_place();
}
}
+ if let Some(events) = events {
+ let action = match allocated {
+ Some(freed_slot) => Some(NodeAction::Allocated { freed_slot }),
+ None if was_live && !shape_matches => Some(NodeAction::Repurposed),
+ None if !payload_matches => Some(NodeAction::Updated),
+ None => None,
+ };
+ if let Some(action) = action {
+ events.push(NodeEvent {
+ role: node.role(),
+ action,
+ });
+ }
+ }
if !payload_matches {
if node.patch_requires_recording() {
delta.requires_display_list_recording = true;
@@ -269,13 +358,21 @@ fn retire_surplus<N: ReconciledNode>(
used: usize,
delta: &mut VisualContextTreeDelta,
outcome: &mut ReconcileOutcome,
+ events: &mut Option<Vec<NodeEvent>>,
) {
if used < existing.len() {
outcome.shape_changed = true;
}
for &handle in existing.get(used..).unwrap_or(&[]) {
+ let role = N::slots(tree)[N::raw(handle) as usize].role();
if N::tombstone_slot(tree, handle) {
delta.note_tombstoned();
+ if let Some(events) = events {
+ events.push(NodeEvent {
+ role,
+ action: NodeAction::Released,
+ });
+ }
}
}
}
diff --git a/Libraries/LibWeb/Rust/src/painting/visual_context/records.rs b/Libraries/LibWeb/Rust/src/painting/visual_context/records.rs
index 8840213a019..760f12b52c5 100644
--- a/Libraries/LibWeb/Rust/src/painting/visual_context/records.rs
+++ b/Libraries/LibWeb/Rust/src/painting/visual_context/records.rs
@@ -31,6 +31,8 @@ pub struct VisualContextState {
pub published_compositor_animations: Vec<VisualAnimation>,
// The boxes whose transform node has an offset path, which depends on the geometry of their containing block.
pub offset_path_boxes: crate::cow_map::CowSet<NodeSlotId>,
+ // What the updates did since a test began tracing them.
+ pub(crate) trace: Option<super::trace::VisualContextTrace>,
}
impl VisualContextState {
diff --git a/Libraries/LibWeb/Rust/src/painting/visual_context/trace.rs b/Libraries/LibWeb/Rust/src/painting/visual_context/trace.rs
new file mode 100644
index 00000000000..4e5b9451a48
--- /dev/null
+++ b/Libraries/LibWeb/Rust/src/painting/visual_context/trace.rs
@@ -0,0 +1,136 @@
+/*
+ * Copyright (c) 2026-present, the Ladybird developers.
+ *
+ * SPDX-License-Identifier: BSD-2-Clause
+ */
+
+use super::delta::VisualContextTreeDelta;
+use super::dirty::VisualContextUpdateScope;
+use super::reconcile::{NodeAction, NodeEvent};
+use crate::css::style::tree::StyleNodeID;
+use crate::fast_hash::FastMap;
+use crate::layout::node_data::NodeSlotId;
+
+/// One line of a visual context trace: the box it is about, named by its element where it has one, and what it says.
+#[derive(Clone)]
+pub(crate) struct TraceLine {
+ pub(crate) indented: bool,
+ slot: Option<NodeSlotId>,
+ pub(crate) element: Option<StyleNodeID>,
+ pub(crate) name_without_element: &'static str,
+ pub(crate) text: String,
+}
+
+/// What the updates of the visual context tree did since a test began tracing them.
+#[derive(Clone, Default)]
+pub(crate) struct VisualContextTrace {
+ pub(crate) lines: Vec<TraceLine>,
+ /// The elements of the boxes removed since the last update, which the update releases the nodes of.
+ removed_box_elements: FastMap<NodeSlotId, Option<StyleNodeID>>,
+}
+
+fn scope_name(scope: VisualContextUpdateScope) -> &'static str {
+ match scope {
+ VisualContextUpdateScope::DirtyPath => "DIRTY-PATH",
+ VisualContextUpdateScope::EveryBox => "EVERY-BOX",
+ VisualContextUpdateScope::FreshTree => "FRESH-TREE",
+ }
+}
+
+fn action_name(action: NodeAction) -> &'static str {
+ match action {
+ NodeAction::Allocated { freed_slot: false } => "ALLOCATED",
+ NodeAction::Allocated { freed_slot: true } => "ALLOCATED (freed slot)",
+ NodeAction::Repurposed => "REPURPOSED",
+ NodeAction::Updated => "UPDATED",
+ NodeAction::Released => "RELEASED",
+ }
+}
+
+impl VisualContextTrace {
+ pub(crate) fn note_removed_box(&mut self, slot: NodeSlotId, element: Option<StyleNodeID>) {
+ self.removed_box_elements.insert(slot, element);
+ }
+
+ /// Opens the block of an update, whose header the update finishes once it knows its scope.
+ pub(crate) fn begin_update(&mut self) -> usize {
+ self.lines.push(TraceLine {
+ indented: false,
+ slot: None,
+ element: None,
+ name_without_element: "",
+ text: String::new(),
+ });
+ self.lines.len() - 1
+ }
+
+ /// Adds what an update did to the nodes of the box in `slot`, which the update names once it is over.
+ pub(crate) fn note_box_events(&mut self, slot: NodeSlotId, events: &[NodeEvent]) {
+ for event in events {
+ self.lines.push(TraceLine {
+ indented: true,
+ slot: Some(slot),
+ element: None,
+ name_without_element: "(anonymous)",
+ text: format!(" {} {}", event.role, action_name(event.action)),
+ });
+ }
+ }
+
+ /// Adds the nodes an update released of the box in `slot`, which was removed.
+ pub(crate) fn note_removed_box_events(&mut self, slot: NodeSlotId, events: &[NodeEvent]) {
+ let element = self.removed_box_elements.get(&slot).copied().flatten();
+ for event in events {
+ self.lines.push(TraceLine {
+ indented: true,
+ slot: None,
+ element,
+ name_without_element: "(removed)",
+ text: format!(" {} {} (removed box)", event.role, action_name(event.action)),
+ });
+ }
+ }
+
+ /// Finishes the block `header` opened: the scope the update asked for and the one it ran, and whether it gave the
+ /// tree a new structural epoch or needs a new recording. `name` answers the element of a box the block is about,
+ /// and whether it is the viewport.
+ pub(crate) fn finish_update(
+ &mut self,
+ header: usize,
+ asked: VisualContextUpdateScope,
+ ran: VisualContextUpdateScope,
+ delta: &VisualContextTreeDelta,
+ name: impl Fn(NodeSlotId) -> (Option<StyleNodeID>, bool),
+ ) {
+ self.removed_box_elements.clear();
+ for line in &mut self.lines[header..] {
+ if let Some(slot) = line.slot.take() {
+ let (element, is_viewport) = name(slot);
+ if is_viewport {
+ line.name_without_element = "@viewport";
+ } else {
+ line.element = element;
+ }
+ }
+ }
+ self.lines[header].text = if asked == ran {
+ format!("update {}", scope_name(ran))
+ } else {
+ format!("update {} -> {}", scope_name(asked), scope_name(ran))
+ };
+ for (applies, text) in [
+ (delta.structural_epoch_changed, "epoch NEW"),
+ (delta.requires_display_list_recording, "recording NEEDED"),
+ ] {
+ if applies {
+ self.lines.push(TraceLine {
+ indented: true,
+ slot: None,
+ element: None,
+ name_without_element: "",
+ text: text.into(),
+ });
+ }
+ }
+ }
+}
diff --git a/Tests/LibWeb/Text/expected/async-scrolling/scroll-node-index-is-stable-after-visual-context-change.txt b/Tests/LibWeb/Text/expected/async-scrolling/scroll-node-index-is-stable-after-visual-context-change.txt
index 7ecb3db3028..8a7475f7928 100644
--- a/Tests/LibWeb/Text/expected/async-scrolling/scroll-node-index-is-stable-after-visual-context-change.txt
+++ b/Tests/LibWeb/Text/expected/async-scrolling/scroll-node-index-is-stable-after-visual-context-change.txt
@@ -1,3 +1,2 @@
-scroll node index changed: false
-live nodes grew: true
-full builds: 0
+PASS: a preceding sibling gains a transform (work + checks)
+PASS: the scroller's parent gains a transform (work + checks)
diff --git a/Tests/LibWeb/Text/expected/avc-value-only-update-with-duplicated-effects-nodes.txt b/Tests/LibWeb/Text/expected/avc-value-only-update-with-duplicated-effects-nodes.txt
deleted file mode 100644
index a099eea0c20..00000000000
--- a/Tests/LibWeb/Text/expected/avc-value-only-update-with-duplicated-effects-nodes.txt
+++ /dev/null
@@ -1,2 +0,0 @@
-builds after opacity change on a static box: 0
-builds after opacity change on a relative box: 0
diff --git a/Tests/LibWeb/Text/expected/css/compositor-background-color-animation-scheme-dependent-colors.txt b/Tests/LibWeb/Text/expected/css/compositor-background-color-animation-scheme-dependent-colors.txt
index 4644b7b5fa9..743aecd8968 100644
--- a/Tests/LibWeb/Text/expected/css/compositor-background-color-animation-scheme-dependent-colors.txt
+++ b/Tests/LibWeb/Text/expected/css/compositor-background-color-animation-scheme-dependent-colors.txt
@@ -1,8 +1,12 @@
-light-dark uses compositor: true
-light-dark keyframes: rgba(0, 0, 200, 0), rgb(0, 0, 255)
-light-dark-font-relative uses compositor: true
-light-dark-font-relative keyframes: rgba(200, 0, 0, 0), rgb(0, 0, 255)
-system uses compositor: true
-system keyframes: rgb(18, 18, 18), rgb(255, 255, 255)
-scripted-light-dark-font-relative uses compositor: true
-scripted-light-dark-font-relative keyframes: rgba(200, 0, 0, 0), rgb(0, 0, 255)
+light-dark:
+ background-color-animation keyframes=[rgba(0, 0, 200, 0), rgb(0, 0, 255)]
+ compositor background-color frame
+light-dark-font-relative:
+ background-color-animation keyframes=[rgba(200, 0, 0, 0), rgb(0, 0, 255)]
+ compositor background-color frame
+system:
+ background-color-animation keyframes=[rgb(18, 18, 18), rgb(255, 255, 255)]
+ compositor background-color frame
+scripted-light-dark-font-relative:
+ background-color-animation keyframes=[rgba(200, 0, 0, 0), rgb(0, 0, 255)]
+ compositor background-color frame
diff --git a/Tests/LibWeb/Text/expected/display_list/will-change-opacity-value-update.txt b/Tests/LibWeb/Text/expected/display_list/will-change-opacity-value-update.txt
index 1b63ff13efa..0c1ae2ad395 100644
--- a/Tests/LibWeb/Text/expected/display_list/will-change-opacity-value-update.txt
+++ b/Tests/LibWeb/Text/expected/display_list/will-change-opacity-value-update.txt
@@ -1,3 +1,3 @@
-PASS: opacity 1 to 0.5 (work + checks)
-PASS: opacity 0.5 to 0.6 (work + checks)
-PASS: opacity 0.6 to 1 (work + checks)
+PASS: opacity 1 to 0.5 (work)
+PASS: opacity 0.5 to 0.6 (work)
+PASS: opacity 0.6 to 1 (work)
diff --git a/Tests/LibWeb/Text/expected/display_list/will-change-transform-value-update.txt b/Tests/LibWeb/Text/expected/display_list/will-change-transform-value-update.txt
index 8cc13de7be0..45b15cb6c8d 100644
--- a/Tests/LibWeb/Text/expected/display_list/will-change-transform-value-update.txt
+++ b/Tests/LibWeb/Text/expected/display_list/will-change-transform-value-update.txt
@@ -1,3 +1,3 @@
-PASS: transform none to translateX(10px) (work + checks)
-PASS: transform translateX(10px) to translateX(20px) (work + checks)
-PASS: transform translateX(20px) to none (work + checks)
+PASS: transform none to translateX(10px) (work)
+PASS: transform translateX(10px) to translateX(20px) (work)
+PASS: transform translateX(20px) to none (work)
diff --git a/Tests/LibWeb/Text/expected/display_list/will-change-visual-context-nodes.txt b/Tests/LibWeb/Text/expected/display_list/will-change-visual-context-nodes.txt
index 8e87916ef59..4a2b438c459 100644
--- a/Tests/LibWeb/Text/expected/display_list/will-change-visual-context-nodes.txt
+++ b/Tests/LibWeb/Text/expected/display_list/will-change-visual-context-nodes.txt
@@ -16,9 +16,3 @@ FillRect@s3/e0 rect=[0,50 50x50] color=rgb(0, 0, 255)
FillRect@s1/e1 rect=[0,100 50x50] color=rgb(255, 0, 0)
FillRect@s1/e2 rect=[0,150 50x50] color=rgb(255, 255, 0)
-transform: spatial=1 effects=0
-translate: spatial=1 effects=0
-opacity: spatial=0 effects=1
-filter: spatial=0 effects=1
-other: spatial=0 effects=0
-inline: spatial=0 effects=0
diff --git a/Tests/LibWeb/Text/expected/inspector-overlay-visual-context-tree-growth.txt b/Tests/LibWeb/Text/expected/inspector-overlay-visual-context-tree-growth.txt
index 480e8b494fa..90e986ad745 100644
--- a/Tests/LibWeb/Text/expected/inspector-overlay-visual-context-tree-growth.txt
+++ b/Tests/LibWeb/Text/expected/inspector-overlay-visual-context-tree-growth.txt
@@ -1,2 +1,3 @@
-PASS: recording with an inspector highlight does not modify the visual context tree
-PASS: visual context tree is unchanged after clearing the highlight
+PASS: recording with an inspector highlight (work)
+PASS: recording again with the highlight (work)
+PASS: recording after clearing the highlight (work)
diff --git a/Tests/LibWeb/Text/expected/lazy-accumulated-visual-context-rebuild.txt b/Tests/LibWeb/Text/expected/lazy-accumulated-visual-context-rebuild.txt
index 144ac7eff03..2b6f50557f0 100644
--- a/Tests/LibWeb/Text/expected/lazy-accumulated-visual-context-rebuild.txt
+++ b/Tests/LibWeb/Text/expected/lazy-accumulated-visual-context-rebuild.txt
@@ -1,11 +1,15 @@
offset width: 110
offset width: 120
offset width: 130
-visual context updates after layout-only reads: 0
+visual context updates after layout-only reads: (none)
layout during clean read: (no layout)
bounding rect width: 130
-visual context updates after identity transform read: 0
+visual context updates after identity transform read: (none)
bounding rect with transformed child: 130
-visual context updates after unrelated transform read: 0
+visual context updates after unrelated transform read: (none)
transformed rect x: 18
-visual context updates after non-identity transform read: 1
+visual context updates after non-identity transform read:
+update DIRTY-PATH
+ div#target transform ALLOCATED
+ div#transformed-child transform ALLOCATED
+ recording NEEDED
diff --git a/Tests/LibWeb/Text/expected/range-client-rects-lazy-visual-context-update.txt b/Tests/LibWeb/Text/expected/range-client-rects-lazy-visual-context-update.txt
index f95e9768eaf..2bff80484c9 100644
--- a/Tests/LibWeb/Text/expected/range-client-rects-lazy-visual-context-update.txt
+++ b/Tests/LibWeb/Text/expected/range-client-rects-lazy-visual-context-update.txt
@@ -1,2 +1,2 @@
rects: 1, at the origin of the text: true
-visual context updates: 0
+visual context updates: (none)
diff --git a/Tests/LibWeb/Text/expected/scroll-does-not-rebuild-accumulated-visual-context-tree.txt b/Tests/LibWeb/Text/expected/scroll-does-not-rebuild-accumulated-visual-context-tree.txt
deleted file mode 100644
index c237bac5aca..00000000000
--- a/Tests/LibWeb/Text/expected/scroll-does-not-rebuild-accumulated-visual-context-tree.txt
+++ /dev/null
@@ -1,4 +0,0 @@
-scrollTop: 100
-scrollLeft: 50
-bounding rect y: 8
-builds after pure scroll: 0
diff --git a/Tests/LibWeb/Text/expected/visual-context/anchor-page-swap-keeps-untouched-node-indices.txt b/Tests/LibWeb/Text/expected/visual-context/anchor-page-swap-keeps-untouched-node-indices.txt
index cab943dad18..6b552e4c622 100644
--- a/Tests/LibWeb/Text/expected/visual-context/anchor-page-swap-keeps-untouched-node-indices.txt
+++ b/Tests/LibWeb/Text/expected/visual-context/anchor-page-swap-keeps-untouched-node-indices.txt
@@ -1,13 +1,4 @@
-b owns nodes: true
-clip swap: full builds 0, incremental updates 1
-clip swap: b keeps its node indices: true
-clip swap: c keeps its node indices: true
-clip swap: live nodes unchanged: false
-clip swap: epoch advanced: true
-transform swap: full builds 0, incremental updates 1
-transform swap: b keeps its node indices: true
-transform swap: c keeps its node indices: true
-transform swap: live nodes unchanged: false
-transform swap: epoch advanced: true
-dead nodes after the swaps: true
-d owns the moved nodes: true
+PASS: clip swap (work)
+PASS: transform swap (work)
+PASS: clip swap while every box is rebuilt (work)
+PASS: transform swap while every box is rebuilt (work)
diff --git a/Tests/LibWeb/Text/expected/visual-context/anchor-positioned-box-keeps-visual-context-updates-incremental.txt b/Tests/LibWeb/Text/expected/visual-context/anchor-positioned-box-keeps-visual-context-updates-incremental.txt
index c06d562b813..f5a55ddcb2f 100644
--- a/Tests/LibWeb/Text/expected/visual-context/anchor-positioned-box-keeps-visual-context-updates-incremental.txt
+++ b/Tests/LibWeb/Text/expected/visual-context/anchor-positioned-box-keeps-visual-context-updates-incremental.txt
@@ -1,11 +1,6 @@
-anchored box top: 20
-anchored box own spatial nodes: 1
-unrelated transform added: full builds 0, incremental updates 1
-unrelated opacity added: full builds 0, incremental updates 1
-anchored box top after scrolling the anchor's scroller: -10
-anchor scroller scrolled: full builds 0, incremental updates 1
-anchored box top after resizing the anchor: 10
-anchor resized: full builds 0, incremental updates 1
-anchored box top after the scroller stops scrolling: 40
-anchored box own spatial nodes without a scroller: 0
-anchor scroller removed: full builds 0, incremental updates 2
+PASS: anchored box (work + checks)
+PASS: unrelated transform added (work)
+PASS: unrelated opacity added (work)
+PASS: anchor scroller scrolled (work + checks)
+PASS: anchor resized (work + checks)
+PASS: anchor scroller removed (work + checks)
diff --git a/Tests/LibWeb/Text/expected/visual-context/anchor-scroll-shift-follows-scroll-container-change.txt b/Tests/LibWeb/Text/expected/visual-context/anchor-scroll-shift-follows-scroll-container-change.txt
index b439191c11c..4807499f1b4 100644
--- a/Tests/LibWeb/Text/expected/visual-context/anchor-scroll-shift-follows-scroll-container-change.txt
+++ b/Tests/LibWeb/Text/expected/visual-context/anchor-scroll-shift-follows-scroll-container-change.txt
@@ -1,8 +1,3 @@
-own spatial nodes without a scroll container above the anchor: 0
-own spatial nodes with a scroll container above the anchor: 1
-scroll container added: full builds 0, incremental updates 1
-anchored box top after scrolling the container: -30
-container scrolled: full builds 0, incremental updates 1
-own spatial nodes after the scroll container is gone: 0
-anchored box top after the scroll container is gone: 20
-scroll container removed: full builds 0, incremental updates 2
+PASS: scroll container added (work)
+PASS: container scrolled (work + checks)
+PASS: scroll container removed (work + checks)
diff --git a/Tests/LibWeb/Text/expected/visual-context/backdrop-filter-value-update-keeps-tree.txt b/Tests/LibWeb/Text/expected/visual-context/backdrop-filter-value-update-keeps-tree.txt
deleted file mode 100644
index 7819ba22cd7..00000000000
--- a/Tests/LibWeb/Text/expected/visual-context/backdrop-filter-value-update-keeps-tree.txt
+++ /dev/null
@@ -1,6 +0,0 @@
-needs display list record: false
-full builds: 0
-incremental updates: 1
-live nodes unchanged: true
-capacity unchanged: true
-epoch unchanged: true
diff --git a/Tests/LibWeb/Text/expected/visual-context/body-background-propagation-flip.txt b/Tests/LibWeb/Text/expected/visual-context/body-background-propagation-flip.txt
index fb49d6215ae..1e325fdeb79 100644
--- a/Tests/LibWeb/Text/expected/visual-context/body-background-propagation-flip.txt
+++ b/Tests/LibWeb/Text/expected/visual-context/body-background-propagation-flip.txt
@@ -1,5 +1,23 @@
-rect x with propagated body background: 13
-rect x without propagation: 13
-rect x with propagation restored: 13
-full builds: 0
-incremental updates: 0
+PASS: propagated body background (work + checks)
+PASS: propagation stops (work + checks)
+PASS: propagation restored (work + checks)
+PASS: fixed body background image (work)
+PASS: fixed body background image with a root background (work)
+PASS: fixed body background image without a root background (work)
+PASS: local body background image (work)
+PASS: local body background image with a root background (work)
+PASS: local body background image without a root background (work)
+PASS: scroll body background image (work)
+PASS: scroll body background image with a root background (work)
+PASS: scroll body background image without a root background (work)
+PASS: body background image removed (work)
+PASS: fixed box background image (work)
+PASS: fixed box background image with a root background (work)
+PASS: fixed box background image without a root background (work)
+PASS: local box background image (work)
+PASS: local box background image with a root background (work)
+PASS: local box background image without a root background (work)
+PASS: scroll box background image (work)
+PASS: scroll box background image with a root background (work)
+PASS: scroll box background image without a root background (work)
+PASS: box background image removed (work)
diff --git a/Tests/LibWeb/Text/expected/visual-context/clip-path-emptiness-flip-re-records-cached-subtree.txt b/Tests/LibWeb/Text/expected/visual-context/clip-path-emptiness-flip-re-records-cached-subtree.txt
index 197e3849cc9..7273ab5eb43 100644
--- a/Tests/LibWeb/Text/expected/visual-context/clip-path-emptiness-flip-re-records-cached-subtree.txt
+++ b/Tests/LibWeb/Text/expected/visual-context/clip-path-emptiness-flip-re-records-cached-subtree.txt
@@ -1,4 +1,3 @@
-hit while clipped away: BODY
-hit after the clip opened: child
-hit after the clip closed again: BODY
-full builds: 0
+PASS: clipped away (work + checks)
+PASS: the clip opens (work + checks)
+PASS: the clip closes again (work + checks)
diff --git a/Tests/LibWeb/Text/expected/visual-context/contain-paint-change-rebuilds-the-box.txt b/Tests/LibWeb/Text/expected/visual-context/contain-paint-change-rebuilds-the-box.txt
index 076a588f6e6..30be4564458 100644
--- a/Tests/LibWeb/Text/expected/visual-context/contain-paint-change-rebuilds-the-box.txt
+++ b/Tests/LibWeb/Text/expected/visual-context/contain-paint-change-rebuilds-the-box.txt
@@ -1,4 +1,3 @@
-overflowing content without containment: child
-overflowing content with paint containment: BODY
-overflowing content after containment is removed: child
-full builds: 0
+PASS: without containment (work + checks)
+PASS: paint containment (work + checks)
+PASS: containment removed (work + checks)
diff --git a/Tests/LibWeb/Text/expected/visual-context/empty-clip-flip-reveals-content.txt b/Tests/LibWeb/Text/expected/visual-context/empty-clip-flip-reveals-content.txt
index 116dbcfd254..7273ab5eb43 100644
--- a/Tests/LibWeb/Text/expected/visual-context/empty-clip-flip-reveals-content.txt
+++ b/Tests/LibWeb/Text/expected/visual-context/empty-clip-flip-reveals-content.txt
@@ -1,5 +1,3 @@
-hit while clipped away: HTML
-hit after the clip opened: child
-hit after the clip closed again: HTML
-full builds: 0
-incremental updates: 2
+PASS: clipped away (work + checks)
+PASS: the clip opens (work + checks)
+PASS: the clip closes again (work + checks)
diff --git a/Tests/LibWeb/Text/expected/visual-context/every-box-rebuild-keeps-untouched-node-indices.txt b/Tests/LibWeb/Text/expected/visual-context/every-box-rebuild-keeps-untouched-node-indices.txt
deleted file mode 100644
index 72160eff613..00000000000
--- a/Tests/LibWeb/Text/expected/visual-context/every-box-rebuild-keeps-untouched-node-indices.txt
+++ /dev/null
@@ -1,13 +0,0 @@
-b owns nodes: true
-clip swap: full builds 1, incremental updates 0
-clip swap: b keeps its node indices: true
-clip swap: c keeps its node indices: true
-clip swap: live nodes unchanged: false
-clip swap: epoch advanced: true
-transform swap: full builds 1, incremental updates 0
-transform swap: b keeps its node indices: true
-transform swap: c keeps its node indices: true
-transform swap: live nodes unchanged: false
-transform swap: epoch advanced: true
-dead nodes after the swaps: true
-d owns the moved nodes: true
diff --git a/Tests/LibWeb/Text/expected/visual-context/fieldset-legend-change.txt b/Tests/LibWeb/Text/expected/visual-context/fieldset-legend-change.txt
index 2f8aa650389..d23979d3e94 100644
--- a/Tests/LibWeb/Text/expected/visual-context/fieldset-legend-change.txt
+++ b/Tests/LibWeb/Text/expected/visual-context/fieldset-legend-change.txt
@@ -1,6 +1 @@
-legend hit: legend
-legend grew: true
-grown legend hit: legend
-content hit: content
-full builds: 0
-incremental updates happened: true
+PASS: legend grows (work + checks)
diff --git a/Tests/LibWeb/Text/expected/visual-context/forced-rebuild-mints-a-new-epoch.txt b/Tests/LibWeb/Text/expected/visual-context/forced-rebuild-mints-a-new-epoch.txt
index 159a6a8da84..34e641444a1 100644
--- a/Tests/LibWeb/Text/expected/visual-context/forced-rebuild-mints-a-new-epoch.txt
+++ b/Tests/LibWeb/Text/expected/visual-context/forced-rebuild-mints-a-new-epoch.txt
@@ -1,5 +1,3 @@
-full builds: 1
-epoch changed: true
-live nodes unchanged: true
-capacity equals live nodes: true
-dead nodes: 0
+PASS: dropping a transform releases its node (work)
+PASS: a forced rebuild builds a fresh tree under a new epoch (work + checks)
+PASS: the fresh tree has no released slots to hand out (work)
diff --git a/Tests/LibWeb/Text/expected/visual-context/geometry-walk-survives-descendant-output-change.txt b/Tests/LibWeb/Text/expected/visual-context/geometry-walk-survives-descendant-output-change.txt
index 1df59885a22..f1f054f1dcb 100644
--- a/Tests/LibWeb/Text/expected/visual-context/geometry-walk-survives-descendant-output-change.txt
+++ b/Tests/LibWeb/Text/expected/visual-context/geometry-walk-survives-descendant-output-change.txt
@@ -1,3 +1,3 @@
-inside the moved clip: target
-old position after the move: BODY
-full builds: 0
+PASS: clip-path added (work)
+PASS: clip-path removed (work)
+PASS: moved with a clip-path again (work + checks)
diff --git a/Tests/LibWeb/Text/expected/visual-context/moved-subtree-refreshes-descendant-clip.txt b/Tests/LibWeb/Text/expected/visual-context/moved-subtree-refreshes-descendant-clip.txt
index 2458e7533bf..b92a180b063 100644
--- a/Tests/LibWeb/Text/expected/visual-context/moved-subtree-refreshes-descendant-clip.txt
+++ b/Tests/LibWeb/Text/expected/visual-context/moved-subtree-refreshes-descendant-clip.txt
@@ -1,6 +1,2 @@
-inside the clip before the move: inner
-beside the clip before the move: wrapper
-old position after the move: BODY
-inside the moved clip: inner
-beyond the moved clip: wrapper
-full builds: 0
+PASS: before the move (work + checks)
+PASS: the wrapper moves (work + checks)
diff --git a/Tests/LibWeb/Text/expected/visual-context/overflow-change-updates-the-clip.txt b/Tests/LibWeb/Text/expected/visual-context/overflow-change-updates-the-clip.txt
index 01adf67a853..485fd00ebec 100644
--- a/Tests/LibWeb/Text/expected/visual-context/overflow-change-updates-the-clip.txt
+++ b/Tests/LibWeb/Text/expected/visual-context/overflow-change-updates-the-clip.txt
@@ -1,8 +1,7 @@
-div content past the box after overflow becomes clip: BODY
-div content past the box after overflow becomes visible: child
-outer svg content past the viewport before overflow changes: BODY
-outer svg content past the viewport after overflow becomes visible: outer-rect
-outer svg content past the viewport after overflow becomes hidden: BODY
-nested svg content past the viewport after the overflow attribute becomes visible: nested-rect
-nested svg content past the viewport after overflow becomes hidden: svg
-full builds: 0
+PASS: div overflow becomes clip (work + checks)
+PASS: div overflow becomes visible (work + checks)
+PASS: outer svg before overflow changes (work + checks)
+PASS: outer svg overflow becomes visible (work + checks)
+PASS: outer svg overflow becomes hidden (work + checks)
+PASS: nested svg overflow attribute becomes visible (work + checks)
+PASS: nested svg overflow becomes hidden (work + checks)
diff --git a/Tests/LibWeb/Text/expected/visual-context/parent-gaining-a-transform-keeps-descendant-node-indices.txt b/Tests/LibWeb/Text/expected/visual-context/parent-gaining-a-transform-keeps-descendant-node-indices.txt
deleted file mode 100644
index bd09826bc76..00000000000
--- a/Tests/LibWeb/Text/expected/visual-context/parent-gaining-a-transform-keeps-descendant-node-indices.txt
+++ /dev/null
@@ -1,4 +0,0 @@
-scroll node index unchanged: true
-live nodes grew: true
-full builds: 0
-scroller x: 13
diff --git a/Tests/LibWeb/Text/expected/visual-context/repaint-only-decoration-changes.txt b/Tests/LibWeb/Text/expected/visual-context/repaint-only-decoration-changes.txt
index 8aed9525120..03c17b45518 100644
--- a/Tests/LibWeb/Text/expected/visual-context/repaint-only-decoration-changes.txt
+++ b/Tests/LibWeb/Text/expected/visual-context/repaint-only-decoration-changes.txt
@@ -1,5 +1,5 @@
-dashed border painted: true
-shadow painted: true
-blended layers painted: true
-full builds: 0
-incremental updates: 1
+PASS: decorations painted (work + checks)
+PASS: border style (work)
+PASS: box shadow (work)
+PASS: outline (work)
+PASS: background blending and clip (work)
diff --git a/Tests/LibWeb/Text/expected/visual-context/repeated-toggle-settles-in-place.txt b/Tests/LibWeb/Text/expected/visual-context/repeated-toggle-settles-in-place.txt
index 475fce38792..fb54ba397fc 100644
--- a/Tests/LibWeb/Text/expected/visual-context/repeated-toggle-settles-in-place.txt
+++ b/Tests/LibWeb/Text/expected/visual-context/repeated-toggle-settles-in-place.txt
@@ -1,3 +1,12 @@
-capacity grew on the first toggle: true
-capacity stable afterwards: true
-full builds: 0
+PASS: toggle 1 lifts the box (work)
+PASS: toggle 1 drops it (work)
+PASS: toggle 2 lifts the box (work)
+PASS: toggle 2 drops it (work)
+PASS: toggle 3 lifts the box (work)
+PASS: toggle 3 drops it (work)
+PASS: toggle 4 lifts the box (work)
+PASS: toggle 4 drops it (work)
+PASS: toggle 5 lifts the box (work)
+PASS: toggle 5 drops it (work)
+PASS: toggle 6 lifts the box (work)
+PASS: toggle 6 drops it (work)
diff --git a/Tests/LibWeb/Text/expected/visual-context/resolved-effect-output-clip-updates.txt b/Tests/LibWeb/Text/expected/visual-context/resolved-effect-output-clip-updates.txt
index be7574792ff..0e08ccd7cb7 100644
--- a/Tests/LibWeb/Text/expected/visual-context/resolved-effect-output-clip-updates.txt
+++ b/Tests/LibWeb/Text/expected/visual-context/resolved-effect-output-clip-updates.txt
@@ -1,27 +1,9 @@
-new clipped effect: epoch unchanged: true
-clipped opacity update: epoch changed: false
-clipped opacity update: one effect: true
-clipped opacity update: full builds: 0
-repeated clipped opacity update: epoch changed: false
-repeated clipped opacity update: one effect: true
-repeated clipped opacity update: full builds: 0
-absolute escape: epoch changed: true
-absolute escape: one effect: true
-absolute escape: full builds: 0
-absolute child escapes: true
-escaped opacity update: epoch changed: false
-escaped opacity update: one effect: true
-escaped opacity update: full builds: 0
-absolute escape removed: epoch changed: true
-absolute escape removed: one effect: true
-absolute escape removed: full builds: 0
-fixed escape: epoch changed: true
-fixed escape: one effect: true
-fixed escape: full builds: 0
-fixed child escapes: true
-fixed escape removed: epoch changed: true
-fixed escape removed: one effect: true
-fixed escape removed: full builds: 0
-clipped opacity update after escapes: epoch changed: false
-clipped opacity update after escapes: one effect: true
-clipped opacity update after escapes: full builds: 0
+PASS: new clipped effect (work + checks)
+PASS: clipped opacity update (work + checks)
+PASS: repeated clipped opacity update (work + checks)
+PASS: absolute escape (work + checks)
+PASS: escaped opacity update (work + checks)
+PASS: absolute escape removed (work + checks)
+PASS: fixed escape (work + checks)
+PASS: fixed escape removed (work + checks)
+PASS: clipped opacity update after escapes (work + checks)
diff --git a/Tests/LibWeb/Text/expected/visual-context/scrollability-flip-from-transformed-child-during-full-relayout.txt b/Tests/LibWeb/Text/expected/visual-context/scrollability-flip-from-transformed-child-during-full-relayout.txt
index 22c2540e7e4..c30fe659a67 100644
--- a/Tests/LibWeb/Text/expected/visual-context/scrollability-flip-from-transformed-child-during-full-relayout.txt
+++ b/Tests/LibWeb/Text/expected/visual-context/scrollability-flip-from-transformed-child-during-full-relayout.txt
@@ -1,2 +1 @@
-nodes added by the flip: 1
-full builds: 0
+PASS: a transformed child makes its parent scrollable during a full relayout (work)
diff --git a/Tests/LibWeb/Text/expected/visual-context/shared-effect-positioned-clip-constraints.txt b/Tests/LibWeb/Text/expected/visual-context/shared-effect-positioned-clip-constraints.txt
index ef1bb4b2c1f..200432f27cb 100644
--- a/Tests/LibWeb/Text/expected/visual-context/shared-effect-positioned-clip-constraints.txt
+++ b/Tests/LibWeb/Text/expected/visual-context/shared-effect-positioned-clip-constraints.txt
@@ -1,21 +1,21 @@
-both positioned children: one owned effect: true
+both positioned children: owned nodes: effects=[opacity=0.5]
both positioned children: one shared layer: true
both positioned children: layer inside overflow clip: false
absolute escapes: true
fixed escapes: true
normal stays clipped: true
-fixed child remains: one owned effect: true
+fixed child remains: owned nodes: effects=[opacity=0.5]
fixed child remains: one shared layer: true
fixed child remains: layer inside overflow clip: false
-no positioned children: one owned effect: true
+no positioned children: owned nodes: effects=[opacity=0.5]
no positioned children: one shared layer: true
no positioned children: layer inside overflow clip: true
-absolute child restored: one owned effect: true
+absolute child restored: owned nodes: effects=[opacity=0.5]
absolute child restored: one shared layer: true
absolute child restored: layer inside overflow clip: false
-both restored: one owned effect: true
+both restored: owned nodes: effects=[opacity=0.5]
both restored: one shared layer: true
both restored: layer inside overflow clip: false
-fresh tree: one owned effect: true
+fresh tree: owned nodes: effects=[opacity=0.5]
fresh tree: one shared layer: true
fresh tree: layer inside overflow clip: false
diff --git a/Tests/LibWeb/Text/expected/visual-context/slot-reuse-after-removal-repaints-correctly.txt b/Tests/LibWeb/Text/expected/visual-context/slot-reuse-after-removal-repaints-correctly.txt
index 96850a3d6a2..0149a17636a 100644
--- a/Tests/LibWeb/Text/expected/visual-context/slot-reuse-after-removal-repaints-correctly.txt
+++ b/Tests/LibWeb/Text/expected/visual-context/slot-reuse-after-removal-repaints-correctly.txt
@@ -1,5 +1,3 @@
-capacity reused: true
-dead nodes: 0
-hit: second
-second x: 18
-full builds: 0
+PASS: a clipped box allocates its nodes (work)
+PASS: removing it releases them (work)
+PASS: after a recording, the next clipped box takes the released slots (work + checks)
diff --git a/Tests/LibWeb/Text/expected/visual-context/slot-reuse-bounds-capacity.txt b/Tests/LibWeb/Text/expected/visual-context/slot-reuse-bounds-capacity.txt
deleted file mode 100644
index caa82cf25f1..00000000000
--- a/Tests/LibWeb/Text/expected/visual-context/slot-reuse-bounds-capacity.txt
+++ /dev/null
@@ -1,4 +0,0 @@
-capacity bounded: true
-dead nodes bounded: true
-full builds: 0
-epoch advanced: true
diff --git a/Tests/LibWeb/Text/expected/visual-context/sticky-after-scroller-resize.txt b/Tests/LibWeb/Text/expected/visual-context/sticky-after-scroller-resize.txt
index f31f12205c2..bcdb26010d7 100644
--- a/Tests/LibWeb/Text/expected/visual-context/sticky-after-scroller-resize.txt
+++ b/Tests/LibWeb/Text/expected/visual-context/sticky-after-scroller-resize.txt
@@ -1,4 +1 @@
-scrollTop: 60
-sticky y after resize and scroll: 0
-scroller y: 0
-full builds: 0
+PASS: the scroller grows and scrolls (work + checks)
diff --git a/Tests/LibWeb/Text/expected/visual-context/structural-change-allocates-and-tombstones.txt b/Tests/LibWeb/Text/expected/visual-context/structural-change-allocates-and-tombstones.txt
index f3dcbd56eb5..558ac20a622 100644
--- a/Tests/LibWeb/Text/expected/visual-context/structural-change-allocates-and-tombstones.txt
+++ b/Tests/LibWeb/Text/expected/visual-context/structural-change-allocates-and-tombstones.txt
@@ -1,11 +1,2 @@
-child rect x: 18
-full builds after insertion: 0
-incremental updates after insertion: 1
-live nodes grew: true
-capacity grew: true
-epoch unchanged after insertion: true
-full builds after removal: 0
-live nodes back to the initial count: true
-capacity kept: true
-dead nodes after removal: true
-epoch bumped by the tombstones: true
+PASS: inserting a clipping transformed child allocates its nodes in place (work + checks)
+PASS: removing it tombstones its nodes under a new epoch (work)
diff --git a/Tests/LibWeb/Text/expected/visual-context/transform-style-change-rebuilds-the-box.txt b/Tests/LibWeb/Text/expected/visual-context/transform-style-change-rebuilds-the-box.txt
index 090bb45bd20..82ce3c01815 100644
--- a/Tests/LibWeb/Text/expected/visual-context/transform-style-change-rebuilds-the-box.txt
+++ b/Tests/LibWeb/Text/expected/visual-context/transform-style-change-rebuilds-the-box.txt
@@ -1,3 +1,2 @@
-live nodes added by preserve-3d: 1
-live nodes added after flat again: 0
-full builds: 0
+PASS: preserve-3d (work)
+PASS: flat again (work)
diff --git a/Tests/LibWeb/Text/expected/visual-context/value-only-update-keeps-tree.txt b/Tests/LibWeb/Text/expected/visual-context/value-only-update-keeps-tree.txt
index c4baa8c72e3..155d89d1551 100644
--- a/Tests/LibWeb/Text/expected/visual-context/value-only-update-keeps-tree.txt
+++ b/Tests/LibWeb/Text/expected/visual-context/value-only-update-keeps-tree.txt
@@ -1,6 +1,3 @@
-rect x: 28
-full builds: 0
-incremental updates: 1
-live nodes unchanged: true
-capacity unchanged: true
-epoch unchanged: true
+PASS: opacity and transform values change (work + checks)
+PASS: opacity value changes on a relative box (work)
+PASS: one backdrop filter replaces another (work)
diff --git a/Tests/LibWeb/Text/input/HTML/frame-in-flight/recording-flight-given-back-keeps-later-ask.html b/Tests/LibWeb/Text/input/HTML/frame-in-flight/recording-flight-given-back-keeps-later-ask.html
index 38b978dcc8e..b20995a5eb4 100644
--- a/Tests/LibWeb/Text/input/HTML/frame-in-flight/recording-flight-given-back-keeps-later-ask.html
+++ b/Tests/LibWeb/Text/input/HTML/frame-in-flight/recording-flight-given-back-keeps-later-ask.html
@@ -16,7 +16,7 @@
box.firstChild.data = "a much longer text";
}, () => {
box.style.opacity = "";
- internals.visualContextNodeIndices(box);
+ internals.updateVisualContextsForTesting();
internals.injectRenderingOpportunity(performance.now());
});
await twoFrames();
diff --git a/Tests/LibWeb/Text/input/async-scrolling/scroll-node-index-is-stable-after-visual-context-change.html b/Tests/LibWeb/Text/input/async-scrolling/scroll-node-index-is-stable-after-visual-context-change.html
index 960849fc49f..fd646833e22 100644
--- a/Tests/LibWeb/Text/input/async-scrolling/scroll-node-index-is-stable-after-visual-context-change.html
+++ b/Tests/LibWeb/Text/input/async-scrolling/scroll-node-index-is-stable-after-visual-context-change.html
@@ -1,11 +1,17 @@
<!DOCTYPE html>
<script src="../include.js"></script>
+<script src="../work-test.js"></script>
<style>
#before {
width: 20px;
height: 20px;
}
+ #parent {
+ width: 200px;
+ height: 200px;
+ }
+
#scroller {
width: 100px;
height: 100px;
@@ -18,23 +24,47 @@
}
</style>
<div id="before"></div>
-<div id="scroller"><div id="content"></div></div>
+<div id="parent"><div id="scroller"><div id="content"></div></div></div>
<script>
- test(() => {
- internals.recordDisplayListForTesting();
- const initialState = internals.recordedAsyncScrollingState();
- const initialNode = initialState.scrollNodes.find(node => !node.isViewport);
- const initialLiveNodes = internals.visualContextTreeNodeCount();
- const initialBuildCount = internals.accumulatedVisualContextTreeBuildCount();
-
- document.getElementById("before").style.transform = "translateX(0)";
-
+ const scrollNodeIndex = () => {
internals.recordDisplayListForTesting();
- const updatedState = internals.recordedAsyncScrollingState();
- const updatedNode = updatedState.scrollNodes.find(node => !node.isViewport);
-
- println(`scroll node index changed: ${initialNode.scrollNodeIndex !== updatedNode.scrollNodeIndex}`);
- println(`live nodes grew: ${internals.visualContextTreeNodeCount() > initialLiveNodes}`);
- println(`full builds: ${internals.accumulatedVisualContextTreeBuildCount() - initialBuildCount}`);
+ return internals.recordedAsyncScrollingState().scrollNodes.find(node => !node.isViewport).scrollNodeIndex;
+ };
+ let initialIndex;
+ visualContextTest({
+ setup: async () => {
+ internals.forceIncompatibleVisualContextTreeRebuild();
+ while (internals.frameSchedulerState() !== "idle")
+ await new Promise(resolve => setTimeout(resolve, 0));
+ initialIndex = scrollNodeIndex();
+ },
+ steps: [
+ {
+ name: "a preceding sibling gains a transform",
+ mutate: () => { document.getElementById("before").style.transform = "translateX(0)"; },
+ check: equal => equal(scrollNodeIndex(), initialIndex, "scroll node index"),
+ expect: `
+ update DIRTY-PATH
+ div#before transform ALLOCATED
+ recording NEEDED
+ `,
+ },
+ {
+ name: "the scroller's parent gains a transform",
+ mutate: () => { document.getElementById("parent").style.transform = "translateX(5px)"; },
+ check: equal => {
+ equal(scrollNodeIndex(), initialIndex, "scroll node index");
+ equal(scroller.getBoundingClientRect().x, 13, "scroller x");
+ },
+ expect: `
+ update DIRTY-PATH
+ div#parent transform ALLOCATED
+ div#scroller clip REPURPOSED
+ div#scroller scroll REPURPOSED
+ epoch NEW
+ recording NEEDED
+ `,
+ },
+ ],
});
</script>
diff --git a/Tests/LibWeb/Text/input/async-scrolling/wheel-latch-survives-scroll-node-renumbering.html b/Tests/LibWeb/Text/input/async-scrolling/wheel-latch-survives-scroll-node-renumbering.html
index 7b22519cb32..3c5f232b8da 100644
--- a/Tests/LibWeb/Text/input/async-scrolling/wheel-latch-survives-scroll-node-renumbering.html
+++ b/Tests/LibWeb/Text/input/async-scrolling/wheel-latch-survives-scroll-node-renumbering.html
@@ -26,9 +26,9 @@
<div id="nested"><div></div></div>
<script>
function scrollNodeIndexOf(element) {
- const spatialNodeIndices = internals.visualContextNodeIndices(element).spatial;
+ const scrollNodeIndex = Number(internals.dumpVisualContextNodes(element).match(/^\[s(\d+)\] scroll\b/m)[1]);
internals.recordDisplayListForTesting();
- return internals.recordedAsyncScrollingState().scrollNodes.find(node => spatialNodeIndices.includes(node.scrollNodeIndex)).scrollNodeIndex;
+ return internals.recordedAsyncScrollingState().scrollNodes.find(node => node.scrollNodeIndex === scrollNodeIndex).scrollNodeIndex;
}
promiseTest(async () => {
diff --git a/Tests/LibWeb/Text/input/avc-value-only-update-with-duplicated-effects-nodes.html b/Tests/LibWeb/Text/input/avc-value-only-update-with-duplicated-effects-nodes.html
deleted file mode 100644
index 7f053d639f1..00000000000
--- a/Tests/LibWeb/Text/input/avc-value-only-update-with-duplicated-effects-nodes.html
+++ /dev/null
@@ -1,25 +0,0 @@
-<!DOCTYPE html>
-<script src="include.js"></script>
-<div id="static-box" style="width: 100px; height: 100px; opacity: 0.5"></div>
-<div id="relative-box" style="position: relative; width: 100px; height: 100px; opacity: 0.5"></div>
-<script>
- test(() => {
- const staticBox = document.getElementById('static-box');
- const relativeBox = document.getElementById('relative-box');
- const lines = [];
-
- staticBox.getBoundingClientRect();
- const initialBuildCount = internals.accumulatedVisualContextTreeBuildCount();
-
- staticBox.style.opacity = '0.6';
- staticBox.getBoundingClientRect();
- lines.push(`builds after opacity change on a static box: ${internals.accumulatedVisualContextTreeBuildCount() - initialBuildCount}`);
-
- relativeBox.style.opacity = '0.7';
- relativeBox.getBoundingClientRect();
- lines.push(`builds after opacity change on a relative box: ${internals.accumulatedVisualContextTreeBuildCount() - initialBuildCount}`);
-
- for (const line of lines)
- println(line);
- });
-</script>
diff --git a/Tests/LibWeb/Text/input/css/compositor-background-color-animation-scheme-dependent-colors.html b/Tests/LibWeb/Text/input/css/compositor-background-color-animation-scheme-dependent-colors.html
index c4270a966f3..46d70890062 100644
--- a/Tests/LibWeb/Text/input/css/compositor-background-color-animation-scheme-dependent-colors.html
+++ b/Tests/LibWeb/Text/input/css/compositor-background-color-animation-scheme-dependent-colors.html
@@ -62,9 +62,9 @@
}
for (const id of ["light-dark", "light-dark-font-relative", "system", "scripted-light-dark-font-relative"]) {
- const context = internals.visualContextNodeIndices(document.getElementById(id));
- println(`${id} uses compositor: ${context.needsCompositorBackgroundColorFrame}`);
- println(`${id} keyframes: ${context.backgroundColorAnimationKeyframes.join(", ")}`);
+ println(`${id}:`);
+ for (const line of internals.dumpVisualContextNodes(document.getElementById(id)).trimEnd().split("\n"))
+ println(` ${line.replace(/^\[[sce]\d+\] /, "")}`);
}
internals.setManualRenderingOpportunities(false);
done();
diff --git a/Tests/LibWeb/Text/input/display_list/will-change-opacity-value-update.html b/Tests/LibWeb/Text/input/display_list/will-change-opacity-value-update.html
index b87a5dea267..508738f83e1 100644
--- a/Tests/LibWeb/Text/input/display_list/will-change-opacity-value-update.html
+++ b/Tests/LibWeb/Text/input/display_list/will-change-opacity-value-update.html
@@ -12,7 +12,10 @@
<script>
// will-change: opacity gives the box its effects node at opacity 1, so leaving 1, moving between
// fractional values and returning to 1 all patch that node: nothing records again.
-let effectNode;
+const valueUpdate = `
+ update DIRTY-PATH
+ div#box effects UPDATED
+`;
const quiet = `
damage: rows=0 moved=0 order=0 eligibility=0 all=false
@canvas RECORD (empty)
@@ -24,23 +27,17 @@ displayListTest({
{
name: "opacity 1 to 0.5",
mutate: () => { box.style.opacity = "0.5"; },
- check: assert => {
- effectNode = internals.visualContextNodeIndices(box).effects[0];
- assert(typeof effectNode, "number", "the box owns an effects node");
- },
- expect: quiet,
+ expect: { visualContexts: valueUpdate, displayList: quiet },
},
{
name: "opacity 0.5 to 0.6",
mutate: () => { box.style.opacity = "0.6"; },
- check: assert => { assert(internals.visualContextNodeIndices(box).effects[0], effectNode, "effects node"); },
- expect: quiet,
+ expect: { visualContexts: valueUpdate, displayList: quiet },
},
{
name: "opacity 0.6 to 1",
mutate: () => { box.style.opacity = ""; },
- check: assert => { assert(internals.visualContextNodeIndices(box).effects[0], effectNode, "effects node"); },
- expect: quiet,
+ expect: { visualContexts: valueUpdate, displayList: quiet },
},
],
});
diff --git a/Tests/LibWeb/Text/input/display_list/will-change-transform-value-update.html b/Tests/LibWeb/Text/input/display_list/will-change-transform-value-update.html
index 29815e68ee0..07a0123871a 100644
--- a/Tests/LibWeb/Text/input/display_list/will-change-transform-value-update.html
+++ b/Tests/LibWeb/Text/input/display_list/will-change-transform-value-update.html
@@ -12,7 +12,10 @@
<script>
// will-change: transform gives the box its transform node before any transform value, so the
// first value, a later value and the return to none all patch that node: nothing records again.
-let transformNode;
+const valueUpdate = `
+ update DIRTY-PATH
+ div#box transform UPDATED
+`;
const quiet = `
damage: rows=0 moved=0 order=0 eligibility=0 all=false
@canvas RECORD (empty)
@@ -24,23 +27,17 @@ displayListTest({
{
name: "transform none to translateX(10px)",
mutate: () => { box.style.transform = "translateX(10px)"; },
- check: assert => {
- transformNode = internals.visualContextNodeIndices(box).spatial[0];
- assert(typeof transformNode, "number", "the box owns a transform node");
- },
- expect: quiet,
+ expect: { visualContexts: valueUpdate, displayList: quiet },
},
{
name: "transform translateX(10px) to translateX(20px)",
mutate: () => { box.style.transform = "translateX(20px)"; },
- check: assert => { assert(internals.visualContextNodeIndices(box).spatial[0], transformNode, "transform node"); },
- expect: quiet,
+ expect: { visualContexts: valueUpdate, displayList: quiet },
},
{
name: "transform translateX(20px) to none",
mutate: () => { box.style.transform = ""; },
- check: assert => { assert(internals.visualContextNodeIndices(box).spatial[0], transformNode, "transform node"); },
- expect: quiet,
+ expect: { visualContexts: valueUpdate, displayList: quiet },
},
],
});
diff --git a/Tests/LibWeb/Text/input/display_list/will-change-visual-context-nodes.html b/Tests/LibWeb/Text/input/display_list/will-change-visual-context-nodes.html
index 606060e5fb3..a284af4e5cf 100644
--- a/Tests/LibWeb/Text/input/display_list/will-change-visual-context-nodes.html
+++ b/Tests/LibWeb/Text/input/display_list/will-change-visual-context-nodes.html
@@ -21,9 +21,5 @@
// identity value; other entries and non-transformable boxes create none.
test(() => {
println(internals.dumpDisplayList());
- for (const id of ["transform", "translate", "opacity", "filter", "other", "inline"]) {
- const nodes = internals.visualContextNodeIndices(document.getElementById(id));
- println(`${id}: spatial=${nodes.spatial.length} effects=${nodes.effects.length}`);
- }
});
</script>
diff --git a/Tests/LibWeb/Text/input/inspector-overlay-visual-context-tree-growth.html b/Tests/LibWeb/Text/input/inspector-overlay-visual-context-tree-growth.html
index 6c7c4d578fa..8575fea59d2 100644
--- a/Tests/LibWeb/Text/input/inspector-overlay-visual-context-tree-growth.html
+++ b/Tests/LibWeb/Text/input/inspector-overlay-visual-context-tree-growth.html
@@ -2,11 +2,7 @@
<!-- Inspector overlays used to append transient copies of the highlighted element's transform/scroll contexts onto
the accumulated visual context tree on every recording, which had to be pruned again by the next recording to
avoid unbounded growth (see #10368). Overlay commands now reference the element's existing context and apply it
- in geometry-only mode, so recording an overlay must not modify the tree at all.
-
- NB: The tree is only rebuilt from scratch when layout is invalidated. Mutating the DOM between measurements (e.g.,
- via println) would dirty layout and force a rebuild — masking accidental growth. So, as in
- visual-context-value-only-updates.html, all measurements are taken first, and printed at the end. -->
+ in geometry-only mode, so recording an overlay must not modify the tree at all. -->
<style>
#box {
width: 100px;
@@ -16,36 +12,158 @@
}
</style>
<script src="include.js"></script>
+<script src="work-test.js"></script>
<div id="box"></div>
<script>
- test(() => {
- const box = document.getElementById("box");
-
- // dumpDisplayList() records a fresh display list; the count that follows is the resulting live visual context
- // tree size.
- const recordAndCount = () => {
- internals.dumpDisplayList();
- return internals.visualContextTreeNodeCount();
- };
-
- const baseCount = recordAndCount();
-
- internals.setHighlightedNode(box);
- const highlightedCounts = [];
- for (let i = 0; i < 6; i++)
- highlightedCounts.push(recordAndCount());
-
- internals.setHighlightedNode(null);
- const clearedCount = recordAndCount();
-
- const untouchedWhileHighlighted = highlightedCounts.every(c => c === baseCount);
- const untouchedAfterClearing = clearedCount === baseCount;
-
- println(untouchedWhileHighlighted
- ? "PASS: recording with an inspector highlight does not modify the visual context tree"
- : `FAIL: visual context tree changed while highlighted: base ${baseCount}, got ${highlightedCounts.join(", ")}`);
- println(untouchedAfterClearing
- ? "PASS: visual context tree is unchanged after clearing the highlight"
- : `FAIL: expected ${baseCount} nodes after clearing the highlight, got ${clearedCount}`);
+ displayListTest({
+ steps: [
+ {
+ name: "recording with an inspector highlight",
+ paintOverlay: true,
+ mutate: () => internals.setHighlightedNode(box),
+ expect: {
+ visualContexts: ``,
+ displayList: `
+ damage: rows=4 moved=0 order=0 eligibility=0 all=false
+ @canvas RECORD (empty)
+ @viewport RECORD
+ @viewport/preamble RECORD (empty)
+ @viewport/background/hit-test RECORD
+ @viewport/scroll-metadata RECORD (empty)
+ @viewport/background SKIP
+ @viewport/border SKIP
+ BlockContainer<HTML>/descendants(background-and-borders) RECORD
+ @viewport/foreground/hit-test RECORD (empty)
+ @viewport/foreground RECORD (empty)
+ BlockContainer<HTML>/descendants(foreground) RECORD
+ BlockContainer<HTML> RECORD
+ BlockContainer<HTML>/preamble RECORD (empty)
+ BlockContainer<HTML>/background/hit-test RECORD
+ BlockContainer<HTML>/scroll-metadata RECORD (empty)
+ BlockContainer<HTML>/background RECORD (empty)
+ BlockContainer<HTML>/border SKIP
+ BlockContainer<BODY>/descendants(background-and-borders) RECORD
+ BlockContainer<BODY>/background/hit-test RECORD
+ BlockContainer<BODY>/scroll-metadata RECORD (empty)
+ BlockContainer<BODY>/background SKIP
+ BlockContainer<BODY>/border SKIP
+ BlockContainer<DIV>#box/descendants(background-and-borders) RECORD
+ BlockContainer<HTML>/foreground/hit-test RECORD (empty)
+ BlockContainer<HTML>/foreground RECORD (empty)
+ BlockContainer<BODY>/descendants(foreground) RECORD
+ BlockContainer<BODY>/foreground/hit-test RECORD (empty)
+ BlockContainer<BODY>/foreground RECORD (empty)
+ BlockContainer<DIV>#box/descendants(foreground) RECORD
+ BlockContainer<BODY>/outline SKIP
+ BlockContainer<BODY>/overlay/hit-test RECORD (empty)
+ BlockContainer<BODY>/overlay SKIP
+ BlockContainer<DIV>#box RECORD
+ BlockContainer<DIV>#box/preamble RECORD (empty)
+ BlockContainer<DIV>#box/background/hit-test RECORD
+ BlockContainer<DIV>#box/scroll-metadata RECORD (empty)
+ BlockContainer<DIV>#box/background RECORD
+ BlockContainer<DIV>#box/border SKIP
+ BlockContainer<DIV>#box/foreground/hit-test RECORD (empty)
+ BlockContainer<DIV>#box/foreground RECORD (empty)
+ BlockContainer<DIV>#box/outline SKIP
+ BlockContainer<DIV>#box/overlay/hit-test RECORD (empty)
+ BlockContainer<DIV>#box/overlay SKIP
+ BlockContainer<HTML>/outline SKIP
+ BlockContainer<HTML>/overlay/hit-test RECORD (empty)
+ BlockContainer<HTML>/overlay SKIP
+ @viewport/outline SKIP
+ @viewport/overlay/hit-test RECORD (empty)
+ @viewport/overlay RECORD (empty)
+ @inspector-overlays RECORD
+ `,
+ },
+ },
+ {
+ name: "recording again with the highlight",
+ paintOverlay: true,
+ expect: {
+ visualContexts: ``,
+ displayList: `
+ damage: rows=0 moved=0 order=0 eligibility=0 all=false
+ @canvas RECORD (empty)
+ @viewport ASSEMBLE
+ @viewport/preamble COPY
+ @viewport/background/hit-test COPY
+ @viewport/scroll-metadata COPY
+ @viewport/background COPY
+ @viewport/border COPY
+ BlockContainer<HTML>/descendants(background-and-borders) COPY
+ @viewport/foreground/hit-test COPY
+ @viewport/foreground COPY
+ BlockContainer<HTML>/descendants(foreground) COPY
+ BlockContainer<HTML> COPY
+ @viewport/outline COPY
+ @viewport/overlay/hit-test COPY
+ @viewport/overlay COPY
+ @inspector-overlays RECORD
+ `,
+ },
+ },
+ {
+ name: "recording after clearing the highlight",
+ paintOverlay: true,
+ mutate: () => internals.setHighlightedNode(null),
+ expect: {
+ visualContexts: ``,
+ displayList: `
+ damage: rows=4 moved=0 order=0 eligibility=0 all=false
+ @canvas RECORD (empty)
+ @viewport ASSEMBLE
+ @viewport/preamble COPY
+ @viewport/background/hit-test COPY
+ @viewport/scroll-metadata COPY
+ @viewport/background COPY
+ @viewport/border COPY
+ BlockContainer<HTML>/descendants(background-and-borders) ASSEMBLE
+ @viewport/foreground/hit-test COPY
+ @viewport/foreground COPY
+ BlockContainer<HTML>/descendants(foreground) ASSEMBLE
+ BlockContainer<HTML> ASSEMBLE
+ BlockContainer<HTML>/preamble COPY
+ BlockContainer<HTML>/background/hit-test COPY
+ BlockContainer<HTML>/scroll-metadata COPY
+ BlockContainer<HTML>/background COPY
+ BlockContainer<HTML>/border COPY
+ BlockContainer<BODY>/descendants(background-and-borders) ASSEMBLE
+ BlockContainer<BODY>/background/hit-test COPY
+ BlockContainer<BODY>/scroll-metadata COPY
+ BlockContainer<BODY>/background COPY
+ BlockContainer<BODY>/border COPY
+ BlockContainer<DIV>#box/descendants(background-and-borders) ASSEMBLE
+ BlockContainer<HTML>/foreground/hit-test COPY
+ BlockContainer<HTML>/foreground COPY
+ BlockContainer<BODY>/descendants(foreground) ASSEMBLE
+ BlockContainer<BODY>/foreground/hit-test COPY
+ BlockContainer<BODY>/foreground COPY
+ BlockContainer<DIV>#box/descendants(foreground) ASSEMBLE
+ BlockContainer<BODY>/outline COPY
+ BlockContainer<BODY>/overlay/hit-test COPY
+ BlockContainer<BODY>/overlay COPY
+ BlockContainer<DIV>#box ASSEMBLE
+ BlockContainer<DIV>#box/preamble RECORD (empty)
+ BlockContainer<DIV>#box/background/hit-test COPY
+ BlockContainer<DIV>#box/scroll-metadata COPY
+ BlockContainer<DIV>#box/background RECORD
+ BlockContainer<DIV>#box/border SKIP
+ BlockContainer<DIV>#box/foreground/hit-test COPY
+ BlockContainer<DIV>#box/foreground RECORD (empty)
+ BlockContainer<DIV>#box/outline SKIP
+ BlockContainer<DIV>#box/overlay/hit-test COPY
+ BlockContainer<DIV>#box/overlay SKIP
+ BlockContainer<HTML>/outline COPY
+ BlockContainer<HTML>/overlay/hit-test COPY
+ BlockContainer<HTML>/overlay COPY
+ @viewport/outline COPY
+ @viewport/overlay/hit-test COPY
+ @viewport/overlay COPY
+ `,
+ },
+ },
+ ],
});
</script>
diff --git a/Tests/LibWeb/Text/input/lazy-accumulated-visual-context-rebuild.html b/Tests/LibWeb/Text/input/lazy-accumulated-visual-context-rebuild.html
index 2fd5b7617f9..d1da3f877c2 100644
--- a/Tests/LibWeb/Text/input/lazy-accumulated-visual-context-rebuild.html
+++ b/Tests/LibWeb/Text/input/lazy-accumulated-visual-context-rebuild.html
@@ -5,11 +5,15 @@
<script>
test(() => {
const target = document.getElementById('target');
- const visualContextUpdateCount = () =>
- internals.accumulatedVisualContextTreeBuildCount() + internals.accumulatedVisualContextIncrementalUpdateCount();
+ const visualContextUpdates = () => {
+ const trace = internals.takeVisualContextTrace().trimEnd();
+ internals.beginVisualContextTrace();
+ return trace ? `\n${trace}` : " (none)";
+ };
- target.getBoundingClientRect();
- const initialUpdateCount = visualContextUpdateCount();
+ internals.forceIncompatibleVisualContextTreeRebuild();
+ internals.updateVisualContextsForTesting();
+ internals.beginVisualContextTrace();
const lines = [];
for (const width of [110, 120, 130]) {
@@ -17,22 +21,24 @@
lines.push(`offset width: ${target.offsetWidth}`);
}
- lines.push(`visual context updates after layout-only reads: ${visualContextUpdateCount() - initialUpdateCount}`);
+ lines.push(`visual context updates after layout-only reads:${visualContextUpdates()}`);
const cleanReadWork = layoutWork(() => target.offsetWidth);
lines.push(`layout during clean read: ${cleanReadWork.passes().join(" | ") || "(no layout)"}`);
lines.push(`bounding rect width: ${target.getBoundingClientRect().width}`);
- lines.push(`visual context updates after identity transform read: ${visualContextUpdateCount() - initialUpdateCount}`);
+ lines.push(`visual context updates after identity transform read:${visualContextUpdates()}`);
const transformedChild = document.createElement('div');
+ transformedChild.id = "transformed-child";
transformedChild.style.transform = 'translateX(10px)';
target.appendChild(transformedChild);
lines.push(`bounding rect with transformed child: ${target.getBoundingClientRect().width}`);
- lines.push(`visual context updates after unrelated transform read: ${visualContextUpdateCount() - initialUpdateCount}`);
+ lines.push(`visual context updates after unrelated transform read:${visualContextUpdates()}`);
target.style.transform = 'translateX(10px)';
lines.push(`transformed rect x: ${target.getBoundingClientRect().x}`);
- lines.push(`visual context updates after non-identity transform read: ${visualContextUpdateCount() - initialUpdateCount}`);
+ lines.push(`visual context updates after non-identity transform read:${visualContextUpdates()}`);
+ internals.takeVisualContextTrace();
for (const line of lines)
println(line);
diff --git a/Tests/LibWeb/Text/input/range-client-rects-lazy-visual-context-update.html b/Tests/LibWeb/Text/input/range-client-rects-lazy-visual-context-update.html
index bf0b1929a00..ece7f8a1ba7 100644
--- a/Tests/LibWeb/Text/input/range-client-rects-lazy-visual-context-update.html
+++ b/Tests/LibWeb/Text/input/range-client-rects-lazy-visual-context-update.html
@@ -5,18 +5,16 @@
// The client rects of a range over text that no box transforms or scrolls are its absolute rects, which spares the
// visual context update a layout left pending. Printing lays the document out, so the lines are printed last.
test(() => {
- const visualContextUpdateCount = () =>
- internals.accumulatedVisualContextTreeBuildCount() + internals.accumulatedVisualContextIncrementalUpdateCount();
const range = document.createRange();
range.selectNodeContents(target.firstChild);
range.getClientRects();
const lines = [];
target.style.width = "120px";
- const before = visualContextUpdateCount();
+ internals.beginVisualContextTrace();
const rects = range.getClientRects();
- const updates = visualContextUpdateCount() - before;
+ const updates = internals.takeVisualContextTrace();
lines.push(`rects: ${rects.length}, at the origin of the text: ${rects[0].left === target.getBoundingClientRect().left}`);
- lines.push(`visual context updates: ${updates}`);
+ lines.push(`visual context updates: ${updates || "(none)"}`);
for (const line of lines)
println(line);
});
diff --git a/Tests/LibWeb/Text/input/scroll-does-not-rebuild-accumulated-visual-context-tree.html b/Tests/LibWeb/Text/input/scroll-does-not-rebuild-accumulated-visual-context-tree.html
deleted file mode 100644
index 22363596010..00000000000
--- a/Tests/LibWeb/Text/input/scroll-does-not-rebuild-accumulated-visual-context-tree.html
+++ /dev/null
@@ -1,24 +0,0 @@
-<!DOCTYPE html>
-<script src="include.js"></script>
-<div id="scroller" style="width: 100px; height: 100px; overflow: scroll">
- <div style="width: 500px; height: 500px"></div>
-</div>
-<script>
- test(() => {
- const scroller = document.getElementById('scroller');
-
- scroller.getBoundingClientRect();
- const initialBuildCount = internals.accumulatedVisualContextTreeBuildCount();
- const lines = [];
-
- scroller.scrollTop = 100;
- scroller.scrollLeft = 50;
- lines.push(`scrollTop: ${scroller.scrollTop}`);
- lines.push(`scrollLeft: ${scroller.scrollLeft}`);
- lines.push(`bounding rect y: ${scroller.getBoundingClientRect().y}`);
- lines.push(`builds after pure scroll: ${internals.accumulatedVisualContextTreeBuildCount() - initialBuildCount}`);
-
- for (const line of lines)
- println(line);
- });
-</script>
diff --git a/Tests/LibWeb/Text/input/visual-context/anchor-page-swap-keeps-untouched-node-indices.html b/Tests/LibWeb/Text/input/visual-context/anchor-page-swap-keeps-untouched-node-indices.html
index 24bb4b2ca5a..b28e9765197 100644
--- a/Tests/LibWeb/Text/input/visual-context/anchor-page-swap-keeps-untouched-node-indices.html
+++ b/Tests/LibWeb/Text/input/visual-context/anchor-page-swap-keeps-untouched-node-indices.html
@@ -1,5 +1,6 @@
<!DOCTYPE html>
<script src="../include.js"></script>
+<script src="../work-test.js"></script>
<style>
body { margin: 0; }
#anchor { anchor-name: --a; width: 20px; height: 20px; }
@@ -20,45 +21,81 @@
<div id="c" class="box clipped lift"></div>
<div id="d" class="box"></div>
<script>
- test(() => {
- const settle = () => document.elementFromPoint(0, 0);
- const indices = element => JSON.stringify(internals.visualContextNodeIndices(element));
- const a = document.getElementById("a");
- const b = document.getElementById("b");
- const c = document.getElementById("c");
- const d = document.getElementById("d");
- const lines = [];
-
- settle();
- document.body.appendChild(document.createElement("pre"));
- settle();
- internals.forceIncompatibleVisualContextTreeRebuild();
- settle();
-
- const swap = (className, label) => {
- const liveNodes = internals.visualContextTreeNodeCount();
- const epoch = internals.visualContextTreeStructuralEpoch();
- const fullBuilds = internals.accumulatedVisualContextTreeBuildCount();
- const incrementalUpdates = internals.accumulatedVisualContextIncrementalUpdateCount();
- const bIndices = indices(b);
- const cIndices = indices(c);
- a.classList.remove(className);
- d.classList.add(className);
- settle();
- lines.push(`${label}: full builds ${internals.accumulatedVisualContextTreeBuildCount() - fullBuilds}, incremental updates ${internals.accumulatedVisualContextIncrementalUpdateCount() - incrementalUpdates}`);
- lines.push(`${label}: b keeps its node indices: ${indices(b) === bIndices}`);
- lines.push(`${label}: c keeps its node indices: ${indices(c) === cIndices}`);
- lines.push(`${label}: live nodes unchanged: ${internals.visualContextTreeNodeCount() === liveNodes}`);
- lines.push(`${label}: epoch advanced: ${internals.visualContextTreeStructuralEpoch() !== epoch}`);
- };
-
- lines.push(`b owns nodes: ${internals.visualContextNodeIndices(b).clips.length > 0 && internals.visualContextNodeIndices(b).spatial.length > 0}`);
- swap("clipped", "clip swap");
- swap("lift", "transform swap");
- lines.push(`dead nodes after the swaps: ${internals.visualContextTreeDeadNodeCount() > 0}`);
- lines.push(`d owns the moved nodes: ${internals.visualContextNodeIndices(d).clips.length > 0 && internals.visualContextNodeIndices(d).spatial.length > 0}`);
-
- for (const line of lines)
- println(line);
+ const swap = (from, to, className) => {
+ from.classList.remove(className);
+ to.classList.add(className);
+ };
+ visualContextTest({
+ setup: async () => {
+ internals.forceIncompatibleVisualContextTreeRebuild();
+ while (internals.frameSchedulerState() !== "idle")
+ await new Promise(resolve => setTimeout(resolve, 0));
+ },
+ steps: [
+ {
+ name: "clip swap",
+ mutate: () => swap(a, d, "clipped"),
+ expect: `
+ update DIRTY-PATH
+ div#a.box.lift clip-path RELEASED
+ div#d.box.clipped clip-path ALLOCATED
+ div#d.box.clipped clip-path ALLOCATED
+ epoch NEW
+ recording NEEDED
+ `,
+ },
+ {
+ name: "transform swap",
+ mutate: () => swap(a, d, "lift"),
+ expect: `
+ update DIRTY-PATH
+ div#a.box transform RELEASED
+ div#d.box.clipped.lift transform ALLOCATED
+ div#d.box.clipped.lift clip-path REPURPOSED
+ div#d.box.clipped.lift clip-path RELEASED
+ epoch NEW
+ recording NEEDED
+ `,
+ },
+ // Flipping the viewport's wheel overflow changes the tree inputs, which rebuilds every
+ // box in place; the swap in the same update must not renumber the untouched boxes.
+ {
+ name: "clip swap while every box is rebuilt",
+ mutate: () => {
+ swap(d, a, "clipped");
+ document.documentElement.style.overflow = "hidden";
+ },
+ expect: `
+ update DIRTY-PATH -> EVERY-BOX
+ div#a.box.clipped clip-path ALLOCATED
+ div#a.box.clipped clip-path ALLOCATED
+ div#b.box.clipped.lift clip-path UPDATED
+ div#b.box.clipped.lift scroll UPDATED
+ div#c.box.clipped.lift clip-path UPDATED
+ div#d.box.lift clip-path RELEASED
+ epoch NEW
+ recording NEEDED
+ `,
+ },
+ {
+ name: "transform swap while every box is rebuilt",
+ mutate: () => {
+ swap(d, a, "lift");
+ document.documentElement.style.overflow = "auto";
+ },
+ expect: `
+ update DIRTY-PATH -> EVERY-BOX
+ div#a.box.clipped.lift transform ALLOCATED
+ div#a.box.clipped.lift clip-path REPURPOSED
+ div#a.box.clipped.lift clip-path RELEASED
+ div#b.box.clipped.lift clip-path UPDATED
+ div#b.box.clipped.lift scroll UPDATED
+ div#c.box.clipped.lift clip-path UPDATED
+ div#d.box transform RELEASED
+ epoch NEW
+ recording NEEDED
+ `,
+ },
+ ],
});
</script>
diff --git a/Tests/LibWeb/Text/input/visual-context/anchor-positioned-box-keeps-visual-context-updates-incremental.html b/Tests/LibWeb/Text/input/visual-context/anchor-positioned-box-keeps-visual-context-updates-incremental.html
index 15d1fcf3e44..722a1494573 100644
--- a/Tests/LibWeb/Text/input/visual-context/anchor-positioned-box-keeps-visual-context-updates-incremental.html
+++ b/Tests/LibWeb/Text/input/visual-context/anchor-positioned-box-keeps-visual-context-updates-incremental.html
@@ -1,9 +1,10 @@
<!DOCTYPE html>
<script src="../include.js"></script>
+<script src="../work-test.js"></script>
<style>
body { margin: 0; }
#scroller { width: 100px; height: 100px; overflow: scroll; }
- #spacer { height: 500px; }
+ #spacer { width: 200px; height: 500px; }
#anchor { anchor-name: --a; width: 20px; height: 20px; }
#target { position: absolute; position-anchor: --a; top: anchor(bottom); left: anchor(left); width: 20px; height: 20px; }
#other { width: 50px; height: 50px; }
@@ -12,43 +13,72 @@
<div id="target"></div>
<div id="other"></div>
<script>
- test(() => {
- const anchor = document.getElementById('anchor');
- const other = document.getElementById('other');
- const scroller = document.getElementById('scroller');
- const target = document.getElementById('target');
-
- println(`anchored box top: ${target.getBoundingClientRect().top}`);
- println(`anchored box own spatial nodes: ${internals.visualContextNodeIndices(target).spatial.length}`);
- let builds = internals.accumulatedVisualContextTreeBuildCount();
- let incrementalUpdates = internals.accumulatedVisualContextIncrementalUpdateCount();
- const report = label => {
- const currentBuilds = internals.accumulatedVisualContextTreeBuildCount();
- const currentIncrementalUpdates = internals.accumulatedVisualContextIncrementalUpdateCount();
- println(`${label}: full builds ${currentBuilds - builds}, incremental updates ${currentIncrementalUpdates - incrementalUpdates}`);
- builds = currentBuilds;
- incrementalUpdates = currentIncrementalUpdates;
- };
-
- other.style.transform = 'translateX(10px)';
- other.getBoundingClientRect();
- report('unrelated transform added');
-
- other.style.opacity = '0.5';
- other.getBoundingClientRect();
- report('unrelated opacity added');
-
- scroller.scrollTop = 30;
- println(`anchored box top after scrolling the anchor's scroller: ${target.getBoundingClientRect().top}`);
- report('anchor scroller scrolled');
-
- anchor.style.height = '40px';
- println(`anchored box top after resizing the anchor: ${target.getBoundingClientRect().top}`);
- report('anchor resized');
-
- scroller.style.overflow = 'visible';
- println(`anchored box top after the scroller stops scrolling: ${target.getBoundingClientRect().top}`);
- println(`anchored box own spatial nodes without a scroller: ${internals.visualContextNodeIndices(target).spatial.length}`);
- report('anchor scroller removed');
+ visualContextTest({
+ setup: async () => {
+ internals.forceIncompatibleVisualContextTreeRebuild();
+ while (internals.frameSchedulerState() !== "idle")
+ await new Promise(resolve => setTimeout(resolve, 0));
+ },
+ steps: [
+ {
+ name: "anchored box",
+ check: equal => equal(target.getBoundingClientRect().top, 20, "anchored box top"),
+ expect: ``,
+ },
+ {
+ name: "unrelated transform added",
+ mutate: () => { other.style.transform = "translateX(10px)"; },
+ expect: `
+ update DIRTY-PATH
+ div#other transform ALLOCATED
+ recording NEEDED
+ `,
+ },
+ {
+ name: "unrelated opacity added",
+ mutate: () => { other.style.opacity = "0.5"; },
+ expect: `
+ update DIRTY-PATH
+ div#other effects ALLOCATED
+ recording NEEDED
+ `,
+ },
+ {
+ name: "anchor scroller scrolled",
+ mutate: () => {
+ scroller.scrollTop = 30;
+ scroller.scrollLeft = 50;
+ },
+ check: equal => {
+ equal(scroller.scrollTop, 30, "scrollTop");
+ equal(scroller.scrollLeft, 50, "scrollLeft");
+ equal(target.getBoundingClientRect().top, -10, "anchored box top");
+ equal(target.getBoundingClientRect().left, -50, "anchored box left");
+ },
+ expect: ``,
+ },
+ {
+ name: "anchor resized",
+ mutate: () => { anchor.style.height = "40px"; },
+ check: equal => equal(target.getBoundingClientRect().top, 10, "anchored box top"),
+ expect: `
+ update DIRTY-PATH
+ div#scroller scroll UPDATED
+ `,
+ },
+ {
+ name: "anchor scroller removed",
+ mutate: () => { scroller.style.overflow = "visible"; },
+ check: equal => equal(target.getBoundingClientRect().top, 40, "anchored box top"),
+ expect: `
+ update DIRTY-PATH
+ div#scroller scroll RELEASED
+ div#scroller clip RELEASED
+ div#target anchor shift RELEASED
+ epoch NEW
+ recording NEEDED
+ `,
+ },
+ ],
});
</script>
diff --git a/Tests/LibWeb/Text/input/visual-context/anchor-scroll-shift-follows-scroll-container-change.html b/Tests/LibWeb/Text/input/visual-context/anchor-scroll-shift-follows-scroll-container-change.html
index 5f6816ec2f7..a82521dc633 100644
--- a/Tests/LibWeb/Text/input/visual-context/anchor-scroll-shift-follows-scroll-container-change.html
+++ b/Tests/LibWeb/Text/input/visual-context/anchor-scroll-shift-follows-scroll-container-change.html
@@ -1,5 +1,6 @@
<!DOCTYPE html>
<script src="../include.js"></script>
+<script src="../work-test.js"></script>
<style>
body { margin: 0; }
#cb { position: relative; width: 300px; height: 300px; }
@@ -14,33 +15,43 @@
<div id="target"></div>
</div>
<script>
- test(() => {
- const container = document.getElementById('container');
- const target = document.getElementById('target');
- const ownSpatialNodes = () => internals.visualContextNodeIndices(target).spatial.length;
-
- println(`own spatial nodes without a scroll container above the anchor: ${ownSpatialNodes()}`);
- let builds = internals.accumulatedVisualContextTreeBuildCount();
- let incrementalUpdates = internals.accumulatedVisualContextIncrementalUpdateCount();
- const report = label => {
- const currentBuilds = internals.accumulatedVisualContextTreeBuildCount();
- const currentIncrementalUpdates = internals.accumulatedVisualContextIncrementalUpdateCount();
- println(`${label}: full builds ${currentBuilds - builds}, incremental updates ${currentIncrementalUpdates - incrementalUpdates}`);
- builds = currentBuilds;
- incrementalUpdates = currentIncrementalUpdates;
- };
-
- container.classList.add('scrolls');
- println(`own spatial nodes with a scroll container above the anchor: ${ownSpatialNodes()}`);
- report('scroll container added');
-
- container.scrollTop = 50;
- println(`anchored box top after scrolling the container: ${target.getBoundingClientRect().top}`);
- report('container scrolled');
-
- container.classList.remove('scrolls');
- println(`own spatial nodes after the scroll container is gone: ${ownSpatialNodes()}`);
- println(`anchored box top after the scroll container is gone: ${target.getBoundingClientRect().top}`);
- report('scroll container removed');
+ visualContextTest({
+ setup: async () => {
+ internals.forceIncompatibleVisualContextTreeRebuild();
+ while (internals.frameSchedulerState() !== "idle")
+ await new Promise(resolve => setTimeout(resolve, 0));
+ },
+ steps: [
+ {
+ name: "scroll container added",
+ mutate: () => container.classList.add("scrolls"),
+ expect: `
+ update DIRTY-PATH
+ div#container.scrolls clip ALLOCATED
+ div#container.scrolls scroll ALLOCATED
+ div#target anchor shift ALLOCATED
+ recording NEEDED
+ `,
+ },
+ {
+ name: "container scrolled",
+ mutate: () => { container.scrollTop = 50; },
+ check: equal => equal(target.getBoundingClientRect().top, -30, "anchored box top"),
+ expect: ``,
+ },
+ {
+ name: "scroll container removed",
+ mutate: () => container.classList.remove("scrolls"),
+ check: equal => equal(target.getBoundingClientRect().top, 20, "anchored box top"),
+ expect: `
+ update DIRTY-PATH
+ div#container scroll RELEASED
+ div#container clip RELEASED
+ div#target anchor shift RELEASED
+ epoch NEW
+ recording NEEDED
+ `,
+ },
+ ],
});
</script>
diff --git a/Tests/LibWeb/Text/input/visual-context/backdrop-filter-value-update-keeps-tree.html b/Tests/LibWeb/Text/input/visual-context/backdrop-filter-value-update-keeps-tree.html
deleted file mode 100644
index e054e3165ac..00000000000
--- a/Tests/LibWeb/Text/input/visual-context/backdrop-filter-value-update-keeps-tree.html
+++ /dev/null
@@ -1,36 +0,0 @@
-<!DOCTYPE html>
-<script src="../include.js"></script>
-<!-- Changing one backdrop filter for another patches the box's effect in place: the recorded display list
- only marks the region and needs no new recording. -->
-<div id="box" style="width: 100px; height: 100px; backdrop-filter: invert(1)"></div>
-<script>
- promiseTest(async () => {
- const settle = () => internals.recordDisplayListForTesting();
- const box = document.getElementById("box");
- settle();
- // Only a frame takes back the request for a recording.
- await new Promise(resolve => requestAnimationFrame(() => requestAnimationFrame(resolve)));
- while (internals.frameSchedulerState() !== "idle")
- await new Promise(resolve => setTimeout(resolve, 0));
- const liveNodes = internals.visualContextTreeNodeCount();
- const capacity = internals.visualContextTreeNodeCapacity();
- const epoch = internals.visualContextTreeStructuralEpoch();
- const fullBuilds = internals.accumulatedVisualContextTreeBuildCount();
- const incrementalUpdates = internals.accumulatedVisualContextIncrementalUpdateCount();
-
- box.style.backdropFilter = "invert(0.5)";
- settle();
- const needsDisplayListRecord = internals.needsDisplayListRecord;
-
- const lines = [
- `needs display list record: ${needsDisplayListRecord}`,
- `full builds: ${internals.accumulatedVisualContextTreeBuildCount() - fullBuilds}`,
- `incremental updates: ${internals.accumulatedVisualContextIncrementalUpdateCount() - incrementalUpdates}`,
- `live nodes unchanged: ${internals.visualContextTreeNodeCount() === liveNodes}`,
- `capacity unchanged: ${internals.visualContextTreeNodeCapacity() === capacity}`,
- `epoch unchanged: ${internals.visualContextTreeStructuralEpoch() === epoch}`,
- ];
- for (const line of lines)
- println(line);
- });
-</script>
diff --git a/Tests/LibWeb/Text/input/visual-context/body-background-propagation-flip.html b/Tests/LibWeb/Text/input/visual-context/body-background-propagation-flip.html
index 43b1021b8ad..8a95fe33099 100644
--- a/Tests/LibWeb/Text/input/visual-context/body-background-propagation-flip.html
+++ b/Tests/LibWeb/Text/input/visual-context/body-background-propagation-flip.html
@@ -1,41 +1,58 @@
<!DOCTYPE html>
<script src="../include.js"></script>
+<script src="../work-test.js"></script>
<style>
#box { width: 50px; height: 50px; transform: translateX(5px); }
</style>
<div id="box"></div>
<script>
- test(() => {
- const settle = () => document.elementFromPoint(0, 0);
- const box = document.getElementById("box");
- settle();
- const fullBuilds = internals.accumulatedVisualContextTreeBuildCount();
- const incrementalUpdates = internals.accumulatedVisualContextIncrementalUpdateCount();
- const lines = [];
-
- document.body.style.background = "orange";
- lines.push(`rect x with propagated body background: ${box.getBoundingClientRect().x}`);
- document.documentElement.style.background = "white";
- lines.push(`rect x without propagation: ${box.getBoundingClientRect().x}`);
- document.documentElement.style.background = "";
- lines.push(`rect x with propagation restored: ${box.getBoundingClientRect().x}`);
- for (const element of [document.body, box]) {
- element.style.backgroundImage = "linear-gradient(red, blue)";
- for (const attachment of ["fixed", "local", "scroll"]) {
- element.style.backgroundAttachment = attachment;
- settle();
- document.documentElement.style.backgroundColor = "white";
- settle();
- document.documentElement.style.backgroundColor = "transparent";
- settle();
- }
- element.style.backgroundImage = "none";
+ const steps = [
+ {
+ name: "propagated body background",
+ mutate: () => { document.body.style.background = "orange"; },
+ check: equal => equal(box.getBoundingClientRect().x, 13, "rect x"),
+ expect: ``,
+ },
+ {
+ name: "propagation stops",
+ mutate: () => { document.documentElement.style.background = "white"; },
+ check: equal => equal(box.getBoundingClientRect().x, 13, "rect x"),
+ expect: ``,
+ },
+ {
+ name: "propagation restored",
+ mutate: () => { document.documentElement.style.background = ""; },
+ check: equal => equal(box.getBoundingClientRect().x, 13, "rect x"),
+ expect: ``,
+ },
+ ];
+ for (const [element, label] of [[document.body, "body"], [box, "box"]]) {
+ for (const attachment of ["fixed", "local", "scroll"]) {
+ steps.push(
+ {
+ name: `${attachment} ${label} background image`,
+ mutate: () => {
+ element.style.backgroundImage = "linear-gradient(red, blue)";
+ element.style.backgroundAttachment = attachment;
+ },
+ expect: ``,
+ },
+ {
+ name: `${attachment} ${label} background image with a root background`,
+ mutate: () => { document.documentElement.style.backgroundColor = "white"; },
+ expect: ``,
+ },
+ {
+ name: `${attachment} ${label} background image without a root background`,
+ mutate: () => { document.documentElement.style.backgroundColor = "transparent"; },
+ expect: ``,
+ });
}
- settle();
- lines.push(`full builds: ${internals.accumulatedVisualContextTreeBuildCount() - fullBuilds}`);
- lines.push(`incremental updates: ${internals.accumulatedVisualContextIncrementalUpdateCount() - incrementalUpdates}`);
-
- for (const line of lines)
- println(line);
- });
+ steps.push({
+ name: `${label} background image removed`,
+ mutate: () => { element.style.backgroundImage = "none"; },
+ expect: ``,
+ });
+ }
+ visualContextTest({ steps });
</script>
diff --git a/Tests/LibWeb/Text/input/visual-context/clip-path-emptiness-flip-re-records-cached-subtree.html b/Tests/LibWeb/Text/input/visual-context/clip-path-emptiness-flip-re-records-cached-subtree.html
index 8dca7b2a555..ed71f6c2eb9 100644
--- a/Tests/LibWeb/Text/input/visual-context/clip-path-emptiness-flip-re-records-cached-subtree.html
+++ b/Tests/LibWeb/Text/input/visual-context/clip-path-emptiness-flip-re-records-cached-subtree.html
@@ -1,5 +1,6 @@
<!DOCTYPE html>
<script src="../include.js"></script>
+<script src="../work-test.js"></script>
<style>
body { margin: 0; }
#clip { clip-path: inset(50%); width: 50px; height: 50px; }
@@ -7,22 +8,34 @@
</style>
<div id="clip"><div id="child"></div></div>
<script>
- test(() => {
- const settle = () => document.elementFromPoint(0, 0);
- const clip = document.getElementById("clip");
- settle();
- const fullBuilds = internals.accumulatedVisualContextTreeBuildCount();
- const lines = [];
- lines.push(`hit while clipped away: ${document.elementFromPoint(10, 10).tagName}`);
-
- clip.style.clipPath = "inset(0)";
- lines.push(`hit after the clip opened: ${document.elementFromPoint(10, 10).id}`);
-
- clip.style.clipPath = "inset(50%)";
- lines.push(`hit after the clip closed again: ${document.elementFromPoint(10, 10).tagName}`);
- lines.push(`full builds: ${internals.accumulatedVisualContextTreeBuildCount() - fullBuilds}`);
-
- for (const line of lines)
- println(line);
+ const hit = () => document.elementFromPoint(10, 10);
+ visualContextTest({
+ steps: [
+ {
+ name: "clipped away",
+ check: equal => equal(hit().tagName, "BODY", "hit"),
+ expect: ``,
+ },
+ {
+ name: "the clip opens",
+ mutate: () => { clip.style.clipPath = "inset(0)"; },
+ check: equal => equal(hit().id, "child", "hit"),
+ expect: `
+ update DIRTY-PATH
+ div#clip clip-path UPDATED
+ div#clip clip-path UPDATED
+ `,
+ },
+ {
+ name: "the clip closes again",
+ mutate: () => { clip.style.clipPath = "inset(50%)"; },
+ check: equal => equal(hit().tagName, "BODY", "hit"),
+ expect: `
+ update DIRTY-PATH
+ div#clip clip-path UPDATED
+ div#clip clip-path UPDATED
+ `,
+ },
+ ],
});
</script>
diff --git a/Tests/LibWeb/Text/input/visual-context/contain-paint-change-rebuilds-the-box.html b/Tests/LibWeb/Text/input/visual-context/contain-paint-change-rebuilds-the-box.html
index 6481293d2b7..d743e795024 100644
--- a/Tests/LibWeb/Text/input/visual-context/contain-paint-change-rebuilds-the-box.html
+++ b/Tests/LibWeb/Text/input/visual-context/contain-paint-change-rebuilds-the-box.html
@@ -1,5 +1,6 @@
<!DOCTYPE html>
<script src="../include.js"></script>
+<script src="../work-test.js"></script>
<style>
body { margin: 0; }
#host { width: 50px; height: 50px; }
@@ -7,22 +8,40 @@
</style>
<div id="host"><div id="child"></div></div>
<script>
- test(() => {
- const settle = () => document.elementFromPoint(0, 0);
- const host = document.getElementById("host");
- settle();
- const fullBuilds = internals.accumulatedVisualContextTreeBuildCount();
- const lines = [];
- lines.push(`overflowing content without containment: ${document.elementFromPoint(75, 10).id}`);
-
- host.style.contain = "paint";
- lines.push(`overflowing content with paint containment: ${document.elementFromPoint(75, 10).tagName}`);
-
- host.style.contain = "none";
- lines.push(`overflowing content after containment is removed: ${document.elementFromPoint(75, 10).id}`);
- lines.push(`full builds: ${internals.accumulatedVisualContextTreeBuildCount() - fullBuilds}`);
-
- for (const line of lines)
- println(line);
+ const overflowingContent = () => document.elementFromPoint(75, 10);
+ visualContextTest({
+ setup: async () => {
+ internals.forceIncompatibleVisualContextTreeRebuild();
+ while (internals.frameSchedulerState() !== "idle")
+ await new Promise(resolve => setTimeout(resolve, 0));
+ },
+ steps: [
+ {
+ name: "without containment",
+ check: equal => equal(overflowingContent().id, "child", "overflowing content"),
+ expect: ``,
+ },
+ {
+ name: "paint containment",
+ mutate: () => { host.style.contain = "paint"; },
+ check: equal => equal(overflowingContent().tagName, "BODY", "overflowing content"),
+ expect: `
+ update DIRTY-PATH
+ div#host clip ALLOCATED
+ recording NEEDED
+ `,
+ },
+ {
+ name: "containment removed",
+ mutate: () => { host.style.contain = "none"; },
+ check: equal => equal(overflowingContent().id, "child", "overflowing content"),
+ expect: `
+ update DIRTY-PATH
+ div#host clip RELEASED
+ epoch NEW
+ recording NEEDED
+ `,
+ },
+ ],
});
</script>
diff --git a/Tests/LibWeb/Text/input/visual-context/empty-clip-flip-reveals-content.html b/Tests/LibWeb/Text/input/visual-context/empty-clip-flip-reveals-content.html
index 77d5b7a2cee..cf35478fe7f 100644
--- a/Tests/LibWeb/Text/input/visual-context/empty-clip-flip-reveals-content.html
+++ b/Tests/LibWeb/Text/input/visual-context/empty-clip-flip-reveals-content.html
@@ -1,5 +1,6 @@
<!DOCTYPE html>
<script src="../include.js"></script>
+<script src="../work-test.js"></script>
<style>
body { margin: 0; }
#clip { overflow: hidden; width: 50px; height: 0; }
@@ -7,24 +8,42 @@
</style>
<div id="clip"><div id="child"></div></div>
<script>
- test(() => {
- const settle = () => document.elementFromPoint(0, 0);
- const clip = document.getElementById("clip");
- settle();
- const fullBuilds = internals.accumulatedVisualContextTreeBuildCount();
- const incrementalUpdates = internals.accumulatedVisualContextIncrementalUpdateCount();
- const lines = [];
- lines.push(`hit while clipped away: ${document.elementFromPoint(25, 25).tagName}`);
-
- clip.style.height = "50px";
- lines.push(`hit after the clip opened: ${document.elementFromPoint(25, 25).id}`);
-
- clip.style.height = "0";
- lines.push(`hit after the clip closed again: ${document.elementFromPoint(25, 25).tagName}`);
- lines.push(`full builds: ${internals.accumulatedVisualContextTreeBuildCount() - fullBuilds}`);
- lines.push(`incremental updates: ${internals.accumulatedVisualContextIncrementalUpdateCount() - incrementalUpdates}`);
-
- for (const line of lines)
- println(line);
+ const hit = () => document.elementFromPoint(25, 25);
+ visualContextTest({
+ setup: async () => {
+ internals.forceIncompatibleVisualContextTreeRebuild();
+ while (internals.frameSchedulerState() !== "idle")
+ await new Promise(resolve => setTimeout(resolve, 0));
+ },
+ steps: [
+ {
+ name: "clipped away",
+ check: equal => equal(hit().tagName, "HTML", "hit"),
+ expect: ``,
+ },
+ {
+ name: "the clip opens",
+ mutate: () => { clip.style.height = "50px"; },
+ check: equal => equal(hit().id, "child", "hit"),
+ expect: `
+ update DIRTY-PATH
+ div#clip clip UPDATED
+ div#clip scroll RELEASED
+ epoch NEW
+ recording NEEDED
+ `,
+ },
+ {
+ name: "the clip closes again",
+ mutate: () => { clip.style.height = "0"; },
+ check: equal => equal(hit().tagName, "HTML", "hit"),
+ expect: `
+ update DIRTY-PATH
+ div#clip clip UPDATED
+ div#clip scroll ALLOCATED
+ recording NEEDED
+ `,
+ },
+ ],
});
</script>
diff --git a/Tests/LibWeb/Text/input/visual-context/every-box-rebuild-keeps-untouched-node-indices.html b/Tests/LibWeb/Text/input/visual-context/every-box-rebuild-keeps-untouched-node-indices.html
deleted file mode 100644
index cd5267643c3..00000000000
--- a/Tests/LibWeb/Text/input/visual-context/every-box-rebuild-keeps-untouched-node-indices.html
+++ /dev/null
@@ -1,63 +0,0 @@
-<!DOCTYPE html>
-<script src="../include.js"></script>
-<style>
- body { margin: 0; }
- .box { position: absolute; top: 100px; width: 100px; height: 100px; }
- .clipped { clip-path: inset(2px); }
- .lift { transform: translateX(1px); }
- #a { left: 0; }
- #b { left: 150px; overflow: scroll; }
- #b > div { width: 400px; height: 400px; }
- #c { left: 300px; }
- #d { left: 450px; }
-</style>
-<div id="a" class="box clipped lift"></div>
-<div id="b" class="box clipped lift"><div></div></div>
-<div id="c" class="box clipped lift"></div>
-<div id="d" class="box"></div>
-<script>
- test(() => {
- const settle = () => document.elementFromPoint(0, 0);
- const indices = element => JSON.stringify(internals.visualContextNodeIndices(element));
- const a = document.getElementById("a");
- const b = document.getElementById("b");
- const c = document.getElementById("c");
- const d = document.getElementById("d");
- const lines = [];
-
- settle();
- document.body.appendChild(document.createElement("pre"));
- settle();
- internals.forceIncompatibleVisualContextTreeRebuild();
- settle();
-
- // Flipping the viewport's wheel overflow changes the tree inputs, which rebuilds every
- // box in place; the swap in the same update must not renumber the untouched boxes.
- const swapWhileEveryBoxIsRebuilt = (className, label, rootOverflow) => {
- const liveNodes = internals.visualContextTreeNodeCount();
- const epoch = internals.visualContextTreeStructuralEpoch();
- const fullBuilds = internals.accumulatedVisualContextTreeBuildCount();
- const incrementalUpdates = internals.accumulatedVisualContextIncrementalUpdateCount();
- const bIndices = indices(b);
- const cIndices = indices(c);
- a.classList.remove(className);
- d.classList.add(className);
- document.documentElement.style.overflow = rootOverflow;
- settle();
- lines.push(`${label}: full builds ${internals.accumulatedVisualContextTreeBuildCount() - fullBuilds}, incremental updates ${internals.accumulatedVisualContextIncrementalUpdateCount() - incrementalUpdates}`);
- lines.push(`${label}: b keeps its node indices: ${indices(b) === bIndices}`);
- lines.push(`${label}: c keeps its node indices: ${indices(c) === cIndices}`);
- lines.push(`${label}: live nodes unchanged: ${internals.visualContextTreeNodeCount() === liveNodes}`);
- lines.push(`${label}: epoch advanced: ${internals.visualContextTreeStructuralEpoch() !== epoch}`);
- };
-
- lines.push(`b owns nodes: ${internals.visualContextNodeIndices(b).clips.length > 0 && internals.visualContextNodeIndices(b).spatial.length > 0}`);
- swapWhileEveryBoxIsRebuilt("clipped", "clip swap", "hidden");
- swapWhileEveryBoxIsRebuilt("lift", "transform swap", "auto");
- lines.push(`dead nodes after the swaps: ${internals.visualContextTreeDeadNodeCount() > 0}`);
- lines.push(`d owns the moved nodes: ${internals.visualContextNodeIndices(d).clips.length > 0 && internals.visualContextNodeIndices(d).spatial.length > 0}`);
-
- for (const line of lines)
- println(line);
- });
-</script>
diff --git a/Tests/LibWeb/Text/input/visual-context/fieldset-legend-change.html b/Tests/LibWeb/Text/input/visual-context/fieldset-legend-change.html
index 3b9e06bea3a..9903e030ab2 100644
--- a/Tests/LibWeb/Text/input/visual-context/fieldset-legend-change.html
+++ b/Tests/LibWeb/Text/input/visual-context/fieldset-legend-change.html
@@ -1,5 +1,6 @@
<!DOCTYPE html>
<script src="../include.js"></script>
+<script src="../work-test.js"></script>
<style>
body { margin: 0; }
fieldset { margin: 0; padding: 20px; border: 4px solid black; width: 200px; }
@@ -7,25 +8,24 @@
</style>
<fieldset id="fieldset"><legend id="legend">Legend</legend><div id="content" style="height: 40px"></div></fieldset>
<script>
- test(() => {
- const settle = () => document.elementFromPoint(0, 0);
- const legend = document.getElementById("legend");
- settle();
- const fullBuilds = internals.accumulatedVisualContextTreeBuildCount();
- const incrementalUpdates = internals.accumulatedVisualContextIncrementalUpdateCount();
- const lines = [];
- const legendRect = legend.getBoundingClientRect();
- lines.push(`legend hit: ${document.elementFromPoint(legendRect.x + 2, legendRect.y + 2).id}`);
-
- legend.style.fontSize = "32px";
- const grownRect = legend.getBoundingClientRect();
- lines.push(`legend grew: ${grownRect.width > legendRect.width && grownRect.height > legendRect.height}`);
- lines.push(`grown legend hit: ${document.elementFromPoint(grownRect.x + grownRect.width - 2, grownRect.y + 2).id}`);
- lines.push(`content hit: ${document.elementFromPoint(30, grownRect.y + grownRect.height + 30).id}`);
- lines.push(`full builds: ${internals.accumulatedVisualContextTreeBuildCount() - fullBuilds}`);
- lines.push(`incremental updates happened: ${internals.accumulatedVisualContextIncrementalUpdateCount() > incrementalUpdates}`);
-
- for (const line of lines)
- println(line);
+ let legendRect;
+ visualContextTest({
+ setup: () => { legendRect = legend.getBoundingClientRect(); },
+ steps: [
+ {
+ name: "legend grows",
+ mutate: () => { legend.style.fontSize = "32px"; },
+ check: equal => {
+ const grownRect = legend.getBoundingClientRect();
+ equal(grownRect.width > legendRect.width && grownRect.height > legendRect.height, true, "legend grew");
+ equal(document.elementFromPoint(legendRect.x + 2, legendRect.y + 2).id, "legend", "legend hit");
+ equal(document.elementFromPoint(grownRect.x + grownRect.width - 2, grownRect.y + 2).id, "legend", "grown legend hit");
+ equal(document.elementFromPoint(30, grownRect.y + grownRect.height + 30).id, "content", "content hit");
+ },
+ expect: `
+ update DIRTY-PATH
+ `,
+ },
+ ],
});
</script>
diff --git a/Tests/LibWeb/Text/input/visual-context/forced-rebuild-mints-a-new-epoch.html b/Tests/LibWeb/Text/input/visual-context/forced-rebuild-mints-a-new-epoch.html
index 82522fc9a68..6e66eafec32 100644
--- a/Tests/LibWeb/Text/input/visual-context/forced-rebuild-mints-a-new-epoch.html
+++ b/Tests/LibWeb/Text/input/visual-context/forced-rebuild-mints-a-new-epoch.html
@@ -1,5 +1,6 @@
<!DOCTYPE html>
<script src="../include.js"></script>
+<script src="../work-test.js"></script>
<style>
.box { position: absolute; top: 100px; width: 100px; height: 100px; transform: translateX(1px); background-image: linear-gradient(green, green); }
#a { left: 0; }
@@ -8,30 +9,45 @@
<div id="a" class="box"></div>
<div id="b" class="box"></div>
<script>
- test(() => {
- const settle = () => document.elementFromPoint(0, 0);
- const lines = [];
-
- settle();
- document.body.appendChild(document.createElement("pre"));
- settle();
- internals.forceIncompatibleVisualContextTreeRebuild();
- settle();
-
- const liveNodes = internals.visualContextTreeNodeCount();
- const epoch = internals.visualContextTreeStructuralEpoch();
- const fullBuilds = internals.accumulatedVisualContextTreeBuildCount();
-
- internals.forceIncompatibleVisualContextTreeRebuild();
- settle();
-
- lines.push(`full builds: ${internals.accumulatedVisualContextTreeBuildCount() - fullBuilds}`);
- lines.push(`epoch changed: ${internals.visualContextTreeStructuralEpoch() !== epoch}`);
- lines.push(`live nodes unchanged: ${internals.visualContextTreeNodeCount() === liveNodes}`);
- lines.push(`capacity equals live nodes: ${internals.visualContextTreeNodeCapacity() === internals.visualContextTreeNodeCount()}`);
- lines.push(`dead nodes: ${internals.visualContextTreeDeadNodeCount()}`);
-
- for (const line of lines)
- println(line);
+ const nodesOf = element => internals.dumpVisualContextNodes(element).replace(/^\[[sce]\d+\] /gm, "");
+ let nodesBefore;
+ visualContextTest({
+ steps: [
+ {
+ name: "dropping a transform releases its node",
+ mutate: () => { b.style.transform = "none"; },
+ expect: `
+ update DIRTY-PATH
+ div#b.box transform RELEASED
+ epoch NEW
+ recording NEEDED
+ `,
+ },
+ {
+ name: "a forced rebuild builds a fresh tree under a new epoch",
+ mutate: () => {
+ nodesBefore = nodesOf(a);
+ internals.forceIncompatibleVisualContextTreeRebuild();
+ },
+ check: equal => equal(nodesOf(a), nodesBefore, "nodes of #a"),
+ expect: `
+ update FRESH-TREE
+ epoch NEW
+ recording NEEDED
+ `,
+ },
+ {
+ name: "the fresh tree has no released slots to hand out",
+ mutate: () => {
+ internals.recordDisplayListForTesting();
+ b.style.transform = "";
+ },
+ expect: `
+ update DIRTY-PATH
+ div#b.box transform ALLOCATED
+ recording NEEDED
+ `,
+ },
+ ],
});
</script>
diff --git a/Tests/LibWeb/Text/input/visual-context/geometry-walk-survives-descendant-output-change.html b/Tests/LibWeb/Text/input/visual-context/geometry-walk-survives-descendant-output-change.html
index 880cfa80daa..237a611db2b 100644
--- a/Tests/LibWeb/Text/input/visual-context/geometry-walk-survives-descendant-output-change.html
+++ b/Tests/LibWeb/Text/input/visual-context/geometry-walk-survives-descendant-output-change.html
@@ -1,5 +1,6 @@
<!DOCTYPE html>
<script src="../include.js"></script>
+<script src="../work-test.js"></script>
<style>
body { margin: 0; }
#moving { margin-left: 0; width: 100px; height: 50px; }
@@ -13,25 +14,59 @@
</div>
</div>
<script>
- test(() => {
- const settle = () => document.elementFromPoint(0, 0);
- const moving = document.getElementById("moving");
- settle();
-
- moving.style.clipPath = "inset(0)";
- settle();
- moving.style.clipPath = "none";
- settle();
- const fullBuilds = internals.accumulatedVisualContextTreeBuildCount();
-
- moving.style.marginLeft = "100px";
- moving.style.clipPath = "inset(0)";
- const lines = [];
- lines.push(`inside the moved clip: ${document.elementFromPoint(125, 25).id}`);
- lines.push(`old position after the move: ${document.elementFromPoint(25, 25).tagName}`);
- lines.push(`full builds: ${internals.accumulatedVisualContextTreeBuildCount() - fullBuilds}`);
-
- for (const line of lines)
- println(line);
+ visualContextTest({
+ setup: async () => {
+ internals.forceIncompatibleVisualContextTreeRebuild();
+ while (internals.frameSchedulerState() !== "idle")
+ await new Promise(resolve => setTimeout(resolve, 0));
+ },
+ steps: [
+ {
+ name: "clip-path added",
+ mutate: () => { moving.style.clipPath = "inset(0)"; },
+ expect: `
+ update DIRTY-PATH
+ div#moving clip-path ALLOCATED
+ div#moving clip-path ALLOCATED
+ div#barrier clip REPURPOSED
+ epoch NEW
+ recording NEEDED
+ `,
+ },
+ {
+ name: "clip-path removed",
+ mutate: () => { moving.style.clipPath = "none"; },
+ expect: `
+ update DIRTY-PATH
+ div#moving clip-path RELEASED
+ div#moving clip-path RELEASED
+ div#barrier clip REPURPOSED
+ epoch NEW
+ recording NEEDED
+ `,
+ },
+ {
+ name: "moved with a clip-path again",
+ mutate: () => {
+ moving.style.marginLeft = "100px";
+ moving.style.clipPath = "inset(0)";
+ },
+ check: equal => {
+ equal(document.elementFromPoint(125, 25).id, "target", "inside the moved clip");
+ equal(document.elementFromPoint(25, 25).tagName, "BODY", "old position after the move");
+ },
+ expect: `
+ update DIRTY-PATH
+ div#moving clip-path ALLOCATED
+ div#moving clip-path ALLOCATED
+ div#barrier transform UPDATED
+ div#barrier clip REPURPOSED
+ div#clip clip UPDATED
+ div#clip scroll UPDATED
+ epoch NEW
+ recording NEEDED
+ `,
+ },
+ ],
});
</script>
diff --git a/Tests/LibWeb/Text/input/visual-context/moved-subtree-refreshes-descendant-clip.html b/Tests/LibWeb/Text/input/visual-context/moved-subtree-refreshes-descendant-clip.html
index d6b30cfb536..f77c3126db1 100644
--- a/Tests/LibWeb/Text/input/visual-context/moved-subtree-refreshes-descendant-clip.html
+++ b/Tests/LibWeb/Text/input/visual-context/moved-subtree-refreshes-descendant-clip.html
@@ -1,5 +1,6 @@
<!DOCTYPE html>
<script src="../include.js"></script>
+<script src="../work-test.js"></script>
<style>
body { margin: 0; }
#wrapper { margin-left: 0; }
@@ -8,22 +9,31 @@
</style>
<div id="wrapper"><div id="clip"><div id="inner"></div></div></div>
<script>
- test(() => {
- const settle = () => document.elementFromPoint(0, 0);
- const wrapper = document.getElementById("wrapper");
- settle();
- const fullBuilds = internals.accumulatedVisualContextTreeBuildCount();
- const lines = [];
- lines.push(`inside the clip before the move: ${document.elementFromPoint(25, 10).id}`);
- lines.push(`beside the clip before the move: ${document.elementFromPoint(125, 10).id}`);
-
- wrapper.style.marginLeft = "100px";
- lines.push(`old position after the move: ${document.elementFromPoint(25, 10).tagName}`);
- lines.push(`inside the moved clip: ${document.elementFromPoint(125, 10).id}`);
- lines.push(`beyond the moved clip: ${document.elementFromPoint(175, 10).id}`);
- lines.push(`full builds: ${internals.accumulatedVisualContextTreeBuildCount() - fullBuilds}`);
-
- for (const line of lines)
- println(line);
+ const hit = x => document.elementFromPoint(x, 10);
+ visualContextTest({
+ steps: [
+ {
+ name: "before the move",
+ check: equal => {
+ equal(hit(25).id, "inner", "inside the clip");
+ equal(hit(125).id, "wrapper", "beside the clip");
+ },
+ expect: ``,
+ },
+ {
+ name: "the wrapper moves",
+ mutate: () => { wrapper.style.marginLeft = "100px"; },
+ check: equal => {
+ equal(hit(25).tagName, "BODY", "old position after the move");
+ equal(hit(125).id, "inner", "inside the moved clip");
+ equal(hit(175).id, "wrapper", "beyond the moved clip");
+ },
+ expect: `
+ update DIRTY-PATH
+ div#clip clip UPDATED
+ div#clip scroll UPDATED
+ `,
+ },
+ ],
});
</script>
diff --git a/Tests/LibWeb/Text/input/visual-context/overflow-change-updates-the-clip.html b/Tests/LibWeb/Text/input/visual-context/overflow-change-updates-the-clip.html
index 673f3d6aa90..616f566797a 100644
--- a/Tests/LibWeb/Text/input/visual-context/overflow-change-updates-the-clip.html
+++ b/Tests/LibWeb/Text/input/visual-context/overflow-change-updates-the-clip.html
@@ -1,5 +1,6 @@
<!DOCTYPE html>
<script src="../include.js"></script>
+<script src="../work-test.js"></script>
<style>
body { margin: 0; }
svg { display: block; }
@@ -10,37 +11,57 @@
<svg id="outer" width="50" height="50"><rect id="outer-rect" width="100" height="50" fill="green"/></svg>
<svg width="100" height="50"><svg id="nested" width="50" height="50"><rect id="nested-rect" width="100" height="50" fill="green"/></svg></svg>
<script>
- test(() => {
- const targetAt = (x, y) => {
- const element = document.elementFromPoint(x, y);
- return element.id || element.tagName;
- };
- const host = document.getElementById("host");
- const outer = document.getElementById("outer");
- const nested = document.getElementById("nested");
- targetAt(0, 0);
- const fullBuilds = internals.accumulatedVisualContextTreeBuildCount();
- const lines = [];
-
- host.style.overflow = "clip";
- lines.push(`div content past the box after overflow becomes clip: ${targetAt(75, 10)}`);
- host.style.overflow = "visible";
- lines.push(`div content past the box after overflow becomes visible: ${targetAt(75, 10)}`);
-
- lines.push(`outer svg content past the viewport before overflow changes: ${targetAt(75, 60)}`);
- outer.style.overflow = "visible";
- lines.push(`outer svg content past the viewport after overflow becomes visible: ${targetAt(75, 60)}`);
- outer.style.overflow = "hidden";
- lines.push(`outer svg content past the viewport after overflow becomes hidden: ${targetAt(75, 60)}`);
-
- nested.setAttribute("overflow", "visible");
- lines.push(`nested svg content past the viewport after the overflow attribute becomes visible: ${targetAt(75, 110)}`);
- nested.style.overflow = "hidden";
- lines.push(`nested svg content past the viewport after overflow becomes hidden: ${targetAt(75, 110)}`);
-
- lines.push(`full builds: ${internals.accumulatedVisualContextTreeBuildCount() - fullBuilds}`);
-
- for (const line of lines)
- println(line);
+ const targetAt = (x, y) => {
+ const element = document.elementFromPoint(x, y);
+ return element.id || element.tagName;
+ };
+ const step = (name, mutate, [x, y, target], expect) => ({
+ name,
+ mutate,
+ check: equal => equal(targetAt(x, y), target, "content past the box"),
+ expect,
+ });
+ visualContextTest({
+ setup: async () => {
+ internals.forceIncompatibleVisualContextTreeRebuild();
+ while (internals.frameSchedulerState() !== "idle")
+ await new Promise(resolve => setTimeout(resolve, 0));
+ },
+ steps: [
+ step("div overflow becomes clip", () => { host.style.overflow = "clip"; }, [75, 10, "BODY"], `
+ update DIRTY-PATH
+ div#host clip ALLOCATED
+ recording NEEDED
+ `),
+ step("div overflow becomes visible", () => { host.style.overflow = "visible"; }, [75, 10, "child"], `
+ update DIRTY-PATH
+ div#host clip RELEASED
+ epoch NEW
+ recording NEEDED
+ `),
+ step("outer svg before overflow changes", undefined, [75, 60, "BODY"], ``),
+ step("outer svg overflow becomes visible", () => { outer.style.overflow = "visible"; }, [75, 60, "outer-rect"], `
+ update DIRTY-PATH
+ svg#outer clip RELEASED
+ epoch NEW
+ recording NEEDED
+ `),
+ step("outer svg overflow becomes hidden", () => { outer.style.overflow = "hidden"; }, [75, 60, "BODY"], `
+ update DIRTY-PATH
+ svg#outer clip ALLOCATED
+ recording NEEDED
+ `),
+ step("nested svg overflow attribute becomes visible", () => { nested.setAttribute("overflow", "visible"); }, [75, 110, "nested-rect"], `
+ update DIRTY-PATH
+ svg#nested clip RELEASED
+ epoch NEW
+ recording NEEDED
+ `),
+ step("nested svg overflow becomes hidden", () => { nested.style.overflow = "hidden"; }, [75, 110, "svg"], `
+ update DIRTY-PATH
+ svg#nested clip ALLOCATED
+ recording NEEDED
+ `),
+ ],
});
</script>
diff --git a/Tests/LibWeb/Text/input/visual-context/parent-gaining-a-transform-keeps-descendant-node-indices.html b/Tests/LibWeb/Text/input/visual-context/parent-gaining-a-transform-keeps-descendant-node-indices.html
deleted file mode 100644
index 88e67b4d9b8..00000000000
--- a/Tests/LibWeb/Text/input/visual-context/parent-gaining-a-transform-keeps-descendant-node-indices.html
+++ /dev/null
@@ -1,41 +0,0 @@
-<!DOCTYPE html>
-<script src="../include.js"></script>
-<style>
- #parent {
- width: 200px;
- height: 200px;
- }
-
- #scroller {
- width: 100px;
- height: 100px;
- overflow: scroll;
- }
-
- #content {
- width: 500px;
- height: 500px;
- }
-</style>
-<div id="parent"><div id="scroller"><div id="content"></div></div></div>
-<script>
- test(() => {
- const settle = () => document.elementFromPoint(0, 0);
- const scrollNodeIndex = () => {
- internals.recordDisplayListForTesting();
- return internals.recordedAsyncScrollingState().scrollNodes.find(node => !node.isViewport).scrollNodeIndex;
- };
- settle();
- const initialIndex = scrollNodeIndex();
- const liveNodes = internals.visualContextTreeNodeCount();
- const fullBuilds = internals.accumulatedVisualContextTreeBuildCount();
-
- document.getElementById("parent").style.transform = "translateX(5px)";
- settle();
-
- println(`scroll node index unchanged: ${scrollNodeIndex() === initialIndex}`);
- println(`live nodes grew: ${internals.visualContextTreeNodeCount() > liveNodes}`);
- println(`full builds: ${internals.accumulatedVisualContextTreeBuildCount() - fullBuilds}`);
- println(`scroller x: ${document.getElementById("scroller").getBoundingClientRect().x}`);
- });
-</script>
diff --git a/Tests/LibWeb/Text/input/visual-context/repaint-only-decoration-changes.html b/Tests/LibWeb/Text/input/visual-context/repaint-only-decoration-changes.html
index 2b9ad7161b8..6da22ceaf2e 100644
--- a/Tests/LibWeb/Text/input/visual-context/repaint-only-decoration-changes.html
+++ b/Tests/LibWeb/Text/input/visual-context/repaint-only-decoration-changes.html
@@ -1,5 +1,6 @@
<!DOCTYPE html>
<script src="../include.js"></script>
+<script src="../work-test.js"></script>
<style>
body { margin: 0; }
#box {
@@ -12,44 +13,56 @@
</style>
<div id="box"></div>
<script>
- test(() => {
- const settle = () => document.elementFromPoint(0, 0);
- const box = document.getElementById("box");
- settle();
- document.body.appendChild(document.createElement("pre"));
- settle();
- const lines = [];
-
- box.style.borderStyle = "dashed";
- box.style.boxShadow = "6px 6px 4px rgba(0, 0, 0, 0.5)";
- box.style.outline = "3px dotted red";
- box.style.outlineOffset = "2px";
- box.style.backgroundBlendMode = "multiply, normal";
- box.style.backgroundClip = "padding-box, border-box";
- settle();
- const dump = internals.dumpDisplayList();
- lines.push(`dashed border painted: ${dump.includes("StrokePath")}`);
- lines.push(`shadow painted: ${dump.includes("PaintOuterBoxShadow")}`);
- lines.push(`blended layers painted: ${dump.includes("DrawIsolatedGroup")}`);
- settle();
-
- const fullBuilds = internals.accumulatedVisualContextTreeBuildCount();
- const incrementalUpdates = internals.accumulatedVisualContextIncrementalUpdateCount();
- box.style.borderStyle = "dotted";
- settle();
- box.style.boxShadow = "2px 2px 2px rgba(0, 0, 0, 0.5)";
- settle();
- box.style.outlineStyle = "dashed";
- box.style.outlineWidth = "5px";
- box.style.outlineOffset = "4px";
- settle();
- box.style.backgroundBlendMode = "normal, multiply";
- box.style.backgroundClip = "border-box, padding-box";
- settle();
- lines.push(`full builds: ${internals.accumulatedVisualContextTreeBuildCount() - fullBuilds}`);
- lines.push(`incremental updates: ${internals.accumulatedVisualContextIncrementalUpdateCount() - incrementalUpdates}`);
-
- for (const line of lines)
- println(line);
+ let dump;
+ visualContextTest({
+ setup: () => {
+ box.style.borderStyle = "dashed";
+ box.style.boxShadow = "6px 6px 4px rgba(0, 0, 0, 0.5)";
+ box.style.outline = "3px dotted red";
+ box.style.outlineOffset = "2px";
+ box.style.backgroundBlendMode = "multiply, normal";
+ box.style.backgroundClip = "padding-box, border-box";
+ dump = internals.dumpDisplayList();
+ },
+ steps: [
+ {
+ name: "decorations painted",
+ check: equal => {
+ equal(dump.includes("StrokePath"), true, "dashed border painted");
+ equal(dump.includes("PaintOuterBoxShadow"), true, "shadow painted");
+ equal(dump.includes("DrawIsolatedGroup"), true, "blended layers painted");
+ },
+ expect: ``,
+ },
+ {
+ name: "border style",
+ mutate: () => { box.style.borderStyle = "dotted"; },
+ expect: `
+ update DIRTY-PATH
+ `,
+ },
+ {
+ name: "box shadow",
+ mutate: () => { box.style.boxShadow = "2px 2px 2px rgba(0, 0, 0, 0.5)"; },
+ expect: ``,
+ },
+ {
+ name: "outline",
+ mutate: () => {
+ box.style.outlineStyle = "dashed";
+ box.style.outlineWidth = "5px";
+ box.style.outlineOffset = "4px";
+ },
+ expect: ``,
+ },
+ {
+ name: "background blending and clip",
+ mutate: () => {
+ box.style.backgroundBlendMode = "normal, multiply";
+ box.style.backgroundClip = "border-box, padding-box";
+ },
+ expect: ``,
+ },
+ ],
});
</script>
diff --git a/Tests/LibWeb/Text/input/visual-context/repeated-toggle-settles-in-place.html b/Tests/LibWeb/Text/input/visual-context/repeated-toggle-settles-in-place.html
index 708df554ec8..ef1a1c6798a 100644
--- a/Tests/LibWeb/Text/input/visual-context/repeated-toggle-settles-in-place.html
+++ b/Tests/LibWeb/Text/input/visual-context/repeated-toggle-settles-in-place.html
@@ -1,31 +1,46 @@
<!DOCTYPE html>
<script src="../include.js"></script>
+<script src="../work-test.js"></script>
<style>
#box { width: 50px; height: 50px; }
#box.lifted { transform: translateY(-2px); }
</style>
<div id="box"></div>
<script>
- test(() => {
- const settle = () => internals.recordDisplayListForTesting();
- const box = document.getElementById("box");
- settle();
- const initialCapacity = internals.visualContextTreeNodeCapacity();
- const fullBuilds = internals.accumulatedVisualContextTreeBuildCount();
- const capacities = [];
- for (let i = 0; i < 6; ++i) {
- box.classList.add("lifted");
- settle();
- capacities.push(internals.visualContextTreeNodeCapacity());
- box.classList.remove("lifted");
- settle();
- }
- const lines = [
- `capacity grew on the first toggle: ${capacities[0] > initialCapacity}`,
- `capacity stable afterwards: ${capacities.every(capacity => capacity === capacities[0])}`,
- `full builds: ${internals.accumulatedVisualContextTreeBuildCount() - fullBuilds}`,
- ];
- for (const line of lines)
- println(line);
+ const steps = [];
+ for (let toggle = 1; toggle <= 6; ++toggle) {
+ steps.push({
+ name: `toggle ${toggle} lifts the box`,
+ mutate: () => {
+ internals.recordDisplayListForTesting();
+ box.classList.add("lifted");
+ },
+ expect: toggle === 1
+ ? `
+ update DIRTY-PATH
+ div#box.lifted transform ALLOCATED
+ recording NEEDED
+ `
+ : `
+ update DIRTY-PATH
+ div#box.lifted transform ALLOCATED (freed slot)
+ epoch NEW
+ recording NEEDED
+ `,
+ });
+ steps.push({
+ name: `toggle ${toggle} drops it`,
+ mutate: () => box.classList.remove("lifted"),
+ expect: `
+ update DIRTY-PATH
+ div#box transform RELEASED
+ epoch NEW
+ recording NEEDED
+ `,
+ });
+ }
+ visualContextTest({
+ setup: () => internals.forceIncompatibleVisualContextTreeRebuild(),
+ steps,
});
</script>
diff --git a/Tests/LibWeb/Text/input/visual-context/resolved-effect-output-clip-updates.html b/Tests/LibWeb/Text/input/visual-context/resolved-effect-output-clip-updates.html
index a75de7334c9..c22228fa236 100644
--- a/Tests/LibWeb/Text/input/visual-context/resolved-effect-output-clip-updates.html
+++ b/Tests/LibWeb/Text/input/visual-context/resolved-effect-output-clip-updates.html
@@ -1,5 +1,6 @@
<!DOCTYPE html>
<script src="../include.js"></script>
+<script src="../work-test.js"></script>
<style>
body { margin: 0; }
#containing-block { transform: translateX(0); width: 200px; height: 100px; }
@@ -9,34 +10,50 @@
</style>
<div id="containing-block"><div id="clipped"><div id="layer"><div id="child"></div></div></div></div>
<script>
- test(() => {
- const layer = document.getElementById("layer");
- const child = document.getElementById("child");
- const settle = () => document.elementFromPoint(0, 0);
- settle();
- const epoch = internals.visualContextTreeStructuralEpoch();
- layer.style.opacity = "0.5";
- settle();
- println(`new clipped effect: epoch unchanged: ${internals.visualContextTreeStructuralEpoch() === epoch}`);
- const check = (label, change) => {
- const epoch = internals.visualContextTreeStructuralEpoch();
- const builds = internals.accumulatedVisualContextTreeBuildCount();
- change();
- settle();
- println(`${label}: epoch changed: ${internals.visualContextTreeStructuralEpoch() !== epoch}`);
- println(`${label}: one effect: ${internals.visualContextNodeIndices(layer).effects.length === 1}`);
- println(`${label}: full builds: ${internals.accumulatedVisualContextTreeBuildCount() - builds}`);
- };
-
- check("clipped opacity update", () => layer.style.opacity = "0.6");
- check("repeated clipped opacity update", () => layer.style.opacity = "0.7");
- check("absolute escape", () => child.style.position = "absolute");
- println(`absolute child escapes: ${document.elementFromPoint(65, 5) === child}`);
- check("escaped opacity update", () => layer.style.opacity = "0.8");
- check("absolute escape removed", () => child.style.position = "static");
- check("fixed escape", () => child.style.position = "fixed");
- println(`fixed child escapes: ${document.elementFromPoint(65, 5) === child}`);
- check("fixed escape removed", () => child.style.position = "static");
- check("clipped opacity update after escapes", () => layer.style.opacity = "0.9");
+ const valueUpdate = `
+ update DIRTY-PATH
+ div#layer effects UPDATED
+ `;
+ const layerBoxRebuilt = `
+ update DIRTY-PATH
+ div#layer effects RELEASED (removed box)
+ div#clipped scroll UPDATED
+ div#layer effects ALLOCATED
+ epoch NEW
+ recording NEEDED
+ `;
+ const step = (name, mutate, expect, check) => ({
+ name,
+ mutate,
+ check: equal => {
+ const ownedNodes = internals.dumpVisualContextNodes(layer).replace(/^\[e\d+\] /gm, "");
+ equal(ownedNodes, `effects=[opacity=${layer.style.opacity}]\n`, "nodes of #layer");
+ check?.(equal);
+ },
+ expect,
+ });
+ visualContextTest({
+ setup: async () => {
+ internals.forceIncompatibleVisualContextTreeRebuild();
+ while (internals.frameSchedulerState() !== "idle")
+ await new Promise(resolve => setTimeout(resolve, 0));
+ },
+ steps: [
+ step("new clipped effect", () => { layer.style.opacity = "0.5"; }, `
+ update DIRTY-PATH
+ div#layer effects ALLOCATED
+ recording NEEDED
+ `),
+ step("clipped opacity update", () => { layer.style.opacity = "0.6"; }, valueUpdate),
+ step("repeated clipped opacity update", () => { layer.style.opacity = "0.7"; }, valueUpdate),
+ step("absolute escape", () => { child.style.position = "absolute"; }, layerBoxRebuilt,
+ equal => equal(document.elementFromPoint(65, 5), child, "absolute child escapes")),
+ step("escaped opacity update", () => { layer.style.opacity = "0.8"; }, valueUpdate),
+ step("absolute escape removed", () => { child.style.position = "static"; }, layerBoxRebuilt),
+ step("fixed escape", () => { child.style.position = "fixed"; }, layerBoxRebuilt,
+ equal => equal(document.elementFromPoint(65, 5), child, "fixed child escapes")),
+ step("fixed escape removed", () => { child.style.position = "static"; }, layerBoxRebuilt),
+ step("clipped opacity update after escapes", () => { layer.style.opacity = "0.9"; }, valueUpdate),
+ ],
});
</script>
diff --git a/Tests/LibWeb/Text/input/visual-context/scrollability-flip-from-transformed-child-during-full-relayout.html b/Tests/LibWeb/Text/input/visual-context/scrollability-flip-from-transformed-child-during-full-relayout.html
index d126ed13f00..0fa85fa9cba 100644
--- a/Tests/LibWeb/Text/input/visual-context/scrollability-flip-from-transformed-child-during-full-relayout.html
+++ b/Tests/LibWeb/Text/input/visual-context/scrollability-flip-from-transformed-child-during-full-relayout.html
@@ -1,5 +1,6 @@
<!DOCTYPE html>
<script src="../include.js"></script>
+<script src="../work-test.js"></script>
<style>
body { margin: 0; }
#scroller { overflow: hidden; width: 100px; height: 100px; }
@@ -9,18 +10,27 @@
<div id="scroller"><div id="slide"></div></div>
<div id="other"></div>
<script>
- test(() => {
- const settle = () => document.elementFromPoint(0, 0);
- const scroller = document.getElementById("scroller");
- const slide = document.getElementById("slide");
- const other = document.getElementById("other");
- settle();
- const fullBuilds = internals.accumulatedVisualContextTreeBuildCount();
- const nodesBefore = internals.visualContextTreeNodeCount();
- slide.style.transform = "translateX(200px)";
- other.style.height = "20px";
- settle();
- println(`nodes added by the flip: ${internals.visualContextTreeNodeCount() - nodesBefore}`);
- println(`full builds: ${internals.accumulatedVisualContextTreeBuildCount() - fullBuilds}`);
+ visualContextTest({
+ setup: async () => {
+ internals.forceIncompatibleVisualContextTreeRebuild();
+ while (internals.frameSchedulerState() !== "idle")
+ await new Promise(resolve => setTimeout(resolve, 0));
+ },
+ steps: [
+ {
+ name: "a transformed child makes its parent scrollable during a full relayout",
+ mutate: () => {
+ slide.style.transform = "translateX(200px)";
+ other.style.height = "20px";
+ },
+ expect: `
+ update DIRTY-PATH
+ div#scroller scroll ALLOCATED
+ div#slide transform REPURPOSED
+ epoch NEW
+ recording NEEDED
+ `,
+ },
+ ],
});
</script>
diff --git a/Tests/LibWeb/Text/input/visual-context/shared-effect-positioned-clip-constraints.html b/Tests/LibWeb/Text/input/visual-context/shared-effect-positioned-clip-constraints.html
index abf6e7e603f..d17a3394ef1 100644
--- a/Tests/LibWeb/Text/input/visual-context/shared-effect-positioned-clip-constraints.html
+++ b/Tests/LibWeb/Text/input/visual-context/shared-effect-positioned-clip-constraints.html
@@ -24,7 +24,7 @@
const check = label => {
// Settle the incremental update before the dump requests a canonical fresh tree.
document.elementFromPoint(0, 0);
- lines.push(`${label}: one owned effect: ${internals.visualContextNodeIndices(layer).effects.length === 1}`);
+ lines.push(`${label}: owned nodes: ${internals.dumpVisualContextNodes(layer).replace(/^\[e\d+\] /gm, "").trimEnd()}`);
const dump = internals.dumpDisplayList();
const effects = dump.split("\n").filter(line => line.includes("effects=[opacity=0.5]"));
lines.push(`${label}: one shared layer: ${effects.length === 1}`);
diff --git a/Tests/LibWeb/Text/input/visual-context/slot-reuse-after-removal-repaints-correctly.html b/Tests/LibWeb/Text/input/visual-context/slot-reuse-after-removal-repaints-correctly.html
index c50564068ee..a38a279b65a 100644
--- a/Tests/LibWeb/Text/input/visual-context/slot-reuse-after-removal-repaints-correctly.html
+++ b/Tests/LibWeb/Text/input/visual-context/slot-reuse-after-removal-repaints-correctly.html
@@ -1,5 +1,6 @@
<!DOCTYPE html>
<script src="../include.js"></script>
+<script src="../work-test.js"></script>
<style>
#parent {
width: 200px;
@@ -16,30 +17,57 @@
</style>
<div id="parent"></div>
<script>
- test(() => {
- const settle = () => internals.recordDisplayListForTesting();
- const parent = document.getElementById("parent");
- settle();
- const first = document.createElement("div");
- first.className = "clipped";
- first.id = "first";
- parent.appendChild(first);
- settle();
- const capacityWithFirst = internals.visualContextTreeNodeCapacity();
- const fullBuilds = internals.accumulatedVisualContextTreeBuildCount();
-
- first.remove();
- settle();
- const second = document.createElement("div");
- second.className = "clipped";
- second.id = "second";
- parent.appendChild(second);
- settle();
-
- println(`capacity reused: ${internals.visualContextTreeNodeCapacity() === capacityWithFirst}`);
- println(`dead nodes: ${internals.visualContextTreeDeadNodeCount()}`);
- println(`hit: ${document.elementFromPoint(30, 30).id}`);
- println(`second x: ${second.getBoundingClientRect().x}`);
- println(`full builds: ${internals.accumulatedVisualContextTreeBuildCount() - fullBuilds}`);
+ const clippedBox = id => {
+ const box = document.createElement("div");
+ box.className = "clipped";
+ box.id = id;
+ document.getElementById("parent").appendChild(box);
+ return box;
+ };
+ let first;
+ let second;
+ visualContextTest({
+ setup: () => internals.forceIncompatibleVisualContextTreeRebuild(),
+ steps: [
+ {
+ name: "a clipped box allocates its nodes",
+ mutate: () => { first = clippedBox("first"); },
+ expect: `
+ update DIRTY-PATH
+ div#first.clipped transform ALLOCATED
+ div#first.clipped clip ALLOCATED
+ recording NEEDED
+ `,
+ },
+ {
+ name: "removing it releases them",
+ mutate: () => first.remove(),
+ expect: `
+ update DIRTY-PATH
+ (removed) transform RELEASED (removed box)
+ (removed) clip RELEASED (removed box)
+ epoch NEW
+ recording NEEDED
+ `,
+ },
+ {
+ name: "after a recording, the next clipped box takes the released slots",
+ mutate: () => {
+ internals.recordDisplayListForTesting();
+ second = clippedBox("second");
+ },
+ check: equal => {
+ equal(document.elementFromPoint(30, 30).id, "second", "hit");
+ equal(second.getBoundingClientRect().x, 18, "second x");
+ },
+ expect: `
+ update DIRTY-PATH
+ div#second.clipped transform ALLOCATED (freed slot)
+ div#second.clipped clip ALLOCATED (freed slot)
+ epoch NEW
+ recording NEEDED
+ `,
+ },
+ ],
});
</script>
diff --git a/Tests/LibWeb/Text/input/visual-context/slot-reuse-bounds-capacity.html b/Tests/LibWeb/Text/input/visual-context/slot-reuse-bounds-capacity.html
deleted file mode 100644
index a6eca0fd6ad..00000000000
--- a/Tests/LibWeb/Text/input/visual-context/slot-reuse-bounds-capacity.html
+++ /dev/null
@@ -1,30 +0,0 @@
-<!DOCTYPE html>
-<script src="../include.js"></script>
-<div id="parent"></div>
-<script>
- test(() => {
- const settle = () => internals.recordDisplayListForTesting();
- const parent = document.getElementById("parent");
- settle();
- const initialCapacity = internals.visualContextTreeNodeCapacity();
- const fullBuilds = internals.accumulatedVisualContextTreeBuildCount();
- const epoch = internals.visualContextTreeStructuralEpoch();
- const iterations = 400;
- for (let i = 0; i < iterations; ++i) {
- const child = document.createElement("div");
- child.style.cssText = "width: 10px; height: 10px; transform: translateX(1px)";
- parent.appendChild(child);
- settle();
- child.remove();
- settle();
- }
- const lines = [
- `capacity bounded: ${internals.visualContextTreeNodeCapacity() < initialCapacity + iterations}`,
- `dead nodes bounded: ${internals.visualContextTreeDeadNodeCount() < iterations}`,
- `full builds: ${internals.accumulatedVisualContextTreeBuildCount() - fullBuilds}`,
- `epoch advanced: ${internals.visualContextTreeStructuralEpoch() > epoch}`,
- ];
- for (const line of lines)
- println(line);
- });
-</script>
diff --git a/Tests/LibWeb/Text/input/visual-context/sticky-after-scroller-resize.html b/Tests/LibWeb/Text/input/visual-context/sticky-after-scroller-resize.html
index f86704b7169..7787dac9cb7 100644
--- a/Tests/LibWeb/Text/input/visual-context/sticky-after-scroller-resize.html
+++ b/Tests/LibWeb/Text/input/visual-context/sticky-after-scroller-resize.html
@@ -1,5 +1,6 @@
<!DOCTYPE html>
<script src="../include.js"></script>
+<script src="../work-test.js"></script>
<style>
body { margin: 0; }
#scroller { overflow: auto; width: 100px; height: 100px; }
@@ -8,23 +9,25 @@
</style>
<div id="scroller"><div id="sticky"></div><div id="filler"></div></div>
<script>
- test(() => {
- const settle = () => document.elementFromPoint(0, 0);
- const scroller = document.getElementById("scroller");
- const sticky = document.getElementById("sticky");
- settle();
- const fullBuilds = internals.accumulatedVisualContextTreeBuildCount();
- const lines = [];
-
- scroller.style.height = "150px";
- scroller.scrollTop = 60;
- lines.push(`scrollTop: ${scroller.scrollTop}`);
- lines.push(`sticky y after resize and scroll: ${sticky.getBoundingClientRect().y}`);
- lines.push(`scroller y: ${scroller.getBoundingClientRect().y}`);
- settle();
- lines.push(`full builds: ${internals.accumulatedVisualContextTreeBuildCount() - fullBuilds}`);
-
- for (const line of lines)
- println(line);
+ visualContextTest({
+ steps: [
+ {
+ name: "the scroller grows and scrolls",
+ mutate: () => {
+ scroller.style.height = "150px";
+ scroller.scrollTop = 60;
+ },
+ check: equal => {
+ equal(scroller.scrollTop, 60, "scrollTop");
+ equal(sticky.getBoundingClientRect().y, 0, "sticky y after resize and scroll");
+ equal(scroller.getBoundingClientRect().y, 0, "scroller y");
+ },
+ expect: `
+ update DIRTY-PATH
+ div#scroller clip UPDATED
+ div#scroller scroll UPDATED
+ `,
+ },
+ ],
});
</script>
diff --git a/Tests/LibWeb/Text/input/visual-context/structural-change-allocates-and-tombstones.html b/Tests/LibWeb/Text/input/visual-context/structural-change-allocates-and-tombstones.html
index bbb8acb9b30..950d1901990 100644
--- a/Tests/LibWeb/Text/input/visual-context/structural-change-allocates-and-tombstones.html
+++ b/Tests/LibWeb/Text/input/visual-context/structural-change-allocates-and-tombstones.html
@@ -1,41 +1,40 @@
<!DOCTYPE html>
<script src="../include.js"></script>
+<script src="../work-test.js"></script>
<div id="sibling" style="width: 100px; height: 100px; transform: translateX(1px)"></div>
<div id="parent" style="width: 100px; height: 100px"></div>
<script>
- test(() => {
- const settle = () => document.elementFromPoint(0, 0);
- const parent = document.getElementById("parent");
- internals.forceIncompatibleVisualContextTreeRebuild();
- settle();
- const liveNodes = internals.visualContextTreeNodeCount();
- const capacity = internals.visualContextTreeNodeCapacity();
- const epoch = internals.visualContextTreeStructuralEpoch();
- const fullBuilds = internals.accumulatedVisualContextTreeBuildCount();
- const incrementalUpdates = internals.accumulatedVisualContextIncrementalUpdateCount();
- const lines = [];
-
- const child = document.createElement("div");
- child.style.cssText = "width: 50px; height: 50px; overflow: hidden; transform: translateX(10px)";
- parent.appendChild(child);
- lines.push(`child rect x: ${child.getBoundingClientRect().x}`);
- settle();
- lines.push(`full builds after insertion: ${internals.accumulatedVisualContextTreeBuildCount() - fullBuilds}`);
- lines.push(`incremental updates after insertion: ${internals.accumulatedVisualContextIncrementalUpdateCount() - incrementalUpdates}`);
- lines.push(`live nodes grew: ${internals.visualContextTreeNodeCount() > liveNodes}`);
- lines.push(`capacity grew: ${internals.visualContextTreeNodeCapacity() > capacity}`);
- lines.push(`epoch unchanged after insertion: ${internals.visualContextTreeStructuralEpoch() === epoch}`);
- const capacityWithChild = internals.visualContextTreeNodeCapacity();
-
- child.remove();
- settle();
- lines.push(`full builds after removal: ${internals.accumulatedVisualContextTreeBuildCount() - fullBuilds}`);
- lines.push(`live nodes back to the initial count: ${internals.visualContextTreeNodeCount() === liveNodes}`);
- lines.push(`capacity kept: ${internals.visualContextTreeNodeCapacity() === capacityWithChild}`);
- lines.push(`dead nodes after removal: ${internals.visualContextTreeDeadNodeCount() > 0}`);
- lines.push(`epoch bumped by the tombstones: ${internals.visualContextTreeStructuralEpoch() > epoch}`);
-
- for (const line of lines)
- println(line);
+ let child;
+ visualContextTest({
+ setup: () => internals.forceIncompatibleVisualContextTreeRebuild(),
+ steps: [
+ {
+ name: "inserting a clipping transformed child allocates its nodes in place",
+ mutate: () => {
+ child = document.createElement("div");
+ child.id = "child";
+ child.style.cssText = "width: 50px; height: 50px; overflow: hidden; transform: translateX(10px)";
+ document.getElementById("parent").appendChild(child);
+ },
+ check: equal => equal(child.getBoundingClientRect().x, 18, "child rect x"),
+ expect: `
+ update DIRTY-PATH
+ div#child transform ALLOCATED
+ div#child clip ALLOCATED
+ recording NEEDED
+ `,
+ },
+ {
+ name: "removing it tombstones its nodes under a new epoch",
+ mutate: () => child.remove(),
+ expect: `
+ update DIRTY-PATH
+ (removed) transform RELEASED (removed box)
+ (removed) clip RELEASED (removed box)
+ epoch NEW
+ recording NEEDED
+ `,
+ },
+ ],
});
</script>
diff --git a/Tests/LibWeb/Text/input/visual-context/transform-style-change-rebuilds-the-box.html b/Tests/LibWeb/Text/input/visual-context/transform-style-change-rebuilds-the-box.html
index ada4a7ce568..ef8dc7ee5ae 100644
--- a/Tests/LibWeb/Text/input/visual-context/transform-style-change-rebuilds-the-box.html
+++ b/Tests/LibWeb/Text/input/visual-context/transform-style-change-rebuilds-the-box.html
@@ -1,29 +1,38 @@
<!DOCTYPE html>
<script src="../include.js"></script>
+<script src="../work-test.js"></script>
<svg width="100" height="100">
<g id="group">
<rect width="50" height="50" fill="green"/>
</g>
</svg>
<script>
- test(() => {
- const settle = () => document.elementFromPoint(0, 0);
- const group = document.getElementById("group");
- settle();
- const fullBuilds = internals.accumulatedVisualContextTreeBuildCount();
- const liveNodes = internals.visualContextTreeNodeCount();
- const lines = [];
-
- group.style.transformStyle = "preserve-3d";
- settle();
- lines.push(`live nodes added by preserve-3d: ${internals.visualContextTreeNodeCount() - liveNodes}`);
-
- group.style.transformStyle = "flat";
- settle();
- lines.push(`live nodes added after flat again: ${internals.visualContextTreeNodeCount() - liveNodes}`);
- lines.push(`full builds: ${internals.accumulatedVisualContextTreeBuildCount() - fullBuilds}`);
-
- for (const line of lines)
- println(line);
+ visualContextTest({
+ setup: async () => {
+ internals.forceIncompatibleVisualContextTreeRebuild();
+ while (internals.frameSchedulerState() !== "idle")
+ await new Promise(resolve => setTimeout(resolve, 0));
+ },
+ steps: [
+ {
+ name: "preserve-3d",
+ mutate: () => { group.style.transformStyle = "preserve-3d"; },
+ expect: `
+ update DIRTY-PATH
+ g#group transform ALLOCATED
+ recording NEEDED
+ `,
+ },
+ {
+ name: "flat again",
+ mutate: () => { group.style.transformStyle = "flat"; },
+ expect: `
+ update DIRTY-PATH
+ g#group transform RELEASED
+ epoch NEW
+ recording NEEDED
+ `,
+ },
+ ],
});
</script>
diff --git a/Tests/LibWeb/Text/input/visual-context/value-only-update-keeps-tree.html b/Tests/LibWeb/Text/input/visual-context/value-only-update-keeps-tree.html
index 4fe7a4a1dc6..e3c8ac5b151 100644
--- a/Tests/LibWeb/Text/input/visual-context/value-only-update-keeps-tree.html
+++ b/Tests/LibWeb/Text/input/visual-context/value-only-update-keeps-tree.html
@@ -1,31 +1,57 @@
<!DOCTYPE html>
<script src="../include.js"></script>
+<script src="../work-test.js"></script>
+<!-- Changing the value of an effect or a transform patches the box's node in place: the tree keeps its structure, and
+ the recorded display list needs no new recording. -->
<div id="box" style="width: 100px; height: 100px; opacity: 0.5; transform: translateX(10px)"></div>
+<div id="relative-box" style="position: relative; width: 100px; height: 100px; opacity: 0.5"></div>
+<div id="backdrop-box" style="width: 100px; height: 100px; backdrop-filter: invert(1)"></div>
<script>
- test(() => {
- const settle = () => document.elementFromPoint(0, 0);
- const box = document.getElementById("box");
- settle();
- const liveNodes = internals.visualContextTreeNodeCount();
- const capacity = internals.visualContextTreeNodeCapacity();
- const epoch = internals.visualContextTreeStructuralEpoch();
- const fullBuilds = internals.accumulatedVisualContextTreeBuildCount();
- const incrementalUpdates = internals.accumulatedVisualContextIncrementalUpdateCount();
-
- box.style.opacity = "0.6";
- box.style.transform = "translateX(20px)";
- const rect = box.getBoundingClientRect();
- settle();
-
- const lines = [
- `rect x: ${rect.x}`,
- `full builds: ${internals.accumulatedVisualContextTreeBuildCount() - fullBuilds}`,
- `incremental updates: ${internals.accumulatedVisualContextIncrementalUpdateCount() - incrementalUpdates}`,
- `live nodes unchanged: ${internals.visualContextTreeNodeCount() === liveNodes}`,
- `capacity unchanged: ${internals.visualContextTreeNodeCapacity() === capacity}`,
- `epoch unchanged: ${internals.visualContextTreeStructuralEpoch() === epoch}`,
- ];
- for (const line of lines)
- println(line);
+ const quietRecording = `
+ damage: rows=0 moved=0 order=0 eligibility=0 all=false
+ @canvas RECORD (empty)
+ @viewport COPY
+ `;
+ displayListTest({
+ steps: [
+ {
+ name: "opacity and transform values change",
+ mutate: () => {
+ box.style.opacity = "0.6";
+ box.style.transform = "translateX(20px)";
+ },
+ check: equal => equal(box.getBoundingClientRect().x, 28, "rect x"),
+ expect: {
+ visualContexts: `
+ update DIRTY-PATH
+ div#box effects UPDATED
+ div#box transform UPDATED
+ `,
+ displayList: quietRecording,
+ },
+ },
+ {
+ name: "opacity value changes on a relative box",
+ mutate: () => { document.getElementById("relative-box").style.opacity = "0.7"; },
+ expect: {
+ visualContexts: `
+ update DIRTY-PATH
+ div#relative-box effects UPDATED
+ `,
+ displayList: quietRecording,
+ },
+ },
+ {
+ name: "one backdrop filter replaces another",
+ mutate: () => { document.getElementById("backdrop-box").style.backdropFilter = "invert(0.5)"; },
+ expect: {
+ visualContexts: `
+ update DIRTY-PATH
+ div#backdrop-box effects UPDATED
+ `,
+ displayList: quietRecording,
+ },
+ },
+ ],
});
</script>
diff --git a/Tests/LibWeb/Text/input/work-test.js b/Tests/LibWeb/Text/input/work-test.js
index 22b61fc8a94..56c772e2ff3 100644
--- a/Tests/LibWeb/Text/input/work-test.js
+++ b/Tests/LibWeb/Text/input/work-test.js
@@ -50,6 +50,12 @@ const workStages = [
take: testInternals => testInternals.takeLayoutTrace(),
settle: testInternals => testInternals.updateLayoutForTesting(),
},
+ {
+ name: "visualContexts",
+ begin: testInternals => testInternals.beginVisualContextTrace(),
+ take: testInternals => testInternals.takeVisualContextTrace(),
+ settle: testInternals => testInternals.updateVisualContextsForTesting(),
+ },
{
name: "displayList",
begin: testInternals => testInternals.beginDisplayListTrace(),
@@ -165,6 +171,10 @@ function styleTest(spec) {
workTest(spec, { stage: "style" });
}
+function visualContextTest(spec) {
+ workTest(spec, { stage: "visualContexts" });
+}
+
function displayListTest(spec) {
workTest(spec, { stage: "displayList", hideOutputAfterSetup: true });
}
@@ -389,3 +399,60 @@ function layoutTreeBuildWork(mutate, { tracked = [] } = {}, testInternals = inte
}),
};
}
+
+// Parses a visual context trace into one event per line:
+// update `scope` the update ran ("DIRTY-PATH", "EVERY-BOX", "FRESH-TREE"), and `asked` where it widened
+// node `box`, `role` ("transform", "clip", "effects", ...), `action` ("ALLOCATED", "REPURPOSED", "UPDATED",
+// "RELEASED"), `freedSlot`, `removedBox`
+// epoch, recording
+function parseVisualContextTrace(text) {
+ const events = [];
+ for (const line of text.replace(/\r/g, "").split("\n")) {
+ if (!line.trim()) continue;
+ let match = line.match(/^update (DIRTY-PATH|EVERY-BOX|FRESH-TREE)(?: -> (DIRTY-PATH|EVERY-BOX|FRESH-TREE))?$/);
+ if (match) {
+ events.push(
+ match[2] ? { event: "update", asked: match[1], scope: match[2] } : { event: "update", scope: match[1] }
+ );
+ continue;
+ }
+ if (line === " epoch NEW") {
+ events.push({ event: "epoch" });
+ continue;
+ }
+ if (line === " recording NEEDED") {
+ events.push({ event: "recording" });
+ continue;
+ }
+ match = line.match(
+ /^ (\S+) (.+?) (ALLOCATED|REPURPOSED|UPDATED|RELEASED)( \(freed slot\))?( \(removed box\))?$/
+ );
+ if (!match) throw new Error(`unrecognized visual context trace line: ${JSON.stringify(line)}`);
+ events.push({
+ event: "node",
+ box: match[1],
+ role: match[2],
+ action: match[3],
+ freedSlot: !!match[4],
+ removedBox: !!match[5],
+ });
+ }
+ return events;
+}
+
+// Brings the visual context tree up to date, then runs `mutate` and does so again, tracing only the updates the
+// mutation causes. Answers the trace and its events, with queries over them.
+function visualContextWork(mutate, testInternals = internals, options = {}) {
+ const text = traceWork("visualContexts", mutate, testInternals, options);
+ const events = parseVisualContextTrace(text);
+ const matching = filter => events.filter(event => workEventMatches(event, filter));
+ return {
+ text,
+ events,
+ count: filter => matching(filter).length,
+ // The scopes of the updates, in order.
+ updates: () => matching({ event: "update" }).map(event => event.scope),
+ // The boxes of the matching node events, each once, in the order they first appear.
+ boxes: filter => [...new Set(matching({ event: "node", ...filter }).map(event => event.box))],
+ };
+}