diff options
author | Dodji Seketeli <dodji@gnome.org> | 2004-02-24 22:12:30 +0000 |
---|---|---|
committer | Dodji Seketeli <dodji@src.gnome.org> | 2004-02-24 22:12:30 +0000 |
commit | fd0c8b8631c68dec29e8438a63e2638ef97ddc32 (patch) | |
tree | c3c5409307e4333c59f587d80055cd5881b3e23d /src | |
parent | 06909a3577a9e2ef7b17b44bd894490b78cd3b68 (diff) | |
download | libcroco-fd0c8b8631c68dec29e8438a63e2638ef97ddc32.tar.gz |
added the support of vendor specific property names.
2004-02-24 Dodji Seketeli <dodji@gnome.org>
* src/cr-parser.c,src/cr-tknzr.c,src/cr-token.[ch]:
added the support of
vendor specific property names.
Diffstat (limited to 'src')
-rw-r--r-- | src/cr-parser.c | 36 | ||||
-rw-r--r-- | src/cr-tknzr.c | 88 | ||||
-rw-r--r-- | src/cr-token.c | 13 | ||||
-rw-r--r-- | src/cr-token.h | 6 |
4 files changed, 137 insertions, 6 deletions
diff --git a/src/cr-parser.c b/src/cr-parser.c index 71df4c0..55bf6ea 100644 --- a/src/cr-parser.c +++ b/src/cr-parser.c @@ -388,6 +388,9 @@ static enum CRStatus cr_parser_parse_ident (CRParser *a_this, GString **a_str) ; static enum CRStatus +cr_parser_parse_vendor_specific_ident (CRParser *a_this, GString **a_str) ; + +static enum CRStatus cr_parser_parse_uri (CRParser *a_this, GString **a_str) ; static enum CRStatus @@ -1990,7 +1993,9 @@ cr_parser_parse_property (CRParser *a_this, GString **a_property) RECORD_INITIAL_POS (a_this, &init_pos) ; status = cr_parser_parse_ident (a_this, a_property) ; - + if (status != CR_OK) + status = cr_parser_parse_vendor_specific_ident + (a_this, a_property) ; CHECK_PARSING_STATUS (status, TRUE) ; cr_parser_try_to_skip_spaces_and_comments (a_this) ; @@ -2846,6 +2851,35 @@ cr_parser_parse_ident (CRParser *a_this, GString **a_str) } /** + *Parses a "vendor-specific-ident" as not defined in the CSS2 spec. + *It's only a dash followed by an identifier. + * + *@param a_this the currens instance of #CRParser. + * + *@param a_str a pointer to parsed ident. If *a_str is NULL, + *this function allocates a new instance of GString. If not, + *the function just appends the parsed string to the one passed. + *In both cases it is up to the caller to free *a_str. + * + *@return CR_OK upon successfull completion, an error code + *otherwise. + */ +static enum CRStatus +cr_parser_parse_vendor_specific_ident (CRParser *a_this, GString **a_str) +{ + enum CRStatus status = CR_OK ; + + g_return_val_if_fail (a_this && PRIVATE (a_this) + && PRIVATE (a_this)->tknzr + && a_str, + CR_BAD_PARAM_ERROR) ; + + status = cr_tknzr_parse_token (PRIVATE (a_this)->tknzr, + VENDOR_SPECIFIC_IDENT_TK, NO_ET, a_str, NULL) ; + return status ; +} + +/** *Parses a stylesheet as defined in the css2 spec in appendix D.1: *stylesheet ::= [ CHARSET_SYM S* STRING S* ';' ]? * [S|CDO|CDC]* [ import [S|CDO|CDC]* ]* diff --git a/src/cr-tknzr.c b/src/cr-tknzr.c index 4315460..830f35e 100644 --- a/src/cr-tknzr.c +++ b/src/cr-tknzr.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 * 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 the COPYRIGHTS file for copyrights information. */ /* @@ -1042,6 +1042,74 @@ cr_tknzr_parse_ident (CRTknzr *a_this, GString **a_str) } /** + *Parses a "vendor-specific-ident". This is only a dash followed + *by a an identifier. This is not specified by the CSS2 spec but + *is heavily used by a lot of user agents. + *@param a_this the currens instance of #CRTknzr. + * + *@param a_str a pointer to parsed ident. If *a_str is NULL, + *this function allocates a new instance of GString. If not, + *the function just appends the parsed string to the one passed. + *In both cases it is up to the caller to free *a_str. + * + *@return CR_OK upon successfull completion, an error code + *otherwise. + */ +static enum CRStatus +cr_tknzr_parse_vendor_specific_ident (CRTknzr *a_this, + GString **a_str) +{ + guint32 tmp_char = 0 ; + CRInputPos init_pos ; + enum CRStatus status = CR_OK ; + + g_return_val_if_fail (a_this && PRIVATE (a_this) + && PRIVATE (a_this)->input + && a_str, + CR_BAD_PARAM_ERROR) ; + + RECORD_INITIAL_POS (a_this, &init_pos) ; + + if (BYTE (PRIVATE (a_this)->input, 1, NULL) == '-') + { + SKIP_BYTES (a_this, 1) ; + } + else + { + return CR_PARSING_ERROR ; + } + + status = cr_tknzr_parse_nmstart (a_this, &tmp_char) ; + if (status != CR_OK) + { + status = CR_PARSING_ERROR ; + goto error ; + } + if (*a_str == NULL) + { + *a_str = g_string_new (NULL) ; + } + g_string_append_c (*a_str, '-') ; + g_string_append_unichar (*a_str, tmp_char) ; + + for (;;) + { + status = + cr_tknzr_parse_nmchar (a_this, &tmp_char); + + if (status != CR_OK) break ; + + g_string_append_unichar (*a_str, tmp_char) ; + } + + return CR_OK ; + + error: + cr_tknzr_set_cur_pos (a_this, &init_pos) ; + return status ; +} + +/** *Parses a "name" as defined by css spec [4.1.1]: *name ::= {nmchar}+ * @@ -2298,7 +2366,18 @@ cr_tknzr_get_next_token (CRTknzr *a_this, CRToken **a_tk) CHECK_PARSING_STATUS (status, TRUE) ; goto done ; } - + else + { + status = cr_tknzr_parse_vendor_specific_ident + (a_this, &str) ; + if (status == CR_OK) + { + cr_token_set_vendor_specific_ident + (token, str) ; + goto done ; + } + } + break ; case '~': if (BYTE (input, 2, NULL) == '=') { @@ -2697,7 +2776,7 @@ cr_tknzr_get_next_token (CRTknzr *a_this, CRToken **a_tk) str = NULL ; } cr_tknzr_set_cur_pos (a_this, - &init_pos) ; + &init_pos) ; return status ; } @@ -2741,6 +2820,7 @@ cr_tknzr_parse_token (CRTknzr *a_this, enum CRTokenType a_type, case STRING_TK: case IDENT_TK: + case VENDOR_SPECIFIC_IDENT_TK: case HASH_TK: case ATKEYWORD_TK: case FUNCTION_TK: diff --git a/src/cr-token.c b/src/cr-token.c index 8ade6be..1ce78dc 100644 --- a/src/cr-token.c +++ b/src/cr-token.c @@ -63,6 +63,7 @@ cr_token_clear (CRToken *a_this) case URI_TK: case FUNCTION_TK: case COMMENT_TK: + case VENDOR_SPECIFIC_IDENT_TK: if (a_this->u.str) { g_string_free (a_this->u.str, TRUE) ; @@ -283,6 +284,18 @@ cr_token_set_ident (CRToken *a_this, GString * a_ident) return CR_OK ; } +enum CRStatus +cr_token_set_vendor_specific_ident (CRToken *a_this, GString * a_ident) +{ + g_return_val_if_fail (a_this, CR_BAD_PARAM_ERROR) ; + + cr_token_clear (a_this) ; + + a_this->type = VENDOR_SPECIFIC_IDENT_TK ; + + a_this->u.str = a_ident ; + return CR_OK ; +} enum CRStatus cr_token_set_function (CRToken *a_this, GString *a_fun_name) diff --git a/src/cr-token.h b/src/cr-token.h index 23aac22..b5ef024 100644 --- a/src/cr-token.h +++ b/src/cr-token.h @@ -74,6 +74,7 @@ enum CRTokenType BO_TK, /*opening bracket*/ BC_TK, /*closing bracket*/ DELIM_TK, + VENDOR_SPECIFIC_IDENT_TK, } ; enum CRTokenExtraType @@ -142,7 +143,10 @@ cr_token_set_string (CRToken *a_this, GString *a_str) ; enum CRStatus cr_token_set_ident (CRToken *a_this, GString * a_ident) ; - + +enum CRStatus +cr_token_set_vendor_specific_ident (CRToken *a_this, GString * a_ident) ; + enum CRStatus cr_token_set_hash (CRToken *a_this, GString *a_hash) ; |