diff options
-rw-r--r-- | ChangeLog | 13 | ||||
-rw-r--r-- | csslint/csslint.c | 41 | ||||
-rw-r--r-- | src/cr-sel-eng.c | 29 |
3 files changed, 67 insertions, 16 deletions
@@ -1,3 +1,16 @@ +2004-03-06 Dodji Seketeli <dodji@gnome.org> + + * csslint/csslint.c: applied a patch from Rob BUIS + to fix some bugs/memleaks here. + Did some cleanups too. + * src/cr-sel-eng.c: + (cr_sel_eng_get_matched_rulesets_real): + handle the case where the sheet is empty (has no rules). That + can happen ! (it actually happened to me during some tests). + (put_css_properties_in_props_list): + handle the !important keyword in the cascading algorithm. + Rob BUIS (again) started this. + 2004-03-05 Dodji Seketeli <dodji@gnome.org> * csslint/csslint.c: diff --git a/csslint/csslint.c b/csslint/csslint.c index 2ac1745..914cf47 100644 --- a/csslint/csslint.c +++ b/csslint/csslint.c @@ -101,21 +101,15 @@ parse_cmd_line (int a_argc, char **a_argv, else if ( !strcmp (a_argv[i], "--evaluate") || !strcmp (a_argv[i], "-e")) { - gchar *xml_doc_path = NULL, - *author_sheet_path = NULL, - *user_sheet_path = NULL, - *ua_sheet_path = NULL ; - for (i++ ; i < a_argc ; i++) { if (!strcmp (a_argv[i], "--author-sheet")) { - if (author_sheet_path) + if (a_options->author_sheet_path) { display_usage () ; exit (-1); } - author_sheet_path = a_argv[i] ; i++ ; if (i >= a_argc || a_argv[i][0] == '-') { @@ -127,12 +121,11 @@ parse_cmd_line (int a_argc, char **a_argv, } else if (!strcmp (a_argv[i], "--user-sheet")) { - if (user_sheet_path) + if (a_options->user_sheet_path) { display_usage () ; exit (-1); } - user_sheet_path = a_argv[i] ; i++ ; if (i >= a_argc || a_argv[i][0] == '-') { @@ -144,12 +137,12 @@ parse_cmd_line (int a_argc, char **a_argv, } else if (!strcmp (a_argv[i], "--ua-sheet")) { - if (ua_sheet_path) + if (a_options->ua_sheet_path) { display_usage () ; exit (-1); } - ua_sheet_path = a_argv[i] ; + i++ ; if (i >= a_argc || a_argv[i][0] == '-') { g_print ("--ua-sheet should be followed by a path to the sheet\n") ; @@ -185,7 +178,9 @@ parse_cmd_line (int a_argc, char **a_argv, break ; } } - if (!author_sheet_path && !user_sheet_path && !ua_sheet_path) + if (!a_options->author_sheet_path + && !a_options->user_sheet_path && + !a_options->ua_sheet_path) { g_print ("Error: you must specify at least one stylesheet\n") ; display_usage () ; @@ -248,7 +243,7 @@ display_usage (void) { g_print ("Usage: csslint <path to a css file>\n"); g_print ("\t| csslint -v|--version\n") ; - g_print ("\t| csslint <--evaluate | -e> [--author-sheet <path> --user-sheet <path> --ua-sheet <path>\n] --xml <path> --xpath <xpath expression>") ; + g_print ("\t| csslint <--evaluate | -e> [--author-sheet <path> --user-sheet <path> --ua-sheet <path>\n] --xml <path> --xpath <xpath expression>\n") ; } /** @@ -428,6 +423,26 @@ evaluate_selectors (gchar *a_xml_path, cascade) ; } } + + if (xpath_context) + { + xmlXPathFreeContext (xpath_context); + xpath_context = NULL ; + } + if (xpath_context) + { + xmlXPathFreeObject (xpath_object); + xpath_object = NULL ; + } + if (sel_eng) + { + cr_sel_eng_destroy (sel_eng); + sel_eng = NULL ; + } + if (cascade) + { + cr_cascade_destroy (cascade) ; + } return CR_OK ; } diff --git a/src/cr-sel-eng.c b/src/cr-sel-eng.c index 77933b0..035253e 100644 --- a/src/cr-sel-eng.c +++ b/src/cr-sel-eng.c @@ -845,11 +845,17 @@ cr_sel_eng_get_matched_rulesets_real (CRSelEng *a_this, g_return_val_if_fail (a_this && a_stylesheet - && a_stylesheet->statements && a_node && a_rulesets, CR_BAD_PARAM_ERROR) ; + if (!a_stylesheet->statements) + { + *a_rulesets = NULL ; + *a_len = 0 ; + return CR_OK ; + } + /* *if this stylesheet is "new one" *let's remember it for subsequent calls. @@ -1195,9 +1201,25 @@ put_css_properties_in_props_list (CRPropList **a_props, < a_stmt->parent_sheet->origin)) { + /* + *if the already selected declaration + *is marked as being !important the current + *declaration must not overide it + *(unless the already selected declaration + *has an UA origin) + */ + if (decl->important == TRUE + && decl->parent_statement->parent_sheet->origin + != ORIGIN_UA) + { + continue ; + } tmp_props = cr_prop_list_unlink (props, pair) ; - /*TODO: pair leaks here, fix it!!*/ + if (props) + { + cr_prop_list_destroy (pair) ; + } props = tmp_props ; tmp_props = NULL ; props = cr_prop_list_append2 @@ -1214,7 +1236,8 @@ put_css_properties_in_props_list (CRPropList **a_props, > a_stmt->parent_sheet->origin)) { - /*TODO: support !important rule.*/ + cr_utils_trace_info + ("We should not reach this line\n") ; continue ; } |