Pass the previous_handler down to the start_element implementations

parent 2554116a
...@@ -28,6 +28,7 @@ trait XmlHandler { ...@@ -28,6 +28,7 @@ trait XmlHandler {
/// Called when the XML parser sees the beginning of an element /// Called when the XML parser sees the beginning of an element
fn start_element( fn start_element(
&self, &self,
previous_handler: Option<&XmlHandler>,
parent: Option<&Rc<Node>>, parent: Option<&Rc<Node>>,
handle: *mut RsvgHandle, handle: *mut RsvgHandle,
name: &str, name: &str,
...@@ -52,6 +53,7 @@ struct NodeCreationContext { ...@@ -52,6 +53,7 @@ struct NodeCreationContext {
impl XmlHandler for NodeCreationContext { impl XmlHandler for NodeCreationContext {
fn start_element( fn start_element(
&self, &self,
_previous_handler: Option<&XmlHandler>,
parent: Option<&Rc<Node>>, parent: Option<&Rc<Node>>,
handle: *mut RsvgHandle, handle: *mut RsvgHandle,
name: &str, name: &str,
...@@ -59,7 +61,7 @@ impl XmlHandler for NodeCreationContext { ...@@ -59,7 +61,7 @@ impl XmlHandler for NodeCreationContext {
) -> Box<XmlHandler> { ) -> Box<XmlHandler> {
if name == "style" { if name == "style" {
let ctx = StyleContext::empty(); let ctx = StyleContext::empty();
StyleContext::start_element(&ctx, parent, handle, name, pbag) ctx.start_element(Some(self), parent, handle, name, pbag)
} else { } else {
let node = self.create_node(parent, handle, name, pbag); let node = self.create_node(parent, handle, name, pbag);
...@@ -158,6 +160,7 @@ struct StyleContext { ...@@ -158,6 +160,7 @@ struct StyleContext {
impl XmlHandler for StyleContext { impl XmlHandler for StyleContext {
fn start_element( fn start_element(
&self, &self,
_previous_handler: Option<&XmlHandler>,
_parent: Option<&Rc<Node>>, _parent: Option<&Rc<Node>>,
_handle: *mut RsvgHandle, _handle: *mut RsvgHandle,
_name: &str, _name: &str,
...@@ -262,11 +265,11 @@ impl XmlState { ...@@ -262,11 +265,11 @@ impl XmlState {
pub fn start_element(&mut self, handle: *mut RsvgHandle, name: &str, pbag: &PropertyBag) { pub fn start_element(&mut self, handle: *mut RsvgHandle, name: &str, pbag: &PropertyBag) {
let next_context = if let Some(top) = self.context_stack.last() { let next_context = if let Some(top) = self.context_stack.last() {
top.handler top.handler
.start_element(top.handler.get_node().as_ref(), handle, name, pbag) .start_element(Some(&*top.handler), top.handler.get_node().as_ref(), handle, name, pbag)
} else { } else {
let default_context = NodeCreationContext::empty(); let default_context = NodeCreationContext::empty();
default_context.start_element(None, handle, name, pbag) default_context.start_element(None, None, handle, name, pbag)
}; };
let context = Context { let context = Context {
......
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