[librsvg] rsvg_characters_impl(): Extract function to create a new chars child node
- From: Federico Mena Quintero <federico src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [librsvg] rsvg_characters_impl(): Extract function to create a new chars child node
- Date: Wed, 6 Dec 2017 13:43:02 +0000 (UTC)
commit c9a47b67c186eb67ce6e06487f96e15851b54ee8
Author: Federico Mena Quintero <federico gnome org>
Date: Wed Dec 6 07:36:58 2017 -0600
rsvg_characters_impl(): Extract function to create a new chars child node
rsvg-base.c | 30 +++++++++++++++++++++---------
1 files changed, 21 insertions(+), 9 deletions(-)
---
diff --git a/rsvg-base.c b/rsvg-base.c
index 0b1dc91..699ea45 100644
--- a/rsvg-base.c
+++ b/rsvg-base.c
@@ -950,29 +950,41 @@ find_last_chars_child (RsvgNode *node)
return child;
}
+static RsvgNode *
+add_new_chars_child_to_current_node (RsvgHandle *ctx)
+{
+ RsvgNode *node;
+
+ node = rsvg_node_chars_new (ctx->priv->currentnode);
+ add_node_to_handle (ctx, node);
+
+ if (ctx->priv->currentnode) {
+ rsvg_node_add_child (ctx->priv->currentnode, node);
+ }
+
+ return node;
+}
+
static void
rsvg_characters_impl (RsvgHandle *ctx, const char *ch, gssize len)
{
RsvgNode *node = NULL;
- if (!ch || !len)
+ if (!ch || !len) {
return;
+ }
- if (!node_is_text_or_tspan (ctx->priv->currentnode))
+ if (!node_is_text_or_tspan (ctx->priv->currentnode)) {
return;
+ }
node = find_last_chars_child (ctx->priv->currentnode);
if (!node) {
- node = rsvg_node_chars_new (ctx->priv->currentnode);
- add_node_to_handle (ctx, node);
-
- if (ctx->priv->currentnode)
- rsvg_node_add_child (ctx->priv->currentnode, node);
- } else {
- g_assert (rsvg_node_get_type (node) == RSVG_NODE_TYPE_CHARS);
+ node = add_new_chars_child_to_current_node (ctx);
}
+ g_assert (rsvg_node_get_type (node) == RSVG_NODE_TYPE_CHARS);
rsvg_node_chars_append (node, ch, len);
node = rsvg_node_unref (node);
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]