pattern.rs: Remove rsvg_pattern_node_has_children(); implement in Rust

node.rs: Make Node.children public
parent d15c379a
......@@ -566,30 +566,3 @@ rsvg_pattern_node_to_rust_pattern (RsvgNode *node)
return pattern;
}
static gboolean
count_one_child_fn (RsvgNode *child, gpointer data)
{
gboolean *has_children = data;
*has_children = TRUE;
return FALSE;
}
static gboolean
node_has_at_least_one_child (RsvgNode *node)
{
gboolean has_children = FALSE;
rsvg_node_foreach_child (node, count_one_child_fn, &has_children);
return has_children;
}
gboolean
rsvg_pattern_node_has_children (RsvgNode *node)
{
if (rsvg_node_get_type (node) != RSVG_NODE_TYPE_PATTERN)
return FALSE;
return node_has_at_least_one_child (node);
}
......@@ -176,9 +176,6 @@ gboolean pattern_resolve_fallbacks_and_set_pattern (Pattern *pattern,
G_GNUC_INTERNAL
Pattern *rsvg_pattern_node_to_rust_pattern (RsvgNode *node);
G_GNUC_INTERNAL
gboolean rsvg_pattern_node_has_children (RsvgNode *node);
struct _RsvgSolidColor {
gboolean currentcolor;
......
......@@ -36,11 +36,11 @@ pub trait NodeTrait: Downcast {
impl_downcast! (NodeTrait);
pub struct Node {
node_type: NodeType,
parent: Option<Weak<Node>>, // optional; weak ref to parent
children: RefCell<Vec<Rc<Node>>>, // strong references to children
state: *mut RsvgState,
node_impl: Box<NodeTrait>
node_type: NodeType,
parent: Option<Weak<Node>>, // optional; weak ref to parent
pub children: RefCell<Vec<Rc<Node>>>, // strong references to children
state: *mut RsvgState,
node_impl: Box<NodeTrait>
}
/* Keep this in sync with rsvg-private.h:RsvgNodeType */
......
......@@ -10,7 +10,7 @@ use length::*;
use drawing_ctx;
use drawing_ctx::RsvgDrawingCtx;
use node::RsvgNode;
use node::*;
use bbox::*;
use util::*;
......@@ -39,11 +39,17 @@ pub struct Pattern {
extern "C" {
fn rsvg_pattern_node_to_rust_pattern (node: *const RsvgNode) -> *mut Pattern;
fn rsvg_pattern_node_has_children (node: *const RsvgNode) -> bool;
}
fn pattern_node_has_children (c_node: *const RsvgNode) -> bool {
unsafe { rsvg_pattern_node_has_children (c_node) }
fn pattern_node_has_children (raw_node: *const RsvgNode) -> bool {
assert! (!raw_node.is_null ());
let node: &RsvgNode = unsafe { & *raw_node };
if node.get_type () == NodeType::Pattern {
node.children.borrow ().len () > 0
} else {
false
}
}
// All of the Pattern's fields are Option<foo> values, because
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment