[librsvg] Don't parse "inherit" for rsvg_css_parse_color()
- From: Federico Mena Quintero <federico src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [librsvg] Don't parse "inherit" for rsvg_css_parse_color()
- Date: Tue, 14 Jan 2020 02:14:05 +0000 (UTC)
commit 54eb9107fccb3146204ab30c5a886a6f45c70823
Author: Federico Mena Quintero <federico gnome org>
Date: Mon Jan 13 20:11:58 2020 -0600
Don't parse "inherit" for rsvg_css_parse_color()
This is not needed by rsvg-convert.
librsvg/rsvg-css.h | 1 -
rsvg_internals/src/color.rs | 23 +++++------------------
2 files changed, 5 insertions(+), 19 deletions(-)
---
diff --git a/librsvg/rsvg-css.h b/librsvg/rsvg-css.h
index f209a821..babf1dc5 100644
--- a/librsvg/rsvg-css.h
+++ b/librsvg/rsvg-css.h
@@ -36,7 +36,6 @@ G_BEGIN_DECLS
/* Keep this in sync with rust/src/color.rs:ColorKind */
typedef enum {
- RSVG_CSS_COLOR_SPEC_INHERIT,
RSVG_CSS_COLOR_SPEC_CURRENT_COLOR,
RSVG_CSS_COLOR_SPEC_ARGB,
RSVG_CSS_COLOR_PARSE_ERROR
diff --git a/rsvg_internals/src/color.rs b/rsvg_internals/src/color.rs
index ddd271fe..464ac3c3 100644
--- a/rsvg_internals/src/color.rs
+++ b/rsvg_internals/src/color.rs
@@ -45,7 +45,6 @@ impl Parse for cssparser::RGBA {
#[repr(C)]
#[derive(Clone, Copy, PartialEq, Debug)]
pub enum ColorKind {
- Inherit,
CurrentColor,
ARGB,
ParseError,
@@ -66,20 +65,15 @@ pub fn rgba_to_argb(rgba: cssparser::RGBA) -> u32 {
| u32::from(rgba.blue)
}
-impl<'i> From<Result<Option<cssparser::Color>, ParseError<'i>>> for ColorSpec {
- fn from(result: Result<Option<cssparser::Color>, ParseError<'i>>) -> ColorSpec {
+impl<'i> From<Result<cssparser::Color, ParseError<'i>>> for ColorSpec {
+ fn from(result: Result<cssparser::Color, ParseError<'i>>) -> ColorSpec {
match result {
- Ok(None) => ColorSpec {
- kind: ColorKind::Inherit,
- argb: 0,
- },
-
- Ok(Some(cssparser::Color::CurrentColor)) => ColorSpec {
+ Ok(cssparser::Color::CurrentColor) => ColorSpec {
kind: ColorKind::CurrentColor,
argb: 0,
},
- Ok(Some(cssparser::Color::RGBA(rgba))) => ColorSpec {
+ Ok(cssparser::Color::RGBA(rgba)) => ColorSpec {
kind: ColorKind::ARGB,
argb: rgba_to_argb(rgba),
},
@@ -96,14 +90,7 @@ impl<'i> From<Result<Option<cssparser::Color>, ParseError<'i>>> for ColorSpec {
pub extern "C" fn rsvg_css_parse_color(string: *const libc::c_char) -> ColorSpec {
let s = unsafe { utf8_cstr(string) };
- if s == "inherit" {
- ColorSpec {
- kind: ColorKind::Inherit,
- argb: 0,
- }
- } else {
- ColorSpec::from(<Color as Parse>::parse_str(s).map(Some))
- }
+ ColorSpec::from(<Color as Parse>::parse_str(s))
}
#[cfg(test)]
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]