• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /* -*- Mode: C; indent-tabs-mode:nil; c-basic-offset: 8-*- */
2 
3 /* libcroco - Library for parsing and applying CSS
4  * Copyright (C) 2006-2019 Free Software Foundation, Inc.
5  *
6  * This file is not part of the GNU gettext program, but is used with
7  * GNU gettext.
8  *
9  * The original copyright notice is as follows:
10  */
11 
12 /*
13  * This file is part of The Croco Library
14  *
15  * Copyright (C) 2003-2004 Dodji Seketeli.  All Rights Reserved.
16  *
17  * This program is free software; you can redistribute it and/or
18  * modify it under the terms of version 2.1 of the GNU Lesser General Public
19  * License as published by the Free Software Foundation.
20  *
21  * This program is distributed in the hope that it will be useful,
22  * but WITHOUT ANY WARRANTY; without even the implied warranty of
23  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
24  * GNU General Public License for more details.
25  *
26  * You should have received a copy of the GNU Lesser General Public License
27  * along with this program; if not, write to the Free Software
28  * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307
29  * USA
30  *
31  * Author: Dodji Seketeli
32  */
33 
34 
35 #ifndef __CR_SEL_H__
36 #define __CR_SEL_H__
37 
38 #include <stdio.h>
39 #include <glib.h>
40 #include "cr-additional-sel.h"
41 #include "cr-parsing-location.h"
42 
43 G_BEGIN_DECLS
44 
45 /**
46  *@file
47  *the declaration of the #CRSimpleSel class.
48  *
49  */
50 enum Combinator
51 {
52         NO_COMBINATOR,
53         COMB_WS,/*whitespace: descendent*/
54         COMB_PLUS,/*'+': preceded by*/
55         COMB_GT/*greater than ('>'): child*/
56 } ;
57 
58 enum SimpleSelectorType
59 {
60         NO_SELECTOR_TYPE = 0,
61         UNIVERSAL_SELECTOR = 1,
62         TYPE_SELECTOR = 1 << 1
63 } ;
64 
65 typedef struct _CRSimpleSel CRSimpleSel ;
66 
67 /**
68  *The abstraction of a css2 simple selection list
69  *as defined by the right part of the "selector" production in the
70  *appendix D.1 of the css2 spec.
71  *It is basically a list of simple selector, each
72  *simple selector being separated by a combinator.
73  *
74  *In the libcroco's implementation, each simple selector
75  *is made of at most two parts:
76  *
77  *1/An element name or 'type selector' (which can hold a '*' and
78  *then been called 'universal selector')
79  *
80  *2/An additional selector that "specializes" the preceding type or
81  *universal selector. The additionnal selector can be either
82  *an id selector, or a class selector, or an attribute selector.
83  */
84 struct _CRSimpleSel
85 {
86         enum SimpleSelectorType type_mask ;
87         gboolean is_case_sentive ;
88         CRString * name ;
89         /**
90          *The combinator that separates
91          *this simple selector from the previous
92          *one.
93          */
94         enum Combinator combinator ;
95 
96         /**
97          *The additional selector list of the
98          *current simple selector.
99          *An additional selector may
100          *be a class selector, an id selector,
101          *or an attribute selector.
102          *Note that this field is a linked list.
103          */
104         CRAdditionalSel *add_sel ;
105 
106         /*
107          *the specificity as specified by
108          *chapter 6.4.3 of the spec.
109          */
110         gulong specificity ;
111 
112         CRSimpleSel *next ;
113         CRSimpleSel *prev ;
114         CRParsingLocation location ;
115 } ;
116 
117 CRSimpleSel * cr_simple_sel_new (void) ;
118 
119 CRSimpleSel * cr_simple_sel_append_simple_sel (CRSimpleSel *a_this,
120                                                CRSimpleSel *a_sel) ;
121 
122 CRSimpleSel * cr_simple_sel_prepend_simple_sel (CRSimpleSel *a_this,
123                                                 CRSimpleSel *a_sel) ;
124 
125 guchar * cr_simple_sel_to_string (CRSimpleSel const *a_this) ;
126 
127 guchar * cr_simple_sel_one_to_string (CRSimpleSel const * a_this) ;
128 
129 enum CRStatus cr_simple_sel_dump (CRSimpleSel const *a_this, FILE *a_fp) ;
130 
131 enum CRStatus cr_simple_sel_dump_attr_sel_list (CRSimpleSel const *a_this) ;
132 
133 enum CRStatus cr_simple_sel_compute_specificity (CRSimpleSel *a_this) ;
134 
135 void cr_simple_sel_destroy (CRSimpleSel *a_this) ;
136 
137 G_END_DECLS
138 
139 
140 #endif /*__CR_SIMPLE_SEL_H__*/
141