[librsvg: 2/4] Unprefixed attributes don't have a namespace at all
- From: Federico Mena Quintero <federico src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [librsvg: 2/4] Unprefixed attributes don't have a namespace at all
- Date: Fri, 10 Jan 2020 19:59:58 +0000 (UTC)
commit c4f5e81bdb2438f65c0c261188e9b745b0c42447
Author: Federico Mena Quintero <federico gnome org>
Date: Thu Jan 9 19:24:30 2020 -0600
Unprefixed attributes don't have a namespace at all
We were rewriting <foo bar="baz"/> to be <foo svg:bar="baz"/>, and the
XML namespaces spec says
https://www.w3.org/TR/xml-names11/#defaulting
A default namespace declaration applies to all unprefixed element
names within its scope. Default namespace declarations do not apply
directly to attribute names; the interpretation of unprefixed
attributes is determined by the element on which they appear.
That is, unprefixed attributes have no namespace and depend solely on
their element for processing.
rsvg_internals/src/create_node.rs | 2 +-
rsvg_internals/src/css.rs | 4 +-
rsvg_internals/src/filter.rs | 12 +--
rsvg_internals/src/filters/blend.rs | 4 +-
rsvg_internals/src/filters/color_matrix.rs | 4 +-
rsvg_internals/src/filters/component_transfer.rs | 14 ++--
rsvg_internals/src/filters/composite.rs | 12 +--
rsvg_internals/src/filters/convolve_matrix.rs | 18 ++---
rsvg_internals/src/filters/displacement_map.rs | 8 +-
rsvg_internals/src/filters/gaussian_blur.rs | 2 +-
rsvg_internals/src/filters/image.rs | 4 +-
rsvg_internals/src/filters/light/light_source.rs | 28 +++----
rsvg_internals/src/filters/light/lighting.rs | 10 +--
rsvg_internals/src/filters/merge.rs | 2 +-
rsvg_internals/src/filters/mod.rs | 12 +--
rsvg_internals/src/filters/morphology.rs | 4 +-
rsvg_internals/src/filters/offset.rs | 4 +-
rsvg_internals/src/filters/turbulence.rs | 10 +--
rsvg_internals/src/gradient.rs | 26 +++----
rsvg_internals/src/image.rs | 12 +--
rsvg_internals/src/marker.rs | 16 ++--
rsvg_internals/src/node.rs | 10 +--
rsvg_internals/src/pattern.rs | 18 ++---
rsvg_internals/src/properties.rs | 92 +++++++++++------------
rsvg_internals/src/property_bag.rs | 94 +++++++++++-------------
rsvg_internals/src/shapes.rs | 40 +++++-----
rsvg_internals/src/structure.rs | 38 +++++-----
rsvg_internals/src/style.rs | 2 +-
rsvg_internals/src/text.rs | 16 ++--
rsvg_internals/src/xml.rs | 8 +-
rsvg_internals/src/xml2_load.rs | 6 +-
31 files changed, 262 insertions(+), 270 deletions(-)
---
diff --git a/rsvg_internals/src/create_node.rs b/rsvg_internals/src/create_node.rs
index 6000fe84..e6d5df70 100644
--- a/rsvg_internals/src/create_node.rs
+++ b/rsvg_internals/src/create_node.rs
@@ -239,7 +239,7 @@ pub fn create_node(name: &QualName, pbag: &PropertyBag) -> RsvgNode {
for (attr, value) in pbag.iter() {
match attr.expanded() {
expanded_name!("", "id") => id = Some(value),
- expanded_name!(svg "class") => class = Some(value),
+ expanded_name!("", "class") => class = Some(value),
_ => (),
}
}
diff --git a/rsvg_internals/src/css.rs b/rsvg_internals/src/css.rs
index fd1f6563..31c2dfbe 100644
--- a/rsvg_internals/src/css.rs
+++ b/rsvg_internals/src/css.rs
@@ -120,9 +120,9 @@ impl<'i> DeclarationParser<'i> for DeclParser {
name: CowRcStr<'i>,
input: &mut Parser<'i, 't>,
) -> Result<Declaration, CssParseError<'i>> {
- let prop_name = QualName::new(None, ns!(svg), LocalName::from(name.as_ref()));
+ let prop_name = QualName::new(None, ns!(), LocalName::from(name.as_ref()));
let property = parse_property(&prop_name, input, true)
- .map_err(|_| input.new_custom_error(ValueErrorKind::parse_error("parse error")))?;
+ .map_err(|_| input.new_custom_error(ValueErrorKind::parse_error("parse error")))?;
let important = input.try_parse(parse_important).is_ok();
diff --git a/rsvg_internals/src/filter.rs b/rsvg_internals/src/filter.rs
index db80f012..acf0f3cb 100644
--- a/rsvg_internals/src/filter.rs
+++ b/rsvg_internals/src/filter.rs
@@ -114,7 +114,7 @@ impl NodeTrait for Filter {
// Parse filterUnits first as it affects x, y, width, height checks.
for (attr, value) in pbag.iter() {
match attr.expanded() {
- expanded_name!(svg "filterUnits") => self.filterunits = attr.parse(value)?,
+ expanded_name!("", "filterUnits") => self.filterunits = attr.parse(value)?,
_ => (),
}
}
@@ -159,21 +159,21 @@ impl NodeTrait for Filter {
// Parse the rest of the attributes.
for (attr, value) in pbag.iter() {
match attr.expanded() {
- expanded_name!(svg "x") => {
+ expanded_name!("", "x") => {
self.x = attr.parse_and_validate(value, check_units_horizontal)?
}
- expanded_name!(svg "y") => {
+ expanded_name!("", "y") => {
self.y = attr.parse_and_validate(value, check_units_vertical)?
}
- expanded_name!(svg "width") => {
+ expanded_name!("", "width") => {
self.width = attr
.parse_and_validate(value, check_units_horizontal_and_ensure_nonnegative)?
}
- expanded_name!(svg "height") => {
+ expanded_name!("", "height") => {
self.height =
attr.parse_and_validate(value, check_units_vertical_and_ensure_nonnegative)?
}
- expanded_name!(svg "primitiveUnits") => self.primitiveunits = attr.parse(value)?,
+ expanded_name!("", "primitiveUnits") => self.primitiveunits = attr.parse(value)?,
_ => (),
}
}
diff --git a/rsvg_internals/src/filters/blend.rs b/rsvg_internals/src/filters/blend.rs
index ebdf0feb..b8fe5ebd 100755
--- a/rsvg_internals/src/filters/blend.rs
+++ b/rsvg_internals/src/filters/blend.rs
@@ -59,10 +59,10 @@ impl NodeTrait for FeBlend {
for (attr, value) in pbag.iter() {
match attr.expanded() {
- expanded_name!(svg "in2") => {
+ expanded_name!("", "in2") => {
self.in2 = Some(attr.parse(value)?);
}
- expanded_name!(svg "mode") => self.mode = attr.parse(value)?,
+ expanded_name!("", "mode") => self.mode = attr.parse(value)?,
_ => (),
}
}
diff --git a/rsvg_internals/src/filters/color_matrix.rs b/rsvg_internals/src/filters/color_matrix.rs
index 71bc6cd1..1b66882b 100644
--- a/rsvg_internals/src/filters/color_matrix.rs
+++ b/rsvg_internals/src/filters/color_matrix.rs
@@ -58,7 +58,7 @@ impl NodeTrait for FeColorMatrix {
let mut operation_type = Default::default();
for (attr, value) in pbag
.iter()
- .filter(|(attr, _)| attr.expanded() == expanded_name!(svg "type"))
+ .filter(|(attr, _)| attr.expanded() == expanded_name!("", "type"))
{
operation_type = attr.parse(value)?;
}
@@ -79,7 +79,7 @@ impl NodeTrait for FeColorMatrix {
} else {
for (attr, value) in pbag
.iter()
- .filter(|(attr, _)| attr.expanded() == expanded_name!(svg "values"))
+ .filter(|(attr, _)| attr.expanded() == expanded_name!("", "values"))
{
let new_matrix = match operation_type {
OperationType::LuminanceToAlpha => unreachable!(),
diff --git a/rsvg_internals/src/filters/component_transfer.rs
b/rsvg_internals/src/filters/component_transfer.rs
index 67c124e4..f75923d9 100644
--- a/rsvg_internals/src/filters/component_transfer.rs
+++ b/rsvg_internals/src/filters/component_transfer.rs
@@ -206,20 +206,20 @@ macro_rules! func_x {
) -> NodeResult {
for (attr, value) in pbag.iter() {
match attr.expanded() {
- expanded_name!(svg "type") => {
+ expanded_name!("", "type") => {
self.function_type = attr.parse(value)?
}
- expanded_name!(svg "tableValues") => {
+ expanded_name!("", "tableValues") => {
let NumberList(v) =
NumberList::parse_str(value, NumberListLength::Unbounded)
.attribute(attr)?;
self.table_values = v;
}
- expanded_name!(svg "slope") => self.slope = attr.parse(value)?,
- expanded_name!(svg "intercept") => self.intercept = attr.parse(value)?,
- expanded_name!(svg "amplitude") => self.amplitude = attr.parse(value)?,
- expanded_name!(svg "exponent") => self.exponent = attr.parse(value)?,
- expanded_name!(svg "offset") => self.offset = attr.parse(value)?,
+ expanded_name!("", "slope") => self.slope = attr.parse(value)?,
+ expanded_name!("", "intercept") => self.intercept = attr.parse(value)?,
+ expanded_name!("", "amplitude") => self.amplitude = attr.parse(value)?,
+ expanded_name!("", "exponent") => self.exponent = attr.parse(value)?,
+ expanded_name!("", "offset") => self.offset = attr.parse(value)?,
_ => (),
}
diff --git a/rsvg_internals/src/filters/composite.rs b/rsvg_internals/src/filters/composite.rs
index 138bbcf4..615971e7 100644
--- a/rsvg_internals/src/filters/composite.rs
+++ b/rsvg_internals/src/filters/composite.rs
@@ -57,12 +57,12 @@ impl NodeTrait for FeComposite {
for (attr, value) in pbag.iter() {
match attr.expanded() {
- expanded_name!(svg "in2") => self.in2 = Some(attr.parse(value)?),
- expanded_name!(svg "operator") => self.operator = attr.parse(value)?,
- expanded_name!(svg "k1") => self.k1 = attr.parse(value)?,
- expanded_name!(svg "k2") => self.k2 = attr.parse(value)?,
- expanded_name!(svg "k3") => self.k3 = attr.parse(value)?,
- expanded_name!(svg "k4") => self.k4 = attr.parse(value)?,
+ expanded_name!("", "in2") => self.in2 = Some(attr.parse(value)?),
+ expanded_name!("", "operator") => self.operator = attr.parse(value)?,
+ expanded_name!("", "k1") => self.k1 = attr.parse(value)?,
+ expanded_name!("", "k2") => self.k2 = attr.parse(value)?,
+ expanded_name!("", "k3") => self.k3 = attr.parse(value)?,
+ expanded_name!("", "k4") => self.k4 = attr.parse(value)?,
_ => (),
}
}
diff --git a/rsvg_internals/src/filters/convolve_matrix.rs b/rsvg_internals/src/filters/convolve_matrix.rs
index ad3cda2b..785e5352 100644
--- a/rsvg_internals/src/filters/convolve_matrix.rs
+++ b/rsvg_internals/src/filters/convolve_matrix.rs
@@ -60,7 +60,7 @@ impl NodeTrait for FeConvolveMatrix {
for (attr, value) in pbag.iter() {
match attr.expanded() {
- expanded_name!(svg "order") => {
+ expanded_name!("", "order") => {
let NumberOptionalNumber(x, y) =
attr.parse_and_validate(value, |v: NumberOptionalNumber<i32>| {
if v.0 > 0 && v.1 > 0 {
@@ -71,7 +71,7 @@ impl NodeTrait for FeConvolveMatrix {
})?;
self.order = (x as u32, y as u32);
}
- expanded_name!(svg "divisor") => {
+ expanded_name!("", "divisor") => {
self.divisor = Some(attr.parse_and_validate(value, |x| {
if x != 0.0 {
Ok(x)
@@ -80,9 +80,9 @@ impl NodeTrait for FeConvolveMatrix {
}
})?)
}
- expanded_name!(svg "bias") => self.bias = attr.parse(value)?,
- expanded_name!(svg "edgeMode") => self.edge_mode = attr.parse(value)?,
- expanded_name!(svg "kernelUnitLength") => {
+ expanded_name!("", "bias") => self.bias = attr.parse(value)?,
+ expanded_name!("", "edgeMode") => self.edge_mode = attr.parse(value)?,
+ expanded_name!("", "kernelUnitLength") => {
let NumberOptionalNumber(x, y) =
attr.parse_and_validate(value, |v: NumberOptionalNumber<f64>| {
if v.0 > 0.0 && v.1 > 0.0 {
@@ -96,7 +96,7 @@ impl NodeTrait for FeConvolveMatrix {
self.kernel_unit_length = Some((x, y))
}
- expanded_name!(svg "preserveAlpha") => self.preserve_alpha = attr.parse(value)?,
+ expanded_name!("", "preserveAlpha") => self.preserve_alpha = attr.parse(value)?,
_ => (),
}
@@ -105,7 +105,7 @@ impl NodeTrait for FeConvolveMatrix {
// target_x and target_y depend on order.
for (attr, value) in pbag.iter() {
match attr.expanded() {
- expanded_name!(svg "targetX") => {
+ expanded_name!("", "targetX") => {
self.target_x = {
let v = attr.parse_and_validate(value, |v: i32| {
if v >= 0 && v < self.order.0 as i32 {
@@ -119,7 +119,7 @@ impl NodeTrait for FeConvolveMatrix {
Some(v as u32)
}
}
- expanded_name!(svg "targetY") => {
+ expanded_name!("", "targetY") => {
self.target_y = {
let v = attr.parse_and_validate(value, |v: i32| {
if v >= 0 && v < self.order.1 as i32 {
@@ -148,7 +148,7 @@ impl NodeTrait for FeConvolveMatrix {
// Finally, parse the kernel matrix.
for (attr, value) in pbag
.iter()
- .filter(|(attr, _)| attr.expanded() == expanded_name!(svg "kernelMatrix"))
+ .filter(|(attr, _)| attr.expanded() == expanded_name!("", "kernelMatrix"))
{
self.kernel_matrix = Some({
let number_of_elements = self.order.0 as usize * self.order.1 as usize;
diff --git a/rsvg_internals/src/filters/displacement_map.rs b/rsvg_internals/src/filters/displacement_map.rs
index e9c734d4..13d206b1 100644
--- a/rsvg_internals/src/filters/displacement_map.rs
+++ b/rsvg_internals/src/filters/displacement_map.rs
@@ -51,14 +51,14 @@ impl NodeTrait for FeDisplacementMap {
for (attr, value) in pbag.iter() {
match attr.expanded() {
- expanded_name!(svg "in2") => self.in2 = Some(attr.parse(value)?),
- expanded_name!(svg "scale") => self.scale = attr.parse(value)?,
+ expanded_name!("", "in2") => self.in2 = Some(attr.parse(value)?),
+ expanded_name!("", "scale") => self.scale = attr.parse(value)?,
- expanded_name!(svg "xChannelSelector") => {
+ expanded_name!("", "xChannelSelector") => {
self.x_channel_selector = attr.parse(value)?
}
- expanded_name!(svg "yChannelSelector") => {
+ expanded_name!("", "yChannelSelector") => {
self.y_channel_selector = attr.parse(value)?
}
_ => (),
diff --git a/rsvg_internals/src/filters/gaussian_blur.rs b/rsvg_internals/src/filters/gaussian_blur.rs
index 35d2692f..d0b68811 100644
--- a/rsvg_internals/src/filters/gaussian_blur.rs
+++ b/rsvg_internals/src/filters/gaussian_blur.rs
@@ -48,7 +48,7 @@ impl NodeTrait for FeGaussianBlur {
for (attr, value) in pbag.iter() {
match attr.expanded() {
- expanded_name!(svg "stdDeviation") => {
+ expanded_name!("", "stdDeviation") => {
let NumberOptionalNumber(x, y) =
attr.parse_and_validate(value, |v: NumberOptionalNumber<f64>| {
if v.0 >= 0.0 && v.1 >= 0.0 {
diff --git a/rsvg_internals/src/filters/image.rs b/rsvg_internals/src/filters/image.rs
index fddcb084..c8cd471c 100644
--- a/rsvg_internals/src/filters/image.rs
+++ b/rsvg_internals/src/filters/image.rs
@@ -113,10 +113,10 @@ impl NodeTrait for FeImage {
for (attr, value) in pbag.iter() {
match attr.expanded() {
- expanded_name!(svg "preserveAspectRatio") => self.aspect = attr.parse(value)?,
+ expanded_name!("", "preserveAspectRatio") => self.aspect = attr.parse(value)?,
// "path" is used by some older Adobe Illustrator versions
- expanded_name!(xlink "href") | expanded_name!(svg "path") => {
+ expanded_name!(xlink "href") | expanded_name!("", "path") => {
let href = Href::parse(value)
.map_err(|_| ValueErrorKind::parse_error("could not parse href"))
.attribute(attr)?;
diff --git a/rsvg_internals/src/filters/light/light_source.rs
b/rsvg_internals/src/filters/light/light_source.rs
index 21991fcd..c390e2c3 100644
--- a/rsvg_internals/src/filters/light/light_source.rs
+++ b/rsvg_internals/src/filters/light/light_source.rs
@@ -106,8 +106,8 @@ impl NodeTrait for FeDistantLight {
fn set_atts(&mut self, _: Option<&RsvgNode>, pbag: &PropertyBag<'_>) -> NodeResult {
for (attr, value) in pbag.iter() {
match attr.expanded() {
- expanded_name!(svg "azimuth") => self.azimuth = attr.parse(value)?,
- expanded_name!(svg "elevation") => self.elevation = attr.parse(value)?,
+ expanded_name!("", "azimuth") => self.azimuth = attr.parse(value)?,
+ expanded_name!("", "elevation") => self.elevation = attr.parse(value)?,
_ => (),
}
}
@@ -138,9 +138,9 @@ impl NodeTrait for FePointLight {
fn set_atts(&mut self, _: Option<&RsvgNode>, pbag: &PropertyBag<'_>) -> NodeResult {
for (attr, value) in pbag.iter() {
match attr.expanded() {
- expanded_name!(svg "x") => self.x = attr.parse(value)?,
- expanded_name!(svg "y") => self.y = attr.parse(value)?,
- expanded_name!(svg "z") => self.z = attr.parse(value)?,
+ expanded_name!("", "x") => self.x = attr.parse(value)?,
+ expanded_name!("", "y") => self.y = attr.parse(value)?,
+ expanded_name!("", "z") => self.z = attr.parse(value)?,
_ => (),
}
}
@@ -187,18 +187,18 @@ impl NodeTrait for FeSpotLight {
fn set_atts(&mut self, _: Option<&RsvgNode>, pbag: &PropertyBag<'_>) -> NodeResult {
for (attr, value) in pbag.iter() {
match attr.expanded() {
- expanded_name!(svg "x") => self.x = attr.parse(value)?,
- expanded_name!(svg "y") => self.y = attr.parse(value)?,
- expanded_name!(svg "z") => self.z = attr.parse(value)?,
- expanded_name!(svg "pointsAtX") => self.points_at_x = attr.parse(value)?,
- expanded_name!(svg "pointsAtY") => self.points_at_y = attr.parse(value)?,
- expanded_name!(svg "pointsAtZ") => self.points_at_z = attr.parse(value)?,
-
- expanded_name!(svg "specularExponent") => {
+ expanded_name!("", "x") => self.x = attr.parse(value)?,
+ expanded_name!("", "y") => self.y = attr.parse(value)?,
+ expanded_name!("", "z") => self.z = attr.parse(value)?,
+ expanded_name!("", "pointsAtX") => self.points_at_x = attr.parse(value)?,
+ expanded_name!("", "pointsAtY") => self.points_at_y = attr.parse(value)?,
+ expanded_name!("", "pointsAtZ") => self.points_at_z = attr.parse(value)?,
+
+ expanded_name!("", "specularExponent") => {
self.specular_exponent = attr.parse(value)?
}
- expanded_name!(svg "limitingConeAngle") => {
+ expanded_name!("", "limitingConeAngle") => {
self.limiting_cone_angle = Some(attr.parse(value)?)
}
diff --git a/rsvg_internals/src/filters/light/lighting.rs b/rsvg_internals/src/filters/light/lighting.rs
index ffe6281d..be68ea76 100644
--- a/rsvg_internals/src/filters/light/lighting.rs
+++ b/rsvg_internals/src/filters/light/lighting.rs
@@ -52,9 +52,9 @@ impl Common {
for (attr, value) in pbag.iter() {
match attr.expanded() {
- expanded_name!(svg "surfaceScale") => self.surface_scale = attr.parse(value)?,
+ expanded_name!("", "surfaceScale") => self.surface_scale = attr.parse(value)?,
- expanded_name!(svg "kernelUnitLength") => {
+ expanded_name!("", "kernelUnitLength") => {
let NumberOptionalNumber(x, y) =
attr.parse_and_validate(value, |v: NumberOptionalNumber<f64>| {
if v.0 > 0.0 && v.1 > 0.0 {
@@ -99,7 +99,7 @@ impl NodeTrait for FeDiffuseLighting {
for (attr, value) in pbag.iter() {
match attr.expanded() {
- expanded_name!(svg "diffuseConstant") => {
+ expanded_name!("", "diffuseConstant") => {
self.diffuse_constant = attr.parse_and_validate(value, |x| {
if x >= 0.0 {
Ok(x)
@@ -168,7 +168,7 @@ impl NodeTrait for FeSpecularLighting {
for (attr, value) in pbag.iter() {
match attr.expanded() {
- expanded_name!(svg "specularConstant") => {
+ expanded_name!("", "specularConstant") => {
self.specular_constant = attr.parse_and_validate(value, |x| {
if x >= 0.0 {
Ok(x)
@@ -179,7 +179,7 @@ impl NodeTrait for FeSpecularLighting {
}
})?;
}
- expanded_name!(svg "specularExponent") => {
+ expanded_name!("", "specularExponent") => {
self.specular_exponent = attr.parse_and_validate(value, |x| {
if x >= 1.0 && x <= 128.0 {
Ok(x)
diff --git a/rsvg_internals/src/filters/merge.rs b/rsvg_internals/src/filters/merge.rs
index 82f68534..88daf571 100644
--- a/rsvg_internals/src/filters/merge.rs
+++ b/rsvg_internals/src/filters/merge.rs
@@ -46,7 +46,7 @@ impl NodeTrait for FeMergeNode {
fn set_atts(&mut self, _parent: Option<&RsvgNode>, pbag: &PropertyBag<'_>) -> NodeResult {
for (attr, value) in pbag.iter() {
match attr.expanded() {
- expanded_name!(svg "in") => self.in_ = Some(attr.parse(value)?),
+ expanded_name!("", "in") => self.in_ = Some(attr.parse(value)?),
_ => (),
}
}
diff --git a/rsvg_internals/src/filters/mod.rs b/rsvg_internals/src/filters/mod.rs
index 48e34865..0ebde6d6 100644
--- a/rsvg_internals/src/filters/mod.rs
+++ b/rsvg_internals/src/filters/mod.rs
@@ -161,27 +161,27 @@ impl NodeTrait for Primitive {
for (attr, value) in pbag.iter() {
match attr.expanded() {
- expanded_name!(svg "x") => {
+ expanded_name!("", "x") => {
self.x = Some(attr.parse_and_validate(value, check_units_horizontal)?)
}
- expanded_name!(svg "y") => {
+ expanded_name!("", "y") => {
self.y = Some(attr.parse_and_validate(value, check_units_vertical)?)
}
- expanded_name!(svg "width") => {
+ expanded_name!("", "width") => {
self.width =
Some(attr.parse_and_validate(
value,
check_units_horizontal_and_ensure_nonnegative,
)?)
}
- expanded_name!(svg "height") => {
+ expanded_name!("", "height") => {
self.height =
Some(attr.parse_and_validate(
value,
check_units_vertical_and_ensure_nonnegative,
)?)
}
- expanded_name!(svg "result") => self.result = Some(attr.parse(value)?),
+ expanded_name!("", "result") => self.result = Some(attr.parse(value)?),
_ => (),
}
}
@@ -217,7 +217,7 @@ impl NodeTrait for PrimitiveWithInput {
for (attr, value) in pbag.iter() {
match attr.expanded() {
- expanded_name!(svg "in") => self.in_ = Some(attr.parse(value)?),
+ expanded_name!("", "in") => self.in_ = Some(attr.parse(value)?),
_ => (),
}
}
diff --git a/rsvg_internals/src/filters/morphology.rs b/rsvg_internals/src/filters/morphology.rs
index 083025c8..ca4cd0d1 100644
--- a/rsvg_internals/src/filters/morphology.rs
+++ b/rsvg_internals/src/filters/morphology.rs
@@ -51,8 +51,8 @@ impl NodeTrait for FeMorphology {
for (attr, value) in pbag.iter() {
match attr.expanded() {
- expanded_name!(svg "operator") => self.operator = attr.parse(value)?,
- expanded_name!(svg "radius") => {
+ expanded_name!("", "operator") => self.operator = attr.parse(value)?,
+ expanded_name!("", "radius") => {
let NumberOptionalNumber(x, y) =
attr.parse_and_validate(value, |v: NumberOptionalNumber<f64>| {
if v.0 >= 0.0 && v.1 >= 0.0 {
diff --git a/rsvg_internals/src/filters/offset.rs b/rsvg_internals/src/filters/offset.rs
index b7c3389b..297b9027 100644
--- a/rsvg_internals/src/filters/offset.rs
+++ b/rsvg_internals/src/filters/offset.rs
@@ -35,8 +35,8 @@ impl NodeTrait for FeOffset {
for (attr, value) in pbag.iter() {
match attr.expanded() {
- expanded_name!(svg "dx") => self.dx = attr.parse(value)?,
- expanded_name!(svg "dy") => self.dy = attr.parse(value)?,
+ expanded_name!("", "dx") => self.dx = attr.parse(value)?,
+ expanded_name!("", "dy") => self.dy = attr.parse(value)?,
_ => (),
}
}
diff --git a/rsvg_internals/src/filters/turbulence.rs b/rsvg_internals/src/filters/turbulence.rs
index 17f99df7..031dabeb 100644
--- a/rsvg_internals/src/filters/turbulence.rs
+++ b/rsvg_internals/src/filters/turbulence.rs
@@ -63,7 +63,7 @@ impl NodeTrait for FeTurbulence {
for (attr, value) in pbag.iter() {
match attr.expanded() {
- expanded_name!(svg "baseFrequency") => {
+ expanded_name!("", "baseFrequency") => {
let NumberOptionalNumber(x, y) =
attr.parse_and_validate(value, |v: NumberOptionalNumber<f64>| {
if v.0 >= 0.0 && v.1 >= 0.0 {
@@ -75,11 +75,11 @@ impl NodeTrait for FeTurbulence {
self.base_frequency = (x, y);
}
- expanded_name!(svg "numOctaves") => {
+ expanded_name!("", "numOctaves") => {
self.num_octaves = attr.parse(value)?;
}
// Yes, seed needs to be parsed as a number and then truncated.
- expanded_name!(svg "seed") => {
+ expanded_name!("", "seed") => {
let v: f64 = attr.parse(value)?;
self.seed = clamp(
v.trunc(),
@@ -87,8 +87,8 @@ impl NodeTrait for FeTurbulence {
f64::from(i32::max_value()),
) as i32;
}
- expanded_name!(svg "stitchTiles") => self.stitch_tiles = attr.parse(value)?,
- expanded_name!(svg "type") => self.type_ = attr.parse(value)?,
+ expanded_name!("", "stitchTiles") => self.stitch_tiles = attr.parse(value)?,
+ expanded_name!("", "type") => self.type_ = attr.parse(value)?,
_ => (),
}
}
diff --git a/rsvg_internals/src/gradient.rs b/rsvg_internals/src/gradient.rs
index deb44195..dda0e1b1 100644
--- a/rsvg_internals/src/gradient.rs
+++ b/rsvg_internals/src/gradient.rs
@@ -130,7 +130,7 @@ impl NodeTrait for Stop {
fn set_atts(&mut self, _: Option<&RsvgNode>, pbag: &PropertyBag<'_>) -> NodeResult {
for (attr, value) in pbag.iter() {
match attr.expanded() {
- expanded_name!(svg "offset") => {
+ expanded_name!("", "offset") => {
self.offset = attr
.parse_and_validate(value, validate_offset)
.map(|l| UnitInterval::clamp(l.length))?
@@ -573,9 +573,9 @@ impl Common {
fn set_atts(&mut self, pbag: &PropertyBag<'_>) -> NodeResult {
for (attr, value) in pbag.iter() {
match attr.expanded() {
- expanded_name!(svg "gradientUnits") => self.units = Some(attr.parse(value)?),
- expanded_name!(svg "gradientTransform") => self.affine = Some(attr.parse(value)?),
- expanded_name!(svg "spreadMethod") => self.spread = Some(attr.parse(value)?),
+ expanded_name!("", "gradientUnits") => self.units = Some(attr.parse(value)?),
+ expanded_name!("", "gradientTransform") => self.affine = Some(attr.parse(value)?),
+ expanded_name!("", "spreadMethod") => self.spread = Some(attr.parse(value)?),
expanded_name!(xlink "href") => {
self.fallback = Some(Fragment::parse(value).attribute(attr)?)
}
@@ -593,10 +593,10 @@ impl NodeTrait for LinearGradient {
for (attr, value) in pbag.iter() {
match attr.expanded() {
- expanded_name!(svg "x1") => self.x1 = Some(attr.parse(value)?),
- expanded_name!(svg "y1") => self.y1 = Some(attr.parse(value)?),
- expanded_name!(svg "x2") => self.x2 = Some(attr.parse(value)?),
- expanded_name!(svg "y2") => self.y2 = Some(attr.parse(value)?),
+ expanded_name!("", "x1") => self.x1 = Some(attr.parse(value)?),
+ expanded_name!("", "y1") => self.y1 = Some(attr.parse(value)?),
+ expanded_name!("", "x2") => self.x2 = Some(attr.parse(value)?),
+ expanded_name!("", "y2") => self.y2 = Some(attr.parse(value)?),
_ => (),
}
@@ -612,11 +612,11 @@ impl NodeTrait for RadialGradient {
for (attr, value) in pbag.iter() {
match attr.expanded() {
- expanded_name!(svg "cx") => self.cx = Some(attr.parse(value)?),
- expanded_name!(svg "cy") => self.cy = Some(attr.parse(value)?),
- expanded_name!(svg "r") => self.r = Some(attr.parse(value)?),
- expanded_name!(svg "fx") => self.fx = Some(attr.parse(value)?),
- expanded_name!(svg "fy") => self.fy = Some(attr.parse(value)?),
+ expanded_name!("", "cx") => self.cx = Some(attr.parse(value)?),
+ expanded_name!("", "cy") => self.cy = Some(attr.parse(value)?),
+ expanded_name!("", "r") => self.r = Some(attr.parse(value)?),
+ expanded_name!("", "fx") => self.fx = Some(attr.parse(value)?),
+ expanded_name!("", "fy") => self.fy = Some(attr.parse(value)?),
_ => (),
}
diff --git a/rsvg_internals/src/image.rs b/rsvg_internals/src/image.rs
index 7dd9665c..94b6d1e6 100644
--- a/rsvg_internals/src/image.rs
+++ b/rsvg_internals/src/image.rs
@@ -29,18 +29,18 @@ impl NodeTrait for Image {
fn set_atts(&mut self, _: Option<&RsvgNode>, pbag: &PropertyBag<'_>) -> NodeResult {
for (attr, value) in pbag.iter() {
match attr.expanded() {
- expanded_name!(svg "x") => self.x = attr.parse(value)?,
- expanded_name!(svg "y") => self.y = attr.parse(value)?,
- expanded_name!(svg "width") => {
+ expanded_name!("", "x") => self.x = attr.parse(value)?,
+ expanded_name!("", "y") => self.y = attr.parse(value)?,
+ expanded_name!("", "width") => {
self.width = attr.parse_and_validate(value, Length::check_nonnegative)?
}
- expanded_name!(svg "height") => {
+ expanded_name!("", "height") => {
self.height = attr.parse_and_validate(value, Length::check_nonnegative)?
}
- expanded_name!(svg "preserveAspectRatio") => self.aspect = attr.parse(value)?,
+ expanded_name!("", "preserveAspectRatio") => self.aspect = attr.parse(value)?,
// "path" is used by some older Adobe Illustrator versions
- expanded_name!(xlink "href") | expanded_name!(svg "path") => {
+ expanded_name!(xlink "href") | expanded_name!("", "path") => {
let href = Href::parse(value)
.map_err(|_| ValueErrorKind::parse_error("could not parse href"))
.attribute(attr)?;
diff --git a/rsvg_internals/src/marker.rs b/rsvg_internals/src/marker.rs
index 346dfb07..22158cba 100644
--- a/rsvg_internals/src/marker.rs
+++ b/rsvg_internals/src/marker.rs
@@ -176,20 +176,20 @@ impl NodeTrait for Marker {
fn set_atts(&mut self, _: Option<&RsvgNode>, pbag: &PropertyBag<'_>) -> NodeResult {
for (attr, value) in pbag.iter() {
match attr.expanded() {
- expanded_name!(svg "markerUnits") => self.units = attr.parse(value)?,
- expanded_name!(svg "refX") => self.ref_x = attr.parse(value)?,
- expanded_name!(svg "refY") => self.ref_y = attr.parse(value)?,
- expanded_name!(svg "markerWidth") => {
+ expanded_name!("", "markerUnits") => self.units = attr.parse(value)?,
+ expanded_name!("", "refX") => self.ref_x = attr.parse(value)?,
+ expanded_name!("", "refY") => self.ref_y = attr.parse(value)?,
+ expanded_name!("", "markerWidth") => {
self.width =
attr.parse_and_validate(value, Length::<Horizontal>::check_nonnegative)?
}
- expanded_name!(svg "markerHeight") => {
+ expanded_name!("", "markerHeight") => {
self.height =
attr.parse_and_validate(value, Length::<Vertical>::check_nonnegative)?
}
- expanded_name!(svg "orient") => self.orient = attr.parse(value)?,
- expanded_name!(svg "preserveAspectRatio") => self.aspect = attr.parse(value)?,
- expanded_name!(svg "viewBox") => self.vbox = Some(attr.parse(value)?),
+ expanded_name!("", "orient") => self.orient = attr.parse(value)?,
+ expanded_name!("", "preserveAspectRatio") => self.aspect = attr.parse(value)?,
+ expanded_name!("", "viewBox") => self.vbox = Some(attr.parse(value)?),
_ => (),
}
}
diff --git a/rsvg_internals/src/node.rs b/rsvg_internals/src/node.rs
index 1da48392..ae9531e3 100644
--- a/rsvg_internals/src/node.rs
+++ b/rsvg_internals/src/node.rs
@@ -143,7 +143,7 @@ impl NodeData {
fn save_style_attribute(&mut self, pbag: &PropertyBag<'_>) {
for (attr, value) in pbag.iter() {
match attr.expanded() {
- expanded_name!(svg "style") => self.style_attr.push_str(value),
+ expanded_name!("", "style") => self.style_attr.push_str(value),
_ => (),
}
}
@@ -152,7 +152,7 @@ impl NodeData {
fn set_transform_attribute(&mut self, pbag: &PropertyBag<'_>) -> Result<(), NodeError> {
for (attr, value) in pbag.iter() {
match attr.expanded() {
- expanded_name!(svg "transform") => {
+ expanded_name!("", "transform") => {
return cairo::Matrix::parse_str(value)
.attribute(attr)
.and_then(|affine| {
@@ -177,17 +177,17 @@ impl NodeData {
for (attr, value) in pbag.iter() {
let mut parse = || -> Result<_, ValueErrorKind> {
match attr.expanded() {
- expanded_name!(svg "requiredExtensions") if cond => {
+ expanded_name!("", "requiredExtensions") if cond => {
cond = RequiredExtensions::from_attribute(value)
.map(|RequiredExtensions(res)| res)?;
}
- expanded_name!(svg "requiredFeatures") if cond => {
+ expanded_name!("", "requiredFeatures") if cond => {
cond = RequiredFeatures::from_attribute(value)
.map(|RequiredFeatures(res)| res)?;
}
- expanded_name!(svg "systemLanguage") if cond => {
+ expanded_name!("", "systemLanguage") if cond => {
cond = SystemLanguage::from_attribute(value, locale)
.map(|SystemLanguage(res)| res)?;
}
diff --git a/rsvg_internals/src/pattern.rs b/rsvg_internals/src/pattern.rs
index a628cd07..b2673f81 100644
--- a/rsvg_internals/src/pattern.rs
+++ b/rsvg_internals/src/pattern.rs
@@ -119,28 +119,28 @@ impl NodeTrait for Pattern {
fn set_atts(&mut self, _: Option<&RsvgNode>, pbag: &PropertyBag<'_>) -> NodeResult {
for (attr, value) in pbag.iter() {
match attr.expanded() {
- expanded_name!(svg "patternUnits") => self.common.units = Some(attr.parse(value)?),
- expanded_name!(svg "patternContentUnits") => {
+ expanded_name!("", "patternUnits") => self.common.units = Some(attr.parse(value)?),
+ expanded_name!("", "patternContentUnits") => {
self.common.content_units = Some(attr.parse(value)?)
}
- expanded_name!(svg "viewBox") => self.common.vbox = Some(Some(attr.parse(value)?)),
- expanded_name!(svg "preserveAspectRatio") => {
+ expanded_name!("", "viewBox") => self.common.vbox = Some(Some(attr.parse(value)?)),
+ expanded_name!("", "preserveAspectRatio") => {
self.common.preserve_aspect_ratio = Some(attr.parse(value)?)
}
- expanded_name!(svg "patternTransform") => {
+ expanded_name!("", "patternTransform") => {
self.common.affine = Some(attr.parse(value)?)
}
expanded_name!(xlink "href") => {
self.fallback = Some(Fragment::parse(value).attribute(attr)?);
}
- expanded_name!(svg "x") => self.common.x = Some(attr.parse(value)?),
- expanded_name!(svg "y") => self.common.y = Some(attr.parse(value)?),
- expanded_name!(svg "width") => {
+ expanded_name!("", "x") => self.common.x = Some(attr.parse(value)?),
+ expanded_name!("", "y") => self.common.y = Some(attr.parse(value)?),
+ expanded_name!("", "width") => {
self.common.width = Some(
attr.parse_and_validate(value, Length::<Horizontal>::check_nonnegative)?,
)
}
- expanded_name!(svg "height") => {
+ expanded_name!("", "height") => {
self.common.height =
Some(attr.parse_and_validate(value, Length::<Vertical>::check_nonnegative)?)
}
diff --git a/rsvg_internals/src/properties.rs b/rsvg_internals/src/properties.rs
index 8a34c7af..fcd75445 100644
--- a/rsvg_internals/src/properties.rs
+++ b/rsvg_internals/src/properties.rs
@@ -230,73 +230,73 @@ pub struct ComputedValues {
pub fn parse_property<'i>(prop_name: &QualName, input: &mut Parser<'i, '_>, accept_shorthands: bool) ->
Result<ParsedProperty, ParseError<'i>> {
// please keep these sorted
match prop_name.expanded() {
- expanded_name!(svg "baseline-shift") =>
+ expanded_name!("", "baseline-shift") =>
Ok(ParsedProperty::BaselineShift(parse_input(input)?)),
- expanded_name!(svg "clip-path") =>
+ expanded_name!("", "clip-path") =>
Ok(ParsedProperty::ClipPath(parse_input(input)?)),
- expanded_name!(svg "clip-rule") =>
+ expanded_name!("", "clip-rule") =>
Ok(ParsedProperty::ClipRule(parse_input(input)?)),
- expanded_name!(svg "color") =>
+ expanded_name!("", "color") =>
Ok(ParsedProperty::Color(parse_input(input)?)),
- expanded_name!(svg "color-interpolation-filters") =>
+ expanded_name!("", "color-interpolation-filters") =>
Ok(ParsedProperty::ColorInterpolationFilters(parse_input(input)?)),
- expanded_name!(svg "direction") =>
+ expanded_name!("", "direction") =>
Ok(ParsedProperty::Direction(parse_input(input)?)),
- expanded_name!(svg "display") =>
+ expanded_name!("", "display") =>
Ok(ParsedProperty::Display(parse_input(input)?)),
- expanded_name!(svg "enable-background") =>
+ expanded_name!("", "enable-background") =>
Ok(ParsedProperty::EnableBackground(parse_input(input)?)),
- expanded_name!(svg "fill") =>
+ expanded_name!("", "fill") =>
Ok(ParsedProperty::Fill(parse_input(input)?)),
- expanded_name!(svg "fill-opacity") =>
+ expanded_name!("", "fill-opacity") =>
Ok(ParsedProperty::FillOpacity(parse_input(input)?)),
- expanded_name!(svg "fill-rule") =>
+ expanded_name!("", "fill-rule") =>
Ok(ParsedProperty::FillRule(parse_input(input)?)),
- expanded_name!(svg "filter") =>
+ expanded_name!("", "filter") =>
Ok(ParsedProperty::Filter(parse_input(input)?)),
- expanded_name!(svg "flood-color") =>
+ expanded_name!("", "flood-color") =>
Ok(ParsedProperty::FloodColor(parse_input(input)?)),
- expanded_name!(svg "flood-opacity") =>
+ expanded_name!("", "flood-opacity") =>
Ok(ParsedProperty::FloodOpacity(parse_input(input)?)),
- expanded_name!(svg "font-family") =>
+ expanded_name!("", "font-family") =>
Ok(ParsedProperty::FontFamily(parse_input(input)?)),
- expanded_name!(svg "font-size") =>
+ expanded_name!("", "font-size") =>
Ok(ParsedProperty::FontSize(parse_input(input)?)),
- expanded_name!(svg "font-stretch") =>
+ expanded_name!("", "font-stretch") =>
Ok(ParsedProperty::FontStretch(parse_input(input)?)),
- expanded_name!(svg "font-style") =>
+ expanded_name!("", "font-style") =>
Ok(ParsedProperty::FontStyle(parse_input(input)?)),
- expanded_name!(svg "font-variant") =>
+ expanded_name!("", "font-variant") =>
Ok(ParsedProperty::FontVariant(parse_input(input)?)),
- expanded_name!(svg "font-weight") =>
+ expanded_name!("", "font-weight") =>
Ok(ParsedProperty::FontWeight(parse_input(input)?)),
- expanded_name!(svg "letter-spacing") =>
+ expanded_name!("", "letter-spacing") =>
Ok(ParsedProperty::LetterSpacing(parse_input(input)?)),
- expanded_name!(svg "lighting-color") =>
+ expanded_name!("", "lighting-color") =>
Ok(ParsedProperty::LightingColor(parse_input(input)?)),
- expanded_name!(svg "marker") => {
+ expanded_name!("", "marker") => {
if accept_shorthands {
Ok(ParsedProperty::Marker(parse_input(input)?))
} else {
@@ -304,73 +304,73 @@ pub fn parse_property<'i>(prop_name: &QualName, input: &mut Parser<'i, '_>, acce
}
}
- expanded_name!(svg "marker-end") =>
+ expanded_name!("", "marker-end") =>
Ok(ParsedProperty::MarkerEnd(parse_input(input)?)),
- expanded_name!(svg "marker-mid") =>
+ expanded_name!("", "marker-mid") =>
Ok(ParsedProperty::MarkerMid(parse_input(input)?)),
- expanded_name!(svg "marker-start") =>
+ expanded_name!("", "marker-start") =>
Ok(ParsedProperty::MarkerStart(parse_input(input)?)),
- expanded_name!(svg "mask") =>
+ expanded_name!("", "mask") =>
Ok(ParsedProperty::Mask(parse_input(input)?)),
- expanded_name!(svg "opacity") =>
+ expanded_name!("", "opacity") =>
Ok(ParsedProperty::Opacity(parse_input(input)?)),
- expanded_name!(svg "overflow") =>
+ expanded_name!("", "overflow") =>
Ok(ParsedProperty::Overflow(parse_input(input)?)),
- expanded_name!(svg "shape-rendering") =>
+ expanded_name!("", "shape-rendering") =>
Ok(ParsedProperty::ShapeRendering(parse_input(input)?)),
- expanded_name!(svg "stop-color") =>
+ expanded_name!("", "stop-color") =>
Ok(ParsedProperty::StopColor(parse_input(input)?)),
- expanded_name!(svg "stop-opacity") =>
+ expanded_name!("", "stop-opacity") =>
Ok(ParsedProperty::StopOpacity(parse_input(input)?)),
- expanded_name!(svg "stroke") =>
+ expanded_name!("", "stroke") =>
Ok(ParsedProperty::Stroke(parse_input(input)?)),
- expanded_name!(svg "stroke-dasharray") =>
+ expanded_name!("", "stroke-dasharray") =>
Ok(ParsedProperty::StrokeDasharray(parse_input(input)?)),
- expanded_name!(svg "stroke-dashoffset") =>
+ expanded_name!("", "stroke-dashoffset") =>
Ok(ParsedProperty::StrokeDashoffset(parse_input(input)?)),
- expanded_name!(svg "stroke-linecap") =>
+ expanded_name!("", "stroke-linecap") =>
Ok(ParsedProperty::StrokeLinecap(parse_input(input)?)),
- expanded_name!(svg "stroke-linejoin") =>
+ expanded_name!("", "stroke-linejoin") =>
Ok(ParsedProperty::StrokeLinejoin(parse_input(input)?)),
- expanded_name!(svg "stroke-miterlimit") =>
+ expanded_name!("", "stroke-miterlimit") =>
Ok(ParsedProperty::StrokeMiterlimit(parse_input(input)?)),
- expanded_name!(svg "stroke-opacity") =>
+ expanded_name!("", "stroke-opacity") =>
Ok(ParsedProperty::StrokeOpacity(parse_input(input)?)),
- expanded_name!(svg "stroke-width") =>
+ expanded_name!("", "stroke-width") =>
Ok(ParsedProperty::StrokeWidth(parse_input(input)?)),
- expanded_name!(svg "text-anchor") =>
+ expanded_name!("", "text-anchor") =>
Ok(ParsedProperty::TextAnchor(parse_input(input)?)),
- expanded_name!(svg "text-decoration") =>
+ expanded_name!("", "text-decoration") =>
Ok(ParsedProperty::TextDecoration(parse_input(input)?)),
- expanded_name!(svg "text-rendering") =>
+ expanded_name!("", "text-rendering") =>
Ok(ParsedProperty::TextRendering(parse_input(input)?)),
- expanded_name!(svg "unicode-bidi") =>
+ expanded_name!("", "unicode-bidi") =>
Ok(ParsedProperty::UnicodeBidi(parse_input(input)?)),
- expanded_name!(svg "visibility") =>
+ expanded_name!("", "visibility") =>
Ok(ParsedProperty::Visibility(parse_input(input)?)),
- expanded_name!(svg "writing-mode") =>
+ expanded_name!("", "writing-mode") =>
Ok(ParsedProperty::WritingMode(parse_input(input)?)),
_ => Err(ValueErrorKind::UnknownProperty)?
diff --git a/rsvg_internals/src/property_bag.rs b/rsvg_internals/src/property_bag.rs
index 685c45f5..161434d0 100644
--- a/rsvg_internals/src/property_bag.rs
+++ b/rsvg_internals/src/property_bag.rs
@@ -6,7 +6,7 @@ use std::mem;
use std::slice;
use std::str;
-use markup5ever::{namespace_url, ns, LocalName, Namespace, Prefix, QualName};
+use markup5ever::{namespace_url, LocalName, Namespace, Prefix, QualName};
use crate::util::{opt_utf8_cstr, utf8_cstr};
@@ -40,7 +40,6 @@ impl<'a> PropertyBag<'a> {
/// `attrs` array, as the property bag does not copy the strings - it directly stores pointers
/// into that array's strings.
pub unsafe fn new_from_xml2_attributes(
- element_ns: &Namespace,
n_attributes: usize,
attrs: *const *const libc::c_char,
) -> PropertyBag<'a> {
@@ -58,28 +57,14 @@ impl<'a> PropertyBag<'a> {
let localname = utf8_cstr(localname);
- let qual_name = if localname == "id" {
- // https://www.w3.org/TR/xml-names11/ section "7 Conformance of Documents"
- // "No attributes with a declared type of ID [...] contain any colons."
- //
- // I'm interpreting this to mean that the id attribute has no
- // namespace.
-
- QualName::new(None, ns!(), LocalName::from(localname))
- } else {
- let prefix = opt_utf8_cstr(prefix);
- let uri = opt_utf8_cstr(uri);
-
- // Use the namespace URI from the attribute, or if it is missing,
- // use the element's namespace, per section "6.2 Namespace Defaulting"
- // of https://www.w3.org/TR/xml-names11/
- QualName::new(
- prefix.map(Prefix::from),
- uri.map(Namespace::from)
- .unwrap_or_else(|| element_ns.clone()),
- LocalName::from(localname),
- )
- };
+ let prefix = opt_utf8_cstr(prefix);
+ let uri = opt_utf8_cstr(uri);
+ let qual_name = QualName::new(
+ prefix.map(Prefix::from),
+ uri.map(Namespace::from)
+ .unwrap_or_else(|| namespace_url!("")),
+ LocalName::from(localname),
+ );
if !value_start.is_null() && !value_end.is_null() {
assert!(value_end >= value_start);
@@ -123,13 +108,13 @@ impl<'a> Iterator for PropertyBagIter<'a> {
#[cfg(test)]
mod tests {
use super::*;
- use markup5ever::{local_name, namespace_url, ns, LocalName};
+ use markup5ever::{expanded_name, local_name, namespace_url, ns};
use std::ffi::CString;
use std::ptr;
#[test]
fn empty_property_bag() {
- let map = unsafe { PropertyBag::new_from_xml2_attributes(&ns!(svg), 0, ptr::null()) };
+ let map = unsafe { PropertyBag::new_from_xml2_attributes(0, ptr::null()) };
assert_eq!(map.len(), 0);
}
@@ -137,21 +122,21 @@ mod tests {
fn property_bag_with_namespaces() {
let attrs = [
(
- CString::new("rx").unwrap(),
- CString::new("svg").unwrap(),
- CString::new("http://www.w3.org/2000/svg").unwrap(),
+ CString::new("href").unwrap(),
+ Some(CString::new("xlink").unwrap()),
+ Some(CString::new("http://www.w3.org/1999/xlink").unwrap()),
CString::new("1").unwrap(),
),
(
CString::new("ry").unwrap(),
- CString::new("svg").unwrap(),
- CString::new("http://www.w3.org/2000/svg").unwrap(),
+ None,
+ None,
CString::new("2").unwrap(),
),
(
- CString::new("empty").unwrap(),
- CString::new("svg").unwrap(),
- CString::new("http://www.w3.org/2000/svg").unwrap(),
+ CString::new("d").unwrap(),
+ None,
+ None,
CString::new("").unwrap(),
),
];
@@ -160,8 +145,17 @@ mod tests {
for (localname, prefix, uri, val) in &attrs {
v.push(localname.as_ptr() as *const libc::c_char);
- v.push(prefix.as_ptr() as *const libc::c_char);
- v.push(uri.as_ptr() as *const libc::c_char);
+ v.push(
+ prefix
+ .as_ref()
+ .map(|p: &CString| p.as_ptr())
+ .unwrap_or_else(|| ptr::null()) as *const libc::c_char,
+ );
+ v.push(
+ uri.as_ref()
+ .map(|p: &CString| p.as_ptr())
+ .unwrap_or_else(|| ptr::null()) as *const libc::c_char,
+ );
let val_start = val.as_ptr() as *const libc::c_char;
let val_end = unsafe { val_start.offset(val.as_bytes().len() as isize) };
@@ -169,35 +163,35 @@ mod tests {
v.push(val_end); // value_end
}
- let pbag = unsafe { PropertyBag::new_from_xml2_attributes(&ns!(svg), 3, v.as_ptr()) };
+ let pbag = unsafe { PropertyBag::new_from_xml2_attributes(3, v.as_ptr()) };
- let mut had_rx: bool = false;
+ let mut had_href: bool = false;
let mut had_ry: bool = false;
- let mut had_empty: bool = false;
+ let mut had_d: bool = false;
for (a, v) in pbag.iter() {
- assert_eq!(a.prefix.as_ref().unwrap(), "svg");
- assert_eq!(a.ns, ns!(svg));
-
- match a.local {
- local_name!("rx") => {
+ match a.expanded() {
+ expanded_name!(xlink "href") => {
assert!(v == "1");
- had_rx = true;
+ had_href = true;
}
- local_name!("ry") => {
+
+ expanded_name!("", "ry") => {
assert!(v == "2");
had_ry = true;
}
- ref n if *n == LocalName::from("empty") => {
+
+ expanded_name!("", "d") => {
assert!(v == "");
- had_empty = true;
+ had_d = true;
}
+
_ => unreachable!(),
}
}
- assert!(had_rx);
+ assert!(had_href);
assert!(had_ry);
- assert!(had_empty);
+ assert!(had_d);
}
}
diff --git a/rsvg_internals/src/shapes.rs b/rsvg_internals/src/shapes.rs
index 323f3c61..0c827a6a 100644
--- a/rsvg_internals/src/shapes.rs
+++ b/rsvg_internals/src/shapes.rs
@@ -108,7 +108,7 @@ pub struct Path {
impl NodeTrait for Path {
fn set_atts(&mut self, _: Option<&RsvgNode>, pbag: &PropertyBag<'_>) -> NodeResult {
for (attr, value) in pbag.iter() {
- if attr.expanded() == expanded_name!(svg "d") {
+ if attr.expanded() == expanded_name!("", "d") {
let mut builder = PathBuilder::new();
if let Err(e) = path_parser::parse_path_into_builder(value, &mut builder) {
// FIXME: we don't propagate errors upstream, but creating a partial
@@ -205,7 +205,7 @@ pub struct Polygon {
impl NodeTrait for Polygon {
fn set_atts(&mut self, _: Option<&RsvgNode>, pbag: &PropertyBag<'_>) -> NodeResult {
for (attr, value) in pbag.iter() {
- if attr.expanded() == expanded_name!(svg "points") {
+ if attr.expanded() == expanded_name!("", "points") {
self.points = attr.parse(value).map(Some)?;
}
}
@@ -234,7 +234,7 @@ pub struct Polyline {
impl NodeTrait for Polyline {
fn set_atts(&mut self, _: Option<&RsvgNode>, pbag: &PropertyBag<'_>) -> NodeResult {
for (attr, value) in pbag.iter() {
- if attr.expanded() == expanded_name!(svg "points") {
+ if attr.expanded() == expanded_name!("", "points") {
self.points = attr.parse(value).map(Some)?;
}
}
@@ -270,10 +270,10 @@ impl NodeTrait for Line {
fn set_atts(&mut self, _: Option<&RsvgNode>, pbag: &PropertyBag<'_>) -> NodeResult {
for (attr, value) in pbag.iter() {
match attr.expanded() {
- expanded_name!(svg "x1") => self.x1 = attr.parse(value)?,
- expanded_name!(svg "y1") => self.y1 = attr.parse(value)?,
- expanded_name!(svg "x2") => self.x2 = attr.parse(value)?,
- expanded_name!(svg "y2") => self.y2 = attr.parse(value)?,
+ expanded_name!("", "x1") => self.x1 = attr.parse(value)?,
+ expanded_name!("", "y1") => self.y1 = attr.parse(value)?,
+ expanded_name!("", "x2") => self.x2 = attr.parse(value)?,
+ expanded_name!("", "y2") => self.y2 = attr.parse(value)?,
_ => (),
}
}
@@ -331,22 +331,22 @@ impl NodeTrait for Rect {
fn set_atts(&mut self, _: Option<&RsvgNode>, pbag: &PropertyBag<'_>) -> NodeResult {
for (attr, value) in pbag.iter() {
match attr.expanded() {
- expanded_name!(svg "x") => self.x = attr.parse(value)?,
- expanded_name!(svg "y") => self.y = attr.parse(value)?,
- expanded_name!(svg "width") => {
+ expanded_name!("", "x") => self.x = attr.parse(value)?,
+ expanded_name!("", "y") => self.y = attr.parse(value)?,
+ expanded_name!("", "width") => {
self.w =
attr.parse_and_validate(value, Length::<Horizontal>::check_nonnegative)?
}
- expanded_name!(svg "height") => {
+ expanded_name!("", "height") => {
self.h =
attr.parse_and_validate(value, Length::<Vertical>::check_nonnegative)?
}
- expanded_name!(svg "rx") => {
+ expanded_name!("", "rx") => {
self.rx = attr
.parse_and_validate(value, Length::<Horizontal>::check_nonnegative)
.map(Some)?
}
- expanded_name!(svg "ry") => {
+ expanded_name!("", "ry") => {
self.ry = attr
.parse_and_validate(value, Length::<Vertical>::check_nonnegative)
.map(Some)?
@@ -558,9 +558,9 @@ impl NodeTrait for Circle {
fn set_atts(&mut self, _: Option<&RsvgNode>, pbag: &PropertyBag<'_>) -> NodeResult {
for (attr, value) in pbag.iter() {
match attr.expanded() {
- expanded_name!(svg "cx") => self.cx = attr.parse(value)?,
- expanded_name!(svg "cy") => self.cy = attr.parse(value)?,
- expanded_name!(svg "r") => {
+ expanded_name!("", "cx") => self.cx = attr.parse(value)?,
+ expanded_name!("", "cy") => self.cy = attr.parse(value)?,
+ expanded_name!("", "r") => {
self.r = attr.parse_and_validate(value, Length::<Both>::check_nonnegative)?
}
_ => (),
@@ -610,13 +610,13 @@ impl NodeTrait for Ellipse {
fn set_atts(&mut self, _: Option<&RsvgNode>, pbag: &PropertyBag<'_>) -> NodeResult {
for (attr, value) in pbag.iter() {
match attr.expanded() {
- expanded_name!(svg "cx") => self.cx = attr.parse(value)?,
- expanded_name!(svg "cy") => self.cy = attr.parse(value)?,
- expanded_name!(svg "rx") => {
+ expanded_name!("", "cx") => self.cx = attr.parse(value)?,
+ expanded_name!("", "cy") => self.cy = attr.parse(value)?,
+ expanded_name!("", "rx") => {
self.rx =
attr.parse_and_validate(value, Length::<Horizontal>::check_nonnegative)?
}
- expanded_name!(svg "ry") => {
+ expanded_name!("", "ry") => {
self.ry =
attr.parse_and_validate(value, Length::<Vertical>::check_nonnegative)?
}
diff --git a/rsvg_internals/src/structure.rs b/rsvg_internals/src/structure.rs
index 4bfa1d9c..765c25d2 100644
--- a/rsvg_internals/src/structure.rs
+++ b/rsvg_internals/src/structure.rs
@@ -182,21 +182,21 @@ impl NodeTrait for Svg {
for (attr, value) in pbag.iter() {
match attr.expanded() {
- expanded_name!(svg "preserveAspectRatio") => {
+ expanded_name!("", "preserveAspectRatio") => {
self.preserve_aspect_ratio = attr.parse(value)?
}
- expanded_name!(svg "x") if is_inner_svg => self.x = Some(attr.parse(value)?),
- expanded_name!(svg "y") if is_inner_svg => self.y = Some(attr.parse(value)?),
- expanded_name!(svg "width") => {
+ expanded_name!("", "x") if is_inner_svg => self.x = Some(attr.parse(value)?),
+ expanded_name!("", "y") if is_inner_svg => self.y = Some(attr.parse(value)?),
+ expanded_name!("", "width") => {
self.w = Some(
attr.parse_and_validate(value, Length::<Horizontal>::check_nonnegative)?,
)
}
- expanded_name!(svg "height") => {
+ expanded_name!("", "height") => {
self.h =
Some(attr.parse_and_validate(value, Length::<Vertical>::check_nonnegative)?)
}
- expanded_name!(svg "viewBox") => self.vbox = attr.parse(value).map(Some)?,
+ expanded_name!("", "viewBox") => self.vbox = attr.parse(value).map(Some)?,
_ => (),
}
}
@@ -305,14 +305,14 @@ impl NodeTrait for Use {
expanded_name!(xlink "href") => {
self.link = Some(Fragment::parse(value).attribute(attr)?)
}
- expanded_name!(svg "x") => self.x = attr.parse(value)?,
- expanded_name!(svg "y") => self.y = attr.parse(value)?,
- expanded_name!(svg "width") => {
+ expanded_name!("", "x") => self.x = attr.parse(value)?,
+ expanded_name!("", "y") => self.y = attr.parse(value)?,
+ expanded_name!("", "width") => {
self.w = attr
.parse_and_validate(value, Length::<Horizontal>::check_nonnegative)
.map(Some)?
}
- expanded_name!(svg "height") => {
+ expanded_name!("", "height") => {
self.h = attr
.parse_and_validate(value, Length::<Vertical>::check_nonnegative)
.map(Some)?
@@ -355,10 +355,10 @@ impl NodeTrait for Symbol {
fn set_atts(&mut self, _parent: Option<&RsvgNode>, pbag: &PropertyBag<'_>) -> NodeResult {
for (attr, value) in pbag.iter() {
match attr.expanded() {
- expanded_name!(svg "preserveAspectRatio") => {
+ expanded_name!("", "preserveAspectRatio") => {
self.preserve_aspect_ratio = attr.parse(value)?
}
- expanded_name!(svg "viewBox") => self.vbox = attr.parse(value).map(Some)?,
+ expanded_name!("", "viewBox") => self.vbox = attr.parse(value).map(Some)?,
_ => (),
}
}
@@ -388,7 +388,7 @@ impl NodeTrait for ClipPath {
fn set_atts(&mut self, _: Option<&RsvgNode>, pbag: &PropertyBag<'_>) -> NodeResult {
for (attr, value) in pbag.iter() {
match attr.expanded() {
- expanded_name!(svg "clipPathUnits") => self.units = attr.parse(value)?,
+ expanded_name!("", "clipPathUnits") => self.units = attr.parse(value)?,
_ => (),
}
}
@@ -448,18 +448,18 @@ impl NodeTrait for Mask {
fn set_atts(&mut self, _: Option<&RsvgNode>, pbag: &PropertyBag<'_>) -> NodeResult {
for (attr, value) in pbag.iter() {
match attr.expanded() {
- expanded_name!(svg "x") => self.x = attr.parse(value)?,
- expanded_name!(svg "y") => self.y = attr.parse(value)?,
- expanded_name!(svg "width") => {
+ expanded_name!("", "x") => self.x = attr.parse(value)?,
+ expanded_name!("", "y") => self.y = attr.parse(value)?,
+ expanded_name!("", "width") => {
self.width =
attr.parse_and_validate(value, Length::<Horizontal>::check_nonnegative)?
}
- expanded_name!(svg "height") => {
+ expanded_name!("", "height") => {
self.height =
attr.parse_and_validate(value, Length::<Vertical>::check_nonnegative)?
}
- expanded_name!(svg "maskUnits") => self.units = attr.parse(value)?,
- expanded_name!(svg "maskContentUnits") => self.content_units = attr.parse(value)?,
+ expanded_name!("", "maskUnits") => self.units = attr.parse(value)?,
+ expanded_name!("", "maskContentUnits") => self.content_units = attr.parse(value)?,
_ => (),
}
}
diff --git a/rsvg_internals/src/style.rs b/rsvg_internals/src/style.rs
index 296ab15f..4f395a0e 100644
--- a/rsvg_internals/src/style.rs
+++ b/rsvg_internals/src/style.rs
@@ -44,7 +44,7 @@ impl Style {
impl NodeTrait for Style {
fn set_atts(&mut self, _: Option<&RsvgNode>, pbag: &PropertyBag<'_>) -> NodeResult {
for (attr, value) in pbag.iter() {
- if attr.expanded() == expanded_name!(svg "type") {
+ if attr.expanded() == expanded_name!("", "type") {
self.type_ = Some(attr.parse(value)?);
}
}
diff --git a/rsvg_internals/src/text.rs b/rsvg_internals/src/text.rs
index ce3bb5b6..2ad63683 100644
--- a/rsvg_internals/src/text.rs
+++ b/rsvg_internals/src/text.rs
@@ -595,10 +595,10 @@ impl NodeTrait for Text {
fn set_atts(&mut self, _: Option<&RsvgNode>, pbag: &PropertyBag<'_>) -> NodeResult {
for (attr, value) in pbag.iter() {
match attr.expanded() {
- expanded_name!(svg "x") => self.x = attr.parse(value)?,
- expanded_name!(svg "y") => self.y = attr.parse(value)?,
- expanded_name!(svg "dx") => self.dx = attr.parse(value).map(Some)?,
- expanded_name!(svg "dy") => self.dy = attr.parse(value).map(Some)?,
+ expanded_name!("", "x") => self.x = attr.parse(value)?,
+ expanded_name!("", "y") => self.y = attr.parse(value)?,
+ expanded_name!("", "dx") => self.dx = attr.parse(value).map(Some)?,
+ expanded_name!("", "dy") => self.dy = attr.parse(value).map(Some)?,
_ => (),
}
}
@@ -755,10 +755,10 @@ impl NodeTrait for TSpan {
fn set_atts(&mut self, _: Option<&RsvgNode>, pbag: &PropertyBag<'_>) -> NodeResult {
for (attr, value) in pbag.iter() {
match attr.expanded() {
- expanded_name!(svg "x") => self.x = attr.parse(value).map(Some)?,
- expanded_name!(svg "y") => self.y = attr.parse(value).map(Some)?,
- expanded_name!(svg "dx") => self.dx = attr.parse(value).map(Some)?,
- expanded_name!(svg "dy") => self.dy = attr.parse(value).map(Some)?,
+ expanded_name!("", "x") => self.x = attr.parse(value).map(Some)?,
+ expanded_name!("", "y") => self.y = attr.parse(value).map(Some)?,
+ expanded_name!("", "dx") => self.dx = attr.parse(value).map(Some)?,
+ expanded_name!("", "dy") => self.dy = attr.parse(value).map(Some)?,
_ => (),
}
}
diff --git a/rsvg_internals/src/xml.rs b/rsvg_internals/src/xml.rs
index 0dbc4305..570b895f 100644
--- a/rsvg_internals/src/xml.rs
+++ b/rsvg_internals/src/xml.rs
@@ -396,11 +396,13 @@ impl XmlState {
let mut parse = None;
let mut encoding = None;
+ let ln_parse = LocalName::from("parse");
+
for (attr, value) in pbag.iter() {
match attr.expanded() {
- ref n if *n == xinclude_name!("href") => href = Some(value),
- ref n if *n == xinclude_name!("parse") => parse = Some(value),
- ref n if *n == xinclude_name!("encoding") => encoding = Some(value),
+ expanded_name!("", "href") => href = Some(value),
+ ref v if *v == ExpandedName { ns: &ns!(), local: &ln_parse } => parse = Some(value),
+ expanded_name!("", "encoding") => encoding = Some(value),
_ => (),
}
}
diff --git a/rsvg_internals/src/xml2_load.rs b/rsvg_internals/src/xml2_load.rs
index 99fa0514..97dda12c 100644
--- a/rsvg_internals/src/xml2_load.rs
+++ b/rsvg_internals/src/xml2_load.rs
@@ -215,11 +215,7 @@ unsafe extern "C" fn sax_start_element_ns_cb(
let qual_name = make_qual_name(prefix, uri, localname);
let nb_attributes = nb_attributes as usize;
- let pbag = PropertyBag::new_from_xml2_attributes(
- &qual_name.ns,
- nb_attributes,
- attributes as *const *const _,
- );
+ let pbag = PropertyBag::new_from_xml2_attributes(nb_attributes, attributes as *const *const _);
if let Err(e) = xml2_parser.state.start_element(qual_name, &pbag) {
let _: () = e; // guard in case we change the error type later
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]