Web source: crop to the widget's true content rect (union of visible body elements) — bounding box tight on all four sides, pinned to (0,0)
- QueryContentBoundsAsync now returns a real JS object (not JSON.stringify — ExecuteScriptAsync double-encodes strings, which silently killed the old crop) and measures the union of every visible body element's getBoundingClientRect: the widget's actual rect, top-left offset included. - CaptureFrame crops AT that offset (x,y) instead of from (0,0), so the widget anchors at origin and the box is flush on right/bottom. Fill maps the frame flush under the box.
This commit is contained in:
+17
-16
@@ -8,23 +8,24 @@ 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 + content crop
|
||||
|
||||
**Root cause finally isolated:** hosting the page at the ELEMENT-box size clips full-bleed widgets
|
||||
(designed for ~1920×1080) to their upper-left chunk inside a small viewport — "image truncated to
|
||||
the upper-left corner regardless of scaling." That truncation persisted across every earlier
|
||||
model because all of them rendered the page at the box (or a mix); e917c41's full 1920×1080
|
||||
render was the only one that showed full content, and its letterbox dead space was purely the
|
||||
display `Uniform` + the box aspect mismatch — not the render.
|
||||
**Root causes finally isolated:** (1) hosting the page at the element-box size clips full-bleed
|
||||
widgets to their upper-left chunk (fixed — page now renders at the master canvas 1920×1080,
|
||||
stable). (2) The content-bounds crop that was supposed to kill right/bottom dead space never ran:
|
||||
the script returned `JSON.stringify(...)` (a string), and `ExecuteScriptAsync` JSON-encodes the
|
||||
result, so `JsonDocument.Parse` hit a string node and `GetProperty` threw → bounds stayed unset →
|
||||
no crop. ALSO the intended measure was wrong: scroll extents ≠ widget rect (they include the
|
||||
page's own margins). Fixed together: the script now returns a real OBJECT (union of every visible
|
||||
`body *` `getBoundingClientRect`), giving the widget's true rect INCLUDING its top-left offset,
|
||||
and `CaptureFrame` crops AT that offset — so the widget anchors at (0,0) and the box is tight on
|
||||
all four sides. `Stretch="Fill"` maps it flush under the box. Creator confirmed render+resize are
|
||||
solid at the canvas-size change; this commit delivers the tight/0,0 bounding box.
|
||||
|
||||
**The model (implemented, visual verification pending):**
|
||||
- `Services/WebView2Manager.cs` — page renders at the MASTER CANVAS size (1920×1080), stable,
|
||||
never tracked: full-bleed widgets render FULL (no upper-left truncation); dragging the box never
|
||||
reflows the page; `overflow:hidden` (html+body) + transparent-bg injection. After each nav
|
||||
`QueryContentBoundsAsync` reads the page's real content rect
|
||||
(`scrollWidth/scrollHeight` vs `innerWidth/innerHeight`) and `CaptureFrame` **crops to the
|
||||
actual content bounds anchored at (0,0)**. Immediate capture on `NavigationCompleted`.
|
||||
- `MainWindow.xaml` — web `<Image>` `Stretch="Fill"`: the cropped 1920×1080 frame maps flush under
|
||||
the box (Box == widget bounds at every size, pinned (0,0), no dead space).
|
||||
- Invariants: **render at canvas size; crop to content; Fill to box.**
|
||||
**The CURRENT MODEL:**
|
||||
- `Services/WebView2Manager.cs` — page renders at 1920×1080 (stable); `overflow:hidden` +
|
||||
transparent-bg injection; `QueryContentBoundsAsync` measures real widget bounds (object return
|
||||
from JS, NOT JSON.stringify); `CaptureFrame` crops at the widget's (x,y) offset → anchored 0,0.
|
||||
- `MainWindow.xaml` — web `<Image>` `Stretch="Fill"`.
|
||||
- Invariant: **render at canvas size; crop to the widget's true bounds; Fill to the box.**
|
||||
|
||||
**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"`
|
||||
|
||||
Reference in New Issue
Block a user