From 6adc5c651c03c813af2b560f9f28257018167b6f Mon Sep 17 00:00:00 2001 From: dotCooCoo Date: Thu, 19 Nov 2026 13:14:42 -0800 Subject: [PATCH] Fill Area: no area while a clipping group or the art it clips is isolated Before, only a clipping mask itself was refused in isolation mode. A clipping group or clipped layer that was isolated, or that held the isolated group, still took the new path, where its mask could hide or cut it. Now no area is found then, for the tool and for shapeBuilder.copyRegion, as the documentation of the command states. --- crates/engine/src/tests/fill_area.rs | 13 +++++++++++++ crates/tools/src/builder/fill_area.rs | 15 ++++++--------- 2 files changed, 19 insertions(+), 9 deletions(-) diff --git a/crates/engine/src/tests/fill_area.rs b/crates/engine/src/tests/fill_area.rs index a11f8d2975..6625c7e150 100644 --- a/crates/engine/src/tests/fill_area.rs +++ b/crates/engine/src/tests/fill_area.rs @@ -318,6 +318,19 @@ fn fill_area_finds_nothing_while_a_compound_path_is_isolated() { let members = node(&s, mask).children().unwrap().len(); assert!(s.execute("shapeBuilder.copyRegion", &json!({"point": [50, 70]})).is_err()); assert_eq!((undo_len(&s), stack(&s), node(&s, mask).children().unwrap().len()), (undo, kids, members)); + // The clipping group itself, and a group of the art it clips, take no new path either: the + // mask would hide or cut it. + s.doc_mut().unwrap().isolation = None; + s.execute("select.set", &json!({"ids": [back.0]})).unwrap(); + let clipped = id_of(&s.execute("object.group", &json!({})).unwrap()); + assert_eq!(s.doc().unwrap().doc.parent_of(clipped), Some(clip)); + deselect(&mut s); + for iso in [clip, clipped] { + s.doc_mut().unwrap().isolation = Some(iso); + let (undo, kids) = (undo_len(&s), stack(&s)); + assert!(s.execute("shapeBuilder.copyRegion", &json!({"point": [5, 5]})).is_err(), "{iso:?}"); + assert_eq!((undo_len(&s), stack(&s)), (undo, kids), "{iso:?}"); + } } /// The new path goes directly above the front-most object along the area, not above art that diff --git a/crates/tools/src/builder/fill_area.rs b/crates/tools/src/builder/fill_area.rs index bd41eeaf24..f535bd0aa3 100644 --- a/crates/tools/src/builder/fill_area.rs +++ b/crates/tools/src/builder/fill_area.rs @@ -179,9 +179,9 @@ fn managed(n: &Node) -> bool { /// only the isolated layer or group's paths count: of `named`, the ones inside it, with the /// isolated object in place of one that holds it. An isolated object that no longer exists counts /// as no isolation. None while an object that is not a layer or a group is isolated (a compound -/// path or a single path), a layer or group with a live effect, a group that is [`managed`] or a -/// clipping mask, or one inside such an object or inside another object that is not a layer or a -/// group (an envelope): no area is found then. +/// path or a single path), a layer or group with a live effect, a group that is [`managed`], a +/// clipping group or clipped layer, or one inside such an object or inside another object that is +/// not a layer or a group (an envelope): no area is found then. pub fn fill_area_roots(doc: &Document, isolation: Option, named: Option<&[NodeId]>) -> Option<(Vec, Option)> { let Some(iso) = isolation.filter(|i| doc.node(*i).is_some()) else { return Some((named.map_or_else(|| every_layer(doc), <[NodeId]>::to_vec), None)); @@ -197,12 +197,9 @@ pub fn fill_area_roots(doc: &Document, isolation: Option, named: Option< if !line.iter().all(|a| doc.node(*a).is_some_and(plain)) { return None; } - // A clipping group or clipped layer's first member is its mask, which clips and is not painted. - let in_mask = line.windows(2).any(|w| { - let [p, m] = w else { return false }; - doc.node(*p).is_some_and(|p| p.clips() && p.children().and_then(|c| c.first()).is_some_and(|f| f.id == *m)) - }); - if in_mask { + // A clipping group or clipped layer's mask clips and is not painted, and its mask hides or cuts + // a new path among the art it clips. + if line.iter().any(|a| doc.node(*a).is_some_and(Node::clips)) { return None; } let Some(named) = named else { return Some((vec![iso], Some(iso))) };