Main Page | Alphabetical List | Data Structures | File List | Data Fields | Globals | Related Pages

cr-statement.h

Go to the documentation of this file.
00001 /* -*- Mode: C; indent-tabs-mode: nil; c-basic-offset: 8 -*- */
00002 
00003 /*
00004  * This file is part of The Croco Library
00005  *
00006  * This program is free software; you can redistribute it and/or
00007  * modify it under the terms of version 2.1 of the GNU Lesser General Public
00008  * License as published by the Free Software Foundation.
00009  *
00010  * This program is distributed in the hope that it will be useful,
00011  * but WITHOUT ANY WARRANTY; without even the implied warranty of
00012  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
00013  * GNU General Public License for more details.
00014  *
00015  * You should have received a copy of the GNU Lesser General Public License
00016  * along with this program; if not, write to the Free Software
00017  * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307
00018  * USA
00019  * 
00020  * See COPYRIGHTS file for copyright information.
00021  */
00022 
00023 /*
00024  *$Id: cr-statement.h,v 1.8 2004/03/06 19:04:47 dodji Exp $
00025  */
00026 
00027 #include <stdio.h>
00028 #include "cr-utils.h"
00029 #include "cr-term.h"
00030 #include "cr-selector.h"
00031 #include "cr-declaration.h"
00032 
00033 #ifndef __CR_STATEMENT_H__
00034 #define __CR_STATEMENT_H__
00035 
00036 G_BEGIN_DECLS
00037 
00038 /**
00039  *@file
00040  *Declaration of the #CRStatement class.
00041  */
00042 
00043 /*
00044  *forward declaration of CRStyleSheet which is defined in
00045  *cr-stylesheet.h
00046  */
00047 
00048 struct _CRStatement ;
00049 
00050 /*
00051  *typedef struct _CRStatement CRStatement ; 
00052  *this is forward declared in 
00053  *cr-declaration.h already.
00054  */
00055 
00056 struct _CRAtMediaRule ;
00057 typedef struct _CRAtMediaRule CRAtMediaRule ;
00058 
00059 typedef struct _CRRuleSet CRRuleSet ;
00060 
00061 /**
00062  *The abstraction of a css ruleset.
00063  *A ruleset is made of a list of selectors,
00064  *followed by a list of declarations.
00065  */
00066 struct _CRRuleSet
00067 {
00068         /**A list of instances of #CRSimpeSel*/
00069         CRSelector *sel_list ;
00070 
00071         /**A list of instances of #CRDeclaration*/
00072         CRDeclaration *decl_list ;
00073         
00074         /**
00075          *The parent media rule, or NULL if
00076          *no parent media rule exists.
00077          */
00078         CRStatement *parent_media_rule ;
00079 } ;
00080 
00081 /*
00082  *a forward declaration of CRStylesheet.
00083  *CRStylesheet is actually declared in
00084  *cr-stylesheet.h
00085  */
00086 struct _CRStyleSheet ;
00087 typedef struct _CRStyleSheet CRStyleSheet;
00088 
00089 
00090 /**The @import rule abstraction.*/
00091 typedef struct _CRAtImportRule CRAtImportRule ;
00092 struct _CRAtImportRule
00093 {
00094         /**the url of the import rule*/
00095         GString *url ;
00096 
00097         GList *media_list ;
00098 
00099         /**
00100          *the stylesheet fetched from the url, if any.
00101          *this is not "owned" by #CRAtImportRule which means
00102          *it is not destroyed by the destructor of #CRAtImportRule.
00103          */
00104         CRStyleSheet * sheet;
00105 };
00106 
00107 
00108 /**abstraction of an @media rule*/
00109 struct _CRAtMediaRule
00110 {
00111         GList *media_list ;
00112         CRStatement *rulesets ; 
00113 } ;
00114 
00115 
00116 typedef struct _CRAtPageRule CRAtPageRule ;
00117 /**The @page rule abstraction*/
00118 struct _CRAtPageRule
00119 {
00120         /**a list of instances of #CRDeclaration*/
00121         CRDeclaration *decl_list ;
00122 
00123         /**page selector. Is a pseudo selector*/
00124         GString *name ;
00125         GString *pseudo ;
00126 } ;
00127 
00128 /**The @charset rule abstraction*/
00129 typedef struct _CRAtCharsetRule CRAtCharsetRule ;
00130 struct _CRAtCharsetRule
00131 {
00132         GString * charset ;
00133 };
00134 
00135 /**The abstaction of the @font-face rule.*/
00136 typedef struct _CRAtFontFaceRule CRAtFontFaceRule ;
00137 struct _CRAtFontFaceRule
00138 {
00139         /*a list of instanaces of #CRDeclaration*/
00140         CRDeclaration *decl_list ;
00141 } ;
00142 
00143 
00144 /**
00145  *The possible types of css2 statements.
00146  */
00147 enum CRStatementType
00148 {
00149         /**
00150          *A generic css at-rule
00151          *each unknown at-rule will
00152          *be of this type.
00153          */
00154 
00155         /**A css at-rule*/
00156         AT_RULE_STMT = 0,
00157 
00158         /*A css ruleset*/
00159         RULESET_STMT,
00160 
00161         /**A css2 import rule*/
00162         AT_IMPORT_RULE_STMT,
00163 
00164         /**A css2 media rule*/
00165         AT_MEDIA_RULE_STMT,
00166 
00167         /**A css2 page rule*/
00168         AT_PAGE_RULE_STMT,
00169 
00170         /**A css2 charset rule*/
00171         AT_CHARSET_RULE_STMT,
00172 
00173         /**A css2 font face rule*/
00174         AT_FONT_FACE_RULE_STMT
00175 } ;
00176 
00177 
00178 /**
00179  *The abstraction of css statement as defined
00180  *in the chapter 4 and appendix D.1 of the css2 spec.
00181  *A statement is actually a double chained list of
00182  *statements.A statement can be a ruleset, an @import
00183  *rule, an @page rule etc ...
00184  */
00185 struct _CRStatement
00186 {
00187         /**
00188          *The type of the statement.
00189          */
00190         enum CRStatementType type ;
00191 
00192         union
00193         {
00194                 CRRuleSet *ruleset ;
00195                 CRAtImportRule *import_rule ;
00196                 CRAtMediaRule *media_rule ;
00197                 CRAtPageRule *page_rule ;
00198                 CRAtCharsetRule *charset_rule ;
00199                 CRAtFontFaceRule *font_face_rule ;
00200         } kind ;
00201 
00202         /*
00203          *the specificity of the selector
00204          *that matched this statement.
00205          *This is only used by the cascading
00206          *order determination algorithm.
00207          */
00208         gulong specificity ;
00209 
00210         /*
00211          *the style sheet that contains
00212          *this css statement.
00213          */
00214         CRStyleSheet *parent_sheet ;
00215         CRStatement *next ;
00216         CRStatement *prev ;
00217 
00218         /**
00219          *a custom pointer useable by
00220          *applications that use libcroco.
00221          *libcroco itself will never modify
00222          *this pointer.
00223          */        
00224         gpointer app_data ;
00225 
00226         /**
00227          *a custom pointer used
00228          *by the upper layers of libcroco.
00229          *application should never use this
00230          *pointer.
00231          */
00232         gpointer croco_data ;
00233 
00234 } ;
00235 
00236 
00237 gboolean
00238 cr_statement_does_buf_parses_against_core (const guchar *a_buf,
00239                                            enum CREncoding a_encoding) ;
00240 CRStatement *
00241 cr_statement_parse_from_buf (const guchar *a_buf,
00242                              enum CREncoding a_encoding) ;
00243 CRStatement*
00244 cr_statement_new_ruleset (CRStyleSheet *a_sheet,
00245                           CRSelector *a_sel_list, 
00246                           CRDeclaration *a_decl_list,
00247                           CRStatement *a_media_rule) ;
00248 CRStatement *
00249 cr_statement_ruleset_parse_from_buf (const guchar * a_buf,
00250                                      enum CREncoding a_enc) ;
00251 
00252 CRStatement*
00253 cr_statement_new_at_import_rule (CRStyleSheet *a_container_sheet,
00254                                  GString *a_url,
00255                                  GList *a_media_list,
00256                                  CRStyleSheet *a_imported_sheet) ;
00257 
00258 CRStatement *
00259 cr_statement_at_import_rule_parse_from_buf (const guchar * a_buf,
00260                                             enum CREncoding a_encoding) ;
00261 
00262 CRStatement *
00263 cr_statement_new_at_media_rule (CRStyleSheet *a_sheet,
00264                                 CRStatement *a_ruleset,
00265                                 GList *a_media) ;
00266 CRStatement *
00267 cr_statement_at_media_rule_parse_from_buf (const guchar *a_buf,
00268                                            enum CREncoding a_enc) ;
00269 
00270 CRStatement *
00271 cr_statement_new_at_charset_rule (CRStyleSheet *a_sheet,
00272                                   GString *a_charset) ;
00273 CRStatement *
00274 cr_statement_at_charset_rule_parse_from_buf (const guchar *a_buf,
00275                                              enum CREncoding a_encoding);
00276 
00277 
00278 CRStatement *
00279 cr_statement_new_at_font_face_rule (CRStyleSheet *a_sheet,
00280                                     CRDeclaration *a_font_decls) ;
00281 CRStatement *
00282 cr_statement_font_face_rule_parse_from_buf (const guchar *a_buf,
00283                                             enum CREncoding a_encoding) ;
00284 
00285 CRStatement *
00286 cr_statement_new_at_page_rule (CRStyleSheet *a_sheet,
00287                                CRDeclaration *a_decl_list,
00288                                GString *a_name,
00289                                GString *a_pseudo) ;
00290 CRStatement *
00291 cr_statement_at_page_rule_parse_from_buf (const guchar *a_buf,
00292                                           enum CREncoding a_encoding)  ;
00293 
00294 enum CRStatus
00295 cr_statement_set_parent_sheet (CRStatement *a_this, 
00296                                CRStyleSheet *a_sheet) ;
00297 
00298 enum CRStatus
00299 cr_statement_get_parent_sheet (CRStatement *a_this, 
00300                                CRStyleSheet **a_sheet) ;
00301 
00302 CRStatement *
00303 cr_statement_append (CRStatement *a_this,
00304                      CRStatement *a_new) ;
00305 
00306 CRStatement*
00307 cr_statement_prepend (CRStatement *a_this,
00308                       CRStatement *a_new) ;
00309 
00310 CRStatement *
00311 cr_statement_unlink (CRStatement *a_stmt) ;
00312 
00313 enum CRStatus
00314 cr_statement_ruleset_set_sel_list (CRStatement *a_this,
00315                                    CRSelector *a_sel_list) ;
00316 
00317 enum CRStatus
00318 cr_statement_ruleset_get_sel_list (CRStatement *a_this,
00319                                    CRSelector **a_list) ;
00320 
00321 enum CRStatus
00322 cr_statement_ruleset_set_decl_list (CRStatement *a_this,
00323                                     CRDeclaration *a_list) ;
00324 
00325 enum CRStatus
00326 cr_statement_ruleset_get_declarations (CRStatement *a_this,
00327                                        CRDeclaration **a_decl_list) ;
00328 
00329 enum CRStatus
00330 cr_statement_ruleset_append_decl2 (CRStatement *a_this,
00331                                    GString *a_prop, CRTerm *a_value) ;
00332 
00333 enum CRStatus
00334 cr_statement_ruleset_append_decl (CRStatement *a_this,
00335                                   CRDeclaration *a_decl) ;
00336 
00337 enum CRStatus
00338 cr_statement_at_import_rule_set_imported_sheet (CRStatement *a_this,
00339                                                 CRStyleSheet *a_sheet) ;
00340 
00341 enum CRStatus
00342 cr_statement_at_import_rule_get_imported_sheet (CRStatement *a_this,
00343                                                 CRStyleSheet **a_sheet) ;
00344 
00345 enum CRStatus
00346 cr_statement_at_import_rule_set_url (CRStatement *a_this,
00347                                      GString *a_url) ;
00348 
00349 enum CRStatus
00350 cr_statement_at_import_rule_get_url (CRStatement *a_this,
00351                                      GString **a_url) ;
00352 
00353 gint
00354 cr_statement_at_media_nr_rules (CRStatement *a_this) ;
00355 
00356 CRStatement *
00357 cr_statement_at_media_get_from_list (CRStatement *a_this, int itemnr) ;
00358 
00359 enum CRStatus
00360 cr_statement_at_page_rule_set_sel (CRStatement *a_this,
00361                                    CRSelector *a_sel) ;
00362 
00363 enum CRStatus
00364 cr_statement_at_page_rule_get_sel (CRStatement *a_this,
00365                                    CRSelector **a_sel) ;
00366 
00367 enum CRStatus
00368 cr_statement_at_page_rule_set_declarations (CRStatement *a_this,
00369                                             CRDeclaration *a_decl_list) ;
00370 
00371 enum CRStatus
00372 cr_statement_at_page_rule_get_declarations (CRStatement *a_this,
00373                                             CRDeclaration **a_decl_list) ;
00374 
00375 enum CRStatus
00376 cr_statement_at_charset_rule_set_charset (CRStatement *a_this,
00377                                           GString *a_charset) ;
00378 
00379 enum CRStatus
00380 cr_statement_at_charset_rule_get_charset (CRStatement *a_this,
00381                                           GString **a_charset) ;
00382 
00383 enum CRStatus
00384 cr_statement_at_font_face_rule_set_decls (CRStatement *a_this,
00385                                           CRDeclaration *a_decls) ;
00386 
00387 enum CRStatus
00388 cr_statement_at_font_face_rule_get_decls (CRStatement *a_this,
00389                                           CRDeclaration **a_decls) ;
00390 
00391 enum CRStatus
00392 cr_statement_at_font_face_rule_add_decl (CRStatement *a_this,
00393                                          GString *a_prop,
00394                                          CRTerm *a_value) ;
00395 
00396 gchar *
00397 cr_statement_to_string (CRStatement * a_this, gulong a_indent) ;
00398 
00399 void
00400 cr_statement_dump (CRStatement *a_this, FILE *a_fp, gulong a_indent) ;
00401 
00402 void
00403 cr_statement_dump_ruleset (CRStatement * a_this, FILE * a_fp, 
00404                            glong a_indent) ;
00405 
00406 void
00407 cr_statement_dump_font_face_rule (CRStatement * a_this, 
00408                                   FILE * a_fp,
00409                                   glong a_indent) ;
00410 
00411 void
00412 cr_statement_dump_page (CRStatement * a_this, FILE * a_fp, 
00413                         gulong a_indent) ;
00414 
00415 
00416 void
00417 cr_statement_dump_media_rule (CRStatement * a_this, 
00418                               FILE * a_fp,
00419                               gulong a_indent) ;
00420 
00421 void
00422 cr_statement_dump_import_rule (CRStatement * a_this, FILE * a_fp,
00423                                gulong a_indent) ; 
00424 void
00425 cr_statement_dump_charset (CRStatement * a_this, FILE * a_fp, 
00426                            gulong a_indent) ;
00427 gint
00428 cr_statement_nr_rules (CRStatement *a_this) ;
00429 
00430 CRStatement *
00431 cr_statement_get_from_list (CRStatement *a_this, int itemnr) ;
00432 
00433 void
00434 cr_statement_destroy (CRStatement *a_this) ;
00435 
00436 G_END_DECLS
00437 
00438 #endif /*__CR_STATEMENT_H__*/

Generated on Sat Mar 20 02:38:44 2004 for Libcroco by doxygen 1.3.5