@@ -1465,23 +1465,33 @@ impl Render for Table<Vector> {
14651465 }
14661466}
14671467
1468- /// Build click targets (subpaths and free-floating anchors) from a `Vector`, apply the transform, and append to `targets`.
1468+ /// Build one `CompoundPath` (non-zero fill rule, so holes like the inside of an "O" work
1469+ /// correctly) plus one `FreePoint` per disconnected anchor, apply the transform, and append.
14691470fn extend_targets_from_vector ( targets : & mut Vec < ClickTarget > , vector : & Vector , transform : DAffine2 ) {
14701471 let stroke_width = vector. style . stroke ( ) . as_ref ( ) . map_or ( 0. , Stroke :: effective_width) ;
14711472 let filled = vector. style . fill ( ) != & Fill :: None ;
1472- let fill = |mut subpath : Subpath < _ > | {
1473- if filled {
1474- subpath. set_closed ( true ) ;
1475- }
1476- subpath
1477- } ;
1478- targets. extend ( vector. stroke_bezier_paths ( ) . map ( fill) . map ( |subpath| {
1479- let mut click_target = ClickTarget :: new_with_subpath ( subpath, stroke_width) ;
1473+ let subpaths: Vec < Subpath < _ > > = vector
1474+ . stroke_bezier_paths ( )
1475+ . map ( |mut subpath| {
1476+ if filled {
1477+ subpath. set_closed ( true ) ;
1478+ }
1479+ subpath
1480+ } )
1481+ . collect ( ) ;
1482+ if !subpaths. is_empty ( ) {
1483+ let mut click_target = ClickTarget :: new_with_compound_path ( subpaths, stroke_width) ;
14801484 click_target. apply_transform ( transform) ;
1481- click_target
1482- } ) ) ;
1485+ targets. push ( click_target) ;
1486+ }
1487+
1488+ for click_target in extend_free_point_targets ( vector, transform) {
1489+ targets. push ( click_target) ;
1490+ }
1491+ }
14831492
1484- let single_anchors = vector. point_domain . ids ( ) . iter ( ) . filter_map ( |& point_id| {
1493+ fn extend_free_point_targets ( vector : & Vector , transform : DAffine2 ) -> impl Iterator < Item = ClickTarget > + ' _ {
1494+ vector. point_domain . ids ( ) . iter ( ) . filter_map ( move |& point_id| {
14851495 if vector. any_connected ( point_id) {
14861496 return None ;
14871497 }
@@ -1490,8 +1500,7 @@ fn extend_targets_from_vector(targets: &mut Vec<ClickTarget>, vector: &Vector, t
14901500 let mut click_target = ClickTarget :: new_with_free_point ( FreePoint :: new ( point_id, anchor) ) ;
14911501 click_target. apply_transform ( transform) ;
14921502 Some ( click_target)
1493- } ) ;
1494- targets. extend ( single_anchors) ;
1503+ } )
14951504}
14961505
14971506impl Render for Table < Raster < CPU > > {
0 commit comments