Web source: geometry-agnostic viewport==box model — viewport locked to element box, Stretch=Fill, no dead space
This commit is contained in:
@@ -917,18 +917,15 @@ 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, the fix that works):** WebView2 viewport is FIXED at the master
|
||||
canvas size (1920×1080) in `Register`, never tracking the element box — the OBS/CEF pattern
|
||||
(fixed render viewport, display box scaled independently via `Stretch="Uniform"`). Capturing the
|
||||
box-sized viewport was the truncation bug. Display `Stretch`: web → `Uniform` (no crop),
|
||||
everything else → `UniformToFill`. Graceful-error handling (item 9) is a follow-up.
|
||||
|
||||
**Box-vs-content padding (2026-08-28):** whitespace gaps between the bounding box and the web
|
||||
content were the page's own UA margins/padding + body sizing to content instead of the viewport.
|
||||
Fixed by injecting a CSS reset into every document via
|
||||
`CoreWebView2.AddScriptToExecuteOnDocumentCreatedAsync` (margin/padding 0, html/body 100% of
|
||||
viewport, overflow hidden, transparent bg) and anchoring the web `<Image>` at (0,0)
|
||||
(`HorizontalAlignment/VerticalAlignment=Left/Top`) inside the element box.
|
||||
**Rendering model (2026-08-28, geometry-agnostic — supersedes the earlier fixed-viewport model):**
|
||||
the WebView2 viewport IS the element box (`Source.Width × Source.Height`); the page renders at
|
||||
exactly the box size and the captured frame is displayed with `Stretch="Fill"`, so the selection
|
||||
rect always bounds the actual rendered content — no fixed render size, no aspect assumptions,
|
||||
no dead space/padding for any widget geometry. A `PropertyChanged` hook keeps the viewport
|
||||
locked to the box; capture is re-triggered on resize. Graceful-error handling (item 9) is a
|
||||
follow-up. Earlier attempts for the record: (a) fixed 1920×1080 viewport + `Stretch="Uniform"`
|
||||
fixed the truncation but left box-vs-content gaps (box aspect ≠ capture aspect); (b) CSS reset
|
||||
injection made gaps larger (belayed by creator).
|
||||
|
||||
### Design decisions
|
||||
|
||||
|
||||
Reference in New Issue
Block a user