diff options
Diffstat (limited to 'src')
-rw-r--r-- | src/Makefile.am | 5 | ||||
-rw-r--r-- | src/cr-prop-list.c | 350 | ||||
-rw-r--r-- | src/cr-prop-list.h | 71 | ||||
-rw-r--r-- | src/cr-sel-eng.c | 299 | ||||
-rw-r--r-- | src/cr-sel-eng.h | 20 | ||||
-rw-r--r-- | src/cr-style.c | 4 | ||||
-rw-r--r-- | src/cr-utils.h | 7 | ||||
-rw-r--r-- | src/libcroco.h | 1 |
8 files changed, 743 insertions, 14 deletions
diff --git a/src/Makefile.am b/src/Makefile.am index 5b82d21..ee4d2c9 100644 --- a/src/Makefile.am +++ b/src/Makefile.am @@ -24,6 +24,7 @@ cr-utils.h \ cr-fonts.h \ cr-sel-eng.h \ cr-style.h \ +cr-prop-list.h \ libcroco-config.h @@ -74,7 +75,9 @@ cr-style.h \ cr-sel-eng.c \ cr-sel-eng.h \ cr-fonts.c \ -cr-fonts.h +cr-fonts.h \ +cr-prop-list.c \ +cr-prop-list.h lib_LTLIBRARIES=libcroco.la libcroco_la_SOURCES= $(SRCS) diff --git a/src/cr-prop-list.c b/src/cr-prop-list.c new file mode 100644 index 0000000..d910a7b --- /dev/null +++ b/src/cr-prop-list.c @@ -0,0 +1,350 @@ +/* + * This file is part of The Croco Library + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of version 2.1 of the GNU Lesser General Public + * License as published by the Free Software Foundation. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 + * USA + * + * See COPYRIGHTS file for copyrights information. + */ + +#include <string.h> +#include "cr-prop-list.h" + +#define PRIVATE(a_obj) (a_obj)->priv + +struct _CRPropListPriv +{ + GString *prop ; + CRDeclaration *decl ; + CRPropList *next ; + CRPropList *prev ; +}; + +static CRPropList * +cr_prop_list_allocate (void) ; + +/** + *Default allocator of CRPropList + *@return the newly allocated CRPropList or NULL + *if an error arises. + */ +static CRPropList * +cr_prop_list_allocate (void) +{ + CRPropList *result = NULL; + + result = g_try_malloc (sizeof (CRPropList)) ; + if (!result) + { + cr_utils_trace_info ("could not allocate CRPropList") ; + return NULL ; + } + memset (result, 0, sizeof (CRPropList)) ; + PRIVATE (result) = g_try_malloc (sizeof (CRPropListPriv)) ; + if (!result) + { + cr_utils_trace_info ("could not allocate CRPropListPriv") ; + g_free (result) ; + return NULL ; + } + memset (PRIVATE (result), 0, sizeof (CRPropListPriv)) ; + return result ; +} + + +/**************** + *public methods + ***************/ + +/** + *Appends a property list to the current one. + *@param a_this the current instance of #CRPropList + *@param a_to_append the property list to append + *@return the resulting prop list, or NULL if an error + *occured + */ +CRPropList * +cr_prop_list_append (CRPropList *a_this, + CRPropList *a_to_append) +{ + CRPropList *cur=NULL ; + + g_return_val_if_fail (a_to_append, NULL) ; + + if (!a_this) + return a_to_append ; + + /*go fetch the last element of the list*/ + for (cur = a_this ; + cur && PRIVATE (cur) && PRIVATE (cur)->next ; + cur = PRIVATE (cur)->next) + ; + g_return_val_if_fail (cur, NULL) ; + PRIVATE (cur)->next = a_to_append ; + PRIVATE (a_to_append)->prev = cur ; + return a_this ; +} + + +/** + *appends a pair of prop/declaration to + *the current prop list. + *@param a_this the current instance of #CRPropList + *@param a_prop the property to consider + *@param a_decl the declaration to consider + *@return the resulting property list, or NULL in case + *of an error. + */ +CRPropList * +cr_prop_list_append2 (CRPropList *a_this, + GString *a_prop, + CRDeclaration *a_decl) +{ + CRPropList *list = NULL, *result = NULL ; + + g_return_val_if_fail (a_prop && a_decl, + NULL) ; + + list = cr_prop_list_allocate () ; + g_return_val_if_fail (list && PRIVATE (list), NULL) ; + + PRIVATE (list)->prop = a_prop ; + PRIVATE (list)->decl = a_decl ; + + result = cr_prop_list_append (a_this, list) ; + return result ; +} + +/** + *Prepends a list to the current list + *@param a_this the current instance of #CRPropList + *@param the new list to prepend. + */ +CRPropList * +cr_prop_list_prepend (CRPropList *a_this, + CRPropList *a_to_prepend) +{ + CRPropList *cur = NULL ; + + g_return_val_if_fail (a_to_prepend, NULL) ; + + if (!a_this) + return a_to_prepend ; + + for (cur = a_to_prepend; cur && PRIVATE (cur)->next ; + cur = PRIVATE (cur)->next) + ; + g_return_val_if_fail (cur, NULL) ; + PRIVATE (cur)->next = a_this ; + PRIVATE (a_this)->prev = cur ; + return a_to_prepend ; +} + +/** + *Prepends a list to the current list + *@param a_this the current instance of #CRPropList + *@param the new list to prepend. + */ +CRPropList * +cr_prop_list_prepend2 (CRPropList *a_this, + GString *a_prop, + CRDeclaration *a_decl) +{ + CRPropList *list = NULL, *result = NULL ; + + g_return_val_if_fail (a_this + && PRIVATE (a_this) + && a_prop && a_decl, NULL) ; + + list = cr_prop_list_allocate () ; + g_return_val_if_fail (list, NULL) ; + PRIVATE (list)->prop = a_prop ; + PRIVATE (list)->decl = a_decl ; + result = cr_prop_list_prepend (a_this, list) ; + return result ; +} + +/** + *sets the property of a CRPropList + *@param a_this the current instance of #CRPropList + *@param a_prop the property to set + */ +enum CRStatus +cr_prop_list_set_prop (CRPropList *a_this, + GString *a_prop) +{ + g_return_val_if_fail (a_this + && PRIVATE (a_this) + && a_prop, CR_BAD_PARAM_ERROR) ; + + PRIVATE (a_this)->prop = a_prop ; + return CR_OK ; +} + + +/** + *Getter of the property associated to the current instance + *of #CRpropList + *@param a_this the current instance of #CRPropList + *@param a_prop out parameter. The returned property + *@return CR_OK upon sucessful completion, an error code + *otherwise. + */ +enum CRStatus +cr_prop_list_get_prop (CRPropList *a_this, + GString **a_prop) +{ + g_return_val_if_fail (a_this + && PRIVATE (a_this) + && a_prop, + CR_BAD_PARAM_ERROR) ; + + *a_prop = PRIVATE (a_this)->prop ; + return CR_OK ; +} + +enum CRStatus +cr_prop_list_set_decl (CRPropList *a_this, + CRDeclaration *a_decl) +{ + g_return_val_if_fail (a_this + && PRIVATE (a_this) + && a_decl, + CR_BAD_PARAM_ERROR) ; + + PRIVATE (a_this)->decl =a_decl ; + return CR_OK ; +} + + +enum CRStatus +cr_prop_list_get_decl (CRPropList *a_this, + CRDeclaration **a_decl) +{ + g_return_val_if_fail (a_this + && PRIVATE (a_this) + && a_decl, + CR_BAD_PARAM_ERROR) ; + + *a_decl = PRIVATE (a_this)->decl ; + return CR_OK ; +} + +/** + *Lookup a given property/declaration pair + *@param a_this the current instance of #CRPropList + *@param a_prop the property to lookup + *@param a_prop_list out parameter. The property/declaration + *pair found (if and only if the function returned code if CR_OK) + *@return CR_OK upon if a prop/decl pair has been found, + *CR_VALUE_NOT_FOUND_ERROR if not, or an error code if something + *bad happens. + */ +enum CRStatus +cr_prop_list_lookup_prop (CRPropList *a_this, + GString *a_prop, + CRPropList **a_pair) +{ + CRPropList *cur = NULL ; + + g_return_val_if_fail (a_prop && a_pair, + CR_BAD_PARAM_ERROR) ; + + if (!a_this) + return CR_VALUE_NOT_FOUND_ERROR ; + + g_return_val_if_fail (PRIVATE (a_this), CR_BAD_PARAM_ERROR) ; + + for (cur = a_this ; cur ; + cur = PRIVATE (cur)->next) + { + if (PRIVATE (cur)->prop + && PRIVATE (cur)->prop->str + && a_prop->str + && ! strcmp (PRIVATE (cur)->prop->str, + a_prop->str)) + break ; + } + + if (cur) + { + *a_pair = cur ; + return CR_OK ; + } + + return CR_VALUE_NOT_FOUND_ERROR ; +} + + +/** + *Gets the next prop/decl pair in the list + *@param a_this the current instance of CRPropList + *@param the next prop/decl pair, or NULL if we + *reached the end of the list. + *@return the next prop/declaration pair of the list, + *or NULL if we reached end of list (or if an error occurs) + */ +CRPropList * +cr_prop_list_get_next (CRPropList *a_this) +{ + g_return_val_if_fail (a_this && PRIVATE (a_this), + NULL) ; + + return PRIVATE (a_this)->next ; +} + +/** + *Gets the previous prop/decl pair in the list + *@param a_this the current instance of CRPropList + *@param the previous prop/decl pair, or NULL if we + *reached the end of the list. + *@return the previous prop/declaration pair of the list, + *or NULL if we reached end of list (or if an error occurs) + */ +CRPropList * +cr_prop_list_get_prev (CRPropList *a_this) +{ + g_return_val_if_fail (a_this && PRIVATE (a_this), + NULL) ; + + return PRIVATE (a_this)->prev ; +} + +void +cr_prop_list_destroy (CRPropList *a_this) +{ + CRPropList *tail = NULL, *cur = NULL ; + + g_return_if_fail (a_this && PRIVATE (a_this)) ; + + for (tail = a_this ; + tail && PRIVATE (tail) && PRIVATE (tail)->next; + tail = cr_prop_list_get_next (tail)) + ; + g_return_if_fail (tail) ; + + cur = tail ; + + while (cur) + { + tail = PRIVATE (cur)->prev ; + if (tail && PRIVATE (tail)) + PRIVATE (tail)->next = NULL ; + PRIVATE (cur)->prev = NULL ; + g_free (PRIVATE (cur)) ; + PRIVATE (cur) = NULL ; + g_free (cur) ; + cur = tail ; + } +} diff --git a/src/cr-prop-list.h b/src/cr-prop-list.h new file mode 100644 index 0000000..4efec0a --- /dev/null +++ b/src/cr-prop-list.h @@ -0,0 +1,71 @@ +/* + * This file is part of The Croco Library + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of version 2.1 of the GNU Lesser General Public + * License as published by the Free Software Foundation. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 + * USA + * + * See COPYRIGHTS file for copyrights information. + */ + +#ifndef __CR_PROP_LIST_H__ +#define __CR_PROP_LIST_H__ + +#include "cr-utils.h" +#include "cr-declaration.h" + +typedef struct _CRPropList CRPropList ; +typedef struct _CRPropListPriv CRPropListPriv ; + +struct _CRPropList +{ + CRPropListPriv * priv; +} ; + +CRPropList * cr_prop_list_append (CRPropList *a_this, + CRPropList *a_to_append) ; + +CRPropList * cr_prop_list_append2 (CRPropList *a_this, + GString *a_prop, + CRDeclaration *a_decl) ; + +CRPropList * cr_prop_list_prepend (CRPropList *a_this, + CRPropList *a_to_append) ; + +CRPropList * cr_prop_list_prepend2 (CRPropList *a_this, + GString *a_prop, + CRDeclaration *a_decl) ; + +enum CRStatus cr_prop_list_set_prop (CRPropList *a_this, + GString *a_prop) ; + +enum CRStatus cr_prop_list_get_prop (CRPropList *a_this, + GString **a_prop) ; + +enum CRStatus cr_prop_list_lookup_prop (CRPropList *a_this, + GString *a_prop, + CRPropList**a_pair) ; + +CRPropList * cr_prop_list_get_next (CRPropList *a_this) ; + +CRPropList * cr_prop_list_get_prev (CRPropList *a_this) ; + +enum CRStatus cr_prop_list_set_decl (CRPropList *a_this, + CRDeclaration *a_decl); + +enum CRStatus cr_prop_list_get_decl (CRPropList *a_this, + CRDeclaration **a_decl) ; + +void cr_prop_list_destroy (CRPropList *a_this) ; + +#endif /*__CR_PROP_LIST_H__*/ diff --git a/src/cr-sel-eng.c b/src/cr-sel-eng.c index 9896781..e365590 100644 --- a/src/cr-sel-eng.c +++ b/src/cr-sel-eng.c @@ -3,8 +3,6 @@ /* * This file is part of The Croco Library * - * Copyright (C) 2002-2003 Dodji Seketeli <dodji at seketeli.org> - * * This program is free software; you can redistribute it and/or * modify it under the terms of version 2.1 of the GNU Lesser General Public * License as published by the Free Software Foundation. @@ -19,12 +17,15 @@ * along with this program; if not, write to the Free Software * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 * USA + * + * See COPYRIGHTS file for copyright informations. */ #include <string.h> #include "cr-sel-eng.h" + /** *@file: *The definition of the #CRSelEng class. @@ -77,11 +78,17 @@ static enum CRStatus cr_sel_eng_get_matched_rulesets_real (CRSelEng *a_this, CRStatement **a_rulesets, gulong *a_len) ; +#ifndef NEW_PROPERTIES_GETTER static enum CRStatus put_css_properties_in_hashtable (GHashTable **a_props_hashtable, CRStatement *a_ruleset) ; - static void set_style_from_props_hash_hr_func (gpointer a_prop, gpointer a_decl, gpointer a_style) ; +#else +static enum CRStatus put_css_properties_in_props_list (CRPropList **a_props, + CRStatement *a_ruleset) ; +#endif + + static gboolean pseudo_class_add_sel_matches_node (CRSelEng * a_this, CRAdditionalSel *a_add_sel, @@ -927,6 +934,8 @@ cr_sel_eng_get_matched_rulesets_real (CRSelEng *a_this, return CR_OK ; } + +#ifndef NEW_PROPERTIES_GETTER /** *Walks through the property/value pairs of a ruleset *statement and put the properties found into a hashtable. @@ -1049,8 +1058,6 @@ put_css_properties_in_hashtable (GHashTable **a_props_hashtable, cur_decl) ; } } - - return CR_OK ; } @@ -1065,6 +1072,136 @@ set_style_from_props_hash_hr_func (gpointer a_prop, gpointer a_decl, cr_style_set_style_from_decl (style, decl) ; } +#else +static enum CRStatus +put_css_properties_in_props_list (CRPropList **a_props, + CRStatement *a_stmt) +{ + CRPropList *props = NULL, *pair = NULL, *tmp_props = NULL ; + CRDeclaration *cur_decl = NULL ; + + g_return_val_if_fail (a_props && a_stmt + && a_stmt->type == RULESET_STMT + && a_stmt->kind.ruleset, + CR_BAD_PARAM_ERROR) ; + + props = *a_props ; + + for (cur_decl = a_stmt->kind.ruleset->decl_list ; + cur_decl ; cur_decl = cur_decl->next) + { + CRDeclaration *decl = NULL ; + + if (!cur_decl->property || !cur_decl->property->str) + continue ; + /* + *First, test if the property is not + *already present in our properties list + *If yes, apply the cascading rules to + *compute the precedence. If not, insert + *the property into the list + */ + cr_prop_list_lookup_prop + (props, cur_decl->property, + &pair) ; + + if (!pair) + { + tmp_props = cr_prop_list_append2 + (props, + cur_decl->property, + cur_decl) ; + if (tmp_props) + { + props = tmp_props ; + tmp_props = NULL ; + } + continue ; + } + + /* + *A property with the same name already exists. + *We must apply here + *some cascading rules + *to compute the precedence. + */ + cr_prop_list_get_decl (pair, &decl) ; + g_return_val_if_fail (decl, CR_ERROR) ; + + /* + *first, look at the origin. + *6.4.1 says: + *"for normal declarations, + *author style sheets override user + *style sheets which override + *the default style sheet." + */ + if (decl->parent_statement + && decl->parent_statement->parent_sheet + && (decl->parent_statement->parent_sheet->origin + < + a_stmt->parent_sheet->origin)) + { + cr_prop_list_set_prop (pair, + cur_decl->property) ; + cr_prop_list_set_decl (pair, + cur_decl) ; + continue ; + } + else if (decl->parent_statement + && decl->parent_statement->parent_sheet + && (decl->parent_statement-> + parent_sheet->origin + > + a_stmt->parent_sheet->origin)) + { + /*TODO: support !important rule.*/ + continue ; + } + + /* + *A property with the same + *name and the same origin already exists. + *shit. This is lasting longer than expected ... + *Luckily, the spec says in 6.4.1: + *"more specific selectors will override + *more general ones" + *and + *"if two rules have the same weight, + *origin and specificity, + *the later specified wins" + */ + if (a_stmt->specificity + >= decl->parent_statement->specificity) + { + + cr_prop_list_set_prop (pair, + cur_decl->property) ; + cr_prop_list_set_decl (pair, + cur_decl) ; + } + } + /*TODO: this may leak. Check this out*/ + *a_props = props ; + + return CR_OK ; +} + +static void +set_style_from_props (CRStyle *a_style, CRPropList *a_props) +{ + CRPropList *cur = NULL ; + CRDeclaration *decl = NULL; + + for (cur = a_props ; cur ; + cur = cr_prop_list_get_next (cur)) + { + cr_prop_list_get_decl (cur, &decl) ; + cr_style_set_style_from_decl (a_style, decl) ; + decl = NULL ; + } +} +#endif /**************************************** *PUBLIC METHODS @@ -1380,6 +1517,7 @@ cr_sel_eng_get_matched_rulesets (CRSelEng *a_this, return status ; } +#ifndef NEW_PROPERTIES_GETTER enum CRStatus cr_sel_eng_get_matched_properties_from_cascade (CRSelEng *a_this, CRCascade *a_cascade, @@ -1452,6 +1590,7 @@ cr_sel_eng_get_matched_properties_from_cascade (CRSelEng *a_this, goto error ; } index += tab_len ; + tab_len = tab_size - index ; } /* @@ -1494,6 +1633,121 @@ cr_sel_eng_get_matched_properties_from_cascade (CRSelEng *a_this, return status ; } +#else +enum CRStatus +cr_sel_eng_get_matched_properties_from_cascade (CRSelEng *a_this, + CRCascade *a_cascade, + xmlNode *a_node, + CRPropList **a_props) +{ + CRStatement ** stmts_tab = NULL ; + enum CRStatus status = CR_OK ; + gulong tab_size = 0, tab_len = 0, i = 0, index = 0; + enum CRStyleOrigin origin = 0 ; + gushort stmts_chunck_size = 8 ; + CRStyleSheet *sheet = NULL ; + + g_return_val_if_fail (a_this + && a_cascade + && a_node + && a_props, + CR_BAD_PARAM_ERROR) ; + + for (origin = ORIGIN_UA ; origin < NB_ORIGINS ; origin++) + { + sheet = cr_cascade_get_sheet (a_cascade, origin) ; + if (!sheet) + continue ; + if (tab_size - index < 1) + { + stmts_tab = g_try_realloc + (stmts_tab, + (tab_size + stmts_chunck_size) + * sizeof (CRStatement*)) ; + if (!stmts_tab) + { + cr_utils_trace_info ("Out of memory") ; + status = CR_ERROR ; + goto error ; + } + tab_size += stmts_chunck_size ; + /* + *compute the max size left for + *cr_sel_eng_get_matched_rulesets_real()'s output tab + */ + tab_len = tab_size - index ; + } + while ((status = cr_sel_eng_get_matched_rulesets_real + (a_this, sheet, a_node, stmts_tab + index, &tab_len)) + == CR_OUTPUT_TOO_SHORT_ERROR) + { + stmts_tab = g_try_realloc + (stmts_tab, + (tab_size + stmts_chunck_size) + * sizeof (CRStatement*)) ; + if (!stmts_tab) + { + cr_utils_trace_info ("Out of memory") ; + status = CR_ERROR ; + goto error ; + } + tab_size += stmts_chunck_size ; + index += tab_len ; + /* + *compute the max size left for + *cr_sel_eng_get_matched_rulesets_real()'s output tab + */ + tab_len = tab_size - index ; + } + if (status != CR_OK) + { + cr_utils_trace_info ("Error while running " + "selector engine") ; + goto error ; + } + index += tab_len ; + tab_len = tab_size - index ; + } + + /* + *TODO, walk down the stmts_tab and build the + *property_name/declaration hashtable. + *Make sure one can walk from the declaration to + *the stylesheet. + */ + for (i = 0 ; i < index ; i ++) + { + CRStatement *stmt = stmts_tab[i] ; + + if (!stmt) + continue ; + switch (stmt->type) + { + case RULESET_STMT: + if (!stmt->parent_sheet) + continue ; + status = put_css_properties_in_props_list + (a_props, stmt) ; + break ; + default: + break ; + } + + } + + return CR_OK ; + error: + + if (stmts_tab) + { + g_free (stmts_tab) ; + stmts_tab = NULL ; + + } + + return status ; +} +#endif enum CRStatus cr_sel_eng_get_matched_style (CRSelEng *a_this, @@ -1503,16 +1757,26 @@ cr_sel_eng_get_matched_style (CRSelEng *a_this, CRStyle **a_style) { enum CRStatus status = CR_OK ; +#ifndef NEW_PROPERTIES_GETTER GHashTable *props_hash = NULL ; +#else + CRPropList *props = NULL ; +#endif g_return_val_if_fail (a_this && a_cascade && a_node && a_style, CR_BAD_PARAM_ERROR) ; - +#ifndef NEW_PROPERTIES_GETTER status = cr_sel_eng_get_matched_properties_from_cascade (a_this, a_cascade, a_node, &props_hash) ; +#else + status = cr_sel_eng_get_matched_properties_from_cascade + (a_this, a_cascade, a_node, &props) ; +#endif g_return_val_if_fail (status == CR_OK, status) ; + +#ifndef NEW_PROPERTIES_GETTER if (props_hash && g_hash_table_size (props_hash)) { @@ -1537,7 +1801,30 @@ cr_sel_eng_get_matched_style (CRSelEng *a_this, g_hash_table_destroy (props_hash) ; props_hash = NULL ; } +#else + if (props) + { + + if (!*a_style) + { + *a_style = cr_style_new () ; + g_return_val_if_fail (*a_style, CR_ERROR) ; + } + else + { + cr_style_set_props_to_defaults (*a_style) ; + } + (*a_style)->parent_style = a_parent_style ; + + set_style_from_props (*a_style, props) ; + if (props) + { + cr_prop_list_destroy (props) ; + props = NULL ; + } + } +#endif return CR_OK ; } diff --git a/src/cr-sel-eng.h b/src/cr-sel-eng.h index b650df0..c6b30f0 100644 --- a/src/cr-sel-eng.h +++ b/src/cr-sel-eng.h @@ -3,8 +3,6 @@ /* * This file is part of The Croco Library * - * Copyright (C) 2002-2003 Dodji Seketeli <dodji@seketeli.org> - * * This program is free software; you can redistribute it and/or * modify it under the terms of version 2.1 of the GNU Lesser General Public * License as published by the Free Software Foundation. @@ -18,20 +16,29 @@ * along with this program; if not, write to the Free Software * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 * USA + * + * See COPYRIGHTS file for copyrights information. */ #ifndef __CR_SEL_ENG_H__ #define __CR_SEL_ENG_H__ +#define NEW_PROPERTIES_GETTER 1 + #include "cr-utils.h" #include "cr-stylesheet.h" #include "cr-cascade.h" #include "cr-style.h" +#ifdef NEW_PROPERTIES_GETTER +#include "cr-prop-list.h" +#endif #ifdef CROCO_HAVE_LIBXML2 #include <libxml/tree.h> #endif + + /** *@file: *The declaration of the #CRSelEng class. @@ -56,6 +63,7 @@ struct _CRSelEng CRSelEngPriv *priv ; } ; + typedef gboolean (*CRPseudoClassSelectorHandler) (CRSelEng* a_this, CRAdditionalSel *a_add_sel, xmlNode *a_node) ; @@ -88,10 +96,18 @@ enum CRStatus cr_sel_eng_get_matched_rulesets (CRSelEng *a_this, CRStatement ***a_rulesets, gulong *a_len) ; +#ifndef NEW_PROPERTIES_GETTER enum CRStatus cr_sel_eng_get_matched_properties_from_cascade (CRSelEng *a_this, CRCascade *a_cascade, xmlNode *a_node, GHashTable **props_decls_dict) ; +#else +enum CRStatus +cr_sel_eng_get_matched_properties_from_cascade (CRSelEng *a_this, + CRCascade *a_cascade, + xmlNode *a_node, + CRPropList **a_props) ; +#endif enum CRStatus cr_sel_eng_get_matched_style (CRSelEng *a_this, CRCascade *a_cascade, diff --git a/src/cr-style.c b/src/cr-style.c index f10e674..760dfa4 100644 --- a/src/cr-style.c +++ b/src/cr-style.c @@ -2127,7 +2127,7 @@ cr_style_set_style_from_decl (CRStyle *a_this, CRDeclaration *a_decl) case PROP_ID_BORDER_RIGHT: status = set_prop_border_x_from_value (a_this, value, - DIR_TOP) ; + DIR_RIGHT) ; break ; case PROP_ID_BORDER_BOTTOM: @@ -2139,7 +2139,7 @@ cr_style_set_style_from_decl (CRStyle *a_this, CRDeclaration *a_decl) case PROP_ID_BORDER_LEFT: status = set_prop_border_x_from_value (a_this, value, - DIR_BOTTOM) ; + DIR_LEFT) ; break ; case PROP_ID_MARGIN_TOP: diff --git a/src/cr-utils.h b/src/cr-utils.h index bb42a22..64ab093 100644 --- a/src/cr-utils.h +++ b/src/cr-utils.h @@ -3,8 +3,6 @@ /* * This file is part of The Croco Library * - * Copyright (C) 2002-2003 Dodji Seketeli <dodji at seketeli.org> - * * This program is free software; you can redistribute it and/or * modify it under the terms of version 2.1 of the GNU Lesser General Public * License as published by the Free Software Foundation. @@ -18,6 +16,8 @@ * along with this program; if not, write to the Free Software * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 * USA + * + * Look at file COPYRIGHTS for copyright information */ #ifndef __CR_DEFS_H__ @@ -64,7 +64,8 @@ enum CRStatus { CR_PSEUDO_CLASS_SEL_HANDLER_NOT_FOUND_ERROR, CR_BAD_PSEUDO_CLASS_SEL_HANDLER_ERROR, CR_ERROR, - CR_FILE_NOT_FOUND_ERROR + CR_FILE_NOT_FOUND_ERROR, + CR_VALUE_NOT_FOUND_ERROR } ; /** diff --git a/src/libcroco.h b/src/libcroco.h index 5562511..15e2677 100644 --- a/src/libcroco.h +++ b/src/libcroco.h @@ -36,6 +36,7 @@ #include "cr-statement.h" #include "cr-stylesheet.h" #include "cr-om-parser.h" +#include "cr-prop-list.h" #include "cr-sel-eng.h" #include "cr-style.h" |