nativeview-layout 0.1.0-rc.1

Shared NodeStore layout layer: StoreLayoutEngine / TextMeasurer traits and the default direct Taffy engine
Documentation
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
//! Per-surface scroll offsets, content bounds, per-axis `Scroll::axes` clamping, Layer-1 scroll
//! anchoring integration, exact sequence-driven controlled scroll reconciliation, and the
//! pluggable [`ScrollPhysicsEngine`] seam.

use std::collections::HashMap;

use nativeview_store::{ChangeSet, NodeId, NodeStore, NvTable};
use nativeview_tables::tables::{Overflow, Scroll, ScrollAxes, Visual};

use crate::StoreLayoutEngine;

mod anchor;
mod chain;
pub use chain::push_unique_node;
pub(crate) mod engine;
pub(crate) mod extent;
mod into_view;

use extent::compute_scroll_content_size;

use super::LaidOutScene;
use anchor::CapturedScrollAnchor;
use engine::ScrollPhysicsEngine;

#[derive(Debug, Clone, Copy, PartialEq, Eq)]
struct SeqSlot {
    node: NodeId,
    seq: u32,
}

const EMPTY_SEQ_SLOT: SeqSlot = SeqSlot {
    node: NodeId::NULL,
    seq: 0,
};

/// Returns `(allow_x, allow_y)` permitted scroll axes for `id`.
#[inline]
pub fn scroll_axes_allow(store: &NodeStore, id: NodeId) -> (bool, bool) {
    match store.try_row::<Scroll>(id).map(|s| s.axes()) {
        Some(ScrollAxes::Vertical) => (false, true),
        Some(ScrollAxes::Horizontal) => (true, false),
        Some(ScrollAxes::Both) => (true, true),
        Some(ScrollAxes::None) => (false, false),
        None => store.try_row::<Visual>(id).map_or((false, false), |v| {
            (
                matches!(v.overflow_x(), Overflow::Scroll | Overflow::Auto),
                matches!(v.overflow_y(), Overflow::Scroll | Overflow::Auto),
            )
        }),
    }
}

/// Summary outcome of [`LaidOutScene::apply_scroll_chain`].
#[derive(Debug, Clone, Copy, Default, PartialEq, Eq)]
pub struct ScrollChainOutcome {
    pub consumed_x: bool,
    pub consumed_y: bool,
    pub any_visual_changed: bool,
    pub any_clamped_changed: bool,
    pub active_physics: bool,
}

/// Per-surface scroll offset map plus generation-safe dense `requested_scroll_seq` deduplication
/// and reusable Layer-1 scroll anchor / scratch buffers (0-alloc steady state).
#[derive(Debug, Default, Clone)]
pub struct ScrollOffsets {
    offsets: HashMap<NodeId, (f32, f32)>,
    last_requested_seq: Vec<SeqSlot>,
    reconcile_scratch: Vec<ScrollReconcileEntry>,
    pub(crate) changed_scratch: Vec<NodeId>,
    /// `changed_scratch` of a commit's first scroll pass, unioned back after its second pass.
    pub(crate) commit_changed: Vec<NodeId>,
    pub(crate) captured_anchors: Vec<CapturedScrollAnchor>,
    pub(crate) chain_changed_scratch: Vec<NodeId>,
    pub(crate) chain_clamped_scratch: Vec<NodeId>,
    pub(crate) step_visual_scratch: Vec<NodeId>,
    pub(crate) step_clamped_scratch: Vec<NodeId>,
    /// Set whenever an offset moves; consumed by the next overlay reconcile, so anchored
    /// top-layer geometry follows scrolling exactly once per frame.
    moved: bool,
}

impl ScrollOffsets {
    /// Returns and clears whether any offset moved since the last call.
    #[inline]
    pub(crate) fn take_moved(&mut self) -> bool {
        core::mem::take(&mut self.moved)
    }

    #[inline]
    pub fn get(&self, id: NodeId) -> (f32, f32) {
        self.offsets.get(&id).copied().unwrap_or((0.0, 0.0))
    }

