[librsvg: 1/15] Simplify conditional with the element macros
- From: Federico Mena Quintero <federico src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [librsvg: 1/15] Simplify conditional with the element macros
- Date: Tue, 24 Nov 2020 18:09:10 +0000 (UTC)
commit 01379f8e2ecaae79082722273c6e1fa9c4483d99
Author: Federico Mena Quintero <federico gnome org>
Date: Tue Nov 17 11:38:56 2020 -0600
Simplify conditional with the element macros
src/drawing_ctx.rs | 90 ++++++++++++++++++++++++++++--------------------------
1 file changed, 46 insertions(+), 44 deletions(-)
---
diff --git a/src/drawing_ctx.rs b/src/drawing_ctx.rs
index 86950b3e..309d99d3 100644
--- a/src/drawing_ctx.rs
+++ b/src/drawing_ctx.rs
@@ -1692,56 +1692,58 @@ impl DrawingCtx {
let child = acquired.get();
- // if it is a symbol
- if child.is_element() {
+ if is_element_of_type!(child, Symbol) {
+ // if the <use> references a <symbol>, it gets handled specially
+
let elt = child.borrow_element();
- if let Element::Symbol(ref symbol) = *elt {
- let clip_mode = if !values.is_overflow()
- || (values.overflow() == Overflow::Visible
- && elt.get_specified_values().is_overflow())
- {
- Some(ClipMode::ClipToVbox)
- } else {
- None
- };
+ let symbol = borrow_element_as!(child, Symbol);
- return self.with_discrete_layer(
- node,
- acquired_nodes,
- values,
- clipping,
- &mut |an, dc| {
- let _params = dc.push_new_viewport(
- symbol.get_viewbox(),
- use_rect,
- symbol.get_preserve_aspect_ratio(),
- clip_mode,
- );
+ let clip_mode = if !values.is_overflow()
+ || (values.overflow() == Overflow::Visible
+ && elt.get_specified_values().is_overflow())
+ {
+ Some(ClipMode::ClipToVbox)
+ } else {
+ None
+ };
- child.draw_children(
- an,
- &CascadedValues::new_from_values(&child, values),
- dc,
- clipping,
- )
- },
- );
- }
- };
+ return self.with_discrete_layer(
+ node,
+ acquired_nodes,
+ values,
+ clipping,
+ &mut |an, dc| {
+ let _params = dc.push_new_viewport(
+ symbol.get_viewbox(),
+ use_rect,
+ symbol.get_preserve_aspect_ratio(),
+ clip_mode,
+ );
- // all other nodes
- let cr = self.cr.clone();
- cr.translate(use_rect.x0, use_rect.y0);
+ child.draw_children(
+ an,
+ &CascadedValues::new_from_values(&child, values),
+ dc,
+ clipping,
+ )
+ },
+ );
+ } else {
+ // otherwise the referenced node is not a <symbol>; process it generically
- self.with_discrete_layer(node, acquired_nodes, values, clipping, &mut |an, dc| {
- dc.draw_node_from_stack(
- &child,
- an,
- &CascadedValues::new_from_values(&child, values),
- clipping,
- )
- })
+ let cr = self.cr.clone();
+ cr.translate(use_rect.x0, use_rect.y0);
+
+ self.with_discrete_layer(node, acquired_nodes, values, clipping, &mut |an, dc| {
+ dc.draw_node_from_stack(
+ &child,
+ an,
+ &CascadedValues::new_from_values(&child, values),
+ clipping,
+ )
+ })
+ }
}
}
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]