Commit fb3d25e
authored
fix(painter-dom): prevent scroll acceleration feedback loop in virtualization (#2291)
* fix(painter-dom): prevent scroll acceleration feedback loop in virtualization
The virtual window update caused uncontrollable scroll acceleration in long
documents when an external scroll container handled scrolling. The root cause
was a positive feedback loop between spacer DOM mutations and browser scroll
anchoring.
The browser picked virtualPagesEl as the scroll anchor. When the top spacer
grew during window shifts, virtualPagesEl moved down, and scroll anchoring
adjusted scrollTop to compensate. This fired a new scroll event with a higher
scrollY, triggering another window shift, cascading to the end of the document.
Fix: set overflow-anchor: none on virtualPagesEl so the browser anchors on
page elements (children) instead. Page elements stay at stable positions
regardless of spacer changes, so scroll anchoring produces zero adjustment.
Also stabilize the scrollY calculation for external scroll containers by
caching the mount-to-container offset and using scrollTop instead of
getBoundingClientRect, which is susceptible to layout shifts during DOM
mutations.
* test(behavior): add scroll acceleration regression tests
Adds 8 Playwright behavior tests covering scroll virtualization stability:
- Incremental scroll does not jump ahead uncontrollably
- Scroll to mid-document shows correct pages (not start/end)
- Rapid small scrolls do not cause runaway to bottom
- Virtual window shift preserves scroll position stability
- Scroll stability with comments enabled (different DOM layout)
- Scroll stability at 75% and 150% zoom levels
All tests pass across Chromium, Firefox, and WebKit.
* test(behavior): add comments: disabled config and scroll tests for SD-2005
Extends the behavior test harness to support comments='disabled', which sets
modules: { comments: false } on the SuperDoc config. This matches the exact
customer configuration that triggered the scroll acceleration bug (SD-2005).
Adds 3 new test variants exercising scroll stability with comments explicitly
disabled, including incremental scroll, rapid scroll, and 75% zoom.
All 33 tests pass across Chromium, Firefox, and WebKit.
* refactor: simplify scroll acceleration tests and fix review findings
- Extract shared test patterns (assertIncrementalScrollStable,
assertRapidScrollStable, assertScrollStableAtZoom) to eliminate
copy-paste across describe blocks
- Split getScrollInfo into separate setScrollTop (write) and
getScrollInfo (read-only) to avoid action-query conflation
- Extract getPageHeight helper (was duplicated 7x inline)
- Replace test.extend<{}>({}) with test.use() inside describe blocks
- Use waitForStable(50) instead of page.waitForTimeout(50)
- Remove redundant instanceof HTMLElement guard in hot path
- Remove as-any cast in harness (modules is already on SuperDocConfig)
* fix: drop duplicate scrollContainerMountOffset reset (already in resetState)1 parent eb48bf1 commit fb3d25e
5 files changed
Lines changed: 358 additions & 74 deletions
File tree
- packages/layout-engine/painters/dom/src
- tests/behavior
- fixtures
- harness
- tests/virtualization
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
1 | 1 | | |
| 2 | + | |
| 3 | + | |
| 4 | + | |
| 5 | + | |
| 6 | + | |
| 7 | + | |
2 | 8 | | |
| 9 | + | |
| 10 | + | |
3 | 11 | | |
| 12 | + | |
| 13 | + | |
| 14 | + | |
| 15 | + | |
| 16 | + | |
4 | 17 | | |
| 18 | + | |
| 19 | + | |
| 20 | + | |
| 21 | + | |
| 22 | + | |
5 | 23 | | |
6 | 24 | | |
7 | 25 | | |
8 | 26 | | |
9 | | - | |
10 | | - | |
11 | | - | |
12 | | - | |
13 | | - | |
14 | | - | |
15 | | - | |
16 | | - | |
17 | | - | |
18 | | - | |
19 | | - | |
20 | | - | |
21 | 27 | | |
| 28 | + | |
22 | 29 | | |
23 | | - | |
24 | | - | |
25 | | - | |
| 30 | + | |
| 31 | + | |
| 32 | + | |
| 33 | + | |
| 34 | + | |
| 35 | + | |
| 36 | + | |
| 37 | + | |
| 38 | + | |
| 39 | + | |
26 | 40 | | |
| 41 | + | |
27 | 42 | | |
| 43 | + | |
28 | 44 | | |
29 | 45 | | |
30 | | - | |
31 | | - | |
32 | 46 | | |
33 | | - | |
34 | | - | |
35 | | - | |
36 | | - | |
37 | 47 | | |
38 | | - | |
39 | | - | |
40 | | - | |
41 | | - | |
42 | | - | |
43 | | - | |
44 | | - | |
45 | | - | |
46 | | - | |
47 | | - | |
48 | 48 | | |
49 | 49 | | |
| 50 | + | |
50 | 51 | | |
51 | | - | |
| 52 | + | |
| 53 | + | |
| 54 | + | |
| 55 | + | |
| 56 | + | |
| 57 | + | |
| 58 | + | |
| 59 | + | |
| 60 | + | |
| 61 | + | |
| 62 | + | |
| 63 | + | |
| 64 | + | |
| 65 | + | |
52 | 66 | | |
53 | 67 | | |
54 | 68 | | |
55 | 69 | | |
56 | | - | |
57 | | - | |
58 | | - | |
59 | | - | |
60 | | - | |
61 | | - | |
62 | | - | |
63 | | - | |
64 | 70 | | |
65 | 71 | | |
| 72 | + | |
66 | 73 | | |
| 74 | + | |
| 75 | + | |
| 76 | + | |
| 77 | + | |
| 78 | + | |
| 79 | + | |
| 80 | + | |
67 | 81 | | |
68 | 82 | | |
69 | | - | |
70 | | - | |
| 83 | + | |
71 | 84 | | |
72 | | - | |
73 | 85 | | |
| 86 | + | |
74 | 87 | | |
75 | 88 | | |
76 | 89 | | |
77 | 90 | | |
78 | 91 | | |
79 | 92 | | |
80 | 93 | | |
81 | | - | |
82 | | - | |
83 | | - | |
84 | | - | |
85 | | - | |
86 | | - | |
87 | | - | |
88 | | - | |
89 | | - | |
90 | | - | |
91 | | - | |
92 | | - | |
93 | | - | |
94 | 94 | | |
95 | 95 | | |
96 | 96 | | |
| |||
1041 | 1041 | | |
1042 | 1042 | | |
1043 | 1043 | | |
| 1044 | + | |
| 1045 | + | |
| 1046 | + | |
| 1047 | + | |
| 1048 | + | |
| 1049 | + | |
1044 | 1050 | | |
1045 | 1051 | | |
1046 | 1052 | | |
| |||
1114 | 1120 | | |
1115 | 1121 | | |
1116 | 1122 | | |
| 1123 | + | |
1117 | 1124 | | |
1118 | 1125 | | |
1119 | 1126 | | |
| |||
1137 | 1144 | | |
1138 | 1145 | | |
1139 | 1146 | | |
| 1147 | + | |
1140 | 1148 | | |
1141 | 1149 | | |
1142 | 1150 | | |
| |||
1576 | 1584 | | |
1577 | 1585 | | |
1578 | 1586 | | |
| 1587 | + | |
| 1588 | + | |
| 1589 | + | |
| 1590 | + | |
| 1591 | + | |
| 1592 | + | |
| 1593 | + | |
| 1594 | + | |
1579 | 1595 | | |
1580 | 1596 | | |
1581 | 1597 | | |
| |||
1589 | 1605 | | |
1590 | 1606 | | |
1591 | 1607 | | |
| 1608 | + | |
| 1609 | + | |
| 1610 | + | |
| 1611 | + | |
1592 | 1612 | | |
1593 | 1613 | | |
1594 | 1614 | | |
| |||
1618 | 1638 | | |
1619 | 1639 | | |
1620 | 1640 | | |
| 1641 | + | |
1621 | 1642 | | |
1622 | 1643 | | |
1623 | 1644 | | |
| |||
1682 | 1703 | | |
1683 | 1704 | | |
1684 | 1705 | | |
| 1706 | + | |
1685 | 1707 | | |
1686 | 1708 | | |
1687 | 1709 | | |
| |||
1700 | 1722 | | |
1701 | 1723 | | |
1702 | 1724 | | |
1703 | | - | |
1704 | | - | |
1705 | | - | |
1706 | | - | |
1707 | | - | |
1708 | | - | |
1709 | | - | |
| 1725 | + | |
| 1726 | + | |
| 1727 | + | |
| 1728 | + | |
| 1729 | + | |
| 1730 | + | |
| 1731 | + | |
| 1732 | + | |
| 1733 | + | |
| 1734 | + | |
| 1735 | + | |
| 1736 | + | |
1710 | 1737 | | |
1711 | 1738 | | |
1712 | 1739 | | |
| |||
2210 | 2237 | | |
2211 | 2238 | | |
2212 | 2239 | | |
| 2240 | + | |
2213 | 2241 | | |
2214 | 2242 | | |
2215 | 2243 | | |
| |||
Lines changed: 10 additions & 10 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
487 | 487 | | |
488 | 488 | | |
489 | 489 | | |
490 | | - | |
491 | | - | |
492 | | - | |
493 | | - | |
| 490 | + | |
| 491 | + | |
| 492 | + | |
| 493 | + | |
494 | 494 | | |
495 | 495 | | |
496 | 496 | | |
497 | 497 | | |
498 | 498 | | |
499 | | - | |
500 | | - | |
501 | | - | |
502 | | - | |
| 499 | + | |
| 500 | + | |
| 501 | + | |
| 502 | + | |
503 | 503 | | |
504 | 504 | | |
505 | 505 | | |
| |||
516 | 516 | | |
517 | 517 | | |
518 | 518 | | |
| 519 | + | |
| 520 | + | |
519 | 521 | | |
520 | 522 | | |
521 | 523 | | |
522 | | - | |
523 | | - | |
524 | 524 | | |
525 | 525 | | |
526 | 526 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
9 | 9 | | |
10 | 10 | | |
11 | 11 | | |
12 | | - | |
| 12 | + | |
13 | 13 | | |
14 | 14 | | |
15 | 15 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
95 | 95 | | |
96 | 96 | | |
97 | 97 | | |
| 98 | + | |
| 99 | + | |
| 100 | + | |
| 101 | + | |
98 | 102 | | |
99 | 103 | | |
100 | 104 | | |
| |||
0 commit comments