summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--Makefile.am2
-rw-r--r--doc/Makefile.am4
-rw-r--r--include/librsvg/rsvg-css.h63
-rw-r--r--po/POTFILES.in1
-rw-r--r--rsvg-c-srcs.mk4
-rw-r--r--src/c_api/color_utils.rs179
-rw-r--r--src/c_api/mod.rs3
7 files changed, 1 insertions, 255 deletions
diff --git a/Makefile.am b/Makefile.am
index 6400ea63..15c39266 100644
--- a/Makefile.am
+++ b/Makefile.am
@@ -23,7 +23,6 @@ include rsvg-c-srcs.mk
librsvg_@RSVG_API_MAJOR_VERSION@_la_SOURCES = \
$(librsvg_public_headers) \
- $(librsvg_private_headers) \
$(NULL)
LIBRSVG_SRC = \
@@ -33,7 +32,6 @@ LIBRSVG_SRC = \
src/api.rs \
src/aspect_ratio.rs \
src/bbox.rs \
- src/c_api/color_utils.rs \
src/c_api/dpi.rs \
src/c_api/handle.rs \
src/c_api/messages.rs \
diff --git a/doc/Makefile.am b/doc/Makefile.am
index 5d383a5f..63f6701d 100644
--- a/doc/Makefile.am
+++ b/doc/Makefile.am
@@ -62,9 +62,7 @@ EXTRA_HFILES = $(top_builddir)/include/librsvg/rsvg-version.h
# Header files to ignore when scanning. Use base file name, no paths
# e.g. IGNORE_HFILES=gtkdebug.h gtkintl.h
-IGNORE_HFILES = \
- config.h \
- rsvg-css.h
+IGNORE_HFILES = config.h
# Images to copy into HTML directory.
# e.g. HTML_IMAGES=$(top_srcdir)/gtk/stock-icons/stock_about_24.png
diff --git a/include/librsvg/rsvg-css.h b/include/librsvg/rsvg-css.h
deleted file mode 100644
index dfca15b0..00000000
--- a/include/librsvg/rsvg-css.h
+++ /dev/null
@@ -1,63 +0,0 @@
-/* -*- Mode: C; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
-/* vim: set sw=4 sts=4 expandtab: */
-/*
- rsvg-css.h : CSS utility functions
-
- Copyright (C) 2000 Eazel, Inc.
- Copyright (C) 2002 Dom Lachowicz <cinamod@hotmail.com>
-
- This library is free software; you can redistribute it and/or
- modify it under the terms of the GNU Lesser General Public
- License as published by the Free Software Foundation; either
- version 2.1 of the License, or (at your option) any later version.
-
- This library is distributed in the hope that it will be useful,
- but WITHOUT ANY WARRANTY; without even the implied warranty of
- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- Lesser General Public License for more details.
-
- You should have received a copy of the GNU Lesser General Public
- License along with this library; if not, write to the Free Software
- Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
-
- Author: Raph Levien <raph@artofcode.com>
-*/
-#ifndef RSVG_CSS_H
-#define RSVG_CSS_H
-
-#include <glib.h>
-
-/* Override to export public/semi-public APIs */
-#ifndef RSVG_API
-# define RSVG_API
-#endif
-
-G_BEGIN_DECLS
-
-/* Keep this in sync with rust/src/color.rs:ColorKind */
-typedef enum {
- RSVG_CSS_COLOR_SPEC_ARGB,
- RSVG_CSS_COLOR_PARSE_ERROR
-} RsvgCssColorKind;
-
-/* Keep this in sync with rust/src/color.rs:RsvgCssColor */
-typedef struct {
- RsvgCssColorKind kind;
- guint32 argb; /* only valid if kind == RSVG_CSS_COLOR_SPEC_ARGB */
-} RsvgCssColorSpec;
-
-/* This one is semi-public for mis-use in rsvg-convert */
-RSVG_API
-RsvgCssColorSpec rsvg_css_parse_color (const char *str);
-
-#ifdef RSVG_COMPILATION
-
-/* Implemented in rust/src/color.rs */
-G_GNUC_INTERNAL
-RsvgCssColorSpec rsvg_css_parse_color (const char *str);
-
-#endif /* RSVG_COMPILATION */
-
-G_END_DECLS
-
-#endif
diff --git a/po/POTFILES.in b/po/POTFILES.in
index e8e277ad..0eec6d32 100644
--- a/po/POTFILES.in
+++ b/po/POTFILES.in
@@ -4,7 +4,6 @@ src/angle.rs
src/api.rs
src/aspect_ratio.rs
src/bbox.rs
-src/c_api/color_utils.rs
src/c_api/dpi.rs
src/c_api/handle.rs
src/c_api/messages.rs
diff --git a/rsvg-c-srcs.mk b/rsvg-c-srcs.mk
index 3c4756d9..3bc0de7c 100644
--- a/rsvg-c-srcs.mk
+++ b/rsvg-c-srcs.mk
@@ -4,7 +4,3 @@ librsvg_public_headers = \
include/librsvg/rsvg-features.h \
include/librsvg/rsvg-version.h \
$(NULL)
-
-librsvg_private_headers = \
- include/librsvg/rsvg-css.h \
- $(NULL)
diff --git a/src/c_api/color_utils.rs b/src/c_api/color_utils.rs
deleted file mode 100644
index 1f1393fc..00000000
--- a/src/c_api/color_utils.rs
+++ /dev/null
@@ -1,179 +0,0 @@
-use std::ffi::CStr;
-
-use crate::{color::Color, parsers::Parse};
-
-// There are two quirks here:
-//
-// First, we need to expose the Color algebraic type *and* a parse
-// error to C, but we can't repr(C) them plainly. So, we define a
-// ColorKind enum and a ColorSpec struct that can both be represented
-// in C.
-//
-// Second, the C code in librsvg expects ARGB colors passed around as
-// guint32. However, in Rust we'd prefer to use cssparser's RGBA
-// structure, which has explicit fields for red/green/blue/alpha.
-// We'll do those conversions here, for the benefit of the C code, and
-// then just wait until the C code gradually disappears.
-
-// Keep this in sync with rsvg-css.h:RsvgCssColorKind
-#[repr(C)]
-#[derive(Clone, Copy, PartialEq, Debug)]
-enum ColorKind {
- ARGB,
- ParseError,
-}
-
-// Keep this in sync with rsvg-css.h:RsvgCssColorSpec
-#[repr(C)]
-#[derive(Clone, Copy, PartialEq, Debug)]
-pub struct ColorSpec {
- kind: ColorKind,
- argb: u32,
-}
-
-fn rgba_to_argb(r: u8, g: u8, b: u8, a: u8) -> u32 {
- u32::from(a) << 24 | u32::from(r) << 16 | u32::from(g) << 8 | u32::from(b)
-}
-
-#[no_mangle]
-pub unsafe extern "C" fn rsvg_css_parse_color(string: *const libc::c_char) -> ColorSpec {
- let s = CStr::from_ptr(string).to_string_lossy();
- let r = <Color as Parse>::parse_str(&s);
-
- match r {
- Ok(Color::RGBA(rgba)) => ColorSpec {
- kind: ColorKind::ARGB,
- argb: rgba_to_argb(rgba.red, rgba.green, rgba.blue, rgba.alpha),
- },
-
- _ => ColorSpec {
- kind: ColorKind::ParseError,
- argb: 0,
- },
- }
-}
-
-#[cfg(test)]
-mod tests {
- use super::*;
- use glib::translate::*;
-
- fn parse(s: &str) -> ColorSpec {
- unsafe { rsvg_css_parse_color(s.to_glib_none().0) }
- }
-
- #[test]
- fn parses_hash_hex_colors() {
- assert_eq!(
- parse("#AB10fa20"),
- ColorSpec {
- kind: ColorKind::ARGB,
- argb: 0x20ab10fa,
- }
- );
- assert_eq!(
- parse("#10fa20"),
- ColorSpec {
- kind: ColorKind::ARGB,
- argb: 0xff10fa20,
- }
- );
- assert_eq!(
- parse("#abcd"),
- ColorSpec {
- kind: ColorKind::ARGB,
- argb: 0xddaabbcc,
- }
- );
- assert_eq!(
- parse("#123"),
- ColorSpec {
- kind: ColorKind::ARGB,
- argb: 0xff112233,
- }
- );
- }
-
- #[test]
- fn parses_color_keywords() {
- assert_eq!(
- parse("red"),
- ColorSpec {
- kind: ColorKind::ARGB,
- argb: 0xffff0000,
- }
- );
- assert_eq!(
- parse("lime"),
- ColorSpec {
- kind: ColorKind::ARGB,
- argb: 0xff00ff00,
- }
- );
- assert_eq!(
- parse("blue"),
- ColorSpec {
- kind: ColorKind::ARGB,
- argb: 0xff0000ff,
- }
- );
- }
-
- #[test]
- fn parses_color_functions() {
- assert_eq!(
- parse("rgb(255, 0, 0)"),
- ColorSpec {
- kind: ColorKind::ARGB,
- argb: 0xffff0000,
- }
- );
- assert_eq!(
- parse("rgb(0, 255, 0)"),
- ColorSpec {
- kind: ColorKind::ARGB,
- argb: 0xff00ff00,
- }
- );
- assert_eq!(
- parse("rgb(0, 0, 255)"),
- ColorSpec {
- kind: ColorKind::ARGB,
- argb: 0xff0000ff,
- }
- );
- }
-
- #[test]
- fn current_color_is_error() {
- assert_eq!(
- parse("currentColor"),
- ColorSpec {
- kind: ColorKind::ParseError,
- argb: 0,
- }
- );
- }
-
- fn make_error() -> ColorSpec {
- ColorSpec {
- kind: ColorKind::ParseError,
- argb: 0,
- }
- }
-
- #[test]
- fn invalid_hash_hex_colors_yield_error() {
- assert_eq!(parse("#"), make_error());
- assert_eq!(parse("#xyz"), make_error());
- assert_eq!(parse("#112233gg"), make_error());
- }
-
- #[test]
- fn invalid_colors_yield_error() {
- assert_eq!(parse(""), make_error());
- assert_eq!(parse("foo"), make_error());
- assert_eq!(parse("rgb(chilaquil)"), make_error());
- assert_eq!(parse("rgb(1, 2, 3, 4, 5)"), make_error());
- }
-}
diff --git a/src/c_api/mod.rs b/src/c_api/mod.rs
index b59fe8b1..fae73f75 100644
--- a/src/c_api/mod.rs
+++ b/src/c_api/mod.rs
@@ -33,8 +33,6 @@ pub use handle::{
rsvg_handle_write,
};
-pub use color_utils::rsvg_css_parse_color;
-
pub use dpi::{rsvg_set_default_dpi, rsvg_set_default_dpi_x_y};
#[rustfmt::skip]
@@ -49,7 +47,6 @@ pub use pixbuf_utils::{
#[macro_use]
mod messages;
-mod color_utils;
mod dpi;
pub mod handle;
pub mod pixbuf_utils;