    /// Every tracked `(node, (x, y))` offset, in unspecified order.
    #[inline]
    pub fn iter(&self) -> impl Iterator<Item = (NodeId, (f32, f32))> + '_ {
        self.offsets.iter().map(|(&id, &xy)| (id, xy))
    }

    #[inline]
    pub fn contains(&self, id: NodeId) -> bool {
        self.offsets.contains_key(&id)
    }

    #[inline]
    pub(crate) fn offsets_is_empty(&self) -> bool {
        self.offsets.is_empty()
    }

    #[inline]
    pub fn last_requested_seq(&self, id: NodeId) -> u32 {
        self.last_requested_seq
            .get(id.index())
            .copied()
            .filter(|slot| slot.node == id)
            .map_or(0, |slot| slot.seq)
    }

    #[inline]
    fn set_last_requested_seq(&mut self, id: NodeId, seq: u32) {
        let idx = id.index();
        if seq == 0 {
            if let Some(slot) = self.last_requested_seq.get_mut(idx)
                && slot.node == id
            {
                *slot = EMPTY_SEQ_SLOT;
            }
            return;
        }
        if idx >= self.last_requested_seq.len() {
            self.last_requested_seq.resize(idx + 1, EMPTY_SEQ_SLOT);
        }
        self.last_requested_seq[idx] = SeqSlot { node: id, seq };
    }

    /// Nodes whose effective scroll offset changed during the most recent reconciliation pass.
    #[inline]
    pub fn last_changed(&self) -> &[NodeId] {
        &self.changed_scratch
    }

    #[inline]
    pub fn set_raw(&mut self, id: NodeId, x: f32, y: f32) {
        if self.offsets.insert(id, (x, y)) != Some((x, y)) {
            self.moved = true;
        }
    }

    #[inline]
    pub fn remove(&mut self, id: NodeId) {
        self.offsets.remove(&id);
        if let Some(slot) = self.last_requested_seq.get_mut(id.index())
            && slot.node == id
        {
            *slot = EMPTY_SEQ_SLOT;
        }
    }

    #[inline]
    pub fn clear(&mut self) {
        self.offsets.clear();
        self.last_requested_seq.fill(EMPTY_SEQ_SLOT);
        self.reconcile_scratch.clear();
        self.changed_scratch.clear();
        self.captured_anchors.clear();
        self.chain_changed_scratch.clear();
        self.chain_clamped_scratch.clear();
        self.step_visual_scratch.clear();
        self.step_clamped_scratch.clear();
    }

    /// Clamped visual child shift for `id`, subtracting any virtualized `Scroll::virtual_top_spacer`.
    /// Pure clamped (zero synthetic overscroll) so OS-native scroll hosts never receive rubber-band
    /// offsets through `NvScrollOffset`.
    #[inline]
    pub fn visual_shift(&self, store: &NodeStore, id: NodeId) -> (f32, f32) {
        let (sx, sy) = self.get(id);
        Self::visual_shift_with(store, id, sx, sy)
    }

    /// [`Self::visual_shift`] for an offset `(sx, sy)` already read (e.g. from [`Self::iter`]).
    #[inline]
    pub fn visual_shift_with(store: &NodeStore, id: NodeId, sx: f32, sy: f32) -> (f32, f32) {
        match store
            .try_row::<Scroll>(id)
            .and_then(|scroll| scroll.virtual_top_spacer())
            .filter(|&v| v.is_finite() && v > 0.0)
        {
            Some(top_spacer) => (sx, (sy - top_spacer).max(0.0)),
            None => (sx, sy),
        }
    }
}

#[derive(Debug, Clone, Copy)]
struct ScrollReconcileEntry {
    id: NodeId,
    x: f32,
    y: f32,
    max_x: f32,
    max_y: f32,
    anchor_dx: f32,
    anchor_dy: f32,
    seq: u32,
    explicit_seek: bool,
    changed: bool,
}

impl<L: StoreLayoutEngine> LaidOutScene<L> {
    #[inline]
    pub fn scroll_offsets(&self) -> &ScrollOffsets {
        &self.scroll
    }

    #[inline]
    pub fn last_reconciled_scroll_nodes(&self) -> &[NodeId] {
        self.scroll.last_changed()
    }

    #[inline]
    pub fn last_scroll_chain_changed(&self) -> &[NodeId] {
        &self.scroll.chain_changed_scratch
    }

    #[inline]
    pub fn last_scroll_chain_clamped_changed(&self) -> &[NodeId] {
        &self.scroll.chain_clamped_scratch
    }

    #[inline]
    pub fn last_physics_visual_changed(&self) -> &[NodeId] {
        &self.scroll.step_visual_scratch
    }

    #[inline]
    pub fn last_physics_clamped_changed(&self) -> &[NodeId] {
        &self.scroll.step_clamped_scratch
    }

    #[inline]
    pub fn set_scroll_offset_raw(&mut self, id: NodeId, dx: f32, dy: f32) {
        self.scroll.set_raw(id, dx, dy);
    }

    #[inline]
    pub fn scroll_offset(&self, id: NodeId) -> (f32, f32) {
        self.scroll.get(id)
    }

