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_caption_side(uint32_t opv,css_style * style,css_select_state * state)17 css_error css__cascade_caption_side(uint32_t opv, css_style *style,
18 css_select_state *state)
19 {
20 uint16_t value = CSS_CAPTION_SIDE_INHERIT;
21
22 UNUSED(style);
23
24 if (isInherit(opv) == false) {
25 switch (getValue(opv)) {
26 case CAPTION_SIDE_TOP:
27 value = CSS_CAPTION_SIDE_TOP;
28 break;
29 case CAPTION_SIDE_BOTTOM:
30 value = CSS_CAPTION_SIDE_BOTTOM;
31 break;
32 }
33 }
34
35 if (css__outranks_existing(getOpcode(opv), isImportant(opv), state,
36 isInherit(opv))) {
37 return set_caption_side(state->computed, value);
38 }
39
40 return CSS_OK;
41 }
42
css__set_caption_side_from_hint(const css_hint * hint,css_computed_style * style)43 css_error css__set_caption_side_from_hint(const css_hint *hint,
44 css_computed_style *style)
45 {
46 return set_caption_side(style, hint->status);
47 }
48
css__initial_caption_side(css_select_state * state)49 css_error css__initial_caption_side(css_select_state *state)
50 {
51 return set_caption_side(state->computed, CSS_CAPTION_SIDE_TOP);
52 }
53
css__compose_caption_side(const css_computed_style * parent,const css_computed_style * child,css_computed_style * result)54 css_error css__compose_caption_side(const css_computed_style *parent,
55 const css_computed_style *child,
56 css_computed_style *result)
57 {
58 uint8_t type = get_caption_side(child);
59
60 if (type == CSS_CAPTION_SIDE_INHERIT) {
61 type = get_caption_side(parent);
62 }
63
64 return set_caption_side(result, type);
65 }
66
67