diff options
Diffstat (limited to 'src/select/properties/display.c')
-rw-r--r-- | src/select/properties/display.c | 114 |
1 files changed, 114 insertions, 0 deletions
diff --git a/src/select/properties/display.c b/src/select/properties/display.c new file mode 100644 index 0000000..6f19501 --- /dev/null +++ b/src/select/properties/display.c @@ -0,0 +1,114 @@ +/* + * This file is part of LibCSS + * Licensed under the MIT License, + * http://www.opensource.org/licenses/mit-license.php + * Copyright 2009 John-Mark Bell <jmb@netsurf-browser.org> + */ + +#include "bytecode/bytecode.h" +#include "bytecode/opcodes.h" +#include "select/propset.h" +#include "select/propget.h" +#include "utils/utils.h" + +#include "select/properties/properties.h" +#include "select/properties/helpers.h" + +css_error cascade_display(uint32_t opv, css_style *style, + css_select_state *state) +{ + uint16_t value = CSS_DISPLAY_INHERIT; + + UNUSED(style); + + if (isInherit(opv) == false) { + switch (getValue(opv)) { + case DISPLAY_INLINE: + value = CSS_DISPLAY_INLINE; + break; + case DISPLAY_BLOCK: + value = CSS_DISPLAY_BLOCK; + break; + case DISPLAY_LIST_ITEM: + value = CSS_DISPLAY_LIST_ITEM; + break; + case DISPLAY_RUN_IN: + value = CSS_DISPLAY_RUN_IN; + break; + case DISPLAY_INLINE_BLOCK: + value = CSS_DISPLAY_INLINE_BLOCK; + break; + case DISPLAY_TABLE: + value = CSS_DISPLAY_TABLE; + break; + case DISPLAY_INLINE_TABLE: + value = CSS_DISPLAY_INLINE_TABLE; + break; + case DISPLAY_TABLE_ROW_GROUP: + value = CSS_DISPLAY_TABLE_ROW_GROUP; + break; + case DISPLAY_TABLE_HEADER_GROUP: + value = CSS_DISPLAY_TABLE_HEADER_GROUP; + break; + case DISPLAY_TABLE_FOOTER_GROUP: + value = CSS_DISPLAY_TABLE_FOOTER_GROUP; + break; + case DISPLAY_TABLE_ROW: + value = CSS_DISPLAY_TABLE_ROW; + break; + case DISPLAY_TABLE_COLUMN_GROUP: + value = CSS_DISPLAY_TABLE_COLUMN_GROUP; + break; + case DISPLAY_TABLE_COLUMN: + value = CSS_DISPLAY_TABLE_COLUMN; + break; + case DISPLAY_TABLE_CELL: + value = CSS_DISPLAY_TABLE_CELL; + break; + case DISPLAY_TABLE_CAPTION: + value = CSS_DISPLAY_TABLE_CAPTION; + break; + case DISPLAY_NONE: + value = CSS_DISPLAY_NONE; + break; + } + } + + if (outranks_existing(getOpcode(opv), isImportant(opv), state, + isInherit(opv))) { + return set_display(state->result, value); + } + + return CSS_OK; +} + +css_error set_display_from_hint(const css_hint *hint, + css_computed_style *style) +{ + return set_display(style, hint->status); +} + +css_error initial_display(css_select_state *state) +{ + return set_display(state->result, CSS_DISPLAY_INLINE); +} + +css_error compose_display(const css_computed_style *parent, + const css_computed_style *child, + css_computed_style *result) +{ + uint8_t type = get_display_static(child); + + if (type == CSS_DISPLAY_INHERIT) { + type = get_display_static(parent); + } + + return set_display(result, type); +} + +uint32_t destroy_display(void *bytecode) +{ + UNUSED(bytecode); + + return sizeof(uint32_t); +} |