summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDodji Seketeli <dodji@src.gnome.org>2003-03-29 15:05:36 +0000
committerDodji Seketeli <dodji@src.gnome.org>2003-03-29 15:05:36 +0000
commit0d5d4e57a3b091909b11a8a5a8fbb85236ac94c2 (patch)
tree6032828c163c19ba79035228545b8a310602c75b
parentdf526da09c8a5faf05101e438b84d5061cb4a091 (diff)
downloadlibcroco-0d5d4e57a3b091909b11a8a5a8fbb85236ac94c2.tar.gz
more code on the layout/cascade front.
some fixes/improvements on the build system front. Dodji.
-rw-r--r--ChangeLog21
-rw-r--r--TODO3
-rwxr-xr-xautogen.sh7
-rw-r--r--configure.in75
-rw-r--r--csslint/Makefile.in1
-rw-r--r--libcroco-config.h.in3
-rw-r--r--src/Makefile.am60
-rw-r--r--src/cr-cascade.c191
-rw-r--r--src/cr-cascade.h85
-rw-r--r--src/cr-lay-eng.c62
-rw-r--r--src/cr-lay-eng.h4
-rw-r--r--src/cr-sel-eng.c47
-rw-r--r--src/cr-sel-eng.h23
-rw-r--r--src/cr-style.c1
-rw-r--r--src/cr-stylesheet.c26
-rw-r--r--src/cr-stylesheet.h26
-rw-r--r--src/cr-utils.h1
-rw-r--r--tests/Makefile.am16
-rw-r--r--tests/test5-main.c2
19 files changed, 579 insertions, 75 deletions
diff --git a/ChangeLog b/ChangeLog
index f6d8954..2094e49 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,5 +1,24 @@
-2003-03-24 dodji <dodji@seketeli.org>
+2003-03-30 Dodji <dodji@seketeli.org>
+ * src/cr-lay-eng.c:
+ Started to code a layout engine. This is more a design
+ sketch than real usefull code so far.
+
+ * src/cr-cascade.c:
+ Started to code a #CRCascade class to abstract a css2 cascade.
+ This is more a placeholder (or a design sketch) than real
+ usefull code today.
+
+ * tests/Makefile.am: improved the conditional compilation
+ of the tests; e.g if the selection engine feature is disabled
+ the selection engine tests won't be compiled.
+ * configure.in: added --enable-layeng to contionaly compile
+ the layout engine files. Also improved the handling of
+ of the enable-xxx arguments => 'yes' forces the feature to
+ be enabled (the coder knows what he is doing); 'auto' checks
+ if the features xxx depends on are available and then
+ switches xxx on.
+2003-03-24 dodji <dodji@seketeli.org>
* src/cr-style.c (cr_style_set_style_from_decl):
Have a first hot (and bugged) implem of this function.
I can now, go and get worried about building the annotated
diff --git a/TODO b/TODO
index eba4dc6..fb73899 100644
--- a/TODO
+++ b/TODO
@@ -1,7 +1,8 @@
*coding:)
-Code the cr_style_new_from_ruleset() fonction. => hard, in progress.
+Code an empty place holder for the CRCascade and make get it used
+by the CRLayEng.
*Doc:)
diff --git a/autogen.sh b/autogen.sh
index e5cea42..8d1b7d4 100755
--- a/autogen.sh
+++ b/autogen.sh
@@ -18,4 +18,9 @@ which gnome-autogen.sh || {
echo "You need to install gnome-common from the GNOME CVS"
exit 1
}
-USE_GNOME2_MACROS=1 . gnome-autogen.sh
+
+if test "$@empty" = "empty" ; then
+ default_args="--enable-tests=yes --enable-seleng=auto --enable-layeng=auto"
+fi
+
+USE_GNOME2_MACROS=1 . gnome-autogen.sh $default_args
diff --git a/configure.in b/configure.in
index 4632032..6adbd52 100644
--- a/configure.in
+++ b/configure.in
@@ -73,48 +73,77 @@ dnl check libxml2 version
have_libxml2=no
PKG_CHECK_MODULES(LIBXML2, [libxml-2.0 >= 2.5.1],
[have_libxml2=yes
- AC_DEFINE(HAVE_LIBXML2, 1, [use libxml2])], have_libxml2=no)
+ AC_DEFINE(HAVE_LIBXML2, 1,
+ [use libxml2])],
+ have_libxml2=no)
-dnl --enable-test
+dnl --enable-tests
dnl this option enables compilation of the unit tests built in to .c files
dnl and also some stuff in the test/ subdir
-WITH_TESTS=no
-AC_ARG_ENABLE(test,
- AC_HELP_STRING([--enable-test=yes|no|auto],
+AC_ARG_ENABLE(tests,
+ AC_HELP_STRING([--enable-test=yes|no],
[Enables unit test code, Default=no]),
WITH_TESTS=$enableval,
- WITH_TESTS="no")
+ WITH_TESTS=no)
-if test "$WITH_TESTS" != no ; then
- if test "$have_libxml2" != no; then
+if test "$WITH_TESTS" = "yes" ; then
AC_DEFINE(WITH_TESTS, 1, [enable the unit tests])
- else
- WITH_TESTS=no
- fi
+else
+ WITH_TESTS="no"
fi
AC_SUBST(WITH_TESTS)
-AM_CONDITIONAL(HAVE_TESTS, test $WITH_TESTS != no)
-
+AM_CONDITIONAL(HAVE_TESTS, test "$WITH_TESTS" = "yes")
+
+
dnl --enable-seleng
dnl this option enables compilation of the selection engine
-WITH_SELENG=no
AC_ARG_ENABLE(seleng,
AC_HELP_STRING([--enable-seleng=yes|no|auto],
[Enables the css2 selector engine based on libxml2. Default=auto]),
WITH_SELENG=$enableval,
- WITH_SELENG="auto")
-
-if test "$WITH_SELENG" != no ; then
- if test "$have_libxml2" != no; then
+ WITH_SELENG="no")
+
+if test "$WITH_SELENG" = "auto" ; then
+ if test "$have_libxml2" != no; then
+ AC_DEFINE(WITH_SELENG, 1, [use css2 selection engine])
+ WITH_SELENG="yes"
+ else
+ WITH_SELENG="no"
+ fi
+elif test "$WITH_SELENG" = "yes" ; then
AC_DEFINE(WITH_SELENG, 1, [use css2 selection engine])
- else
- WITH_SELENG=no
- fi
+else
+ WITH_SELENG="no"
fi
AC_SUBST(WITH_SELENG)
-AM_CONDITIONAL(HAVE_SELENG, test $WITH_SELENG != no)
+AM_CONDITIONAL(HAVE_SELENG, test "$WITH_SELENG" = "yes")
+
+dnl --enable-layeng
+dnl this option enable the layout engine/box model/style stuffs.
+AC_ARG_ENABLE(layeng,
+ AC_HELP_STRING([--enable-layeng=yes|no|auto],
+ [Enables the layout engine. Default=auto]),
+ WITH_LAYENG=$enableval,
+ WITH_LAYENG="no")
+
+if test "$WITH_LAYENG" = "auto" ; then
+ if test "$WITH_SELENG" = "yes" ; then
+ AC_DEFINE(WITH_LAYENG, 1, [use layout engine])
+ WITH_LAYENG="yes"
+ else
+ WITH_LAYENG="no"
+ fi
+
+elif test "$WITH_LAYENG" = "yes" ; then
+ AC_DEFINE(WITH_LAYENG, 1, [use layout engine])
+else
+ WITH_LAYENG="no"
+fi
+
+AC_SUBST(WITH_LAYENG)
+AM_CONDITIONAL(HAVE_LAYENG, test "$WITH_LAYENG" = "yes")
dnl By default compile in debug mode
CFLAGS="-g -Wunused -Wimplicit -Wreturn-type -Wswitch \
@@ -170,6 +199,6 @@ echo "
Maintainer mode: : ${USE_MAINTAINER_MODE}
Building unit tests: : ${WITH_TESTS}
Building with selection engine: : ${WITH_SELENG}
-
+ Building with layout engine: : ${WITH_LAYENG}
" \ No newline at end of file
diff --git a/csslint/Makefile.in b/csslint/Makefile.in
index 6bd91fd..a2bd346 100644
--- a/csslint/Makefile.in
+++ b/csslint/Makefile.in
@@ -89,6 +89,7 @@ REQUIRE_LIBXML2 = @REQUIRE_LIBXML2@
STRIP = @STRIP@
U = @U@
VERSION = @VERSION@
+WITH_LAYENG = @WITH_LAYENG@
WITH_SELENG = @WITH_SELENG@
WITH_TESTS = @WITH_TESTS@
diff --git a/libcroco-config.h.in b/libcroco-config.h.in
index 19d332a..d548eb0 100644
--- a/libcroco-config.h.in
+++ b/libcroco-config.h.in
@@ -63,6 +63,9 @@
/* Version number of package */
#undef VERSION
+/* use layout engine */
+#undef WITH_LAYENG
+
/* use css2 selection engine */
#undef WITH_SELENG
diff --git a/src/Makefile.am b/src/Makefile.am
index d61592b..d066e42 100644
--- a/src/Makefile.am
+++ b/src/Makefile.am
@@ -4,31 +4,41 @@ crocoincdir=$(includedir)/@PACKAGE@
crocoinc_HEADERS= *.h
-libcroco_la_SOURCES= \
- cr-utils.c \
- cr-input.c \
- cr-enc-handler.c \
- cr-num.c \
- cr-rgb.c \
- cr-token.c \
- cr-tknzr.c \
- cr-term.c \
- cr-attr-sel.c \
- cr-pseudo.c \
- cr-additional-sel.c \
- cr-simple-sel.c \
- cr-selector.c \
- cr-doc-handler.c \
- cr-parser.c \
- cr-declaration.c \
- cr-statement.c \
- cr-stylesheet.c \
- cr-om-parser.c \
- cr-sel-eng.c \
- cr-style.c \
- cr-box.c \
- cr-lay-eng.c \
- *.h
+#the core parser files
+SRCS=\
+cr-utils.c \
+cr-input.c \
+cr-enc-handler.c \
+cr-num.c \
+cr-rgb.c \
+cr-token.c \
+cr-tknzr.c \
+cr-term.c \
+cr-attr-sel.c \
+cr-pseudo.c \
+cr-additional-sel.c \
+cr-simple-sel.c \
+cr-selector.c \
+cr-doc-handler.c \
+cr-parser.c \
+cr-declaration.c \
+cr-statement.c \
+cr-stylesheet.c \
+cr-cascade.c \
+cr-om-parser.c \
+*.h
+
+#the selection engine files
+if HAVE_SELENG
+SELENG_SRCS= cr-style.c cr-sel-eng.c
+endif
+
+#the layout engine files
+if HAVE_LAYENG
+LAYENG_SRCS= cr-box.c cr-lay-eng.c
+endif
+
+libcroco_la_SOURCES= $(SRCS) $(SELENG_SRCS) $(LAYENG_SRCS)
INCLUDES=-I$(top_srcdir) -I$(top_srcdir)/intl `pkg-config --cflags glib-2.0` `pkg-config --cflags libxml-2.0` @LIBXML2_CFLAGS@
libcroco_la_LDFLAGS=-version-info @LIBCROCO_VERSION_INFO@ @LIBXML2_LIBS@
diff --git a/src/cr-cascade.c b/src/cr-cascade.c
new file mode 100644
index 0000000..fcc2091
--- /dev/null
+++ b/src/cr-cascade.c
@@ -0,0 +1,191 @@
+/* -*- Mode: C; indent-tabs-mode:nil; c-basic-offset: 8-*- */
+
+/*
+ * This file is part of The Croco Library
+ *
+ * Copyright (C) 2002-2003 Dodji Seketeli <dodji@seketeli.org>
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of version 2.1 of the
+ * GNU Lesser General Public
+ * License as published by the Free Software Foundation.
+ *
+ * This program 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 General Public License for more details.
+ *
+ * You should have received a copy of the
+ * GNU Lesser General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307
+ * USA
+ */
+
+/*
+ *$Id$
+ */
+
+#include <string.h>
+#include "cr-cascade.h"
+
+#define PRIVATE(a_this) ((a_this)->priv)
+
+struct _CRCascadePriv
+{
+ /**
+ *the 3 style sheets of the cascade:
+ *author, user, and useragent sheet.
+ *Intended to be addressed by
+ *sheets[ORIGIN_AUTHOR] or sheets[ORIGIN_USER]
+ *of sheets[ORIGIN_UA] ;
+ */
+ CRStyleSheet *sheets[3] ;
+} ;
+
+
+/**
+ *Constructor of the #CRCascade class.
+ *Note that all three parameters of this
+ *method are ref counted and their refcount is increased.
+ *Their refcount will be decreased at the destruction of
+ *the instance of #CRCascade.
+ *So the caller should not call their destructor. The caller
+ *should call their ref/unref method instead if it wants
+ *@param a_author_sheet the autor origin style sheet
+ *@param a_user_sheet the user origin style sheet.
+ *@param a_ua_sheet the user agent origin style sheet.
+ *@return the newly built instance of CRCascade or NULL if
+ *an error arose during constrution.
+ */
+CRCascade *
+cr_cascade_new (CRStyleSheet *a_author_sheet,
+ CRStyleSheet *a_user_sheet,
+ CRStyleSheet *a_ua_sheet)
+{
+ CRCascade *result = NULL ;
+
+ result = g_try_malloc (sizeof (CRCascade)) ;
+ if (!result)
+ {
+ cr_utils_trace_info ("Out of memory") ;
+ return NULL ;
+ }
+ memset (result, 0, sizeof (CRCascade)) ;
+
+ PRIVATE (result) = g_try_malloc (sizeof (CRCascade)) ;
+ if (!PRIVATE (result))
+ {
+ cr_utils_trace_info ("Out of memory") ;
+ return NULL ;
+ }
+ memset (PRIVATE (result), 0, sizeof (CRCascadePriv)) ;
+
+ if (a_author_sheet)
+ {
+ PRIVATE (result)->sheets[ORIGIN_AUTHOR] =
+ a_author_sheet ;
+ cr_stylesheet_ref (a_author_sheet) ;
+ }
+ if (a_user_sheet)
+ {
+ PRIVATE (result)->sheets[ORIGIN_USER] = a_user_sheet ;
+ cr_stylesheet_ref (a_user_sheet) ;
+ }
+ if (a_ua_sheet)
+ {
+ PRIVATE (result)->sheets[ORIGIN_UA] = a_ua_sheet ;
+ cr_stylesheet_ref (a_ua_sheet) ;
+ }
+
+ return result ;
+}
+
+/**
+ *Gets a given origin sheet.
+ *Note that the returned stylesheet
+ *is refcounted so if the caller wants
+ *to manage it's lifecycle, it must use
+ *cr_stylesheet_ref()/cr_stylesheet_unref() instead
+ *of the cr_stylesheet_destroy() method.
+ *@param a_this the current instance of #CRCascade.
+ *@param a_origin the origin of the style sheet as
+ *defined in the css2 spec in chapter 6.4.
+ *@return the style sheet, or NULL if it does not
+ *exist.
+ */
+CRStyleSheet *
+cr_cascade_get_sheet (CRCascade *a_this,
+ enum CRStyleOrigin a_origin)
+{
+ g_return_val_if_fail (a_this
+ && a_origin >= ORIGIN_AUTHOR
+ && a_origin < ORIGIN_END,
+ NULL) ;
+
+ return PRIVATE (a_this)->sheets[a_origin] ;
+}
+
+
+/**
+ *Sets a stylesheet in the cascade
+ *@param a_this the current instance of #CRCascade.
+ *@param a_sheet the stylesheet to set.
+ *@param a_origin the origin of the stylesheet.
+ *@return CR_OK upon successfull completion, an error
+ *code otherwise.
+ */
+enum CRStatus
+cr_cascade_set_sheet (CRCascade *a_this,
+ CRStyleSheet *a_sheet,
+ enum CRStyleOrigin a_origin)
+{
+ g_return_val_if_fail (a_this
+ && a_sheet
+ && a_origin >= ORIGIN_AUTHOR
+ && a_origin < ORIGIN_END,
+ CR_BAD_PARAM_ERROR) ;
+
+ if (PRIVATE (a_this)->sheets[a_origin])
+ cr_stylesheet_unref
+ (PRIVATE (a_this)->sheets[a_origin]) ;
+ PRIVATE (a_this)->sheets[a_origin] = a_sheet ;
+ cr_stylesheet_ref (a_sheet) ;
+
+ return CR_OK ;
+}
+
+
+/**
+ *Destructor of #CRCascade.
+ */
+void
+cr_cascade_destroy (CRCascade *a_this)
+{
+ g_return_if_fail (a_this) ;
+
+ if (PRIVATE (a_this))
+ {
+ gulong i = 0 ;
+
+ for (i = 0 ;
+ PRIVATE (a_this)->sheets
+ && i < ORIGIN_END ;
+ i++)
+ {
+ if (PRIVATE (a_this)->sheets[i])
+ {
+ if (cr_stylesheet_unref
+ (PRIVATE (a_this)->sheets[i])
+ == TRUE)
+ {
+ PRIVATE (a_this)->sheets[i] =
+ NULL ;
+ }
+ }
+ }
+ g_free (PRIVATE (a_this)) ;
+ PRIVATE (a_this) = NULL ;
+ }
+ g_free (a_this) ;
+}
diff --git a/src/cr-cascade.h b/src/cr-cascade.h
new file mode 100644
index 0000000..bc228c2
--- /dev/null
+++ b/src/cr-cascade.h
@@ -0,0 +1,85 @@
+/* -*- Mode: C; indent-tabs-mode:nil; c-basic-offset: 8-*- */
+
+/*
+ * This file is part of The Croco Library
+ *
+ * Copyright (C) 2002-2003 Dodji Seketeli <dodji@seketeli.org>
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of version 2.1 of the
+ * GNU Lesser General Public
+ * License as published by the Free Software Foundation.
+ *
+ * This program 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 General Public License for more details.
+ *
+ * You should have received a copy of the
+ * GNU Lesser General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307
+ * USA
+ */
+
+/*
+ *$Id$
+ */
+
+#ifndef __CR_CASCADE_H__
+#define __CR_CASCADE_H__
+
+#include "cr-stylesheet.h"
+
+/**
+ *@file
+ *the declaration of the #CRCascade class.
+ */
+
+G_BEGIN_DECLS
+
+
+enum CRStyleOrigin
+{
+ /*Please don't change the order of
+ *the values enumerated here ...
+ *New values should be added at the end,
+ *just before ORIGIN_END.
+ */
+ ORIGIN_AUTHOR = 0,
+ ORIGIN_USER ,
+ ORIGIN_UA,
+ ORIGIN_END /*must always be the last one*/
+} ;
+
+typedef struct _CRCascadePriv CRCascadePriv ;
+
+/**
+ *An abstraction of the "Cascade" defined
+ *in the css2 spec, chapter 6.4.
+ */
+typedef struct
+{
+ CRCascadePriv *priv ;
+} CRCascade ;
+
+
+CRCascade *
+cr_cascade_new (CRStyleSheet *a_author_sheet,
+ CRStyleSheet *a_user_sheet,
+ CRStyleSheet *a_ua_sheet) ;
+
+CRStyleSheet *
+cr_cascade_get_sheet (CRCascade *a_this,
+ enum CRStyleOrigin a_origin) ;
+
+enum CRStatus
+cr_cascade_set_sheet (CRCascade *a_this,
+ CRStyleSheet *a_sheet,
+ enum CRStyleOrigin a_origin) ;
+void
+cr_cascade_destroy (CRCascade *a_this) ;
+
+G_END_DECLS
+
+#endif /*__CR_CASCADE_H__*/
diff --git a/src/cr-lay-eng.c b/src/cr-lay-eng.c
index dc279ab..a3c863f 100644
--- a/src/cr-lay-eng.c
+++ b/src/cr-lay-eng.c
@@ -27,12 +27,52 @@ n * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
#define PRIVATE(a_this) ((a_this)->priv)
+static enum CRStatus
+cr_lay_eng_annotate_tree_real (CRLayEng *a_this,
+ xmlNode *a_root_node) ;
+
struct _CRLayEngPriv
{
-
+ CRStyleSheet *cur_sheet ;
} ;
+static enum CRStatus
+cr_lay_eng_annotate_tree_real (CRLayEng *a_this,
+ xmlNode *a_root_node)
+{
+ enum CRStatus status = CR_OK ;
+ xmlNode *cur = NULL ;
+ g_return_val_if_fail (a_this
+ && PRIVATE (a_this)
+ && PRIVATE (a_this)->cur_sheet
+ && a_root_node,
+ CR_BAD_PARAM_ERROR) ;
+
+ for (cur = a_root_node ; cur ; cur = cur->next)
+ {
+ /*TODO: build here the annotated node*/
+
+ /*walk through what remains from the tree*/
+ if (cur->children)
+ {
+ status =
+ cr_lay_eng_annotate_tree_real
+ (a_this, cur->children) ;
+
+ if (status != CR_OK)
+ return status ;
+ }
+ else
+ {
+ return status ;
+ }
+ }
+
+ return CR_OK ;
+}
+
+
CRLayEng *
cr_lay_eng_new (void)
{
@@ -60,6 +100,26 @@ cr_lay_eng_new (void)
}
+enum CRStatus
+cr_lay_eng_build_annotate_tree (CRLayEng *a_this,
+ xmlDoc *a_doc,
+ CRStyleSheet *a_sheet)
+{
+ xmlNode *root_node = NULL ;
+
+ g_return_val_if_fail (a_this && a_doc && a_sheet,
+ CR_BAD_PARAM_ERROR) ;
+
+ root_node = xmlDocGetRootElement (a_doc) ;
+ if (!root_node)
+ return CR_NO_ROOT_NODE_ERROR ;
+
+ PRIVATE (a_this)->cur_sheet = a_sheet ;
+ return cr_lay_eng_annotate_tree_real (a_this, root_node) ;
+
+ return CR_OK ;
+}
+
void
cr_lay_eng_destroy (CRLayEng *a_this)
{
diff --git a/src/cr-lay-eng.h b/src/cr-lay-eng.h
index 2a410db..883f95d 100644
--- a/src/cr-lay-eng.h
+++ b/src/cr-lay-eng.h
@@ -29,6 +29,8 @@
#include "cr-utils.h"
#include "cr-stylesheet.h"
+G_BEGIN_DECLS
+
typedef struct _CRLayEngPriv CRLayEngPriv ;
typedef struct
@@ -49,4 +51,6 @@ cr_lay_eng_build_annotate_tree (CRLayEng *a_this,
void
cr_lay_eng_destroy (CRLayEng *a_this) ;
+G_END_DECLS
+
#endif /*__CR_LAYOUT_ENG_H__*/
diff --git a/src/cr-sel-eng.c b/src/cr-sel-eng.c
index 746ae19..2e1e459 100644
--- a/src/cr-sel-eng.c
+++ b/src/cr-sel-eng.c
@@ -661,7 +661,7 @@ cr_sel_eng_get_matched_rulesets_real (CRSelEng *a_this,
if (!cur_sel->simple_sel)
continue ;
- status = cr_sel_eng_sel_matches_node
+ status = cr_sel_eng_matches_node
(a_this, cur_sel->simple_sel,
a_node, &matches) ;
@@ -747,8 +747,8 @@ cr_sel_eng_new (void)
*@return the CR_OK if the selection ran correctly, an error code otherwise.
*/
enum CRStatus
-cr_sel_eng_sel_matches_node (CRSelEng *a_this, CRSimpleSel *a_sel,
- xmlNode *a_node, gboolean *a_result)
+cr_sel_eng_matches_node (CRSelEng *a_this, CRSimpleSel *a_sel,
+ xmlNode *a_node, gboolean *a_result)
{
g_return_val_if_fail (a_this && PRIVATE (a_this)
&& a_this && a_node
@@ -782,11 +782,11 @@ cr_sel_eng_sel_matches_node (CRSelEng *a_this, CRSimpleSel *a_sel,
*@return CR_OK upon sucessfull completion, an error code otherwise.
*/
enum CRStatus
-cr_sel_eng_sel_get_matched_rulesets (CRSelEng *a_this,
- CRStyleSheet *a_sheet,
- xmlNode *a_node,
- CRStatement ***a_rulesets,
- gulong *a_len)
+cr_sel_eng_get_matched_rulesets (CRSelEng *a_this,
+ CRStyleSheet *a_sheet,
+ xmlNode *a_node,
+ CRStatement ***a_rulesets,
+ gulong *a_len)
{
CRStatement ** stmts_tab = NULL ;
enum CRStatus status = CR_OK ;
@@ -850,6 +850,37 @@ cr_sel_eng_sel_get_matched_rulesets (CRSelEng *a_this,
}
/**
+ *Retrieves the style structure that matches the xml node
+ *from the cascade.
+ *NOTE: this does not implement the complex cascade algorithms
+ *described in the css2 spec from chapter 6.4 on, but instead,
+ *is just an empty design sketch so that other hackers (yeah, we can dream)
+ *can come an implement it. I don't have the time for this right now.
+ *@param a_this the current instance of #CRSelEng.
+ *@param a_cascade the cascade from which the request is to be made.
+ *@param a_node the xml node to match
+ *@param a_parent_style the style of the parent xml node.
+ *@param a_style out parameter. a pointer to the style
+ *structure to be returned. *a_style must be set to NULL, otherwise
+ *a CR_BAD_PARAM_ERROR is returned. The caller must free the
+ *the returned *a_style using cr_style_destroy().
+ *@return CR_OK upon successfull completion, an error code otherwise.
+ */
+enum CRStatus
+cr_sel_eng_get_matched_style (CRSelEng *a_this,
+ CRCascade *a_cascade,
+ xmlNode *a_node,
+ CRStyle *a_parent_style,
+ CRStyle **a_style)
+{
+ g_return_val_if_fail (a_this && a_cascade
+ && a_node && a_style) ;
+
+ return CR_OK ;
+}
+
+
+/**
*The destructor of #CRSelEng
*@param a_this the current instance of the selection engine.
*/
diff --git a/src/cr-sel-eng.h b/src/cr-sel-eng.h
index 56e2b90..274895c 100644
--- a/src/cr-sel-eng.h
+++ b/src/cr-sel-eng.h
@@ -25,6 +25,8 @@
#include "cr-utils.h"
#include "cr-stylesheet.h"
+#include "cr-cascade.h"
+#include "cr-style.h"
#ifdef HAVE_LIBXML2
#include <libxml/tree.h>
@@ -61,15 +63,22 @@ CRSelEng *
cr_sel_eng_new (void) ;
enum CRStatus
-cr_sel_eng_sel_matches_node (CRSelEng *a_this, CRSimpleSel *a_sel,
- xmlNode *a_node, gboolean *a_result) ;
+cr_sel_eng_matches_node (CRSelEng *a_this, CRSimpleSel *a_sel,
+ xmlNode *a_node, gboolean *a_result) ;
enum CRStatus
-cr_sel_eng_sel_get_matched_rulesets (CRSelEng *a_this,
- CRStyleSheet *a_sheet,
- xmlNode *a_node,
- CRStatement ***a_rulesets,
- gulong *a_len) ;
+cr_sel_eng_get_matched_rulesets (CRSelEng *a_this,
+ CRStyleSheet *a_sheet,
+ xmlNode *a_node,
+ CRStatement ***a_rulesets,
+ gulong *a_len) ;
+
+enum CRStatus
+cr_sel_eng_get_matched_style (CRSelEng *a_this,
+ CRCascade *a_cascade,
+ xmlNode *a_node,
+ CRStyle **a_style) ;
+
void
cr_sel_eng_destroy (CRSelEng *a_this) ;
diff --git a/src/cr-style.c b/src/cr-style.c
index 8cbd0ec..e789c19 100644
--- a/src/cr-style.c
+++ b/src/cr-style.c
@@ -28,7 +28,6 @@
#include <string.h>
#include "cr-style.h"
-
/**
*@file
*The definition of the #CRStyle class.
diff --git a/src/cr-stylesheet.c b/src/cr-stylesheet.c
index 02b8f26..4b3cba6 100644
--- a/src/cr-stylesheet.c
+++ b/src/cr-stylesheet.c
@@ -78,6 +78,32 @@ cr_stylesheet_dump (CRStyleSheet *a_this, FILE *a_fp)
}
}
+void
+cr_stylesheet_ref (CRStyleSheet *a_this)
+{
+ g_return_if_fail (a_this) ;
+
+ a_this->ref_count ++ ;
+}
+
+gboolean
+cr_stylesheet_unref (CRStyleSheet *a_this)
+{
+ g_return_val_if_fail (a_this, FALSE) ;
+
+ if (a_this->ref_count)
+ a_this->ref_count -- ;
+
+ if (!a_this->ref_count)
+ {
+ cr_stylesheet_destroy (a_this) ;
+ return TRUE ;
+ }
+
+ return FALSE ;
+}
+
+
/**
*Destructor of the #CRStyleSheet class.
*@param a_this the current instance of the #CRStyleSheet class.
diff --git a/src/cr-stylesheet.h b/src/cr-stylesheet.h
index f147bb0..a19c04c 100644
--- a/src/cr-stylesheet.h
+++ b/src/cr-stylesheet.h
@@ -1,4 +1,4 @@
-/* -*- Mode: C; indent-tabs-mode: ni; c-basic-offset: 8 -*- */
+/* -*- Mode: C; indent-tabs-mode: nil; c-basic-offset: 8 -*- */
/*
* This file is part of The Croco Library
@@ -43,8 +43,24 @@ struct _CRStyleSheet
{
/**The css statements list*/
CRStatement *statements ;
-} ;
+ /**custom data used by libcroco*/
+ void *croco_data ;
+
+ /**
+ *custom application data pointer
+ *Can be used by applications.
+ */
+ void * app_data ;
+
+ /**
+ *the reference count of this insance
+ *Please, don't never ever modify it
+ *directly. Use cr_stylesheet_ref()
+ *and cr_stylesheet_unref() instead.
+ */
+ gulong ref_count ;
+} ;
CRStyleSheet *
cr_stylesheet_new (CRStatement *a_stmts) ;
@@ -53,6 +69,12 @@ void
cr_stylesheet_dump (CRStyleSheet *a_this, FILE *a_fp) ;
void
+cr_stylesheet_ref (CRStyleSheet *a_this) ;
+
+gboolean
+cr_stylesheet_unref (CRStyleSheet *a_this) ;
+
+void
cr_stylesheet_destroy (CRStyleSheet *a_this) ;
#endif /*__CR_STYLESHEET_H__*/
diff --git a/src/cr-utils.h b/src/cr-utils.h
index 6d2d373..b13513d 100644
--- a/src/cr-utils.h
+++ b/src/cr-utils.h
@@ -56,6 +56,7 @@ enum CRStatus {
CR_ENCODING_NOT_FOUND_ERROR,
CR_PARSING_ERROR,
CR_SYNTAX_ERROR,
+ CR_NO_ROOT_NODE_ERROR,
CR_NO_TOKEN,
CR_ERROR
} ;
diff --git a/tests/Makefile.am b/tests/Makefile.am
index bab2490..bb1d205 100644
--- a/tests/Makefile.am
+++ b/tests/Makefile.am
@@ -1,8 +1,15 @@
-if HAVE_TESTS
+if HAVE_TESTS
-noinst_PROGRAMS=test0 test1 test2 test3 test4 test5 test6
+if HAVE_SELENG
+SELENG_TESTS = test5
+endif
+
+CORE_TESTS=test0 test1 test2 test3 test4 test6
+
+PRGS = $(CORE_TESTS) $(SELENG_TESTS)
-test0_SOURCES=test0-main.c
+noinst_PROGRAMS=$(PRGS)
+test0_SOURCES=test0-main.c
test1_SOURCES=test1-main.c
test2_SOURCES=test2-main.c cr-test-utils.c cr-test-utils.h
test3_SOURCES=test3-main.c cr-test-utils.c cr-test-utils.h
@@ -10,7 +17,6 @@ test4_SOURCES=test4-main.c cr-test-utils.c cr-test-utils.h
test5_SOURCES=test5-main.c cr-test-utils.c cr-test-utils.h
test6_SOURCES=test6-main.c cr-test-utils.c cr-test-utils.h
-endif
LDADD=$(top_srcdir)/src/libcroco.la
@@ -21,3 +27,5 @@ INCLUDES=-I$(top_srcdir)/intl \
LDFLAGS=`pkg-config --libs glib-2.0` @LIBXML2_LIBS@
AM_CFLAGS=-Wall -I. @LIBXML2_CFLAGS@
+
+endif \ No newline at end of file
diff --git a/tests/test5-main.c b/tests/test5-main.c
index 14e55cf..c8e0a69 100644
--- a/tests/test5-main.c
+++ b/tests/test5-main.c
@@ -111,7 +111,7 @@ walk_xml_tree_and_lookup_rules (CRSelEng *a_sel_eng,
for (cur_node = a_node ;cur_node ; cur_node = cur_node->next)
{
- status = cr_sel_eng_sel_get_matched_rulesets
+ status = cr_sel_eng_get_matched_rulesets
(a_sel_eng, a_sheet,
cur_node, &stmts_tab, &tab_len) ;