Repository navigation
feat(web): add display-only El::web_image for cross-origin raster images - #2637
Merged
Merged
Conversation
Hona
force-pushed
the
feat/web-image-display-only
branch
from
November 27, 2026 15:18
0a0a6f9 to
7e7b206
Compare
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
Adds opt-in display-only
El::web_imageandEl::web_image_fitso Rune apps on web can display cross-origin raster images whose servers omit CORS headers, without reading pixels or bypassing browser cross-origin restrictions.crates/rune/src/web_image.rs):El::web_image(url)andEl::web_image_fit(url, fit)accept validatedhttp:,https:, and relative URLs (rejectingjavascript:,mailto:,file:,data:, and scheme-relative//...), combine withEl::radius,El::corners,El::border,El::fill(drawn underneath on canvas as a loading/error/transparency backdrop),El::opacity,El::layer_opacity,El::rotate,El::surface_anchor,El::surface_unscaled, andEl::image_filter(ImageFilter::Nearest).crates/rune/src/runtime/paint/web_image.rs): Records visibleWebImageDrawentries in CSS pixels on every built frame (bypassingPaintKeepandEl::cache()elision), inset inside visible borders, with exact rectangular clips, enclosing rounded clips (El::clip_rounded/El::clip_corners), rotated 2D CSS affine matrices, UI zoom, andApp::web_documentdocument coordinates. Also emits<img>in--htmlstatic export and exposesRuntime::web_images()for inspection and tests.crates/rune/src/platform/web/bridge.js,web_images.rs): Lazily mounts[data-rune-web-images]above the canvas and directly before[data-rune-a11y](pointer-events: none,aria-hidden="true", never settingcrossOrigin), reuses<img>elements by stableNodeIdacross scroll/animation/clip changes without reassigningsrc, nests clip wrappers, followsApp::web_documentheight and mobile keyboard shift, and cleans up on empty sync ordestroy.WEB.md): ExistingImageCache::url+El::pixelsis unchanged; because the DOM<img>layer sits above the canvas, canvas-drawn popovers/overlays and shaders cannot composite over aweb_image.Fixes #1667
Verification
cargo test -p rune web_image(7 passed)cargo test -p rune --lib export::tests(13 passed)cargo check-wasm(WebGPUwasm32-unknown-unknown) andcargo check-webgl(WebGL2wasm32-unknown-unknown)node --test crates/rune/src/platform/web/bridge.test.mjs(80 passed, including newsyncWebImagesDOM/clip/reuse/document-mode tests)Access-Control-Allow-Origin.