Web source: container == content — element grid + selection box sized to the cropped frame's canvas extent
- FindContentBounds already trimmed the bitmap; the grid/box still rendered at the uncropped user size, so Fill stretched the tight widget into a bigger frame = dead-between-content-and-border. - ContentCanvasSize maps the crop rect to canvas units (1920/pixW per axis, DPI-correct) and the preview event now carries (bitmap, canvasW, canvasH). - OnWebView2PreviewBitmapChanged sets the element Width/Height to that size; the grid and the SelectionOverlay (both bound to the element's Width/Height) now equal the widget exactly. - IsPreviewDragging (set in MainWindow drag/resize) suppresses auto-fit mid-gesture. - Tests 10/10 (alpha bounds, canvas-size mapping incl. DPI, control size); 0 warnings.
This commit is contained in:
+26
-28
@@ -6,36 +6,34 @@
|
||||
working). **NOT pushed — user rule: never push without explicit instruction (2026-08-24).** No feature
|
||||
branches pre-1.0: all work lands on `main` per work unit.
|
||||
|
||||
## The web-source rendering work (2026-08-28) — CURRENT MODEL: canvas-size viewport + ALPHA-BBOX crop
|
||||
## The web-source rendering work (2026-08-28) — CURRENT MODEL: canvas-size viewport + alpha crop + container==content
|
||||
|
||||
**History of failures (see MyMistakes.md for the full log):** box-size rendering clipped full-bleed
|
||||
widgets to their upper-left chunk (fixed — page renders at the master canvas 1920×1080, stable, the
|
||||
one render the creator confirmed solid). Then four crop attempts failed in different ways: (1) the
|
||||
`JSON.stringify` return double-encoded under `ExecuteScriptAsync`, silently disabling the crop;
|
||||
(2) `scrollWidth/scrollHeight` at canvas size returns the whole viewport for full-canvas wrapper
|
||||
bodies → no trim (ghost boundary); (3) union-of-DOM-elements measured an unsettled layout on
|
||||
NavigationCompleted and BROKE the image (creator's "don't break the rendering" boundary crossed).
|
||||
(4) Reverting to f39ebd9's scroll-crop was another dead end (#2 again).
|
||||
**History of failures (see MyMistakes.md for the full log):**
|
||||
1. box-sized viewport clipped full-bleed widgets to their upper-left chunk → render at the master
|
||||
canvas 1920×1080 (stable), the only render the creator confirmed solid.
|
||||
2. `JSON.stringify` return double-encoded under `ExecuteScriptAsync` → crop silently disabled.
|
||||
3. `scrollWidth/scrollHeight` at canvas size = whole viewport for full-canvas wrapper bodies → no trim.
|
||||
4. DOM-element-union crop measured an unsettled layout on NavigationCompleted → BROKE the image.
|
||||
5. Alpha-bbox crop (from the frame itself) fixed the BITMAP but the grid/box stayed at the uncropped
|
||||
user size → Fill stretched the tight widget into a big frame → dead space between content and border.
|
||||
|
||||
**The CURRENT MODEL (this commit):**
|
||||
**The CURRENT MODEL (this change):**
|
||||
- `Services/WebView2Manager.cs` — page renders at 1920×1080 (stable, never tracked); `overflow:hidden`
|
||||
+ transparent-bg injection. `FindContentBounds` scans the Bgra32 capture per frame and crops to the
|
||||
bounding box of NON-TRANSPARENT pixels — the widget's true rendered extent, measured from the frame
|
||||
itself. No DOM query, no layout timing: it can never truncate visible content (worst case = full
|
||||
frame = the confirmed-good image). `Stretch="Fill"` maps the cropped frame flush under the selection
|
||||
box → the box hugs the widget on all four sides. `QueryContentBoundsAsync` + the JS script are
|
||||
DELETED.
|
||||
- `MainWindow.xaml` — web `<Image>` Stretch set to Fill via the IsWebSource DataTrigger (unchanged).
|
||||
- Invariant: **render at canvas size; crop to the alpha extent; Fill to the box.**
|
||||
- Unit tests: 3 new for `FindContentBounds` (tight box, no-alpha no-crop, full-alpha no-crop).
|
||||
+ transparent-bg injection. `FindContentBounds` crops the Bgra32 capture to the bounding box of
|
||||
non-transparent pixels each frame (immune to timing, can never truncate content). `ContentCanvasSize`
|
||||
maps the crop rect to CANVAS UNITS (DPI-correct). Preview event now carries (bitmap, canvasW, canvasH).
|
||||
- `ViewModels/MainViewModel.cs` — `OnWebView2PreviewBitmapChanged` sets the element's Width/Height to
|
||||
the cropped canvas size → the element grid AND the SelectionOverlay (both bound to element
|
||||
Width/Height) EQUAL the widget. `IsPreviewDragging` suppresses the auto-fit during a drag gesture.
|
||||
- `MainWindow.xaml.cs` — sets/clears `IsPreviewDragging` at drag/resize start and end.
|
||||
- Invariant: **render at canvas size; crop to the alpha extent; SIZE THE BOX to the crop.**
|
||||
- Unit tests: 10/10 (alpha bounds ×3, canvas-size mapping ×3, control size ×4).
|
||||
|
||||
**Property panel / sliders (2026-08-28):** web URI ✕ clears the textbox; web ✓/✕ icon buttons
|
||||
`IsTabStop="False"` so Tab walks X→Y→W→H→URI; Slider style `IsMoveToPointEnabled="True"`
|
||||
restores click-anywhere-on-bar. All three confirmed fixed by the creator.
|
||||
`IsTabStop="False"`; Slider style `IsMoveToPointEnabled="True"`. Confirmed fixed by the creator.
|
||||
|
||||
Build: 0 warnings; tests 7/7 (WebView2Manager). Rejected for the record: box-sized viewport (upper-left
|
||||
truncation), fixed 1920×1080 + `Uniform` (letterbox dead space), CSS margin/100% reset (enlarged gap),
|
||||
viewport==box (reflow/truncation/scrollbars), DOM-union crop (broke the image).
|
||||
Build: 0 warnings; tests 10/10. Rejected for the record: box-sized viewport, `Uniform`, CSS reset,
|
||||
viewport==box, DOM-union crop (broke image), crop-without-container-size (left the gap).
|
||||
|
||||
## Key facts / landmines
|
||||
|
||||
@@ -52,8 +50,8 @@ viewport==box (reflow/truncation/scrollbars), DOM-union crop (broke the image).
|
||||
- No `CODING.md`; conventions live in `AGENTS.md` + `ai.md`.
|
||||
|
||||
## Next steps
|
||||
1. AWAIT creator's verdict on the ALPHA-BBOX crop — reload a widget URL at several box sizes; the
|
||||
selection frame must snap flush to the widget with no dead space, image must stay identical for
|
||||
full-bleed widgets. If an animated widget causes visible jitter, add crop hysteresis as a follow-up.
|
||||
2. Follow-up only if the creator asks: graceful handling of navigation errors / invalid URIs (TASK 17 ×9).
|
||||
1. AWAIT creator's verdict on the container==content auto-fit — reload a widget; the selection frame
|
||||
must equal the widget exactly (no dead space, including during resize). Follow-ups only if asked:
|
||||
crop hysteresis for animated widgets, ticker/percent-display widgets.
|
||||
2. Graceful handling of navigation errors / invalid URIs (TASK 17 ×9) — only if the creator asks.
|
||||
3. Continue queue: TASK 18 local recording, TASK 21 media source, TASK 22 audio sync offset.
|
||||
Reference in New Issue
Block a user