summaryrefslogtreecommitdiff
path: root/src/text.rs
diff options
context:
space:
mode:
Diffstat (limited to 'src/text.rs')
-rw-r--r--src/text.rs30
1 files changed, 12 insertions, 18 deletions
diff --git a/src/text.rs b/src/text.rs
index 7b642975..dceae602 100644
--- a/src/text.rs
+++ b/src/text.rs
@@ -10,7 +10,7 @@ use std::sync::Arc;
use crate::bbox::BoundingBox;
use crate::document::{AcquiredNodes, NodeId};
use crate::drawing_ctx::{create_pango_context, DrawingCtx, FontOptions, ViewParams};
-use crate::element::{Draw, Element, ElementResult, SetAttributes};
+use crate::element::{set_attribute, Draw, Element, SetAttributes};
use crate::error::*;
use crate::layout::{self, FontProperties, StackingContext, Stroke, TextSpan};
use crate::length::*;
@@ -733,18 +733,16 @@ impl Text {
}
impl SetAttributes for Text {
- fn set_attributes(&mut self, attrs: &Attributes, _session: &Session) -> ElementResult {
+ fn set_attributes(&mut self, attrs: &Attributes, session: &Session) {
for (attr, value) in attrs.iter() {
match attr.expanded() {
- expanded_name!("", "x") => self.x = attr.parse(value)?,
- expanded_name!("", "y") => self.y = attr.parse(value)?,
- expanded_name!("", "dx") => self.dx = attr.parse(value)?,
- expanded_name!("", "dy") => self.dy = attr.parse(value)?,
+ expanded_name!("", "x") => set_attribute(&mut self.x, attr.parse(value), session),
+ expanded_name!("", "y") => set_attribute(&mut self.y, attr.parse(value), session),
+ expanded_name!("", "dx") => set_attribute(&mut self.dx, attr.parse(value), session),
+ expanded_name!("", "dy") => set_attribute(&mut self.dy, attr.parse(value), session),
_ => (),
}
}
-
- Ok(())
}
}
@@ -926,7 +924,7 @@ fn extract_chars_children_to_chunks_recursively(
}
impl SetAttributes for TRef {
- fn set_attributes(&mut self, attrs: &Attributes, _session: &Session) -> ElementResult {
+ fn set_attributes(&mut self, attrs: &Attributes, _session: &Session) {
self.link = attrs
.iter()
.find(|(attr, _)| attr.expanded() == expanded_name!(xlink "href"))
@@ -934,8 +932,6 @@ impl SetAttributes for TRef {
// the <tref> element got removed in SVG2. So, here we still use a match
// against the full namespaced version of the attribute.
.and_then(|(attr, value)| NodeId::parse(value).attribute(attr).ok());
-
- Ok(())
}
}
@@ -994,18 +990,16 @@ impl TSpan {
}
impl SetAttributes for TSpan {
- fn set_attributes(&mut self, attrs: &Attributes, _session: &Session) -> ElementResult {
+ fn set_attributes(&mut self, attrs: &Attributes, session: &Session) {
for (attr, value) in attrs.iter() {
match attr.expanded() {
- expanded_name!("", "x") => self.x = attr.parse(value)?,
- expanded_name!("", "y") => self.y = attr.parse(value)?,
- expanded_name!("", "dx") => self.dx = attr.parse(value)?,
- expanded_name!("", "dy") => self.dy = attr.parse(value)?,
+ expanded_name!("", "x") => set_attribute(&mut self.x, attr.parse(value), session),
+ expanded_name!("", "y") => set_attribute(&mut self.y, attr.parse(value), session),
+ expanded_name!("", "dx") => set_attribute(&mut self.dx, attr.parse(value), session),
+ expanded_name!("", "dy") => set_attribute(&mut self.dy, attr.parse(value), session),
_ => (),
}
}
-
- Ok(())
}
}