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 2009 John-Mark Bell <jmb@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_list_style_type(uint32_t opv,css_style * style,css_select_state * state)17 css_error css__cascade_list_style_type(uint32_t opv, css_style *style,
18 		css_select_state *state)
19 {
20 	uint16_t value = CSS_LIST_STYLE_TYPE_INHERIT;
21 
22 	UNUSED(style);
23 
24 	if (isInherit(opv) == false) {
25 		switch (getValue(opv)) {
26 		case LIST_STYLE_TYPE_DISC:
27 			value = CSS_LIST_STYLE_TYPE_DISC;
28 			break;
29 		case LIST_STYLE_TYPE_CIRCLE:
30 			value = CSS_LIST_STYLE_TYPE_CIRCLE;
31 			break;
32 		case LIST_STYLE_TYPE_SQUARE:
33 			value = CSS_LIST_STYLE_TYPE_SQUARE;
34 			break;
35 		case LIST_STYLE_TYPE_DECIMAL:
36 			value = CSS_LIST_STYLE_TYPE_DECIMAL;
37 			break;
38 		case LIST_STYLE_TYPE_DECIMAL_LEADING_ZERO:
39 			value = CSS_LIST_STYLE_TYPE_DECIMAL_LEADING_ZERO;
40 			break;
41 		case LIST_STYLE_TYPE_LOWER_ROMAN:
42 			value = CSS_LIST_STYLE_TYPE_LOWER_ROMAN;
43 			break;
44 		case LIST_STYLE_TYPE_UPPER_ROMAN:
45 			value = CSS_LIST_STYLE_TYPE_UPPER_ROMAN;
46 			break;
47 		case LIST_STYLE_TYPE_LOWER_GREEK:
48 			value = CSS_LIST_STYLE_TYPE_LOWER_GREEK;
49 			break;
50 		case LIST_STYLE_TYPE_LOWER_LATIN:
51 			value = CSS_LIST_STYLE_TYPE_LOWER_LATIN;
52 			break;
53 		case LIST_STYLE_TYPE_UPPER_LATIN:
54 			value = CSS_LIST_STYLE_TYPE_UPPER_LATIN;
55 			break;
56 		case LIST_STYLE_TYPE_ARMENIAN:
57 			value = CSS_LIST_STYLE_TYPE_ARMENIAN;
58 			break;
59 		case LIST_STYLE_TYPE_GEORGIAN:
60 			value = CSS_LIST_STYLE_TYPE_GEORGIAN;
61 			break;
62 		case LIST_STYLE_TYPE_LOWER_ALPHA:
63 			value = CSS_LIST_STYLE_TYPE_LOWER_ALPHA;
64 			break;
65 		case LIST_STYLE_TYPE_UPPER_ALPHA:
66 			value = CSS_LIST_STYLE_TYPE_UPPER_ALPHA;
67 			break;
68 		case LIST_STYLE_TYPE_NONE:
69 			value = CSS_LIST_STYLE_TYPE_NONE;
70 			break;
71 		}
72 	}
73 
74 	if (css__outranks_existing(getOpcode(opv), isImportant(opv), state,
75 			isInherit(opv))) {
76 		return set_list_style_type(state->computed, value);
77 	}
78 
79 	return CSS_OK;
80 }
81 
css__set_list_style_type_from_hint(const css_hint * hint,css_computed_style * style)82 css_error css__set_list_style_type_from_hint(const css_hint *hint,
83 		css_computed_style *style)
84 {
85 	return set_list_style_type(style, hint->status);
86 }
87 
css__initial_list_style_type(css_select_state * state)88 css_error css__initial_list_style_type(css_select_state *state)
89 {
90 	return set_list_style_type(state->computed, CSS_LIST_STYLE_TYPE_DISC);
91 }
92 
css__compose_list_style_type(const css_computed_style * parent,const css_computed_style * child,css_computed_style * result)93 css_error css__compose_list_style_type(const css_computed_style *parent,
94 		const css_computed_style *child,
95 		css_computed_style *result)
96 {
97 	uint8_t type = get_list_style_type(child);
98 
99 	if (type == CSS_LIST_STYLE_TYPE_INHERIT) {
100 		type = get_list_style_type(parent);
101 	}
102 
103 	return set_list_style_type(result, type);
104 }
105 
106