Libcroco
Data Structures | Macros | Typedefs | Enumerations | Functions
cr-style.h File Reference
#include "cr-utils.h"
#include "cr-statement.h"
#include "cr-fonts.h"

Go to the source code of this file.

Data Structures

struct  _CRNumPropVal
 
struct  _CRRgbPropVal
 
struct  _CRFontSizeVal
 
struct  _CRStyle
 The css2 style class. More...
 

Macros

#define BORDER_THIN   2
 
#define BORDER_MEDIUM   4
 
#define BORDER_THICK   6
 

Typedefs

typedef typedefG_BEGIN_DECLS struct _CRStyle CRStyle
 
typedef struct _CRNumPropVal CRNumPropVal
 A numerical css property value. More...
 
typedef struct _CRRgbPropVal CRRgbPropVal
 An rgb css property value. More...
 
typedef struct _CRFontSizeVal CRFontSizeVal
 

Enumerations

enum  CRBorderStyle {
  BORDER_STYLE_NONE = 0, BORDER_STYLE_HIDDEN, BORDER_STYLE_DOTTED, BORDER_STYLE_DASHED,
  BORDER_STYLE_SOLID, BORDER_STYLE_DOUBLE, BORDER_STYLE_GROOVE, BORDER_STYLE_RIDGE,
  BORDER_STYLE_INSET, BORDER_STYLE_OUTSET, BORDER_STYLE_INHERIT
}
 
enum  CRDisplayType {
  DISPLAY_NONE, DISPLAY_INLINE, DISPLAY_BLOCK, DISPLAY_LIST_ITEM,
  DISPLAY_RUN_IN, DISPLAY_COMPACT, DISPLAY_MARKER, DISPLAY_TABLE,
  DISPLAY_INLINE_TABLE, DISPLAY_TABLE_ROW_GROUP, DISPLAY_TABLE_HEADER_GROUP, DISPLAY_TABLE_FOOTER_GROUP,
  DISPLAY_TABLE_ROW, DISPLAY_TABLE_COLUMN_GROUP, DISPLAY_TABLE_COLUMN, DISPLAY_TABLE_CELL,
  DISPLAY_TABLE_CAPTION, DISPLAY_INHERIT
}
 
enum  CRPositionType {
  POSITION_STATIC, POSITION_RELATIVE, POSITION_ABSOLUTE, POSITION_FIXED,
  POSITION_INHERIT
}
 
enum  CRFloatType { FLOAT_NONE, FLOAT_LEFT, FLOAT_RIGHT, FLOAT_INHERIT }
 
enum  CRWhiteSpaceType { WHITE_SPACE_NORMAL, WHITE_SPACE_PRE, WHITE_SPACE_NOWRAP, WHITE_SPACE_INHERIT }
 
enum  CRNumProp {
  NUM_PROP_TOP =0, NUM_PROP_RIGHT, NUM_PROP_BOTTOM, NUM_PROP_LEFT,
  NUM_PROP_PADDING_TOP, NUM_PROP_PADDING_RIGHT, NUM_PROP_PADDING_BOTTOM, NUM_PROP_PADDING_LEFT,
  NUM_PROP_BORDER_TOP, NUM_PROP_BORDER_RIGHT, NUM_PROP_BORDER_BOTTOM, NUM_PROP_BORDER_LEFT,
  NUM_PROP_MARGIN_TOP, NUM_PROP_MARGIN_RIGHT, NUM_PROP_MARGIN_BOTTOM, NUM_PROP_MARGIN_LEFT,
  NUM_PROP_WIDTH, NB_NUM_PROPS
}
 
enum  CRRgbProp {
  RGB_PROP_BORDER_TOP_COLOR = 0, RGB_PROP_BORDER_RIGHT_COLOR, RGB_PROP_BORDER_BOTTOM_COLOR, RGB_PROP_BORDER_LEFT_COLOR,
  RGB_PROP_COLOR, RGB_PROP_BACKGROUND_COLOR, NB_RGB_PROPS
}
 
