Repository navigation
feat(engine): re-render an iframe after a parent mutates it via contentDocument - #434
Merged
Merged
Conversation
…ntDocument Round 41's own last disclosed limitation: the iframe's pixels were already composited into the parent page before any parent script ran, and nothing afterward ever looked again. A new refreshIframeImages (iframe.go) mirrors the existing refreshCanvasImages exactly: after the parent's settle loop finishes, walk every already-loaded iframe and re-paint its CURRENT tree into the same maps the final composite reads. Deliberately does NOT re-run the nested document's own JavaScript -- a copy of Engine with DisableJS forced on gives cascade->layout->paint of the tree exactly as it now stands. Verified both ways with a nested script sharing this engine's own JSLog callback: removing the DisableJS guard logs it twice, restoring it logs exactly once. A new dom.Node.IframeURL field carries the nested document's own base URL forward so a relative resource inside it still resolves on re-render. Also fixes a stray double blank line in js/dom.go, introduced by the previous round's own edit and missed at the time (gofmt -l . now clean of it). Fixes #433 Co-Authored-By: Claude Sonnet 5 <[email protected]>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Round 41's own last disclosed limitation (Refs #431, already closed; cited for context only): the iframe's pixels were already composited into the parent page before any parent script ran, and nothing afterward ever looked again.
A new
refreshIframeImages(iframe.go) mirrors the existingrefreshCanvasImagesexactly: after the parent's settle loop finishes, walk every already-loaded<iframe>and re-paint its CURRENT tree (n.IframeDoc, whatever a parent script'scontentDocumentaccess left it as) into the sameimgSize/imgsmaps the final composite reads.Deliberately does NOT re-run the nested document's own JavaScript — a real correctness hazard checked directly, not assumed safe: a copy of
EnginewithDisableJSforced on gives cascade→layout→paint of the tree exactly as it now stands. Verified both ways with a nested<script>console.log(...)</script>, since its output shares this engine's singleJSLogcallback with the parent's own: removing theDisableJSguard logs it twice; restoring it logs exactly once.A new
dom.Node.IframeURLfield (set alongsideIframeDoc) carries the nested document's own base URL forward into the refresh, so a relative resource inside it still resolves correctly on re-render.Also fixed: a stray double blank line in
js/dom.go, introduced by the previous round's own edit and missed at the time (gofmt -l .now clean of it).Fixes #433.
Test plan
go build ./... && go vet ./... && gofmt -l .cleango vet -tags "webengine_nojs webengine_nonet webengine_fontsext" . ./paint/...cleango test ./...full suite greengovulncheck ./...cleancontentDocument.body.style.backgroundmutation lands in the final rendered pixels; a nested script's ownconsole.logfires exactly once, not twice, after the refreshrefreshIframeImagescall reproduces the exact stale-colour symptom; removingDisableJSreproduces the exact double-log symptom🤖 Generated with Claude Code