    #[inline]
    pub fn scroll_overscroll(&self, id: NodeId) -> (f32, f32) {
        self.scroll_physics.overscroll(id)
    }

    /// Clamped visual scroll shift (without synthetic overscroll).
    #[inline]
    pub fn visual_scroll_shift(&self, store: &NodeStore, id: NodeId) -> (f32, f32) {
        self.scroll.visual_shift(store, id)
    }

    /// Compositor scroll shift including active rubber-band `(overscroll_x, overscroll_y)` for
    /// custom-drawn surfaces (`SkiaBackend`), hit-testing, and sticky header tracking.
    #[inline]
    pub fn compositor_scroll_shift(&self, store: &NodeStore, id: NodeId) -> (f32, f32) {
        let (vx, vy) = self.scroll.visual_shift(store, id);
        let (ox, oy) = self.scroll_physics.overscroll(id);
        (vx + ox, vy + oy)
    }

    /// Raw scroll offset plus active rubber-band overscroll (used by sticky positioning).
    #[inline]
    pub(crate) fn compositor_scroll_offset(&self, id: NodeId) -> (f32, f32) {
        let (sx, sy) = self.scroll.get(id);
        let (ox, oy) = self.scroll_physics.overscroll(id);
        (sx + ox, sy + oy)
    }

    /// Replaces this surface's active [`ScrollPhysicsEngine`].
    #[inline]
    pub fn set_scroll_physics(&mut self, engine: Box<dyn ScrollPhysicsEngine>) {
        self.scroll_physics = engine;
    }

    #[inline]
    pub fn scroll_physics(&self) -> &dyn ScrollPhysicsEngine {
        self.scroll_physics.as_ref()
    }

    #[inline]
    pub fn scroll_physics_mut(&mut self) -> &mut dyn ScrollPhysicsEngine {
        self.scroll_physics.as_mut()
    }

    /// Logical pixels per discrete mouse-wheel line detent reported by the installed engine.
    #[inline]
    pub fn scroll_px_per_line(&self) -> f32 {
        self.scroll_physics.px_per_line()
    }

    /// Updates the reduced-motion preference on the installed [`ScrollPhysicsEngine`].
    /// Returns `true` if any active smooth-wheel animations snapped immediately to their target.
    pub fn set_scroll_reduced_motion(&mut self, reduced: bool) -> bool {
        self.scroll.step_visual_scratch.clear();
        self.scroll.step_clamped_scratch.clear();
        let mut out_visual = std::mem::take(&mut self.scroll.step_visual_scratch);
        let mut out_clamped = std::mem::take(&mut self.scroll.step_clamped_scratch);
        let snapped = self.scroll_physics.set_reduced_motion(
            reduced,
            &mut self.scroll,
            &mut out_visual,
            &mut out_clamped,
        );
        self.scroll.step_visual_scratch = out_visual;
        self.scroll.step_clamped_scratch = out_clamped;
        snapped
    }

    #[inline]
    pub fn set_scroll_synthetic_momentum(&mut self, enabled: bool) {
        self.scroll_physics.set_synthetic_momentum(enabled);
    }

    #[inline]
    pub fn has_active_scroll_physics(&self) -> bool {
        self.scroll_physics.has_active()
    }

    pub fn scroll_content_size(&self, store: &NodeStore, node_id: NodeId) -> Option<(f32, f32)> {
        let cascade = self.style_cascade();
        compute_scroll_content_size(
            store,
            |id| self.layout.layout_of(id),
            |id| cascade.display(store, id),
            node_id,
        )
    }

    #[inline]
    pub(crate) fn scroll_bounds(
        &self,
        store: &NodeStore,
        id: NodeId,
    ) -> Option<(f32, f32, f32, f32)> {
        let rect = self.layout.layout_of(id)?;
        let (cw, ch) = self
            .scroll_content_size(store, id)
            .unwrap_or((rect.width, rect.height));
        let (allow_x, allow_y) = scroll_axes_allow(store, id);
        let max_x = if allow_x {
            (cw - rect.width).max(0.0)
        } else {
            0.0
        };
        let max_y = if allow_y {
            (ch - rect.height).max(0.0)
        } else {
            0.0
        };
        Some((rect.width.max(1.0), rect.height.max(1.0), max_x, max_y))
    }

    /// Cancels any active scroll physics/overscroll on `node_id`. Returns `true` if the node had
    /// non-zero rubber-band overscroll so callers can clear visual overscroll state immediately.
    #[inline]
    pub fn cancel_scroll_physics(&mut self, node_id: NodeId) -> bool {
        let (ox, oy) = self.scroll_physics.overscroll(node_id);
        self.scroll_physics.cancel_node(node_id);
        ox.abs() > 1e-4 || oy.abs() > 1e-4
    }

