[libcroco-list] Patch for lang pseudo class handling
- From: rwlbuis xs4all nl
- To: libcroco-list gnome org
- Subject: [libcroco-list] Patch for lang pseudo class handling
- Date: Sun, 29 Feb 2004 12:02:17 +0100 (CET)
Hi,
The attached patch should handle constructs like foo:lang(fr).
To test it I changed locally test5-main.c and the input file, this
seems to work :)
Cheers,
Rob.
Index: src/cr-sel-eng.c
===================================================================
RCS file: /cvs/gnome/libcroco/src/cr-sel-eng.c,v
retrieving revision 1.20
diff -u -3 -p -p -u -b -r1.20 cr-sel-eng.c
--- src/cr-sel-eng.c 29 Feb 2004 01:06:28 -0000 1.20
+++ src/cr-sel-eng.c 29 Feb 2004 10:57:36 -0000
@@ -94,6 +94,10 @@ static gboolean pseudo_class_add_sel_mat
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,41 @@ static xmlNode * get_prev_element_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 ;
+ const char *str = NULL;
+
+ 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))
+ {
+ str = xmlGetProp (node, "lang");
+ if (str && !strncmp(str, a_sel->content.pseudo->extra->str, a_sel->content.pseudo->extra->len))
+ return TRUE ;
+ }
+ return FALSE ;
+}
+
+static gboolean
first_child_pseudo_class_handler (CRSelEng *a_this,
CRAdditionalSel *a_sel,
xmlNode *a_node)
@@ -1241,6 +1280,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 ;
}
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]