Paint an EXISTING DOM subtree to a fresh Screen at its natural * height, scan for query. Returns positions relative to the element's * bounding box (row 0 = element top). * * The element comes from the MAIN tree — built with all real * providers, yoga already computed. We paint it
(el: dom.DOMElement)
| 1222 | * |
| 1223 | * ~1-2ms (paint only, no reconcile — the DOM is already built). */ |
| 1224 | scanElementSubtree(el: dom.DOMElement): MatchPosition[] { |
| 1225 | if (!this.searchHighlightQuery || !el.yogaNode) return []; |
| 1226 | const width = Math.ceil(el.yogaNode.getComputedWidth()); |
| 1227 | const height = Math.ceil(el.yogaNode.getComputedHeight()); |
| 1228 | if (width <= 0 || height <= 0) return []; |
| 1229 | // renderNodeToOutput adds el's OWN computedLeft/Top to offsetX/Y. |
| 1230 | // Passing -elLeft/-elTop nets to 0 → paints at (0,0) in our buffer. |
| 1231 | const elLeft = el.yogaNode.getComputedLeft(); |
| 1232 | const elTop = el.yogaNode.getComputedTop(); |
| 1233 | const screen = createScreen(width, height, this.stylePool, this.charPool, this.hyperlinkPool); |
| 1234 | const output = new Output({ |
| 1235 | width, |
| 1236 | height, |
| 1237 | stylePool: this.stylePool, |
| 1238 | screen |
| 1239 | }); |
| 1240 | renderNodeToOutput(el, output, { |
| 1241 | offsetX: -elLeft, |
| 1242 | offsetY: -elTop, |
| 1243 | prevScreen: undefined |
| 1244 | }); |
| 1245 | const rendered = output.get(); |
| 1246 | // renderNodeToOutput wrote our offset positions to nodeCache — |
| 1247 | // corrupts the main render (it'd blit from wrong coords). Mark the |
| 1248 | // subtree dirty so the next main render repaints + re-caches |
| 1249 | // correctly. One extra paint of this message, but correct > fast. |
| 1250 | dom.markDirty(el); |
| 1251 | const positions = scanPositions(rendered, this.searchHighlightQuery); |
| 1252 | logForDebugging(`scanElementSubtree: q='${this.searchHighlightQuery}' ` + `el=${width}x${height}@(${elLeft},${elTop}) n=${positions.length} ` + `[${positions.slice(0, 10).map(p => `${p.row}:${p.col}`).join(',')}` + `${positions.length > 10 ? ',…' : ''}]`); |
| 1253 | return positions; |
| 1254 | } |
| 1255 | |
| 1256 | /** Set the position-based highlight state. Every frame, writes CURRENT |
| 1257 | * style at positions[currentIdx] + rowOffset. null clears. The scan- |
no test coverage detected