enum  CRBorderStyleProp {
  BORDER_STYLE_PROP_TOP = 0, BORDER_STYLE_PROP_RIGHT, BORDER_STYLE_PROP_BOTTOM, BORDER_STYLE_PROP_LEFT,
  NB_BORDER_STYLE_PROPS
}
 
enum  CRBoxOffsetProp {
  BOX_OFFSET_PROP_TOP = 0, BOX_OFFSET_PROP_RIGHT, BOX_OFFSET_PROP_BOTTOM, BOX_OFFSET_PROP_LEFT,
  NB_BOX_OFFSET_PROPS
}
 

Functions

enum CRStatus cr_style_white_space_type_to_string (enum CRWhiteSpaceType a_code, GString *a_str, guint a_nb_indent)
 
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. More...
 
enum CRStatus cr_style_rgb_prop_val_to_string (CRRgbPropVal *a_prop_val, GString *a_str, guint a_nb_indent)
 
enum CRStatus cr_style_border_style_to_string (enum CRBorderStyle a_prop, GString *a_str, guint a_nb_indent)
 
enum CRStatus cr_style_display_type_to_string (enum CRDisplayType a_code, GString *a_str, guint a_nb_indent)
 
enum CRStatus cr_style_position_type_to_string (enum CRPositionType a_code, GString *a_str, guint a_nb_indent)
 
enum CRStatus cr_style_float_type_to_string (enum CRFloatType a_code, GString *a_str, guint a_nb_indent)
 
CRStylecr_style_new (gboolean a_set_props_to_initial_values)
 Default constructor of CRStyle. More...
 
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 property is inherited, its initial value otherwise. More...
 
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. More...
 
enum CRStatus cr_style_resolve_inherited_properties (CRStyle *a_this)
 Resolves the inherited properties. More...
 
enum CRStatus cr_style_propagate_from_parent (CRStyle *a_this)
 
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 structure. More...
 
enum CRStatus cr_style_copy (CRStyle *a_dest, CRStyle *a_src)
 Copies a style data structure into another. More...
 
enum CRStatus cr_style_ref (CRStyle *a_this)
 Increases the reference count of the current instance of CRStyle. More...
 
gboolean cr_style_unref (CRStyle *a_this)
 Decreases the reference count of the current instance of CRStyle. More...
 
void cr_style_destroy (CRStyle *a_this)
 Destructor of the CRStyle class. More...
 
CRStylecr_style_dup (CRStyle *a_this)
 Duplicates the current instance of CRStyle . More...
 
enum CRStatus cr_style_to_string (CRStyle *a_this, GString **a_str, guint a_nb_indent)
 Serializes in instance of CRStyle into a string. More...
 

Detailed Description

The declaration of the CRStyle class.

Definition in file cr-style.h.

Macro Definition Documentation

◆ BORDER_MEDIUM

#define BORDER_MEDIUM   4

Definition at line 104 of file cr-style.h.

◆ BORDER_THICK

#define BORDER_THICK   6

Definition at line 105 of file cr-style.h.

◆ BORDER_THIN

#define BORDER_THIN   2

Definition at line 103 of file cr-style.h.

Typedef Documentation

◆ CRFontSizeVal

typedef struct _CRFontSizeVal CRFontSizeVal

Definition at line 213 of file cr-style.h.

◆ CRNumPropVal

typedef struct _CRNumPropVal CRNumPropVal

A numerical css property value.

This data type is actually split in 3 parts: 1/the specified value 2/the computed value 3/the actual value. To understand the semantic of these three parts, see css2 spec chap 6.1 ("Specified, computed and actual values.").

Definition at line 117 of file cr-style.h.

◆ CRRgbPropVal

typedef struct _CRRgbPropVal CRRgbPropVal

An rgb css property value.

This data type is actually split in 3 parts: 1/the specified value 2/the computed value 3/the actual value. To understand the semantic of these three parts, see css2 spec chap 6.1 ("Specified, computed and actual values.").

Definition at line 137 of file cr-style.h.

◆ CRStyle

