## cr-sel-eng

cr-sel-eng

## Synopsis

                        CRSelEng;
                        CRSelEngPriv;
    gboolean            (*CRPseudoClassSelectorHandler)     (CRSelEng *a_this,
                                                             CRAdditionalSel *a_add_sel,
                                                             xmlNode *a_node);
    CRSelEng *          cr_sel_eng_new                      (void);
    enum CRStatus       cr_sel_eng_register_pseudo_class_sel_handler
                                                            (CRSelEng *a_this,
                                                             guchar *a_pseudo_class_sel_name,
                                                             enum CRPseudoType a_pseudo_class_type,
                                                             CRPseudoClassSelectorHandler a_handler);
    enum CRStatus       cr_sel_eng_unregister_pseudo_class_sel_handler
                                                            (CRSelEng *a_this,
                                                             guchar *a_pseudo_class_sel_name,
                                                             enum CRPseudoType a_pseudo_class_type);
    enum CRStatus       cr_sel_eng_unregister_all_pseudo_class_sel_handlers
                                                            (CRSelEng *a_this);
    enum CRStatus       cr_sel_eng_get_pseudo_class_selector_handler
                                                            (CRSelEng *a_this,
                                                             guchar *a_pseudo_class_sel_name,
                                                             enum CRPseudoType a_pseudo_class_type,
                                                             CRPseudoClassSelectorHandler *a_handler);
    enum CRStatus       cr_sel_eng_matches_node             (CRSelEng *a_this,
                                                             CRSimpleSel *a_sel,
                                                             xmlNode *a_node,
                                                             gboolean *a_result);
    enum CRStatus       cr_sel_eng_get_matched_rulesets     (CRSelEng *a_this,
                                                             CRStyleSheet *a_sheet,
                                                             xmlNode *a_node,
                                                             CRStatement ***a_rulesets,
                                                             gulong *a_len);
    enum CRStatus       cr_sel_eng_get_matched_properties_from_cascade
                                                            (CRSelEng *a_this,
                                                             CRCascade *a_cascade,
                                                             xmlNode *a_node,
                                                             CRPropList **a_props);
    enum CRStatus       cr_sel_eng_get_matched_style        (CRSelEng *a_this,
                                                             CRCascade *a_cascade,
                                                             xmlNode *a_node,
                                                             CRStyle *a_parent_style,
                                                             CRStyle **a_style,
                                                             gboolean a_set_props_to_initial_values);
    void                cr_sel_eng_destroy                  (CRSelEng *a_this);

## Description

## Details

### CRSelEng

    typedef struct {
    	CRSelEngPriv *priv ;
    } CRSelEng;

### CRSelEngPriv

    typedef struct _CRSelEngPriv CRSelEngPriv;

### CRPseudoClassSelectorHandler ()

    gboolean            (*CRPseudoClassSelectorHandler)     (CRSelEng *a_this,
                                                             CRAdditionalSel *a_add_sel,
                                                             xmlNode *a_node);

`a_this` : |
`a_add_sel` : |
`a_node` : |
Returns : |

### cr_sel_eng_new ()

    CRSelEng *          cr_sel_eng_new                      (void);

Returns : | the newly built instance of CRSelEng of NULL if an error occurs.

### cr_sel_eng_register_pseudo_class_sel_handler ()

    enum CRStatus       cr_sel_eng_register_pseudo_class_sel_handler
                                                            (CRSelEng *a_this,
                                                             guchar *a_pseudo_class_sel_name,
                                                             enum CRPseudoType a_pseudo_class_type,
                                                             CRPseudoClassSelectorHandler a_handler);

Adds a new handler entry in the handlers entry table.

`a_this` : | the current instance of CRSelEng
`a_pseudo_class_sel_name` : | the name of the pseudo class selector.
`a_pseudo_class_type` : | the type of the pseudo class selector.
`a_handler` : | the actual handler or callback to be called during the selector evaluation process.
Returns : | CR_OK, upon successful completion, an error code otherwise.

