summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDodji Seketeli <dodji@gnome.org>2004-02-07 22:46:53 +0000
committerDodji Seketeli <dodji@src.gnome.org>2004-02-07 22:46:53 +0000
commitb4b0cb746513170579d6fe7450fb6cb555cb73b8 (patch)
tree8fcd69a334101b3f1694e95b3885026e8e11cfd5
parentb10c9b189723585325dee43719540a34f7269ceb (diff)
downloadlibcroco-b4b0cb746513170579d6fe7450fb6cb555cb73b8.tar.gz
In the process of adding style structure debugging facilities.
2004-02-07 Dodji Seketeli <dodji@gnome.org> * src/cr-fonts.[hc],src/cr-num.h,src/cr-style.[ch]: In the process of adding style structure debugging facilities.
-rw-r--r--ChangeLog10
-rw-r--r--src/cr-fonts.c266
-rw-r--r--src/cr-fonts.h32
-rw-r--r--src/cr-num.h4
-rw-r--r--src/cr-sel-eng.c3
-rw-r--r--src/cr-style.c550
-rw-r--r--src/cr-style.h28
7 files changed, 866 insertions, 27 deletions
diff --git a/ChangeLog b/ChangeLog
index 5a14e69..ab980b3 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,13 @@
+2004-02-07 Dodji Seketeli <dodji@gnome.org>
+
+ * src/cr-fonts.[hc],src/cr-num.h,src/cr-style.[ch]:
+ In the process of adding style structure debugging facilities.
+
+2004-02-04 Dodji Seketeli <dodji@gnome.org>
+
+ * src/cr-style.c: cr_style_to_string() added this prototype.
+ Still have to code it.
+
2004-01-29 Dodji Seketeli <dodji@gnome.org>
* src/cr-sel-eng.c:
diff --git a/src/cr-fonts.c b/src/cr-fonts.c
index 2a5f908..39e5f14 100644
--- a/src/cr-fonts.c
+++ b/src/cr-fonts.c
@@ -3,7 +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
@@ -20,6 +19,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
*/
#include "cr-fonts.h"
@@ -78,25 +79,74 @@ cr_font_family_to_string_real (CRFontFamily *a_this,
{
if (a_this->prev)
{
- g_string_append_printf (*a_string,
- ", %s", name) ;
+ g_string_append_printf (*a_string, ", %s", name) ;
}
else
{
- g_string_append (*a_string,
- name) ;
+ g_string_append (*a_string, name) ;
}
}
-
if (a_walk_list == TRUE && a_this->next)
{
result = cr_font_family_to_string_real (a_this->next,
TRUE, a_string) ;
}
-
return result ;
}
+static const gchar *
+cr_predefined_absolute_font_size_to_string (enum CRPredefinedAbsoluteFontSize a_code)
+{
+ gchar *str = NULL ;
+ switch (a_code)
+ {
+ case FONT_SIZE_XX_SMALL:
+ str = (gchar*)"font-size-xx-small" ;
+ break ;
+ case FONT_SIZE_X_SMALL:
+ str = (gchar*)"font-size-x-small" ;
+ break ;
+ case FONT_SIZE_SMALL:
+ str = (gchar*)"font-size-small" ;
+ break ;
+ case FONT_SIZE_MEDIUM:
+ str = (gchar*)"font-size-medium" ;
+ break ;
+ case FONT_SIZE_LARGE:
+ str = (gchar*)"font-size-large" ;
+ break ;
+ case FONT_SIZE_X_LARGE:
+ str = (gchar*)"font-size-x-large" ;
+ break ;
+ case FONT_SIZE_XX_LARGE:
+ str = (gchar*)"font-size-xx-large" ;
+ break ;
+ default:
+ str = (gchar*) "unknown predefined absolute font size value";
+ }
+ return str ;
+}
+
+static const gchar *
+cr_relative_font_size_to_string (enum CRRelativeFontSize a_code)
+{
+ gchar *str = NULL ;
+
+ switch (a_code)
+ {
+ case FONT_SIZE_LARGER:
+ str = (gchar*)"font-size-larger" ;
+ break ;
+ case FONT_SIZE_SMALLER:
+ str = (gchar*)"font-size-smaller" ;
+ break ;
+ default:
+ str = (gchar*)"unknown relative font size value" ;
+ break ;
+ }
+ return str ;
+}
+
CRFontFamily *
cr_font_family_new (enum CRFontFamilyType a_type, guchar *a_name)
{
@@ -335,6 +385,208 @@ cr_font_size_copy (CRFontSize *a_dst, CRFontSize *a_src)
return CR_OK ;
}
+gchar*
+cr_font_size_to_string (CRFontSize *a_this)
+{
+ gchar *str = NULL ;
+ g_return_val_if_fail (a_this, NULL) ;
+
+ switch (a_this->type)
+ {
+ case PREDEFINED_ABSOLUTE_FONT_SIZE:
+ str = g_strdup (cr_predefined_absolute_font_size_to_string
+ (a_this->value.predefined)) ;
+ break ;
+ case ABSOLUTE_FONT_SIZE:
+ str = cr_num_to_string (a_this->value.absolute) ;
+ break ;
+ case RELATIVE_FONT_SIZE:
+ str = g_strdup (cr_relative_font_size_to_string
+ (a_this->value.relative)) ;
+ break ;
+ case INHERITED_FONT_SIZE:
+ str = g_strdup ("inherited") ;
+ break ;
+ default:
+ break ;
+ }
+ return str ;
+}
+
+
+gchar *
+cr_font_size_adjust_to_string (CRFontSizeAdjust *a_this)
+{
+ gchar *str = NULL ;
+
+ g_return_val_if_fail (a_this, NULL) ;
+
+ switch (a_this->type)
+ {
+ case FONT_SIZE_ADJUST_NONE:
+ str = g_strdup ("font-size-adjust-none") ;
+ break ;
+ case FONT_SIZE_ADJUST_NUMBER:
+ if (a_this->num)
+ str = cr_num_to_string (a_this->num) ;
+ else
+ str = g_strdup ("font-size-adjust-NULL") ;
+ break ;
+ case FONT_SIZE_ADJUST_INHERIT:
+ str = g_strdup ("font-size-adjust-inherit") ;
+ }
+ return str ;
+}
+
+const gchar *
+cr_font_style_to_string (enum CRFontStyle a_code)
+{
+ gchar *str = NULL ;
+
+ switch (a_code)
+ {
+ case FONT_STYLE_NORMAL:
+ str = (gchar*)"font-style-normal" ;
+ break ;
+ case FONT_STYLE_ITALIC:
+ str = (gchar*)"font-style-italic" ;
+ break ;
+ case FONT_STYLE_OBLIQUE:
+ str = (gchar*)"font-style-oblique" ;
+ break ;
+ case FONT_STYLE_INHERIT:
+ str = (gchar*)"font-style-inherit" ;
+ break ;
+ default:
+ str = (gchar*)"font-style" ;
+ break ;
+ }
+ return str ;
+}
+
+const gchar *
+cr_font_variant_to_string (enum CRFontVariant a_code)
+{
+ gchar *str = NULL ;
+
+ switch (a_code)
+ {
+ case FONT_VARIANT_NORMAL:
+ str = (gchar*) "font-variant-normal";
+ break ;
+ case FONT_VARIANT_SMALL_CAPS:
+ str = (gchar*) "font-variant-small-caps" ;
+ break ;
+ case FONT_VARIANT_INHERIT:
+ str = (gchar*) "font-variant-inherent" ;
+ break ;
+ }
+ return str ;
+}
+
+const gchar *
+cr_font_weight_to_string (enum CRFontWeight a_code)
+{
+ gchar *str = NULL ;
+
+ switch (a_code)
+ {
+ case FONT_WEIGHT_NORMAL:
+ str = (gchar*) "font-weight-normal";
+ break ;
+ case FONT_WEIGHT_BOLD:
+ str = (gchar*) "font-weight-bold";
+ break ;
+ case FONT_WEIGHT_BOLDER:
+ str = (gchar*) "font-weight-bolder";
+ break ;
+ case FONT_WEIGHT_LIGHTER:
+ str = (gchar*) "font-weight-lighter";
+ break ;
+ case FONT_WEIGHT_100:
+ str = (gchar*) "font-weight-100";
+ break ;
+ case FONT_WEIGHT_200:
+ str = (gchar*) "font-weight-200";
+ break ;
+ case FONT_WEIGHT_300:
+ str = (gchar*) "font-weight-300";
+ break ;
+ case FONT_WEIGHT_400:
+ str = (gchar*) "font-weight-400";
+ break ;
+ case FONT_WEIGHT_500:
+ str = (gchar*) "font-weight-500";
+ break ;
+ case FONT_WEIGHT_600:
+ str = (gchar*) "font-weight-600";
+ break ;
+ case FONT_WEIGHT_700:
+ str = (gchar*) "font-weight-700";
+ break ;
+ case FONT_WEIGHT_800:
+ str = (gchar*) "font-weight-800";
+ break ;
+ case FONT_WEIGHT_900:
+ str = (gchar*) "font-weight-900";
+ break ;
+ case FONT_WEIGHT_INHERIT:
+ str = (gchar*) "font-weight-inherit";
+ break ;
+ default:
+ str = (gchar*) "unknown font-weight property value";
+ break ;
+ }
+ return str ;
+}
+
+const gchar *
+cr_font_stretch_to_string (enum CRFontStretch a_code)
+{
+ gchar *str = NULL ;
+
+ switch (a_code)
+ {
+ case FONT_STRETCH_NORMAL:
+ str = (gchar*)"font-stretch-normal" ;
+ break ;
+ case FONT_STRETCH_WIDER:
+ str = (gchar*)"font-stretch-wider" ;
+ break ;
+ case FONT_STRETCH_NARROWER:
+ str = (gchar*)"font-stretch-narrower" ;
+ break ;
+ case FONT_STRETCH_ULTRA_CONDENSED:
+ str = (gchar*)"font-stretch-ultra-condensed" ;
+ break ;
+ case FONT_STRETCH_EXTRA_CONDENSED:
+ str = (gchar*)"font-stretch-extra-condensed" ;
+ break ;
+ case FONT_STRETCH_CONDENSED:
+ str = (gchar*)"font-stretch-condensed" ;
+ break ;
+ case FONT_STRETCH_SEMI_CONDENSED:
+ str = (gchar*)"font-stretch-semi-condensed" ;
+ break ;
+ case FONT_STRETCH_SEMI_EXPANDED:
+ str = (gchar*)"font-stretch-semi-expanded" ;
+ break ;
+ case FONT_STRETCH_EXPANDED:
+ str = (gchar*)"font-stretch-expanded" ;
+ break ;
+ case FONT_STRETCH_EXTRA_EXPANDED:
+ str = (gchar*)"font-stretch-extra-expaned" ;
+ break ;
+ case FONT_STRETCH_ULTRA_EXPANDED:
+ str = (gchar*)"font-stretch-ultra-expanded" ;
+ break ;
+ case FONT_STRETCH_INHERIT:
+ str = (gchar*)"font-stretch-inherit" ;
+ break ;
+ }
+ return str ;
+}
+
void
cr_font_size_destroy (CRFontSize *a_font_size)
{
diff --git a/src/cr-fonts.h b/src/cr-fonts.h
index 758778f..76effe7 100644
--- a/src/cr-fonts.h
+++ b/src/cr-fonts.h
@@ -250,27 +250,35 @@ cr_font_family_set_name (CRFontFamily *a_this, guchar *a_name) ;
*'font-size' manipulation functions
***********************************/
-CRFontSize *
-cr_font_size_new (void) ;
+CRFontSize * cr_font_size_new (void) ;
-enum CRStatus
-cr_font_size_clear (CRFontSize *a_this) ;
+enum CRStatus cr_font_size_clear (CRFontSize *a_this) ;
-enum CRStatus
-cr_font_size_copy (CRFontSize *a_dst, CRFontSize *a_src) ;
+enum CRStatus cr_font_size_copy (CRFontSize *a_dst, CRFontSize *a_src) ;
+gchar* cr_font_size_to_string (CRFontSize *a_this) ;
-void
-cr_font_size_destroy (CRFontSize *a_font_size) ;
+void cr_font_size_destroy (CRFontSize *a_font_size) ;
/*******************************************************
*'font-size-adjust' manipulation function declarations
*******************************************************/
-CRFontSizeAdjust *
-cr_font_size_adjust_new (void) ;
+CRFontSizeAdjust * cr_font_size_adjust_new (void) ;
+
+gchar * cr_font_size_adjust_to_string (CRFontSizeAdjust *a_this) ;
+
+void cr_font_size_adjust_destroy (CRFontSizeAdjust *a_this) ;
+
+/***********************************
+ *various other font related functions
+ ***********************************/
+const gchar * cr_font_style_to_string (enum CRFontStyle a_code) ;
+
+const gchar * cr_font_weight_to_string (enum CRFontWeight a_code) ;
+
+const gchar * cr_font_variant_to_string (enum CRFontVariant a_code) ;
-void
-cr_font_size_adjust_destroy (CRFontSizeAdjust *a_this) ;
+const gchar * cr_font_stretch_to_string (enum CRFontStretch a_code) ;
G_END_DECLS
diff --git a/src/cr-num.h b/src/cr-num.h
index f50cfb2..2f4bf7d 100644
--- a/src/cr-num.h
+++ b/src/cr-num.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
*/
/*
diff --git a/src/cr-sel-eng.c b/src/cr-sel-eng.c
index 4153d61..4e47c96 100644
--- a/src/cr-sel-eng.c
+++ b/src/cr-sel-eng.c
@@ -1499,8 +1499,7 @@ cr_sel_eng_get_matched_style (CRSelEng *a_this,
GHashTable *props_hash = NULL ;
g_return_val_if_fail (a_this && a_cascade
- && a_node && a_style
- && (*a_style == NULL),
+ && a_node && a_style,
CR_BAD_PARAM_ERROR) ;
status = cr_sel_eng_get_matched_properties_from_cascade
diff --git a/src/cr-style.c b/src/cr-style.c
index 7533b3e..88d7aa1 100644
--- a/src/cr-style.c
+++ b/src/cr-style.c
@@ -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
@@ -20,6 +18,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 COPYRIGTHS file for information
*/
/*
@@ -162,6 +162,64 @@ static GHashTable *gv_prop_hash = NULL ;
*/
static gulong gv_prop_hash_ref_count = 0 ;
+struct CRNumPropEnumDumpInfo {
+ enum CRNumProp code ;
+ const gchar * str ;
+} ;
+
+static struct CRNumPropEnumDumpInfo gv_num_props_dump_infos[] = {
+ {NUM_PROP_TOP, "top"},
+ {NUM_PROP_RIGHT, "right"},
+ {NUM_PROP_BOTTOM, "bottom"},
+ {NUM_PROP_LEFT, "left"},
+ {NUM_PROP_PADDING_TOP, "padding-top"},
+ {NUM_PROP_PADDING_RIGHT, "padding-right"},
+ {NUM_PROP_PADDING_BOTTOM, "padding-bottom"},
+ {NUM_PROP_PADDING_LEFT, "padding-left"},
+ {NUM_PROP_BORDER_TOP, "border-top"},
+ {NUM_PROP_BORDER_RIGHT, "border-right"},
+ {NUM_PROP_BORDER_BOTTOM, "border-bottom"},
+ {NUM_PROP_BORDER_LEFT, "border-left"},
+ {NUM_PROP_MARGIN_TOP, "margin-top"},
+ {NUM_PROP_MARGIN_RIGHT, "margin-right"},
+ {NUM_PROP_MARGIN_BOTTOM, "margin-bottom"},
+ {NUM_PROP_MARGIN_LEFT, "margin-left"},
+ {NUM_PROP_WIDTH, "width"},
+ {0, NULL}
+} ;
+
+struct CRRgbPropEnumDumpInfo {
+ enum CRRgbProp code ;
+ const gchar *str ;
+} ;
+
+static struct CRRgbPropEnumDumpInfo gv_rgb_props_dump_infos [] =
+{
+ {RGB_PROP_BORDER_TOP_COLOR, "border-top-color"},
+ {RGB_PROP_BORDER_RIGHT_COLOR, "border-right-color"},
+ {RGB_PROP_BORDER_BOTTOM_COLOR, "bottom-color"},
+ {RGB_PROP_BORDER_LEFT_COLOR, "left-color"},
+ {RGB_PROP_COLOR, "color"},
+ {RGB_PROP_BACKGROUND_COLOR, "background-color"},
+ {0, NULL}
+} ;
+
+struct CRBorderStylePropEnumDumpInfo
+{
+ enum CRBorderStyleProp code ;
+ const gchar *str ;
+
+} ;
+
+static struct CRBorderStylePropEnumDumpInfo gv_border_style_props_dump_infos [] =
+{
+ {BORDER_STYLE_PROP_TOP, "border-style-top"},
+ {BORDER_STYLE_PROP_RIGHT, "border-style-right"},
+ {BORDER_STYLE_PROP_BOTTOM, "boder-style-bottom"},
+ {BORDER_STYLE_PROP_LEFT, "border-style-left"},
+ {0,NULL}
+} ;
+
static enum CRStatus
cr_style_init_properties (void) ;
@@ -176,6 +234,14 @@ enum CRDirection
NB_DIRS
} ;
+static const gchar *
+num_prop_code_to_string (enum CRNumProp a_code) ;
+
+static const gchar *
+rgb_prop_code_to_string (enum CRRgbProp a_code) ;
+
+static const gchar *
+border_style_prop_code_to_string (enum CRBorderStyleProp a_code) ;
static enum CRStatus
set_prop_padding_x_from_value (CRStyle *a_style,
@@ -251,6 +317,84 @@ set_prop_font_style_from_value (CRStyle *a_style, CRTerm *a_value) ;
static enum CRStatus
set_prop_font_weight_from_value (CRStyle *a_style, CRTerm *a_value) ;
+
+static const gchar *
+num_prop_code_to_string (enum CRNumProp a_code)
+{
+ gint len = sizeof (gv_num_props_dump_infos) /
+ sizeof (struct CRNumPropEnumDumpInfo) ;
+ if (a_code >= len)
+ {
+ cr_utils_trace_info ("A field has been added "
+ "to 'enum CRNumProp' and no matching"
+ " entry has been "
+ "added to gv_num_prop_dump_infos table.\n"
+ "Please add the missing matching entry") ;
+ return NULL ;
+ }
+ if (gv_num_props_dump_infos[a_code].code != a_code)
+ {
+ cr_utils_trace_info ("mismatch between the order of fields in"
+ " 'enum CRNumProp' and "
+ "the order of entries in "
+ "the gv_num_prop_dump_infos table") ;
+ return NULL ;
+ }
+ return gv_num_props_dump_infos[a_code].str ;
+}
+
+static const gchar *
+rgb_prop_code_to_string (enum CRRgbProp a_code)
+{
+ gint len = sizeof (gv_rgb_props_dump_infos) /
+ sizeof (struct CRRgbPropEnumDumpInfo) ;
+
+ if (a_code >= len)
+ {
+ cr_utils_trace_info ("A field has been added "
+ "to 'enum CRRgbProp' and no matching"
+ " entry has been "
+ "added to gv_rgb_prop_dump_infos table.\n"
+ "Please add the missing matching entry") ;
+ return NULL ;
+ }
+ if (gv_rgb_props_dump_infos[a_code].code != a_code)
+ {
+ cr_utils_trace_info ("mismatch between the order of fields in"
+ " 'enum CRRgbProp' and "
+ "the order of entries in "
+ "the gv_rgb_props_dump_infos table") ;
+ return NULL ;
+ }
+ return gv_rgb_props_dump_infos[a_code].str ;
+}
+
+static const gchar *
+border_style_prop_code_to_string (enum CRBorderStyleProp a_code)
+{
+ gint len = sizeof (gv_border_style_props_dump_infos) /
+ sizeof (struct CRBorderStylePropEnumDumpInfo) ;
+
+ if (a_code >= len)
+ {
+ cr_utils_trace_info ("A field has been added "
+ "to 'enum CRBorderStyleProp' and no matching"
+ " entry has been "
+ "added to gv_border_style_prop_dump_infos table.\n"
+ "Please add the missing matching entry") ;
+ return NULL ;
+ }
+ if (gv_border_style_props_dump_infos[a_code].code != a_code)
+ {
+ cr_utils_trace_info ("mismatch between the order of fields in"
+ " 'enum CRBorderStyleProp' and "
+ "the order of entries in "
+ "the gv_border_style_props_dump_infos table") ;
+ return NULL ;
+ }
+ return gv_border_style_props_dump_infos[a_code].str ;
+}
+
static enum CRStatus
cr_style_init_properties (void)
{
@@ -282,7 +426,6 @@ cr_style_init_properties (void)
}
-
static enum CRPropertyID
cr_style_get_prop_id (const guchar * a_prop)
{
@@ -2193,6 +2336,407 @@ cr_style_copy (CRStyle *a_dest, CRStyle *a_src)
}
/**
+ *dump a CRNumpPropVal in a string.
+ *@param a_prop_val the numerical property value to dump
+ *@param a_str the string to dump the numerical propertie into.
+ *Note that the string value is appended to a_str.
+ *@param a_nb_indent the number white chars of indentation.
+ */
+enum CRStatus
+cr_style_num_prop_val_to_string (CRNumPropVal *a_prop_val,
+ GString *a_str,
+ guint a_nb_indent)
+{
+ enum CRStatus status = CR_OK ;
+ guchar * tmp_str = NULL ;
+ GString *str = NULL ;
+
+ g_return_val_if_fail (a_prop_val && a_str,
+ CR_BAD_PARAM_ERROR) ;
+
+ str = g_string_new (NULL) ;
+ cr_utils_dump_n_chars2 (' ', str, a_nb_indent) ;
+ g_string_append_printf (str, "NumPropVal {") ;
+ tmp_str = cr_num_to_string (&a_prop_val->sv) ;
+ if (!tmp_str)
+ {
+ status = CR_ERROR ;
+ goto cleanup ;
+ }
+ g_string_append_printf (str, "sv: %s ", tmp_str) ;
+ g_free (tmp_str) ;
+ tmp_str = NULL ;
+ tmp_str = cr_num_to_string (&a_prop_val->cv) ;
+ if (!tmp_str)
+ {
+ status = CR_ERROR ;
+ goto cleanup ;
+ }
+ g_string_append_printf (str, "av: %s ", tmp_str) ;
+ g_free (tmp_str) ;
+ tmp_str = NULL ;
+ g_string_append_printf (str, "}") ;
+ g_string_append (str, str->str) ;
+
+ g_string_append (a_str, str->str) ;
+ status = CR_OK ;
+ cleanup:
+
+ if (tmp_str)
+ {
+ g_free (tmp_str) ;
+ tmp_str = NULL ;
+ }
+ if (str)
+ {
+ g_string_free (str, TRUE) ;
+ }
+ return status ;
+}
+
+
+enum CRStatus
+cr_style_rgb_prop_val_to_string (CRRgbPropVal *a_prop_val,
+ GString *a_str,
+ guint a_nb_indent)
+{
+ enum CRStatus status = CR_OK ;
+ guchar * tmp_str = NULL ;
+ GString *str = NULL ;
+
+ g_return_val_if_fail (a_prop_val && a_str, CR_BAD_PARAM_ERROR) ;
+
+ str = g_string_new (NULL) ;
+
+ cr_utils_dump_n_chars2 (' ', str, a_nb_indent) ;
+ g_string_append_printf (str, "RGBPropVal {") ;
+ tmp_str = cr_rgb_to_string (&a_prop_val->sv) ;
+ if (!tmp_str)
+ {
+ status = CR_ERROR ;
+ goto cleanup ;
+ }
+ g_string_append_printf (str, "sv: %s ", tmp_str) ;
+ g_free (tmp_str) ;
+ tmp_str = NULL ;
+ tmp_str = cr_rgb_to_string (&a_prop_val->cv) ;
+ if (!tmp_str)
+ {
+ status = CR_ERROR ;
+ goto cleanup ;
+ }
+ g_string_append_printf (str, "cv: %s ", tmp_str) ;
+ g_free (tmp_str) ;
+ tmp_str = NULL ;
+ tmp_str = cr_rgb_to_string (&a_prop_val->av) ;
+ if (!tmp_str)
+ {
+ status = CR_ERROR ;
+ goto cleanup ;
+ }
+ g_string_append_printf (str, "av: %s ", tmp_str) ;
+ g_free (tmp_str) ;
+ tmp_str = NULL ;
+
+ g_string_append_printf (str, "}") ;
+ g_string_append (str, str->str) ;
+ g_string_append (a_str, str->str) ;
+ status = CR_OK ;
+ cleanup:
+
+ if (tmp_str)
+ {
+ g_free (tmp_str) ;
+ tmp_str = NULL ;
+ }
+ if (str)
+ {
+ g_string_free (str, TRUE) ;
+ }
+ return status ;
+}
+
+enum CRStatus
+cr_style_border_style_to_string (enum CRBorderStyle a_prop,
+ GString *a_str,
+ guint a_nb_indent)
+{
+ gchar *str = NULL ;
+
+ g_return_val_if_fail (a_str, CR_BAD_PARAM_ERROR) ;
+
+ switch (a_prop)
+ {
+ case BORDER_STYLE_NONE:
+ str = (gchar*) "border-style-none" ;
+ break ;
+ case BORDER_STYLE_HIDDEN:
+ str = (gchar*) "border-style-hidden" ;
+ break ;
+ case BORDER_STYLE_DOTTED:
+ str = (gchar*) "border-style-dotted" ;
+ break ;
+ case BORDER_STYLE_DASHED:
+ str = (gchar*) "border-style-dashed" ;
+ break ;
+ case BORDER_STYLE_SOLID:
+ str = (gchar*) "border-style-solid" ;
+ break ;
+ case BORDER_STYLE_DOUBLE:
+ str = (gchar*) "border-style-double" ;
+ break ;
+ case BORDER_STYLE_GROOVE:
+ str = (gchar*) "border-style-groove" ;
+ break ;
+ case BORDER_STYLE_RIDGE:
+ str = (gchar*) "border-style-ridge" ;
+ break ;
+ case BORDER_STYLE_INSET:
+ str = (gchar*) "border-style-inset" ;
+ break ;
+ case BORDER_STYLE_OUTSET:
+ str = (gchar*) "border-style-outset" ;
+ break ;
+ default:
+ str = (gchar*) "unknown border style" ;
+ break ;
+ }
+ cr_utils_dump_n_chars2 (' ', a_str, a_nb_indent) ;
+ g_string_append_printf (a_str, "%s", str) ;
+ return CR_OK ;
+}
+
+
+enum CRStatus
+cr_style_display_type_to_string (enum CRDisplayType a_code,
+ GString *a_str,
+ guint a_nb_indent)
+{
+ gchar *str = NULL ;
+
+ g_return_val_if_fail (a_str, CR_BAD_PARAM_ERROR) ;
+
+ switch (a_code)
+ {
+ case DISPLAY_NONE:
+ str = (gchar*) "display-none" ;
+ break ;
+ case DISPLAY_INLINE:
+ str = (gchar*) "display-inline" ;
+ break ;
+ case DISPLAY_BLOCK:
+ str = (gchar*) "display-block" ;
+ break ;
+ case DISPLAY_LIST_ITEM:
+ str = (gchar*) "display-list-item" ;
+ break ;
+ case DISPLAY_RUN_IN:
+ str = (gchar*) "display-run-in" ;
+ break ;
+ case DISPLAY_COMPACT:
+ str = (gchar*) "display-compact" ;
+ break ;
+ case DISPLAY_MARKER:
+ str = (gchar*) "display-marker" ;
+ break ;
+ case DISPLAY_TABLE:
+ str = (gchar*) "display-table" ;
+ break ;
+ case DISPLAY_INLINE_TABLE:
+ str = (gchar*) "display-inline-table" ;
+ break ;
+ case DISPLAY_TABLE_ROW_GROUP:
+ str = (gchar*) "display-table-row-group" ;
+ break ;
+ case DISPLAY_TABLE_HEADER_GROUP:
+ str = (gchar*) "display-table-header-group" ;
+ break ;
+ case DISPLAY_TABLE_FOOTER_GROUP:
+ str = (gchar*) "display-table-footer-group" ;
+ break ;
+ case DISPLAY_TABLE_ROW:
+ str = (gchar*) "display-table-row" ;
+ break ;
+ case DISPLAY_TABLE_COLUMN_GROUP:
+ str = (gchar*) "display-table-column-group" ;
+ break ;
+ case DISPLAY_TABLE_COLUMN:
+ str = (gchar*) "display-table-column" ;
+ break ;
+ case DISPLAY_TABLE_CELL:
+ str = (gchar*) "display-table-cell" ;
+ break ;
+ case DISPLAY_TABLE_CAPTION:
+ str = (gchar*) "display-table-caption" ;
+ break ;
+ case DISPLAY_INHERIT:
+ str = (gchar*) "display-inherit" ;
+ break ;
+ default:
+ str = (gchar*) "unknown display property" ;
+ break ;
+ }
+ cr_utils_dump_n_chars2 (' ', a_str, a_nb_indent) ;
+ g_string_append_printf (a_str, str) ;
+ return CR_OK ;
+
+}
+
+enum CRStatus
+cr_style_position_type_to_string (enum CRPositionType a_code,
+ GString *a_str,
+ guint a_nb_indent)
+{
+ gchar *str = NULL ;
+
+ g_return_val_if_fail (a_str, CR_BAD_PARAM_ERROR) ;
+
+ switch (a_code)
+ {
+ case POSITION_STATIC:
+ str = (gchar*) "position-static" ;
+ break ;
+ case POSITION_RELATIVE:
+ str = (gchar*) "position-relative" ;
+ break ;
+ case POSITION_ABSOLUTE:
+ str = (gchar*) "position-absolute" ;
+ break ;
+ case POSITION_FIXED:
+ str = (gchar*) "position-fixed" ;
+ break ;
+ case POSITION_INHERIT:
+ str = (gchar*) "position-inherit" ;
+ break ;
+ default:
+ str = (gchar*)"unknown static property" ;
+ }
+ cr_utils_dump_n_chars2 (' ', a_str, a_nb_indent) ;
+ g_string_append_printf (a_str, "%s", str) ;
+ return CR_OK ;
+}
+
+enum CRStatus
+cr_style_float_type_to_string (enum CRFloatType a_code,
+ GString *a_str,
+ guint a_nb_indent)
+{
+ gchar *str = NULL ;
+
+ g_return_val_if_fail (a_str, CR_BAD_PARAM_ERROR) ;
+
+ switch (a_code)
+ {
+ case FLOAT_NONE:
+ str = (gchar*)"float-none" ;
+ break ;
+ case FLOAT_LEFT:
+ str = (gchar*)"float-left" ;
+ break ;
+ case FLOAT_RIGHT:
+ str = (gchar*)"float-right" ;
+ break ;
+ case FLOAT_INHERIT:
+ str = (gchar*)"float-inherit" ;
+ break ;
+ default:
+ str = (gchar*)"unknown float property value" ;
+ break ;
+ }
+ return CR_OK ;
+}
+
+/**
+ *TODO: code this style dumping function (much needed for debugging reasons),
+ *this is a blocking feature.
+ */
+enum CRStatus
+cr_style_to_string (CRStyle *a_this,
+ GString **a_str,
+ guint a_nb_indent)
+{
+ const gint INTERNAL_INDENT = 2 ;
+ gchar *tmp_str = NULL ;
+ GString *indent = NULL, *str = NULL ;
+ gint i = 0 ;
+
+ g_return_val_if_fail (a_this && a_str, CR_BAD_PARAM_ERROR) ;
+
+ if (!*a_str)
+ {
+ str = g_string_new (NULL) ;
+ }
+ else
+ {
+ str = *a_str ;
+ }
+
+ cr_utils_dump_n_chars2 (' ', str, a_nb_indent) ;
+ g_string_append_printf (str, "style {") ;
+
+ /*loop over the num_props and to_string() them*/
+ for (i = NUM_PROP_TOP ; i < NB_NUM_PROPS ; i++) {
+ /*
+ *to_string() the name of the num_prop
+ *(using num_prop_code_to_string)
+ *before outputing it value
+ */
+ tmp_str = (gchar*)num_prop_code_to_string (i) ;
+ if (tmp_str)
+ {
+ g_string_append_printf (str, "%s: ", tmp_str) ;
+ }
+ else
+ {
+ g_string_append_printf (str, "NULL:") ;
+ }
+ tmp_str = NULL ;
+ cr_style_num_prop_val_to_string (&a_this->num_props[i], str,
+ a_nb_indent + INTERNAL_INDENT) ;
+ g_string_append_printf (str, "\n") ;
+ }
+ /*loop over the rgb_props and to_string() them all*/
+ for (i=RGB_PROP_BORDER_TOP_COLOR ; i < NB_RGB_PROPS; i++)
+ {
+ tmp_str = (gchar*)rgb_prop_code_to_string (i) ;
+ if (tmp_str)
+ {
+ g_string_append_printf (str, "%s: ", tmp_str) ;
+ }
+ else
+ {
+ g_string_append_printf (str, "NULL: ") ;
+ }
+ tmp_str = NULL ;
+ cr_style_rgb_prop_val_to_string (&a_this->rgb_props[i], str,
+ a_nb_indent + INTERNAL_INDENT) ;
+ g_string_append_printf (str, "\n") ;
+ }
+ /*loop over the border_style_props and to_string() them*/
+ for (i=BORDER_STYLE_PROP_TOP ; i < NB_BORDER_STYLE_PROPS ; i++)
+ {
+ tmp_str = (gchar*)border_style_prop_code_to_string (i) ;
+ if (tmp_str)
+ {
+ g_string_append_printf (str, "%s: ", tmp_str) ;
+ }
+ else
+ {
+ g_string_append_printf (str, "NULL: ") ;
+ }
+ tmp_str = NULL ;
+ cr_style_border_style_to_string (a_this->border_style_props[i],
+ str,
+ a_nb_indent + INTERNAL_INDENT) ;
+ g_string_append_printf (str, "\n") ;
+ }
+ cr_utils_dump_n_chars2 (' ', str, a_nb_indent) ;
+ g_string_append_printf (str, "}") ;
+
+ return CR_OK ;
+}
+
+/**
*Destructor of the #CRStyle class.
*@param a_this the instance to destroy.
*/
diff --git a/src/cr-style.h b/src/cr-style.h
index b0f9035..54f49eb 100644
--- a/src/cr-style.h
+++ b/src/cr-style.h
@@ -205,7 +205,7 @@ enum CRBoxOffsetProp
/**
*The css2 style class.
*Contains computed and actual values
- *of inferred from the declarations found
+ *inferred from the declarations found
*in the stylesheets.
*See css2 spec chapter 6.
*/
@@ -258,7 +258,29 @@ struct _CRStyle
gulong ref_count ;
} ;
+enum CRStatus cr_style_num_prop_val_to_string (CRNumPropVal *a_prop_val,
+ GString *a_str,
+ guint a_nb_indent) ;
+enum CRStatus cr_style_rgb_prop_val_to_string (CRRgbPropVal *a_prop_val,
+ GString *a_str,
+ guint a_nb_indent) ;
+
+enum CRStatus cr_style_border_style_to_string (enum CRBorderStyle a_prop,
+ GString *a_str,
+ guint a_nb_indent) ;
+
+enum CRStatus cr_style_display_type_to_string (enum CRDisplayType a_code,
+ GString *a_str,
+ guint a_nb_indent) ;
+
+enum CRStatus cr_style_position_type_to_string (enum CRPositionType a_code,
+ GString *a_str,
+ guint a_nb_indent) ;
+
+enum CRStatus cr_style_float_type_to_string (enum CRFloatType a_code,
+ GString *a_str,
+ guint a_nb_indent) ;
CRStyle * cr_style_new (void) ;
enum CRStatus cr_style_set_props_to_defaults (CRStyle *a_this) ;
@@ -276,6 +298,10 @@ void cr_style_destroy (CRStyle *a_this) ;
CRStyle * cr_style_dup (CRStyle *a_this) ;
+enum CRStatus cr_style_to_string (CRStyle *a_this,
+ GString **a_str,
+ guint a_nb_indent) ;
+
G_END_DECLS
#endif /*__CR_STYLE_H__*/