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.
This commit is contained in:
dotCooCoo
2026-11-19 13:14:42 -08:00
parent c10df66a90
commit 6adc5c651c
2 changed files with 19 additions and 9 deletions
+13
View File
@@ -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
+6 -9
View File
@@ -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<NodeId>, named: Option<&[NodeId]>) -> Option<(Vec<NodeId>, Option<NodeId>)> {
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<NodeId>, 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))) };