Commit 95ffad7
committed
fix(css): resolve em against the element font-size
build() (layout_pass.rs:122-154) hands the *same* ConversionContext to
to_taffy_style for every node in the tree and never re-derives it from the
node's own (cascaded) font-size, and the only production builder keeps
..LengthContext::default() → font_size: 16.0 (scene.rs:29-37). So padding:
"1em", gap: "0.5em", width: "10em", top: "2em" all resolve against 16px
regardless of the element's actual font size: on a 48px-font card, padding:
"1em" reserves 16px instead of 48px. Unlike the context-free .px() accessors
— which were deliberately made to warn loudly for exactly this class of drop
(units.rs:240-256) — this path is silent, so the wrong geometry reaches both
the renderer and the validator with no signal.
Fix: Derive a per-node LengthContext while building the taffy tree: resolve
the node's own font-size (post-cascade) to px and pass it as
ctx.length.font_size to its own to_taffy_style call and to its children's.
Until that exists, emit the same one-shot warning order already uses
(taffy_bridge.rs:142-151) whenever an em reaches this bridge.
Refs #2201 parent 3a156c2 commit 95ffad7
2 files changed
Lines changed: 78 additions & 9 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
6 | 6 | | |
7 | 7 | | |
8 | 8 | | |
| 9 | + | |
9 | 10 | | |
10 | 11 | | |
11 | 12 | | |
| |||
85 | 86 | | |
86 | 87 | | |
87 | 88 | | |
88 | | - | |
| 89 | + | |
89 | 90 | | |
90 | 91 | | |
91 | 92 | | |
| |||
119 | 120 | | |
120 | 121 | | |
121 | 122 | | |
| 123 | + | |
| 124 | + | |
| 125 | + | |
| 126 | + | |
| 127 | + | |
| 128 | + | |
| 129 | + | |
| 130 | + | |
| 131 | + | |
| 132 | + | |
| 133 | + | |
122 | 134 | | |
123 | 135 | | |
124 | 136 | | |
125 | 137 | | |
126 | 138 | | |
| 139 | + | |
127 | 140 | | |
128 | | - | |
| 141 | + | |
| 142 | + | |
| 143 | + | |
| 144 | + | |
| 145 | + | |
| 146 | + | |
| 147 | + | |
| 148 | + | |
| 149 | + | |
| 150 | + | |
| 151 | + | |
| 152 | + | |
| 153 | + | |
| 154 | + | |
| 155 | + | |
129 | 156 | | |
130 | 157 | | |
131 | 158 | | |
132 | 159 | | |
133 | | - | |
134 | | - | |
135 | | - | |
136 | | - | |
137 | | - | |
| 160 | + | |
138 | 161 | | |
139 | 162 | | |
140 | 163 | | |
141 | 164 | | |
142 | 165 | | |
143 | | - | |
| 166 | + | |
144 | 167 | | |
145 | 168 | | |
146 | 169 | | |
147 | 170 | | |
148 | | - | |
149 | 171 | | |
150 | 172 | | |
151 | 173 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
| 1 | + | |
| 2 | + | |
| 3 | + | |
| 4 | + | |
| 5 | + | |
| 6 | + | |
| 7 | + | |
| 8 | + | |
| 9 | + | |
| 10 | + | |
| 11 | + | |
| 12 | + | |
| 13 | + | |
| 14 | + | |
| 15 | + | |
| 16 | + | |
| 17 | + | |
| 18 | + | |
| 19 | + | |
| 20 | + | |
| 21 | + | |
| 22 | + | |
| 23 | + | |
| 24 | + | |
| 25 | + | |
| 26 | + | |
| 27 | + | |
| 28 | + | |
| 29 | + | |
| 30 | + | |
| 31 | + | |
| 32 | + | |
| 33 | + | |
| 34 | + | |
| 35 | + | |
| 36 | + | |
| 37 | + | |
| 38 | + | |
| 39 | + | |
| 40 | + | |
| 41 | + | |
| 42 | + | |
| 43 | + | |
| 44 | + | |
| 45 | + | |
| 46 | + | |
| 47 | + | |
0 commit comments