Repository navigation
#27: an SVG <text>, <image> and <title> keep their SVG attribute names - #35
Conversation
Codex Review Summary: ✅ CompletedThis comment shows the latest Codex review activity on this pull request.
ℹ️ About Codex in GitHubYour team has set up Codex to review pull requests in this repo. Reviews are triggered when you
Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings. |
shinyobjectz
left a comment
There was a problem hiding this comment.
Thank you, @JimGHTB12. This is a careful fix with a clear write-up, and the before/after tables made it easy to follow.
I read through it, and the approach is right:
IN_SVGis set and restored around each subtree, and reset insyncwith the others.foreignObjectswitches back to HTML, and an<svg>inside it starts SVG again.$ns: "svg"goes only on the three tagsin_svgleaves out, matching what sdk/ui's host sends.- On update, ops.rs also accepts a node created in SVG's namespace, which fixes the animated
fontSizefor sdk/ui too. - The frame-to-frame test through
Tree::diffandops::applyis a good regression test, and moving it into raea-runtime-page was the right call.
One small change is needed before it can merge. It comes from main moving under you, not from your code. Two fixes landed today (22074b5 and 30960ed) and each added a line to raea-sys-page, which is now at exactly 2,000 lines on main. Merged onto main, this PR's ops.rs change (+2 −1) takes the crate to 2,001, so tools/size.sh refuses it. Could you rebase onto main and keep that hunk at net zero? For example, put the comment at the end of the line:
let svg = in_svg(kind) || m.element_name(n).is_some_and(|q| q.ns == ns!(svg)); // a text, image or title made in SVG's namespace (`$ns` at its create)Once it's updated, I'll run the tests and #27's repro, including the animated fontSize case, on macOS and approve.
|
An update to my review, @JimGHTB12: please ignore what I said about shaving a line to fit raea-sys-page under its 2000-line limit. The crate reached that limit through our own landings today, so making room is our job, not yours. Sorry for the churn. We're splitting the crate on our side. Your branch edits Thanks again for the fix, and for the clear write-up on #27. |
…tems/page-ops): ops.rs and ops/attrs.rs moved whole, with ALL_DAMAGE, which they mark damage with. raea-sys-page re-exports it as `ops` (and ALL_DAMAGE), so every raea_sys_page::ops path reads as before. raea-sys-page had reached 2000 lines through the day's landings, so a fix in it (PR #35, #37's next) had no room; it's 1424 now. No code changed: the moved tests pass (cargo test -p raea-sys-page-ops) and raea-sys-page checks with its tests.
…tribute names The composition walk never said `$ns: "svg"` for the three SVG tags HTML also has, so inside an <svg> they became HTML elements and their camelCase attributes were lowercased (textAnchor to textanchor, fontSize to fontsize), which usvg doesn't know. The walk now tracks whether it is inside an <svg> and not back in HTML under a <foreignObject> (IN_SVG, beside IN_3D), and gives those three `$ns: "svg"` there, as sdk/ui's host does. An update in ops.rs also treats a node as SVG's when its element is in SVG's namespace, so an animated fontSize keeps `font-size` on every frame, on sdk/ui's path too. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…ugh the frame diff raea-sys-page is at its 2000-line limit (tools/size.sh), so the test of an SVG <text>'s attribute names leaves ops.rs. In raea-runtime-page it takes the path a composition's frames take: the walk's Wants (the <text> with `$ns`), then Tree::diff, whose second frame sends only the changed fontSize and textAnchor, then ops::apply. It fails without the ops.rs change: the update adds fontsize and textanchor beside the stale font-size. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
1ed49d6 to
07908a4
Compare
shinyobjectz
left a comment
There was a problem hiding this comment.
Approved. Thank you, @JimGHTB12. Your diagnosis in #27 was exact, and the fix is just what you proposed.
Rebase. I rebased the branch onto main after our crate split (fd4d06c). Your two commits keep your authorship and their messages unchanged.
- Your
ops.rschange carried over by itself intosystems/page-ops/src/lib.rs. - The only conflict was in
elements.rs, where #28 had changedmedia_urlsand its doc comment above your new functions. I kept both sides.
Checks
cargo test -p raea-runtime-page -p raea-sys-page-ops -p raea-sys-pagepasses.- Mutation check: with the namespace check in
applyreverted,an_svg_texts_attributes_keep_their_svg_names_from_frame_to_framefails, as it should. - Your repro, rendered on macOS (black ink's x extent and height):
| before | with this PR | |
|---|---|---|
| Start | 321 to 353, 12 px | 322 to 420, 36 px |
| Middle | 321 to 365, 12 px | 253 to 388, 36 px |
| End | 321 to 346, 12 px | 238 to 316, 36 px |
These match your kebab-case column.
- Animated case: one
<text>going fromfontSize24 withtextAnchor="start"on frame 0 to 60 with"end"on frame 1, so frame 1's change arrives through the frame diff.- Before: both frames stuck at 12 px, starting at x=321.
- With this PR: frame 0 is 322 to 389 (17 px), and frame 1 is 147 to 317 (44 px), ending left of the x=320 anchor.
A note, not a blocker. The frame-diff test writes $ns into its own input, so the page.insert("$ns", ...) line in the walk is covered only through svg_owned's logic. The renders above cover it end to end. A later test could go through the walk itself.
We'll merge it with a merge commit, so your commits show in history. Thanks again.
…he walk (part of #27). It handed Tree::diff a frame written by hand with `$ns` already in it, so nothing tested the walk giving it: with elements.rs's `page.insert("$ns", "svg")` taken out, every test still passed. The test now builds the React tree a composition's commit leaves (a <text> in an <svg>, and a <title> under its <foreignObject>), walks it on each of two frames as BevyPage does, and sends the walk's wants through Tree::diff to ops::apply. It checks that the <text> has `$ns` and the HTML <title> doesn't, and that the second frame's fontSize and textAnchor keep their SVG names. With the insert taken out, it now fails at "the walk names the <text> SVG's". world.rs's walk (a plain App's page) now also starts from IN_3D 0 and IN_SVG false, as BevyPage's does.
…ch shot its own <Camera3d>, switched with is_active; a cut is one render, its first frame drawn as a shot alone starts) and 3d/limits.md is regenerated from raea's guide (raea-skills #35, for RR2)
In a composition, an SVG
<text>losttextAnchorandfontSize, and<image>and<title>lost their camelCase attributes the same way. Closes #27.Why
in_svgleavestext,imageandtitleout, because HTML has those tags too. For those three, sdk/ui's host says the namespace with$ns: "svg". The composition walk never did, so they became HTML elements, andtextAnchorandfontSizewere lowercased to attributes usvg doesn't know. On an update,systems/page/src/ops.rsdecided SVG-ness byin_svg(kind)alone, so an animatedfontSizewas lowercased on every path, sdk/ui's included.Change
runtime/page. The walk tracks whether it is inside an<svg>, and not back in HTML under a<foreignObject>, inIN_SVGbesideIN_3D.BevyPage::syncresets it with the others. Atext,imageortitlemet there gets$ns: "svg", as sdk/ui's host gives it. The rule is two small functions inelements.rs,svg_insideandsvg_owned.systems/page/src/ops.rs. An update treats a node as SVG's when its element is in SVG's namespace, as well as whenin_svg(kind)says so.Testing
cargo test -p raea-runtime-page --lib -- svg_namespacepasses, with two tests:an_svg_texts_attributes_keep_their_svg_names_from_frame_to_frametakes a composition's path: the walk'sWants with the<text>carrying$ns, thenTree::diff, thenops::apply. Its second frame changesfontSizeandtextAnchor, so the diff sends only those. Without theops.rschange it fails: the update addsfontsize="60"andtextanchor="end"beside the stalefont-size="48". It lives here, not inraea-sys-page, because that crate is at its 2,000-line limit.text_image_and_title_are_svgs_only_inside_an_svgcovers the scope rule: inside an<svg>, under a<foreignObject>, and an<svg>inside that<foreignObject>.tools/size.shpasses on this branch merged withmain, andlayers.sh,names.sh,one-version.shandno-void.shpass on the branch.The repro from #27, camelCase, at x=320. This branch now draws exactly what kebab-case drew on canary.2:
The animated case: one
textAnchor="middle"line whosefontSizegoes from 24 to 72 over 30 frames, rendered as a sequence so every frame after the first is an update:fontSize)On this branch every frame is centred on x=320, and the height follows
fontSize.Only Windows was run.
<image>and<title>take the same rule and are covered by the unit tests, not by a render.🤖 Generated with Claude Code