1 /*
2  * This file is part of LibCSS
3  * Licensed under the MIT License,
4  *		  http://www.opensource.org/licenses/mit-license.php
5  * Copyright 2012 Michael Drake <tlsa@netsurf-browser.org>
6  */
7 
8 #include "bytecode/bytecode.h"
9 #include "bytecode/opcodes.h"
10 #include "select/propset.h"
11 #include "select/propget.h"
12 #include "utils/utils.h"
13 
14 #include "select/properties/properties.h"
15 #include "select/properties/helpers.h"
16 
css__cascade_column_rule_color(uint32_t opv,css_style * style,css_select_state * state)17 css_error css__cascade_column_rule_color(uint32_t opv, css_style *style,
18 		css_select_state *state)
19 {
20 	bool inherit = isInherit(opv);
21 	uint16_t value = CSS_COLUMN_RULE_COLOR_INHERIT;
22 	css_color color = 0;
23 
24 	if (isInherit(opv) == false) {
25 		switch (getValue(opv)) {
26 		case COLUMN_RULE_COLOR_TRANSPARENT:
27 			value = CSS_COLUMN_RULE_COLOR_COLOR;
28 			break;
29 		case COLUMN_RULE_COLOR_CURRENT_COLOR:
30 			value = CSS_COLUMN_RULE_COLOR_CURRENT_COLOR;
31 			break;
32 		case COLUMN_RULE_COLOR_SET:
33 			value = CSS_COLUMN_RULE_COLOR_COLOR;
34 			color = *((css_fixed *) style->bytecode);
35 			advance_bytecode(style, sizeof(color));
36 			break;
37 		}
38 	}
39 
40 	if (css__outranks_existing(getOpcode(opv), isImportant(opv), state,
41 			inherit)) {
42 		return set_column_rule_color(state->computed, value, color);
43 	}
44 
45 	return CSS_OK;
46 }
47 
css__set_column_rule_color_from_hint(const css_hint * hint,css_computed_style * style)48 css_error css__set_column_rule_color_from_hint(const css_hint *hint,
49 		css_computed_style *style)
50 {
51 	return set_column_rule_color(style, hint->status, hint->data.color);
52 }
53 
css__initial_column_rule_color(css_select_state * state)54 css_error css__initial_column_rule_color(css_select_state *state)
55 {
56 	return set_column_rule_color(state->computed,
57 			CSS_COLUMN_RULE_COLOR_CURRENT_COLOR, 0);
58 }
59 
css__compose_column_rule_color(const css_computed_style * parent,const css_computed_style * child,css_computed_style * result)60 css_error css__compose_column_rule_color(const css_computed_style *parent,
61 		const css_computed_style *child,
62 		css_computed_style *result)
63 {
64 	css_color color;
65 	uint8_t type = get_column_rule_color(child, &color);
66 
67 	if (type == CSS_COLUMN_RULE_COLOR_INHERIT) {
68 		type = get_column_rule_color(parent, &color);
69 	}
70 
71 	return set_column_rule_color(result, type, color);
72 }
73 
74