typedef typedefG_BEGIN_DECLS struct _CRStyle CRStyle

Definition at line 38 of file cr-style.h.

Enumeration Type Documentation

◆ CRBorderStyle

Enumerator
BORDER_STYLE_NONE 
BORDER_STYLE_HIDDEN 
BORDER_STYLE_DOTTED 
BORDER_STYLE_DASHED 
BORDER_STYLE_SOLID 
BORDER_STYLE_DOUBLE 
BORDER_STYLE_GROOVE 
BORDER_STYLE_RIDGE 
BORDER_STYLE_INSET 
BORDER_STYLE_OUTSET 
BORDER_STYLE_INHERIT 

Definition at line 40 of file cr-style.h.

◆ CRBorderStyleProp

Enumerator
BORDER_STYLE_PROP_TOP 
BORDER_STYLE_PROP_RIGHT 
BORDER_STYLE_PROP_BOTTOM 
BORDER_STYLE_PROP_LEFT 
NB_BORDER_STYLE_PROPS 

Definition at line 191 of file cr-style.h.

◆ CRBoxOffsetProp

Enumerator
BOX_OFFSET_PROP_TOP 
BOX_OFFSET_PROP_RIGHT 
BOX_OFFSET_PROP_BOTTOM 
BOX_OFFSET_PROP_LEFT 
NB_BOX_OFFSET_PROPS 

Definition at line 202 of file cr-style.h.

◆ CRDisplayType

Enumerator
DISPLAY_NONE 
DISPLAY_INLINE 
DISPLAY_BLOCK 
DISPLAY_LIST_ITEM 
DISPLAY_RUN_IN 
DISPLAY_COMPACT 
DISPLAY_MARKER 
DISPLAY_TABLE 
DISPLAY_INLINE_TABLE 
DISPLAY_TABLE_ROW_GROUP 
DISPLAY_TABLE_HEADER_GROUP 
DISPLAY_TABLE_FOOTER_GROUP 
DISPLAY_TABLE_ROW 
DISPLAY_TABLE_COLUMN_GROUP 
DISPLAY_TABLE_COLUMN 
DISPLAY_TABLE_CELL 
DISPLAY_TABLE_CAPTION 
DISPLAY_INHERIT 

Definition at line 55 of file cr-style.h.

◆ CRFloatType

Enumerator
FLOAT_NONE 
FLOAT_LEFT 
FLOAT_RIGHT 
FLOAT_INHERIT 

Definition at line 86 of file cr-style.h.

◆ CRNumProp

enum CRNumProp
Enumerator
NUM_PROP_TOP 
NUM_PROP_RIGHT 
NUM_PROP_BOTTOM 
NUM_PROP_LEFT 
NUM_PROP_PADDING_TOP 
NUM_PROP_PADDING_RIGHT 
NUM_PROP_PADDING_BOTTOM 
NUM_PROP_PADDING_LEFT 
NUM_PROP_BORDER_TOP 
NUM_PROP_BORDER_RIGHT 
NUM_PROP_BORDER_BOTTOM 
NUM_PROP_BORDER_LEFT 
NUM_PROP_MARGIN_TOP 
NUM_PROP_MARGIN_RIGHT 
NUM_PROP_MARGIN_BOTTOM 
NUM_PROP_MARGIN_LEFT 
NUM_PROP_WIDTH 
NB_NUM_PROPS 

Definition at line 149 of file cr-style.h.

◆ CRPositionType

Enumerator
POSITION_STATIC 
POSITION_RELATIVE 
POSITION_ABSOLUTE 
POSITION_FIXED 
POSITION_INHERIT 

Definition at line 77 of file cr-style.h.

◆ CRRgbProp

enum CRRgbProp
Enumerator
RGB_PROP_BORDER_TOP_COLOR 
RGB_PROP_BORDER_RIGHT_COLOR 
RGB_PROP_BORDER_BOTTOM_COLOR 
RGB_PROP_BORDER_LEFT_COLOR 
RGB_PROP_COLOR 
RGB_PROP_BACKGROUND_COLOR 
NB_RGB_PROPS 

