From 1b13f81b8259f4416df7b3063cb280cb977722d7 Mon Sep 17 00:00:00 2001 From: John Mark Bell Date: Sat, 29 Jan 2011 17:53:22 +0000 Subject: Centralise handling of transparent colours. Add support for currentColor svn path=/trunk/libcss/; revision=11525 --- src/select/properties/color.c | 25 +++++++++++++++++++------ 1 file changed, 19 insertions(+), 6 deletions(-) (limited to 'src/select/properties/color.c') diff --git a/src/select/properties/color.c b/src/select/properties/color.c index 3cd1e3d..dad2b9d 100644 --- a/src/select/properties/color.c +++ b/src/select/properties/color.c @@ -17,17 +17,30 @@ css_error css__cascade_color(uint32_t opv, css_style *style, css_select_state *state) { + bool inherit = isInherit(opv); uint16_t value = CSS_COLOR_INHERIT; css_color color = 0; - if (isInherit(opv) == false) { - value = CSS_COLOR_COLOR; - color = *((css_color *) style->bytecode); - advance_bytecode(style, sizeof(color)); + if (inherit == false) { + switch (getValue(opv)) { + case COLOR_TRANSPARENT: + value = CSS_COLOR_COLOR; + break; + case COLOR_CURRENT_COLOR: + /* color: currentColor always computes to inherit */ + value = CSS_COLOR_INHERIT; + inherit = true; + break; + case COLOR_SET: + value = CSS_COLOR_COLOR; + color = *((css_color *) style->bytecode); + advance_bytecode(style, sizeof(color)); + break; + } } - if (css__outranks_existing(getOpcode(opv), isImportant(opv), state, - isInherit(opv))) { + if (css__outranks_existing(getOpcode(opv), isImportant(opv), state, + inherit)) { return set_color(state->computed, value, color); } -- cgit v1.2.3