Libcroco
cr-statement.h
Go to the documentation of this file.
1 /* -*- Mode: C; indent-tabs-mode: nil; c-basic-offset: 8 -*- */
2 
3 /*
4  * This file is part of The Croco Library
5  *
6  * This program is free software; you can redistribute it and/or
7  * modify it under the terms of version 2.1 of the GNU Lesser General Public
8  * License as published by the Free Software Foundation.
9  *
10  * This program is distributed in the hope that it will be useful,
11  * but WITHOUT ANY WARRANTY; without even the implied warranty of
12  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13  * GNU General Public License for more details.
14  *
15  * You should have received a copy of the GNU Lesser General Public License
16  * along with this program; if not, write to the Free Software
17  * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307
18  * USA
19  *
20  * Author: Dodji Seketeli
21  * See COPYRIGHTS file for copyright information.
22  */
23 
24 #include <stdio.h>
25 #include "cr-utils.h"
26 #include "cr-term.h"
27 #include "cr-selector.h"
28 #include "cr-declaration.h"
29 
30 #ifndef __CR_STATEMENT_H__
31 #define __CR_STATEMENT_H__
32 
33 G_BEGIN_DECLS
34 
35 /**
36  *@file
37  *Declaration of the #CRStatement class.
38  */
39 
40 /*
41  *forward declaration of CRStyleSheet which is defined in
42  *cr-stylesheet.h
43  */
44 
45 struct _CRStatement ;
46 
47 /*
48  *typedef struct _CRStatement CRStatement ;
49  *this is forward declared in
50  *cr-declaration.h already.
51  */
52 
53 struct _CRAtMediaRule ;
54 typedef struct _CRAtMediaRule CRAtMediaRule ;
55 
56 typedef struct _CRRuleSet CRRuleSet ;
57 
58 /**
59  *The abstraction of a css ruleset.
60  *A ruleset is made of a list of selectors,
61  *followed by a list of declarations.
62  */
63 struct _CRRuleSet
64 {
65  /**A list of instances of #CRSimpeSel*/
67 
68  /**A list of instances of #CRDeclaration*/
70 
71  /**
72  *The parent media rule, or NULL if
73  *no parent media rule exists.
74  */
76 } ;
77 
78 /*
79  *a forward declaration of CRStylesheet.
80  *CRStylesheet is actually declared in
81  *cr-stylesheet.h
82  */
83 struct _CRStyleSheet ;
84 typedef struct _CRStyleSheet CRStyleSheet;
85 
86 
87 /**The \@import rule abstraction.*/
90 {
91  /**the url of the import rule*/
93 
94  GList *media_list ;
95 
96  /**
97  *the stylesheet fetched from the url, if any.
98  *this is not "owned" by #CRAtImportRule which means
99  *it is not destroyed by the destructor of #CRAtImportRule.
100  */
102 };
103 
104 
105 /**abstraction of an \@media rule*/
107 {
108  GList *media_list ;
110 } ;
111 
112 
113 typedef struct _CRAtPageRule CRAtPageRule ;
114 /**The \@page rule abstraction*/
116 {
117  /**a list of instances of #CRDeclaration*/
119 
120  /**page selector. Is a pseudo selector*/
123 } ;
124 
125 /**The \@charset rule abstraction*/
128 {
130 };
131 
132 /**The abstaction of the \@font-face rule.*/
135 {
136  /*a list of instanaces of #CRDeclaration*/
138 } ;
139 
140 
141 /**
142  *The possible types of css2 statements.
143  */
145 {
146  /**
147  *A generic css at-rule
148  *each unknown at-rule will
149  *be of this type.
150  */
151 
152  /**A css at-rule*/
154 
155  /*A css ruleset*/
157 
158  /**A css2 import rule*/
160 
161  /**A css2 media rule*/
163 
164  /**A css2 page rule*/
166 
167  /**A css2 charset rule*/
169 
170  /**A css2 font face rule*/
172 } ;
173 
174 
175 /**
176  *The abstraction of css statement as defined
177  *in the chapter 4 and appendix D.1 of the css2 spec.
178  *A statement is actually a double chained list of
179  *statements.A statement can be a ruleset, an \@import
180  *rule, an \@page rule etc ...
181  */
183 {
184  /**
185  *The type of the statement.
186  */
188 
189  union
190  {
197  } kind ;
198 
199  /*
200  *the specificity of the selector
201  *that matched this statement.
202  *This is only used by the cascading
203  *order determination algorithm.
204  */
205  gulong specificity ;
206 
207  /*
208  *the style sheet that contains
209  *this css statement.
210  */
214 
216 
217  /**
218  *a custom pointer useable by
219  *applications that use libcroco.
220  *libcroco itself will never modify
221  *this pointer.
222  */
223  gpointer app_data ;
224 
225  /**
226  *a custom pointer used
227  *by the upper layers of libcroco.
228  *application should never use this
229  *pointer.
230  */
231  gpointer croco_data ;
232 
233 } ;
234 
235 
236 gboolean
237 cr_statement_does_buf_parses_against_core (const guchar *a_buf,
238  enum CREncoding a_encoding) ;
239 CRStatement *
240 cr_statement_parse_from_buf (const guchar *a_buf,
241  enum CREncoding a_encoding) ;
244  CRSelector *a_sel_list,
245  CRDeclaration *a_decl_list,
246  CRStatement *a_media_rule) ;
247 CRStatement *
248 cr_statement_ruleset_parse_from_buf (const guchar * a_buf,
249  enum CREncoding a_enc) ;
250 
253  CRString *a_url,
254  GList *a_media_list,
255  CRStyleSheet *a_imported_sheet) ;
256 
257 CRStatement *
258 cr_statement_at_import_rule_parse_from_buf (const guchar * a_buf,
259  enum CREncoding a_encoding) ;
260 
261 CRStatement *
263  CRStatement *a_ruleset,
264  GList *a_media) ;
265 CRStatement *
266 cr_statement_at_media_rule_parse_from_buf (const guchar *a_buf,
267  enum CREncoding a_enc) ;
268 
269 CRStatement *
271  CRString *a_charset) ;
272 CRStatement *
274  enum CREncoding a_encoding);
275 
276 
277 CRStatement *
279  CRDeclaration *a_font_decls) ;
280 CRStatement *
281 cr_statement_font_face_rule_parse_from_buf (const guchar *a_buf,
282  enum CREncoding a_encoding) ;
283 
284 CRStatement *
286  CRDeclaration *a_decl_list,
287  CRString *a_name,
288  CRString *a_pseudo) ;
289 CRStatement *
290 cr_statement_at_page_rule_parse_from_buf (const guchar *a_buf,
291  enum CREncoding a_encoding) ;
292 
293 enum CRStatus
295  CRStyleSheet *a_sheet) ;
296 
297 enum CRStatus
299  CRStyleSheet **a_sheet) ;
300 
301 CRStatement *
303  CRStatement *a_new) ;
304 
307  CRStatement *a_new) ;
308 
309 CRStatement *
311 
312 enum CRStatus
314  CRSelector *a_sel_list) ;
315 
316 enum CRStatus
318  CRSelector **a_list) ;
319 
320 enum CRStatus
322  CRDeclaration *a_list) ;
323 
324 enum CRStatus
326  CRDeclaration **a_decl_list) ;
327 
328 enum CRStatus
330  CRString *a_prop, CRTerm *a_value) ;
331 
332 enum CRStatus
334  CRDeclaration *a_decl) ;
335 
336 enum CRStatus
338  CRStyleSheet *a_sheet) ;
339 
340 enum CRStatus
342  CRStyleSheet **a_sheet) ;
343 
344 enum CRStatus
346  CRString *a_url) ;
347 
348 enum CRStatus
350  CRString **a_url) ;
351 
352 gint
354 
355 CRStatement *
356 cr_statement_at_media_get_from_list (CRStatement *a_this, int itemnr) ;
357 
358 enum CRStatus
360  CRSelector *a_sel) ;
361 
362 enum CRStatus
364  CRSelector **a_sel) ;
365 
366 enum CRStatus
368  CRDeclaration *a_decl_list) ;
369 
370 enum CRStatus
372  CRDeclaration **a_decl_list) ;
373 
374 enum CRStatus
376  CRString *a_charset) ;
377 
378 enum CRStatus
380  CRString **a_charset) ;
381 
382 enum CRStatus
384  CRDeclaration *a_decls) ;
385 
386 enum CRStatus
388  CRDeclaration **a_decls) ;
389 
390 enum CRStatus
392  CRString *a_prop,
393  CRTerm *a_value) ;
394 
395 gchar *
396 cr_statement_to_string (CRStatement const * a_this, gulong a_indent) ;
397 
398 gchar*
399 cr_statement_list_to_string (CRStatement const *a_this, gulong a_indent) ;
400 
401 void
402 cr_statement_dump (CRStatement const *a_this, FILE *a_fp, gulong a_indent) ;
403 
404 void
405 cr_statement_dump_ruleset (CRStatement const * a_this, FILE * a_fp,
406  glong a_indent) ;
407 
408 void
410  FILE * a_fp,
411  glong a_indent) ;
412 
413 void
414 cr_statement_dump_page (CRStatement const * a_this, FILE * a_fp,
415  gulong a_indent) ;
416 
417 
418 void
420  FILE * a_fp,
421  gulong a_indent) ;
422 
423 void
424 cr_statement_dump_import_rule (CRStatement const * a_this, FILE * a_fp,
425  gulong a_indent) ;
426 void
427 cr_statement_dump_charset (CRStatement const * a_this, FILE * a_fp,
428  gulong a_indent) ;
429 gint
430 cr_statement_nr_rules (CRStatement const *a_this) ;
431 
432 CRStatement *
433 cr_statement_get_from_list (CRStatement *a_this, int itemnr) ;
434 
435 void
437 
438 G_END_DECLS
439 
440 #endif /*__CR_STATEMENT_H__*/
A css2 page rule.
Definition: cr-statement.h:165
enum CRStatus cr_statement_ruleset_append_decl(CRStatement *a_this, CRDeclaration *a_decl)
cr_statement_ruleset_append_decl:
gchar * cr_statement_to_string(CRStatement const *a_this, gulong a_indent)
cr_statement_to_string:
CRSelector * sel_list
A list of instances of #CRSimpeSel.
Definition: cr-statement.h:66
The @page rule abstraction.
Definition: cr-statement.h:115
A css2 media rule.
Definition: cr-statement.h:162
CRStatement * parent_media_rule
The parent media rule, or NULL if no parent media rule exists.
Definition: cr-statement.h:75
CRDeclaration * decl_list
A list of instances of CRDeclaration.
Definition: cr-statement.h:69
CRAtMediaRule * media_rule
Definition: cr-statement.h:193
union _CRStatement::@1 kind
CRStatement * cr_statement_new_at_charset_rule(CRStyleSheet *a_sheet, CRString *a_charset)
cr_statement_new_at_charset_rule:
void cr_statement_dump_page(CRStatement const *a_this, FILE *a_fp, gulong a_indent)
cr_statement_dump_page:
enum CRStatus cr_statement_at_page_rule_set_sel(CRStatement *a_this, CRSelector *a_sel)
CRAtFontFaceRule * font_face_rule
Definition: cr-statement.h:196
CRStatement * cr_statement_at_import_rule_parse_from_buf(const guchar *a_buf, enum CREncoding a_encoding)
cr_statement_at_import_rule_parse_from_buf:
enum CRStatus cr_statement_at_import_rule_get_imported_sheet(CRStatement *a_this, CRStyleSheet **a_sheet)
cr_statement_at_import_rule_get_imported_sheet:
enum CRStatus cr_statement_ruleset_append_decl2(CRStatement *a_this, CRString *a_prop, CRTerm *a_value)
cr_statement_ruleset_append_decl2:
enum CRStatus cr_statement_at_font_face_rule_set_decls(CRStatement *a_this, CRDeclaration *a_decls)
cr_statement_at_font_face_rule_set_decls:
enum CRStatus cr_statement_get_parent_sheet(CRStatement *a_this, CRStyleSheet **a_sheet)
cr_statement_get_parent_sheet:
enum CRStatus cr_statement_ruleset_set_sel_list(CRStatement *a_this, CRSelector *a_sel_list)
cr_statement_ruleset_set_sel_list:
CRStatement * cr_statement_new_at_media_rule(CRStyleSheet *a_sheet, CRStatement *a_ruleset, GList *a_media)
cr_statement_new_at_media_rule:
enum CRStatus cr_statement_at_font_face_rule_get_decls(CRStatement *a_this, CRDeclaration **a_decls)
cr_statement_at_font_face_rule_get_decls:
CRStatement * cr_statement_font_face_rule_parse_from_buf(const guchar *a_buf, enum CREncoding a_encoding)
cr_statement_font_face_rule_parse_from_buf:
An abstraction of a css stylesheet as defined by the css2 spec in chapter 4.
Definition: cr-stylesheet.h:57
The Croco library basic types definitions And global definitions.
CRAtPageRule * page_rule
Definition: cr-statement.h:194
enum CRStatus cr_statement_at_import_rule_set_imported_sheet(CRStatement *a_this, CRStyleSheet *a_sheet)
cr_statement_at_import_rule_set_imported_sheet:
The declaration file of the CRSelector file.
GList * media_list
Definition: cr-statement.h:108
gboolean cr_statement_does_buf_parses_against_core(const guchar *a_buf, enum CREncoding a_encoding)
cr_statement_does_buf_parses_against_core:
Definition: cr-statement.c:931
A css2 font face rule.
Definition: cr-statement.h:171
enum CRStatus cr_statement_at_font_face_rule_add_decl(CRStatement *a_this, CRString *a_prop, CRTerm *a_value)
cr_statement_at_font_face_rule_add_decl:
CRStatement * cr_statement_append(CRStatement *a_this, CRStatement *a_new)
cr_statement_append:
CREncoding
Encoding values.
Definition: cr-utils.h:84
CRDeclaration * decl_list
Definition: cr-statement.h:137
typedefG_BEGIN_DECLS struct _CRSelector CRSelector
Definition: cr-selector.h:40
CRStatus
The status type returned by the methods of the croco library.
Definition: cr-utils.h:43
enum CRStatementType type
The type of the statement.
Definition: cr-statement.h:187
CRStatement * cr_statement_get_from_list(CRStatement *a_this, int itemnr)
cr_statement_get_from_list:
enum CRStatus cr_statement_at_page_rule_set_declarations(CRStatement *a_this, CRDeclaration *a_decl_list)
cr_statement_at_page_rule_set_declarations:
enum CRStatus cr_statement_ruleset_get_declarations(CRStatement *a_this, CRDeclaration **a_decl_list)
cr_statement_ruleset_get_declarations:
gpointer app_data
a custom pointer useable by applications that use libcroco.
Definition: cr-statement.h:223
CRAtCharsetRule * charset_rule
Definition: cr-statement.h:195
CRStatement * cr_statement_at_charset_rule_parse_from_buf(const guchar *a_buf, enum CREncoding a_encoding)
cr_statement_at_charset_rule_parse_from_buf:
The abstraction of css statement as defined in the chapter 4 and appendix D.1 of the css2 spec.
Definition: cr-statement.h:182
CRStatementType
The possible types of css2 statements.
Definition: cr-statement.h:144
CRStatement * cr_statement_new_ruleset(CRStyleSheet *a_sheet, CRSelector *a_sel_list, CRDeclaration *a_decl_list, CRStatement *a_media_rule)
cr_statement_new_ruleset:
void cr_statement_dump_charset(CRStatement const *a_this, FILE *a_fp, gulong a_indent)
cr_statement_dump_charset:
CRString * pseudo
Definition: cr-statement.h:122
void cr_statement_dump_import_rule(CRStatement const *a_this, FILE *a_fp, gulong a_indent)
cr_statement_dump_import_rule:
CRStatement * cr_statement_new_at_page_rule(CRStyleSheet *a_sheet, CRDeclaration *a_decl_list, CRString *a_name, CRString *a_pseudo)
cr_statement_new_at_page_rule:
A css2 charset rule.
Definition: cr-statement.h:168
The declaration of the CRDeclaration class.
CRRuleSet * ruleset
Definition: cr-statement.h:191
CRStatement * cr_statement_unlink(CRStatement *a_stmt)
cr_statement_unlink:
CRStatement * rulesets
Definition: cr-statement.h:109
A generic css at-rule each unknown at-rule will be of this type.
Definition: cr-statement.h:153
enum CRStatus cr_statement_set_parent_sheet(CRStatement *a_this, CRStyleSheet *a_sheet)
cr_statement_set_parent_sheet:
CRStatement * cr_statement_parse_from_buf(const guchar *a_buf, enum CREncoding a_encoding)
cr_statement_parse_from_buf:
Definition: cr-statement.c:974
gchar * cr_statement_list_to_string(CRStatement const *a_this, gulong a_indent)
CRStatement * cr_statement_ruleset_parse_from_buf(const guchar *a_buf, enum CREncoding a_enc)
cr_statement_ruleset_parse_from_buf:
typedefG_BEGIN_DECLS struct _CRString CRString
Definition: cr-string.h:37
CRStatement * cr_statement_at_media_rule_parse_from_buf(const guchar *a_buf, enum CREncoding a_enc)
cr_statement_at_media_rule_parse_from_buf:
CRStatement * cr_statement_at_page_rule_parse_from_buf(const guchar *a_buf, enum CREncoding a_encoding)
cr_statement_at_page_rule_parse_from_buf:
enum CRStatus cr_statement_ruleset_set_decl_list(CRStatement *a_this, CRDeclaration *a_list)
cr_statement_ruleset_set_decl_list:
CRStyleSheet * sheet
the stylesheet fetched from the url, if any.
Definition: cr-statement.h:101
void cr_statement_dump(CRStatement const *a_this, FILE *a_fp, gulong a_indent)
cr_statement_dump:
CRStatement * cr_statement_new_at_import_rule(CRStyleSheet *a_container_sheet, CRString *a_url, GList *a_media_list, CRStyleSheet *a_imported_sheet)
cr_statement_new_at_import_rule:
CRString * charset
Definition: cr-statement.h:129
void cr_statement_destroy(CRStatement *a_this)
cr_statement_destroy:
void cr_statement_dump_ruleset(CRStatement const *a_this, FILE *a_fp, glong a_indent)
cr_statement_dump_ruleset:
enum CRStatus cr_statement_at_import_rule_get_url(CRStatement const *a_this, CRString **a_url)
cr_statement_at_import_rule_get_url:
The abstraction of a css ruleset.
Definition: cr-statement.h:63
An abstraction of a css2 term as defined in the CSS2 spec in appendix D.1: term ::= [ NUMBER S* | PER...
Definition: cr-term.h:82
CRStatement * cr_statement_new_at_font_face_rule(CRStyleSheet *a_sheet, CRDeclaration *a_font_decls)
cr_statement_new_at_font_face_rule:
CRAtImportRule * import_rule
Definition: cr-statement.h:192
gpointer croco_data
a custom pointer used by the upper layers of libcroco.
Definition: cr-statement.h:231
CRParsingLocation location
Definition: cr-statement.h:215
CRString * url
the url of the import rule
Definition: cr-statement.h:92
CRStyleSheet * parent_sheet
Definition: cr-statement.h:211
abstraction of an @media rule
Definition: cr-statement.h:106
gulong specificity
Definition: cr-statement.h:205
gint cr_statement_nr_rules(CRStatement const *a_this)
cr_statement_nr_rules:
Declaration of the #CRTem class.
GList * media_list
Definition: cr-statement.h:94
CRStatement * next
Definition: cr-statement.h:212
void cr_statement_dump_media_rule(CRStatement const *a_this, FILE *a_fp, gulong a_indent)
cr_statement_dump_media_rule:
void cr_statement_dump_font_face_rule(CRStatement const *a_this, FILE *a_fp, glong a_indent)
cr_statement_dump_font_face_rule:
A css2 import rule.
Definition: cr-statement.h:159
enum CRStatus cr_statement_at_charset_rule_get_charset(CRStatement const *a_this, CRString **a_charset)
cr_statement_at_charset_rule_get_charset: @a_this: the current @charset rule statement.
enum CRStatus cr_statement_at_charset_rule_set_charset(CRStatement *a_this, CRString *a_charset)
cr_statement_at_charset_rule_set_charset:
CRString * name
page selector.
Definition: cr-statement.h:121
enum CRStatus cr_statement_at_page_rule_get_declarations(CRStatement *a_this, CRDeclaration **a_decl_list)
cr_statement_at_page_rule_get_declarations:
enum CRStatus cr_statement_ruleset_get_sel_list(CRStatement const *a_this, CRSelector **a_list)
cr_statement_ruleset_get_sel_list:
CRStatement * cr_statement_at_media_get_from_list(CRStatement *a_this, int itemnr)
cr_statement_at_media_get_from_list:
enum CRStatus cr_statement_at_page_rule_get_sel(CRStatement const *a_this, CRSelector **a_sel)
CRStatement * cr_statement_prepend(CRStatement *a_this, CRStatement *a_new)
cr_statement_prepend:
CRDeclaration * decl_list
a list of instances of CRDeclaration
Definition: cr-statement.h:118
enum CRStatus cr_statement_at_import_rule_set_url(CRStatement *a_this, CRString *a_url)
cr_statement_at_import_rule_set_url:
CRStatement * prev
Definition: cr-statement.h:213
gint cr_statement_at_media_nr_rules(CRStatement const *a_this)
cr_statement_at_media_nr_rules: