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)
| 1069 | * |
| 1070 | * ~1-2ms (paint only, no reconcile — the DOM is already built). */ |
| 1071 | scanElementSubtree(el: dom.DOMElement): MatchPosition[] { |
| 1072 | if (!this.searchHighlightQuery || !el.yogaNode) return []; |
| 1073 | const width = Math.ceil(el.yogaNode.getComputedWidth()); |
| 1074 | const height = Math.ceil(el.yogaNode.getComputedHeight()); |
| 1075 | if (width <= 0 || height <= 0) return []; |
| 1076 | // renderNodeToOutput adds el's OWN computedLeft/Top to offsetX/Y. |
| 1077 | // Passing -elLeft/-elTop nets to 0 → paints at (0,0) in our buffer. |
| 1078 | const elLeft = el.yogaNode.getComputedLeft(); |
| 1079 | const elTop = el.yogaNode.getComputedTop(); |
| 1080 | const screen = createScreen(width, height, this.stylePool, this.charPool, this.hyperlinkPool); |
| 1081 | const output = new Output({ |
| 1082 | width, |
| 1083 | height, |
| 1084 | stylePool: this.stylePool, |
| 1085 | screen |
| 1086 | }); |
| 1087 | renderNodeToOutput(el, output, { |
| 1088 | offsetX: -elLeft, |
| 1089 | offsetY: -elTop, |
| 1090 | prevScreen: undefined |
| 1091 | }); |
| 1092 | const rendered = output.get(); |
| 1093 | // renderNodeToOutput wrote our offset positions to nodeCache — |
| 1094 | // corrupts the main render (it'd blit from wrong coords). Mark the |
| 1095 | // subtree dirty so the next main render repaints + re-caches |
| 1096 | // correctly. One extra paint of this message, but correct > fast. |
| 1097 | dom.markDirty(el); |
| 1098 | const positions = scanPositions(rendered, this.searchHighlightQuery); |
| 1099 | 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 ? ',…' : ''}]`); |
| 1100 | return positions; |
| 1101 | } |
| 1102 | |
| 1103 | /** Set the position-based highlight state. Every frame, writes CURRENT |
| 1104 | * style at positions[currentIdx] + rowOffset. null clears. The scan- |
no test coverage detected