[librsvg] rsvg_handle_get_geometry_sub(): Untangle this function a bit
- From: Federico Mena Quintero <federico src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [librsvg] rsvg_handle_get_geometry_sub(): Untangle this function a bit
- Date: Wed, 19 Dec 2018 19:37:29 +0000 (UTC)
commit 6f38c9ebbbdbb93a16a8c9f8af4787c0586df04e
Author: Federico Mena Quintero <federico gnome org>
Date: Wed Dec 19 12:03:28 2018 -0600
rsvg_handle_get_geometry_sub(): Untangle this function a bit
librsvg/rsvg-handle.c | 51 ++++++++++++++++++++++-----------------------------
1 file changed, 22 insertions(+), 29 deletions(-)
---
diff --git a/librsvg/rsvg-handle.c b/librsvg/rsvg-handle.c
index a252f396..92f08530 100644
--- a/librsvg/rsvg-handle.c
+++ b/librsvg/rsvg-handle.c
@@ -1190,10 +1190,7 @@ rsvg_handle_get_dimensions_sub (RsvgHandle * handle, RsvgDimensionData * dimensi
gboolean
rsvg_handle_get_geometry_sub (RsvgHandle * handle, RsvgRectangle * ink_rect, RsvgRectangle * logical_rect,
const char *id)
{
- RsvgNode *root = NULL;
RsvgNode *node = NULL;
- gboolean has_size;
- int root_width, root_height;
gboolean res = FALSE;
RsvgRectangle ink_r, logical_r;
@@ -1206,42 +1203,39 @@ rsvg_handle_get_geometry_sub (RsvgHandle * handle, RsvgRectangle * ink_rect, Rsv
return FALSE;
}
- root = rsvg_handle_rust_get_root (handle->priv->rust_handle);
-
if (id && *id) {
node = rsvg_handle_defs_lookup (handle, id);
-
- if (node && rsvg_handle_rust_node_is_root (handle->priv->rust_handle, node))
- id = NULL;
+ } else {
+ node = rsvg_handle_rust_get_root (handle->priv->rust_handle);
}
- if (!node && id) {
+ if (!node) {
goto out;
}
- has_size = rsvg_node_svg_get_size (root,
- rsvg_handle_rust_get_dpi_x (handle->priv->rust_handle),
- rsvg_handle_rust_get_dpi_y (handle->priv->rust_handle),
- &root_width, &root_height);
-
- if (id || !has_size) {
- res = rsvg_handle_get_node_geometry (handle, node ? node : root, &ink_r, &logical_r);
- if (!res) {
+ if (rsvg_handle_rust_node_is_root (handle->priv->rust_handle, node)) {
+ int root_width, root_height;
+ if (rsvg_node_svg_get_size (node,
+ rsvg_handle_rust_get_dpi_x (handle->priv->rust_handle),
+ rsvg_handle_rust_get_dpi_y (handle->priv->rust_handle),
+ &root_width, &root_height))
+ {
+ ink_r.width = root_width;
+ ink_r.height = root_height;
+ ink_r.x = 0;
+ ink_r.y = 0;
+
+ logical_r.width = root_width;
+ logical_r.height = root_height;
+ logical_r.x = 0;
+ logical_r.y = 0;
+
+ res = TRUE;
goto out;
}
- } else {
- ink_r.width = root_width;
- ink_r.height = root_height;
- ink_r.x = 0;
- ink_r.y = 0;
-
- logical_r.width = root_width;
- logical_r.height = root_height;
- logical_r.x = 0;
- logical_r.y = 0;
}
- res = TRUE;
+ res = rsvg_handle_get_node_geometry (handle, node, &ink_r, &logical_r);
out:
@@ -1254,7 +1248,6 @@ out:
}
g_clear_pointer (&node, rsvg_node_unref);
- g_clear_pointer (&root, rsvg_node_unref);
return res;
}
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]