- FindContentBounds scans the Bgra32 capture for the bounding box of non-transparent pixels
(background is injected transparent, so alpha = widget extent). Crop to that rect + Stretch=Fill
maps the widget flush under the selection box: full-canvas widgets fall through to the full frame
(identical to the confirmed-good image); floating widgets get tight-fitted with no dead space.
- Removes QueryContentBoundsAsync + the JS script entirely — the DOM-union attempt (a5b9952) broke
rendering by measuring an unsettled layout on NavigationCompleted; alpha measurement is immune.
- 3 new unit tests: tight box, no-alpha no-crop, full-alpha no-crop. 7/7 pass, 0 warnings.
3.6 KiB
MyMistakes.md
One task at a time. Updated before every commit touching that task: current iteration + why the last one failed. On task complete, committed AND pushed → truncate to this stub. A new task does NOT seed this file until its first failure.
Task (active — committed 582d1f4, NOT pushed, awaiting creator verification)
Stream widget bounding box: hug the widget on all four sides, pinned to canvas (0,0).
Iterations that failed
e917c41— fixed 1920×1080 viewport +Stretch="Uniform"+ startup registration. Failed:Uniformletterboxed the 16:9 canvas into arbitrary‑sized boxes → asymmetric dead padding read as a "gap". Lesson: Fill the box with the cropped frame, never Uniform.9d4103c— per‑document CSS reset (html/bodywidth/height 100%) + (0,0) anchor. Failed ("enlarged the gap"): forcing dimensions overrode the widget's own layout and expanded the dead space. Lesson: inject onlyoverflow:hidden+ transparent background — never set sizes.8d793af— viewport == element‑box size +Stretch="Fill". Failed (janky / truncating / scrollbars): hosting at the box size clips full‑bleed widgets to their upper‑left chunk, and tracking the box reflows the page on drag. Lesson: render at a fixed canvas size, never track the box.f39ebd9— crop capture toscrollWidth/scrollHeightbounds + (0,0) + Fill. Partially passed (panel fixes 1a/1b/4 confirmed) but the box stayed loose; the apparent "tight right/bottom" was just the small‑viewport clip edge. ROOT CAUSE: the crop never ran. The script returnedJSON.stringify(...)(a string);ExecuteScriptAsyncJSON‑encodes every result, so the JSON was double‑encoded →JsonDocument.Parsegot a string node →GetPropertythrew → try/catch swallowed → bounds unset → no crop. Lesson: return a real JS object, never a stringified one. Also: scroll extents ≠ widget rect (they include page margins).70fe2b8— fixed canvas‑size viewport (1920×1080) + crop + Fill. Image render/resize became solid (creator confirmed) but the box still gapped right/bottom and wasn't 0,0. Same silent JSON bug — the crop still never executed — and the measure was scroll extents regardless. Lesson: verify declared mechanics actually execute; assume nothing ran.
Current iteration (web bounding box — UNCOMMITTED, verification pending)
ALPHA-BBOX CROP: FindContentBounds scans the captured Bgra32 frame and returns the bounding box
of non-transparent pixels (the background is injected transparent, so alpha = the widget's extent).
Capture is cropped to that rect and Stretch="Fill" maps it flush under the box. No DOM query, no
layout timing — the crop rect IS the rendered widget by construction, so it can NEVER truncate
visible content. Worst case (widget fills the canvas) = full frame = the confirmed-good render.
Canvas-size viewport + Fill untouched. QueryContentBoundsAsync + the JS script are DELETED.
Iteration that just failed (a5b9952 — wrapper-excluded DOM-union crop + image alignment)
Broke the image rendering — creator could not evaluate the box because the image was gone/ruined. Why: the visible-element-union rect is measured ONCE on NavigationCompleted; widget layout isn't settled then (async fonts/images, load animations, iframes), so the crop rect comes out tiny/wrong and the Fill-stretched frame renders a broken/zoomed sliver. This was against the creator's explicit "don't break the rendering" instruction. Lesson: measure actual RENDERED PIXELS (alpha), never transient DOM state; and never ship a crop blind.