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_visibility(uint32_t opv,css_style * style,css_select_state * state)17 css_error css__cascade_visibility(uint32_t opv, css_style *style,
18 		css_select_state *state)
19 {
20 	uint16_t value = CSS_VISIBILITY_INHERIT;
21 
22 	UNUSED(style);
23 
24 	if (isInherit(opv) == false) {
25 		switch (getValue(opv)) {
26 		case VISIBILITY_VISIBLE:
27 			value = CSS_VISIBILITY_VISIBLE;
28 			break;
29 		case VISIBILITY_HIDDEN:
30 			value = CSS_VISIBILITY_HIDDEN;
31 			break;
32 		case VISIBILITY_COLLAPSE:
33 			value = CSS_VISIBILITY_COLLAPSE;
34 			break;
35 		}
36 	}
37 
38 	if (css__outranks_existing(getOpcode(opv), isImportant(opv), state,
39 			isInherit(opv))) {
40 		return set_visibility(state->computed, value);
41 	}
42 
43 	return CSS_OK;
44 }
45 
css__set_visibility_from_hint(const css_hint * hint,css_computed_style * style)46 css_error css__set_visibility_from_hint(const css_hint *hint,
47 		css_computed_style *style)
48 {
49 	return set_visibility(style, hint->status);
50 }
51 
css__initial_visibility(css_select_state * state)52 css_error css__initial_visibility(css_select_state *state)
53 {
54 	return set_visibility(state->computed, CSS_VISIBILITY_VISIBLE);
55 }
56 
css__compose_visibility(const css_computed_style * parent,const css_computed_style * child,css_computed_style * result)57 css_error css__compose_visibility(const css_computed_style *parent,
58 		const css_computed_style *child,
59 		css_computed_style *result)
60 {
61 	uint8_t type = get_visibility(child);
62 
63 	if (type == CSS_VISIBILITY_INHERIT) {
64 		type = get_visibility(parent);
65 	}
66 
67 	return set_visibility(result, type);
68 }
69 
70