    /// Sets `node_id`'s scroll offset clamped to `[0..=content - viewport]` per `Scroll::axes`,
    /// cancelling any active scroll physics on `node_id`. Returns `(clamped_x, clamped_y, changed)`.
    pub fn set_scroll_offset_clamped(
        &mut self,
        store: &NodeStore,
        node_id: NodeId,
        x: f32,
        y: f32,
    ) -> (f32, f32, bool) {
        let Some((_, _, max_x, max_y)) = self.scroll_bounds(store, node_id) else {
            return (0.0, 0.0, false);
        };
        self.set_scroll_offset_clamped_max(node_id, x, y, max_x, max_y)
    }

    /// [`Self::set_scroll_offset_clamped`] using pre-cached `(viewport_w, viewport_h, content_w,
    /// content_h)` bounds so retained hosts avoid recomputing content extents on 120 Hz scrolls.
    #[allow(clippy::too_many_arguments)]
    pub fn set_scroll_offset_clamped_with_bounds(
        &mut self,
        store: &NodeStore,
        node_id: NodeId,
        x: f32,
        y: f32,
        vw: f32,
        vh: f32,
        cw: f32,
        ch: f32,
    ) -> (f32, f32, bool) {
        let (allow_x, allow_y) = scroll_axes_allow(store, node_id);
        let max_x = if allow_x { (cw - vw).max(0.0) } else { 0.0 };
        let max_y = if allow_y { (ch - vh).max(0.0) } else { 0.0 };
        self.set_scroll_offset_clamped_max(node_id, x, y, max_x, max_y)
    }

    #[inline]
    fn set_scroll_offset_clamped_max(
        &mut self,
        node_id: NodeId,
        x: f32,
        y: f32,
        max_x: f32,
        max_y: f32,
    ) -> (f32, f32, bool) {
        let clamped_x = if x.is_finite() { x.clamp(0.0, max_x) } else { 0.0 };
        let clamped_y = if y.is_finite() { y.clamp(0.0, max_y) } else { 0.0 };
        let had_overscroll = self.cancel_scroll_physics(node_id);
        let prev = self.scroll.get(node_id);
        self.scroll.set_raw(node_id, clamped_x, clamped_y);
        let changed = had_overscroll
            || (prev.0 - clamped_x).abs() > 1e-4
            || (prev.1 - clamped_y).abs() > 1e-4;
        (clamped_x, clamped_y, changed)
    }

    /// Applies an incremental scroll delta `(dx, dy)` clamped against content bounds & `Scroll::axes`.
    /// Returns `(clamped_x, clamped_y, changed)`.
    pub fn apply_scroll_delta(
        &mut self,
        store: &NodeStore,
        node_id: NodeId,
        dx: f32,
        dy: f32,
    ) -> (f32, f32, bool) {
        let (cur_x, cur_y) = self.scroll.get(node_id);
        let nx = cur_x + if dx.is_finite() { dx } else { 0.0 };
        let ny = cur_y + if dy.is_finite() { dy } else { 0.0 };
        self.set_scroll_offset_clamped(store, node_id, nx, ny)
    }

    /// Fast-path guard around [`Self::reconcile_scroll_offsets`]: skips all work in `O(1)` when
    /// layout did not run, no `Scroll` table row changed, and no nodes were removed.
    #[inline]
    pub(crate) fn reconcile_scroll_offsets_if_needed(
        &mut self,
        store: &NodeStore,
        changes: &ChangeSet,
        laid_out: bool,
    ) -> &[NodeId] {
        self.scroll.changed_scratch.clear();
        if let Some(tc) = changes.table(Scroll::slot()) {
            for &id in &tc.detached {
                self.scroll.remove(id);
                self.scroll_physics.cancel_node(id);
            }
        }
        if !laid_out && changes.removed.is_empty() && changes.table(Scroll::slot()).is_none() {
            self.scroll.captured_anchors.clear();
            return &self.scroll.changed_scratch;
        }
        self.reconcile_scroll_offsets(store)
    }

