diff options
Diffstat (limited to 'src/cr-om-parser.c')
-rw-r--r-- | src/cr-om-parser.c | 130 |
1 files changed, 73 insertions, 57 deletions
diff --git a/src/cr-om-parser.c b/src/cr-om-parser.c index b8d70e3..a62e98d 100644 --- a/src/cr-om-parser.c +++ b/src/cr-om-parser.c @@ -25,10 +25,9 @@ #include "cr-utils.h" #include "cr-om-parser.h" -#define UNUSED(_param) ((void)(_param)) - /** - *@file + *@CROMParser: + * *The definition of the CSS Object Model Parser. *This parser uses (and sits) the SAC api of libcroco defined *in cr-parser.h and cr-doc-handler.h @@ -112,8 +111,9 @@ struct _ParsingContext { static ParsingContext * new_parsing_context (void) { - ParsingContext *result = - (ParsingContext *)g_try_malloc (sizeof (ParsingContext)); + ParsingContext *result = NULL; + + result = g_try_malloc (sizeof (ParsingContext)); if (!result) { cr_utils_trace_info ("Out of Memory"); return NULL; @@ -216,7 +216,7 @@ start_font_face (CRDocHandler * a_this, ParsingContext *ctxt = NULL; ParsingContext **ctxtptr = NULL; - UNUSED(a_location); + g_return_if_fail (a_this); g_return_if_fail (a_this); ctxtptr = &ctxt; @@ -315,8 +315,6 @@ charset (CRDocHandler * a_this, CRString * a_charset, ParsingContext *ctxt = NULL; ParsingContext **ctxtptr = NULL; - UNUSED(a_location); - g_return_if_fail (a_this); ctxtptr = &ctxt; status = cr_doc_handler_get_ctxt (a_this, (gpointer *) ctxtptr); @@ -351,8 +349,6 @@ start_page (CRDocHandler * a_this, ParsingContext *ctxt = NULL; ParsingContext **ctxtptr = NULL; - UNUSED(a_location); - g_return_if_fail (a_this); ctxtptr = &ctxt; status = cr_doc_handler_get_ctxt (a_this, (gpointer *) ctxtptr); @@ -430,8 +426,6 @@ start_media (CRDocHandler * a_this, ParsingContext **ctxtptr = NULL; GList *media_list = NULL; - UNUSED(a_location); - g_return_if_fail (a_this); ctxtptr = &ctxt; status = cr_doc_handler_get_ctxt (a_this, (gpointer *) ctxtptr); @@ -499,8 +493,6 @@ import_style (CRDocHandler * a_this, ParsingContext **ctxtptr = NULL; GList *media_list = NULL ; - UNUSED(a_location); - g_return_if_fail (a_this); ctxtptr = &ctxt; status = cr_doc_handler_get_ctxt (a_this, (gpointer *) ctxtptr); @@ -770,16 +762,19 @@ unrecoverable_error (CRDocHandler * a_this) ********************************************/ /** + * cr_om_parser_new: + *@a_input: the input stream. + * *Constructor of the CROMParser. - *@param a_input the input stream. - *@return the newly built instance of #CROMParser. + *Returns the newly built instance of #CROMParser. */ CROMParser * cr_om_parser_new (CRInput * a_input) { + CROMParser *result = NULL; enum CRStatus status = CR_OK; - CROMParser *result = (CROMParser *)g_try_malloc (sizeof (CROMParser)); + result = g_try_malloc (sizeof (CROMParser)); if (!result) { cr_utils_trace_info ("Out of memory"); @@ -787,7 +782,7 @@ cr_om_parser_new (CRInput * a_input) } memset (result, 0, sizeof (CROMParser)); - PRIVATE (result) = (CROMParserPriv *)g_try_malloc (sizeof (CROMParserPriv)); + PRIVATE (result) = g_try_malloc (sizeof (CROMParserPriv)); if (!PRIVATE (result)) { cr_utils_trace_info ("Out of memory"); @@ -821,13 +816,16 @@ cr_om_parser_new (CRInput * a_input) } /** + * cr_om_parser_parse_buf: + *@a_this: the current instance of #CROMParser. + *@a_buf: the in memory buffer to parse. + *@a_len: the length of the in memory buffer in number of bytes. + *@a_enc: the encoding of the in memory buffer. + *@a_result: out parameter the resulting style sheet + * *Parses the content of an in memory buffer. - *@param a_this the current instance of #CROMParser. - *@param a_buf the in memory buffer to parse. - *@param a_len the length of the in memory buffer in number of bytes. - *@param a_enc the encoding of the in memory buffer. - *@param a_result out parameter the resulting style sheet - *@return CR_OK upon successfull completion, an error code otherwise. + * + *Returns CR_OK upon successfull completion, an error code otherwise. */ enum CRStatus cr_om_parser_parse_buf (CROMParser * a_this, @@ -868,12 +866,15 @@ cr_om_parser_parse_buf (CROMParser * a_this, } /** + * cr_om_parser_simply_parse_buf: + *@a_buf: the css2 in memory buffer. + *@a_len: the length of the in memory buffer. + *@a_enc: the encoding of the in memory buffer. + *@a_result: out parameter. The resulting css2 style sheet. + * *The simpler way to parse an in memory css2 buffer. - *@param a_buf the css2 in memory buffer. - *@param a_len the length of the in memory buffer. - *@param a_enc the encoding of the in memory buffer. - *@param a_result out parameter. The resulting css2 style sheet. - *@return CR_OK upon successfull completion, an error code otherwise. + * + *Returns CR_OK upon successfull completion, an error code otherwise. */ enum CRStatus cr_om_parser_simply_parse_buf (const guchar * a_buf, @@ -903,16 +904,18 @@ cr_om_parser_simply_parse_buf (const guchar * a_buf, } /** - *Parses a css2 stylesheet contained - *in a file. - *@param a_this the current instance of the cssom parser. - *@param a_file_uri the uri of the file. + * cr_om_parser_parse_file: + *@a_this: the current instance of the cssom parser. + *@a_file_uri: the uri of the file. *(only local file paths are suppported so far) - *@param a_enc the encoding of the file. - *@param a_result out parameter. A pointer + *@a_enc: the encoding of the file. + *@a_result: out parameter. A pointer *the build css object model. - *@param CR_OK upon successfull completion, an error code - *otherwise. + * + *Parses a css2 stylesheet contained + *in a file. + * + * Returns CR_OK upon succesful completion, an error code otherwise. */ enum CRStatus cr_om_parser_parse_file (CROMParser * a_this, @@ -952,12 +955,15 @@ cr_om_parser_parse_file (CROMParser * a_this, } /** - *The simpler method to parse a css2 file. - *@param a_file_path the css2 local file path. - *@param a_enc the file encoding. - *@param a_result out parameter. The returned css stylesheet. + * cr_om_parser_simply_parse_file: + *@a_file_path: the css2 local file path. + *@a_enc: the file encoding. + *@a_result: out parameter. The returned css stylesheet. *Must be freed by the caller using cr_stylesheet_destroy. - *@return CR_OK upon successfull completion, an error code otherwise. + * + *The simpler method to parse a css2 file. + * + *Returns CR_OK upon successfull completion, an error code otherwise. *Note that this method uses cr_om_parser_parse_file() so both methods *have the same return values. */ @@ -987,14 +993,18 @@ cr_om_parser_simply_parse_file (const guchar * a_file_path, } /** - *Parses three sheets located by their paths and build a cascade - *@param a_this the current instance of #CROMParser - *@param a_author_path the path to the author stylesheet - *@param a_user_path the path to the user stylesheet - *@param a_ua_path the path to the User Agent stylesheet - *@param a_result out parameter. The resulting cascade if the parsing + * cr_om_parser_parse_paths_to_cascade: + *@a_this: the current instance of #CROMParser + *@a_author_path: the path to the author stylesheet + *@a_user_path: the path to the user stylesheet + *@a_ua_path: the path to the User Agent stylesheet + *@a_encoding: the encoding of the sheets. + *@a_result: out parameter. The resulting cascade if the parsing *was okay - *@return CR_OK upon successful completion, an error code otherwise + * + *Parses three sheets located by their paths and build a cascade + * + *Returns CR_OK upon successful completion, an error code otherwise */ enum CRStatus cr_om_parser_parse_paths_to_cascade (CROMParser * a_this, @@ -1014,7 +1024,7 @@ cr_om_parser_parse_paths_to_cascade (CROMParser * a_this, g_return_val_if_fail (a_this, CR_BAD_PARAM_ERROR); - memset (sheets, 0, sizeof (sheets)); + memset (sheets, 0, sizeof (CRStyleSheet*) * 3); paths[0] = (guchar *) a_author_path; paths[1] = (guchar *) a_user_path; paths[2] = (guchar *) a_ua_path; @@ -1043,13 +1053,17 @@ cr_om_parser_parse_paths_to_cascade (CROMParser * a_this, } /** - *Parses three sheets located by their paths and build a cascade - *@param a_author_path the path to the author stylesheet - *@param a_user_path the path to the user stylesheet - *@param a_ua_path the path to the User Agent stylesheet - *@param a_result out parameter. The resulting cascade if the parsing + * cr_om_parser_simply_parse_paths_to_cascade: + *@a_author_path: the path to the author stylesheet + *@a_user_path: the path to the user stylesheet + *@a_ua_path: the path to the User Agent stylesheet + *@a_encoding: the encoding of the sheets. + *@a_result: out parameter. The resulting cascade if the parsing *was okay - *@return CR_OK upon successful completion, an error code otherwise + * + *Parses three sheets located by their paths and build a cascade + * + *Returns CR_OK upon successful completion, an error code otherwise */ enum CRStatus cr_om_parser_simply_parse_paths_to_cascade (const guchar * a_author_path, @@ -1080,8 +1094,10 @@ cr_om_parser_simply_parse_paths_to_cascade (const guchar * a_author_path, } /** + * cr_om_parser_destroy: + *@a_this: the current instance of #CROMParser. + * *Destructor of the #CROMParser. - *@param a_this the current instance of #CROMParser. */ void cr_om_parser_destroy (CROMParser * a_this) |