summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJohn Mark Bell <jmb@netsurf-browser.org>2009-02-11 01:32:32 +0000
committerJohn Mark Bell <jmb@netsurf-browser.org>2009-02-11 01:32:32 +0000
commit23d09aa24963553bee6cba36321d5195356b39c7 (patch)
tree890a8153e2cb38e7fe2aec0d4789b66e74faf64f
parent03c904ae58e88ca8c4edd6e0a5ef9bdb8cd4dfa4 (diff)
downloadlibcss-23d09aa24963553bee6cba36321d5195356b39c7.tar.gz
libcss-23d09aa24963553bee6cba36321d5195356b39c7.tar.bz2
Border colours. Factor out common code.
svn path=/trunk/libcss/; revision=6418
-rw-r--r--include/libcss/properties.h6
-rw-r--r--src/select/properties.c121
2 files changed, 61 insertions, 66 deletions
diff --git a/include/libcss/properties.h b/include/libcss/properties.h
index 0be9ba2..7475642 100644
--- a/include/libcss/properties.h
+++ b/include/libcss/properties.h
@@ -52,9 +52,9 @@ enum css_border_spacing {
};
enum css_border_color {
- CSS_BORDER_COLOR_INHERIT = 0x0,
- CSS_BORDER_COLOR_TRANSPARENT = 0x1,
- CSS_BORDER_COLOR_COLOR = 0x2
+ CSS_BORDER_COLOR_INHERIT = CSS_BACKGROUND_COLOR_INHERIT,
+ CSS_BORDER_COLOR_TRANSPARENT = CSS_BACKGROUND_COLOR_TRANSPARENT,
+ CSS_BORDER_COLOR_COLOR = CSS_BACKGROUND_COLOR_COLOR
};
enum css_border_style {
diff --git a/src/select/properties.c b/src/select/properties.c
index 53d1de1..7cd7976 100644
--- a/src/select/properties.c
+++ b/src/select/properties.c
@@ -5,6 +5,11 @@
* Copyright 2009 John-Mark Bell <jmb@netsurf-browser.org>
*/
+static css_error cascade_bg_border_color(uint32_t opv, css_style *style,
+ css_select_state *state,
+ css_error (*fun)(css_computed_style *, uint8_t, css_color));
+
+
static css_error cascade_azimuth(uint32_t opv, css_style *style,
css_select_state *state)
{
@@ -71,27 +76,7 @@ static css_error initial_background_attachment(css_computed_style *style)
static css_error cascade_background_color(uint32_t opv, css_style *style,
css_select_state *state)
{
- uint16_t value = CSS_BACKGROUND_COLOR_INHERIT;
- css_color color = 0;
-
- if (isInherit(opv) == false) {
- switch (getValue(opv)) {
- case BACKGROUND_COLOR_TRANSPARENT:
- value = CSS_BACKGROUND_COLOR_TRANSPARENT;
- break;
- case BACKGROUND_COLOR_SET:
- value = CSS_BACKGROUND_COLOR_COLOR;
- color = *((css_color *) style->bytecode);
- advance_bytecode(style, sizeof(color));
- break;
- }
- }
-
- if (outranks_existing(getOpcode(opv), isImportant(opv), state)) {
- return set_background_color(state->result, value, color);
- }
-
- return CSS_OK;
+ return cascade_bg_border_color(opv, style, state, set_background_color);
}
static css_error initial_background_color(css_computed_style *style)
@@ -303,76 +288,51 @@ static css_error initial_border_spacing(css_computed_style *style)
0, CSS_UNIT_PX, 0, CSS_UNIT_PX);
}
-static css_error cascade_border_top_color(
- uint32_t opv, css_style *style, css_select_state *state)
+static css_error cascade_border_top_color(uint32_t opv, css_style *style,
+ css_select_state *state)
{
-
- UNUSED(opv);
- UNUSED(style);
- UNUSED(state);
-
- return CSS_OK;
+ return cascade_bg_border_color(opv, style, state, set_border_top_color);
}
static css_error initial_border_top_color(css_computed_style *style)
{
- UNUSED(style);
-
- return CSS_OK;
+ return set_border_top_color(style, CSS_BORDER_COLOR_COLOR, 0);
}
-static css_error cascade_border_right_color(
- uint32_t opv, css_style *style, css_select_state *state)
+static css_error cascade_border_right_color(uint32_t opv, css_style *style,
+ css_select_state *state)
{
-
- UNUSED(opv);
- UNUSED(style);
- UNUSED(state);
-
- return CSS_OK;
+ return cascade_bg_border_color(opv, style, state,
+ set_border_right_color);
}
static css_error initial_border_right_color(css_computed_style *style)
{
- UNUSED(style);
-
- return CSS_OK;
+ return set_border_right_color(style, CSS_BORDER_COLOR_COLOR, 0);
}
-static css_error cascade_border_bottom_color(
- uint32_t opv, css_style *style, css_select_state *state)
+static css_error cascade_border_bottom_color(uint32_t opv, css_style *style,
+ css_select_state *state)
{
-
- UNUSED(opv);
- UNUSED(style);
- UNUSED(state);
-
- return CSS_OK;
+ return cascade_bg_border_color(opv, style, state,
+ set_border_bottom_color);
}
static css_error initial_border_bottom_color(css_computed_style *style)
{
- UNUSED(style);
-
- return CSS_OK;
+ return set_border_bottom_color(style, CSS_BORDER_COLOR_COLOR, 0);
}
static css_error cascade_border_left_color(
uint32_t opv, css_style *style, css_select_state *state)
{
-
- UNUSED(opv);
- UNUSED(style);
- UNUSED(state);
-
- return CSS_OK;
+ return cascade_bg_border_color(opv, style, state,
+ set_border_left_color);
}
static css_error initial_border_left_color(css_computed_style *style)
{
- UNUSED(style);
-
- return CSS_OK;
+ return set_border_left_color(style, CSS_BORDER_COLOR_COLOR, 0);
}
static css_error cascade_border_top_style(
@@ -1941,3 +1901,38 @@ static css_error initial_z_index(css_computed_style *style)
return CSS_OK;
}
+/******************************************************************************
+ * Utilities below here *
+ ******************************************************************************/
+css_error cascade_bg_border_color(uint32_t opv, css_style *style,
+ css_select_state *state,
+ css_error (*fun)(css_computed_style *, uint8_t, css_color))
+{
+ uint16_t value = CSS_BACKGROUND_COLOR_INHERIT;
+ css_color color = 0;
+
+ assert(CSS_BACKGROUND_COLOR_INHERIT == CSS_BORDER_COLOR_INHERIT);
+ assert(CSS_BACKGROUND_COLOR_TRANSPARENT ==
+ CSS_BORDER_COLOR_TRANSPARENT);
+ assert(CSS_BACKGROUND_COLOR_COLOR == CSS_BORDER_COLOR_COLOR);
+
+ if (isInherit(opv) == false) {
+ switch (getValue(opv)) {
+ case BACKGROUND_COLOR_TRANSPARENT:
+ value = CSS_BACKGROUND_COLOR_TRANSPARENT;
+ break;
+ case BACKGROUND_COLOR_SET:
+ value = CSS_BACKGROUND_COLOR_COLOR;
+ color = *((css_color *) style->bytecode);
+ advance_bytecode(style, sizeof(color));
+ break;
+ }
+ }
+
+ if (outranks_existing(getOpcode(opv), isImportant(opv), state)) {
+ return fun(state->result, value, color);
+ }
+
+ return CSS_OK;
+}
+