summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDodji Seketeli <dodji@gnome.org>2004-01-29 22:05:14 +0000
committerDodji Seketeli <dodji@src.gnome.org>2004-01-29 22:05:14 +0000
commitb10c9b189723585325dee43719540a34f7269ceb (patch)
tree4baf102731c467ceaa59b9bb82f4fd172fc4c57e
parent1f1479180cb81ec70c9308c447dfdfd6808a3c17 (diff)
downloadlibcroco-b10c9b189723585325dee43719540a34f7269ceb.tar.gz
make sure to set the fields of the style structure passed as an argument
2004-01-29 Dodji Seketeli <dodji@gnome.org> * src/cr-sel-eng.c: (cr_sel_eng_get_matched_style): make sure to set the fields of the style structure passed as an argument of the function, when its not NULL. * src/cr-style.c: (cr_style_set_props_to_defaults): make this function public
-rw-r--r--ChangeLog9
-rw-r--r--src/cr-cascade.h14
-rw-r--r--src/cr-om-parser.h81
-rw-r--r--src/cr-sel-eng.c9
-rw-r--r--src/cr-style.c191
-rw-r--r--src/cr-style.h21
6 files changed, 170 insertions, 155 deletions
diff --git a/ChangeLog b/ChangeLog
index 3ea3946..5a14e69 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,12 @@
+2004-01-29 Dodji Seketeli <dodji@gnome.org>
+
+ * src/cr-sel-eng.c:
+ (cr_sel_eng_get_matched_style): make sure to set the fields
+ of the style structure passed as an argument of the function, when
+ its not NULL.
+ * src/cr-style.c:
+ (cr_style_set_props_to_defaults): make this function public
+
2004-01-27 Gael CHAMOULAUD <strider@gnome.org>
* configure.in: Removed the old references with libgnomeui and pango !
diff --git a/src/cr-cascade.h b/src/cr-cascade.h
index a8c45d6..3119ae8 100644
--- a/src/cr-cascade.h
+++ b/src/cr-cascade.h
@@ -52,14 +52,12 @@ struct _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) ;
+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,
diff --git a/src/cr-om-parser.h b/src/cr-om-parser.h
index 0213c5d..13d35b1 100644
--- a/src/cr-om-parser.h
+++ b/src/cr-om-parser.h
@@ -55,50 +55,43 @@ struct _CROMParser
CROMParserPriv *priv ;
} ;
-CROMParser *
-cr_om_parser_new (CRInput *a_input) ;
-
-
-enum CRStatus
-cr_om_parser_simply_parse_file (const guchar *a_file_path,
- enum CREncoding a_enc,
- CRStyleSheet **a_result) ;
-
-enum CRStatus
-cr_om_parser_parse_file (CROMParser *a_this,
- const guchar *a_file_uri,
- enum CREncoding a_enc,
- CRStyleSheet **a_result) ;
-enum CRStatus
-cr_om_parser_simply_parse_buf (const guchar *a_buf,
- gulong a_len,
- enum CREncoding a_enc,
- CRStyleSheet **a_result) ;
-
-enum CRStatus
-cr_om_parser_parse_buf (CROMParser *a_this,
- const guchar *a_buf,
- gulong a_len,
- enum CREncoding a_enc,
- CRStyleSheet **a_result) ;
-
-enum CRStatus
-cr_om_parser_parse_paths_to_cascade (CROMParser *a_this,
- const guchar *a_author_path,
- const guchar *a_user_path,
- const guchar *a_ua_path,
- enum CREncoding a_encoding,
- CRCascade ** a_result) ;
-
-enum CRStatus
-cr_om_parser_simply_parse_paths_to_cascade (const guchar *a_author_path,
- const guchar *a_user_path,
- const guchar *a_ua_path,
- enum CREncoding a_encoding,
- CRCascade ** a_result) ;
-
-void
-cr_om_parser_destroy (CROMParser *a_this) ;
+CROMParser * cr_om_parser_new (CRInput *a_input) ;
+
+
+enum CRStatus cr_om_parser_simply_parse_file (const guchar *a_file_path,
+ enum CREncoding a_enc,
+ CRStyleSheet **a_result) ;
+
+enum CRStatus cr_om_parser_parse_file (CROMParser *a_this,
+ const guchar *a_file_uri,
+ enum CREncoding a_enc,
+ CRStyleSheet **a_result) ;
+
+enum CRStatus cr_om_parser_simply_parse_buf (const guchar *a_buf,
+ gulong a_len,
+ enum CREncoding a_enc,
+ CRStyleSheet **a_result) ;
+
+enum CRStatus cr_om_parser_parse_buf (CROMParser *a_this,
+ const guchar *a_buf,
+ gulong a_len,
+ enum CREncoding a_enc,
+ CRStyleSheet **a_result) ;
+
+enum CRStatus cr_om_parser_parse_paths_to_cascade (CROMParser *a_this,
+ const guchar *a_author_path,
+ const guchar *a_user_path,
+ const guchar *a_ua_path,
+ enum CREncoding a_encoding,
+ CRCascade ** a_result) ;
+
+enum CRStatus cr_om_parser_simply_parse_paths_to_cascade (const guchar *a_author_path,
+ const guchar *a_user_path,
+ const guchar *a_ua_path,
+ enum CREncoding a_encoding,
+ CRCascade ** a_result) ;
+
+void cr_om_parser_destroy (CROMParser *a_this) ;
G_END_DECLS
diff --git a/src/cr-sel-eng.c b/src/cr-sel-eng.c
index edec6b3..4153d61 100644
--- a/src/cr-sel-eng.c
+++ b/src/cr-sel-eng.c
@@ -1515,14 +1515,17 @@ cr_sel_eng_get_matched_style (CRSelEng *a_this,
*a_style = cr_style_new () ;
g_return_val_if_fail (*a_style, CR_ERROR) ;
}
+ else
+ {
+ cr_style_set_props_to_defaults (*a_style) ;
+ }
(*a_style)->parent_style = a_parent_style ;
-
+
g_hash_table_foreach (props_hash,
((GHFunc)
set_style_from_props_hash_hr_func),
- *a_style) ;
+ *a_style) ;
}
-
if (props_hash)
{
g_hash_table_destroy (props_hash) ;
diff --git a/src/cr-style.c b/src/cr-style.c
index 8059bcd..7533b3e 100644
--- a/src/cr-style.c
+++ b/src/cr-style.c
@@ -176,8 +176,6 @@ enum CRDirection
NB_DIRS
} ;
-static enum CRStatus
-cr_style_set_props_to_defaults (CRStyle *a_this) ;
static enum CRStatus
set_prop_padding_x_from_value (CRStyle *a_style,
@@ -283,90 +281,6 @@ cr_style_init_properties (void)
return CR_OK ;
}
-/**
- *Sets the style properties to their default values
- *according to the css2 spec.
- *@param a_this the current instance of #CRStyle.
- *@return CR_OK upon successfull completion, an error code otherwise.
- */
-static enum CRStatus
-cr_style_set_props_to_defaults (CRStyle *a_this)
-{
- glong i = 0 ;
-
- g_return_val_if_fail (a_this, CR_BAD_PARAM_ERROR) ;
-
- for (i = 0 ; i < NB_NUM_PROPS ; i++)
- {
- switch (i)
- {
- case NUM_PROP_WIDTH:
- case NUM_PROP_TOP:
- case NUM_PROP_RIGHT:
- case NUM_PROP_BOTTOM:
- case NUM_PROP_LEFT:
- cr_num_set (&a_this->num_props[i].sv,
- 0, NUM_AUTO) ;
- break ;
-
- case NUM_PROP_PADDING_TOP:
- case NUM_PROP_PADDING_RIGHT:
- case NUM_PROP_PADDING_BOTTOM:
- case NUM_PROP_PADDING_LEFT:
- case NUM_PROP_BORDER_TOP:
- case NUM_PROP_BORDER_RIGHT:
- case NUM_PROP_BORDER_BOTTOM:
- case NUM_PROP_BORDER_LEFT:
- case NUM_PROP_MARGIN_TOP:
- case NUM_PROP_MARGIN_RIGHT:
- case NUM_PROP_MARGIN_BOTTOM:
- case NUM_PROP_MARGIN_LEFT:
- cr_num_set (&a_this->num_props[i].sv,
- 0, NUM_LENGTH_PX) ;
- break ;
-
- default:
- cr_utils_trace_info ("Unknown property") ;
- break ;
- }
- }
-
- for (i = 0 ; i < NB_RGB_PROPS ; i++)
- {
-
- switch (i)
- {
- /*default foreground color is black*/
- case RGB_PROP_COLOR:
- cr_rgb_set (&a_this->rgb_props[i].sv, 0, 0, 0,
- FALSE) ;
- break ;
-
- /*default background color is white*/
- case RGB_PROP_BACKGROUND_COLOR:
- cr_rgb_set (&a_this->rgb_props[i].sv,
- 255, 255, 255, FALSE) ;
- break ;
-
- default:
- cr_rgb_set (&a_this->rgb_props[i].sv, 0, 0, 0,
- FALSE) ;
- break ;
- }
- }
-
- for (i = 0 ; i < NB_BORDER_STYLE_PROPS ; i++)
- {
- a_this->border_style_props[i] = BORDER_STYLE_NONE ;
- }
-
- a_this->display = DISPLAY_BLOCK ;
- a_this->position = POSITION_STATIC ;
- a_this->float_type = FLOAT_NONE ;
- a_this->parent_style = NULL ;
-
- return CR_OK ;
-}
static enum CRPropertyID
@@ -1853,6 +1767,91 @@ cr_style_new (void)
/**
+ *Sets the style properties to their default values
+ *according to the css2 spec.
+ *@param a_this the current instance of #CRStyle.
+ *@return CR_OK upon successfull completion, an error code otherwise.
+ */
+enum CRStatus
+cr_style_set_props_to_defaults (CRStyle *a_this)
+{
+ glong i = 0 ;
+
+ g_return_val_if_fail (a_this, CR_BAD_PARAM_ERROR) ;
+
+ for (i = 0 ; i < NB_NUM_PROPS ; i++)
+ {
+ switch (i)
+ {
+ case NUM_PROP_WIDTH:
+ case NUM_PROP_TOP:
+ case NUM_PROP_RIGHT:
+ case NUM_PROP_BOTTOM:
+ case NUM_PROP_LEFT:
+ cr_num_set (&a_this->num_props[i].sv,
+ 0, NUM_AUTO) ;
+ break ;
+
+ case NUM_PROP_PADDING_TOP:
+ case NUM_PROP_PADDING_RIGHT:
+ case NUM_PROP_PADDING_BOTTOM:
+ case NUM_PROP_PADDING_LEFT:
+ case NUM_PROP_BORDER_TOP:
+ case NUM_PROP_BORDER_RIGHT:
+ case NUM_PROP_BORDER_BOTTOM:
+ case NUM_PROP_BORDER_LEFT:
+ case NUM_PROP_MARGIN_TOP:
+ case NUM_PROP_MARGIN_RIGHT:
+ case NUM_PROP_MARGIN_BOTTOM:
+ case NUM_PROP_MARGIN_LEFT:
+ cr_num_set (&a_this->num_props[i].sv,
+ 0, NUM_LENGTH_PX) ;
+ break ;
+
+ default:
+ cr_utils_trace_info ("Unknown property") ;
+ break ;
+ }
+ }
+
+ for (i = 0 ; i < NB_RGB_PROPS ; i++)
+ {
+
+ switch (i)
+ {
+ /*default foreground color is black*/
+ case RGB_PROP_COLOR:
+ cr_rgb_set (&a_this->rgb_props[i].sv, 0, 0, 0,
+ FALSE) ;
+ break ;
+
+ /*default background color is white*/
+ case RGB_PROP_BACKGROUND_COLOR:
+ cr_rgb_set (&a_this->rgb_props[i].sv,
+ 255, 255, 255, FALSE) ;
+ break ;
+
+ default:
+ cr_rgb_set (&a_this->rgb_props[i].sv, 0, 0, 0,
+ FALSE) ;
+ break ;
+ }
+ }
+
+ for (i = 0 ; i < NB_BORDER_STYLE_PROPS ; i++)
+ {
+ a_this->border_style_props[i] = BORDER_STYLE_NONE ;
+ }
+
+ a_this->display = DISPLAY_BLOCK ;
+ a_this->position = POSITION_STATIC ;
+ a_this->float_type = FLOAT_NONE ;
+ a_this->parent_style = NULL ;
+
+ return CR_OK ;
+}
+
+/**
*Walks through a css2 property declaration, and populated the
*according field(s) in the #CRStyle structure.
*If the properties or their value(s) are/is not known,
@@ -2171,11 +2170,27 @@ cr_style_dup (CRStyle *a_this)
cr_utils_trace_info ("Out of memory") ;
return NULL ;
}
- memcpy (result, a_this, sizeof (CRStyle)) ;
-
+ cr_style_copy (result, a_this) ;
return result ;
}
+/**
+ *Copies a style data structure into another.
+ *TODO: this is actually broken because it's based
+ *on memcpy although some data stuctures of CRStyle should
+ *be properly duplicated.
+ *@param a_dest the destination style datastructure
+ *@param a_src the source style datastructure.
+ *@return CR_OK upon succesfull completion, an error code otherwise
+ */
+enum CRStatus
+cr_style_copy (CRStyle *a_dest, CRStyle *a_src)
+{
+ g_return_val_if_fail (a_dest && a_src, CR_BAD_PARAM_ERROR) ;
+
+ memcpy (a_dest, a_src, sizeof (CRStyle)) ;
+ return CR_OK ;
+}
/**
*Destructor of the #CRStyle class.
diff --git a/src/cr-style.h b/src/cr-style.h
index 2348c76..b0f9035 100644
--- a/src/cr-style.h
+++ b/src/cr-style.h
@@ -259,25 +259,22 @@ struct _CRStyle
} ;
-CRStyle *
-cr_style_new (void) ;
+CRStyle * cr_style_new (void) ;
+enum CRStatus cr_style_set_props_to_defaults (CRStyle *a_this) ;
-enum CRStatus
-cr_style_set_style_from_decl (CRStyle *a_this, CRDeclaration *a_decl) ;
+enum CRStatus cr_style_set_style_from_decl (CRStyle *a_this, CRDeclaration *a_decl) ;
-enum CRStatus
-cr_style_ref (CRStyle *a_this) ;
+enum CRStatus cr_style_copy (CRStyle *a_dest, CRStyle *a_src) ;
-gboolean
-cr_style_unref (CRStyle *a_this) ;
+enum CRStatus cr_style_ref (CRStyle *a_this) ;
-void
-cr_style_destroy (CRStyle *a_this) ;
+gboolean cr_style_unref (CRStyle *a_this) ;
-CRStyle *
-cr_style_dup (CRStyle *a_this) ;
+void cr_style_destroy (CRStyle *a_this) ;
+
+CRStyle * cr_style_dup (CRStyle *a_this) ;
G_END_DECLS