Truly independent web browser
LibWeb: Answer caret queries from a list walked from rows on demand
Aliaksandr Kalenik24ab85246ea7
diff --git a/Libraries/LibWeb/DOM/Document.cpp b/Libraries/LibWeb/DOM/Document.cppindex 7926414db51..ea7f752b22f 100644--- a/Libraries/LibWeb/DOM/Document.cpp+++ b/Libraries/LibWeb/DOM/Document.cpp@@ -12164,31 +12164,14 @@ void Document::set_caret_hit_test_debug_rect(Optional<CSSPixelRect> rect)Optional<Painting::HitTestQuery> Document::prepare_hit_test_query(Layout::BegunRead const& read, Optional<i64> visual_animation_sample_time_nanoseconds){+ Painting::publish_image_map_area_facts_if_needed(read, *this);if (!has_committed_viewport_box())return {};- // A hit test only reads a recording of the document as it is now: it presents nothing, so the compositor never- // shows a frame a hit test made in place of one the render clock sampled later. The next frame records again.- // It copies from the published recording only where it records with the paint config the frames record with.- auto rebuild_hit_test_display_list = [&] {- set_needs_to_record_display_list();- HTML::PaintConfig paint_config { .paint_overlay = true };- if (auto navigable = this->navigable())- paint_config = navigable->stamp_paint_config(paint_config);- (void)record_display_list(read, paint_config, Painting::PaintCommandCacheMode::ReadOnly);- };-- // The recording in flight replaces the hit-test list once it lands, so a list that is not current waits for it- // first.- if (!hit_test_display_list_is_current(read)) {- if (auto navigable = this->navigable())- navigable->take_recording_in_flight_in(HTML::LocalNavigable::TakeIn::Wait);- }- if (!hit_test_display_list_is_current(read)) {- rebuild_hit_test_display_list();- if (!hit_test_display_list_is_current(read))- return {};- }+ // A hit test reads the document's rows as they are now, so it waits for no recording and makes none.+ Layout::RustFFI::render_state_prepare_paint_properties_before_hit_test(layout_node_arena().host(), &read);+ if (!m_hit_test_display_list)+ m_hit_test_display_list = Painting::HitTestDisplayList::create_before_any_recording(layout_node_arena(), *m_chrome_widget_registry);return Painting::HitTestQuery {*m_hit_test_display_list,diff --git a/Libraries/LibWeb/Painting/HitTestDisplayList.cpp b/Libraries/LibWeb/Painting/HitTestDisplayList.cppindex 55cae4a043e..fbef40f8a70 100644--- a/Libraries/LibWeb/Painting/HitTestDisplayList.cpp+++ b/Libraries/LibWeb/Painting/HitTestDisplayList.cpp@@ -23,6 +23,11 @@ NonnullRefPtr<HitTestDisplayList> HitTestDisplayList::create_from_rust_recordingreturn adopt_ref(*new HitTestDisplayList(visual_context_tree_structural_epoch, arena, chrome_widget_registry, Layout::RustFFI::layout_hit_test_list_generation(arena.host())));}+NonnullRefPtr<HitTestDisplayList> HitTestDisplayList::create_before_any_recording(Layout::NodeArena& arena, ChromeWidgetRegistry& chrome_widget_registry)+{+ return adopt_ref(*new HitTestDisplayList(0, arena, chrome_widget_registry, 0));+}+HitTestDisplayList::HitTestDisplayList(u64 visual_context_tree_structural_epoch, Layout::NodeArena& arena, ChromeWidgetRegistry& chrome_widget_registry, u64 rust_generation): m_visual_context_tree_structural_epoch(visual_context_tree_structural_epoch), m_arena(arena)diff --git a/Libraries/LibWeb/Painting/HitTestDisplayList.h b/Libraries/LibWeb/Painting/HitTestDisplayList.hindex 9b4588d8423..be210ce4840 100644--- a/Libraries/LibWeb/Painting/HitTestDisplayList.h+++ b/Libraries/LibWeb/Painting/HitTestDisplayList.h@@ -55,6 +55,8 @@ private:class WEB_API HitTestDisplayList : public RefCounted<HitTestDisplayList> {public:static NonnullRefPtr<HitTestDisplayList> create_from_rust_recording(Layout::BegunRead const& read, u64 visual_context_tree_structural_epoch, Layout::NodeArena&, ChromeWidgetRegistry&);+ // What answers hit tests of a document no recording of which has landed: it is current for no frame.+ static NonnullRefPtr<HitTestDisplayList> create_before_any_recording(Layout::NodeArena&, ChromeWidgetRegistry&);u64 visual_context_tree_structural_epoch() const { return m_visual_context_tree_structural_epoch; }[[nodiscard]] bool is_current() const;diff --git a/Libraries/LibWeb/Rust/src/layout/commit.rs b/Libraries/LibWeb/Rust/src/layout/commit.rsindex 5d1bca23f28..86e135cab9f 100644--- a/Libraries/LibWeb/Rust/src/layout/commit.rs+++ b/Libraries/LibWeb/Rust/src/layout/commit.rs@@ -1207,6 +1207,7 @@ pub(crate) fn commit_replacing(let number = arena.layout_commit_count() as u32;let is_full_commit = arena.data(root).kind.get() == NodeKind::Viewport;arena.clear_absolute_rect_memo();+ arena.note_hit_test_items_changed();Commit {arena,messages: Vec::new(),diff --git a/Libraries/LibWeb/Rust/src/layout/row_reads.rs b/Libraries/LibWeb/Rust/src/layout/row_reads.rsindex 657483588bc..87f6609cd95 100644--- a/Libraries/LibWeb/Rust/src/layout/row_reads.rs+++ b/Libraries/LibWeb/Rust/src/layout/row_reads.rs@@ -39,7 +39,7 @@ pub(crate) struct RowSnapshot {pub(crate) viewport: NodeSlotId,/// How far the arena's rows had been written when they were published.version: RowsVersion,- /// Whether every row's scrollable overflow was measured when the rows were published.+ /// Whether every row's scrollable overflow and ink overflow were measured when the rows were published.overflow_is_settled: bool,/// The text rows that waited for their text to be rendered again when the rows were published, by slot index:/// every other text row carries the text it renders.@@ -299,7 +299,7 @@ impl LayoutNodeArena {visual_context_tree: self.paint_state().visual_context.tree.clone(),viewport: self.layout_root(),version: self.rows_version(),- overflow_is_settled: self.scrollable_overflow_is_settled(),+ overflow_is_settled: self.scrollable_overflow_is_settled() && self.ink_overflow_is_settled(),text_awaiting_render: self.text_rows_awaiting_sync(),}}diff --git a/Libraries/LibWeb/Rust/src/painting/ffi/main_thread_entries.rs b/Libraries/LibWeb/Rust/src/painting/ffi/main_thread_entries.rsindex f59b1c45090..8db89708e46 100644--- a/Libraries/LibWeb/Rust/src/painting/ffi/main_thread_entries.rs+++ b/Libraries/LibWeb/Rust/src/painting/ffi/main_thread_entries.rs@@ -570,6 +570,20 @@ pub unsafe extern "C" fn render_state_prepare_paint_properties_for_testing(unsafe { prepare_paint_properties(host, read) };}+/// Brings the paint and hit testing properties of `host`'s document up to date before the document hit tests.+///+/// # 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_before_hit_test(+ 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.///@@ -972,9 +986,10 @@ fn landed_recording_stands(host: &crate::render_state::DocumentHost, version: cr})}-/// Answers `query` from the hit-test list of the last recording `host`'s document published, built up by `build`, and-/// the rows as of every write the host made, with every row's overflow measured, in `read`. Answers `default` where no recording-/// was published. Every entry that hits tests is called with a live document host, on its document's thread.+/// Answers `query` from every hit-test item of `host`'s document, built up by `build`, and the rows as of every write+/// the host made, with every row's overflow measured, in `read`. The items are walked from those rows where the ones+/// the host kept no longer say what the rows do. Answers `default` where the document has no visual context tree.+/// Every entry that hits tests is called with a live document host, on its document's thread.fn with_hit_test_list<R>(host: &crate::render_state::DocumentHost,read: &crate::render_state::BegunRead,@@ -987,12 +1002,14 @@ fn with_hit_test_list<R>() -> R,) -> R {let rows = host.fresh_measured_rows(read);- let absolute_rects = std::cell::RefCell::default();- let source = crate::painting::paint_read::PaintSource::over_rows(&rows.paintable, &absolute_rects);- let mut recording = host.recording();- let Some(list) = recording.hit_test_list().as_mut() else {+ let Some(tree) = rows.visual_context_tree.as_deref() else {return default;};+ let absolute_rects = std::cell::RefCell::default();+ let source = crate::painting::paint_read::PaintSource::over_rows(&rows.paintable, &absolute_rects);+ let mut kept = host.whole_document_hit_test_list();+ let list =+ crate::painting::hit_test::walk::WholeDocumentHitTestList::current(&mut kept, &source, tree, rows.viewport);build(list, &source);query(list, &rows, &source)}diff --git a/Libraries/LibWeb/Rust/src/painting/hit_test/walk.rs b/Libraries/LibWeb/Rust/src/painting/hit_test/walk.rsindex 8f43b30dc17..ac509f8cf61 100644--- a/Libraries/LibWeb/Rust/src/painting/hit_test/walk.rs+++ b/Libraries/LibWeb/Rust/src/painting/hit_test/walk.rs@@ -74,6 +74,120 @@ fn own_accumulated_2d_scale()}+struct WholeDocumentWalk<'a, R: PaintRead> {+ rows: &'a R,+ spaces: WorldTransforms,+ paint_overlay: bool,+ items: Vec<HitTestItem>,+}++impl<R: PaintRead> HitTestItemSink for WholeDocumentWalk<'_, R> {+ fn hit_test_facts(&mut self, paintable: NodeSlotId) -> HitTestFacts {+ hit_test_facts(self.rows, paintable)+ }++ fn own_accumulated_2d_scale(&self, paintable: NodeSlotId) -> libgfx_rust::FloatSize {+ own_accumulated_2d_scale(self.rows, &self.spaces, paintable)+ }++ fn append(&mut self, item: HitTestItem) {+ self.items.push(item);+ }+}++impl<R: PaintRead> WholeDocumentWalk<'_, R> {+ fn scope(&mut self, scope: PaintScope) {+ let plan = PaintScopePlan::build(self.rows, scope, self.paint_overlay);+ if plan.establishes_stacking_context && !stacking_context_paints(self.rows, scope.owner) {+ return;+ }+ for item in plan.items {+ match item {+ PaintOrderItem::Producer(producer) => {+ for kind in producer_kinds(producer) {+ self.producer(scope.owner, kind);+ }+ }+ PaintOrderItem::Scope(child) => self.scope(child),+ }+ }+ }++ fn producer(&mut self, owner: NodeSlotId, kind: ProducerKind) {+ let rows = self.rows;+ if let Some(phase) = hit_phase(kind) {+ hit_test_items_of_phase(rows, self, owner, phase);+ } else if kind == ProducerKind::Svg {+ self.svg_box(owner);+ }+ }++ fn svg_box(&mut self, svg_box: NodeSlotId) {+ let rows = self.rows;+ if svg_box_is_hidden_by_an_empty_mask_or_clip(rows, svg_box) {+ return;+ }+ hit_test_items_of_phase(rows, self, svg_box, PaintPhase::Foreground);+ for child in svg_children_painted_with_their_parent(rows, svg_box) {+ self.svg_box(child);+ }+ }+}++/// Every hit-test item of a document as of one state of its rows.+pub(crate) struct WholeDocumentHitTestList {+ hit_test_items_stamp: u64,+ visual_context_tree_structural_epoch: u64,+ pub list: HitTestList,+}++impl WholeDocumentHitTestList {+ /// The list in `kept` where it still says what the rows do, and otherwise a list walked from the rows, which+ /// `kept` holds from then on. The items name nodes of `tree`, so a tree built anew makes a new list too.+ pub(crate) fn current<'kept>(+ kept: &'kept mut Option<Self>,+ rows: &impl PaintRead,+ tree: &VisualContextTree,+ viewport: NodeSlotId,+ ) -> &'kept mut HitTestList {+ let hit_test_items_stamp = rows.hit_test_items_stamp();+ let is_current = kept.as_ref().is_some_and(|kept| {+ kept.hit_test_items_stamp == hit_test_items_stamp+ && kept.visual_context_tree_structural_epoch == tree.structural_epoch+ });+ if !is_current {+ *kept = Some(Self {+ hit_test_items_stamp,+ visual_context_tree_structural_epoch: tree.structural_epoch,+ list: HitTestList {+ items: Arc::new(hit_test_items_in_paint_order(rows, tree, viewport, true)),+ ..HitTestList::default()+ },+ });+ }+ &mut kept.as_mut().expect("a list was kept above").list+ }+}++/// Every hit-test item of the document in paint order, with the overlays of stacking contexts where `paint_overlay`.+fn hit_test_items_in_paint_order(+ rows: &impl PaintRead,+ tree: &VisualContextTree,+ viewport: NodeSlotId,+ paint_overlay: bool,+) -> Vec<HitTestItem> {+ let mut walk = WholeDocumentWalk {+ rows,+ spaces: WorldTransforms::new(tree, &[], None),+ paint_overlay,+ items: Vec::new(),+ };+ if rows.paintable_row_is_populated(viewport) {+ walk.scope(PaintScope::stacking_context(viewport));+ }+ walk.items+}+/// An item under a point, with the point in the space of the item.#[derive(Clone, Debug, PartialEq)]pub(crate) struct PointHit {diff --git a/Libraries/LibWeb/Rust/src/painting/ink_overflow.rs b/Libraries/LibWeb/Rust/src/painting/ink_overflow.rsindex b69595f1422..59b55a9c55e 100644--- a/Libraries/LibWeb/Rust/src/painting/ink_overflow.rs+++ b/Libraries/LibWeb/Rust/src/painting/ink_overflow.rs@@ -580,7 +580,14 @@ impl crate::layout::LayoutNodeArena {}}+ pub(crate) fn ink_overflow_is_settled(&self) -> bool {+ self.paintable_rows.ink_overflow_requests.is_empty()+ }+pub(crate) fn settle_ink_overflow(&mut self) {+ // A relayout leaves the boxes of a line without their share of its fragments until it is assigned again,+ // and what a box paints follows its share.+ crate::painting::fragment_ownership::assign_fragment_ownership_for_pending_line_roots(self);let verification = crate::painting::record::ink_bounds::verification();if self.paintable_rows.ink_overflow_requests.is_empty() && !verification.enabled {return;diff --git a/Libraries/LibWeb/Rust/src/painting/paint_read.rs b/Libraries/LibWeb/Rust/src/painting/paint_read.rsindex 5752bb1d267..725c3af28ab 100644--- a/Libraries/LibWeb/Rust/src/painting/paint_read.rs+++ b/Libraries/LibWeb/Rust/src/painting/paint_read.rs@@ -121,6 +121,7 @@ fn link(link: NodeSlotId) -> Option<NodeSlotId> {pub(crate) trait GeometryRead: Sized {fn ink_overflow_stamp(&self) -> u64;+ fn hit_test_items_stamp(&self) -> u64;fn stored_ink_overflow(&self, id: NodeSlotId) -> crate::painting::ink_overflow::InkOverflow;fn absolute_ink_overflow_rect(&self, id: NodeSlotId) -> Option<CssPixelRect> {@@ -431,6 +432,10 @@ impl<Live: AsRef<LayoutNodeArena> + LiveAbsoluteRects> GeometryRead for Live {self.as_ref().paintable_rows.ink_overflow_stamp}+ fn hit_test_items_stamp(&self) -> u64 {+ self.as_ref().paintable_rows.hit_test_items_stamp+ }+fn stored_ink_overflow(&self, id: NodeSlotId) -> crate::painting::ink_overflow::InkOverflow {self.as_ref().paintable_rows@@ -603,6 +608,10 @@ impl GeometryRead for PaintSource<'_> {self.rows().ink_overflow_stamp}+ fn hit_test_items_stamp(&self) -> u64 {+ self.rows().hit_test_items_stamp+ }+fn stored_ink_overflow(&self, id: NodeSlotId) -> crate::painting::ink_overflow::InkOverflow {self.rows().ink_overflowdiff --git a/Libraries/LibWeb/Rust/src/painting/paintable_rows.rs b/Libraries/LibWeb/Rust/src/painting/paintable_rows.rsindex caf5f8dd196..7a14c5fb511 100644--- a/Libraries/LibWeb/Rust/src/painting/paintable_rows.rs+++ b/Libraries/LibWeb/Rust/src/painting/paintable_rows.rs@@ -245,6 +245,9 @@ pub(crate) struct PaintableRowStore {rows: CowColumn<PaintableData, PAINTABLE_SLOTS_PER_CHUNK>,pub(crate) ink_overflow: CowColumn<crate::painting::ink_overflow::InkOverflow, PAINTABLE_SLOTS_PER_CHUNK>,pub(crate) ink_overflow_stamp: u64,+ /// Names what the rows say can be hit, and where: it moves with every write that can change a hit-test item.+ /// Scrolling and selecting change none.+ pub(crate) hit_test_items_stamp: u64,pub(crate) ink_overflow_audit_sequence: u64,pub(crate) ink_overflow_dirty: crate::fork_vec::ForkVec<bool>,pub(crate) ink_overflow_requests: Vec<NodeSlotId>,@@ -666,6 +669,7 @@ impl LayoutNodeArena {geometry_epoch: store.absolute_rect_memo_epoch,ink_overflow: store.ink_overflow.publish(),ink_overflow_stamp: store.ink_overflow_stamp,+ hit_test_items_stamp: store.hit_test_items_stamp,nodes,paint_facts,rows: store.rows.publish(),@@ -768,12 +772,14 @@ impl LayoutNodeArena {*dirty = false;}self.request_ink_overflow_recalculation(layout_node);+ self.note_hit_test_items_changed();self.notify_committed_box_changed(layout_node);}fn reset_paintable_row(&mut self, row_is_still_linked: bool, reset: PaintableRowReset) {let id = reset.slot;self.forget_ink_overflow_of_row_being_reset(id);+ self.note_hit_test_items_changed();if row_is_still_linked {// A cleared row is still linked, so the ancestor whose plans listed it is known now.self.push_enclosing_paint_order_damage(id);diff --git a/Libraries/LibWeb/Rust/src/painting/published_frame.rs b/Libraries/LibWeb/Rust/src/painting/published_frame.rsindex bc10bff82a6..41fad2429b8 100644--- a/Libraries/LibWeb/Rust/src/painting/published_frame.rs+++ b/Libraries/LibWeb/Rust/src/painting/published_frame.rs@@ -54,6 +54,7 @@ pub(crate) struct PublishedRows {pub(super) geometry_epoch: u64,pub(super) ink_overflow: ColumnSnapshot<crate::painting::ink_overflow::InkOverflow, PAINTABLE_SLOTS_PER_CHUNK>,pub(crate) ink_overflow_stamp: u64,+ pub(crate) hit_test_items_stamp: u64,pub(super) nodes: ColumnSnapshot<PaintNode, PUBLISHED_ROWS_PER_CHUNK>,pub(super) paint_facts: PublishedPaintFacts,pub(super) rows: ColumnSnapshot<PaintableData, PAINTABLE_SLOTS_PER_CHUNK>,diff --git a/Libraries/LibWeb/Rust/src/painting/record/damage.rs b/Libraries/LibWeb/Rust/src/painting/record/damage.rsindex ed6d6963655..a894efbdfe5 100644--- a/Libraries/LibWeb/Rust/src/painting/record/damage.rs+++ b/Libraries/LibWeb/Rust/src/painting/record/damage.rs@@ -252,6 +252,15 @@ impl LayoutNodeArena {if damage.is_empty() || !self.paintable_row_is_populated(row) {return;}+ if damage.intersects(+ PaintDamage::ALL_HIT+ | PaintDamage::MOVED+ | PaintDamage::ORDER+ | PaintDamage::CONTEXT_ORDER+ | PaintDamage::ELIGIBILITY,+ ) {+ self.note_hit_test_items_changed();+ }if damage.intersects(PaintDamage::ALL_DRAW | PaintDamage::MOVED | PaintDamage::ORDER) {self.request_ink_overflow_recalculation(row);self.request_inline_ink_overflow_recalculation(row);@@ -369,7 +378,12 @@ impl LayoutNodeArena {None}+ pub(crate) fn note_hit_test_items_changed(&mut self) {+ self.paintable_rows.hit_test_items_stamp = crate::cow_column::new_edit_token();+ }+pub(crate) fn push_all_paint_damage(&mut self) {+ self.note_hit_test_items_changed();let set = &mut self.paintable_rows.damage;set.push_revision += 1;set.all = set.stamp_for_push();diff --git a/Libraries/LibWeb/Rust/src/painting/scrollable_overflow.rs b/Libraries/LibWeb/Rust/src/painting/scrollable_overflow.rsindex ee04aacc4c9..6adbc3de3c6 100644--- a/Libraries/LibWeb/Rust/src/painting/scrollable_overflow.rs+++ b/Libraries/LibWeb/Rust/src/painting/scrollable_overflow.rs@@ -284,6 +284,8 @@ impl LayoutNodeArena {}self.request_ink_overflow_recalculation(slot);self.request_inline_ink_overflow_recalculation(slot);+ // A style decides whether a box can be hit, its corners, its writing mode and its stroke.+ self.note_hit_test_items_changed();let Some(style) = self.node_style_if_live(slot) else {return;};diff --git a/Libraries/LibWeb/Rust/src/render_state/document_host.rs b/Libraries/LibWeb/Rust/src/render_state/document_host.rsindex fa2f134f9e4..d9d97b6fc5e 100644--- a/Libraries/LibWeb/Rust/src/render_state/document_host.rs+++ b/Libraries/LibWeb/Rust/src/render_state/document_host.rs@@ -68,6 +68,9 @@ pub struct DocumentHost {recording: RefCell<RecordingSlot>,/// The rows the render state published last, which the host reads between its jobs.rows: RefCell<Option<Rc<RowSnapshot>>>,+ /// Every hit-test item of the document, which caret queries walk the rows for when they first need them and+ /// read until the rows say something else can be hit.+ whole_document_hit_test_list: RefCell<Option<crate::painting::hit_test::walk::WholeDocumentHitTestList>>,/// The reactions of the style update the host took last, which it reads until it ends the transaction.style_update: RefCell<Option<StyleJobAnswer>>,/// The first sample of the transitions a step the host read from the style update starts, by element, which@@ -207,6 +210,7 @@ impl DocumentHost {host_tables: HostTables::default(),recording: RefCell::default(),rows: RefCell::default(),+ whole_document_hit_test_list: RefCell::default(),style_update: RefCell::default(),fresh_transition_sample: Cell::default(),absolute_rects: RefCell::default(),@@ -1539,6 +1543,12 @@ impl DocumentHost {self.compositor_animations.take()}+ pub(crate) fn whole_document_hit_test_list(+ &self,+ ) -> RefMut<'_, Option<crate::painting::hit_test::walk::WholeDocumentHitTestList>> {+ self.whole_document_hit_test_list.borrow_mut()+ }+/// What the document keeps of its recordings.pub(crate) fn recording(&self) -> RefMut<'_, RecordingSlot> {self.recording.borrow_mut()diff --git a/Tests/LibWeb/Text/expected/display_list/hit-test-recording-copies-from-published-recording.txt b/Tests/LibWeb/Text/expected/display_list/hit-test-recording-copies-from-published-recording.txtdeleted file mode 100644index 1c7810df22d..00000000000--- a/Tests/LibWeb/Text/expected/display_list/hit-test-recording-copies-from-published-recording.txt+++ /dev/null@@ -1,2 +0,0 @@-PASS: paint with overlays (work)-PASS: hit test after a move, then the next frame (work + checks)diff --git a/Tests/LibWeb/Text/expected/display_list/hit-test-recording-then-next-frame-records-again.txt b/Tests/LibWeb/Text/expected/display_list/hit-test-recording-then-next-frame-records-again.txtdeleted file mode 100644index 413d6bf157c..00000000000--- a/Tests/LibWeb/Text/expected/display_list/hit-test-recording-then-next-frame-records-again.txt+++ /dev/null@@ -1,4 +0,0 @@-left=10: hit target=box, hit-test recordings=1-left=10: subsequent frame recordings=1-left=20: hit target=box, hit-test recordings=1-left=20: subsequent frame recordings=1diff --git a/Tests/LibWeb/Text/expected/display_list/hit-test-recording-with-force-dark-copies-from-published-recording.txt b/Tests/LibWeb/Text/expected/display_list/hit-test-recording-with-force-dark-copies-from-published-recording.txtdeleted file mode 100644index 44f6b2e5396..00000000000--- a/Tests/LibWeb/Text/expected/display_list/hit-test-recording-with-force-dark-copies-from-published-recording.txt+++ /dev/null@@ -1,2 +0,0 @@-hit target: box-hit-test recording: @viewport ASSEMBLEdiff --git a/Tests/LibWeb/Text/expected/display_list/hit-test-records-nothing.txt b/Tests/LibWeb/Text/expected/display_list/hit-test-records-nothing.txtnew file mode 100644index 00000000000..8fd34e62ded--- /dev/null+++ b/Tests/LibWeb/Text/expected/display_list/hit-test-records-nothing.txt@@ -0,0 +1,6 @@+left=10: hit target=box, caret in box, recordings=0+left=10: subsequent frame recordings=1+left=200: hit target=html, caret in BODY, recordings=0+left=200: subsequent frame recordings=1+left=20: hit target=box, caret in box, recordings=0+left=20: subsequent frame recordings=1diff --git a/Tests/LibWeb/Text/input/display_list/hit-test-recording-copies-from-published-recording.html b/Tests/LibWeb/Text/input/display_list/hit-test-recording-copies-from-published-recording.htmldeleted file mode 100644index 3ddbe913a22..00000000000--- a/Tests/LibWeb/Text/input/display_list/hit-test-recording-copies-from-published-recording.html+++ /dev/null@@ -1,203 +0,0 @@-<!doctype html>-<html id="html">-<script src="../include.js"></script>-<script src="../work-test.js"></script>-<style>- body { margin: 0; font: 16px/20px monospace; }- #static { width: 200px; height: 40px; background: silver; }- #box { position: absolute; left: 10px; top: 60px; width: 50px; height: 50px; background: green; }-</style>-<body id="body">-<div id="static">static text</div>-<div id="box"></div>-<script>-// A hit test that finds its hit-test list stale records a frame that publishes nothing. It copies the clean output-// of the published recording and records only what was damaged since, and leaves that damage for the frame that-// publishes next.-let hitTarget = null;-displayListTest({- setup: removeBodyWhitespace,- steps: [- {- name: "paint with overlays",- paintOverlay: true,- expect: `- damage: rows=0 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>#html/descendants(background-and-borders) RECORD- @viewport/foreground/hit-test RECORD (empty)- @viewport/foreground RECORD (empty)- BlockContainer<HTML>#html/descendants(foreground) RECORD- BlockContainer<HTML>#html RECORD- BlockContainer<HTML>#html/preamble RECORD (empty)- BlockContainer<HTML>#html/background/hit-test RECORD- BlockContainer<HTML>#html/scroll-metadata RECORD (empty)- BlockContainer<HTML>#html/background RECORD (empty)- BlockContainer<HTML>#html/border SKIP- BlockContainer<BODY>#body/descendants(background-and-borders) RECORD- BlockContainer<BODY>#body/background/hit-test RECORD- BlockContainer<BODY>#body/scroll-metadata RECORD (empty)- BlockContainer<BODY>#body/background SKIP- BlockContainer<BODY>#body/border SKIP- BlockContainer<DIV>#static/descendants(background-and-borders) RECORD- BlockContainer<DIV>#static/background/hit-test RECORD- BlockContainer<DIV>#static/scroll-metadata RECORD (empty)- BlockContainer<DIV>#static/background RECORD- BlockContainer<DIV>#static/border SKIP- BlockContainer<DIV>#box/descendants(background-and-borders) RECORD- BlockContainer<HTML>#html/foreground/hit-test RECORD (empty)- BlockContainer<HTML>#html/foreground RECORD (empty)- BlockContainer<BODY>#body/descendants(foreground) RECORD- BlockContainer<BODY>#body/foreground/hit-test RECORD (empty)- BlockContainer<BODY>#body/foreground RECORD (empty)- BlockContainer<DIV>#static/descendants(foreground) RECORD- BlockContainer<DIV>#static/foreground/hit-test RECORD- BlockContainer<DIV>#static/foreground RECORD- BlockContainer<DIV>#static/outline SKIP- BlockContainer<DIV>#static/overlay/hit-test RECORD (empty)- BlockContainer<DIV>#static/overlay SKIP- BlockContainer<DIV>#box/descendants(foreground) RECORD- BlockContainer<BODY>#body/outline SKIP- BlockContainer<BODY>#body/overlay/hit-test RECORD (empty)- BlockContainer<BODY>#body/overlay SKIP- BlockContainer<DIV>#box RECORD- 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>#html/outline SKIP- BlockContainer<HTML>#html/overlay/hit-test RECORD (empty)- BlockContainer<HTML>#html/overlay SKIP- @viewport/outline SKIP- @viewport/overlay/hit-test RECORD (empty)- @viewport/overlay RECORD (empty)- `- },- {- name: "hit test after a move, then the next frame",- paintOverlay: true,- mutate: () => {- box.style.left = "100px";- hitTarget = document.elementFromPoint(120, 80);- },- check: equal => { equal(hitTarget?.id, "box", "hit target"); },- expect: `- damage: rows=4 moved=1 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>#html/descendants(background-and-borders) ASSEMBLE- @viewport/foreground/hit-test COPY- @viewport/foreground COPY- BlockContainer<HTML>#html/descendants(foreground) ASSEMBLE- BlockContainer<HTML>#html ASSEMBLE- BlockContainer<HTML>#html/preamble COPY- BlockContainer<HTML>#html/background/hit-test COPY- BlockContainer<HTML>#html/scroll-metadata COPY- BlockContainer<HTML>#html/background COPY- BlockContainer<HTML>#html/border COPY- BlockContainer<BODY>#body/descendants(background-and-borders) ASSEMBLE- BlockContainer<BODY>#body/background/hit-test COPY- BlockContainer<BODY>#body/scroll-metadata COPY- BlockContainer<BODY>#body/background COPY- BlockContainer<BODY>#body/border COPY- BlockContainer<DIV>#static/descendants(background-and-borders) COPY- BlockContainer<DIV>#box/descendants(background-and-borders) ASSEMBLE- BlockContainer<HTML>#html/foreground/hit-test COPY- BlockContainer<HTML>#html/foreground COPY- BlockContainer<BODY>#body/descendants(foreground) ASSEMBLE- BlockContainer<BODY>#body/foreground/hit-test COPY- BlockContainer<BODY>#body/foreground COPY- BlockContainer<DIV>#static/descendants(foreground) COPY- BlockContainer<DIV>#box/descendants(foreground) ASSEMBLE- BlockContainer<BODY>#body/outline COPY- BlockContainer<BODY>#body/overlay/hit-test COPY- BlockContainer<BODY>#body/overlay COPY- BlockContainer<DIV>#box ASSEMBLE- 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>#html/outline COPY- BlockContainer<HTML>#html/overlay/hit-test COPY- BlockContainer<HTML>#html/overlay COPY- @viewport/outline COPY- @viewport/overlay/hit-test COPY- @viewport/overlay COPY- recording (overlay=true)- damage: rows=4 moved=1 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>#html/descendants(background-and-borders) ASSEMBLE- @viewport/foreground/hit-test COPY- @viewport/foreground COPY- BlockContainer<HTML>#html/descendants(foreground) ASSEMBLE- BlockContainer<HTML>#html ASSEMBLE- BlockContainer<HTML>#html/preamble COPY- BlockContainer<HTML>#html/background/hit-test COPY- BlockContainer<HTML>#html/scroll-metadata COPY- BlockContainer<HTML>#html/background COPY- BlockContainer<HTML>#html/border COPY- BlockContainer<BODY>#body/descendants(background-and-borders) ASSEMBLE- BlockContainer<BODY>#body/background/hit-test COPY- BlockContainer<BODY>#body/scroll-metadata COPY- BlockContainer<BODY>#body/background COPY- BlockContainer<BODY>#body/border COPY- BlockContainer<DIV>#static/descendants(background-and-borders) COPY- BlockContainer<DIV>#box/descendants(background-and-borders) ASSEMBLE- BlockContainer<HTML>#html/foreground/hit-test COPY- BlockContainer<HTML>#html/foreground COPY- BlockContainer<BODY>#body/descendants(foreground) ASSEMBLE- BlockContainer<BODY>#body/foreground/hit-test COPY- BlockContainer<BODY>#body/foreground COPY- BlockContainer<DIV>#static/descendants(foreground) COPY- BlockContainer<DIV>#box/descendants(foreground) ASSEMBLE- BlockContainer<BODY>#body/outline COPY- BlockContainer<BODY>#body/overlay/hit-test COPY- BlockContainer<BODY>#body/overlay COPY- BlockContainer<DIV>#box ASSEMBLE- 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>#html/outline COPY- BlockContainer<HTML>#html/overlay/hit-test COPY- BlockContainer<HTML>#html/overlay COPY- @viewport/outline COPY- @viewport/overlay/hit-test COPY- @viewport/overlay COPY- `- }- ]-});-</script>diff --git a/Tests/LibWeb/Text/input/display_list/hit-test-recording-with-force-dark-copies-from-published-recording.html b/Tests/LibWeb/Text/input/display_list/hit-test-recording-with-force-dark-copies-from-published-recording.htmldeleted file mode 100644index 8ee9b97193b..00000000000--- a/Tests/LibWeb/Text/input/display_list/hit-test-recording-with-force-dark-copies-from-published-recording.html+++ /dev/null@@ -1,26 +0,0 @@-<!doctype html>-<script src="../include.js"></script>-<style>- body { margin: 0; }- #box { position: absolute; left: 10px; top: 60px; width: 50px; height: 50px; background: green; }-</style>-<div id="box"></div>-<script>-// The frames record with the navigable's paint config, which has force dark on here. A hit test records with the same-// config, so it still copies from the frame published last instead of recording the whole page.-promiseTest(async () => {- const nextFrame = () => new Promise(resolve => requestAnimationFrame(resolve));- internals.setForceDarkEnabled(true);- await nextFrame();- await nextFrame();-- box.style.left = "100px";- internals.beginDisplayListTrace();- const target = document.elementFromPoint(120, 80);- const viewportWork = internals.takeDisplayListTrace().split("\n").find(line => line.startsWith("@viewport "));- internals.setForceDarkEnabled(false);-- println(`hit target: ${target.id}`);- println(`hit-test recording: ${viewportWork}`);-});-</script>diff --git a/Tests/LibWeb/Text/input/display_list/hit-test-recording-then-next-frame-records-again.html b/Tests/LibWeb/Text/input/display_list/hit-test-records-nothing.htmlsimilarity index 71%rename from Tests/LibWeb/Text/input/display_list/hit-test-recording-then-next-frame-records-again.htmlrename to Tests/LibWeb/Text/input/display_list/hit-test-records-nothing.htmlindex 43c0545972f..698d8ff9972 100644--- a/Tests/LibWeb/Text/input/display_list/hit-test-recording-then-next-frame-records-again.html+++ b/Tests/LibWeb/Text/input/display_list/hit-test-records-nothing.html@@ -6,6 +6,8 @@</style><div id="box"></div><script>+ // A hit test reads the document's rows as they are, so it finds a box where a change that no frame has shown+ // yet put it, records nothing, and leaves the change for the next frame to record.promiseTest(async () => {const nextFrame = () => new Promise(resolve => requestAnimationFrame(resolve));const settle = async () => {@@ -18,11 +20,12 @@// Printing changes the document and would invalidate the recording under test.const results = [];await settle();- for (const left of [10, 20]) {+ for (const left of [10, 200, 20]) {box.style.left = `${left}px`;internals.beginDisplayListTrace();const target = document.elementFromPoint(50, 50);- results.push(`left=${left}: hit target=${target.id}, hit-test recordings=${recordingCount()}`);+ const caret = document.caretPositionFromPoint(50, 50);+ results.push(`left=${left}: hit target=${target.id || target.localName}, caret in ${caret.offsetNode.id || caret.offsetNode.nodeName}, recordings=${recordingCount()}`);internals.beginDisplayListTrace();await settle();