summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--ccss-cairo/ccss-cairo-appearance-parser.c2
-rw-r--r--ccss-cairo/ccss-cairo-background.c3
-rw-r--r--ccss-cairo/ccss-cairo-background.h2
-rw-r--r--ccss-cairo/ccss-cairo-border-image.c1
-rw-r--r--ccss-cairo/ccss-cairo-border.c4
-rw-r--r--ccss-cairo/ccss-cairo-style.c6
-rw-r--r--ccss-doc/ccss-sections.txt5
-rw-r--r--ccss-gtk/ccss-gtk-property.h1
-rw-r--r--ccss-gtk/ccss-gtk-stylesheet.c56
-rw-r--r--ccss/Makefile.am5
-rw-r--r--ccss/ccss-background-parser.c2
-rw-r--r--ccss/ccss-background-priv.h109
-rw-r--r--ccss/ccss-background.c2
-rw-r--r--ccss/ccss-background.h65
-rw-r--r--ccss/ccss-border-image-parser.c2
-rw-r--r--ccss/ccss-border-image-priv.h48
-rw-r--r--ccss/ccss-border-image.c2
-rw-r--r--ccss/ccss-border-image.h14
-rw-r--r--ccss/ccss-border-parser.c2
-rw-r--r--ccss/ccss-border-priv.h67
-rw-r--r--ccss/ccss-border.c2
-rw-r--r--ccss/ccss-border.h38
-rw-r--r--ccss/ccss-color-impl.h11
-rw-r--r--ccss/ccss-color.c2
-rw-r--r--ccss/ccss-color.h11
-rw-r--r--ccss/ccss-node-priv.h20
-rw-r--r--ccss/ccss-node.c135
-rw-r--r--ccss/ccss-node.h78
-rw-r--r--ccss/ccss-padding-parser.c2
-rw-r--r--ccss/ccss-padding-priv.h41
-rw-r--r--ccss/ccss-padding.c2
-rw-r--r--ccss/ccss-padding.h8
-rw-r--r--ccss/ccss-position-priv.h40
-rw-r--r--ccss/ccss-position.c1
-rw-r--r--ccss/ccss-position.h6
-rw-r--r--ccss/ccss-property-impl.h13
-rw-r--r--ccss/ccss-property.h13
-rw-r--r--ccss/ccss.sym4
-rw-r--r--examples/example-2.c54
39 files changed, 606 insertions, 273 deletions
diff --git a/ccss-cairo/ccss-cairo-appearance-parser.c b/ccss-cairo/ccss-cairo-appearance-parser.c
index 8214b4a..8777f7e 100644
--- a/ccss-cairo/ccss-cairo-appearance-parser.c
+++ b/ccss-cairo/ccss-cairo-appearance-parser.c
@@ -20,7 +20,7 @@
*/
#include <gmodule.h>
-#include <ccss/ccss-property-impl.h>
+#include "ccss/ccss-property-impl.h"
#include "ccss-cairo-appearance.h"
#include "ccss-cairo-appearance-parser.h"
#include "config.h"
diff --git a/ccss-cairo/ccss-cairo-background.c b/ccss-cairo/ccss-cairo-background.c
index e7ba978..0044fba 100644
--- a/ccss-cairo/ccss-cairo-background.c
+++ b/ccss-cairo/ccss-cairo-background.c
@@ -22,7 +22,8 @@
#include <math.h>
#include <string.h>
#include <glib.h>
-#include <ccss/ccss-property-impl.h>
+#include "ccss/ccss-background-priv.h"
+#include "ccss/ccss-property-impl.h"
#include "ccss-cairo-background.h"
#include "ccss-cairo-image-cache.h"
#include "config.h"
diff --git a/ccss-cairo/ccss-cairo-background.h b/ccss-cairo/ccss-cairo-background.h
index 6982e02..dc85a58 100644
--- a/ccss-cairo/ccss-cairo-background.h
+++ b/ccss-cairo/ccss-cairo-background.h
@@ -28,9 +28,7 @@
#endif
#endif
-#include <stdint.h>
#include <cairo.h>
-#include <libcroco/libcroco.h>
#include <ccss/ccss.h>
CCSS_BEGIN_DECLS
diff --git a/ccss-cairo/ccss-cairo-border-image.c b/ccss-cairo/ccss-cairo-border-image.c
index ef3b44b..eca31ca 100644
--- a/ccss-cairo/ccss-cairo-border-image.c
+++ b/ccss-cairo/ccss-cairo-border-image.c
@@ -22,6 +22,7 @@
/* Direct access to struct members for fun and profit. */
#include <ccss/ccss-macros.h>
+#include "ccss/ccss-border-image-priv.h"
#include "ccss-cairo-border-image.h"
#include "ccss-cairo-image-cache.h"
#include "config.h"
diff --git a/ccss-cairo/ccss-cairo-border.c b/ccss-cairo/ccss-cairo-border.c
index 259d99e..ce5aecd 100644
--- a/ccss-cairo/ccss-cairo-border.c
+++ b/ccss-cairo/ccss-cairo-border.c
@@ -23,7 +23,9 @@
#include <stdio.h>
#include <string.h>
#include <glib.h>
-#include <ccss/ccss-property-impl.h>
+#include "ccss/ccss-border-priv.h"
+#include "ccss/ccss-color-impl.h"
+#include "ccss/ccss-property-impl.h"
#include "ccss-cairo-border.h"
#include "config.h"
diff --git a/ccss-cairo/ccss-cairo-style.c b/ccss-cairo/ccss-cairo-style.c
index 58cbda1..966a13c 100644
--- a/ccss-cairo/ccss-cairo-style.c
+++ b/ccss-cairo/ccss-cairo-style.c
@@ -21,8 +21,10 @@
#include <string.h>
#include <glib.h>
-#include <ccss/ccss-property-impl.h>
-#include "ccss/ccss-style-priv.h" /* PONDERING: use only public headers? */
+#include "ccss/ccss-background-priv.h"
+#include "ccss/ccss-border-priv.h"
+#include "ccss/ccss-property-impl.h"
+#include "ccss/ccss-style-priv.h"
#include "ccss-cairo-appearance.h"
#include "ccss-cairo-background.h"
#include "ccss-cairo-border.h"
diff --git a/ccss-doc/ccss-sections.txt b/ccss-doc/ccss-sections.txt
index a6d79bd..69c65a6 100644
--- a/ccss-doc/ccss-sections.txt
+++ b/ccss-doc/ccss-sections.txt
@@ -113,6 +113,7 @@ ccss_grammar_create_stylesheet_from_file
<TITLE>ccss_node_t</TITLE>
<FILE>node</FILE>
+CCSS_NODE_CLASS_N_METHODS
ccss_node_t
ccss_node_class_t
ccss_node_is_a_f
@@ -127,7 +128,9 @@ ccss_node_get_attribute_f
ccss_node_get_style_f
ccss_node_get_viewport_f
ccss_node_release_f
-ccss_node_init
+ccss_node_create
+ccss_node_destroy
+ccss_node_get_user_data
</SECTION>
<SECTION>
diff --git a/ccss-gtk/ccss-gtk-property.h b/ccss-gtk/ccss-gtk-property.h
index 62c03dc..c4164a2 100644
--- a/ccss-gtk/ccss-gtk-property.h
+++ b/ccss-gtk/ccss-gtk-property.h
@@ -28,6 +28,7 @@
#endif
#endif
+#include <ccss/ccss-property-impl.h>
#include <ccss-cairo/ccss-cairo.h>
#include <gtk/gtk.h>
diff --git a/ccss-gtk/ccss-gtk-stylesheet.c b/ccss-gtk/ccss-gtk-stylesheet.c
index 44d070a..04e3691 100644
--- a/ccss-gtk/ccss-gtk-stylesheet.c
+++ b/ccss-gtk/ccss-gtk-stylesheet.c
@@ -25,42 +25,47 @@
#include "config.h"
/*
- * Node implementation for querying the stylesheet.
+ * Widget implementation for querying the stylesheet.
*/
typedef struct {
- ccss_node_t parent;
char const *type_name;
char const *id;
char const *pseudo_classes[2];
-} Node;
+} Widget;
static char const *
-get_type (Node const *self)
+get_type (ccss_node_t const *self)
{
- return self->type_name;
+ Widget *w = ccss_node_get_user_data (self);
+
+ return w->type_name;
}
static char const *
-get_id (Node const *self)
+get_id (ccss_node_t const *self)
{
- return self->id;
+ Widget *w = ccss_node_get_user_data (self);
+
+ return w->id;
}
static char const **
-get_pseudo_classes (Node const *self)
+get_pseudo_classes (ccss_node_t const *self)
{
- return (char const **) self->pseudo_classes;
+ Widget *w = ccss_node_get_user_data (self);
+
+ return (char const **) w->pseudo_classes;
}
static ccss_node_class_t _node_class = {
.is_a = NULL,
.get_container = NULL,
.get_base_style = NULL,
- .get_id = (ccss_node_get_id_f) get_id,
- .get_type = (ccss_node_get_type_f) get_type,
+ .get_id = get_id,
+ .get_type = get_type,
.get_classes = NULL,
- .get_pseudo_classes = (ccss_node_get_pseudo_classes_f) get_pseudo_classes,
+ .get_pseudo_classes = get_pseudo_classes,
.get_attribute = NULL,
.get_viewport = NULL,
.release = NULL
@@ -243,18 +248,21 @@ accumulate_state (ccss_stylesheet_t *stylesheet,
struct RcState *state,
GSList **style_properties)
{
- ccss_style_t *style;
- Node node;
- char *color;
- gboolean ret;
-
- ccss_node_init (&node.parent, &_node_class);
- node.type_name = type_name;
- node.id = NULL;
- node.pseudo_classes[0] = state_name;
- node.pseudo_classes[1] = NULL;
-
- style = ccss_stylesheet_query (stylesheet, &node.parent);
+ ccss_style_t *style;
+ ccss_node_t *node;
+ Widget widget;
+ char *color;
+ gboolean ret;
+
+ widget.type_name = type_name;
+ widget.id = NULL;
+ widget.pseudo_classes[0] = state_name;
+ widget.pseudo_classes[1] = NULL;
+ node = ccss_node_create (&_node_class,
+ CCSS_NODE_CLASS_N_METHODS (_node_class),
+ &widget);
+ style = ccss_stylesheet_query (stylesheet, node);
+ ccss_node_destroy (node);
if (!style) {
return false;
}
diff --git a/ccss/Makefile.am b/ccss/Makefile.am
index 8d4f6cb..d84a55e 100644
--- a/ccss/Makefile.am
+++ b/ccss/Makefile.am
@@ -29,12 +29,15 @@ libccss_1_la_SOURCES = \
ccss-background.c \
ccss-background-parser.c \
ccss-background-parser.h \
+ ccss-background-priv.h \
ccss-block.c \
ccss-block-priv.h \
ccss-border.c \
+ ccss-border-priv.h \
ccss-border-parser.c \
ccss-border-parser.h \
ccss-border-image.c \
+ ccss-border-image-priv.h \
ccss-border-image-parser.c \
ccss-border-image-parser.h \
ccss-color.c \
@@ -48,9 +51,11 @@ libccss_1_la_SOURCES = \
ccss-node.c \
ccss-node-priv.h \
ccss-padding.c \
+ ccss-padding-priv.h \
ccss-padding-parser.c \
ccss-padding-parser.h \
ccss-position.c \
+ ccss-position-priv.h \
ccss-position-parser.h \
ccss-property.c \
ccss-property-parser.c \
diff --git a/ccss/ccss-background-parser.c b/ccss/ccss-background-parser.c
index 56c4adf..d89d39b 100644
--- a/ccss/ccss-background-parser.c
+++ b/ccss/ccss-background-parser.c
@@ -23,7 +23,7 @@
#include <string.h>
#include <glib.h>
#include "ccss-background-parser.h"
-#include "ccss-background.h"
+#include "ccss-background-priv.h"
#include "ccss-block.h"
#include "ccss-color-impl.h"
#include "ccss-function-impl.h"
diff --git a/ccss/ccss-background-priv.h b/ccss/ccss-background-priv.h
new file mode 100644
index 0000000..e05be0b
--- /dev/null
+++ b/ccss/ccss-background-priv.h
@@ -0,0 +1,109 @@
+/* vim: set ts=8 sw=8 noexpandtab: */
+
+/* The `C' CSS Library.
+ * Copyright (C) 2008 Robert Staudinger
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 2 of the License, or (at your option) any later version.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston,
+ * MA 02110-1301, USA.
+ */
+
+#ifndef CCSS_BACKGROUND_PRIV_H
+#define CCSS_BACKGROUND_PRIV_H
+
+#include <ccss/ccss-macros.h>
+#include <ccss/ccss-background.h>
+#include <ccss/ccss-color-impl.h>
+#include <ccss/ccss-position-priv.h>
+#include <ccss/ccss-property-impl.h>
+
+CCSS_BEGIN_DECLS
+
+/*
+ * Background attachment.
+ */
+
+struct ccss_background_attachment_ {
+ /*< private >*/
+ CCSS_DEPRECATED (ccss_property_t base);
+
+ CCSS_DEPRECATED (ccss_background_attachment_type_t attachment);
+};
+
+/*
+ * Background image.
+ */
+
+struct ccss_background_image_ {
+ /*< private >*/
+ CCSS_DEPRECATED (ccss_property_t base);
+
+ CCSS_DEPRECATED (char *uri);
+};
+
+/*
+ * Background position.
+ */
+
+struct ccss_background_position_ {
+ /*< private >*/
+ CCSS_DEPRECATED (ccss_property_t base);
+
+ CCSS_DEPRECATED (ccss_position_t hpos);
+ CCSS_DEPRECATED (ccss_position_t vpos);
+};
+
+/*
+ * Background repeat.
+ */
+
+struct ccss_background_repeat_ {
+ /*< private >*/
+ CCSS_DEPRECATED (ccss_property_t base);
+
+ CCSS_DEPRECATED (ccss_background_repeat_type_t repeat);
+};
+
+/*
+ * Background size.
+ */
+
+struct ccss_background_size_ {
+ /*< private >*/
+ CCSS_DEPRECATED (ccss_property_t base);
+
+ CCSS_DEPRECATED (ccss_position_t width);
+ CCSS_DEPRECATED (ccss_position_t height);
+};
+
+/*
+ * Background.
+ */
+
+struct ccss_background_ {
+ /*< private >*/
+ CCSS_DEPRECATED (ccss_property_t base);
+
+ CCSS_DEPRECATED (ccss_background_attachment_t bg_attachment);
+ CCSS_DEPRECATED (ccss_color_t bg_color);
+ CCSS_DEPRECATED (ccss_background_image_t bg_image);
+ CCSS_DEPRECATED (ccss_background_position_t bg_position);
+ CCSS_DEPRECATED (ccss_background_repeat_t bg_repeat);
+ CCSS_DEPRECATED (ccss_background_size_t bg_size);
+};
+
+CCSS_END_DECLS
+
+#endif /* CCSS_BACKGROUND_PRIV_H */
+
diff --git a/ccss/ccss-background.c b/ccss/ccss-background.c
index 993cc3c..89fadec 100644
--- a/ccss/ccss-background.c
+++ b/ccss/ccss-background.c
@@ -20,7 +20,7 @@
*/
#include <glib.h>
-#include "ccss-background.h"
+#include "ccss-background-priv.h"
ccss_background_attachment_type_t
ccss_background_attachment_get_attachment (ccss_background_attachment_t const *self)
diff --git a/ccss/ccss-background.h b/ccss/ccss-background.h
index ff1008f..9894962 100644
--- a/ccss/ccss-background.h
+++ b/ccss/ccss-background.h
@@ -28,38 +28,34 @@
CCSS_BEGIN_DECLS
+/*
+ * Background attachment.
+ */
+
typedef enum {
CCSS_BACKGROUND_SCROLL = 0,
CCSS_BACKGROUND_FIXED
} ccss_background_attachment_type_t;
-typedef struct {
- /*< private >*/
- CCSS_DEPRECATED (ccss_property_t base);
-
- CCSS_DEPRECATED (ccss_background_attachment_type_t attachment);
-} ccss_background_attachment_t;
+typedef struct ccss_background_attachment_ ccss_background_attachment_t;
ccss_background_attachment_type_t
ccss_background_attachment_get_attachment (ccss_background_attachment_t const *self);
-typedef struct {
- /*< private >*/
- CCSS_DEPRECATED (ccss_property_t base);
+/*
+ * Background image.
+ */
- CCSS_DEPRECATED (char *uri);
-} ccss_background_image_t;
+typedef struct ccss_background_image_ ccss_background_image_t;
char const *
ccss_background_image_get_uri (ccss_background_image_t const *self);
-typedef struct {
- /*< private >*/
- CCSS_DEPRECATED (ccss_property_t base);
+/*
+ * Background position.
+ */
- CCSS_DEPRECATED (ccss_position_t hpos);
- CCSS_DEPRECATED (ccss_position_t vpos);
-} ccss_background_position_t;
+typedef struct ccss_background_position_ ccss_background_position_t;
ccss_position_t const *
ccss_background_position_get_horizontal_position (ccss_background_position_t const *self);
@@ -74,23 +70,20 @@ typedef enum {
CCSS_BACKGROUND_NO_REPEAT
} ccss_background_repeat_type_t;
-typedef struct {
- /*< private >*/
- CCSS_DEPRECATED (ccss_property_t base);
+/*
+ * Background repeat.
+ */
- CCSS_DEPRECATED (ccss_background_repeat_type_t repeat);
-} ccss_background_repeat_t;
+typedef struct ccss_background_repeat_ ccss_background_repeat_t;
ccss_background_repeat_type_t
ccss_background_repeat_get_repeat (ccss_background_repeat_t const *self);
-typedef struct {
- /*< private >*/
- CCSS_DEPRECATED (ccss_property_t base);
+/*
+ * Background size.
+ */
- CCSS_DEPRECATED (ccss_position_t width);
- CCSS_DEPRECATED (ccss_position_t height);
-} ccss_background_size_t;
+typedef struct ccss_background_size_ ccss_background_size_t;
ccss_position_t const *
ccss_background_size_get_height (ccss_background_size_t const *self);
@@ -98,17 +91,11 @@ ccss_background_size_get_height (ccss_background_size_t const *self);
ccss_position_t const *
ccss_background_size_get_width (ccss_background_size_t const *self);
-typedef struct {
- /*< private >*/
- CCSS_DEPRECATED (ccss_property_t base);
-
- CCSS_DEPRECATED (ccss_background_attachment_t bg_attachment);
- CCSS_DEPRECATED (ccss_color_t bg_color);
- CCSS_DEPRECATED (ccss_background_image_t bg_image);
- CCSS_DEPRECATED (ccss_background_position_t bg_position);
- CCSS_DEPRECATED (ccss_background_repeat_t bg_repeat);
- CCSS_DEPRECATED (ccss_background_size_t bg_size);
-} ccss_background_t;
+/*
+ * Background.
+ */
+
+typedef struct ccss_background_ ccss_background_t;
ccss_background_attachment_t const *
ccss_background_get_attachment (ccss_background_t const *self);
diff --git a/ccss/ccss-border-image-parser.c b/ccss/ccss-border-image-parser.c
index c58913c..a7bab72 100644
--- a/ccss/ccss-border-image-parser.c
+++ b/ccss/ccss-border-image-parser.c
@@ -20,7 +20,7 @@
*/
#include <string.h>
-#include "ccss-border-image.h"
+#include "ccss-border-image-priv.h"
#include "ccss-border-image-parser.h"
#include "ccss-function-impl.h"
#include "ccss-grammar.h"
diff --git a/ccss/ccss-border-image-priv.h b/ccss/ccss-border-image-priv.h
new file mode 100644
index 0000000..821dc80
--- /dev/null
+++ b/ccss/ccss-border-image-priv.h
@@ -0,0 +1,48 @@
+/* vim: set ts=8 sw=8 noexpandtab: */
+
+/* The `C' CSS Library.
+ * Copyright (C) 2008 Robert Staudinger
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 2 of the License, or (at your option) any later version.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston,
+ * MA 02110-1301, USA.
+ */
+
+#ifndef CCSS_BORDER_IMAGE_PRIV_H
+#define CCSS_BORDER_IMAGE_PRIV_H
+
+#include <ccss/ccss-macros.h>
+#include <ccss/ccss-border-image.h>
+#include <ccss/ccss-position-priv.h>
+#include <ccss/ccss-property-impl.h>
+
+CCSS_BEGIN_DECLS
+
+struct ccss_border_image_ {
+ /*< private >*/
+ CCSS_DEPRECATED (ccss_property_t base);
+
+ CCSS_DEPRECATED (char *uri);
+ CCSS_DEPRECATED (ccss_position_t top);
+ CCSS_DEPRECATED (ccss_position_t right);
+ CCSS_DEPRECATED (ccss_position_t bottom);
+ CCSS_DEPRECATED (ccss_position_t left);
+ CCSS_DEPRECATED (ccss_border_image_tiling_t top_middle_bottom_horizontal_tiling);
+ CCSS_DEPRECATED (ccss_border_image_tiling_t left_middle_right_vertical_tiling);
+};
+
+CCSS_END_DECLS
+
+#endif /* CCSS_BORDER_IMAGE_PRIV_H */
+
diff --git a/ccss/ccss-border-image.c b/ccss/ccss-border-image.c
index cde2e94..480a077 100644
--- a/ccss/ccss-border-image.c
+++ b/ccss/ccss-border-image.c
@@ -20,7 +20,7 @@
*/
#include <glib.h>
-#include "ccss-border-image.h"
+#include "ccss-border-image-priv.h"
char const *
ccss_border_image_get_uri (ccss_border_image_t const *self)
diff --git a/ccss/ccss-border-image.h b/ccss/ccss-border-image.h
index 0782bf1..02a56ac 100644
--- a/ccss/ccss-border-image.h
+++ b/ccss/ccss-border-image.h
@@ -24,7 +24,6 @@
#include <ccss/ccss-macros.h>
#include <ccss/ccss-position.h>
-#include <ccss/ccss-property.h>
CCSS_BEGIN_DECLS
@@ -34,18 +33,7 @@ typedef enum {
CCSS_BORDER_IMAGE_TILING_STRETCH
} ccss_border_image_tiling_t;
-typedef struct {
- /*< private >*/
- CCSS_DEPRECATED (ccss_property_t base);
-
- CCSS_DEPRECATED (char *uri);
- CCSS_DEPRECATED (ccss_position_t top);
- CCSS_DEPRECATED (ccss_position_t right);
- CCSS_DEPRECATED (ccss_position_t bottom);
- CCSS_DEPRECATED (ccss_position_t left);
- CCSS_DEPRECATED (ccss_border_image_tiling_t top_middle_bottom_horizontal_tiling);
- CCSS_DEPRECATED (ccss_border_image_tiling_t left_middle_right_vertical_tiling);
-} ccss_border_image_t;
+typedef struct ccss_border_image_ ccss_border_image_t;
char const *
ccss_border_image_get_uri (ccss_border_image_t const *self);
diff --git a/ccss/ccss-border-parser.c b/ccss/ccss-border-parser.c
index 28b148b..daf1610 100644
--- a/ccss/ccss-border-parser.c
+++ b/ccss/ccss-border-parser.c
@@ -24,8 +24,8 @@
#include <stdio.h>
#include <string.h>
#include <glib.h>
-#include "ccss-border.h"
#include "ccss-border-parser.h"
+#include "ccss-border-priv.h"
#include "ccss-color-impl.h"
#include "ccss-property-impl.h"
#include "config.h"
diff --git a/ccss/ccss-border-priv.h b/ccss/ccss-border-priv.h
new file mode 100644
index 0000000..ca064cd
--- /dev/null
+++ b/ccss/ccss-border-priv.h
@@ -0,0 +1,67 @@
+/* vim: set ts=8 sw=8 noexpandtab: */
+
+/* The `C' CSS Library.
+ * Copyright (C) 2008 Robert Staudinger
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 2 of the License, or (at your option) any later version.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston,
+ * MA 02110-1301, USA.
+ */
+
+#ifndef CCSS_BORDER_PRIV_H
+#define CCSS_BORDER_PRIV_H
+
+#include <ccss/ccss-macros.h>
+#include <ccss/ccss-border.h>
+#include <ccss/ccss-property-impl.h>
+
+CCSS_BEGIN_DECLS
+
+/*
+ * Border style.
+ */
+
+struct ccss_border_style_ {
+ /*< private >*/
+ CCSS_DEPRECATED (ccss_property_t base);
+
+ CCSS_DEPRECATED (ccss_border_style_type_t style);
+};
+
+/*
+ * Border width.
+ */
+
+struct ccss_border_width_ {
+ /*< private >*/
+ CCSS_DEPRECATED (ccss_property_t base);
+
+ CCSS_DEPRECATED (double width);
+};
+
+/*
+ * Border join.
+ */
+
+struct ccss_border_join_ {
+ /*< private >*/
+ CCSS_DEPRECATED (ccss_property_t base);
+
+ CCSS_DEPRECATED (double radius);
+};
+
+CCSS_END_DECLS
+
+#endif /* CCSS_BORDER_PRIV_H */
+
diff --git a/ccss/ccss-border.c b/ccss/ccss-border.c
index 57063d7..cfd9a7f 100644
--- a/ccss/ccss-border.c
+++ b/ccss/ccss-border.c
@@ -21,7 +21,7 @@
*/
#include <glib.h>
-#include "ccss-border.h"
+#include "ccss-border-priv.h"
ccss_border_style_type_t
ccss_border_style_get_style (ccss_border_style_t const *self)
diff --git a/ccss/ccss-border.h b/ccss/ccss-border.h
index e3ee459..cd9b5d6 100644
--- a/ccss/ccss-border.h
+++ b/ccss/ccss-border.h
@@ -28,6 +28,10 @@
CCSS_BEGIN_DECLS
+/*
+ * Border style.
+ */
+
typedef enum {
CCSS_BORDER_STYLE_HIDDEN,
CCSS_BORDER_STYLE_DOTTED,
@@ -40,38 +44,36 @@ typedef enum {
CCSS_BORDER_STYLE_OUTSET
} ccss_border_style_type_t;
-typedef struct {
- /*< private >*/
- CCSS_DEPRECATED (ccss_property_t base);
-
- CCSS_DEPRECATED (ccss_border_style_type_t style);
-} ccss_border_style_t;
+typedef struct ccss_border_style_ ccss_border_style_t;
ccss_border_style_type_t
ccss_border_style_get_style (ccss_border_style_t const *self);
-typedef struct {
- /*< private >*/
- CCSS_DEPRECATED (ccss_property_t base);
+/*
+ * Border width.
+ */
- CCSS_DEPRECATED (double width);
-} ccss_border_width_t;
+typedef struct ccss_border_width_ ccss_border_width_t;
double
ccss_border_width_get_width (ccss_border_width_t const *self);
-/* FIXME: introduce generic "double" value struct. */
-typedef ccss_border_width_t ccss_border_spacing_t;
+/*
+ * Border spacing.
+ * FIXME: introduce generic "double" value struct.
+ */
+
+typedef struct ccss_border_width_ ccss_border_spacing_t;
double
ccss_border_spacing_get_spacing (ccss_border_spacing_t const *self);
-typedef struct {
- /*< private >*/
- CCSS_DEPRECATED (ccss_property_t base);
+/*
+ * Border join.
+ * FIXME: rename to `border-radius'?
+ */
- CCSS_DEPRECATED (double radius);
-} ccss_border_join_t; /* FIXME: rename to `border-radius'? */
+typedef struct ccss_border_join_ ccss_border_join_t;
double
ccss_border_join_get_radius (ccss_border_join_t const *self);
diff --git a/ccss/ccss-color-impl.h b/ccss/ccss-color-impl.h
index 00ce41c..7f84166 100644
--- a/ccss/ccss-color-impl.h
+++ b/ccss/ccss-color-impl.h
@@ -43,9 +43,20 @@
#include <ccss/ccss-color.h>
#include <ccss/ccss-grammar.h>
#include <ccss/ccss-macros.h>
+#include <ccss/ccss-property-impl.h>
CCSS_BEGIN_DECLS
+struct ccss_color_ {
+ /*< private >*/
+ CCSS_DEPRECATED (ccss_property_t base);
+
+ CCSS_DEPRECATED (float red);
+ CCSS_DEPRECATED (float green);
+ CCSS_DEPRECATED (float blue);
+ CCSS_DEPRECATED (float alpha);
+};
+
bool
ccss_color_parse (ccss_color_t *self,
ccss_grammar_t const *grammar,
diff --git a/ccss/ccss-color.c b/ccss/ccss-color.c
index 3597ca9..30ccb18 100644
--- a/ccss/ccss-color.c
+++ b/ccss/ccss-color.c
@@ -20,7 +20,7 @@
*/
#include <glib.h>
-#include "ccss-color.h"
+#include "ccss-color-impl.h"
double
ccss_color_get_red (ccss_color_t const *self)
diff --git a/ccss/ccss-color.h b/ccss/ccss-color.h
index 9a2da9d..ef620dc 100644
--- a/ccss/ccss-color.h
+++ b/ccss/ccss-color.h
@@ -23,19 +23,10 @@
#define CCSS_COLOR_H
#include <ccss/ccss-macros.h>
-#include <ccss/ccss-property.h>
CCSS_BEGIN_DECLS
-typedef struct {
- /*< private >*/
- CCSS_DEPRECATED (ccss_property_t base);
-
- CCSS_DEPRECATED (float red);
- CCSS_DEPRECATED (float green);
- CCSS_DEPRECATED (float blue);
- CCSS_DEPRECATED (float alpha);
-} ccss_color_t;
+typedef struct ccss_color_ ccss_color_t;
double
ccss_color_get_red (ccss_color_t const *self);
diff --git a/ccss/ccss-node-priv.h b/ccss/ccss-node-priv.h
index 08a383c..97b0188 100644
--- a/ccss/ccss-node-priv.h
+++ b/ccss/ccss-node-priv.h
@@ -29,6 +29,26 @@
CCSS_BEGIN_DECLS
+/**
+ * ccss_node_t:
+ *
+ * Represents a DOM node object.
+ **/
+struct ccss_node_ {
+ /*< private >*/
+ CCSS_DEPRECATED (ccss_node_class_t const node_class);
+
+ CCSS_DEPRECATED (void *user_data);
+
+ /* Cache */
+ CCSS_DEPRECATED (ptrdiff_t instance);
+ CCSS_DEPRECATED (char const *id);
+ CCSS_DEPRECATED (char const *type_name);
+ CCSS_DEPRECATED (char const **css_classes);
+ CCSS_DEPRECATED (char const **pseudo_classes);
+ CCSS_DEPRECATED (char const *inline_style);
+};
+
bool
ccss_node_is_a (ccss_node_t *self,
char const *type_name);
diff --git a/ccss/ccss-node.c b/ccss/ccss-node.c
index 3b560af..e7e0fbf 100644
--- a/ccss/ccss-node.c
+++ b/ccss/ccss-node.c
@@ -25,7 +25,7 @@
#include "config.h"
static bool
-is_a (ccss_node_t *self,
+is_a (ccss_node_t const *self,
char const *type_name)
{
return false;
@@ -119,38 +119,58 @@ static const ccss_node_class_t _default_node_class = {
};
typedef void (*node_f) (void);
-#define N_ELEMENTS(vtable_) (sizeof (vtable_) / sizeof (node_f))
/**
- * ccss_node_init:
- * @self: a #ccss_node_t embedding structure.
+ * ccss_node_create:
* @node_class: a #ccss_node_class_t vtable.
+ * @n_methods: number of methods in @node_class.
+ * @user_data: data to associate with the node, typically a pointer to the documents native node.
*
- * Initializes @node_class by filling unset functions with the default
- * implementations and attaches it to @self.
+ * Creates a new #ccss_node_t instance and of class @node_class.
+ *
+ * Returns: a #ccss_node_t.
**/
-void
-ccss_node_init (ccss_node_t *self,
- ccss_node_class_t *node_class)
+ccss_node_t *
+ccss_node_create (ccss_node_class_t const *node_class,
+ unsigned int n_methods,
+ void *user_data)
{
+ ccss_node_t *self;
+ node_f const *user_vtable;
node_f const *default_vtable;
node_f *vtable;
- g_return_if_fail (self && node_class);
+ g_return_val_if_fail (node_class, NULL);
+ g_return_val_if_fail (n_methods > 0, NULL);
+ g_return_val_if_fail (n_methods <= CCSS_NODE_CLASS_N_METHODS (_default_node_class), NULL);
- memset (self, 0, sizeof (*self));
+ self = g_new0 (ccss_node_t, 1);
- /* Initialize the node class.
- * FIXME: run only once per node class? */
+ user_vtable = (node_f const *) node_class;
default_vtable = (node_f const *) &_default_node_class;
- vtable = (node_f *) node_class;
- for (unsigned int i = 0; i < N_ELEMENTS (_default_node_class); i++) {
- if (NULL == vtable[i])
+ vtable = (node_f *) self; /* The node class is at the start of the node. */
+ for (unsigned int i = 0; i < n_methods; i++) {
+ if (user_vtable[i])
+ vtable[i] = user_vtable[i];
+ else
vtable[i] = default_vtable[i];
}
- /* Initializse node. */
- self->node_class = node_class;
+ self->user_data = user_data;
+
+ return self;
+}
+
+/**
+ * ccss_node_destroy:
+ * @self: a #ccss_node_t.
+ *
+ * Frees @self.
+ */
+void
+ccss_node_destroy (ccss_node_t *self)
+{
+ g_free (self);
}
/**
@@ -166,11 +186,10 @@ ccss_node_is_a (ccss_node_t *self,
char const *node_type_name;
g_return_val_if_fail (self, false);
- g_return_val_if_fail (self->node_class, false);
g_return_val_if_fail (type_name, false);
- if (self->node_class->is_a != is_a) {
- return self->node_class->is_a (self, type_name);
+ if (self->node_class.is_a != is_a) {
+ return self->node_class.is_a (self, type_name);
} else {
node_type_name = ccss_node_get_type (self);
return node_type_name ?
@@ -179,87 +198,89 @@ ccss_node_is_a (ccss_node_t *self,
}
}
+/**
+ * ccss_node_get_user_data:
+ * @self: a #ccss_node_t.
+ *
+ * Retrieve the user data associated with the node.
+ *
+ * Returns: node user data.
+ **/
+void *
+ccss_node_get_user_data (ccss_node_t const *self)
+{
+ g_return_val_if_fail (self, NULL);
+
+ return self->user_data;
+}
+
ccss_node_t *
ccss_node_get_container (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_container, NULL);
- return self->node_class->get_container (self);
+ return self->node_class.get_container (self);
}
ccss_node_t *
-ccss_node_get_base_style (ccss_node_t *self)
+ccss_node_get_base_style (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_base_style, NULL);
- return self->node_class->get_base_style (self);
+ return self->node_class.get_base_style (self);
}
char const *
-ccss_node_get_type (ccss_node_t *self)
+ccss_node_get_type (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_type, NULL);
if (NULL == self->type_name)
- self->type_name = self->node_class->get_type (self);
+ self->type_name = self->node_class.get_type (self);
return self->type_name;
}
ptrdiff_t
-ccss_node_get_instance (ccss_node_t *self)
+ccss_node_get_instance (ccss_node_t *self)
{
g_return_val_if_fail (self, 0);
- g_return_val_if_fail (self->node_class, 0);
- g_return_val_if_fail (self->node_class->get_instance, 0);
if (0 == self->instance)
- self->instance = self->node_class->get_instance (self);
+ self->instance = self->node_class.get_instance (self);
return self->instance;
}
char const *
-ccss_node_get_id (ccss_node_t *self)
+ccss_node_get_id (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_id, NULL);
if (NULL == self->id)
- self->id = self->node_class->get_id (self);
+ self->id = self->node_class.get_id (self);
return self->id;
}
const char **
-ccss_node_get_classes (ccss_node_t *self)
+ccss_node_get_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_classes, NULL);
if (NULL == self->css_classes)
- self->css_classes = self->node_class->get_classes (self);
+ self->css_classes = self->node_class.get_classes (self);
return self->css_classes;
}
const char **
-ccss_node_get_pseudo_classes (ccss_node_t *self)
+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_classes, NULL);
if (NULL == self->pseudo_classes)
- self->pseudo_classes = self->node_class->get_pseudo_classes (self);
+ self->pseudo_classes = self->node_class.get_pseudo_classes (self);
return self->pseudo_classes;
}
@@ -269,10 +290,8 @@ ccss_node_get_attribute (ccss_node_t const *self,
char const *name)
{
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_attribute, NULL);
- return self->node_class->get_attribute (self, name);
+ return self->node_class.get_attribute (self, name);
}
char const *
@@ -280,12 +299,10 @@ ccss_node_get_style (ccss_node_t *self,
unsigned int descriptor)
{
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_style, NULL);
if (NULL == self->inline_style)
- self->inline_style = self->node_class->get_style (self,
- descriptor);
+ self->inline_style = self->node_class.get_style (self,
+ descriptor);
return self->inline_style;
}
@@ -298,19 +315,15 @@ ccss_node_get_viewport (ccss_node_t const *self,
double *height)
{
g_return_val_if_fail (self, false);
- g_return_val_if_fail (self->node_class, false);
- g_return_val_if_fail (self->node_class->get_viewport, false);
- return self->node_class->get_viewport (self, x, y, width, height);
+ return self->node_class.get_viewport (self, x, y, width, height);
}
void
ccss_node_release (ccss_node_t *self)
{
g_return_if_fail (self);
- g_return_if_fail (self->node_class);
- g_return_if_fail (self->node_class->release);
- self->node_class->release (self);
+ self->node_class.release (self);
}
diff --git a/ccss/ccss-node.h b/ccss/ccss-node.h
index c3524f8..5f80b5e 100644
--- a/ccss/ccss-node.h
+++ b/ccss/ccss-node.h
@@ -40,12 +40,12 @@ typedef struct ccss_node_ ccss_node_t;
*
* Returns: %TRUE if matches.
**/
-typedef bool (*ccss_node_is_a_f) (ccss_node_t *self,
- char const *type_name);
+typedef bool (*ccss_node_is_a_f) (ccss_node_t const *self,
+ char const *type_name);
/**
* ccss_node_get_container_f:
- * @self: a #ccss_node_t.
+ * @self: a #ccss_node_t.
*
* Hook function to query the container of a #ccss_node_t.
*
@@ -55,7 +55,7 @@ typedef ccss_node_t * (*ccss_node_get_container_f) (ccss_node_t const *self);
/**
* ccss_node_get_base_style_f:
- * @self: a #ccss_node_t.
+ * @self: a #ccss_node_t.
*
* Hook function to query the name of the style a #ccss_node_t derives from.
*
@@ -66,7 +66,7 @@ typedef ccss_node_t * (*ccss_node_get_base_style_f) (ccss_node_t const *self);
/**
* ccss_node_get_type_f:
- * @self: a #ccss_node_t.
+ * @self: a #ccss_node_t.
*
* Hook function to query the type name of a #ccss_node_t.
*
@@ -77,7 +77,7 @@ typedef const char * (*ccss_node_get_type_f) (ccss_node_t const *self);
/**
* ccss_node_get_instance_f:
- * @self: a #ccss_node_t.
+ * @self: a #ccss_node_t.
*
* Hook function to query for a unique numerical representation of a #ccss_node_t.
*
@@ -87,7 +87,7 @@ typedef ptrdiff_t (*ccss_node_get_instance_f) (ccss_node_t const *self);
/**
* ccss_node_get_id_f:
- * @self: a #ccss_node_t.
+ * @self: a #ccss_node_t.
*
* Hook function to query the ID of a #ccss_node_t.
*
@@ -98,7 +98,7 @@ typedef const char * (*ccss_node_get_id_f) (ccss_node_t const *self);
/**
* ccss_node_get_classes_f:
- * @self: a #ccss_node_t.
+ * @self: a #ccss_node_t.
*
* Hook function to query the class names of a #ccss_node_t.
*
@@ -109,7 +109,7 @@ typedef const char ** (*ccss_node_get_classes_f) (ccss_node_t const *self);
/**
* ccss_node_get_pseudo_classes_f:
- * @self: a #ccss_node_t.
+ * @self: a #ccss_node_t.
*
* Hook function to query the pseudo-class name of a #ccss_node_t.
*
@@ -120,8 +120,8 @@ typedef const char ** (*ccss_node_get_pseudo_classes_f) (ccss_node_t const *self
/**
* ccss_node_get_attribute_f:
- * @self: a #ccss_node_t.
- * @name: attribute name.
+ * @self: a #ccss_node_t.
+ * @name: attribute name.
*
* Hook function to query a #ccss_node_t's attributes.
*
@@ -133,8 +133,8 @@ typedef char * (*ccss_node_get_attribute_f) (ccss_node_t const *self,
/**
* ccss_node_get_style_f:
- * @self: a #ccss_node_t.
- * @descriptor: handle to unload this style from the stylesheet later on.
+ * @self: a #ccss_node_t.
+ * @descriptor: handle to unload this style from the stylesheet later on.
*
* Hook function to query a #ccss_node_t's inline CSS style.
*
@@ -165,7 +165,7 @@ typedef bool (*ccss_node_get_viewport_f) (ccss_node_t const *self,
/**
* ccss_node_release_f:
- * @self: a #ccss_node_t.
+ * @self: a #ccss_node_t.
*
* Hook function to deallocate a #ccss_node_t instance.
**/
@@ -189,7 +189,8 @@ typedef void (*ccss_node_release_f) (ccss_node_t *self);
* Dispatch table a CCSS consumer has to fill so the selection engine can
* retrieve information about the document the document.
*
- * The implemented dispatch table needs to be passed to #ccss_node_init.
+ * The implemented dispatch table needs to be passed to #ccss_node_create.
+ * All fields have to be initialised to either a node function or %NULL.
**/
typedef struct {
ccss_node_is_a_f is_a;
@@ -204,43 +205,28 @@ typedef struct {
ccss_node_get_style_f get_style;
ccss_node_get_viewport_f get_viewport;
ccss_node_release_f release;
- /*< private >*/
- void (*_padding_0) (void);
- void (*_padding_1) (void);
- void (*_padding_2) (void);
- void (*_padding_3) (void);
- void (*_padding_4) (void);
} ccss_node_class_t;
/**
- * ccss_node_t:
- *
- * Stack-allocatable struct representing a document node. Used for querying the
- * #ccss_stylesheet_t.
- *
- * <emphasis>Memory management:</emphasis> Unless specified otherwise, objects
- * of this kind are under the responsibility of the libccss consumer.
+ * CCSS_NODE_CLASS_N_METHODS:
+ *
+ * Returns the number of methods in a #ccss_node_class_t vtable.
+ *
+ * See: #ccss_node_class_t.
**/
-struct ccss_node_ {
- /*< private >*/
- CCSS_DEPRECATED (ccss_node_class_t const *node_class);
-
- CCSS_DEPRECATED (ptrdiff_t instance);
- CCSS_DEPRECATED (char const *id);
- CCSS_DEPRECATED (char const *type_name);
- CCSS_DEPRECATED (char const **css_classes);
- CCSS_DEPRECATED (char const **pseudo_classes);
- CCSS_DEPRECATED (char const *inline_style);
- CCSS_DEPRECATED (void *_padding_0);
- CCSS_DEPRECATED (void *_padding_1);
- CCSS_DEPRECATED (void *_padding_2);
- CCSS_DEPRECATED (void *_padding_3);
- CCSS_DEPRECATED (void *_padding_4);
-};
+#define CCSS_NODE_CLASS_N_METHODS(vtable_) \
+ (sizeof (vtable_) / sizeof (void (*)(void)))
+
+ccss_node_t *
+ccss_node_create (ccss_node_class_t const *node_class,
+ unsigned int n_methods,
+ void *user_data);
void
-ccss_node_init (ccss_node_t *self,
- ccss_node_class_t *node_class);
+ccss_node_destroy (ccss_node_t *self);
+
+void *
+ccss_node_get_user_data (ccss_node_t const *self);
CCSS_END_DECLS
diff --git a/ccss/ccss-padding-parser.c b/ccss/ccss-padding-parser.c
index 38bbdfb..e724b95 100644
--- a/ccss/ccss-padding-parser.c
+++ b/ccss/ccss-padding-parser.c
@@ -22,7 +22,7 @@
#include <string.h>
#include "ccss-block.h"
#include "ccss-grammar.h"
-#include "ccss-padding.h"
+#include "ccss-padding-priv.h"
#include "ccss-padding-parser.h"
#include "ccss-property-impl.h"
#include "config.h"
diff --git a/ccss/ccss-padding-priv.h b/ccss/ccss-padding-priv.h
new file mode 100644
index 0000000..7da4cc8
--- /dev/null
+++ b/ccss/ccss-padding-priv.h
@@ -0,0 +1,41 @@
+/* vim: set ts=8 sw=8 noexpandtab: */
+
+/* The `C' CSS Library.
+ * Copyright (C) 2008 Robert Staudinger
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 2 of the License, or (at your option) any later version.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston,
+ * MA 02110-1301, USA.
+ */
+
+#ifndef CCSS_PADDING_PRIV_H
+#define CCSS_PADDING_PRIV_H
+
+#include <ccss/ccss-macros.h>
+#include <ccss/ccss-padding.h>
+#include <ccss/ccss-property-impl.h>
+
+CCSS_BEGIN_DECLS
+
+struct ccss_padding_ {
+ /*< private >*/
+ CCSS_DEPRECATED (ccss_property_t base);
+
+ CCSS_DEPRECATED (double padding);
+};
+
+CCSS_END_DECLS
+
+#endif /* CCSS_PADDING_PRIV_H */
+
diff --git a/ccss/ccss-padding.c b/ccss/ccss-padding.c
index d4468eb..377c251 100644
--- a/ccss/ccss-padding.c
+++ b/ccss/ccss-padding.c
@@ -20,7 +20,7 @@
*/
#include <glib.h>
-#include "ccss-padding.h"
+#include "ccss-padding-priv.h"
#include "config.h"
double
diff --git a/ccss/ccss-padding.h b/ccss/ccss-padding.h
index cf7b824..8a5dd78 100644
--- a/ccss/ccss-padding.h
+++ b/ccss/ccss-padding.h
@@ -23,16 +23,10 @@
#define CCSS_PADDING_H
#include <ccss/ccss-macros.h>
-#include <ccss/ccss-property.h>
CCSS_BEGIN_DECLS
-typedef struct {
- /*< private >*/
- CCSS_DEPRECATED (ccss_property_t base);
-
- CCSS_DEPRECATED (double padding);
-} ccss_padding_t;
+typedef struct ccss_padding_ ccss_padding_t;
double
ccss_padding_get_padding (ccss_padding_t const *self);
diff --git a/ccss/ccss-position-priv.h b/ccss/ccss-position-priv.h
new file mode 100644
index 0000000..ba4d281
--- /dev/null
+++ b/ccss/ccss-position-priv.h
@@ -0,0 +1,40 @@
+/* vim: set ts=8 sw=8 noexpandtab: */
+
+/* The `C' CSS Library.
+ * Copyright (C) 2008 Robert Staudinger
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 2 of the License, or (at your option) any later version.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston,
+ * MA 02110-1301, USA.
+ */
+
+#ifndef CCSS_POSITION_PRIV_H
+#define CCSS_POSITION_PRIV_H
+
+#include <ccss/ccss-macros.h>
+#include <ccss/ccss-position.h>
+#include <ccss/ccss-property-impl.h>
+
+CCSS_BEGIN_DECLS
+
+struct ccss_position_ {
+ /*< private >*/
+ CCSS_DEPRECATED (ccss_position_type_t type);
+ CCSS_DEPRECATED (double value);
+};
+
+CCSS_END_DECLS
+
+#endif /* CCSS_POSITION_PRIV_H */
+
diff --git a/ccss/ccss-position.c b/ccss/ccss-position.c
index 4beee74..be949e3 100644
--- a/ccss/ccss-position.c
+++ b/ccss/ccss-position.c
@@ -21,6 +21,7 @@
#include <glib.h>
#include "ccss-position-parser.h"
+#include "ccss-position-priv.h"
#include "config.h"
static const struct {
diff --git a/ccss/ccss-position.h b/ccss/ccss-position.h
index 17002d8..79a0110 100644
--- a/ccss/ccss-position.h
+++ b/ccss/ccss-position.h
@@ -59,11 +59,7 @@ typedef enum {
CCSS_POSITION_COVER
} ccss_position_type_t;
-typedef struct {
- /*< private >*/
- CCSS_DEPRECATED (ccss_position_type_t type);
- CCSS_DEPRECATED (double value);
-} ccss_position_t;
+typedef struct ccss_position_ ccss_position_t;
double
ccss_position_get_pos (ccss_position_t const *self,
diff --git a/ccss/ccss-property-impl.h b/ccss/ccss-property-impl.h
index 39da513..401ae49 100644
--- a/ccss/ccss-property-impl.h
+++ b/ccss/ccss-property-impl.h
@@ -153,6 +153,19 @@ struct ccss_property_class_ {
};
/**
+ * ccss_property_t:
+ * @vtable: class descriptor, see #ccss_property_class_t.
+ * @state: property state, see #ccss_property_state_t.
+ *
+ * This structure has to be embedded at the beginning of every custom property.
+ **/
+struct ccss_property_ {
+ /*< private >*/
+ CCSS_DEPRECATED (ccss_property_class_t const *vtable);
+ CCSS_DEPRECATED (ccss_property_state_t state);
+};
+
+/**
* ccss_property_generic_t:
* @base: base property.
* @name: name of the property, e.g. %color.
diff --git a/ccss/ccss-property.h b/ccss/ccss-property.h
index 2400946..240e279 100644
--- a/ccss/ccss-property.h
+++ b/ccss/ccss-property.h
@@ -65,19 +65,6 @@ typedef enum {
typedef struct ccss_property_ ccss_property_t;
typedef struct ccss_property_class_ ccss_property_class_t;
-/**
- * ccss_property_t:
- * @vtable: class descriptor, see #ccss_property_class_t.
- * @state: property state, see #ccss_property_state_t.
- *
- * This structure has to be embedded at the beginning of every custom property.
- **/
-struct ccss_property_ {
- /*< private >*/
- CCSS_DEPRECATED (ccss_property_class_t const *vtable);
- CCSS_DEPRECATED (ccss_property_state_t state);
-};
-
ccss_property_state_t
ccss_property_get_state (ccss_property_t const *self);
diff --git a/ccss/ccss.sym b/ccss/ccss.sym
index 578ceea..ecfc497 100644
--- a/ccss/ccss.sym
+++ b/ccss/ccss.sym
@@ -46,7 +46,9 @@ ccss_grammar_invoke_function
ccss_grammar_lookup_function
ccss_grammar_lookup_property
ccss_grammar_reference
-ccss_node_init
+ccss_node_create
+ccss_node_destroy
+ccss_node_get_user_data
ccss_padding_get_padding
ccss_position_get_hsize
ccss_position_get_pos
diff --git a/examples/example-2.c b/examples/example-2.c
index fdcd3f7..60c70d9 100644
--- a/examples/example-2.c
+++ b/examples/example-2.c
@@ -7,35 +7,49 @@
#include "config.h"
typedef struct {
- ccss_node_t parent;
char const *type_name;
ptrdiff_t instance;
char const *inline_css;
-} node_t;
+} nodeinfo_t;
static char const *
-get_type (node_t const *self)
+get_type (ccss_node_t const *self)
{
- return self->type_name;
+ nodeinfo_t *info = ccss_node_get_user_data (self);
+
+ return info->type_name;
}
static ptrdiff_t
-get_instance (node_t const *self)
+get_instance (ccss_node_t const *self)
{
- return self->instance;
+ nodeinfo_t *info = ccss_node_get_user_data (self);
+
+ return info->instance;
}
static char const *
-get_style (node_t const *self,
+get_style (ccss_node_t const *self,
unsigned int descriptor)
{
- return self->inline_css;
+ nodeinfo_t *info = ccss_node_get_user_data (self);
+
+ return info->inline_css;
}
static ccss_node_class_t _node_class = {
- .get_type = (ccss_node_get_type_f) get_type,
- .get_instance = (ccss_node_get_instance_f) get_instance,
- .get_style = (ccss_node_get_style_f) get_style
+ .is_a = NULL,
+ .get_container = NULL,
+ .get_base_style = NULL,
+ .get_instance = get_instance,
+ .get_id = NULL,
+ .get_type = get_type,
+ .get_classes = NULL,
+ .get_pseudo_classes = NULL,
+ .get_attribute = NULL,
+ .get_style = get_style,
+ .get_viewport = NULL,
+ .release = NULL
};
static gboolean
@@ -74,9 +88,10 @@ main (int argc,
ccss_grammar_t *grammar;
ccss_stylesheet_t *stylesheet;
ccss_style_t *style;
- node_t node;
+ ccss_node_t *node;
GtkWidget *window;
GtkWidget *area;
+ nodeinfo_t info;
gtk_init (&argc, &argv);
@@ -84,13 +99,14 @@ main (int argc,
stylesheet = ccss_grammar_create_stylesheet_from_buffer (grammar,
_css, sizeof (_css),
NULL);
-
- ccss_node_init ((ccss_node_t *) &node, &_node_class);
- node.type_name = "box";
- node.instance = 0xdeadbeef;
- node.inline_css = "background-color: yellow";
-
- style = ccss_stylesheet_query (stylesheet, &node.parent);
+ info.type_name = "box";
+ info.instance = 0xdeadbeef;
+ info.inline_css = "background-color: yellow";
+ node = ccss_node_create (&_node_class,
+ CCSS_NODE_CLASS_N_METHODS (_node_class),
+ &info);
+ style = ccss_stylesheet_query (stylesheet, node);
+ ccss_node_destroy (node);
g_assert (style);
#ifdef CCSS_DEBUG