[librsvg: 20/48] NodeCreationContext: move the actual node creation to its own function
- From: Federico Mena Quintero <federico src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [librsvg: 20/48] NodeCreationContext: move the actual node creation to its own function
- Date: Sat, 17 Nov 2018 10:21:42 +0000 (UTC)
commit 6133971dba2ace21597e38323b9d1d60502f9622
Author: Federico Mena Quintero <federico gnome org>
Date: Fri Sep 7 15:10:23 2018 -0500
NodeCreationContext: move the actual node creation to its own function
We'll decide whether to create nodes or use other handlers in the main
start_element() implementation.
rsvg_internals/src/xml.rs | 53 ++++++++++++++++++++++++++++-------------------
1 file changed, 32 insertions(+), 21 deletions(-)
---
diff --git a/rsvg_internals/src/xml.rs b/rsvg_internals/src/xml.rs
index 5e005fad..7df43237 100644
--- a/rsvg_internals/src/xml.rs
+++ b/rsvg_internals/src/xml.rs
@@ -52,28 +52,9 @@ impl XmlHandler for NodeCreationContext {
name: &str,
pbag: &PropertyBag,
) -> Box<XmlHandler> {
- let mut defs = handle::get_defs(handle);
- let mut is_svg = false;
-
- let new_node = rsvg_load_new_node(name, parent, pbag, &mut defs, &mut is_svg);
-
- if let Some(parent) = parent {
- parent.add_child(&new_node);
- }
-
- new_node.set_atts(&new_node, handle, pbag);
-
- // The "svg" node is special; it will parse its style attributes
- // until the end, in standard_element_end().
- if new_node.get_type() != NodeType::Svg {
- new_node.parse_style_attributes(handle, name, pbag);
- }
-
- new_node.set_overridden_properties();
+ let node = self.create_node(parent, handle, name, pbag);
- Box::new(NodeCreationContext {
- node: Some(new_node),
- })
+ Box::new(NodeCreationContext { node: Some(node) })
}
fn end_element(&self, handle: *mut RsvgHandle, _name: &str) -> Rc<Node> {
@@ -123,6 +104,36 @@ impl XmlHandler for NodeCreationContext {
}
}
+impl NodeCreationContext {
+ fn create_node(
+ &self,
+ parent: Option<&Rc<Node>>,
+ handle: *const RsvgHandle,
+ name: &str,
+ pbag: &PropertyBag,
+ ) -> Rc<Node> {
+ let mut defs = handle::get_defs(handle);
+
+ let new_node = rsvg_load_new_node(name, parent, pbag, &mut defs);
+
+ if let Some(parent) = parent {
+ parent.add_child(&new_node);
+ }
+
+ new_node.set_atts(&new_node, handle, pbag);
+
+ // The "svg" node is special; it will parse its style attributes
+ // until the end, in standard_element_end().
+ if new_node.get_type() != NodeType::Svg {
+ new_node.parse_style_attributes(handle, name, pbag);
+ }
+
+ new_node.set_overridden_properties();
+
+ new_node
+ }
+}
+
/// A concrete parsing context for a surrounding `element_name` and its XML event handlers
struct Context {
element_name: String,
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]