    /// Prunes removed/detached scroll nodes, honors exact `Scroll::requested_scroll_seq`
    /// transitions (`seq != 0 && seq != prev_seq`), applies Layer-1 scroll anchor compensation,
    /// reconciles active physics entries across mid-fling commits, and re-clamps offsets per
    /// `Scroll::axes` in `O(scroll_containers)` time with zero steady-state allocations.
    pub fn reconcile_scroll_offsets(&mut self, store: &NodeStore) -> &[NodeId] {
        self.scroll.changed_scratch.clear();
        if !self.scroll.offsets.is_empty() {
            let last_seq = &mut self.scroll.last_requested_seq;
            let physics = self.scroll_physics.as_mut();
            self.scroll.offsets.retain(|&id, _| {
                let keep = store.is_live(id) && store.has::<Scroll>(id);
                if !keep {
                    physics.cancel_node(id);
                    if let Some(slot) = last_seq.get_mut(id.index())
                        && slot.node == id
                    {
                        *slot = EMPTY_SEQ_SLOT;
                    }
                }
                keep
            });
        }
        self.scroll_physics.prune_missing(store);

        let Some(nativeview_store::TableStorage {
            owners, row_count, ..
        }) = store.table_storage(Scroll::slot())
        else {
            self.scroll.captured_anchors.clear();
            return &self.scroll.changed_scratch;
        };
        if row_count == 0 {
            self.scroll.captured_anchors.clear();
            return &self.scroll.changed_scratch;
        }

        let mut updates = std::mem::take(&mut self.scroll.reconcile_scratch);
        updates.clear();
        if !owners.is_empty() {
            for &id in &owners[..row_count.min(owners.len())] {
                self.collect_scroll_node(store, id, &mut updates);
            }
        } else {
            for idx in 1..store.capacity() {
                if let Some(id) = store.id_at(idx) {
                    self.collect_scroll_node(store, id, &mut updates);
                }
            }
        }
        for entry in updates.drain(..) {
            self.scroll.set_last_requested_seq(entry.id, entry.seq);
            if entry.x != 0.0 || entry.y != 0.0 || self.scroll.contains(entry.id) {
                self.scroll.set_raw(entry.id, entry.x, entry.y);
            }
            self.scroll_physics.reconcile_node(
                entry.id,
                (entry.x, entry.y),
                (entry.max_x, entry.max_y),
                (entry.anchor_dx, entry.anchor_dy),
                entry.explicit_seek,
            );
            if entry.changed {
                self.scroll.changed_scratch.push(entry.id);
            }
        }
        self.scroll.reconcile_scratch = updates;
        self.scroll.captured_anchors.clear();
        &self.scroll.changed_scratch
    }

    fn collect_scroll_node(
        &self,
        store: &NodeStore,
        id: NodeId,
        out: &mut Vec<ScrollReconcileEntry>,
    ) {
        if !store.is_live(id) {
            return;
        }
        let Some(scroll) = store.try_row::<Scroll>(id) else {
            return;
        };
        let Some(rect) = self.layout.layout_of(id) else {
            return;
        };
        let (cw, ch) = self
            .scroll_content_size(store, id)
            .unwrap_or((rect.width, rect.height));
        let (allow_x, allow_y) = scroll_axes_allow(store, id);
        let max_x = if allow_x {
            (cw - rect.width).max(0.0)
        } else {
            0.0
        };
        let max_y = if allow_y {
            (ch - rect.height).max(0.0)
        } else {
            0.0
        };

        let (prev_x, prev_y) = self.scroll.get(id);
        let (mut sx, mut sy) = (prev_x, prev_y);
        let seq = scroll.requested_scroll_seq();
        let prev_seq = self.scroll.last_requested_seq(id);
        let explicit_seek = seq != 0 && seq != prev_seq;
        let mut anchor_dx = 0.0f32;
        let mut anchor_dy = 0.0f32;

        if explicit_seek {
            if let Some(req_x) = scroll.requested_scroll_x().filter(|v| v.is_finite()) {
                sx = req_x;
            }
            if let Some(req_y) = scroll.requested_scroll_y().filter(|v| v.is_finite()) {
                sy = req_y;
            }
        } else if !self.scroll.captured_anchors.is_empty() {
            let (dx, dy) = self.scroll_anchor_delta(store, id, rect, allow_x, allow_y);
            if dx != 0.0 || dy != 0.0 {
                sx += dx;
                sy += dy;
                anchor_dx = dx;
                anchor_dy = dy;
            }
        }

        let nx = sx.clamp(0.0, max_x);
        let ny = sy.clamp(0.0, max_y);
        let (ox, oy) = self.scroll_physics.overscroll(id);
        let had_overscroll = ox.abs() > 1e-4 || oy.abs() > 1e-4;
        let changed = (nx - prev_x).abs() > 1e-4
            || (ny - prev_y).abs() > 1e-4
            || (explicit_seek && had_overscroll);
        out.push(ScrollReconcileEntry {
            id,
            x: nx,
            y: ny,
            max_x,
            max_y,
            anchor_dx,
            anchor_dy,
            seq,
            explicit_seek,
            changed,
        });
    }
}