• Home
  • History
  • Annotate
  • Line#
  • Navigate
  • Raw
  • Download
  • only in /netgear-WNDR4500v2-V1.0.0.60_1.0.38/ap/gpl/timemachine/gettext-0.17/gettext-tools/gnulib-lib/libcroco/
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 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 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
33G_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
45struct _CRStatement ;
46
47/*
48 *typedef struct _CRStatement CRStatement ;
49 *this is forward declared in
50 *cr-declaration.h already.
51 */
52
53struct _CRAtMediaRule ;
54typedef struct _CRAtMediaRule CRAtMediaRule ;
55
56typedef 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 */
63struct _CRRuleSet
64{
65	/**A list of instances of #CRSimpeSel*/
66	CRSelector *sel_list ;
67
68	/**A list of instances of #CRDeclaration*/
69	CRDeclaration *decl_list ;
70
71	/**
72	 *The parent media rule, or NULL if
73	 *no parent media rule exists.
74	 */
75	CRStatement *parent_media_rule ;
76} ;
77
78/*
79 *a forward declaration of CRStylesheet.
80 *CRStylesheet is actually declared in
81 *cr-stylesheet.h
82 */
83struct _CRStyleSheet ;
84typedef struct _CRStyleSheet CRStyleSheet;
85
86
87/**The @import rule abstraction.*/
88typedef struct _CRAtImportRule CRAtImportRule ;
89struct _CRAtImportRule
90{
91	/**the url of the import rule*/
92	CRString *url ;
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	 */
101	CRStyleSheet * sheet;
102};
103
104
105/**abstraction of an @media rule*/
106struct _CRAtMediaRule
107{
108	GList *media_list ;
109	CRStatement *rulesets ;
110} ;
111
112
113typedef struct _CRAtPageRule CRAtPageRule ;
114/**The @page rule abstraction*/
115struct _CRAtPageRule
116{
117	/**a list of instances of #CRDeclaration*/
118	CRDeclaration *decl_list ;
119
120	/**page selector. Is a pseudo selector*/
121	CRString *name ;
122	CRString *pseudo ;
123} ;
124
125/**The @charset rule abstraction*/
126typedef struct _CRAtCharsetRule CRAtCharsetRule ;
127struct _CRAtCharsetRule
128{
129	CRString * charset ;
130};
131
132/**The abstaction of the @font-face rule.*/
133typedef struct _CRAtFontFaceRule CRAtFontFaceRule ;
134struct _CRAtFontFaceRule
135{
136	/*a list of instanaces of #CRDeclaration*/
137	CRDeclaration *decl_list ;
138} ;
139
140
141/**
142 *The possible types of css2 statements.
143 */
144enum CRStatementType
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*/
153	AT_RULE_STMT = 0,
154
155	/*A css ruleset*/
156	RULESET_STMT,
157
158	/**A css2 import rule*/
159	AT_IMPORT_RULE_STMT,
160
161	/**A css2 media rule*/
162	AT_MEDIA_RULE_STMT,
163
164	/**A css2 page rule*/
165	AT_PAGE_RULE_STMT,
166
167	/**A css2 charset rule*/
168	AT_CHARSET_RULE_STMT,
169
170	/**A css2 font face rule*/
171	AT_FONT_FACE_RULE_STMT
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 */
182struct _CRStatement
183{
184	/**
185	 *The type of the statement.
186	 */
187	enum CRStatementType type ;
188
189	union
190	{
191		CRRuleSet *ruleset ;
192		CRAtImportRule *import_rule ;
193		CRAtMediaRule *media_rule ;
194		CRAtPageRule *page_rule ;
195		CRAtCharsetRule *charset_rule ;
196		CRAtFontFaceRule *font_face_rule ;
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         */
211        CRStyleSheet *parent_sheet ;
212	CRStatement *next ;
213	CRStatement *prev ;
214
215        CRParsingLocation location ;
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
236gboolean
237cr_statement_does_buf_parses_against_core (const guchar *a_buf,
238                                           enum CREncoding a_encoding) ;
239CRStatement *
240cr_statement_parse_from_buf (const guchar *a_buf,
241			     enum CREncoding a_encoding) ;
242CRStatement*
243cr_statement_new_ruleset (CRStyleSheet *a_sheet,
244                          CRSelector *a_sel_list,
245			  CRDeclaration *a_decl_list,
246			  CRStatement *a_media_rule) ;
247CRStatement *
248cr_statement_ruleset_parse_from_buf (const guchar * a_buf,
249				     enum CREncoding a_enc) ;
250
251CRStatement*
252cr_statement_new_at_import_rule (CRStyleSheet *a_container_sheet,
253                                 CRString *a_url,
254                                 GList *a_media_list,
255				 CRStyleSheet *a_imported_sheet) ;
256
257CRStatement *
258cr_statement_at_import_rule_parse_from_buf (const guchar * a_buf,
259                                            enum CREncoding a_encoding) ;
260
261CRStatement *
262cr_statement_new_at_media_rule (CRStyleSheet *a_sheet,
263                                CRStatement *a_ruleset,
264				GList *a_media) ;
265CRStatement *
266cr_statement_at_media_rule_parse_from_buf (const guchar *a_buf,
267					   enum CREncoding a_enc) ;
268
269CRStatement *
270cr_statement_new_at_charset_rule (CRStyleSheet *a_sheet,
271                                  CRString *a_charset) ;
272CRStatement *
273cr_statement_at_charset_rule_parse_from_buf (const guchar *a_buf,
274					     enum CREncoding a_encoding);
275
276
277CRStatement *
278cr_statement_new_at_font_face_rule (CRStyleSheet *a_sheet,
279                                    CRDeclaration *a_font_decls) ;
280CRStatement *
281cr_statement_font_face_rule_parse_from_buf (const guchar *a_buf,
282					    enum CREncoding a_encoding) ;
283
284CRStatement *
285cr_statement_new_at_page_rule (CRStyleSheet *a_sheet,
286                               CRDeclaration *a_decl_list,
287			       CRString *a_name,
288			       CRString *a_pseudo) ;
289CRStatement *
290cr_statement_at_page_rule_parse_from_buf (const guchar *a_buf,
291					  enum CREncoding a_encoding)  ;
292
293enum CRStatus
294cr_statement_set_parent_sheet (CRStatement *a_this,
295                               CRStyleSheet *a_sheet) ;
296
297enum CRStatus
298cr_statement_get_parent_sheet (CRStatement *a_this,
299                               CRStyleSheet **a_sheet) ;
300
301CRStatement *
302cr_statement_append (CRStatement *a_this,
303		     CRStatement *a_new) ;
304
305CRStatement*
306cr_statement_prepend (CRStatement *a_this,
307		      CRStatement *a_new) ;
308
309CRStatement *
310cr_statement_unlink (CRStatement *a_stmt) ;
311
312enum CRStatus
313cr_statement_ruleset_set_sel_list (CRStatement *a_this,
314				   CRSelector *a_sel_list) ;
315
316enum CRStatus
317cr_statement_ruleset_get_sel_list (CRStatement *a_this,
318				   CRSelector **a_list) ;
319
320enum CRStatus
321cr_statement_ruleset_set_decl_list (CRStatement *a_this,
322				    CRDeclaration *a_list) ;
323
324enum CRStatus
325cr_statement_ruleset_get_declarations (CRStatement *a_this,
326                                       CRDeclaration **a_decl_list) ;
327
328enum CRStatus
329cr_statement_ruleset_append_decl2 (CRStatement *a_this,
330				   CRString *a_prop, CRTerm *a_value) ;
331
332enum CRStatus
333cr_statement_ruleset_append_decl (CRStatement *a_this,
334				  CRDeclaration *a_decl) ;
335
336enum CRStatus
337cr_statement_at_import_rule_set_imported_sheet (CRStatement *a_this,
338                                                CRStyleSheet *a_sheet) ;
339
340enum CRStatus
341cr_statement_at_import_rule_get_imported_sheet (CRStatement *a_this,
342                                                CRStyleSheet **a_sheet) ;
343
344enum CRStatus
345cr_statement_at_import_rule_set_url (CRStatement *a_this,
346				     CRString *a_url) ;
347
348enum CRStatus
349cr_statement_at_import_rule_get_url (CRStatement *a_this,
350				     CRString **a_url) ;
351
352gint
353cr_statement_at_media_nr_rules (CRStatement *a_this) ;
354
355CRStatement *
356cr_statement_at_media_get_from_list (CRStatement *a_this, int itemnr) ;
357
358enum CRStatus
359cr_statement_at_page_rule_set_sel (CRStatement *a_this,
360				   CRSelector *a_sel) ;
361
362enum CRStatus
363cr_statement_at_page_rule_get_sel (CRStatement *a_this,
364				   CRSelector **a_sel) ;
365
366enum CRStatus
367cr_statement_at_page_rule_set_declarations (CRStatement *a_this,
368					    CRDeclaration *a_decl_list) ;
369
370enum CRStatus
371cr_statement_at_page_rule_get_declarations (CRStatement *a_this,
372					    CRDeclaration **a_decl_list) ;
373
374enum CRStatus
375cr_statement_at_charset_rule_set_charset (CRStatement *a_this,
376					  CRString *a_charset) ;
377
378enum CRStatus
379cr_statement_at_charset_rule_get_charset (CRStatement *a_this,
380					  CRString **a_charset) ;
381
382enum CRStatus
383cr_statement_at_font_face_rule_set_decls (CRStatement *a_this,
384					  CRDeclaration *a_decls) ;
385
386enum CRStatus
387cr_statement_at_font_face_rule_get_decls (CRStatement *a_this,
388					  CRDeclaration **a_decls) ;
389
390enum CRStatus
391cr_statement_at_font_face_rule_add_decl (CRStatement *a_this,
392					 CRString *a_prop,
393					 CRTerm *a_value) ;
394
395gchar *
396cr_statement_to_string (CRStatement * a_this, gulong a_indent) ;
397
398gchar*
399cr_statement_list_to_string (CRStatement *a_this, gulong a_indent) ;
400
401void
402cr_statement_dump (CRStatement *a_this, FILE *a_fp, gulong a_indent) ;
403
404void
405cr_statement_dump_ruleset (CRStatement * a_this, FILE * a_fp,
406                           glong a_indent) ;
407
408void
409cr_statement_dump_font_face_rule (CRStatement * a_this,
410                                  FILE * a_fp,
411                                  glong a_indent) ;
412
413void
414cr_statement_dump_page (CRStatement * a_this, FILE * a_fp,
415                        gulong a_indent) ;
416
417
418void
419cr_statement_dump_media_rule (CRStatement * a_this,
420                              FILE * a_fp,
421                              gulong a_indent) ;
422
423void
424cr_statement_dump_import_rule (CRStatement * a_this, FILE * a_fp,
425                               gulong a_indent) ;
426void
427cr_statement_dump_charset (CRStatement * a_this, FILE * a_fp,
428                           gulong a_indent) ;
429gint
430cr_statement_nr_rules (CRStatement *a_this) ;
431
432CRStatement *
433cr_statement_get_from_list (CRStatement *a_this, int itemnr) ;
434
435void
436cr_statement_destroy (CRStatement *a_this) ;
437
438G_END_DECLS
439
440#endif /*__CR_STATEMENT_H__*/
441