### cr_sel_eng_unregister_pseudo_class_sel_handler ()

    enum CRStatus       cr_sel_eng_unregister_pseudo_class_sel_handler
                                                            (CRSelEng *a_this,
                                                             guchar *a_pseudo_class_sel_name,
                                                             enum CRPseudoType a_pseudo_class_type);

`a_this` : |
`a_pseudo_class_sel_name` : |
`a_pseudo_class_type` : |
Returns : |

### cr_sel_eng_unregister_all_pseudo_class_sel_handlers ()

    enum CRStatus       cr_sel_eng_unregister_all_pseudo_class_sel_handlers
                                                            (CRSelEng *a_this);

Unregisters all the pseudo class sel handlers and frees all the associated allocated datastructures.

`a_this` : | the current instance of CRSelEng .
Returns : | CR_OK upon succesful completion, an error code otherwise.

### cr_sel_eng_get_pseudo_class_selector_handler ()

    enum CRStatus       cr_sel_eng_get_pseudo_class_selector_handler
                                                            (CRSelEng *a_this,
                                                             guchar *a_pseudo_class_sel_name,
                                                             enum CRPseudoType a_pseudo_class_type,
                                                             CRPseudoClassSelectorHandler *a_handler);

`a_this` : |
`a_pseudo_class_sel_name` : |
`a_pseudo_class_type` : |
`a_handler` : |
Returns : |

### cr_sel_eng_matches_node ()

    enum CRStatus       cr_sel_eng_matches_node             (CRSelEng *a_this,
                                                             CRSimpleSel *a_sel,
                                                             xmlNode *a_node,
                                                             gboolean *a_result);

Evaluates a chained list of simple selectors (known as a css2 selector). Says wheter if this selector matches the xml node given in parameter or not.

`a_this` : | the selection engine.
`a_sel` : | the simple selector against which the xml node is going to be matched.
`a_node` : | the node against which the selector is going to be matched.
`a_result` : | out parameter. The result of the match. Is set to TRUE if the selector matches the node, FALSE otherwise. This value is considered if and only if this functions returns CR_OK.
Returns : | the CR_OK if the selection ran correctly, an error code otherwise.

### cr_sel_eng_get_matched_rulesets ()

    enum CRStatus       cr_sel_eng_get_matched_rulesets     (CRSelEng *a_this,
                                                             CRStyleSheet *a_sheet,
                                                             xmlNode *a_node,
                                                             CRStatement ***a_rulesets,
                                                             gulong *a_len);

Returns an array of pointers to selectors that matches the xml node given in parameter.

`a_this` : | the current instance of the selection engine.
`a_sheet` : | the stylesheet that holds the selectors.
`a_node` : | the xml node to consider during the walk thru the stylesheet.
`a_rulesets` : | out parameter. A pointer to an array of rulesets statement pointers. *a_rulesets is allocated by this function and must be freed by the caller. However, the caller must not alter the rulesets statements pointer because they point to statements that are still in the css stylesheet.
`a_len` : | the length of *a_ruleset.
Returns : | CR_OK upon sucessfull completion, an error code otherwise.

### cr_sel_eng_get_matched_properties_from_cascade ()

    enum CRStatus       cr_sel_eng_get_matched_properties_from_cascade
                                                            (CRSelEng *a_this,
                                                             CRCascade *a_cascade,
                                                             xmlNode *a_node,
                                                             CRPropList **a_props);

`a_this` : |
`a_cascade` : |
`a_node` : |
`a_props` : |
Returns : |

### cr_sel_eng_get_matched_style ()

    enum CRStatus       cr_sel_eng_get_matched_style        (CRSelEng *a_this,
                                                             CRCascade *a_cascade,
                                                             xmlNode *a_node,
                                                             CRStyle *a_parent_style,
                                                             CRStyle **a_style,
                                                             gboolean a_set_props_to_initial_values);

`a_this` : |
`a_cascade` : |
`a_node` : |
`a_parent_style` : |
`a_style` : |
`a_set_props_to_initial_values` : |
Returns : |

### cr_sel_eng_destroy ()

    void                cr_sel_eng_destroy                  (CRSelEng *a_this);

The destructor of CRSelEng

`a_this` : | the current instance of the selection engine.