()
| 266 | } |
| 267 | |
| 268 | get(): Screen { |
| 269 | const screen = this.screen |
| 270 | const screenWidth = this.width |
| 271 | const screenHeight = this.height |
| 272 | |
| 273 | // Track blit vs write cell counts for debugging |
| 274 | let blitCells = 0 |
| 275 | let writeCells = 0 |
| 276 | |
| 277 | // Pass 1: expand damage to cover clear regions. The buffer is freshly |
| 278 | // zeroed by resetScreen, so this pass only marks damage so diff() |
| 279 | // checks these regions against the previous frame. |
| 280 | // |
| 281 | // Also collect clears from absolute-positioned nodes. An absolute |
| 282 | // node overlays normal-flow siblings; when it shrinks, its clear is |
| 283 | // pushed AFTER those siblings' clean-subtree blits (DOM order). The |
| 284 | // blit copies the absolute node's own stale paint from prevScreen, |
| 285 | // and since clear is damage-only, the ghost survives diff. Normal- |
| 286 | // flow clears don't need this — a normal-flow node's old position |
| 287 | // can't have been painted on top of a sibling's current position. |
| 288 | const absoluteClears: Rectangle[] = [] |
| 289 | for (const operation of this.operations) { |
| 290 | if (operation.type !== 'clear') continue |
| 291 | const { x, y, width, height } = operation.region |
| 292 | const startX = Math.max(0, x) |
| 293 | const startY = Math.max(0, y) |
| 294 | const maxX = Math.min(x + width, screenWidth) |
| 295 | const maxY = Math.min(y + height, screenHeight) |
| 296 | if (startX >= maxX || startY >= maxY) continue |
| 297 | const rect = { |
| 298 | x: startX, |
| 299 | y: startY, |
| 300 | width: maxX - startX, |
| 301 | height: maxY - startY, |
| 302 | } |
| 303 | screen.damage = screen.damage ? unionRect(screen.damage, rect) : rect |
| 304 | if (operation.fromAbsolute) absoluteClears.push(rect) |
| 305 | } |
| 306 | |
| 307 | const clips: Clip[] = [] |
| 308 | |
| 309 | for (const operation of this.operations) { |
| 310 | switch (operation.type) { |
| 311 | case 'clear': |
| 312 | // handled in pass 1 |
| 313 | continue |
| 314 | |
| 315 | case 'clip': |
| 316 | // Intersect with the parent clip (if any) so nested |
| 317 | // overflow:hidden boxes can't write outside their ancestor's |
| 318 | // clip region. Without this, a message with overflow:hidden at |
| 319 | // the bottom of a scrollbox pushes its OWN clip (based on its |
| 320 | // layout bounds, already translated by -scrollTop) which can |
| 321 | // extend below the scrollbox viewport — writes escape into |
| 322 | // the sibling bottom section's rows. |
| 323 | clips.push(intersectClip(clips.at(-1), operation.clip)) |
| 324 | continue |
| 325 |
no test coverage detected