🐛 Fit a synced masked group to its mask again

A masked group takes all its geometry from its mask. When a copy turned
the mask of a masked group, a sync gave the copy's group the geometry of
its main's group, square to the page, and fitted only the group's
parents, so the group no longer matched its turned mask; a reflow then
fitted it again, and settling and a full sync gave different files.

After a sync writes a masked group's attributes, the group fits its mask
again along with its parents.

Test: generated `a-synced-masked-group-fits-the-mask-its-copy-turned`
(fails before the fix).

Benchmark (bench-components, alone):

|                             :world | :baseline |    :now |  :mean | :ratio |
|------------------------------------+-----------+---------+--------+--------|
|  deepest-edit-through-three-levels |    35.215 |  22.245 | 23.118 |   0.63 |
| edit-through-a-chain-of-dependents |    68.931 |  43.743 | 44.839 |   0.63 |
|         library-update-into-copies |    83.083 |  54.447 | 57.814 |   0.66 |
|        main-edit-among-many-shapes |     4.837 |   2.742 |  2.876 |   0.57 |
|           main-edit-into-10-copies |      1.79 |   1.077 |  1.135 |    0.6 |
|          main-edit-into-100-copies |    15.415 |  10.488 | 11.093 |   0.68 |
|         main-edit-into-1000-copies |   153.086 | 106.222 |  112.37 |   0.69 |
|         variant-switch-into-copies |    32.052 |  23.155 | 23.929 |   0.72 |

AI-assisted-by: claude-opus-5-5
This commit is contained in:
alonso.torres 2026-11-16 17:07:31 +01:00
parent 998f3ef633
commit c5602b8170
2 changed files with 12 additions and 2 deletions

View File

@ -1907,8 +1907,11 @@
it to them meanwhile, while it keeps the transform the change gave it,
rewrites geometry the change did not touch."
[changes dest-shape container roperations uoperations]
(let [update-parents {:type :reg-objects
:shapes (cfh/get-parent-ids (:objects container) (:id dest-shape))}
(let [;; a masked group takes all its geometry from its mask, so it fits
;; its mask again after taking its main's
update-parents {:type :reg-objects
:shapes (cond->> (vec (cfh/get-parent-ids (:objects container) (:id dest-shape)))
(:masked-group dest-shape) (into [(:id dest-shape)]))}
undone (into #{} (map :attr) uoperations)
uoperations (cond-> (vec uoperations)
(and (#{:group :bool} (:type dest-shape))

View File

@ -2495,6 +2495,13 @@
:ops [[:variant-property 0 9 3 0] [:switch 4] [:combine 2] [:switch 8] [:style 11 7 1]
[:update-main 2 0 0 0]]}))))
(t/deftest a-synced-masked-group-fits-the-mask-its-copy-turned
;; a copy turns the mask of a masked group; a sync gives the group its
;; main's geometry and then fits it to the turned mask again
(t/is (map? (cg/run {:world [2 0 {:variants true :rich-variants true :text true :layout nil :layout-copies true
:layout-children false}]
:ops [[:add-child 1] [:structure 3 1 0] [:transform 2 3 0 2]]}))))
(t/deftest a-pasted-copy-compares-with-the-main-the-file-accepted
;; the library widened a main the stale file has not accepted: a copy
;; pasted from it shows the accepted size, which is no override