summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDodji <dodji@gnome.org>2004-03-06 19:04:47 +0000
committerDodji Seketeli <dodji@src.gnome.org>2004-03-06 19:04:47 +0000
commit406526f52125bbf6dbf95eee6f01655544a70b24 (patch)
tree7b534b4e448c3de988f08276986663c200d88cbb
parent67ae4b95a62651c71d1ea250308e6479aca048f7 (diff)
downloadlibcroco-406526f52125bbf6dbf95eee6f01655544a70b24.tar.gz
reflect the removal of src/parser src/seleng and src/layeng added this new
2004-03-06 Dodji <dodji@gnome.org> * Doxyfile: reflect the removal of src/parser src/seleng and src/layeng * src/cr-declaration.c: (cr_declaration_list_to_string2): added this new method. * src/cr-sel-eng.c: fix a bug in the !important handling in the cascading algorithm.
-rw-r--r--ChangeLog9
-rw-r--r--Doxyfile2
-rw-r--r--src/cr-declaration.c56
-rw-r--r--src/cr-declaration.h12
-rw-r--r--src/cr-sel-eng.c24
-rw-r--r--src/cr-statement.c90
-rw-r--r--src/cr-statement.h4
7 files changed, 159 insertions, 38 deletions
diff --git a/ChangeLog b/ChangeLog
index fbe40f0..c6cb33c 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,12 @@
+2004-03-06 Dodji <dodji@gnome.org>
+
+ * Doxyfile: reflect the removal of src/parser src/seleng and
+ src/layeng
+ * src/cr-declaration.c:
+ (cr_declaration_list_to_string2): added this new method.
+ * src/cr-sel-eng.c: fix a bug in the !important handling
+ in the cascading algorithm.
+
2004-03-06 Dodji Seketeli <dodji@gnome.org>
* csslint/csslint.c: applied a patch from Rob BUIS
diff --git a/Doxyfile b/Doxyfile
index ef3ecc2..84eedbd 100644
--- a/Doxyfile
+++ b/Doxyfile
@@ -316,7 +316,7 @@ WARN_LOGFILE =
# directories like "/usr/src/myproject". Separate the files or directories
# with spaces.
-INPUT = src src/parser src/seleng src/layeng
+INPUT = src
# If the value of the INPUT tag contains directories, you can use the
# FILE_PATTERNS tag to specify one or more wildcard pattern (like *.cpp
diff --git a/src/cr-declaration.c b/src/cr-declaration.c
index 38b8b5c..743e450 100644
--- a/src/cr-declaration.c
+++ b/src/cr-declaration.c
@@ -512,7 +512,7 @@ cr_declaration_dump_one (CRDeclaration *a_this,
*@param a_indent the number of indentation white char
*to put before the actual serialisation.
*/
-guchar *
+gchar *
cr_declaration_to_string (CRDeclaration *a_this,
gulong a_indent)
{
@@ -619,6 +619,60 @@ cr_declaration_list_to_string (CRDeclaration *a_this,
}
/**
+ *Serializes the declaration list into a string
+ *@param a_this the current instance of #CRDeclaration.
+ *@param a_indent the number of indentation white char
+ *to put before the actual serialisation.
+ */
+guchar *
+cr_declaration_list_to_string2 (CRDeclaration *a_this,
+ gulong a_indent,
+ gboolean a_one_decl_per_line)
+{
+ CRDeclaration *cur = NULL ;
+ GString *stringue = NULL ;
+ guchar *str = NULL, *result = NULL ;
+
+ g_return_val_if_fail (a_this, NULL) ;
+
+ stringue = g_string_new (NULL) ;
+
+ for (cur = a_this ; cur ; cur = cur->next)
+ {
+ str = cr_declaration_to_string (cur, a_indent) ;
+ if (str)
+ {
+ if (a_one_decl_per_line == TRUE)
+ {
+ if (cur->next)
+ g_string_append_printf (stringue,
+ "%s;\n", str) ;
+ else
+ g_string_append_printf (stringue,
+ "%s", str) ;
+ }
+ else
+ {
+ if (cur->next)
+ g_string_append_printf (stringue, "%s;", str) ;
+ else
+ g_string_append_printf (stringue, "%s", str) ;
+ }
+ g_free (str) ;
+ }
+ else
+ break;
+ }
+ if (stringue && stringue->str)
+ {
+ result = stringue->str ;
+ g_string_free (stringue, FALSE) ;
+ }
+
+ return result ;
+}
+
+/**
*Return the number of properties in the declaration;
*@param a_this the current instance of #CRDeclaration.
*@return number of properties in the declaration list.
diff --git a/src/cr-declaration.h b/src/cr-declaration.h
index d12c1d9..eed3a3d 100644
--- a/src/cr-declaration.h
+++ b/src/cr-declaration.h
@@ -111,14 +111,16 @@ CRDeclaration * cr_declaration_get_from_list (CRDeclaration *a_this, int itemnr)
CRDeclaration * cr_declaration_get_by_prop_name (CRDeclaration *a_this, const guchar *a_str) ;
-guchar * cr_declaration_to_string (CRDeclaration *a_this,
- gulong a_indent) ;
+gchar * cr_declaration_to_string (CRDeclaration *a_this,
+ gulong a_indent) ;
guchar * cr_declaration_list_to_string (CRDeclaration *a_this,
- gulong a_indent) ;
+ gulong a_indent) ;
+guchar * cr_declaration_list_to_string2 (CRDeclaration *a_this,
+ gulong a_indent,
+ gboolean a_one_decl_per_line) ;
void cr_declaration_ref (CRDeclaration *a_this) ;
-gboolean
-cr_declaration_unref (CRDeclaration *a_this) ;
+gboolean cr_declaration_unref (CRDeclaration *a_this) ;
void cr_declaration_destroy (CRDeclaration *a_this) ;
diff --git a/src/cr-sel-eng.c b/src/cr-sel-eng.c
index 035253e..6ac2a65 100644
--- a/src/cr-sel-eng.c
+++ b/src/cr-sel-eng.c
@@ -895,7 +895,7 @@ cr_sel_eng_get_matched_rulesets_real (CRSelEng *a_this,
sel_list = cur_stmt->kind.ruleset->sel_list ;
}
break ;
-
+
case AT_MEDIA_RULE_STMT:
if (cur_stmt->kind.media_rule
&& cur_stmt->kind.media_rule->rulesets
@@ -1256,18 +1256,18 @@ put_css_properties_in_props_list (CRPropList **a_props,
if (a_stmt->specificity
>= decl->parent_statement->specificity)
{
- tmp_props = cr_prop_list_unlink (props,
- pair) ;
- if (!tmp_props)
- {
- cr_utils_trace_info ("tmp_props != NULL failed") ;
+ if (decl->important == TRUE)
continue ;
- }
- props = tmp_props ;
- tmp_props = NULL ;
- cr_prop_list_append2 (props,
- cur_decl->property,
- cur_decl) ;
+ props = cr_prop_list_unlink (props,
+ pair) ;
+ if (pair)
+ {
+ cr_prop_list_destroy (pair) ;
+ pair = NULL ;
+ }
+ props = cr_prop_list_append2 (props,
+ cur_decl->property,
+ cur_decl) ;
}
}
/*TODO: this may leak. Check this out*/
diff --git a/src/cr-statement.c b/src/cr-statement.c
index 6c3ccc2..8e9bca6 100644
--- a/src/cr-statement.c
+++ b/src/cr-statement.c
@@ -601,50 +601,106 @@ cr_statement_clear (CRStatement *a_this)
}
/**
- *Dumps a ruleset statement to a file.
- *@param a_this the current instance of #CRStatement.
- *@param a_fp the destination file pointer.
- *@param a_indent the number of indentation white spaces to add.
+ *Serializes the ruleset statement into a string
+ *@param a_this the current instance of #CRStatement
+ *@param a_indent the number of whitespace to use for indentation
+ *@return the newly allocated serialised string. Must be freed
+ *by the caller, using g_free().
*/
-static void
-cr_statement_dump_ruleset (CRStatement *a_this, FILE *a_fp, glong a_indent)
+static gchar *
+cr_statement_ruleset_to_string (CRStatement *a_this, glong a_indent)
{
- guchar *str = NULL, *tmp_str = NULL ;
+ GString *stringue = NULL ;
+ gchar *tmp_str = NULL, *result = NULL ;
+
+ g_return_val_if_fail (a_this && a_this->type == RULESET_STMT,
+ NULL) ;
- g_return_if_fail (a_this && a_this->type == RULESET_STMT) ;
+ stringue = g_string_new (NULL) ;
if (a_this->kind.ruleset->sel_list)
{
if (a_indent)
- cr_utils_dump_n_chars (' ', a_fp, a_indent) ;
+ cr_utils_dump_n_chars2
+ (' ', stringue, a_indent) ;
- cr_selector_dump (a_this->kind.ruleset->sel_list, a_fp) ;
+ tmp_str =
+ cr_selector_to_string (a_this->kind.ruleset->sel_list) ;
+ if (tmp_str)
+ {
+ g_string_append_printf (stringue,
+ "%s", tmp_str) ;
+ g_free (tmp_str) ;
+ tmp_str = NULL ;
+ }
}
if (a_this->kind.ruleset->decl_list)
{
- fprintf (a_fp," {\n") ;
+ g_string_append_printf (stringue," {\n") ;
+
+ tmp_str = cr_declaration_list_to_string2
+ (a_this->kind.ruleset->decl_list,
+ a_indent + DECLARATION_INDENT_NB,
+ TRUE) ;
+ /*
cr_declaration_dump (a_this->kind.ruleset->decl_list,
a_fp, a_indent + DECLARATION_INDENT_NB,
TRUE) ;
- fprintf (a_fp,"\n") ;
- cr_utils_dump_n_chars (' ', a_fp, a_indent) ;
- fprintf (a_fp,"}") ;
+ */
+ if (tmp_str)
+ {
+ g_string_append_printf
+ (stringue, "%s", tmp_str) ;
+ g_free (tmp_str) ;
+ tmp_str = NULL ;
+ }
+ g_string_append_printf (stringue, "%s", "\n") ;
+ cr_utils_dump_n_chars2 (' ', stringue, a_indent) ;
+ g_string_append_printf (stringue ,"%s","}") ;
}
- if (str)
+ result = stringue->str ;
+
+ if (stringue)
{
- g_free (str) ;
- str = NULL ;
+ g_string_free (stringue, FALSE) ;
+ stringue = NULL ;
}
if (tmp_str)
{
g_free (tmp_str) ;
tmp_str = NULL ;
}
+ return result ;
}
/**
+ *Dumps a ruleset statement to a file.
+ *@param a_this the current instance of #CRStatement.
+ *@param a_fp the destination file pointer.
+ *@param a_indent the number of indentation white spaces to add.
+ */
+static void
+cr_statement_dump_ruleset (CRStatement *a_this, FILE *a_fp, glong a_indent)
+{
+ guchar *str = NULL;
+
+ g_return_if_fail (a_fp && a_this) ;
+ str = cr_statement_ruleset_to_string (a_this, a_indent) ;
+ if (str)
+ {
+ fprintf (a_fp, str) ;
+ g_free (str) ;
+ str = NULL ;
+ }
+}
+
+
+
+/**
+ *TODO: write cr_statement_font_face_rule_to_string()
+ *and make this function use it.
*Dumps a font face rule statement to a file.
*@param a_this the current instance of font face rule statement.
*@param a_fp the destination file pointer.
diff --git a/src/cr-statement.h b/src/cr-statement.h
index 78a38b4..f393d12 100644
--- a/src/cr-statement.h
+++ b/src/cr-statement.h
@@ -3,8 +3,6 @@
/*
* 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.
@@ -18,6 +16,8 @@
* along with this program; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307
* USA
+ *
+ * See COPYRIGHTS file for copyright information.
*/
/*