Commit d9dfeb1
authored
fix(rtl-tables): drop double-mirror for logical cell margins (SD-3134) (#3272)
* fix(rtl-tables): drop double-mirror for logical cell margins (SD-3134)
Two paths needed alignment with the borders fix from #3227:
1. getTableCellMargins (super-converter) only iterated left/right/top/bottom,
so inline w:tcMar/w:start and w:end never projected to top-level
cellMargins. Extend the iteration to add marginStart/marginEnd, preserving
the OOXML logical names.
2. convertCellMarginsToPx (pm-adapter table-styles) still pre-swapped
marginStart/marginEnd for RTL via an isRtlTable param. DomPainter already
mirrors padding for bidiVisual tables, so the table-style hydration path
was double-mirroring. Remove the pre-swap and the param; pm-adapter now
stores logical start/end LTR-default. Same rule the borders fix encodes:
importer/style-engine preserve OOXML logical names, pm-adapter maps
logical to LTR-default physical, DomPainter performs the single visual
RTL mirror.
Flip the bad RTL unit test that was locking in the swap. Unfixme the
behavior regression test at tests/behavior/tests/tables/
rtl-bidivisual-asymmetric.spec.ts.
Verified:
- pm-adapter tests: 201 pass (table-styles + borders + table)
- super-converter tests: 2889 pass
- Playwright RTL bidiVisual asymmetric spec: 12 pass across
chromium/firefox/webkit (tcMar test now passes for real, no fixme)
* fix(rtl-tables): resolve tcMar precedence over table-level defaults (SD-3134)
Follow-up to the original fix in this PR. A second-round review caught a
case the original change still got wrong: when a table has tblCellMar
with physical w:left/w:right defaults and a cell has inline tcMar with
logical w:start/w:end, the cell-level exception was silently dropped.
Root cause: the importer stored physical defaults in result.left/right
and logical inline values in result.marginStart/marginEnd. Downstream
extractCellPadding gave physical precedence (padding.left was already
non-null), so the inline w:start/w:end never reached the painter.
Per ECMA-376 section 17.4.68: "This setting [tcMar], if present, shall
override the table cell margins from the table-level cell margins".
Rewrite getTableCellMargins to resolve precedence inside the importer:
cell-level inline (physical or logical) wins over table-level defaults
(physical or logical). Output is a single physical-shaped object with
LTR-default semantic; DomPainter still owns the visual RTL mirror.
Verified with a Word-native fixture (table-level w:tblCellMar w:left=40
and w:right=40 plus cell-level w:tcMar w:start=480 and w:end=60) loaded
in the dev app:
- before: paddingLeft=2.667, paddingRight=2.667 (table defaults; bug)
- after: paddingLeft=32, paddingRight=4 (cell exception; correct)
Tests:
- pm-adapter: 213 pass
- super-converter: 2889 pass
- behavior spec rtl-bidivisual-asymmetric: 15 pass across chromium /
firefox / webkit (new precedence test + 4 existing ones)
* refactor(rtl-tables): drop dead defensive branch + freshen test comment
Comment-audit follow-up on SD-3134:
- readMargin had a defensive branch for a nested { value: { value, type } }
shape, but no super-converter or layout-engine translator emits that
shape. Per CLAUDE.md (do not add error handling for scenarios that
cannot happen) the branch and its vague "some translators emit" comment
are removed.
- The regression note on the round-1 tcMar behavior test described the
round-1 importer output (marginStart/marginEnd keys), which no longer
matches the round-2 output (resolved physical left/right). Refreshed
so future agents do not look for keys that no longer exist.
No behavior change. Tests still pass.1 parent 33b66e8 commit d9dfeb1
5 files changed
Lines changed: 145 additions & 68 deletions
File tree
- packages
- layout-engine/pm-adapter/src/converters
- super-editor/src/editors/v1/core/super-converter/v3/handlers/w/tc/helpers
- tests/behavior/tests/tables
- fixtures
Lines changed: 7 additions & 4 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
330 | 330 | | |
331 | 331 | | |
332 | 332 | | |
333 | | - | |
| 333 | + | |
334 | 334 | | |
335 | 335 | | |
336 | 336 | | |
| |||
354 | 354 | | |
355 | 355 | | |
356 | 356 | | |
357 | | - | |
358 | | - | |
359 | | - | |
| 357 | + | |
| 358 | + | |
| 359 | + | |
| 360 | + | |
| 361 | + | |
| 362 | + | |
360 | 363 | | |
361 | 364 | | |
Lines changed: 8 additions & 11 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
35 | 35 | | |
36 | 36 | | |
37 | 37 | | |
38 | | - | |
39 | 38 | | |
40 | 39 | | |
41 | 40 | | |
42 | 41 | | |
43 | 42 | | |
44 | 43 | | |
45 | 44 | | |
46 | | - | |
| 45 | + | |
47 | 46 | | |
48 | 47 | | |
49 | 48 | | |
| |||
99 | 98 | | |
100 | 99 | | |
101 | 100 | | |
102 | | - | |
103 | | - | |
104 | | - | |
105 | | - | |
| 101 | + | |
106 | 102 | | |
107 | 103 | | |
108 | 104 | | |
| |||
163 | 159 | | |
164 | 160 | | |
165 | 161 | | |
166 | | - | |
| 162 | + | |
167 | 163 | | |
168 | 164 | | |
169 | | - | |
170 | | - | |
| 165 | + | |
| 166 | + | |
| 167 | + | |
171 | 168 | | |
172 | 169 | | |
173 | 170 | | |
| |||
177 | 174 | | |
178 | 175 | | |
179 | 176 | | |
180 | | - | |
181 | | - | |
| 177 | + | |
| 178 | + | |
182 | 179 | | |
183 | 180 | | |
184 | 181 | | |
| |||
Lines changed: 46 additions & 13 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
287 | 287 | | |
288 | 288 | | |
289 | 289 | | |
290 | | - | |
291 | | - | |
292 | | - | |
293 | | - | |
294 | | - | |
295 | | - | |
296 | | - | |
297 | | - | |
298 | | - | |
299 | | - | |
| 290 | + | |
| 291 | + | |
| 292 | + | |
| 293 | + | |
| 294 | + | |
| 295 | + | |
| 296 | + | |
| 297 | + | |
| 298 | + | |
| 299 | + | |
| 300 | + | |
| 301 | + | |
| 302 | + | |
| 303 | + | |
| 304 | + | |
| 305 | + | |
| 306 | + | |
| 307 | + | |
| 308 | + | |
| 309 | + | |
| 310 | + | |
| 311 | + | |
| 312 | + | |
| 313 | + | |
| 314 | + | |
| 315 | + | |
| 316 | + | |
| 317 | + | |
| 318 | + | |
| 319 | + | |
| 320 | + | |
| 321 | + | |
| 322 | + | |
| 323 | + | |
| 324 | + | |
| 325 | + | |
| 326 | + | |
| 327 | + | |
| 328 | + | |
| 329 | + | |
| 330 | + | |
| 331 | + | |
300 | 332 | | |
301 | | - | |
| 333 | + | |
302 | 334 | | |
303 | | - | |
304 | | - | |
| 335 | + | |
| 336 | + | |
| 337 | + | |
305 | 338 | | |
Binary file not shown.
Lines changed: 84 additions & 40 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
97 | 97 | | |
98 | 98 | | |
99 | 99 | | |
100 | | - | |
101 | | - | |
102 | | - | |
103 | | - | |
104 | | - | |
105 | | - | |
106 | | - | |
107 | | - | |
108 | | - | |
109 | | - | |
110 | | - | |
111 | | - | |
112 | | - | |
113 | | - | |
114 | | - | |
115 | | - | |
116 | | - | |
117 | | - | |
118 | | - | |
119 | | - | |
120 | | - | |
121 | | - | |
122 | | - | |
123 | | - | |
124 | | - | |
125 | | - | |
126 | | - | |
127 | | - | |
128 | | - | |
129 | | - | |
130 | | - | |
131 | | - | |
132 | | - | |
133 | | - | |
134 | | - | |
135 | | - | |
136 | | - | |
137 | | - | |
138 | | - | |
139 | | - | |
| 100 | + | |
| 101 | + | |
| 102 | + | |
| 103 | + | |
| 104 | + | |
| 105 | + | |
| 106 | + | |
| 107 | + | |
| 108 | + | |
| 109 | + | |
| 110 | + | |
| 111 | + | |
| 112 | + | |
| 113 | + | |
| 114 | + | |
| 115 | + | |
| 116 | + | |
| 117 | + | |
| 118 | + | |
| 119 | + | |
| 120 | + | |
| 121 | + | |
| 122 | + | |
| 123 | + | |
| 124 | + | |
| 125 | + | |
| 126 | + | |
| 127 | + | |
| 128 | + | |
| 129 | + | |
| 130 | + | |
| 131 | + | |
| 132 | + | |
| 133 | + | |
| 134 | + | |
| 135 | + | |
| 136 | + | |
| 137 | + | |
| 138 | + | |
| 139 | + | |
| 140 | + | |
| 141 | + | |
| 142 | + | |
| 143 | + | |
| 144 | + | |
| 145 | + | |
| 146 | + | |
| 147 | + | |
| 148 | + | |
| 149 | + | |
| 150 | + | |
| 151 | + | |
| 152 | + | |
| 153 | + | |
| 154 | + | |
| 155 | + | |
| 156 | + | |
| 157 | + | |
| 158 | + | |
| 159 | + | |
| 160 | + | |
| 161 | + | |
| 162 | + | |
| 163 | + | |
| 164 | + | |
| 165 | + | |
| 166 | + | |
| 167 | + | |
| 168 | + | |
| 169 | + | |
| 170 | + | |
| 171 | + | |
| 172 | + | |
| 173 | + | |
| 174 | + | |
| 175 | + | |
| 176 | + | |
| 177 | + | |
| 178 | + | |
| 179 | + | |
| 180 | + | |
| 181 | + | |
| 182 | + | |
| 183 | + | |
140 | 184 | | |
141 | 185 | | |
142 | 186 | | |
| |||
0 commit comments