Web source: crop to the frame's ALPHA bounding box — the widget's true rendered extent, no DOM timing, can't break the render

- 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.
This commit is contained in:
2026-08-28 11:53:36 -07:00
parent 5348b5c480
commit bccdb4892c
5 changed files with 117 additions and 80 deletions
+9 -7
View File
@@ -31,15 +31,17 @@ Stream widget bounding box: hug the widget on all four sides, pinned to canvas (
extents regardless. Lesson: verify declared mechanics actually execute; assume nothing ran.
## Current iteration (web bounding box — UNCOMMITTED, verification pending)
RENDER RESTORED to the last creator-verified-good state (`70fe2b8`): full-frame capture (no crop),
1920×1080 canvas-size viewport, plain `Stretch="Fill"`. Image rendering is back to "renders and
resizes beautifully". The bounding-box dead-space problem is STILL OPEN — do NOT reintroduce any
crop until the creator explicitly approves the approach.
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 content-union crop + image alignment)
## 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: the canvas-size render + Fill is the ONLY verified
good base; any crop must be built on it one tested step at a time, never shipped blind.
"don't break the rendering" instruction. Lesson: measure actual RENDERED PIXELS (alpha), never
transient DOM state; and never ship a crop blind.