summaryrefslogtreecommitdiffstats
path: root/src/3rdparty/libcroco/docs
diff options
context:
space:
mode:
authorDaniel Baumann <daniel.baumann@progress-linux.org>2024-04-13 11:50:49 +0000
committerDaniel Baumann <daniel.baumann@progress-linux.org>2024-04-13 11:50:49 +0000
commitc853ffb5b2f75f5a889ed2e3ef89b818a736e87a (patch)
tree7d13a0883bb7936b84d6ecdd7bc332b41ed04bee /src/3rdparty/libcroco/docs
parentInitial commit. (diff)
downloadinkscape-upstream.tar.xz
inkscape-upstream.zip
Adding upstream version 1.3+ds.upstream/1.3+dsupstream
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
Diffstat (limited to 'src/3rdparty/libcroco/docs')
-rw-r--r--src/3rdparty/libcroco/docs/Makefile.am3
-rw-r--r--src/3rdparty/libcroco/docs/design/parser-architecture.txt146
-rw-r--r--src/3rdparty/libcroco/docs/design/sel-instr.txt64
-rw-r--r--src/3rdparty/libcroco/docs/examples/Makefile.am1
-rw-r--r--src/3rdparty/libcroco/docs/examples/cssom-example-1.c109
-rw-r--r--src/3rdparty/libcroco/docs/examples/sac-example-1.c198
-rw-r--r--src/3rdparty/libcroco/docs/examples/sac-example-2.c349
-rw-r--r--src/3rdparty/libcroco/docs/examples/selection-example-1.c191
-rw-r--r--src/3rdparty/libcroco/docs/examples/selection-example-1.css41
-rw-r--r--src/3rdparty/libcroco/docs/examples/selection-example-1.xml14
-rw-r--r--src/3rdparty/libcroco/docs/reference/Makefile.am53
-rw-r--r--src/3rdparty/libcroco/docs/reference/libcroco-docs.sgml39
-rw-r--r--src/3rdparty/libcroco/docs/release-notes-template.txt41
-rw-r--r--src/3rdparty/libcroco/docs/usage.txt47
14 files changed, 1296 insertions, 0 deletions
diff --git a/src/3rdparty/libcroco/docs/Makefile.am b/src/3rdparty/libcroco/docs/Makefile.am
new file mode 100644
index 0000000..ece8c4b
--- /dev/null
+++ b/src/3rdparty/libcroco/docs/Makefile.am
@@ -0,0 +1,3 @@
+SUBDIRS=examples reference
+
+EXTRA_DIST=usage.txt
diff --git a/src/3rdparty/libcroco/docs/design/parser-architecture.txt b/src/3rdparty/libcroco/docs/design/parser-architecture.txt
new file mode 100644
index 0000000..67b7713
--- /dev/null
+++ b/src/3rdparty/libcroco/docs/design/parser-architecture.txt
@@ -0,0 +1,146 @@
+Libcroco parser architecture
+-----------------------------
+
+Author: Dodji Seketeli <dodji@seketeli.org>
+
+$Id$
+
+I) Forethoughts.
+===================
+
+Libcroco's parser is a simple recursive descent parser.
+The major design focus has been simplicity, reliability and
+conformance.
+
+Simplicity
+-----------
+We want the code to be maintainable by anyone who knows the CSS spec
+and who knows how to code in C. Therefore, we avoid to overuse
+the C preprocessor magic and all the tricks that tend to turn C into
+a maintenance nightmare.
+
+We also try to adhere to the Gnome coding guidelines specified
+at http://developer.gnome.org/doc/guides/programming-guidelines.
+
+
+Reliability
+-----------
+Each single function of the libcroco library should never crash,
+and this, whatever the arguments it takes.
+As a consequence we tend to be paranoid when it comes to check
+pointers values before dereferencing them for example...
+
+Conformance
+-----------
+We try to stick to the CSS spec. We know this is almost impossible to achieve
+given the resources we have but we think it is a sane target to chase.
+
+II) Overall architecture
+=========================
+The parser is organized around several main classes:
+
+1/ CRInput
+2/ CRTknzr (Tokenizer or lexer)
+3/ CRParser
+4/ CROMParser
+
+II.1 The CRInput class
+-----------------------
+The CRInput class provides the abstraction of
+an utf8-encoded character stream.
+
+Ideally, it should abstract local data sources
+(local files and in-memory buffers)
+and remote data sources (sockets, url-identified resources) but for the
+moment, it can only abstract local data sources.
+
+Adding a new type of data source should be transparent for the
+classes that already use CRInput. After all, this is what abstraction is about :)
+
+
+II.2 The CRTknzr class
+----------------------
+The main job of the tokenizer (or lexer) is to
+provide a get_next_token() method.
+This methods returns the next CSS token found in the input stream.
+(Note that the input stream here is an instance of CRInput).
+
+This provides an extremely useful facility to the parser.
+
+II.3 The CRParser class
+-------------------------
+The core of the parser.
+
+The main job of this class is to provide a cr_parser_parse_stylesheet()
+method. During the parsing (the execution of the cr_parser_stylesheet())
+the parser sends events to notify the application when it encounters
+remarkable CSS constructions. This is the SAC (Simple API for CSS) API model.
+
+To achieve that task, almost each production of the CSS grammar
+has a matching parsing function (or method) in this class.
+
+For example, the following production named "ruleset" (specified in the
+CSS2 spec in appendix D.1):
+
+ruleset : selector [ ',' S* selector ]*
+ '{' S* declaration [ ';' S* declaration ]* '}' S*
+
+is "implemented" by the cr_parser_parse_ruleset() method.
+
+The same thing applies for the "selector" production:
+
+selector : simple_selector [ combinator simple_selector ]*
+
+which is implemented by the cr_parser_parse_selector() method... and so on
+and so forth.
+
+II.3.1 Structure of a parsing method.
+-------------------------------------
+A parsing method (e.g cr_parser_parse_ruleset()) is there
+to:
+
+ * try to recognize a substring of the incoming character string
+ as something that matches a given CSS grammar production.
+
+ e.g: the job of the cr_parser_parse_ruleset() is to try
+ to recognize if "what" comes next in the input stream
+ is a CSS2 "ruleset".
+
+ * build a basic abstract data structure to
+ store the information encountered
+ during the parsing of the current character string.
+
+ eg: cr_parser_parse_declaration() has the following prototype:
+
+ enum CRStatus
+ cr_parser_parse_declaration (CRParser *a_this, GString **a_property,
+ CRTerm **a_value) ;
+
+ In case of successful parsing, this method returns
+ (via its parameters) the property _and_ the
+ value of the CSS2 declaration.
+ Note that a CSS2 declaration is specified as follows:
+
+ declaration : property ':' S* expr prio?
+ | /* empty */
+
+ * After completion, say if the parsing has succeeded or not.
+
+ eg: cr_parser_parse_declaration() returns CR_OK if the
+ parsing has succeeded, and error code otherwise. Obviously,
+ the out parameters "a_property" and "a_value" are valid if and only
+ if the return value is CR_OK.
+
+ * whenever the function is parsing a construct that must
+ be notified to the user as part of the SAC API spec, notify
+ the user by calling the right SAC callback.
+
+ * if the parsing failed, leave the position in the stream unchanged.
+ That is, the position in the character stream should be as if
+ the parsing function hasn't been called at all.
+
+
+II.4 The selection Engine.
+--------------------------
+
+Hmmh, I should kick my ass to write this down ... \ No newline at end of file
diff --git a/src/3rdparty/libcroco/docs/design/sel-instr.txt b/src/3rdparty/libcroco/docs/design/sel-instr.txt
new file mode 100644
index 0000000..6b19389
--- /dev/null
+++ b/src/3rdparty/libcroco/docs/design/sel-instr.txt
@@ -0,0 +1,64 @@
+Draft of the libcroco selector internal instruction set.
+*********************************************************
+
+READERS SHOULD READ THE CHAPTER 5 of THE CSS2 CSS2 SPEC INTITLED
+"Selectors" FIRST.
+
+I) Introduction
+''''''''''''''''''''
+This is the instructions set understood by the libcroco
+sel-eng.c module (Selection engine).
+
+The purpose of the selection engine is to basically to say whether if a given
+xml node is matched by a given css2 selector or not.
+
+II) Rationale
+''''''''''''''''''''
+For the sake of performance (mostly processing speed) each CSS2
+selector is compiled into a sequences of atomic selection instructions
+that are easily executable by the selection engine.
+
+III) Selection instruction set overview
+''''''''''''''''''''''''''''''''''''''''
+
+Each selection instruction returns a boolean value (TRUE or FALSE).
+The execution of a sequence of selection instruction stops at the
+first instruction that returns a FALSE value and the selection engine
+returns returns the value FALSE to say that the current xml node
+is matched by the CSS2 selection expression being evaluated.
+
+Note that during the evaluation of a CSS2 selection expression,
+all the contextual information are stored into an evaluation context.
+For example, the context will hold a pointer to the xml node the
+selection engine is trying to match.
+
+III.1) The instruction set.
+'''''''''''''''''''''''''''
+
+set-cur-node 'a_node'
+----------------------
+a_node: an xml node
+Sets the current xml node (in the context) to a_node.
+
+match-n-ancestor 'a_n' 'a_parent'
+----------------------------------
+a_parent: a string.
+a_n: a number. The depth of the ancestor
+
+Returns true if the current xml node has an ancestor
+located at a depth 'n' (going upward from the current node)
+and named 'a_parent'. An ancestor located at depth '0' designates
+the current xml node. An ancesstor located at depth '1' designates
+the parent of the current xml node etc ...
+
+match-any
+---------
+Always returns true.
+
+match-first-child 'a_name'
+--------------------------
+Returns true if the current xml element's name equal 'a_name' and
+if the current xml element is the first child of its parent.
+
+TODO: continue reading the chapter 5 of the css2 spec and finish
+the design of this instruction set.
diff --git a/src/3rdparty/libcroco/docs/examples/Makefile.am b/src/3rdparty/libcroco/docs/examples/Makefile.am
new file mode 100644
index 0000000..e960594
--- /dev/null
+++ b/src/3rdparty/libcroco/docs/examples/Makefile.am
@@ -0,0 +1 @@
+EXTRA_DIST=cssom-example-1.c sac-example-1.c sac-example-2.c
diff --git a/src/3rdparty/libcroco/docs/examples/cssom-example-1.c b/src/3rdparty/libcroco/docs/examples/cssom-example-1.c
new file mode 100644
index 0000000..85079ce
--- /dev/null
+++ b/src/3rdparty/libcroco/docs/examples/cssom-example-1.c
@@ -0,0 +1,109 @@
+/* -*- Mode: C; indent-tabs-mode:nil; c-basic-offset:8 -*- */
+
+/**
+ *This is an example that shows how to use
+ *the CSSOM api of the libcroco CSS2 parsing library.
+ *It just parses the CSS document given in argument and
+ *it dumps it (serializes) it on the screen.
+ *
+ *To compile it using gcc, type
+ *
+ *gcc -g -Wall `croco-0.6-config --cflags` `croco-0.6-config --libs` -o cssom-example-1 cssom-example-1.c
+ *
+ *Prior to that, you must have compiled and installed libcroco, of course.
+ *
+ *@author Dodji Seketeli
+ */
+
+#include <string.h>
+#include <libcroco/libcroco.h>
+
+/**
+ *Displays the usage of this program.
+ *@param prg_name the name of the program.
+ */
+void
+display_usage (char *prg_name)
+{
+ printf ("\nusage: %s [options] <css file to parse>\n\n",
+ prg_name) ;
+ printf ("\twhere options are:\n") ;
+ printf ("\t--help|h\tdisplays this help\n") ;
+ printf ("\n") ;
+}
+
+
+/**
+ *Main entry point.
+ *This function illustrates a way to use libcroco.
+ *In this example, we will use a CSS Object Model parser
+ *to parse a cascading style sheet and dump what we have parsed on stdout.
+ *
+ *The goal of the object model parser is to parse a css and build
+ *an abstract tree out of it. One can then walk the tree to perform
+ *whatever action he wants. In our case, the function used to
+ *dump the tree on stdout will walk the tree and dump each one of its
+ *components (a.k.a. css statements).
+ */
+int
+main (int argc, char **argv)
+{
+ short i = 0 ;
+ enum CRStatus status = CR_OK ;
+ CRStyleSheet *stylesheet = NULL ;
+
+ /*first parse command line arguments*/
+ for (i = 1 ; i < argc ; i++)
+ {
+ if (argv[i][0] != '-')
+ break ;
+ if (!strcmp (argv[i],"--help")
+ || !strcmp (argv[i], "-h"))
+ {
+ display_usage (argv[0]) ;
+ return 0 ;
+ }
+ else
+ {
+ display_usage (argv[0]) ;
+ return 0 ;
+ }
+ }
+ if (i >= argc)
+ {
+ display_usage (argv[0]) ;
+ return 0;
+ }
+
+ /*****************************************************
+ *Enough plumbering... now, the real libcroco stuffs.
+ ***************************************************/
+
+ /*
+ *What we want here is to simply parse
+ *a CSS document using the cssom api.
+ */
+ status = cr_om_parser_simply_parse_file ((const guchar*)argv[i] /*sheet*/,
+ CR_ASCII /*the encoding*/,
+ &stylesheet) ;
+ if (status == CR_OK && stylesheet)
+ {
+ /*
+ *everything went well,
+ *so dump the stylesheet on stdout.
+ */
+ cr_stylesheet_dump (stylesheet, stdout) ;
+ }
+
+ if (stylesheet)
+ {
+ /*
+ *free the the memory used to hold the css
+ *object model
+ */
+ cr_stylesheet_destroy (stylesheet) ;
+ stylesheet = NULL ;
+ }
+
+ return 0 ;
+}
diff --git a/src/3rdparty/libcroco/docs/examples/sac-example-1.c b/src/3rdparty/libcroco/docs/examples/sac-example-1.c
new file mode 100644
index 0000000..074fc07
--- /dev/null
+++ b/src/3rdparty/libcroco/docs/examples/sac-example-1.c
@@ -0,0 +1,198 @@
+/* -*- Mode: C; indent-tabs-mode:nil; c-basic-offset:8 -*- */
+
+/**
+ *This test example shows how to use the SAC api.
+ *
+ *This features a simple parser that says "hey" when
+ *it encounters the beginning of a CSS ruleset, and "woohoo"
+ *at the end of a CSS ruleset.
+ *
+ *To compile this file, type:
+ *
+ *gcc -g -Wall -o sac-example-1 `croco-0.6-config --cflags` `croco-0.6-config --libs` sac-example-1.c
+ *
+ *Make sure you have compiled and installed libcroco prior to trying to
+ *compile this file :)
+ *
+ *Once you have compiled it, type:
+ *
+ *./sac-example-1 <a-path-to-a-css-file>
+ *
+ *to try it on a CSS file of your choice.
+ *
+ *Initial Author: Dodji Seketeli <Dodji 47 seketeli dot org>
+ */
+
+#include <string.h>
+#include <libcroco/libcroco.h>
+
+/**
+ *This is a callback function that will
+ *be called at the beginning of each css ruleset.
+ *@param a_handler a pointer to the current sac
+ *document handler
+ *@param a_selector a pointer to the selector.
+ *of the current ruleset.
+ */
+static void
+start_selector_cb (CRDocHandler *a_handler,
+ CRSelector *a_selector)
+{
+ printf ("==========================================\n") ;
+ printf ("Hey, this is the beginning of a ruleset\n") ;
+}
+
+/**
+ *This is a callback function that will be called at the end
+ *of the each css ruleset.
+ */
+static void
+end_selector_cb (CRDocHandler *a_handler,
+ CRSelector *a_selector)
+{
+ printf ("Woohoo, this is the end of a ruleset\n") ;
+ printf ("======================================\n\n") ;
+}
+
+/**
+ *Displays some information about how to use this program.
+ *@param a_prog_name the name of the current program.
+ */
+void
+display_usage (unsigned char *a_prog_name)
+{
+ unsigned char *prog_name = a_prog_name ;
+
+ if (!prog_name)
+ {
+ prog_name = (unsigned char*)"sac-example-1" ;
+ }
+
+ printf ("usage: %s [--help] | <css file name>\n", prog_name) ;
+}
+
+int
+main (int argc, char **argv)
+{
+ unsigned short i = 0 ;
+ unsigned char * file_path = NULL ;
+ CRParser * parser = NULL ;
+ CRDocHandler *sac_handler = NULL ;
+
+ if (argc <= 1)
+ {
+ display_usage ((unsigned char*)argv[0]) ;
+ return -1 ;
+ }
+
+ /*
+ *Let's parse the
+ *command line arguments of this
+ *program in this loop.
+ */
+ for (i=1 ; i < argc ;i++)
+ {
+ if (*argv[i] != '-')
+ break ;
+
+ if (!strcmp (argv[i], "--help")
+ || !strcmp (argv[i], "-h"))
+ {
+ display_usage ((unsigned char*)argv[0]) ;
+ return -1;
+ }
+ else
+ {
+ /*
+ *no other option is
+ *available now, so this is
+ *a bit redundant...
+ */
+ display_usage ((unsigned char*)argv[0]) ;
+ }
+ }
+
+ if (i > argc)
+ {
+ /*
+ *no file name has been given
+ *in parameter, go out.
+ */
+ return -1 ;
+ }
+
+ /****************************************
+ *Now, the real libcroco related stuffs...
+ ****************************************/
+
+ file_path = (unsigned char*)argv[i] ;
+
+ /*
+ *Instantiate the libcroco parser.
+ */
+ parser = cr_parser_new_from_file (file_path,
+ CR_ASCII) ;
+ if (!parser)
+ {
+ /*
+ *Damned, something bad happened ...
+ */
+ return -1;
+ }
+
+ /*
+ *Instantiates the SAC document handler.
+ */
+ sac_handler = cr_doc_handler_new () ;
+ if (!sac_handler)
+ {
+ /*
+ *Argh, something bad happened here :-\
+ *Let's release the resources we allocated
+ *and let's get out.
+ */
+
+ cr_parser_destroy (parser) ;
+ return -1;
+ }
+
+ /******************
+ *Sets some of the sac document handlers.
+ ****************/
+
+ /*
+ *This sac handler callback function will get called by the parser
+ *each time it encounters the beginning of a ruleset.
+ */
+ sac_handler->start_selector = start_selector_cb ;
+
+ /*
+ *This sac handler callback function will get called by the parser
+ *each time it encounters the end of a ruleset.
+ */
+ sac_handler->end_selector = end_selector_cb ;
+
+ /*
+ *Let's register our sac handler into the parser.
+ */
+ cr_parser_set_sac_handler (parser, sac_handler) ;
+
+ /*
+ *Now, let's do the parsing !!!
+ */
+ cr_parser_parse (parser) ;
+
+ /*******************************************************
+ *End of the parsing. A lot of sentences beginning with "Hey"
+ *may have been printed on the screen...
+ ***********************************************/
+
+ /*
+ *Time to free the resources we allocated.
+ */
+ cr_parser_destroy (parser) ;
+
+ cr_doc_handler_unref (sac_handler) ;
+
+ return 0 ;
+}
diff --git a/src/3rdparty/libcroco/docs/examples/sac-example-2.c b/src/3rdparty/libcroco/docs/examples/sac-example-2.c
new file mode 100644
index 0000000..63b002d
--- /dev/null
+++ b/src/3rdparty/libcroco/docs/examples/sac-example-2.c
@@ -0,0 +1,349 @@
+/* -*- Mode: C; indent-tabs-mode:nil; c-basic-offset:8 -*- */
+/**
+ *This test example shows how to use the SAC api.
+ *
+ *This features a simple parser that prints the selector list
+ *and the properties list of each CSS ruleset found.
+ *It also prints the number of properties found in each CSS ruleset.
+ *
+ *At the end of the parsing, it a prints the number of rulesets found
+ *in the CSS document.
+ *
+ *To to this, several handler callbacks have been registered.
+ *We have also created a data structure that we call a parsing context.
+ *This parsing context stores the data necessary to achieve the calculation
+ *done during the parsing (count the number of rulesets and the number
+ *of properties per ruleset)
+ *The parsing context itself is stored in the "app_data" field of the sac handler.
+ *This field is there to provide applications with a
+ *place to store the custom data they want to be able to get/set during the parsing.
+ *
+ *To compile this file, type:
+ *
+ *gcc -g -Wall -o sac-example-2 `croco-0.6-config --cflags` `croco-0.6-config --libs` sac-example-2.c
+ *
+ *Make sure you have compiled and installed libcroco prior to trying to
+ *compile this file :)
+ *
+ *Once you have compiled it, type:
+ *
+ *./sac-example-2 <a-path-to-a-css-file>
+ *
+ *to try it on a CSS file of your choice.
+ *
+ *Initial Author: Dodji Seketeli <Dodji 47 seketeli dot org>
+ */
+#include <string.h>
+#include <stdlib.h>
+#include <libcroco/libcroco.h>
+
+/**
+ *A Context that will hold the
+ *variables necessary to count the number
+ *of rulesets and the number of properties
+ *per ruleset.
+ */
+struct MyFooContext
+{
+ /**the total number of rulesets in the stylesheet.*/
+ int nb_rulesets ;
+
+ /**the number of property per ruleset.*/
+ int nb_props_per_ruleset ;
+} ;
+
+/**
+ *This callback is called only once, at the beginning of
+ *the CSS Document.
+ *So here, we will allocate a custom parsing context
+ *where we will store data necessary for us to
+ *count the number of rulesets and properties found in
+ *the CSS document.
+ *@param a_handler the sac handler.
+ */
+static void
+start_document_cb (CRDocHandler *a_handler)
+{
+ struct MyFooContext * parsing_context = NULL ;
+
+ /*
+ *Allocate the parsing context.
+ *Our custom parsing context.
+ */
+ parsing_context = (struct MyFooContext*) malloc
+ (sizeof (struct MyFooContext)) ;
+ if (!parsing_context)
+ {
+ /*
+ *the system ran out of memory. Advertise it and
+ *stop the program.
+ */
+ fprintf (stderr, "program ran out of memory") ;
+ exit (-1) ;
+ }
+
+ /*
+ *Initialize the newly allocated custom parsing context
+ *to zero.
+ */
+ memset (parsing_context, 0, sizeof (struct MyFooContext)) ;
+
+ /*
+ *Store the parsing context in the document handler.
+ *The app_data field CRDocHandler is especially there
+ *for that: give applications a place to store some data
+ *during the parsing.
+ */
+ a_handler->app_data = parsing_context ;
+}
+
+/**
+ *This callback function will
+ *be called at the beginning of each css ruleset.
+ *@param a_handler a pointer to the current sac
+ *document handler
+ *@param a_selector a pointer to the selector.
+ *of the current ruleset.
+ */
+static void
+start_selector_cb (CRDocHandler *a_handler,
+ CRSelector *a_selector)
+{
+ struct MyFooContext *context = NULL ;
+
+ context = (struct MyFooContext*) a_handler->app_data ;
+ if (!context)
+ return ;
+ context->nb_props_per_ruleset = 0 ;
+
+ cr_selector_dump (a_selector, stdout) ;
+ printf (" {\n") ;
+
+}
+
+/**
+ *This callback function is called when
+ *the parser encounters a CSS property.
+ *@param a_handler the SAC handler.
+ *@param a_name string that contains the
+ *name of the property.
+ *@param a_value the value of the property.
+ */
+static void
+property_cb (CRDocHandler *a_handler,
+ CRString *a_name,
+ CRTerm *a_value,
+ gboolean a_important)
+{
+ struct MyFooContext *context = NULL ;
+
+ context = (struct MyFooContext *)a_handler->app_data ;
+
+ if (!context || !a_name)
+ return ;
+ context->nb_props_per_ruleset ++ ;
+
+ printf ("%s : ", cr_string_peek_raw_str (a_name)) ;
+ cr_term_dump (a_value, stdout) ;
+ printf ("\n") ;
+}
+
+
+/**
+ *This is a callback function that will be called at the end
+ *of the each css ruleset.
+ */
+static void
+end_selector_cb (CRDocHandler *a_handler,
+ CRSelector *a_selector)
+{
+ struct MyFooContext *context = NULL ;
+
+ context = (struct MyFooContext*)a_handler->app_data ;
+ if (!context)
+ return ;
+ context->nb_rulesets ++ ;
+ printf ("\n}\n") ;
+ printf ("**Number of properties in this ruleset: %d\n\n\n",
+ context->nb_props_per_ruleset) ;
+}
+
+/**
+ *This callback is called only once at the end
+ *of the CSS document.
+ *@param a_handler the SAC handler.
+ */
+static void
+end_document_cb (CRDocHandler *a_handler)
+{
+ struct MyFooContext *context = NULL ;
+
+ context = (struct MyFooContext*) a_handler->app_data ;
+ if (!context)
+ return ;
+
+ printf ("\nTotal number of rulesets: %d\n",
+ context->nb_rulesets) ;
+
+ free (context) ;
+ a_handler->app_data = NULL ;
+}
+
+/**
+ *Displays some information about how to use this program.
+ *@param a_prog_name the name of the current program.
+ */
+void
+display_usage (unsigned char *a_prog_name)
+{
+ unsigned char *prog_name = a_prog_name ;
+
+ if (!prog_name)
+ {
+ prog_name = (unsigned char*) "sac-example-1" ;
+ }
+
+ printf ("usage: %s [--help] | <css file name>\n", prog_name) ;
+}
+
+int
+main (int argc, char **argv)
+{
+ unsigned short i = 0 ;
+ unsigned char * file_path = NULL ;
+ CRParser * parser = NULL ;
+ CRDocHandler *sac_handler = NULL ;
+
+ if (argc <= 1)
+ {
+ display_usage ((unsigned char*)argv[0]) ;
+ return -1 ;
+ }
+
+ /*
+ *Let's parse the
+ *command line arguments of this
+ *program in this loop.
+ */
+ for (i=1 ; i < argc ;i++)
+ {
+ if (*argv[i] != '-')
+ break ;
+
+ if (!strcmp (argv[i], "--help")
+ || !strcmp (argv[i], "-h"))
+ {
+ display_usage ((unsigned char*)argv[0]) ;
+ return -1;
+ }
+ else
+ {
+ /*
+ *no other option is
+ *available now, so this is
+ *a bit redundant...
+ */
+ /*display_usage ((unsigned char*)argv[0]) ;*/
+ }
+ }
+
+ if (i > argc)
+ {
+ /*
+ *no file name has been given
+ *in parameter, go out.
+ */
+ return -1;
+ }
+
+ /****************************************
+ *Now, the real libcroco related stuffs...
+ ****************************************/
+
+ file_path = (unsigned char*)argv[i] ;
+
+ /*
+ *Instantiate the libcroco parser.
+ */
+ parser = cr_parser_new_from_file (file_path,
+ CR_ASCII) ;
+ if (!parser)
+ {
+ /*
+ *Damned, something bad happened ...
+ */
+ return -1 ;
+ }
+
+ /*
+ *Instantiates the SAC document handler.
+ */
+ sac_handler = cr_doc_handler_new () ;
+ if (!sac_handler)
+ {
+ /*
+ *Argh, something bad happened here :-\
+ *Let's release the resources we allocated
+ *and let's get out.
+ */
+
+ cr_parser_destroy (parser) ;
+ return -1 ;
+ }
+
+ /****************************************
+ *Set some of the sac document handlers.
+ ****************************************/
+
+ /*
+ *This callback function will be called by the parser
+ *only once, at the beginning of the CSS Document.
+ */
+ sac_handler->start_document = start_document_cb ;
+
+ /*
+ *This callback function will be called by the parser
+ *only once, at the end of the CSS Document.
+ */
+ sac_handler->end_document =end_document_cb ;
+
+ /*
+ *This callback function will be called by the parser
+ *each time it encounters the beginning of a ruleset.
+ */
+ sac_handler->start_selector = start_selector_cb ;
+
+ /*
+ *This callback function will be called by the parser
+ *each time it encounters the beginning of a ruleset.
+ */
+ sac_handler->property = property_cb ;
+
+ /*
+ *This sac handler callback function will be called by the parser
+ *each time it encounters the end of a ruleset.
+ */
+ sac_handler->end_selector = end_selector_cb ;
+
+ /*
+ *Let's register our sac handler into the parser.
+ */
+ cr_parser_set_sac_handler (parser, sac_handler) ;
+
+ /*
+ *Now, let's do the parsing !!!
+ */
+ cr_parser_parse (parser) ;
+
+ /*******************************************************
+ *End of the parsing. A Couple of CSS rulesets must have
+ *been printed on the screen...
+ ***********************************************/
+
+ /*
+ *Time to free the resources we allocated.
+ */
+ cr_parser_destroy (parser) ;
+
+ return 0 ;
+}
diff --git a/src/3rdparty/libcroco/docs/examples/selection-example-1.c b/src/3rdparty/libcroco/docs/examples/selection-example-1.c
new file mode 100644
index 0000000..3215a99
--- /dev/null
+++ b/src/3rdparty/libcroco/docs/examples/selection-example-1.c
@@ -0,0 +1,191 @@
+/**
+ * This example looks up a node from a document with an
+ * xpath expression, then reports all properties that apply
+ * from a given stylesheet.
+ *
+ * To compile it using gcc, type
+ *
+ * gcc -g -Wall `croco-0.6-config --cflags` `croco-0.6-config --libs` -o selection-example-1 selection-example-1.c
+ *
+ * Initial author: Stefan Seefeld.
+ */
+
+#include <libcroco/libcroco.h>
+#include <libcroco/cr-libxml-node-iface.h>
+#include <libxml/tree.h>
+#include <libxml/xpath.h>
+
+void
+usage_and_exit (char *progname)
+{
+ fprintf (stderr,
+ "Usage: %s <xml doc> <stylesheet> <xpath>\n",
+ progname);
+ exit(-1);
+}
+
+struct workspace
+{
+ xmlDoc *document;
+ xmlXPathContext *xpath;
+ xmlXPathObject *result;
+ CRStyleSheet *stylesheet;
+ CRCascade *cascade;
+ CRSelEng *selector;
+};
+
+/**
+ *construct workspace members in order...
+ * return 0 on success and -1 on error
+ */
+int
+init (struct workspace *ws, char **args)
+{
+ enum CRStatus status = CR_OK;
+
+ ws->document = 0;
+ ws->xpath = 0;
+ ws->result = 0;
+ ws->stylesheet = 0;
+ ws->cascade = 0;
+ ws->selector = 0;
+
+
+ ws->document = xmlParseFile(args[0]);
+ if (!ws->document)
+ {
+ fprintf(stderr, "could not parse the document %s", args[0]);
+ return -1;
+ }
+ ws->xpath = xmlXPathNewContext(ws->document);
+ if (!ws->xpath)
+ {
+ fprintf(stderr, "Error: unable to create new XPath context\n");
+ return -1;
+ }
+ ws->result = xmlXPathEvalExpression((xmlChar *)args[2], ws->xpath);
+ if (!ws->result)
+ {
+ fprintf(stderr, "Error: unable to evaluate xpath expression\n");
+ return -1;
+ }
+ if (ws->result->type != XPATH_NODESET || !ws->result->nodesetval)
+ {
+ fprintf(stderr, "Error: xpath does not evaluate to a node set\n");
+ return -1;
+ }
+
+ status = cr_om_parser_simply_parse_file((const guchar*)args[1] /*sheet*/,
+ CR_ASCII /*the encoding*/,
+ &ws->stylesheet);
+ if (status != CR_OK || !ws->stylesheet)
+ {
+ fprintf(stderr, "could not parse the stylesheet %s", args[1]);
+ return -1;
+ }
+ ws->cascade = cr_cascade_new(ws->stylesheet, 0, 0);
+ ws->selector = cr_sel_eng_new(&cr_libxml_node_iface);
+ return 1 ;
+}
+
+/* ...and destruct in reverse order*/
+void
+fini(struct workspace *ws)
+{
+ if (ws->selector)
+ {
+ cr_sel_eng_destroy(ws->selector);
+ ws->selector = NULL ;
+ }
+ if (ws->cascade)
+ {
+ cr_cascade_destroy(ws->cascade);
+ ws->cascade = NULL ;
+ }
+
+ if (ws->result)
+ {
+ xmlXPathFreeObject(ws->result);
+ ws->result = NULL ;
+ }
+ if (ws->xpath)
+ {
+ xmlXPathFreeContext(ws->xpath);
+ ws->xpath = NULL ;
+ }
+ if (ws->document)
+ {
+ xmlFreeDoc(ws->document);
+ ws->document = NULL ;
+ }
+ xmlCleanupParser () ;
+}
+
+void
+print_properties_real (CRPropList *proplist)
+{
+ CRDeclaration *decl = NULL ;
+ CRPropList *cur_pair = NULL ;
+
+ for (cur_pair = proplist ; cur_pair ;
+ cur_pair= cr_prop_list_get_next (cur_pair)) {
+ gchar *str = NULL ;
+ decl = NULL ;
+
+ cr_prop_list_get_decl (cur_pair, &decl) ;
+ if (decl) {
+ str = cr_declaration_to_string (decl, 0) ;
+ if (str) {
+ printf ("%s\n", str) ;
+ g_free (str);
+ str = NULL ;
+ }
+ }
+ }
+}
+
+void
+print_properties (struct workspace *ws)
+{
+ enum CRStatus status;
+ CRPropList *prop_list = NULL;
+ xmlNode *node = ws->result->nodesetval->nodeTab[0];
+
+ status = cr_sel_eng_get_matched_properties_from_cascade
+ (ws->selector, ws->cascade,
+ node, &prop_list);
+
+ if (status != CR_OK)
+ fprintf(stderr, "Error retrieving properties\n");
+ else
+ {
+ xmlChar *prop = NULL ;
+ prop = xmlGetNodePath(node) ;
+ if (prop) {
+ printf("properties for node %s :\n", prop);
+ xmlFree (prop) ;
+ prop = NULL ;
+ }
+ print_properties_real (prop_list) ;
+ }
+ cr_prop_list_destroy (prop_list) ;
+}
+
+int
+main(int argc, char **argv)
+{
+ struct workspace ws;
+ if (argc != 4) usage_and_exit(argv[0]);
+ if (!init(&ws, argv + 1)) {
+ fini(&ws);
+ return -1 ;
+ }
+
+ if (ws.result->nodesetval->nodeNr == 0)
+ printf("no matching nodes found\n");
+ else
+ print_properties(&ws);
+
+ fini(&ws);
+ return 0;
+}
diff --git a/src/3rdparty/libcroco/docs/examples/selection-example-1.css b/src/3rdparty/libcroco/docs/examples/selection-example-1.css
new file mode 100644
index 0000000..044e053
--- /dev/null
+++ b/src/3rdparty/libcroco/docs/examples/selection-example-1.css
@@ -0,0 +1,41 @@
+report
+{
+ color : red;
+}
+
+report > entry
+{
+ color : blue;
+}
+
+note
+{
+ color : note-color;
+ frame : solid;
+}
+
+note[id]
+{
+ color : note-id-color;
+ frame : solid;
+}
+
+note[id=bar]
+{
+ margin : 5px;
+ color: note-id-bar-color ;
+}
+
+note[id=foo]
+{
+ color : note-id-foo-color;
+}
+
+entry[type=notice] note[id=bar]
+{
+ padding : 5px;
+}
+
+note + notea {
+ color: notea-color ;
+}
diff --git a/src/3rdparty/libcroco/docs/examples/selection-example-1.xml b/src/3rdparty/libcroco/docs/examples/selection-example-1.xml
new file mode 100644
index 0000000..4c3f558
--- /dev/null
+++ b/src/3rdparty/libcroco/docs/examples/selection-example-1.xml
@@ -0,0 +1,14 @@
+<?xml version="1.0" ?>
+<report>
+ <entry type="notice">
+ <note id="foo"/>
+ <notea/>
+ <note id="bar"/>
+ </entry>
+ <entry>
+ <notea/>
+ <note/>
+ <note id="foo"/>
+ <note id="bar"/>
+ </entry>
+</report>
diff --git a/src/3rdparty/libcroco/docs/reference/Makefile.am b/src/3rdparty/libcroco/docs/reference/Makefile.am
new file mode 100644
index 0000000..0ec463d
--- /dev/null
+++ b/src/3rdparty/libcroco/docs/reference/Makefile.am
@@ -0,0 +1,53 @@
+## Process this file with automake to produce Makefile.in
+NULL=
+
+# The name of the module, e.g. 'glib'.
+DOC_MODULE=libcroco
+
+# The top-level SGML file. Change it if you want.
+DOC_MAIN_SGML_FILE=$(DOC_MODULE)-docs.sgml
+
+# The directory containing the source code. Relative to $(srcdir).
+# gtk-doc will search all .c & .h files beneath here for inline comments
+# documenting functions and macros.
+DOC_SOURCE_DIR=../../src
+
+# Extra options to pass to gtkdoc-scanobj or gtkdoc-scangobj.
+SCANGOBJ_OPTIONS=--type-init-func="g_type_init()"
+
+# Extra options to supply to gtkdoc-scan.
+SCAN_OPTIONS=
+
+# Extra options to supply to gtkdoc-mkdb.
+MKDB_OPTIONS=--sgml-mode --output-format=xml
+
+# Extra options to supply to gtkdoc-fixref.
+FIXXREF_OPTIONS=
+
+# Used for dependencies.
+HFILE_GLOB=$(top_srcdir)/src/*.h
+CFILE_GLOB=$(top_srcdir)/src/*.c
+
+# Header files to ignore when scanning.
+IGNORE_HFILES=\
+ $(NULL)
+
+# Images to copy into HTML directory.
+HTML_IMAGES=\
+ $(NULL)
+
+# Extra SGML files that are included by $(DOC_MAIN_SGML_FILE).
+content_files=\
+ $(NULL)
+
+# CFLAGS and LDFLAGS for compiling scan program. Only needed if your app/lib
+# contains GtkObjects/GObjects and you want to document signals and properties.
+GTKDOC_CFLAGS=\
+ $(CROCO_CFLAGS) \
+ $(NULL)
+GTKDOC_LIBS=\
+ $(CROCO_LIBS) \
+ $(NULL)
+
+include $(top_srcdir)/gtk-doc.make
+
diff --git a/src/3rdparty/libcroco/docs/reference/libcroco-docs.sgml b/src/3rdparty/libcroco/docs/reference/libcroco-docs.sgml
new file mode 100644
index 0000000..f67e318
--- /dev/null
+++ b/src/3rdparty/libcroco/docs/reference/libcroco-docs.sgml
@@ -0,0 +1,39 @@
+<?xml version="1.0"?>
+<!DOCTYPE book PUBLIC "-//OASIS//DTD DocBook XML V4.1.2//EN"
+ "http://www.oasis-open.org/docbook/xml/4.1.2/docbookx.dtd">
+<book id="index" xmlns:xi="http://www.w3.org/2003/XInclude">
+ <bookinfo>
+ <title>Libcroco Reference Manual</title>
+ </bookinfo>
+
+ <chapter>
+ <title>Extensive APIs description</title>
+ <xi:include href="xml/cr-additional-sel.xml"/>
+ <xi:include href="xml/cr-attr-sel.xml"/>
+ <xi:include href="xml/cr-cascade.xml"/>
+ <xi:include href="xml/cr-declaration.xml"/>
+ <xi:include href="xml/cr-doc-handler.xml"/>
+ <xi:include href="xml/cr-enc-handler.xml"/>
+ <xi:include href="xml/cr-fonts.xml"/>
+ <xi:include href="xml/cr-input.xml"/>
+ <xi:include href="xml/cr-num.xml"/>
+ <xi:include href="xml/cr-om-parser.xml"/>
+ <xi:include href="xml/cr-parser.xml"/>
+ <xi:include href="xml/cr-parsing-location.xml"/>
+ <xi:include href="xml/cr-prop-list.xml"/>
+ <xi:include href="xml/cr-pseudo.xml"/>
+ <xi:include href="xml/cr-rgb.xml"/>
+ <xi:include href="xml/cr-sel-eng.xml"/>
+ <xi:include href="xml/cr-selector.xml"/>
+ <xi:include href="xml/cr-simple-sel.xml"/>
+ <xi:include href="xml/cr-statement.xml"/>
+ <xi:include href="xml/cr-string.xml"/>
+ <xi:include href="xml/cr-style.xml"/>
+ <xi:include href="xml/cr-stylesheet.xml"/>
+ <xi:include href="xml/cr-term.xml"/>
+ <xi:include href="xml/cr-tknzr.xml"/>
+ <xi:include href="xml/cr-token.xml"/>
+ <xi:include href="xml/cr-utils.xml"/>
+ <xi:include href="xml/libcroco-config.xml"/>
+ </chapter>
+</book>
diff --git a/src/3rdparty/libcroco/docs/release-notes-template.txt b/src/3rdparty/libcroco/docs/release-notes-template.txt
new file mode 100644
index 0000000..df66f98
--- /dev/null
+++ b/src/3rdparty/libcroco/docs/release-notes-template.txt
@@ -0,0 +1,41 @@
+Application
+===========
+
+Libcroco 0.4
+
+Description
+===========
+
+Libcroco is a CSS parsing and manipulation library
+written in C for the gnome project.
+
+It provides :
+
+-two CSS parsing apis: SAC and CSSOM.
+-A CSS2 selection and cascading engine based on libxml2.
+-An experimental XML/CSS rendering engine.
+
+Changes
+=======
+- Removed the pango dependency from the
+ selection engine and put it in the layout engine. (Dodji Seketeli)
+- Added a test example to demonstrate the use of the selection engine (Stefan Seefeld)
+
+Fixes
+=====
+- Fixed some gcc-2.96 parse errors (Dodji Seketeli)
+- Make sure the header files are C++ friendly (Dodji Seketeli)
+- Make sure the code examples compile with g++ (Dodji Seketeli)
+- Fixed a bug in the selection engine (Dodji Seketeli)
+
+Homepage
+========
+http://www.freespiders.org/projects/libcroco
+
+Download
+========
+http://ftp.gnome.org/pub/GNOME/sources/libcroco
+
+GNOME Software Map entry
+========================
+http://www.gnome.org/softwaremap/projects/libcroco
diff --git a/src/3rdparty/libcroco/docs/usage.txt b/src/3rdparty/libcroco/docs/usage.txt
new file mode 100644
index 0000000..a061116
--- /dev/null
+++ b/src/3rdparty/libcroco/docs/usage.txt
@@ -0,0 +1,47 @@
+initial author: Dodji Seketeli <dodji@seketeli.org>
+
+Note:
+----
+Users can generate an html doc of all the functions of libcroco.
+This is documentation is an unvaluable tool to master the libcroco
+usage and internals.
+To generate the documentation, just cd into the libcroco project
+directory and type 'make apidoc' ;
+This will generate the documentation in the docs/api directory.
+
+
+Usage of the libcroco css2 parsing library
+===========================================
+
+libcroco has two main user programming interfaces:
+the SAC parser, and the CSSOM parser.
+
+
+The SAC parser
+''''''''''''''''
+
+The SAC (Simple Api for CSS) is the lowest level parsing api
+provided by libcroco.
+It is an event driven api in which the parser notifies the
+caller whenever it encounters a remarquable css construction.
+
+The SAC parser is implemented in the CRParser class.
+To use it, one must first instantiate a CRParser.
+
+I said earlier the the SAC parser notifies it caller
+whenever it encounters certain css language constructions during
+the parsing. "Notifies" actually means that it calls a subset of given
+callback function pointers set. This set of function pointers is
+called a "Document Handler". So, by overriding some function pointers
+of the document handler, the user can define the actions to be
+performed when a given css language construction is encountered.
+
+The SAC parser's api is defined in cr-parser.h and
+the document handler's api is defined in cr-doc-handler.h .
+
+
+The CSSOM parser
+'''''''''''''''''
+
+
+