summaryrefslogtreecommitdiff
path: root/src/select
diff options
context:
space:
mode:
authorJohn Mark Bell <jmb@netsurf-browser.org>2009-07-04 17:09:07 +0000
committerJohn Mark Bell <jmb@netsurf-browser.org>2009-07-04 17:09:07 +0000
commit081c8b365001d9ec9df0f06ba5025dd621c8e4ec (patch)
treebeaa0c8a0243a2cb50e869282565033bcdcba6a6 /src/select
parenta3105d297fa8bb6bc8728d60a21b662d867688ae (diff)
downloadlibcss-081c8b365001d9ec9df0f06ba5025dd621c8e4ec.tar.gz
libcss-081c8b365001d9ec9df0f06ba5025dd621c8e4ec.tar.bz2
Add callback to make client compute the font size.
Some progress towards computing absolute values. svn path=/trunk/libcss/; revision=8311
Diffstat (limited to 'src/select')
-rw-r--r--src/select/computed.c41
-rw-r--r--src/select/select.c18
2 files changed, 48 insertions, 11 deletions
diff --git a/src/select/computed.c b/src/select/computed.c
index d8007c1..4c58102 100644
--- a/src/select/computed.c
+++ b/src/select/computed.c
@@ -7,8 +7,7 @@
#include <string.h>
-#include <libcss/computed.h>
-
+#include "select/computed.h"
#include "select/dispatch.h"
#include "utils/utils.h"
@@ -94,9 +93,11 @@ css_error css_computed_style_destroy(css_computed_style *style)
/**
* Compose two computed styles
*
- * \param parent Parent style
- * \param child Child style
- * \param result Pointer to style to compose into
+ * \param parent Parent style
+ * \param child Child style
+ * \param compute_font_size Function to compute an absolute font size
+ * \param pw Client data for compute_font_size
+ * \param result Pointer to style to compose into
* \return CSS_OK on success, appropriate error otherwise.
*
* Precondition: Parent is a fully composed style (thus has no properties
@@ -104,6 +105,9 @@ 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_error (*compute_font_size)(void *pw,
+ const css_hint *parent, css_hint *size),
+ void *pw,
css_computed_style *result)
{
css_error error = CSS_OK;
@@ -131,6 +135,31 @@ css_error css_computed_style_compose(const css_computed_style *parent,
break;
}
- return error;
+ /* Finally, compute absolute values for everything */
+ return compute_absolute_values(result, compute_font_size, pw);
+}
+
+/******************************************************************************
+ * Library internals *
+ ******************************************************************************/
+
+/**
+ * Compute the absolute values of a style
+ *
+ * \param style Computed style to process
+ * \param compute_font_size Callback to calculate an absolute font-size
+ * \param pw Private word for callback
+ * \return CSS_OK on success.
+ */
+css_error compute_absolute_values(css_computed_style *style,
+ css_error (*compute_font_size)(void *pw,
+ const css_hint *parent, css_hint *size),
+ void *pw)
+{
+ UNUSED(style);
+ UNUSED(compute_font_size);
+ UNUSED(pw);
+
+ return CSS_OK;
}
diff --git a/src/select/select.c b/src/select/select.c
index c839be1..f94b2c2 100644
--- a/src/select/select.c
+++ b/src/select/select.c
@@ -8,12 +8,12 @@
#include <assert.h>
#include <string.h>
-#include <libcss/computed.h>
#include <libcss/select.h>
#include "bytecode/bytecode.h"
#include "bytecode/opcodes.h"
#include "stylesheet.h"
+#include "select/computed.h"
#include "select/dispatch.h"
#include "select/hash.h"
#include "select/propset.h"
@@ -323,10 +323,7 @@ css_error css_select_style(css_select_ctx *ctx, void *node,
}
/* Take account of presentational hints and fix up any remaining
- * unset properties.
- * Those properties which are inherited need to be set as inherit.
- * Those which are not inherited need to be set to their default value.
- */
+ * unset properties. */
for (i = 0; i < CSS_N_PROPERTIES; i++) {
/* If the existing property value came from an author
* stylesheet or a user sheet using !important, then leave
@@ -349,6 +346,17 @@ css_error css_select_style(css_select_ctx *ctx, void *node,
}
}
+ /* If this is the root element, then we must ensure that all
+ * length values are absolute, display and float are correctly
+ * computed, and the default border-{top,right,bottom,left}-color
+ * is set to the computed value of color. */
+ if (parent == NULL) {
+ error = compute_absolute_values(result,
+ handler->compute_font_size, pw);
+ if (error != CSS_OK)
+ goto cleanup;
+ }
+
error = CSS_OK;
cleanup:
if (ctx->sheets[0] != NULL) {