[librsvg: 35/43] Convert XmlLang, XmlSpace to CssParseError
- From: Federico Mena Quintero <federico src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [librsvg: 35/43] Convert XmlLang, XmlSpace to CssParseError
- Date: Sat, 21 Dec 2019 02:32:26 +0000 (UTC)
commit 7c31e6941c79fc19d5dd27e21ab094a691799721
Author: Federico Mena Quintero <federico gnome org>
Date: Fri Dec 20 18:46:04 2019 -0600
Convert XmlLang, XmlSpace to CssParseError
rsvg_internals/src/properties.rs | 8 +++-----
rsvg_internals/src/property_defs.rs | 14 +++++++-------
2 files changed, 10 insertions(+), 12 deletions(-)
---
diff --git a/rsvg_internals/src/properties.rs b/rsvg_internals/src/properties.rs
index 8bb675b3..63b293f1 100644
--- a/rsvg_internals/src/properties.rs
+++ b/rsvg_internals/src/properties.rs
@@ -8,7 +8,7 @@ use std::collections::HashSet;
use crate::css::{DeclParser, Declaration};
use crate::error::*;
-use crate::parsers::{Parse, ParseToParseError};
+use crate::parsers::{ParseToParseError, ParseValueToParseError};
use crate::property_bag::PropertyBag;
use crate::property_defs::*;
use crate::property_macros::Property;
@@ -624,16 +624,14 @@ impl SpecifiedValues {
// xml:lang is a non-presentation attribute and as such cannot have the
// "inherit" value. So, we don't call parse_one_presentation_attribute()
// for it, but rather call its parser directly.
- self.xml_lang =
- SpecifiedValue::Specified(XmlLang::parse_str(value).attribute(attr)?);
+ self.xml_lang = SpecifiedValue::Specified(attr.parse_to_parse_error(value)?);
}
expanded_name!(svg "xml:space") => {
// xml:space is a non-presentation attribute and as such cannot have the
// "inherit" value. So, we don't call parse_one_presentation_attribute()
// for it, but rather call its parser directly.
- self.xml_space =
-
SpecifiedValue::Specified(XmlSpace::parse_str_to_parse_error(value).attribute(attr)?);
+ self.xml_space = SpecifiedValue::Specified(attr.parse_to_parse_error(value)?);
}
_ => self.parse_one_presentation_attribute(attr, value)?,
diff --git a/rsvg_internals/src/property_defs.rs b/rsvg_internals/src/property_defs.rs
index 2db61b75..ce18d08a 100644
--- a/rsvg_internals/src/property_defs.rs
+++ b/rsvg_internals/src/property_defs.rs
@@ -8,7 +8,7 @@ use crate::font_props::{FontSizeSpec, FontWeightSpec, LetterSpacingSpec, SingleF
use crate::iri::IRI;
use crate::length::*;
use crate::paint_server::PaintServer;
-use crate::parsers::{Parse, ParseToParseError};
+use crate::parsers::ParseToParseError;
use crate::properties::ComputedValues;
use crate::property_macros::Property;
use crate::unit_interval::UnitInterval;
@@ -688,10 +688,10 @@ make_property!(
inherits_automatically: true,
newtype: String,
parse_impl: {
- impl Parse for XmlLang {
- fn parse(
- parser: &mut Parser<'_, '_>,
- ) -> Result<XmlLang, ValueErrorKind> {
+ impl ParseToParseError for XmlLang {
+ fn parse_to_parse_error<'i>(
+ parser: &mut Parser<'i, '_>,
+ ) -> Result<XmlLang, CssParseError<'i>> {
Ok(XmlLang(parser.expect_ident()?.to_string()))
}
}
@@ -702,11 +702,11 @@ make_property!(
#[test]
fn parses_xml_lang() {
assert_eq!(
- XmlLang::parse_str("es-MX").unwrap(),
+ XmlLang::parse_str_to_parse_error("es-MX").unwrap(),
XmlLang("es-MX".to_string())
);
- assert!(XmlLang::parse_str("").is_err());
+ assert!(XmlLang::parse_str_to_parse_error("").is_err());
}
make_property!(
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]