diff options
author | Dodji Seketeli <dodji@gnome.org> | 2004-02-29 11:54:43 +0000 |
---|---|---|
committer | Dodji Seketeli <dodji@src.gnome.org> | 2004-02-29 11:54:43 +0000 |
commit | 6a2cb75412be707fd68b20399e2e1376b10b9f33 (patch) | |
tree | 5bea8663419646af5f3dd7f1aa734c74baa4b4f6 | |
parent | 3ead86bfa0d3c7dd5749649a3ba805a944b33689 (diff) | |
download | libcroco-6a2cb75412be707fd68b20399e2e1376b10b9f33.tar.gz |
applied a patch from Rob BUIS that provides new apis to manipulate CSS
2004-02-29 Dodji Seketeli <dodji@gnome.org>
* src/cr-statement.[ch],src/cr-stylesheet.[ch]:
applied a patch from Rob BUIS that provides new apis
to manipulate CSS statements.
-rw-r--r-- | ChangeLog | 6 | ||||
-rw-r--r-- | src/cr-statement.c | 73 | ||||
-rw-r--r-- | src/cr-statement.h | 12 | ||||
-rw-r--r-- | src/cr-stylesheet.c | 28 | ||||
-rw-r--r-- | src/cr-stylesheet.h | 6 |
5 files changed, 125 insertions, 0 deletions
@@ -1,5 +1,11 @@ 2004-02-29 Dodji Seketeli <dodji@gnome.org> + * src/cr-statement.[ch],src/cr-stylesheet.[ch]: + applied a patch from Rob BUIS that provides new apis + to manipulate CSS statements. + +2004-02-29 Dodji Seketeli <dodji@gnome.org> + * src/cr-sel-eng.c: (put_css_properties_in_props_list): fixed a small bug in here: Always Initialise output function argument !!!. diff --git a/src/cr-statement.c b/src/cr-statement.c index b675826..b8ff481 100644 --- a/src/cr-statement.c +++ b/src/cr-statement.c @@ -753,6 +753,45 @@ cr_statement_dump_page (CRStatement *a_this, FILE *a_fp, gulong a_indent) } /** + *Return the number of rules in the statement list; + *@param a_this the current instance of #CRStatement. + *@return number of rules in the statement list. + */ +int +cr_statement_nr_rules (CRStatement *a_this) +{ + CRStatement *cur = NULL ; + int nr = 0; + + g_return_val_if_fail (a_this, -1) ; + + for (cur = a_this ; cur ; cur = cur->next) + nr ++; + return nr; +} + +/** + *Use an index to get a CRStatement from the statement list. + *@param a_this the current instance of #CRStatement. + *@param itemnr the index into the statement list. + *@return CRStatement at position itemnr, if itemnr > number of statements - 1, + *it will return NULL. + */ +CRStatement * +cr_statement_get_from_list (CRStatement *a_this, int itemnr) +{ + CRStatement *cur = NULL ; + int nr = 0; + + g_return_val_if_fail (a_this, NULL) ; + + for (cur = a_this ; cur ; cur = cur->next) + if (nr++ == itemnr) + return cur; + return NULL; +} + +/** *Dumps an @media rule statement to a file. *@param a_this the statement to dump. *@param a_fp the destination file pointer @@ -2108,6 +2147,40 @@ cr_statement_at_import_rule_get_url (CRStatement *a_this, } /** + *Return the number of rules in the media rule; + *@param a_this the current instance of #CRStatement. + *@return number of rules in the media rule. + */ +int +cr_statement_at_media_nr_rules (CRStatement *a_this) +{ + g_return_val_if_fail (a_this + && a_this->type == AT_MEDIA_RULE_STMT + && a_this->kind.media_rule, + CR_BAD_PARAM_ERROR) ; + + return cr_statement_nr_rules (a_this->kind.media_rule->rulesets); +} + +/** + *Use an index to get a CRStatement from the media rule list of rules. + *@param a_this the current instance of #CRStatement. + *@param itemnr the index into the media rule list of rules. + *@return CRStatement at position itemnr, if itemnr > number of rules - 1, + *it will return NULL. + */ +CRStatement * +cr_statement_at_media_get_from_list (CRStatement *a_this, int itemnr) +{ + g_return_val_if_fail (a_this + && a_this->type == AT_MEDIA_RULE_STMT + && a_this->kind.media_rule, + NULL) ; + + return cr_statement_get_from_list (a_this->kind.media_rule->rulesets, itemnr); +} + +/** *Sets a declaration list to the current @page rule statement. *@param a_this the current @page rule statement. *@param a_decl_list the declaration list to add. Will be freed diff --git a/src/cr-statement.h b/src/cr-statement.h index b052c26..78a38b4 100644 --- a/src/cr-statement.h +++ b/src/cr-statement.h @@ -350,6 +350,12 @@ enum CRStatus cr_statement_at_import_rule_get_url (CRStatement *a_this, GString **a_url) ; +int +cr_statement_at_media_nr_rules (CRStatement *a_this) ; + +CRStatement * +cr_statement_at_media_get_from_list (CRStatement *a_this, int itemnr) ; + enum CRStatus cr_statement_at_page_rule_set_sel (CRStatement *a_this, CRSelector *a_sel) ; @@ -390,6 +396,12 @@ cr_statement_at_font_face_rule_add_decl (CRStatement *a_this, void cr_statement_dump (CRStatement *a_this, FILE *a_fp, gulong a_indent) ; +int +cr_statement_nr_rules (CRStatement *a_this) ; + +CRStatement * +cr_statement_get_from_list (CRStatement *a_this, int itemnr) ; + void cr_statement_destroy (CRStatement *a_this) ; diff --git a/src/cr-stylesheet.c b/src/cr-stylesheet.c index 06b1c5f..a1b8b01 100644 --- a/src/cr-stylesheet.c +++ b/src/cr-stylesheet.c @@ -78,6 +78,34 @@ cr_stylesheet_dump (CRStyleSheet *a_this, FILE *a_fp) } } +/** + *Return the number of rules in the stylesheet. + *@param a_this the current instance of #CRStyleSheet. + *@return number of rules in the stylesheet. + */ +int +cr_stylesheets_nr_rules (CRStyleSheet *a_this) +{ + g_return_val_if_fail (a_this, -1) ; + + return cr_statement_nr_rules (a_this->statements); +} + +/** + *Use an index to get a CRStatement from the rules in a given stylesheet. + *@param a_this the current instance of #CRStatement. + *@param itemnr the index into the rules. + *@return CRStatement at position itemnr, if itemnr > number of rules - 1, + *it will return NULL. + */ +CRStatement * +cr_stylesheet_statement_get_from_list (CRStyleSheet *a_this, int itemnr) +{ + g_return_val_if_fail (a_this, NULL) ; + + return cr_statement_get_from_list (a_this->statements, itemnr); +} + void cr_stylesheet_ref (CRStyleSheet *a_this) { diff --git a/src/cr-stylesheet.h b/src/cr-stylesheet.h index c850e6e..6ea3ab0 100644 --- a/src/cr-stylesheet.h +++ b/src/cr-stylesheet.h @@ -91,6 +91,12 @@ cr_stylesheet_new (CRStatement *a_stmts) ; void cr_stylesheet_dump (CRStyleSheet *a_this, FILE *a_fp) ; +int +cr_stylesheet_nr_rules (CRStyleSheet *a_this) ; + +CRStatement * +cr_stylesheet_statement_get_from_list (CRStyleSheet *a_this, int itemnr) ; + void cr_stylesheet_ref (CRStyleSheet *a_this) ; |