summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJohn Mark Bell <jmb@netsurf-browser.org>2009-02-07 02:08:15 +0000
committerJohn Mark Bell <jmb@netsurf-browser.org>2009-02-07 02:08:15 +0000
commit3f5ac6a18b13034f14c7f9261f57887a52e454e3 (patch)
treea00df47421276213a980aa57612a643bbca3d607
parent9ed557ba18facc04fd9d9b35a5dac15844f161c3 (diff)
downloadlibcss-3f5ac6a18b13034f14c7f9261f57887a52e454e3.tar.gz
libcss-3f5ac6a18b13034f14c7f9261f57887a52e454e3.tar.bz2
More API changes.
Make css_computed_style_create() private. Implement css_computed_style_[create,destroy](). svn path=/trunk/libcss/; revision=6389
-rw-r--r--include/libcss/computed.h4
-rw-r--r--include/libcss/select.h2
-rw-r--r--src/select/Makefile2
-rw-r--r--src/select/computed.c130
-rw-r--r--src/select/computed.h16
-rw-r--r--src/select/select.c5
6 files changed, 152 insertions, 7 deletions
diff --git a/include/libcss/computed.h b/include/libcss/computed.h
index f47c523..61cb888 100644
--- a/include/libcss/computed.h
+++ b/include/libcss/computed.h
@@ -294,13 +294,11 @@ struct css_computed_style {
void *pw;
};
-css_error css_computed_style_create(css_alloc alloc, void *pw,
- css_computed_style **result);
css_error css_computed_style_destroy(css_computed_style *style);
css_error css_computed_style_compose(const css_computed_style *parent,
const css_computed_style *child,
- css_computed_style *result);
+ css_computed_style **result);
/******************************************************************************
* Property accessors below here *
diff --git a/include/libcss/select.h b/include/libcss/select.h
index 1948ca1..e8d8ff8 100644
--- a/include/libcss/select.h
+++ b/include/libcss/select.h
@@ -29,6 +29,6 @@ css_error css_select_ctx_get_sheet(css_select_ctx *ctx, uint32_t index,
css_error css_select_style(css_select_ctx *ctx, void *node,
uint64_t pseudo_element, uint64_t pseudo_classes,
- uint64_t media, css_computed_style *result);
+ uint64_t media, css_computed_style **result);
#endif
diff --git a/src/select/Makefile b/src/select/Makefile
index 7a2c25d..9d5656c 100644
--- a/src/select/Makefile
+++ b/src/select/Makefile
@@ -35,7 +35,7 @@ d := $(DIR)
CFLAGS := $(CFLAGS) -I$(d)
# Sources
-SRCS_$(d) := hash.c select.c
+SRCS_$(d) := computed.c hash.c select.c
# Append to sources for component
SOURCES += $(addprefix $(d), $(SRCS_$(d)))
diff --git a/src/select/computed.c b/src/select/computed.c
new file mode 100644
index 0000000..6a6808b
--- /dev/null
+++ b/src/select/computed.c
@@ -0,0 +1,130 @@
+/*
+ * This file is part of LibCSS
+ * Licensed under the MIT License,
+ * http://www.opensource.org/licenses/mit-license.php
+ * Copyright 2009 John-Mark Bell <jmb@netsurf-browser.org>
+ */
+
+#include <string.h>
+
+#include "select/computed.h"
+#include "utils/utils.h"
+
+/**
+ * Create a computed style
+ *
+ * \param alloc Memory (de)allocation function
+ * \param pw Pointer to client-specific data
+ * \param result Pointer to location to receive result
+ * \return CSS_OK on success,
+ * CSS_NOMEM on memory exhaustion,
+ * CSS_BADPARM on bad parameters.
+ */
+css_error css_computed_style_create(css_alloc alloc, void *pw,
+ css_computed_style **result)
+{
+ css_computed_style *s;
+
+ if (alloc == NULL || result == NULL)
+ return CSS_BADPARM;
+
+ s = alloc(NULL, sizeof(css_computed_style), pw);
+ if (s == NULL)
+ return CSS_NOMEM;
+
+ memset(s, 0, sizeof(css_computed_style));
+
+ *result = s;
+
+ return CSS_OK;
+}
+
+/**
+ * Destroy a computed style
+ *
+ * \param style Style to destroy
+ * \return CSS_OK on success, appropriate error otherwise
+ */
+css_error css_computed_style_destroy(css_computed_style *style)
+{
+ if (style == NULL)
+ return CSS_BADPARM;
+
+ if (style->uncommon != NULL) {
+ if (style->uncommon->counter_increment != NULL) {
+ css_computed_counter **c =
+ style->uncommon->counter_increment;
+
+ while (*c != NULL) {
+ style->alloc(*c, 0, style->pw);
+ c++;
+ }
+
+ style->alloc(style->uncommon->counter_increment, 0,
+ style->pw);
+ }
+
+ if (style->uncommon->counter_reset != NULL) {
+ css_computed_counter **c =
+ style->uncommon->counter_reset;
+
+ while (*c != NULL) {
+ style->alloc(*c, 0, style->pw);
+ c++;
+ }
+
+ style->alloc(style->uncommon->counter_reset, 0,
+ style->pw);
+ }
+
+ if (style->uncommon->quotes != NULL)
+ style->alloc(style->uncommon->quotes, 0, style->pw);
+
+ if (style->uncommon->cursor != NULL)
+ style->alloc(style->uncommon->cursor, 0, style->pw);
+
+ style->alloc(style->uncommon, 0, style->pw);
+ }
+
+ if (style->page != NULL) {
+ /** \todo clean up members */
+ style->alloc(style->page, 0, style->pw);
+ }
+
+ if (style->aural != NULL) {
+ /** \todo clean up members */
+ style->alloc(style->aural, 0, style->pw);
+ }
+
+ if (style->font_family != NULL)
+ style->alloc(style->font_family, 0, style->pw);
+
+ style->alloc(style, 0, style->pw);
+
+ return CSS_OK;
+}
+
+/**
+ * Compose two computed styles
+ *
+ * \param parent Parent style
+ * \param child Child style
+ * \param result Pointer to location to receive composed style
+ * \return CSS_OK on success, appropriate error otherwise.
+ *
+ * Precondition: Parent is a fully composed style (thus has no properties
+ * marked as inherited)
+ */
+css_error css_computed_style_compose(const css_computed_style *parent,
+ const css_computed_style *child,
+ css_computed_style **result)
+{
+ UNUSED(parent);
+ UNUSED(child);
+ UNUSED(result);
+
+ /** \todo implement */
+
+ return CSS_OK;
+}
+
diff --git a/src/select/computed.h b/src/select/computed.h
new file mode 100644
index 0000000..eddc7c0
--- /dev/null
+++ b/src/select/computed.h
@@ -0,0 +1,16 @@
+/*
+ * This file is part of LibCSS
+ * Licensed under the MIT License,
+ * http://www.opensource.org/licenses/mit-license.php
+ * Copyright 2009 John-Mark Bell <jmb@netsurf-browser.org>
+ */
+
+#ifndef css_select_computed_h_
+#define css_select_computed_h_
+
+#include <libcss/computed.h>
+
+css_error css_computed_style_create(css_alloc alloc, void *pw,
+ css_computed_style **result);
+
+#endif
diff --git a/src/select/select.c b/src/select/select.c
index 68c3279..ac13d22 100644
--- a/src/select/select.c
+++ b/src/select/select.c
@@ -10,6 +10,7 @@
#include <libcss/select.h>
#include "stylesheet.h"
+#include "select/computed.h"
#include "select/hash.h"
#include "select/propset.h"
#include "utils/utils.h"
@@ -212,7 +213,7 @@ css_error css_select_ctx_get_sheet(css_select_ctx *ctx, uint32_t index,
* \param pseudo_element Pseudo element to select for, instead
* \param pseudo_classes Currently active pseudo classes
* \param media Currently active media types
- * \param result Pointer to style to populate
+ * \param result Pointer to location to receive resulting style
* \return CSS_OK on success, appropriate error otherwise.
*
* In computing the style, no reference is made to the parent node's
@@ -226,7 +227,7 @@ css_error css_select_ctx_get_sheet(css_select_ctx *ctx, uint32_t index,
*/
css_error css_select_style(css_select_ctx *ctx, void *node,
uint64_t pseudo_element, uint64_t pseudo_classes,
- uint64_t media, css_computed_style *result)
+ uint64_t media, css_computed_style **result)
{
UNUSED(ctx);
UNUSED(node);