diff options
-rw-r--r-- | ChangeLog | 9 | ||||
-rw-r--r-- | src/cr-sel-eng.c | 55 | ||||
-rw-r--r-- | tests/test-inputs/test5.1.css | 1 | ||||
-rw-r--r-- | tests/test-output-refs/test5.1.css.out | 11 | ||||
-rw-r--r-- | tests/test5-main.c | 1 |
5 files changed, 77 insertions, 0 deletions
@@ -1,5 +1,14 @@ 2004-02-29 Dodji Seketeli <dodji@gnome.org> + * src/cr-sel-eng.c: applied a patch of Rob BUIS + to add the support of the :lang() pseudo class using + the pluggable pseudo class system. + * tests/test5-main.c,tests/test-inputs/test5.1.css,tests/test-output-refs/test5.1.css.out: + Updated the non regression tests suite to test the :lang() pseudo + class. + +2004-02-29 Dodji Seketeli <dodji@gnome.org> + * src/cr-statement.[ch],src/cr-stylesheet.[ch]: applied a patch from Rob BUIS that provides new apis to manipulate CSS statements. diff --git a/src/cr-sel-eng.c b/src/cr-sel-eng.c index 5a8954a..bfa61ea 100644 --- a/src/cr-sel-eng.c +++ b/src/cr-sel-eng.c @@ -94,6 +94,10 @@ static gboolean pseudo_class_add_sel_matches_node (CRSelEng * a_this, CRAdditionalSel *a_add_sel, xmlNode *a_node) ; +static gboolean lang_pseudo_class_handler (CRSelEng *a_this, + CRAdditionalSel *a_sel, + xmlNode *a_node) ; + static gboolean first_child_pseudo_class_handler (CRSelEng *a_this, CRAdditionalSel *a_sel, xmlNode *a_node) ; @@ -107,6 +111,52 @@ static xmlNode * get_prev_element_node (xmlNode *a_node) ; static xmlNode * get_next_parent_element_node (xmlNode *a_node) ; static gboolean +lang_pseudo_class_handler (CRSelEng *a_this, + CRAdditionalSel *a_sel, + xmlNode *a_node) +{ + xmlNode *node = a_node ; + xmlChar *val = NULL; + gboolean result = FALSE ; + + g_return_val_if_fail (a_this && PRIVATE (a_this) + && a_sel && a_sel->content.pseudo + && a_sel->content.pseudo + && a_sel->content.pseudo->name + && a_node, + CR_BAD_PARAM_ERROR) ; + + if (strncmp (a_sel->content.pseudo->name->str, + "lang", 4) + || !a_sel->content.pseudo->type == FUNCTION_PSEUDO) + { + cr_utils_trace_info + ("This handler is for :lang only") ; + return CR_BAD_PSEUDO_CLASS_SEL_HANDLER_ERROR ; + } + /*lang code should exist and be at least of length 2*/ + if (!a_sel->content.pseudo->extra || a_sel->content.pseudo->extra->len < 2) + return FALSE ; + for (;node;node = get_next_parent_element_node (node)) + { + val = xmlGetProp (node, "lang"); + if (val + && !strncmp (val, + a_sel->content.pseudo->extra->str, + a_sel->content.pseudo->extra->len)) + { + result = TRUE ; + } + } + if (val) + { + xmlFree (val) ; + val = NULL ; + } + return result ; +} + +static gboolean first_child_pseudo_class_handler (CRSelEng *a_this, CRAdditionalSel *a_sel, xmlNode *a_node) @@ -1241,6 +1291,11 @@ cr_sel_eng_new (void) IDENT_PSEUDO, (CRPseudoClassSelectorHandler) first_child_pseudo_class_handler) ; + cr_sel_eng_register_pseudo_class_sel_handler + (result, (guchar*)"lang", + FUNCTION_PSEUDO, + (CRPseudoClassSelectorHandler) + lang_pseudo_class_handler) ; return result ; } diff --git a/tests/test-inputs/test5.1.css b/tests/test-inputs/test5.1.css index 8847471..26c3627 100644 --- a/tests/test-inputs/test5.1.css +++ b/tests/test-inputs/test5.1.css @@ -4,6 +4,7 @@ [attr3~=val3_2] {prop6: val6} [attr2=val2] {prop5: val5} :first-child {first-child-prop: first-child-value} +:lang(fr) {lang-prop: lang-value} E2[attr2=val2] {prop8: val8} E0 {prop0: val0} E0+E1{pro1:val1} diff --git a/tests/test-output-refs/test5.1.css.out b/tests/test-output-refs/test5.1.css.out index b29f30e..75b17d0 100644 --- a/tests/test-output-refs/test5.1.css.out +++ b/tests/test-output-refs/test5.1.css.out @@ -120,3 +120,14 @@ xml start element: E6 xml end element: E6 ''''''''''''''''''''''''' +''''''''''''''''''''''''' +xml start element: E7 + + + + :lang(fr) { + lang-prop : lang-value + } + +xml end element: E7 +''''''''''''''''''''''''' diff --git a/tests/test5-main.c b/tests/test5-main.c index 6305543..4214746 100644 --- a/tests/test5-main.c +++ b/tests/test5-main.c @@ -45,6 +45,7 @@ const guchar *xml_content= "<E4 attr4=\"val4_1-val4_2-val4_3\">text4</E4>" "<E5 class=\"class5\">text5</E5>" "<E6 id=\"id6\">text6</E6>" +"<E7 lang=\"fr\">text7</E7>" "</document>"; static void |