Definition at line 177 of file cr-style.h.

◆ CRWhiteSpaceType

Enumerator
WHITE_SPACE_NORMAL 
WHITE_SPACE_PRE 
WHITE_SPACE_NOWRAP 
WHITE_SPACE_INHERIT 

Definition at line 94 of file cr-style.h.

Function Documentation

◆ 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 
)

◆ cr_style_copy()

enum CRStatus cr_style_copy ( CRStyle a_dest,
CRStyle a_src 
)

Copies a style data structure into another.

TODO: this is actually broken because it's based on memcpy although some data stuctures of CRStyle should be properly duplicated.

Parameters
a_destthe destination style datastructure
a_srcthe source style datastructure.
Returns
CR_OK upon succesfull completion, an error code otherwise

Definition at line 2312 of file cr-style.c.

References CR_BAD_PARAM_ERROR, and CR_OK.

Referenced by cr_style_dup().

◆ cr_style_destroy()

void cr_style_destroy ( CRStyle a_this)

Destructor of the CRStyle class.

Parameters
a_thisthe instance to destroy.

Definition at line 2845 of file cr-style.c.

Referenced by cr_style_unref().

◆ 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 
)

◆ cr_style_dup()

CRStyle* cr_style_dup ( CRStyle a_this)

Duplicates the current instance of CRStyle .

The newly created instance of CRStyle must be freed using cr_style_destroy ().

Parameters
a_thisthe current instance of CRStyle.
Returns
the newly duplicated instance of CRStyle.

Definition at line 2287 of file cr-style.c.

References cr_style_copy(), cr_style_new(), and cr_utils_trace_info.

◆ 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 
)

◆ cr_style_new()

CRStyle* cr_style_new ( gboolean  a_set_props_to_initial_values)

Default constructor of CRStyle.

Parameters
a_set_props_to_initial_valuesif TRUE, the style properties will be set to the default values. Only the style properties of the root box should be set to their initial values. Otherwise, the style values are set to their default value. Read the CSS2 spec, chapters 6.1.1 to 6.2.

Definition at line 1712 of file cr-style.c.

References cr_utils_trace_info.

Referenced by cr_sel_eng_get_matched_style(), and cr_style_dup().

◆ 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.

Parameters
a_prop_valthe numerical property value to dump
a_strthe string to dump the numerical propertie into. Note that the string value is appended to a_str.
a_nb_indentthe number white chars of indentation.

Definition at line 2328 of file cr-style.c.

References _CRNumPropVal::av, CR_BAD_PARAM_ERROR, CR_ERROR, cr_num_to_string(), CR_OK, cr_utils_dump_n_chars2(), _CRNumPropVal::cv, and _CRNumPropVal::sv.

◆ 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 
)

◆ cr_style_propagate_from_parent()

enum CRStatus cr_style_propagate_from_parent ( CRStyle a_this)

◆ cr_style_ref()

enum CRStatus cr_style_ref ( CRStyle a_this)

Increases the reference count of the current instance of CRStyle.

Parameters
a_thisthe current instance of CRStyle.
Returns
CR_OK upon successfull completion, an error code otherwise.

Definition at line 2246 of file cr-style.c.

References CR_BAD_PARAM_ERROR, and CR_OK.

◆ cr_style_resolve_inherited_properties()

enum CRStatus cr_style_resolve_inherited_properties ( CRStyle a_this)

Resolves the inherited properties.

The function sets the "inherited" properties to either the value of their parent properties. This function is NOT recursive. So the inherited properties of the parent style must have been resolved prior to calling this function.

Parameters
a_thisthe instance where
Returns
CR_OK if a root node is found and the propagation is successful, an error code otherwise

Definition at line 1937 of file cr-style.c.

