summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--include/libcss/computed.h4
-rw-r--r--src/select/computed.c40
2 files changed, 44 insertions, 0 deletions
diff --git a/include/libcss/computed.h b/include/libcss/computed.h
index 9d7a073..d754bae 100644
--- a/include/libcss/computed.h
+++ b/include/libcss/computed.h
@@ -16,6 +16,7 @@
#include <libcss/types.h>
struct css_hint;
+struct css_select_handler;
enum css_computed_content_type {
CSS_COMPUTED_CONTENT_NONE = 0,
@@ -333,6 +334,9 @@ css_error css_computed_style_create(css_allocator_fn alloc, void *pw,
css_computed_style **result);
css_error css_computed_style_destroy(css_computed_style *style);
+css_error css_computed_style_initialise(css_computed_style *style,
+ struct css_select_handler *handler, void *pw);
+
css_error css_computed_style_compose(const css_computed_style *parent,
const css_computed_style *child,
css_error (*compute_font_size)(void *pw,
diff --git a/src/select/computed.c b/src/select/computed.c
index 6364cd6..9c146da 100644
--- a/src/select/computed.c
+++ b/src/select/computed.c
@@ -164,6 +164,45 @@ css_error css_computed_style_destroy(css_computed_style *style)
}
/**
+ * Populate a blank computed style with Initial values
+ *
+ * \param style Computed style to populate
+ * \param handler Dispatch table of handler functions
+ * \param pw Client-specific private data for handler functions
+ * \return CSS_OK on success.
+ */
+css_error css_computed_style_initialise(css_computed_style *style,
+ css_select_handler *handler, void *pw)
+{
+ css_select_state state;
+ uint32_t i;
+ css_error error;
+
+ if (style == NULL)
+ return CSS_BADPARM;
+
+ state.node = NULL;
+ state.pseudo_element = CSS_PSEUDO_ELEMENT_NONE;
+ state.media = CSS_MEDIA_ALL;
+ state.result = style;
+ state.handler = handler;
+ state.pw = pw;
+
+ for (i = 0; i < CSS_N_PROPERTIES; i++) {
+ /* No need to initialise anything other than the normal
+ * properties -- the others are handled by the accessors */
+ if (prop_dispatch[i].inherited == false &&
+ prop_dispatch[i].group == GROUP_NORMAL) {
+ error = prop_dispatch[i].initial(&state);
+ if (error != CSS_OK)
+ return error;
+ }
+ }
+
+ return CSS_OK;
+}
+
+/**
* Compose two computed styles
*
* \param parent Parent style
@@ -810,6 +849,7 @@ css_error compute_absolute_sides(css_computed_style *style,
if (error != CSS_OK)
return error;
} else {
+ /** \todo This should be containing block's direction */
/* Overconstrained => consult direction */
if (css_computed_direction(style) ==
CSS_DIRECTION_LTR) {