summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorRobert Staudinger <robsta@gnome.org>2009-07-03 18:15:08 +0200
committerRobert Staudinger <robsta@gnome.org>2009-07-03 18:15:08 +0200
commit5862cf3c8da5045e557187f5092d668c5668c9c9 (patch)
tree66bbb9b0b1bba5babf97dfa4a663978d0e77ac78
parent992e2ffdf84cef5073fc52876319d1c0f4b5d83b (diff)
[feature] Support for multiple pseudo-classes per node.
-rw-r--r--ccss-doc/tmpl/ccss-unused.sgml8
-rw-r--r--ccss-doc/tmpl/node.sgml11
-rw-r--r--ccss-gtk/ccss-gtk-stylesheet.c13
-rw-r--r--ccss/ccss-node-priv.h4
-rw-r--r--ccss/ccss-node.c18
-rw-r--r--ccss/ccss-node.h24
-rw-r--r--ccss/ccss-selector.c9
7 files changed, 45 insertions, 42 deletions
diff --git a/ccss-doc/tmpl/ccss-unused.sgml b/ccss-doc/tmpl/ccss-unused.sgml
index 02f3f65..34891ab 100644
--- a/ccss-doc/tmpl/ccss-unused.sgml
+++ b/ccss-doc/tmpl/ccss-unused.sgml
@@ -111,6 +111,14 @@ ccss_selector_group_t
@y:
@Returns:
+<!-- ##### USER_FUNCTION ccss_node_get_pseudo_class_f ##### -->
+<para>
+
+</para>
+
+@self:
+@Returns:
+
<!-- ##### USER_FUNCTION ccss_property_free_f ##### -->
<para>
diff --git a/ccss-doc/tmpl/node.sgml b/ccss-doc/tmpl/node.sgml
index 2e9bd98..63de4f0 100644
--- a/ccss-doc/tmpl/node.sgml
+++ b/ccss-doc/tmpl/node.sgml
@@ -156,7 +156,7 @@ ccss_node_t
@get_id:
@get_type:
@get_class:
-@get_pseudo_class:
+@get_pseudo_classes:
@get_attribute:
@get_style:
@get_viewport:
@@ -226,15 +226,6 @@ ccss_node_t
@Returns:
-<!-- ##### USER_FUNCTION ccss_node_get_pseudo_class_f ##### -->
-<para>
-
-</para>
-
-@self:
-@Returns:
-
-
<!-- ##### USER_FUNCTION ccss_node_get_attribute_f ##### -->
<para>
diff --git a/ccss-gtk/ccss-gtk-stylesheet.c b/ccss-gtk/ccss-gtk-stylesheet.c
index 419f1cb..d67af3b 100644
--- a/ccss-gtk/ccss-gtk-stylesheet.c
+++ b/ccss-gtk/ccss-gtk-stylesheet.c
@@ -32,7 +32,7 @@ typedef struct {
ccss_node_t parent;
char const *type_name;
char const *id;
- char const *pseudo_class;
+ char const *pseudo_classes[2];
} Node;
static char const *
@@ -47,10 +47,10 @@ get_id (Node const *self)
return self->id;
}
-static char const *
-get_pseudo_class (Node const *self)
+static char const **
+get_pseudo_classes (Node const *self)
{
- return self->pseudo_class;
+ return (char const **) self->pseudo_classes;
}
static ccss_node_class_t _node_class = {
@@ -60,7 +60,7 @@ static ccss_node_class_t _node_class = {
.get_id = (ccss_node_get_id_f) get_id,
.get_type = (ccss_node_get_type_f) get_type,
.get_class = NULL,
- .get_pseudo_class = (ccss_node_get_pseudo_class_f) get_pseudo_class,
+ .get_pseudo_classes = (ccss_node_get_pseudo_classes_f) get_pseudo_classes,
.get_attribute = NULL,
.get_viewport = NULL,
.release = NULL
@@ -214,7 +214,8 @@ accumulate_state (ccss_stylesheet_t *stylesheet,
ccss_node_init (&node.parent, &_node_class);
node.type_name = type_name;
node.id = NULL;
- node.pseudo_class = state_name;
+ node.pseudo_classes[0] = state_name;
+ node.pseudo_classes[1] = NULL;
style = ccss_stylesheet_query (stylesheet, &node.parent);
if (!style) {
diff --git a/ccss/ccss-node-priv.h b/ccss/ccss-node-priv.h
index 4727d97..73e1e92 100644
--- a/ccss/ccss-node-priv.h
+++ b/ccss/ccss-node-priv.h
@@ -51,8 +51,8 @@ ccss_node_get_id (ccss_node_t *self);
char const *
ccss_node_get_class (ccss_node_t *self);
-char const *
-ccss_node_get_pseudo_class (ccss_node_t *self);
+const char **
+ccss_node_get_pseudo_classes (ccss_node_t *self);
char *
ccss_node_get_attribute (ccss_node_t const *self,
diff --git a/ccss/ccss-node.c b/ccss/ccss-node.c
index 1eb0973..39d7a1d 100644
--- a/ccss/ccss-node.c
+++ b/ccss/ccss-node.c
@@ -67,8 +67,8 @@ get_class (ccss_node_t const *self)
return NULL;
}
-static char const *
-get_pseudo_class (ccss_node_t const *self)
+static char const **
+get_pseudo_classes (ccss_node_t const *self)
{
return NULL;
}
@@ -110,7 +110,7 @@ static const ccss_node_class_t _default_node_class = {
.get_id = get_id,
.get_type = get_type,
.get_class = get_class,
- .get_pseudo_class = get_pseudo_class,
+ .get_pseudo_classes = get_pseudo_classes,
.get_attribute = get_attribute,
.get_style = get_style,
.get_viewport = get_viewport,
@@ -250,17 +250,17 @@ ccss_node_get_class (ccss_node_t *self)
return self->css_class;
}
-char const *
-ccss_node_get_pseudo_class (ccss_node_t *self)
+const char **
+ccss_node_get_pseudo_classes (ccss_node_t *self)
{
g_return_val_if_fail (self, NULL);
g_return_val_if_fail (self->node_class, NULL);
- g_return_val_if_fail (self->node_class->get_pseudo_class, NULL);
+ g_return_val_if_fail (self->node_class->get_pseudo_classes, NULL);
- if (NULL == self->pseudo_class)
- self->pseudo_class = self->node_class->get_pseudo_class (self);
+ if (NULL == self->pseudo_classes)
+ self->pseudo_classes = self->node_class->get_pseudo_classes (self);
- return self->pseudo_class;
+ return self->pseudo_classes;
}
char *
diff --git a/ccss/ccss-node.h b/ccss/ccss-node.h
index 1a77eeb..d40da30 100644
--- a/ccss/ccss-node.h
+++ b/ccss/ccss-node.h
@@ -108,15 +108,15 @@ typedef const char * (*ccss_node_get_id_f) (ccss_node_t const *self);
typedef const char * (*ccss_node_get_class_f) (ccss_node_t const *self);
/**
- * ccss_node_get_pseudo_class_f:
+ * ccss_node_get_pseudo_classes_f:
* @self: a #ccss_node_t.
*
* Hook function to query the pseudo-class name of a #ccss_node_t.
*
- * Returns: node pseudo-class name or %NULL. The returned value must be valid until
- * the current stylesheet query returns.
+ * Returns: node pseudo-classes or %NULL. The returned values must be valid
+ * until the current stylesheet query returns.
**/
-typedef const char * (*ccss_node_get_pseudo_class_f) (ccss_node_t const *self);
+typedef const char ** (*ccss_node_get_pseudo_classes_f) (ccss_node_t const *self);
/**
* ccss_node_get_attribute_f:
@@ -174,7 +174,7 @@ typedef void (*ccss_node_release_f) (ccss_node_t *self);
* @get_id: a #ccss_node_get_id_f.
* @get_type: a #ccss_node_get_type_f.
* @get_class: a #ccss_node_get_class_f.
- * @get_pseudo_class: a #ccss_node_get_pseudo_class_f.
+ * @get_pseudo_classes: a #ccss_node_get_pseudo_classes_f.
* @get_attribute: a #ccss_node_get_attribute_f.
* @get_style: a #ccss_node_get_style_f.
* @get_viewport: a #ccss_node_get_viewport_f.
@@ -193,7 +193,7 @@ typedef struct {
ccss_node_get_id_f get_id;
ccss_node_get_type_f get_type;
ccss_node_get_class_f get_class;
- ccss_node_get_pseudo_class_f get_pseudo_class;
+ ccss_node_get_pseudo_classes_f get_pseudo_classes;
ccss_node_get_attribute_f get_attribute;
ccss_node_get_style_f get_style;
ccss_node_get_viewport_f get_viewport;
@@ -213,12 +213,12 @@ struct ccss_node_ {
/*< private >*/
ccss_node_class_t const *node_class;
- ptrdiff_t instance;
- char const *id;
- char const *type_name;
- char const *css_class;
- char const *pseudo_class;
- char const *inline_style;
+ ptrdiff_t instance;
+ char const *id;
+ char const *type_name;
+ char const *css_class;
+ char const **pseudo_classes;
+ char const *inline_style;
};
void
diff --git a/ccss/ccss-selector.c b/ccss/ccss-selector.c
index 8b54426..829c944 100644
--- a/ccss/ccss-selector.c
+++ b/ccss/ccss-selector.c
@@ -945,9 +945,12 @@ ccss_selector_query (ccss_selector_t const *self,
g_free (value), value = NULL;
break;
case CCSS_SELECTOR_MODALITY_PSEUDO_CLASS:
- name = ccss_node_get_pseudo_class (node);
- is_matching = !g_strcmp0 (name,
- ((ccss_pseudo_class_selector_t *) self)->pseudo_class);
+ for (const char **pseudo_classes = ccss_node_get_pseudo_classes (node);
+ pseudo_classes && *pseudo_classes;
+ pseudo_classes++) {
+ is_matching = !g_strcmp0 (*pseudo_classes,
+ ((ccss_pseudo_class_selector_t *) self)->pseudo_class);
+ }
break;
case CCSS_SELECTOR_MODALITY_INSTANCE:
instance = ccss_node_get_instance (node);