References BORDER_STYLE_INHERIT, CR_BAD_PARAM_ERROR, cr_font_size_copy(), cr_num_copy(), CR_OK, cr_rgb_copy(), cr_rgb_is_set_to_inherit(), DISPLAY_INHERIT, FLOAT_INHERIT, FONT_STRETCH_INHERIT, FONT_STYLE_INHERIT, FONT_VARIANT_INHERIT, FONT_WEIGHT_INHERIT, INHERITED_FONT_SIZE, NB_BORDER_STYLE_PROPS, NB_NUM_PROPS, NB_RGB_PROPS, NUM_INHERIT, and POSITION_INHERIT.

◆ 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 
)

◆ cr_style_set_props_to_default_values()

enum CRStatus cr_style_set_props_to_default_values ( CRStyle a_this)

◆ 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.

This function should be used to initialize the style of the root element of an xml tree. Some properties are user agent dependant like font-family, and are not initialized, read the spec to make you renderer compliant.

Parameters
a_thisthe current instance of CRStyle.
Returns
CR_OK upon successfull completion, an error code otherwise.

Definition at line 1845 of file cr-style.c.

References BORDER_STYLE_NONE, CR_BAD_PARAM_ERROR, cr_font_size_set_predefined_absolute_font_size(), cr_num_set(), CR_OK, cr_rgb_set(), cr_rgb_set_to_transparent(), cr_utils_trace_info, DISPLAY_BLOCK, FLOAT_NONE, FONT_SIZE_MEDIUM, FONT_STRETCH_NORMAL, FONT_STYLE_NORMAL, FONT_VARIANT_NORMAL, FONT_WEIGHT_NORMAL, NB_BORDER_STYLE_PROPS, NB_NUM_PROPS, NB_RGB_PROPS, NUM_AUTO, NUM_LENGTH_PX, NUM_PROP_BORDER_BOTTOM, NUM_PROP_BORDER_LEFT, NUM_PROP_BORDER_RIGHT, NUM_PROP_BORDER_TOP, NUM_PROP_BOTTOM, NUM_PROP_LEFT, NUM_PROP_MARGIN_BOTTOM, NUM_PROP_MARGIN_LEFT, NUM_PROP_MARGIN_RIGHT, NUM_PROP_MARGIN_TOP, NUM_PROP_PADDING_BOTTOM, NUM_PROP_PADDING_LEFT, NUM_PROP_PADDING_RIGHT, NUM_PROP_PADDING_TOP, NUM_PROP_RIGHT, NUM_PROP_TOP, NUM_PROP_WIDTH, POSITION_STATIC, RGB_PROP_BACKGROUND_COLOR, RGB_PROP_COLOR, and WHITE_SPACE_NORMAL.

Referenced by cr_sel_eng_get_matched_style().

◆ 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 structure.

If the properties or their value(s) are/is not known, sets the corresponding field(s) of CRStyle to its/their default value(s)

Parameters
a_thisthe instance of CRStyle to set.
a_declthe declaration from which the CRStyle fields are set.
Returns
CR_OK upon successfull completion, an error code otherwise.

Definition at line 2012 of file cr-style.c.

References CR_BAD_PARAM_ERROR, CR_OK, PROP_ID_NOT_KNOWN, and _CRDeclaration::property.

◆ 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.

Parameters
a_thisthe instance of CRStyle to serialize
a_strthe string to serialise the style into. if *a_str is NULL, a new GString is instanciated, otherwise the style serialisation is appended to the existed *a_str
thenumber of white space char to use for indentation.
Returns
CR_OK upon successful completion, an error code otherwise.

Definition at line 2659 of file cr-style.c.

References CR_BAD_PARAM_ERROR, cr_utils_dump_n_chars2(), NB_NUM_PROPS, and NUM_PROP_TOP.

◆ cr_style_unref()

gboolean cr_style_unref ( CRStyle a_this)

Decreases the reference count of the current instance of CRStyle.

If the reference count reaches 0, the instance of CRStyle is destoyed.

Parameters
a_thisthe current instance of CRStyle.
Returns
TRUE if the instance has been destroyed, FALSE otherwise.

Definition at line 2264 of file cr-style.c.

References cr_style_destroy().

◆ 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 
)