summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDodji Seketeli <dodji@gnome.org>2004-02-29 13:38:27 +0000
committerDodji Seketeli <dodji@src.gnome.org>2004-02-29 13:38:27 +0000
commitac6a175cddd835cf0e36ad0ffba103fc8cb3a579 (patch)
tree3121519869755f4c275857f094ce57a3f44d1121
parent6a2cb75412be707fd68b20399e2e1376b10b9f33 (diff)
downloadlibcroco-ac6a175cddd835cf0e36ad0ffba103fc8cb3a579.tar.gz
applied a patch of Rob BUIS to add the support of the :lang() pseudo class
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.
-rw-r--r--ChangeLog9
-rw-r--r--src/cr-sel-eng.c55
-rw-r--r--tests/test-inputs/test5.1.css1
-rw-r--r--tests/test-output-refs/test5.1.css.out11
-rw-r--r--tests/test5-main.c1
5 files changed, 77 insertions, 0 deletions
diff --git a/ChangeLog b/ChangeLog
index 5a944bd..150f214 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -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