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_count(uint32_t opv,css_style * style,css_select_state * state)17 css_error css__cascade_column_count(uint32_t opv, css_style *style,
18 css_select_state *state)
19 {
20 uint16_t value = CSS_COLUMN_COUNT_INHERIT;
21 css_fixed count = 0;
22
23 if (isInherit(opv) == false) {
24 switch (getValue(opv)) {
25 case COLUMN_COUNT_SET:
26 value = CSS_COLUMN_COUNT_SET;
27 count = *((css_fixed *) style->bytecode);
28 advance_bytecode(style, sizeof(count));
29 break;
30 case COLUMN_COUNT_AUTO:
31 value = CSS_COLUMN_COUNT_AUTO;
32 break;
33 }
34 }
35
36 if (css__outranks_existing(getOpcode(opv), isImportant(opv), state,
37 isInherit(opv))) {
38 return set_column_count(state->computed, value, count);
39 }
40
41 return CSS_OK;
42 }
43
css__set_column_count_from_hint(const css_hint * hint,css_computed_style * style)44 css_error css__set_column_count_from_hint(const css_hint *hint,
45 css_computed_style *style)
46 {
47 return set_column_count(style, hint->status, hint->data.integer);
48 }
49
css__initial_column_count(css_select_state * state)50 css_error css__initial_column_count(css_select_state *state)
51 {
52 return set_column_count(state->computed, CSS_COLUMN_COUNT_AUTO, 0);
53 }
54
css__compose_column_count(const css_computed_style * parent,const css_computed_style * child,css_computed_style * result)55 css_error css__compose_column_count(const css_computed_style *parent,
56 const css_computed_style *child,
57 css_computed_style *result)
58 {
59 int32_t count = 0;
60 uint8_t type = get_column_count(child, &count);
61
62 if (type == CSS_COLUMN_COUNT_INHERIT) {
63 type = get_column_count(parent, &count);
64 }
65
66 return set_column_count(result, type, count);
67 }
68