gtk-css-engine r14 - in bzr-playground: . libccd/ccd src
- From: robsta svn gnome org
- To: svn-commits-list gnome org
- Subject: gtk-css-engine r14 - in bzr-playground: . libccd/ccd src
- Date: Mon, 18 Aug 2008 13:50:53 +0000 (UTC)
Author: robsta
Date: Mon Aug 18 13:50:53 2008
New Revision: 14
URL: http://svn.gnome.org/viewvc/gtk-css-engine?rev=14&view=rev
Log:
Implement child selectors.
Modified:
bzr-playground/ (props changed)
bzr-playground/libccd/ccd/ccd-parser.c
bzr-playground/libccd/ccd/ccd-selector.c
bzr-playground/libccd/ccd/ccd-selector.h
bzr-playground/src/gce-node.c
Modified: bzr-playground/libccd/ccd/ccd-parser.c
==============================================================================
--- bzr-playground/libccd/ccd/ccd-parser.c (original)
+++ bzr-playground/libccd/ccd/ccd-parser.c Mon Aug 18 13:50:53 2008
@@ -126,7 +126,15 @@
if (cr_simple_sel->next) {
ccd_selector_t *descendant;
descendant = walk_simple_selector_r (cr_simple_sel->next);
- selector = ccd_selector_append (selector, descendant);
+ if (COMB_WS == cr_simple_sel->next->combinator) {
+ selector = ccd_selector_append_descendant (selector,
+ descendant);
+ } else if (COMB_GT == cr_simple_sel->next->combinator) {
+ selector = ccd_selector_append_child (selector,
+ descendant);
+ } else {
+ g_assert_not_reached ();
+ }
}
return selector;
Modified: bzr-playground/libccd/ccd/ccd-selector.c
==============================================================================
--- bzr-playground/libccd/ccd/ccd-selector.c (original)
+++ bzr-playground/libccd/ccd/ccd-selector.c Mon Aug 18 13:50:53 2008
@@ -49,6 +49,7 @@
uint8_t e;
struct ccd_selector_ *refinement;
struct ccd_selector_ *container;
+ struct ccd_selector_ *antecessor;
ccd_block_t const *block;
};
@@ -66,6 +67,7 @@
to->e = self->e;
to->refinement = NULL;
to->container = NULL;
+ to->antecessor = NULL;
to->block = self->block;
}
@@ -438,6 +440,10 @@
self->container = ccd_selector_copy (original->container);
}
+ if (original->antecessor) {
+ self->antecessor = ccd_selector_copy (original->antecessor);
+ }
+
return self;
}
@@ -481,12 +487,16 @@
{
g_assert (self);
+ if (self->refinement) {
+ ccd_selector_free (self->refinement), self->refinement = NULL;
+ }
+
if (self->container) {
ccd_selector_free (self->container), self->container = NULL;
}
- if (self->refinement) {
- ccd_selector_free (self->refinement), self->refinement = NULL;
+ if (self->antecessor) {
+ ccd_selector_free (self->antecessor), self->antecessor = NULL;
}
switch (self->modality) {
@@ -551,18 +561,12 @@
}
}
-/*
- * Add a selector to the chain.
- * This can change the selector instance, make sure to regard the return value.
- */
-ccd_selector_t *
-ccd_selector_append (ccd_selector_t *self,
- ccd_selector_t *selector)
+static void
+append (ccd_selector_t const *self,
+ ccd_selector_t *selector)
{
g_assert (self && selector);
- selector->container = self;
-
/* propagate specificity */
selector->a = self->a;
selector->b = self->b;
@@ -587,8 +591,34 @@
default:
g_warning ("Invalid selector modality %d", self->modality);
}
+}
- return selector;
+/*
+ * Add a selector to the chain.
+ * This can change the selector instance, make sure to regard the return value.
+ */
+ccd_selector_t *
+ccd_selector_append_child (ccd_selector_t *self,
+ ccd_selector_t *selector)
+{
+ append (self, selector);
+ selector->container = self;
+
+ return selector;
+}
+
+/*
+ * Add a selector to the chain.
+ * This can change the selector instance, make sure to regard the return value.
+ */
+ccd_selector_t *
+ccd_selector_append_descendant (ccd_selector_t *self,
+ ccd_selector_t *selector)
+{
+ append (self, selector);
+ selector->antecessor = self;
+
+ return selector;
}
bool
@@ -722,7 +752,29 @@
*e = self->e;
}
-extern void dump_node (ccd_node_t const *node);
+static bool
+match_antecessor_r (ccd_selector_t const *self,
+ ccd_node_t const *node)
+{
+ ccd_node_class_t const *node_class;
+ ccd_node_t *container;
+ bool is_matching;
+
+ node_class = ccd_node_get_class ();
+
+ container = node_class->get_container (node);
+ if (container) {
+ is_matching = ccd_selector_query_apply (self, container, NULL);
+ if (!is_matching) {
+ is_matching = match_antecessor_r (self, container);
+ }
+ node_class->release (container);
+ } else {
+ is_matching = false;
+ }
+
+ return is_matching;
+}
/*
* `style' may be NULL, in which case this just tests for a match.
@@ -797,7 +849,7 @@
}
}
- /* recursively match container */
+ /* match container */
if (self->container) {
ccd_node_t *container;
container = node_class->get_container (node);
@@ -811,6 +863,14 @@
}
}
+ /* recursively match antecessor */
+ if (self->antecessor) {
+ is_matching = match_antecessor_r (self->antecessor, node);
+ if (!is_matching) {
+ return false;
+ }
+ }
+
/* merge */
if (self->block && style) {
ccd_selector_apply (self, style);
@@ -885,12 +945,23 @@
printf ("( ");
container = self->container;
while (container) {
- printf("%s ", ccd_selector_get_key (container));
+ printf("%s < ", ccd_selector_get_key (container));
container = container->container;
}
printf (")");
}
+ if (self->antecessor) {
+ ccd_selector_t const *container;
+ printf ("( ");
+ container = self->antecessor;
+ while (container) {
+ printf("%s", ccd_selector_get_key (container));
+ container = container->antecessor;
+ }
+ printf (")");
+ }
+
switch (self->modality) {
case CCD_SELECTOR_MODALITY_UNIVERSAL:
universal_selector_dump ((ccd_universal_selector_t *) self);
Modified: bzr-playground/libccd/ccd/ccd-selector.h
==============================================================================
--- bzr-playground/libccd/ccd/ccd-selector.h (original)
+++ bzr-playground/libccd/ccd/ccd-selector.h Mon Aug 18 13:50:53 2008
@@ -55,8 +55,9 @@
void ccd_selector_free (ccd_selector_t *self);
-void ccd_selector_refine (ccd_selector_t *self, ccd_selector_t *selector);
-ccd_selector_t * ccd_selector_append (ccd_selector_t *self, ccd_selector_t *selector);
+void ccd_selector_refine (ccd_selector_t *self, ccd_selector_t *selector);
+ccd_selector_t * ccd_selector_append_child (ccd_selector_t *self, ccd_selector_t *selector);
+ccd_selector_t * ccd_selector_append_descendant (ccd_selector_t *self, ccd_selector_t *selector);
bool ccd_selector_is_type (ccd_selector_t const *self);
bool ccd_selector_is_class (ccd_selector_t const *self);
Modified: bzr-playground/src/gce-node.c
==============================================================================
--- bzr-playground/src/gce-node.c (original)
+++ bzr-playground/src/gce-node.c Mon Aug 18 13:50:53 2008
@@ -60,7 +60,8 @@
is_a (GceNode const *node,
char const *type_name)
{
- GType gtype;
+ GType gtype;
+ bool is_matching;
switch (node->flavor) {
case PRIMITIVE:
@@ -72,8 +73,10 @@
case CONTAINER:
case TYPE:
gtype = g_type_from_name (type_name);
- return g_type_is_a (G_OBJECT_TYPE (node->widget), gtype);
+ is_matching = g_type_is_a (G_OBJECT_TYPE (node->widget), gtype);
+ return is_matching;
default:
+ g_warning ("Unknown flavor %d\n", node->flavor);
g_assert_not_reached ();
return FALSE;
}
@@ -87,6 +90,7 @@
g_assert (node);
+ container_node = NULL;
switch (node->flavor) {
case UNSET:
case CONTAINER:
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]