Libcroco
cr-style.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  *
7  * This program is free software; you can redistribute it and/or
8  * modify it under the terms of version 2.1 of the GNU Lesser General Public
9  * License as published by the Free Software Foundation.
10  *
11  * This program is distributed in the hope that it will be useful,
12  * but WITHOUT ANY WARRANTY; without even the implied warranty of
13  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14  * GNU General Public License for more details.
15  *
16  * You should have received a copy of the GNU Lesser General Public License
17  * along with this program; if not, write to the Free Software
18  * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307
19  * USA
20  *
21  * Author: Dodji Seketeli.
22  * See COPYRIGHTS file for copyright information.
23  */
24 
25 #ifndef __CR_STYLE_H__
26 #define __CR_STYLE_H__
27 
28 #include "cr-utils.h"
29 #include "cr-statement.h"
30 #include "cr-fonts.h"
31 
32 /**
33  *@file
34  *The declaration of the #CRStyle class.
35  */
36 G_BEGIN_DECLS
37 
38 typedef struct _CRStyle CRStyle ;
39 
41 {
53 } ;
54 
56 {
75 } ;
76 
78 {
84 } ;
85 
87 {
92 } ;
93 
95 {
100 } ;
101 
102 
103 #define BORDER_THIN 2
104 #define BORDER_MEDIUM 4
105 #define BORDER_THICK 6
106 
107 
108 /**
109  *A numerical css property value.
110  *This data type is actually split in 3 parts:
111  *1/the specified value
112  *2/the computed value
113  *3/the actual value.
114  *To understand the semantic of these three parts,
115  *see css2 spec chap 6.1 ("Specified, computed and actual values.").
116  */
117 typedef struct _CRNumPropVal CRNumPropVal ;
119 {
120  /**specified value*/
122  /**computed value*/
124  /**actual value*/
126 } ;
127 
128 /**
129  *An rgb css property value.
130  *This data type is actually split in 3 parts:
131  *1/the specified value
132  *2/the computed value
133  *3/the actual value.
134  *To understand the semantic of these three parts,
135  *see css2 spec chap 6.1 ("Specified, computed and actual values.").
136  */
137 typedef struct _CRRgbPropVal CRRgbPropVal ;
139 {
140  /**specified value*/
142  /**computed value*/
144  /**actual value*/
146 } ;
147 
148 
150 {
155 
160 
165 
170 
172 
173  /*must be last*/
175 } ;
176 
178 {
185 
186  /*must be last*/
188 } ;
189 
190 
192 {
197 
198  /*must be last*/
200 } ;
201 
203 {
208 
209  /*must be last*/
211 } ;
212 
215  /*specified value*/
217  /*computed value*/
219  /*actual value*/
221 } ;
222 
223 /**
224  *The css2 style class.
225  *Contains computed and actual values
226  *inferred from the declarations found
227  *in the stylesheets.
228  *See css2 spec chapter 6.
229  */
230 struct _CRStyle
231 {
232  /**
233  *numerical properties.
234  *the properties are indexed by
235  *enum #CRNumProp.
236  */
238 
239  /**
240  *color properties.
241  *They are indexed by enum #CRRgbProp .
242  */
244 
245  /**
246  *border style properties.
247  *They are indexed by enum #CRBorderStyleProp .
248  */
250 
251  /**box display type*/
253 
254  /**the positioning scheme*/
256 
257  /**the float property*/
259 
260  /*
261  *the 'font-family' property.
262  */
264 
265  /**
266  *the 'font-size' property.
267  */
274 
275  /**
276  * the 'tex' properties
277  */
279 
282  gulong ref_count ;
283 } ;
284 
286  GString * a_str, guint a_nb_indent) ;
287 
289  GString *a_str,
290  guint a_nb_indent) ;
291 
293  GString *a_str,
294  guint a_nb_indent) ;
295 
297  GString *a_str,
298  guint a_nb_indent) ;
299 
301  GString *a_str,
302  guint a_nb_indent) ;
303 
305  GString *a_str,
306  guint a_nb_indent) ;
307 
309  GString *a_str,
310  guint a_nb_indent) ;
311 
312 CRStyle * cr_style_new (gboolean a_set_props_to_initial_values) ;
313 
318 
320  CRDeclaration *a_decl) ;
321 
322 
323 enum CRStatus cr_style_copy (CRStyle *a_dest, CRStyle *a_src) ;
324 
325 enum CRStatus cr_style_ref (CRStyle *a_this) ;
326 
327 gboolean cr_style_unref (CRStyle *a_this) ;
328 
329 void cr_style_destroy (CRStyle *a_this) ;
330 
331 CRStyle * cr_style_dup (CRStyle *a_this) ;
332 
333 enum CRStatus cr_style_to_string (CRStyle *a_this,
334  GString **a_str,
335  guint a_nb_indent) ;
336 
337 G_END_DECLS
338 
339 #endif /*__CR_STYLE_H__*/
_CRStyle::num_props
CRNumPropVal num_props[NB_NUM_PROPS]
numerical properties.
Definition: cr-style.h:237
cr_style_float_type_to_string
enum CRStatus cr_style_float_type_to_string(enum CRFloatType a_code, GString *a_str, guint a_nb_indent)
Definition: cr-style.c:2589
DISPLAY_TABLE_FOOTER_GROUP
@ DISPLAY_TABLE_FOOTER_GROUP
Definition: cr-style.h:68
NUM_PROP_PADDING_LEFT
@ NUM_PROP_PADDING_LEFT
Definition: cr-style.h:159
DISPLAY_TABLE_CELL
@ DISPLAY_TABLE_CELL
Definition: cr-style.h:72
DISPLAY_INLINE
@ DISPLAY_INLINE
Definition: cr-style.h:58
POSITION_STATIC
@ POSITION_STATIC
Definition: cr-style.h:79
NUM_PROP_LEFT
@ NUM_PROP_LEFT
Definition: cr-style.h:154
_CRNumPropVal
Definition: cr-style.h:118
NUM_PROP_BORDER_TOP
@ NUM_PROP_BORDER_TOP
Definition: cr-style.h:161
POSITION_ABSOLUTE
@ POSITION_ABSOLUTE
Definition: cr-style.h:81
cr_style_propagate_from_parent
enum CRStatus cr_style_propagate_from_parent(CRStyle *a_this)
WHITE_SPACE_PRE
@ WHITE_SPACE_PRE
Definition: cr-style.h:97
DISPLAY_COMPACT
@ DISPLAY_COMPACT
Definition: cr-style.h:62
_CRRgbPropVal::av
CRRgb av
actual value
Definition: cr-style.h:145
cr_style_destroy
void cr_style_destroy(CRStyle *a_this)
Destructor of the CRStyle class.
Definition: cr-style.c:2845
DISPLAY_TABLE
@ DISPLAY_TABLE
Definition: cr-style.h:64
BORDER_STYLE_PROP_TOP
@ BORDER_STYLE_PROP_TOP
Definition: cr-style.h:193
DISPLAY_INHERIT
@ DISPLAY_INHERIT
Definition: cr-style.h:74
RGB_PROP_COLOR
@ RGB_PROP_COLOR
Definition: cr-style.h:183
BORDER_STYLE_NONE
@ BORDER_STYLE_NONE
Definition: cr-style.h:42
NUM_PROP_WIDTH
@ NUM_PROP_WIDTH
Definition: cr-style.h:171
NUM_PROP_MARGIN_RIGHT
@ NUM_PROP_MARGIN_RIGHT
Definition: cr-style.h:167
POSITION_RELATIVE
@ POSITION_RELATIVE
Definition: cr-style.h:80
CRDisplayType
CRDisplayType
Definition: cr-style.h:55
NUM_PROP_PADDING_BOTTOM
@ NUM_PROP_PADDING_BOTTOM
Definition: cr-style.h:158
_CRFontSizeVal::cv
CRFontSize cv
Definition: cr-style.h:218
cr_style_new
CRStyle * cr_style_new(gboolean a_set_props_to_initial_values)
Default constructor of CRStyle.
Definition: cr-style.c:1712
_CRStyle::float_type
enum CRFloatType float_type
the float property
Definition: cr-style.h:258
cr-fonts.h
_CRStyle::ref_count
gulong ref_count
Definition: cr-style.h:282
_CRNumPropVal::sv
CRNum sv
specified value
Definition: cr-style.h:121
_CRStyle::position
enum CRPositionType position
the positioning scheme
Definition: cr-style.h:255
DISPLAY_INLINE_TABLE
@ DISPLAY_INLINE_TABLE
Definition: cr-style.h:65
cr_style_ref
enum CRStatus cr_style_ref(CRStyle *a_this)
Increases the reference count of the current instance of CRStyle.
Definition: cr-style.c:2246
CRBoxOffsetProp
CRBoxOffsetProp
Definition: cr-style.h:202
DISPLAY_BLOCK
@ DISPLAY_BLOCK
Definition: cr-style.h:59
RGB_PROP_BORDER_TOP_COLOR
@ RGB_PROP_BORDER_TOP_COLOR
Definition: cr-style.h:179
DISPLAY_RUN_IN
@ DISPLAY_RUN_IN
Definition: cr-style.h:61
cr_style_copy
enum CRStatus cr_style_copy(CRStyle *a_dest, CRStyle *a_src)
Copies a style data structure into another.
Definition: cr-style.c:2312
cr_style_to_string
enum CRStatus cr_style_to_string(CRStyle *a_this, GString **a_str, guint a_nb_indent)
Serializes in instance of CRStyle into a string.
Definition: cr-style.c:2659
_CRDeclaration
Definition: cr-declaration.h:47
NUM_PROP_RIGHT
@ NUM_PROP_RIGHT
Definition: cr-style.h:152
NB_RGB_PROPS
@ NB_RGB_PROPS
Definition: cr-style.h:187
BORDER_STYLE_SOLID
@ BORDER_STYLE_SOLID
Definition: cr-style.h:46
CRFontWeight
CRFontWeight
Definition: cr-fonts.h:192
BORDER_STYLE_PROP_RIGHT
@ BORDER_STYLE_PROP_RIGHT
Definition: cr-style.h:194
NB_BORDER_STYLE_PROPS
@ NB_BORDER_STYLE_PROPS
Definition: cr-style.h:199
_CRRgbPropVal
Definition: cr-style.h:138
BORDER_STYLE_PROP_LEFT
@ BORDER_STYLE_PROP_LEFT
Definition: cr-style.h:196
BORDER_STYLE_DASHED
@ BORDER_STYLE_DASHED
Definition: cr-style.h:45
DISPLAY_LIST_ITEM
@ DISPLAY_LIST_ITEM
Definition: cr-style.h:60
NB_BOX_OFFSET_PROPS
@ NB_BOX_OFFSET_PROPS
Definition: cr-style.h:210
FLOAT_INHERIT
@ FLOAT_INHERIT
Definition: cr-style.h:91
NUM_PROP_PADDING_TOP
@ NUM_PROP_PADDING_TOP
Definition: cr-style.h:156
WHITE_SPACE_INHERIT
@ WHITE_SPACE_INHERIT
Definition: cr-style.h:99
_CRStyle::font_weight
enum CRFontWeight font_weight
Definition: cr-style.h:272
NUM_PROP_MARGIN_BOTTOM
@ NUM_PROP_MARGIN_BOTTOM
Definition: cr-style.h:168
BORDER_STYLE_OUTSET
@ BORDER_STYLE_OUTSET
Definition: cr-style.h:51
CRBorderStyleProp
CRBorderStyleProp
Definition: cr-style.h:191
NUM_PROP_PADDING_RIGHT
@ NUM_PROP_PADDING_RIGHT
Definition: cr-style.h:157
RGB_PROP_BORDER_LEFT_COLOR
@ RGB_PROP_BORDER_LEFT_COLOR
Definition: cr-style.h:182
CRWhiteSpaceType
CRWhiteSpaceType
Definition: cr-style.h:94
_CRStyle::font_stretch
enum CRFontStretch font_stretch
Definition: cr-style.h:273
BORDER_STYLE_HIDDEN
@ BORDER_STYLE_HIDDEN
Definition: cr-style.h:43
BOX_OFFSET_PROP_TOP
@ BOX_OFFSET_PROP_TOP
Definition: cr-style.h:204
_CRNum
An abstraction of a number (num) as defined in the css2 spec.
Definition: cr-num.h:90
DISPLAY_TABLE_COLUMN_GROUP
@ DISPLAY_TABLE_COLUMN_GROUP
Definition: cr-style.h:70
NUM_PROP_TOP
@ NUM_PROP_TOP
Definition: cr-style.h:151
_CRStyle::font_size
CRFontSizeVal font_size
the 'font-size' property.
Definition: cr-style.h:268
cr_style_set_props_to_initial_values
enum CRStatus cr_style_set_props_to_initial_values(CRStyle *a_this)
Sets the style properties to their initial value according to the css2 spec.
Definition: cr-style.c:1845
RGB_PROP_BORDER_BOTTOM_COLOR
@ RGB_PROP_BORDER_BOTTOM_COLOR
Definition: cr-style.h:181
cr_style_position_type_to_string
enum CRStatus cr_style_position_type_to_string(enum CRPositionType a_code, GString *a_str, guint a_nb_indent)
Definition: cr-style.c:2557
RGB_PROP_BORDER_RIGHT_COLOR
@ RGB_PROP_BORDER_RIGHT_COLOR
Definition: cr-style.h:180
_CRStyle::inherited_props_resolved
gboolean inherited_props_resolved
Definition: cr-style.h:280
cr_style_dup
CRStyle * cr_style_dup(CRStyle *a_this)
Duplicates the current instance of CRStyle .
Definition: cr-style.c:2287
_CRStyle::font_family
CRFontFamily * font_family
Definition: cr-style.h:263
BORDER_STYLE_RIDGE
@ BORDER_STYLE_RIDGE
Definition: cr-style.h:49
CRRgbProp
CRRgbProp
Definition: cr-style.h:177
BOX_OFFSET_PROP_RIGHT
@ BOX_OFFSET_PROP_RIGHT
Definition: cr-style.h:205
CRPositionType
CRPositionType
Definition: cr-style.h:77
_CRStyle::font_style
enum CRFontStyle font_style
Definition: cr-style.h:270
_CRFontSizeVal::av
CRFontSize av
Definition: cr-style.h:220
CRFontStretch
CRFontStretch
Definition: cr-fonts.h:211
WHITE_SPACE_NORMAL
@ WHITE_SPACE_NORMAL
Definition: cr-style.h:96
NUM_PROP_BORDER_LEFT
@ NUM_PROP_BORDER_LEFT
Definition: cr-style.h:164
NUM_PROP_MARGIN_TOP
@ NUM_PROP_MARGIN_TOP
Definition: cr-style.h:166
CRFontVariant
CRFontVariant
Definition: cr-fonts.h:185
cr_style_white_space_type_to_string
enum CRStatus cr_style_white_space_type_to_string(enum CRWhiteSpaceType a_code, GString *a_str, guint a_nb_indent)
Definition: cr-style.c:2619
DISPLAY_TABLE_HEADER_GROUP
@ DISPLAY_TABLE_HEADER_GROUP
Definition: cr-style.h:67
_CRRgbPropVal::sv
CRRgb sv
specified value
Definition: cr-style.h:141
_CRStyle::white_space
enum CRWhiteSpaceType white_space
the 'tex' properties
Definition: cr-style.h:278
_CRStyle
The css2 style class.
Definition: cr-style.h:230
_CRStyle::border_style_props
enum CRBorderStyle border_style_props[NB_BORDER_STYLE_PROPS]
border style properties.
Definition: cr-style.h:249
_CRRgbPropVal::cv
CRRgb cv
computed value
Definition: cr-style.h:143
_CRStyle::rgb_props
CRRgbPropVal rgb_props[NB_RGB_PROPS]
color properties.
Definition: cr-style.h:243
cr_style_resolve_inherited_properties
enum CRStatus cr_style_resolve_inherited_properties(CRStyle *a_this)
Resolves the inherited properties.
Definition: cr-style.c:1937
cr_style_unref
gboolean cr_style_unref(CRStyle *a_this)
Decreases the reference count of the current instance of CRStyle.
Definition: cr-style.c:2264
BOX_OFFSET_PROP_BOTTOM
@ BOX_OFFSET_PROP_BOTTOM
Definition: cr-style.h:206
CRNumProp
CRNumProp
Definition: cr-style.h:149
cr_style_border_style_to_string
enum CRStatus cr_style_border_style_to_string(enum CRBorderStyle a_prop, GString *a_str, guint a_nb_indent)
Definition: cr-style.c:2436
BORDER_STYLE_GROOVE
@ BORDER_STYLE_GROOVE
Definition: cr-style.h:48
cr_style_set_props_to_default_values
enum CRStatus cr_style_set_props_to_default_values(CRStyle *a_this)
Sets the style properties to their default values according to the css2 spec i.e inherit if the prope...
Definition: cr-style.c:1740
BORDER_STYLE_INSET
@ BORDER_STYLE_INSET
Definition: cr-style.h:50
cr_style_rgb_prop_val_to_string
enum CRStatus cr_style_rgb_prop_val_to_string(CRRgbPropVal *a_prop_val, GString *a_str, guint a_nb_indent)
Definition: cr-style.c:2382
CRRgb
typedefG_BEGIN_DECLS struct _CRRgb CRRgb
Definition: cr-rgb.h:34
FLOAT_LEFT
@ FLOAT_LEFT
Definition: cr-style.h:89
FLOAT_NONE
@ FLOAT_NONE
Definition: cr-style.h:88
_CRNumPropVal::av
CRNum av
actual value
Definition: cr-style.h:125
DISPLAY_TABLE_CAPTION
@ DISPLAY_TABLE_CAPTION
Definition: cr-style.h:73
DISPLAY_TABLE_ROW_GROUP
@ DISPLAY_TABLE_ROW_GROUP
Definition: cr-style.h:66
_CRFontSizeAdjust
Definition: cr-fonts.h:171
CRStyle
typedefG_BEGIN_DECLS struct _CRStyle CRStyle
Definition: cr-style.h:38
BORDER_STYLE_DOUBLE
@ BORDER_STYLE_DOUBLE
Definition: cr-style.h:47
BORDER_STYLE_INHERIT
@ BORDER_STYLE_INHERIT
Definition: cr-style.h:52
CRStatus
CRStatus
The status type returned by the methods of the croco library.
Definition: cr-utils.h:43
CRBorderStyle
CRBorderStyle
Definition: cr-style.h:40
RGB_PROP_BACKGROUND_COLOR
@ RGB_PROP_BACKGROUND_COLOR
Definition: cr-style.h:184
NUM_PROP_MARGIN_LEFT
@ NUM_PROP_MARGIN_LEFT
Definition: cr-style.h:169
_CRStyle::parent_style
CRStyle * parent_style
Definition: cr-style.h:281
cr-statement.h
cr-utils.h
BORDER_STYLE_DOTTED
@ BORDER_STYLE_DOTTED
Definition: cr-style.h:44
POSITION_FIXED
@ POSITION_FIXED
Definition: cr-style.h:82
_CRNumPropVal::cv
CRNum cv
computed value
Definition: cr-style.h:123
cr_style_display_type_to_string
enum CRStatus cr_style_display_type_to_string(enum CRDisplayType a_code, GString *a_str, guint a_nb_indent)
Definition: cr-style.c:2484
_CRStyle::font_variant
enum CRFontVariant font_variant
Definition: cr-style.h:271
DISPLAY_MARKER
@ DISPLAY_MARKER
Definition: cr-style.h:63
cr_style_set_style_from_decl
enum CRStatus cr_style_set_style_from_decl(CRStyle *a_this, CRDeclaration *a_decl)
Walks through a css2 property declaration, and populated the according field(s) in the CRStyle struct...
Definition: cr-style.c:2012
_CRStyle::display
enum CRDisplayType display
box display type
Definition: cr-style.h:252
_CRStyle::font_size_adjust
CRFontSizeAdjust * font_size_adjust
Definition: cr-style.h:269
DISPLAY_NONE
@ DISPLAY_NONE
Definition: cr-style.h:57
DISPLAY_TABLE_COLUMN
@ DISPLAY_TABLE_COLUMN
Definition: cr-style.h:71
DISPLAY_TABLE_ROW
@ DISPLAY_TABLE_ROW
Definition: cr-style.h:69
FLOAT_RIGHT
@ FLOAT_RIGHT
Definition: cr-style.h:90
_CRFontSizeVal
Definition: cr-style.h:214
POSITION_INHERIT
@ POSITION_INHERIT
Definition: cr-style.h:83
BORDER_STYLE_PROP_BOTTOM
@ BORDER_STYLE_PROP_BOTTOM
Definition: cr-style.h:195
NB_NUM_PROPS
@ NB_NUM_PROPS
Definition: cr-style.h:174
NUM_PROP_BORDER_BOTTOM
@ NUM_PROP_BORDER_BOTTOM
Definition: cr-style.h:163
_CRFontSizeVal::sv
CRFontSize sv
Definition: cr-style.h:216
CRFontStyle
CRFontStyle
Definition: cr-fonts.h:177
NUM_PROP_BOTTOM
@ NUM_PROP_BOTTOM
Definition: cr-style.h:153
WHITE_SPACE_NOWRAP
@ WHITE_SPACE_NOWRAP
Definition: cr-style.h:98
CRFloatType
CRFloatType
Definition: cr-style.h:86
_CRFontFamily
Definition: cr-fonts.h:55
NUM_PROP_BORDER_RIGHT
@ NUM_PROP_BORDER_RIGHT
Definition: cr-style.h:162
BOX_OFFSET_PROP_LEFT
@ BOX_OFFSET_PROP_LEFT
Definition: cr-style.h:207
cr_style_num_prop_val_to_string
enum CRStatus cr_style_num_prop_val_to_string(CRNumPropVal *a_prop_val, GString *a_str, guint a_nb_indent)
dump a CRNumpPropVal in a string.
Definition: cr-style.c:2328
_CRFontSize
Definition: cr-fonts.h:155