From a61e4fc15ca36c3fd699043499ddadc34fc11ca9 Mon Sep 17 00:00:00 2001 From: John Mark Bell Date: Sun, 12 Jul 2009 11:34:22 +0000 Subject: Provide some API to allow retrieval of an Initial style svn path=/trunk/libcss/; revision=8468 --- src/select/computed.c | 40 ++++++++++++++++++++++++++++++++++++++++ 1 file changed, 40 insertions(+) (limited to 'src/select') 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 @@ -163,6 +163,45 @@ css_error css_computed_style_destroy(css_computed_style *style) return CSS_OK; } +/** + * 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 * @@ -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) { -- cgit v1.2.3