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  * Copyright (C) 2002-2003 Dodji Seketeli <dodji@seketeli.org>
00007  *
00008  * This program is free software; you can redistribute it and/or
00009  * modify it under the terms of version 2.1 of the GNU Lesser General Public
00010  * License as published by the Free Software Foundation.
00011  *
00012  * This program is distributed in the hope that it will be useful,
00013  * but WITHOUT ANY WARRANTY; without even the implied warranty of
00014  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
00015  * GNU General Public License for more details.
00016  *
00017  * You should have received a copy of the GNU Lesser General Public License
00018  * along with this program; if not, write to the Free Software
00019  * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307
00020  * USA
00021  */
00022 
00023 /*
00024  *$Id: cr-statement.h,v 1.12 2003/06/21 12:04:53 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         AT_RULE_STMT = 0,
00155 
00156         /**A css at-rule*/
00157         RULESET_STMT,
00158 
00159         /**A css2 import rule*/
00160         AT_IMPORT_RULE_STMT,
00161 
00162         /**A css2 media rule*/
00163         AT_MEDIA_RULE_STMT,
00164 
00165         /**A css2 page rule*/
00166         AT_PAGE_RULE_STMT,
00167 
00168         /**A css2 charset rule*/
00169         AT_CHARSET_RULE_STMT,
00170 
00171         /**A css2 font face rule*/
00172         AT_FONT_FACE_RULE_STMT
00173 } ;
00174 
00175 
00176 /**
00177  *The abstraction of css statement as defined
00178  *in the chapter 4 and appendix D.1 of the css2 spec.
00179  *A statement is actually a double chained list of
00180  *statements.A statement can be a ruleset, an @import
00181  *rule, an @page rule etc ...
00182  */
00183 struct _CRStatement
00184 {
00185         /**
00186          *The type of the statement.
00187          */
00188         enum CRStatementType type ;
00189 
00190         union
00191         {
00192                 CRRuleSet *ruleset ;
00193                 CRAtImportRule *import_rule ;
00194                 CRAtMediaRule *media_rule ;
00195                 CRAtPageRule *page_rule ;
00196                 CRAtCharsetRule *charset_rule ;
00197                 CRAtFontFaceRule *font_face_rule ;
00198         } kind ;
00199 
00200         /*
00201          *the specificity of the selector
00202          *that matched this statement.
00203          *This is only used by the cascading
00204          *order determination algorithm.
00205          */
00206         gulong specificity ;
00207 
00208         /*
00209          *the style sheet that contains
00210          *this css statement.
00211          */
00212         CRStyleSheet *parent_sheet ;
00213         CRStatement *next ;
00214         CRStatement *prev ;
00215 
00216         /**
00217          *a custom pointer useable by
00218          *applications that use libcroco.
00219          *libcroco itself will never modify
00220          *this pointer.
00221          */        
00222         gpointer app_data ;
00223 
00224         /**
00225          *a custom pointer used
00226          *by the upper layers of libcroco.
00227          *application should never use this
00228          *pointer.
00229          */
00230         gpointer croco_data ;
00231 
00232 } ;
00233 
00234 
00235 gboolean
00236 cr_statement_does_buf_parses_against_core (const guchar *a_buf,
00237                                            enum CREncoding a_encoding) ;
00238 CRStatement *
00239 cr_statement_parse_from_buf (const guchar *a_buf,
00240                              enum CREncoding a_encoding) ;
00241 CRStatement*
00242 cr_statement_new_ruleset (CRStyleSheet *a_sheet,
00243                           CRSelector *a_sel_list, 
00244                           CRDeclaration *a_decl_list,
00245                           CRStatement *a_media_rule) ;
00246 CRStatement *
00247 cr_statement_ruleset_parse_from_buf (const guchar * a_buf,
00248                                      enum CREncoding a_enc) ;
00249 
00250 CRStatement*
00251 cr_statement_new_at_import_rule (CRStyleSheet *a_container_sheet,
00252                                  GString *a_url,
00253                                  GList *a_media_list,
00254                                  CRStyleSheet *a_imported_sheet) ;
00255 
00256 CRStatement *
00257 cr_statement_at_import_rule_parse_from_buf (const guchar * a_buf,
00258                                             enum CREncoding a_encoding) ;
00259 
00260 CRStatement *
00261 cr_statement_new_at_media_rule (CRStyleSheet *a_sheet,
00262                                 CRStatement *a_ruleset,
00263                                 GList *a_media) ;
00264 CRStatement *
00265 cr_statement_at_media_rule_parse_from_buf (const guchar *a_buf,
00266                                            enum CREncoding a_enc) ;
00267 
00268 CRStatement *
00269 cr_statement_new_at_charset_rule (CRStyleSheet *a_sheet,
00270                                   GString *a_charset) ;
00271 CRStatement *
00272 cr_statement_at_charset_rule_parse_from_buf (const guchar *a_buf,
00273                                              enum CREncoding a_encoding);
00274 
00275 
00276 CRStatement *
00277 cr_statement_new_at_font_face_rule (CRStyleSheet *a_sheet,
00278                                     CRDeclaration *a_font_decls) ;
00279 CRStatement *
00280 cr_statement_font_face_rule_parse_from_buf (const guchar *a_buf,
00281                                             enum CREncoding a_encoding) ;
00282 
00283 CRStatement *
00284 cr_statement_new_at_page_rule (CRStyleSheet *a_sheet,
00285                                CRDeclaration *a_decl_list,
00286                                GString *a_name,
00287                                GString *a_pseudo) ;
00288 CRStatement *
00289 cr_statement_at_page_rule_parse_from_buf (const guchar *a_buf,
00290                                           enum CREncoding a_encoding)  ;
00291 
00292 enum CRStatus
00293 cr_statement_set_parent_sheet (CRStatement *a_this, 
00294                                CRStyleSheet *a_sheet) ;
00295 
00296 enum CRStatus
00297 cr_statement_get_parent_sheet (CRStatement *a_this, 
00298                                CRStyleSheet **a_sheet) ;
00299 
00300 CRStatement *
00301 cr_statement_append (CRStatement *a_this,
00302                      CRStatement *a_new) ;
00303 
00304 CRStatement*
00305 cr_statement_prepend (CRStatement *a_this,
00306                       CRStatement *a_new) ;
00307 
00308 CRStatement *
00309 cr_statement_unlink (CRStatement *a_stmt) ;
00310 
00311 enum CRStatus
00312 cr_statement_ruleset_set_sel_list (CRStatement *a_this,
00313                                    CRSelector *a_sel_list) ;
00314 
00315 enum CRStatus
00316 cr_statement_ruleset_get_sel_list (CRStatement *a_this,
00317                                    CRSelector **a_list) ;
00318 
00319 enum CRStatus
00320 cr_statement_ruleset_set_decl_list (CRStatement *a_this,
00321                                     CRDeclaration *a_list) ;
00322 
00323 enum CRStatus
00324 cr_statement_ruleset_get_declarations (CRStatement *a_this,
00325                                        CRDeclaration **a_decl_list) ;
00326 
00327 enum CRStatus
00328 cr_statement_ruleset_append_decl2 (CRStatement *a_this,
00329                                    GString *a_prop, CRTerm *a_value) ;
00330 
00331 enum CRStatus
00332 cr_statement_ruleset_append_decl (CRStatement *a_this,
00333                                   CRDeclaration *a_decl) ;
00334 
00335 enum CRStatus
00336 cr_statement_at_import_rule_set_imported_sheet (CRStatement *a_this,
00337                                                 CRStyleSheet *a_sheet) ;
00338 
00339 enum CRStatus
00340 cr_statement_at_import_rule_get_imported_sheet (CRStatement *a_this,
00341                                                 CRStyleSheet **a_sheet) ;
00342 
00343 enum CRStatus
00344 cr_statement_at_import_rule_set_url (CRStatement *a_this,
00345                                      GString *a_url) ;
00346 
00347 enum CRStatus
00348 cr_statement_at_import_rule_get_url (CRStatement *a_this,
00349                                      GString **a_url) ;
00350 
00351 enum CRStatus
00352 cr_statement_at_page_rule_set_sel (CRStatement *a_this,
00353                                    CRSelector *a_sel) ;
00354 
00355 enum CRStatus
00356 cr_statement_at_page_rule_get_sel (CRStatement *a_this,
00357                                    CRSelector **a_sel) ;
00358 
00359 enum CRStatus
00360 cr_statement_at_page_rule_set_declarations (CRStatement *a_this,
00361                                             CRDeclaration *a_decl_list) ;
00362 
00363 enum CRStatus
00364 cr_statement_at_page_rule_get_declarations (CRStatement *a_this,
00365                                             CRDeclaration **a_decl_list) ;
00366 
00367 enum CRStatus
00368 cr_statement_at_charset_rule_set_charset (CRStatement *a_this,
00369                                           GString *a_charset) ;
00370 
00371 enum CRStatus
00372 cr_statement_at_charset_rule_get_charset (CRStatement *a_this,
00373                                           GString **a_charset) ;
00374 
00375 enum CRStatus
00376 cr_statement_at_font_face_rule_set_decls (CRStatement *a_this,
00377                                           CRDeclaration *a_decls) ;
00378 
00379 enum CRStatus
00380 cr_statement_at_font_face_rule_get_decls (CRStatement *a_this,
00381                                           CRDeclaration **a_decls) ;
00382 
00383 enum CRStatus
00384 cr_statement_at_font_face_rule_add_decl (CRStatement *a_this,
00385                                          GString *a_prop,
00386                                          CRTerm *a_value) ;
00387 
00388 void
00389 cr_statement_dump (CRStatement *a_this, FILE *a_fp, gulong a_indent) ;
00390 
00391 void
00392 cr_statement_destroy (CRStatement *a_this) ;
00393 
00394 G_END_DECLS
00395 
00396 #endif /*__CR_STATEMENT_H__*/

Generated on Wed Oct 1 01:36:48 2003 for Libcroco by doxygen 1.3.3