diff options
author | Federico Mena Quintero <federico@gnome.org> | 2021-10-18 12:38:54 -0500 |
---|---|---|
committer | Marge Bot <marge-bot@gnome.org> | 2021-10-18 20:38:40 +0000 |
commit | 9058a34a1fa8196dfe2502c2d7206f9f4890a4d8 (patch) | |
tree | 7ed6e534bfb9e550bd5bde8c904ef1788f0a2691 /src/structure.rs | |
parent | 6aff484d19c26579abe6636e6e530b9691176d4c (diff) | |
download | librsvg-9058a34a1fa8196dfe2502c2d7206f9f4890a4d8.tar.gz |
StackingContext: store the link_target here for <a> elements
The <a> Link element used to draw itself by wrapping its drawing in a
call to DrawingCtx::with_link_tag(). We remove that function, pass
the link target as part of StackingCtx, and deal with it in
DrawingCtx::with_discrete_layer().
Part-of: <https://gitlab.gnome.org/GNOME/librsvg/-/merge_requests/613>
Diffstat (limited to 'src/structure.rs')
-rw-r--r-- | src/structure.rs | 24 |
1 files changed, 17 insertions, 7 deletions
diff --git a/src/structure.rs b/src/structure.rs index 3cc8ac46..f3e5477d 100644 --- a/src/structure.rs +++ b/src/structure.rs @@ -552,7 +552,22 @@ impl Draw for Link { let values = cascaded.get(); let elt = node.borrow_element(); - let stacking_ctx = StackingContext::new(acquired_nodes, &elt, values.transform(), values); + + let link_is_empty = self.link.as_ref().map(|l| l.is_empty()).unwrap_or(true); + + let link_target = if link_is_empty { + None + } else { + self.link.clone() + }; + + let stacking_ctx = StackingContext::new_with_link( + acquired_nodes, + &elt, + values.transform(), + values, + link_target, + ); draw_ctx.with_discrete_layer( &stacking_ctx, @@ -560,12 +575,7 @@ impl Draw for Link { values, clipping, None, - &mut |an, dc| match self.link.as_ref() { - Some(l) if !l.is_empty() => { - dc.with_link_tag(l, &mut |dc| node.draw_children(an, &cascaded, dc, clipping)) - } - _ => node.draw_children(an, &cascaded, dc, clipping), - }, + &mut |an, dc| node.draw_children(an, &cascaded, dc, clipping), ) } } |