Commit 3c950c14 authored by Christian Persch's avatar Christian Persch

Hard-depend on libcroco

parent 59a3fed3
......@@ -88,14 +88,12 @@ librsvg_@RSVG_API_MAJOR_VERSION@_la_CPPFLAGS = \
librsvg_@RSVG_API_MAJOR_VERSION@_la_CFLAGS = \
$(LIBRSVG_CFLAGS) \
$(LIBCROCO_CFLAGS) \
$(AM_CFLAGS)
librsvg_@RSVG_API_MAJOR_VERSION@_la_LDFLAGS = -version-info @RSVG_LT_VERSION_INFO@ -export-dynamic -no-undefined -export-symbols $(srcdir)/librsvg.def $(AM_LDFLAGS)
librsvg_@RSVG_API_MAJOR_VERSION@_la_LIBADD = \
$(LIBRSVG_LIBS) \
$(LIBCROCO_LIBS) \
$(libm)
librsvgincdir = $(includedir)/librsvg-$(RSVG_API_VERSION)/librsvg
......@@ -120,7 +118,6 @@ rsvg_convert_CPPFLAGS = \
rsvg_convert_CFLAGS =\
$(LIBRSVG_CFLAGS) \
$(LIBCROCO_CFLAGS) \
$(AM_CFLAGS)
rsvg_convert_LDFLAGS = $(AM_LDFLAGS)
......@@ -128,7 +125,6 @@ rsvg_convert_LDFLAGS = $(AM_LDFLAGS)
rsvg_convert_LDADD = \
$(top_builddir)/librsvg-@RSVG_API_MAJOR_VERSION@.la \
$(LIBRSVG_LIBS) \
$(LIBCROCO_LIBS) \
$(GTHREAD_LIBS) \
$(libm)
......@@ -144,7 +140,6 @@ rsvg_view_CPPFLAGS = \
rsvg_view_CFLAGS =\
$(GTK2_CFLAGS) \
$(LIBRSVG_CFLAGS) \
$(LIBCROCO_CFLAGS) \
$(AM_CFLAGS)
rsvg_view_LDFLAGS =
......@@ -153,7 +148,6 @@ rsvg_view_LDADD = \
$(top_builddir)/librsvg-@RSVG_API_MAJOR_VERSION@.la \
$(GTK2_LIBS) \
$(LIBRSVG_LIBS) \
$(LIBCROCO_LIBS) \
$(GTHREAD_LIBS) \
$(libm)
......@@ -169,7 +163,6 @@ rsvg_view_3_CPPFLAGS = \
rsvg_view_3_CFLAGS =\
$(GTK3_CFLAGS) \
$(LIBRSVG_CFLAGS) \
$(LIBCROCO_CFLAGS) \
$(AM_CFLAGS)
rsvg_view_3_LDFLAGS =
......@@ -178,7 +171,6 @@ rsvg_view_3_LDADD = \
$(top_builddir)/librsvg-@RSVG_API_MAJOR_VERSION@.la \
$(GTK3_LIBS) \
$(LIBRSVG_LIBS) \
$(LIBCROCO_LIBS) \
$(GTHREAD_LIBS) \
$(libm)
......
......@@ -38,6 +38,7 @@ PANGOCAIRO_REQUIRED=1.10.0
GDK_PIXBUF_REQUIRED=1.3.7
GTK2_REQUIRED=2.16.0
GTK3_REQUIRED=3.0.0
CROCO_REQUIRED=0.6.1
# ===========================================================================
......@@ -102,46 +103,13 @@ PKG_CHECK_MODULES(LIBRSVG, \
libxml-2.0 >= $LIBXML_REQUIRED \
pangocairo >= $PANGOCAIRO_REQUIRED \
cairo >= $CAIRO_REQUIRED \
cairo-png >= $CAIRO_REQUIRED)
cairo-png >= $CAIRO_REQUIRED
libcroco-0.6 >= $CROCO_REQUIRED)
PKG_CHECK_MODULES([GTHREAD],[gthread-2.0 >= $GLIB_REQUIRED])
dnl ===========================================================================
LIBCROCO_CFLAGS=""
LIBCROCO_LIBS=""
LIBCROCOPKG=""
test_croco=true
AC_ARG_WITH(croco,[ --with-croco Use libcroco for CSS parsing],[
if test "x$withval" = "xno"; then
test_croco=false
fi
])
if test "x$test_croco" = "xtrue"; then
PKG_CHECK_MODULES(LIBCROCO,[libcroco-0.6 >= 0.6.1], test_croco=true, test_croco=false)
fi
if test "x$test_croco" = "xtrue"; then
croco_define=1
LIBCROCO_CFLAGS="$LIBCROCO_CFLAGS -DHAVE_LIBCROCO=1"
LIBCROCOPKG="libcroco-0.6"
else
croco_define=0
AC_MSG_WARN([LibCroco support disabled, as requested (Use --with-croco to enable)])
croco_warning="
You are building without libcroco support. LibRSVG will not be able to handle embedded CSS, as is required per the SVG specification. If you are a library vendor or distributor, you are doing the world a disservice and should strongly consider shipping libcroco. Even KSVG needs libcroco now..."
fi
AC_SUBST(LIBCROCOPKG)
AC_SUBST(LIBCROCO_CFLAGS)
AC_SUBST(LIBCROCO_LIBS)
AC_SUBST([CSS_SUPPORTED],[$test_croco])
AC_SUBST([LIBRSVG_HAVE_CSS],[$croco_define])
dnl ===========================================================================
AC_CHECK_FUNCS(strtok_r)
dnl ===========================================================================
......@@ -349,9 +317,4 @@ librsvg-$VERSION
GTK 3.0: ${have_gtk_3}
Build GTK 2.0 theme engine: ${enable_gtk_theme}
Build miscellaenous tools: ${build_misc_tools}
Use libcroco for css parsing: ${test_croco}
"
if test "x$croco_warning" != "x"; then
AC_MSG_RESULT([$croco_warning]);
fi
......@@ -112,7 +112,6 @@ GTKDOC_CFLAGS = \
-I$(top_srcdir) \
-I$(top_builddir) \
$(LIBRSVG_CFLAGS) \
$(LIBCROCO_CFLAGS) \
$(GTK_CFLAGS) \
$(GDK_X11_CFLAGS) \
$(WARN_CFLAGS) \
......@@ -123,7 +122,6 @@ GTKDOC_LIBS = \
$(top_builddir)/librsvg-@RSVG_API_MAJOR_VERSION@.la \
$(LIBRSVG_LIBS) \
$(GTHREAD_LIBS) \
$(LIBCROCO_LIBS) \
$(GTK_LIBS)
# This includes the standard gtk-doc make rules, copied by gtkdocize.
......
......@@ -17,7 +17,6 @@ libpixbufloader_svg_la_CPPFLAGS = \
libpixbufloader_svg_la_CFLAGS = \
$(GDK_PIXBUF_CFLAGS) \
$(LIBRSVG_CFLAGS) \
$(LIBCROCO_CFLAGS) \
$(AM_CFLASG)
libpixbufloader_svg_la_LDFLAGS = -avoid-version -module $(AM_LDFLAGS)
......@@ -25,8 +24,7 @@ libpixbufloader_svg_la_LDFLAGS = -avoid-version -module $(AM_LDFLAGS)
libpixbufloader_svg_la_LIBADD = \
$(top_builddir)/librsvg-@RSVG_API_MAJOR_VERSION@.la \
$(GDK_PIXBUF_LIBS) \
$(LIBRSVG_LIBS) \
$(LIBCROCO_LIBS)
$(LIBRSVG_LIBS)
if PLATFORM_WIN32
libpixbufloader_svg_la_LDFLAGS += -no-undefined
......
......@@ -12,7 +12,7 @@
(LIBRSVG_MAJOR_VERSION == (major) && LIBRSVG_MINOR_VERSION == (minor) && LIBRSVG_MICRO_VERSION >= (micro)))
#define LIBRSVG_HAVE_SVGZ (TRUE)
#define LIBRSVG_HAVE_CSS (@LIBRSVG_HAVE_CSS@)
#define LIBRSVG_HAVE_CSS (TRUE)
#define LIBRSVG_CHECK_FEATURE(FEATURE) (defined(LIBRSVG_HAVE_##FEATURE) && LIBRSVG_HAVE_##FEATURE)
......
......@@ -4,7 +4,7 @@ libdir=@libdir@
includedir=@includedir@
svgz_supported=true
css_supported=@CSS_SUPPORTED@
css_supported=true
Name: librsvg
Description: library that renders svg files
......
......@@ -4,7 +4,7 @@ libdir=@libdir@
includedir=@includedir@
svgz_supported=true
css_supported=@CSS_SUPPORTED@
css_supported=true
Name: librsvg
Description: library that renders svg files
......
......@@ -37,6 +37,8 @@
#include "rsvg-mask.h"
#include "rsvg-marker.h"
#include <libcroco/libcroco.h>
#define RSVG_DEFAULT_FONT "Times New Roman"
enum {
......@@ -992,10 +994,6 @@ rsvg_css_define_style (RsvgHandle * ctx,
}
}
#ifdef HAVE_LIBCROCO
#include <libcroco/libcroco.h>
typedef struct _CSSUserData {
RsvgHandle *ctx;
CRSelector *selector;
......@@ -1112,8 +1110,8 @@ init_sac_handler (CRDocHandler * a_handler)
a_handler->unrecoverable_error = ccss_unrecoverable_error;
}
static void
rsvg_real_parse_cssbuffer (RsvgHandle * ctx, const char *buff, size_t buflen)
void
rsvg_parse_cssbuffer (RsvgHandle * ctx, const char *buff, size_t buflen)
{
enum CRStatus status = CR_OK;
CRParser *parser = NULL;
......@@ -1157,103 +1155,13 @@ ccss_import_style (CRDocHandler * a_this,
_rsvg_acquire_xlink_href_resource ((gchar *) cr_string_peek_raw_str (a_uri),
rsvg_handle_get_base_uri (user_data->ctx), NULL);
if (stylesheet_data) {
rsvg_real_parse_cssbuffer (user_data->ctx, (const char *) stylesheet_data->data,
(size_t) stylesheet_data->len);
rsvg_parse_cssbuffer (user_data->ctx, (const char *) stylesheet_data->data,
(size_t) stylesheet_data->len);
g_byte_array_free (stylesheet_data, TRUE);
}
}
}
#else /* !HAVE_LIBCROCO */
static void
rsvg_real_parse_cssbuffer (RsvgHandle * ctx, const char *buff, size_t buflen)
{
/*
* Extremely poor man's CSS parser. Not robust. Not compliant.
* See also: http://www.w3.org/TR/REC-CSS2/syndata.html
*/
size_t loc = 0;
while (loc < buflen) {
gchar **selectors;
gchar **styles;
guint i;
GString *selector = g_string_new (NULL);
GString *style_props = g_string_new (NULL);
/* advance to the style's name */
while (loc < buflen && g_ascii_isspace (buff[loc]))
loc++;
/* advance to the first { that defines the style's properties */
while (loc < buflen && buff[loc] != '{')
g_string_append_c (selector, buff[loc++]);
loc++;
while (loc < buflen && g_ascii_isspace (buff[loc]))
loc++;
while (loc < buflen && buff[loc] != '}') {
/* suck in and append our property */
while (loc < buflen && buff[loc] != ';' && buff[loc] != '}')
g_string_append_c (style_props, buff[loc++]);
if (loc == buflen || buff[loc] == '}')
break;
else {
g_string_append_c (style_props, ';');
/* advance to the next property */
loc++;
while (loc < buflen && g_ascii_isspace (buff[loc]))
loc++;
}
}
selectors = g_strsplit (selector->str, ",", -1);
styles = g_strsplit (style_props->str, ";", -1);
for (i = 0; i < g_strv_length (selectors); i++) {
guint j;
for (j = 0; j < g_strv_length (styles); j++) {
gchar **values;
values = g_strsplit (styles[j], ":", 2);
if (g_strv_length (values) == 2) {
gchar *style_value = NULL;
gboolean important;
parse_style_value (g_strstrip (values[1]), &style_value, &important);
rsvg_css_define_style (ctx,
g_strstrip (selectors[i]),
g_strstrip (values[0]),
g_strstrip (style_value),
important);
g_free (style_value);
}
g_strfreev (values);
}
}
g_strfreev (selectors);
g_strfreev (styles);
g_string_free (selector, TRUE);
g_string_free (style_props, TRUE);
loc++;
while (loc < buflen && g_ascii_isspace (buff[loc]))
loc++;
}
}
#endif /* HAVE_LIBCROCO */
void
rsvg_parse_cssbuffer (RsvgHandle * ctx, const char *buff, size_t buflen)
{
/* delegate off to the builtin or libcroco implementation */
rsvg_real_parse_cssbuffer (ctx, buff, buflen);
}
/* Parse an SVG transform string into an affine matrix. Reference: SVG
working draft dated 1999-07-06, section 8.5. Return TRUE on
success. */
......
......@@ -11,7 +11,6 @@ endif
INCLUDES = \
-I$(top_srcdir) \
-I$(top_builddir) \
$(LIBCROCO_CFLAGS) \
$(LIBRSVG_CFLAGS) \
$(GTK_CFLAGS) \
$(GDK_X11_CFLAGS) \
......@@ -22,7 +21,6 @@ DEPS = $(top_builddir)/librsvg-@RSVG_API_MAJOR_VERSION@.la \
librsvg_tools_main.la
LDADDS = \
$(GLIB_LIBS) \
$(LIBCROCO_LIBS) \
$(LIBRSVG_LIBS) \
$(top_builddir)/librsvg-@RSVG_API_MAJOR_VERSION@.la
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment