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))) };