1 /* -*- Mode: C; indent-tabs-mode:nil; c-basic-offset: 8-*- */
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 */
25 #ifndef __CR_SEL_H__
26 #define __CR_SEL_H__
28 #include <stdio.h>
29 #include <glib.h>
30 #include "cr-additional-sel.h"
31 #include "cr-parsing-location.h"
33 G_BEGIN_DECLS
35 /**
36 *@file
37 *the declaration of the #CRSimpleSel class.
38 *
39 */
40 enum Combinator
41 {
42 NO_COMBINATOR,
43 COMB_WS,/*whitesape*/
44 COMB_PLUS,
45 COMB_GT/*greater than*/
46 } ;
48 enum SimpleSelectorType
49 {
50 NO_SELECTOR_TYPE = 0,
51 UNIVERSAL_SELECTOR = 1,
52 TYPE_SELECTOR = 1 << 1
53 } ;
55 typedef struct _CRSimpleSel CRSimpleSel ;
57 /**
58 *The abstraction of a css2 simple selection list
59 *as defined by the right part of the "selector" production in the
60 *appendix D.1 of the css2 spec.
61 *It is basically a list of simple selector, each
62 *simple selector being separated by a combinator.
63 *
64 *In the libcroco's implementation, each simple selector
65 *is made of at most two parts:
66 *
67 *1/An element name or 'type selector' (which can hold a '*' and
68 *then been called 'universal selector')
69 *
70 *2/An additional selector that "specializes" the preceding type or
71 *universal selector. The additionnal selector can be either
72 *an id selector, or a class selector, or an attribute selector.
73 */
74 struct _CRSimpleSel
75 {
76 enum SimpleSelectorType type_mask ;
77 gboolean is_case_sentive ;
78 CRString * name ;
79 /**
80 *The combinator that separates
81 *this simple selector from the previous
82 *one.
83 */
84 enum Combinator combinator ;
86 /**
87 *The additional selector list of the
88 *current simple selector.
89 *An additional selector may
90 *be a class selector, an id selector,
91 *or an attribute selector.
92 *Note that this field is a linked list.
93 */
94 CRAdditionalSel *add_sel ;
96 /*
97 *the specificity as specified by
98 *chapter 6.4.3 of the spec.
99 */
100 gulong specificity ;
102 CRSimpleSel *next ;
103 CRSimpleSel *prev ;
104 CRParsingLocation location ;
105 } ;
107 CRSimpleSel * cr_simple_sel_new (void) ;
109 CRSimpleSel * cr_simple_sel_append_simple_sel (CRSimpleSel *a_this,
110 CRSimpleSel *a_sel) ;
112 CRSimpleSel * cr_simple_sel_prepend_simple_sel (CRSimpleSel *a_this,
113 CRSimpleSel *a_sel) ;
115 guchar * cr_simple_sel_to_string (CRSimpleSel *a_this) ;
117 guchar * cr_simple_sel_one_to_string (CRSimpleSel * a_this) ;
119 enum CRStatus cr_simple_sel_dump (CRSimpleSel *a_this, FILE *a_fp) ;
121 enum CRStatus cr_simple_sel_dump_attr_sel_list (CRSimpleSel *a_this) ;
123 enum CRStatus cr_simple_sel_compute_specificity (CRSimpleSel *a_this) ;
125 void cr_simple_sel_destroy (CRSimpleSel *a_this) ;
127 G_END_DECLS
130 #endif /*__CR_SIMPLE_SEL_H__*/