Revert ab29ec8: container==content auto-fit made it worse — back to alpha-crop with the container at element size

The container tracks the element's own Width/Height again; the crop stays in the bitmap.
This commit is contained in:
2026-08-28 12:09:13 -07:00
parent ab29ec801d
commit 9b56e88800
7 changed files with 51 additions and 103 deletions
+7 -10
View File
@@ -917,19 +917,16 @@ capturing the primary display (which causes the infinity mirror effect).
8. ✅ Preview shows live web content (not just a blank rectangle)
9. ☐ Handle navigation errors, invalid URIs, timeout gracefully
**Rendering model (2026-08-28, canvas-size viewport + alpha crop + CONTAINER==CONTENT):**
**Rendering model (2026-08-28, canvas-size viewport + ALPHA-BBOX crop):**
the page renders at the MASTER CANVAS size (1920×1080), stable, never tracked (no reflow/truncation;
scrollbars suppressed via `overflow:hidden`). `FindContentBounds` scans the Bgra32 capture and crops
to the bounding box of non-transparent pixels — the widget's true rendered extent, measured from the
frame itself (NO DOM query, immune to layout timing, can never truncate content; full-canvas widgets
fall through to the full frame). `ContentCanvasSize` maps the cropped pixel rect to canvas units
(DPI-correct); `MainViewModel.OnWebView2PreviewBitmapChanged` sizes the element's Width/Height to it —
so the element grid AND the SelectionOverlay (both bound to the element's Width/Height) equal the
widget exactly. Auto-fit suppressed while dragging (`IsPreviewDragging`). `Stretch="Fill"` is now
~1:1; no cropped bitmap is stretched into a larger frame.
⚠️ Lesson bank: never return `JSON.stringify` from `ExecuteScriptAsync` (double-encodes); never
measure DOM on NavigationCompleted (unsettled layout broke the image — `a5b9952`); fixing the
bitmap crop without sizing the container leaves the gap (— `bccdb48`).
frame itself (NO DOM query, immune to layout timing; can never truncate content; full-canvas widgets
fall through to the full frame = prior verified-good image). `Stretch="Fill"` maps the cropped frame
flush under the selection box → box hugs the widget on all four sides. `QueryContentBoundsAsync` +
the JS content-bounds script are DELETED. ⚠️ Lesson bank: never return `JSON.stringify` from
`ExecuteScriptAsync` (double-encodes); never measure DOM stuff on NavigationCompleted (unsettled
layout broke the image — `a5b9952`); measure rendered pixels instead.
**Properties panel (2026-08-28):** web URI ✓/✕ icon buttons are `IsTabStop="False"` so Tab flows
X→Y→W→H→URI; the ✕ button now clears the URI textbox (was reverting to the pre-accept snapshot).