summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--include/libcss/hint.h118
-rw-r--r--include/libcss/select.h3
-rw-r--r--src/select/select.c14
3 files changed, 133 insertions, 2 deletions
diff --git a/include/libcss/hint.h b/include/libcss/hint.h
new file mode 100644
index 0000000..366b254
--- /dev/null
+++ b/include/libcss/hint.h
@@ -0,0 +1,118 @@
+/*
+ * 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 libcss_hint_h_
+#define libcss_hint_h_
+
+#include <libwapcaplet/libwapcaplet.h>
+
+#include <libcss/errors.h>
+#include <libcss/functypes.h>
+#include <libcss/types.h>
+
+/**
+ * Length object for use in presentational hints
+ */
+typedef struct css_hint_length {
+ css_fixed value;
+ css_unit unit;
+} css_hint_length;
+
+/**
+ * Typed colour object for use in presentational hints
+ */
+typedef struct css_hint_typed_colour {
+ uint8_t type;
+ css_colour color;
+} css_hint_typed_colour;
+
+/**
+ * Typed length object for use in presentational hints
+ */
+typedef struct css_hint_typed_length {
+ uint8_t type;
+ css_hint_length length;
+} css_hint_typed_length;
+
+/**
+ * Typed string object for use in presentational hints
+ */
+typedef struct css_hint_typed_string {
+ uint8_t type;
+ lwc_string *string;
+} css_hint_typed_string;
+
+/**
+ * Presentational hint border
+ */
+typedef struct css_hint_border {
+ css_hint_typed_length width;
+ css_hint_typed_colour color;
+ uint8_t style;
+} css_hint_border;
+
+/**
+ * Presentational hints
+ *
+ * \todo There's no way to flag that a property isn't set here.
+ */
+typedef struct css_hint {
+ css_hint_typed_colour background_color;
+
+ css_hint_typed_string background_image;
+
+ uint8_t border_collapse;
+
+ css_hint_border border_bottom;
+ css_hint_border border_left;
+ css_hint_border border_right;
+ css_hint_border border_top;
+
+ struct {
+ uint8_t type;
+ css_hint_length h;
+ css_hint_length v;
+ } border_spacing;
+
+ uint8_t caption_side;
+
+ uint8_t clear;
+
+ css_hint_typed_colour color;
+
+ uint8_t _float;
+
+ css_hint_typed_string font_family;
+
+ css_hint_typed_length font_size;
+
+ css_hint_typed_length height;
+
+ uint8_t list_style_type;
+
+ css_hint_typed_length margin_bottom;
+ css_hint_typed_length margin_left;
+ css_hint_typed_length margin_right;
+ css_hint_typed_length margin_top;
+
+ uint8_t overflow;
+
+ css_hint_typed_length padding_bottom;
+ css_hint_typed_length padding_left;
+ css_hint_typed_length padding_right;
+ css_hint_typed_length padding_top;
+
+ uint8_t text_align;
+
+ css_hint_typed_length vertical_align;
+
+ uint8_t white_space;
+
+ css_hint_typed_length width;
+} css_hint;
+
+#endif
diff --git a/include/libcss/select.h b/include/libcss/select.h
index 6d774ec..44befcd 100644
--- a/include/libcss/select.h
+++ b/include/libcss/select.h
@@ -12,6 +12,7 @@
#include <libcss/errors.h>
#include <libcss/functypes.h>
+#include <libcss/hint.h>
#include <libcss/types.h>
enum css_pseudo_element {
@@ -79,7 +80,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,
uint32_t pseudo_element, uint64_t media,
- css_computed_style *result,
+ const css_hint *hints, css_computed_style *result,
css_select_handler *handler, void *pw);
#endif
diff --git a/src/select/select.c b/src/select/select.c
index a27a0cf..7b83f90 100644
--- a/src/select/select.c
+++ b/src/select/select.c
@@ -240,6 +240,7 @@ css_error css_select_ctx_get_sheet(css_select_ctx *ctx, uint32_t index,
* \param node Node to select style for
* \param pseudo_element Pseudo element to select for, instead
* \param media Currently active media types
+ * \param hint Presentational hints, or NULL for none
* \param result Pointer to style to populate (assumed clean)
* \param handler Dispatch table of handler functions
* \param pw Client-specific private data for handler functions
@@ -256,7 +257,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,
uint32_t pseudo_element, uint64_t media,
- css_computed_style *result,
+ const css_hint *hints, css_computed_style *result,
css_select_handler *handler, void *pw)
{
uint32_t i;
@@ -287,6 +288,17 @@ css_error css_select_style(css_select_ctx *ctx, void *node,
}
}
+ /** \todo take account of presentational hints:
+ *
+ * foreach property in hints:
+ * if !state.property.set || (state.property.origin == UA ||
+ * (state.property.origin == USER &&
+ * !state.property.important)):
+ * result.property = property
+ * state.property.set = true
+ */
+ UNUSED(hints);
+
/* Finally, 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.