Bump blitz to 0.3.0-alpha.4; add DataUrlNetProvider for @font-face; expose StyleThreading#1
Open
HenriqueAnzoategui wants to merge 1 commit into
Open
Conversation
…ading Three pieces, all needed for hyper-render to be usable in concurrent embedder contexts (servers rendering documents per request via `tokio::task::spawn_blocking`, batch pre-renderers, etc.): 1. Bump `blitz-* = "=0.3.0-alpha.4"` (was `0.2`). Companion bumps: `anyrender 0.10`, `anyrender_vello_cpu 0.12.1`, and the PDF-feature deps `krilla 0.7`, `stylo 0.17`, `parley 0.9`. `stylo` MUST match blitz's pin (links = "servo_style_crate"). MSRV is now 1.92 per the new vello stack. `render_to_png` and `render_to_pdf` now take `&mut HtmlDocument` — `blitz_paint::paint_scene` requires a mutable document reference as of alpha.4. 2. New `DataUrlNetProvider` (src/net.rs) — an in-process `NetProvider` resolving `data:` URIs synchronously. blitz-dom otherwise falls back to `DummyNetProvider`, which silently drops every embedded asset — that's the historical "system fonts only" / "@font-face not yet supported" limitation. With this provider wired in, `@font-face { src: url(data:font/...) }` and inline base64 images load correctly. Non-`data:` URLs are still ignored; hyper-render does no real network I/O. 3. New `Config.style_threading: StyleThreading` field that forwards to `DocumentConfig.style_threading` (introduced in blitz-dom 0.3.0-alpha.4 via DioxusLabs/blitz#437). Defaults to `StyleThreading::Parallel`, matching blitz's default — no behavior change for existing callers. Pass `StyleThreading::Sequential` when invoking `render` from multiple OS threads concurrently. Stylo's `STYLE_THREAD_POOL` is process-global; two `Parallel` resolves that share a rayon worker can panic on the worker's thread-local sharing cache (`already mutably borrowed`). `Sequential` bypasses the global pool at the `traverse_dom` call site at the cost of intra-render style parallelism (negligible at typical hyper-render document sizes). `StyleThreading` is mirrored as a hyper-render-owned enum (same pattern as `ColorScheme`) with a `From` impl for the blitz type, so the public API doesn't leak `blitz_dom` types. Tests ----- - 4 unit tests in `src/net.rs` for `DataUrlNetProvider`: base64, percent-encoded, non-`data:` ignored, binary payload round-trip. - `tests/font_face.rs` (new): renders HTML containing `@font-face { src: url(data:font/otf;base64,...) }` and asserts a valid PNG comes out. - Doctest on the new `style_threading` builder method. Local verification ------------------ - `cargo fmt --all --check` - `cargo clippy --no-default-features --features png --all-targets -- -D warnings` - `cargo test --no-default-features --features png` (15 tests pass) - `cargo check --no-default-features --features pdf`
07cf5a1 to
9edbb75
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
Three pieces, all needed for hyper-render to work against the current blitz release and to be usable in concurrent embedder contexts (servers rendering documents per request via
tokio::task::spawn_blocking, batch pre-renderers, etc.):Bump
blitz-* = "=0.3.0-alpha.4"(was0.2). Companion bumps:anyrender 0.10,anyrender_vello_cpu 0.12.1, and the PDF-feature depskrilla 0.7,stylo 0.17,parley 0.9.styloMUST match blitz's pin (links = "servo_style_crate"). MSRV is now Rust 1.92.render_to_pngandrender_to_pdfnow take&mut HtmlDocument—blitz_paint::paint_scenerequires a mutable document reference as of alpha.4.DataUrlNetProviderinsrc/net.rs— an in-processNetProviderresolvingdata:URIs synchronously. Without it, blitz-dom falls back toDummyNetProvider, which silently drops every embedded asset — that's the historical "system fonts only" / "@font-face not yet supported" limitation. With it,@font-face { src: url(data:font/...) }and inline base64 images load correctly. Non-data:URLs are still ignored; hyper-render does no real network I/O.New
Config.style_threading: StyleThreadingfield that forwards toDocumentConfig.style_threading(introduced in blitz-dom 0.3.0-alpha.4 viadioxuslabs/blitz#437). Defaults toStyleThreading::Parallel, matching blitz's default — no behavior change for existing callers. PassStyleThreading::Sequentialto disable Stylo's global thread pool and makerendersafe to invoke from many OS threads concurrently.StyleThreadingis mirrored as a hyper-render-owned enum (same pattern asColorScheme) with aFromimpl for the blitz type, so the public API doesn't leakblitz_domtypes.Changes
Cargo.toml— dep version bumps.src/net.rs(new) —DataUrlNetProvider.src/config.rs—StyleThreadingenum + field onConfig+ builder method.src/lib.rs— wires the net provider and the style-threading field through toDocumentConfigincreate_document; flipsrender_to_png/render_to_pdfto&mutfor the new paint_scene signature.src/render/png.rs/pdf.rs—&mut HtmlDocumentanddocument.as_mut()for paint_scene.tests/font_face.rs(new) — integration test for@font-facewithdata:URI.README.md/CLAUDE.md— lift the@font-face not yet supportedbullet.CHANGELOG.md—0.3.0entry.Tests
src/net.rsforDataUrlNetProvider: base64, percent-encoded, non-data:ignored, binary payload round-trip.tests/font_face.rs: renders HTML with@font-face { src: url(data:font/otf;base64,...) }and asserts a valid PNG comes out.style_threadingbuilder method.Verified locally
cargo fmt --all --check✓cargo clippy --no-default-features --features png --all-targets -- -D warnings✓cargo test --no-default-features --features png✓ (15 passed)cargo check --no-default-features --features pdf✓