[librsvg: 33/45] Refactor DrawingCtx::get_clip_in_user_and_object_space()
- From: Federico Mena Quintero <federico src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [librsvg: 33/45] Refactor DrawingCtx::get_clip_in_user_and_object_space()
- Date: Tue, 1 Oct 2019 15:09:42 +0000 (UTC)
commit 154b8066833abd66a7cee824800ef4ef7433f60f
Author: Federico Mena Quintero <federico gnome org>
Date: Mon Sep 30 13:44:25 2019 -0500
Refactor DrawingCtx::get_clip_in_user_and_object_space()
rsvg_internals/src/drawing_ctx.rs | 32 +++++++++++++++++---------------
1 file changed, 17 insertions(+), 15 deletions(-)
---
diff --git a/rsvg_internals/src/drawing_ctx.rs b/rsvg_internals/src/drawing_ctx.rs
index c1b360f5..04692a3e 100644
--- a/rsvg_internals/src/drawing_ctx.rs
+++ b/rsvg_internals/src/drawing_ctx.rs
@@ -339,23 +339,25 @@ impl DrawingCtx {
&mut self,
clip_uri: Option<&Fragment>,
) -> (Option<RsvgNode>, Option<RsvgNode>) {
- if let Some(clip_node) = self
- .acquired_nodes
- .get_node_of_type(clip_uri, NodeType::ClipPath)
- {
- let clip_node = clip_node.get().clone();
+ clip_uri
+ .and_then(|fragment| {
+ self.acquired_nodes
+ .get_node_of_type(Some(fragment), NodeType::ClipPath)
+ })
+ .and_then(|acquired| {
+ let clip_node = acquired.get().clone();
- let ClipPathUnits(units) = clip_node.borrow().get_impl::<NodeClipPath>().get_units();
+ let ClipPathUnits(units) =
+ clip_node.borrow().get_impl::<NodeClipPath>().get_units();
- if units == CoordUnits::UserSpaceOnUse {
- (Some(clip_node), None)
- } else {
- assert!(units == CoordUnits::ObjectBoundingBox);
- (None, Some(clip_node))
- }
- } else {
- (None, None)
- }
+ if units == CoordUnits::UserSpaceOnUse {
+ Some((Some(clip_node), None))
+ } else {
+ assert!(units == CoordUnits::ObjectBoundingBox);
+ Some((None, Some(clip_node)))
+ }
+ })
+ .unwrap_or((None, None))
}
fn clip_to_node(
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]