summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorLucas Neves <lcneves@gmail.com>2017-09-28 15:46:31 +0000
committerMichael Drake <michael.drake@codethink.co.uk>2017-10-21 15:03:51 +0100
commit12fd8aea8f990d30a2475ae886fc7aa98c77525b (patch)
tree77cb1264e856e4adfb472707008b791ce28c26a2
parentd637196dce1f95d5294d9fb6fc2a8a3c785684d4 (diff)
downloadlibcss-12fd8aea8f990d30a2475ae886fc7aa98c77525b.tar.gz
libcss-12fd8aea8f990d30a2475ae886fc7aa98c77525b.tar.bz2
Selection: Logic for the flexbox properties.
-rw-r--r--src/parse/properties/flex_flow.c2
-rw-r--r--src/select/properties/Makefile10
-rw-r--r--src/select/properties/align_content.c81
-rw-r--r--src/select/properties/align_items.c75
-rw-r--r--src/select/properties/align_self.c78
-rw-r--r--src/select/properties/display.c6
-rw-r--r--src/select/properties/flex_basis.c79
-rw-r--r--src/select/properties/flex_direction.c72
-rw-r--r--src/select/properties/flex_grow.c62
-rw-r--r--src/select/properties/flex_shrink.c62
-rw-r--r--src/select/properties/flex_wrap.c69
-rw-r--r--src/select/properties/justify_content.c79
-rw-r--r--src/select/properties/min_height.c4
-rw-r--r--src/select/properties/min_width.c5
-rw-r--r--src/select/properties/order.c62
-rw-r--r--src/select/properties/properties.h10
16 files changed, 751 insertions, 5 deletions
diff --git a/src/parse/properties/flex_flow.c b/src/parse/properties/flex_flow.c
index 40a42d9..6a83e15 100644
--- a/src/parse/properties/flex_flow.c
+++ b/src/parse/properties/flex_flow.c
@@ -1,4 +1,4 @@
-*
+/*
* This file is part of LibCSS.
* Licensed under the MIT License,
* http://www.opensource.org/licenses/mit-license.php
diff --git a/src/select/properties/Makefile b/src/select/properties/Makefile
index 288eda9..6c6cf84 100644
--- a/src/select/properties/Makefile
+++ b/src/select/properties/Makefile
@@ -1,5 +1,8 @@
# Sources
DIR_SOURCES := helpers.c \
+align_content.c \
+align_items.c \
+align_self.c \
azimuth.c \
background_attachment.c \
background_color.c \
@@ -47,6 +50,11 @@ direction.c \
display.c \
elevation.c \
empty_cells.c \
+flex_basis.c \
+flex_direction.c \
+flex_grow.c \
+flex_shrink.c \
+flex_wrap.c \
float.c \
font_family.c \
font_size.c \
@@ -54,6 +62,7 @@ font_style.c \
font_variant.c \
font_weight.c \
height.c \
+justify_content.c \
left.c \
letter_spacing.c \
line_height.c \
@@ -69,6 +78,7 @@ max_width.c \
min_height.c \
min_width.c \
opacity.c \
+order.c \
orphans.c \
outline_color.c \
outline_style.c \
diff --git a/src/select/properties/align_content.c b/src/select/properties/align_content.c
new file mode 100644
index 0000000..f43cd8e
--- /dev/null
+++ b/src/select/properties/align_content.c
@@ -0,0 +1,81 @@
+/*
+ * This file is part of LibCSS
+ * Licensed under the MIT License,
+ * http://www.opensource.org/licenses/mit-license.php
+ * Copyright 2017 Lucas Neves <lcneves@gmail.com>
+ */
+
+#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 css__cascade_align_content(uint32_t opv, css_style *style,
+ css_select_state *state)
+{
+ uint16_t value = CSS_ALIGN_CONTENT_INHERIT;
+
+ UNUSED(style);
+
+ if (isInherit(opv) == false) {
+ switch (getValue(opv)) {
+ case ALIGN_CONTENT_STRETCH:
+ value = CSS_ALIGN_CONTENT_STRETCH;
+ break;
+ case ALIGN_CONTENT_FLEX_START:
+ value = CSS_ALIGN_CONTENT_FLEX_START;
+ break;
+ case ALIGN_CONTENT_FLEX_END:
+ value = CSS_ALIGN_CONTENT_FLEX_END;
+ break;
+ case ALIGN_CONTENT_CENTER:
+ value = CSS_ALIGN_CONTENT_CENTER;
+ break;
+ case ALIGN_CONTENT_SPACE_BETWEEN:
+ value = CSS_ALIGN_CONTENT_SPACE_BETWEEN;
+ break;
+ case ALIGN_CONTENT_SPACE_AROUND:
+ value = CSS_ALIGN_CONTENT_SPACE_AROUND;
+ break;
+ case ALIGN_CONTENT_SPACE_EVENLY:
+ value = CSS_ALIGN_CONTENT_SPACE_EVENLY;
+ break;
+ }
+ }
+
+ if (css__outranks_existing(getOpcode(opv), isImportant(opv), state,
+ isInherit(opv))) {
+ return set_align_content(state->computed, value);
+ }
+
+ return CSS_OK;
+}
+
+css_error css__set_align_content_from_hint(const css_hint *hint,
+ css_computed_style *style)
+{
+ return set_align_content(style, hint->status);
+}
+
+css_error css__initial_align_content(css_select_state *state)
+{
+ return set_align_content(state->computed, CSS_ALIGN_CONTENT_STRETCH);
+}
+
+css_error css__compose_align_content(const css_computed_style *parent,
+ const css_computed_style *child,
+ css_computed_style *result)
+{
+ uint8_t type = get_align_content(child);
+
+ if (type == CSS_ALIGN_CONTENT_INHERIT) {
+ type = get_align_content(parent);
+ }
+
+ return set_align_content(result, type);
+}
+
diff --git a/src/select/properties/align_items.c b/src/select/properties/align_items.c
new file mode 100644
index 0000000..ad69c81
--- /dev/null
+++ b/src/select/properties/align_items.c
@@ -0,0 +1,75 @@
+/*
+ * This file is part of LibCSS
+ * Licensed under the MIT License,
+ * http://www.opensource.org/licenses/mit-license.php
+ * Copyright 2017 Lucas Neves <lcneves@gmail.com>
+ */
+
+#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 css__cascade_align_items(uint32_t opv, css_style *style,
+ css_select_state *state)
+{
+ uint16_t value = CSS_ALIGN_ITEMS_INHERIT;
+
+ UNUSED(style);
+
+ if (isInherit(opv) == false) {
+ switch (getValue(opv)) {
+ case ALIGN_ITEMS_STRETCH:
+ value = CSS_ALIGN_ITEMS_STRETCH;
+ break;
+ case ALIGN_ITEMS_FLEX_START:
+ value = CSS_ALIGN_ITEMS_FLEX_START;
+ break;
+ case ALIGN_ITEMS_FLEX_END:
+ value = CSS_ALIGN_ITEMS_FLEX_END;
+ break;
+ case ALIGN_ITEMS_CENTER:
+ value = CSS_ALIGN_ITEMS_CENTER;
+ break;
+ case ALIGN_ITEMS_BASELINE:
+ value = CSS_ALIGN_ITEMS_BASELINE;
+ break;
+ }
+ }
+
+ if (css__outranks_existing(getOpcode(opv), isImportant(opv), state,
+ isInherit(opv))) {
+ return set_align_items(state->computed, value);
+ }
+
+ return CSS_OK;
+}
+
+css_error css__set_align_items_from_hint(const css_hint *hint,
+ css_computed_style *style)
+{
+ return set_align_items(style, hint->status);
+}
+
+css_error css__initial_align_items(css_select_state *state)
+{
+ return set_align_items(state->computed, CSS_ALIGN_ITEMS_STRETCH);
+}
+
+css_error css__compose_align_items(const css_computed_style *parent,
+ const css_computed_style *child,
+ css_computed_style *result)
+{
+ uint8_t type = get_align_items(child);
+
+ if (type == CSS_ALIGN_ITEMS_INHERIT) {
+ type = get_align_items(parent);
+ }
+
+ return set_align_items(result, type);
+}
+
diff --git a/src/select/properties/align_self.c b/src/select/properties/align_self.c
new file mode 100644
index 0000000..e8e469e
--- /dev/null
+++ b/src/select/properties/align_self.c
@@ -0,0 +1,78 @@
+/*
+ * This file is part of LibCSS
+ * Licensed under the MIT License,
+ * http://www.opensource.org/licenses/mit-license.php
+ * Copyright 2017 Lucas Neves <lcneves@gmail.com>
+ */
+
+#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 css__cascade_align_self(uint32_t opv, css_style *style,
+ css_select_state *state)
+{
+ uint16_t value = CSS_ALIGN_SELF_INHERIT;
+
+ UNUSED(style);
+
+ if (isInherit(opv) == false) {
+ switch (getValue(opv)) {
+ case ALIGN_SELF_STRETCH:
+ value = CSS_ALIGN_SELF_STRETCH;
+ break;
+ case ALIGN_SELF_FLEX_START:
+ value = CSS_ALIGN_SELF_FLEX_START;
+ break;
+ case ALIGN_SELF_FLEX_END:
+ value = CSS_ALIGN_SELF_FLEX_END;
+ break;
+ case ALIGN_SELF_CENTER:
+ value = CSS_ALIGN_SELF_CENTER;
+ break;
+ case ALIGN_SELF_BASELINE:
+ value = CSS_ALIGN_SELF_BASELINE;
+ break;
+ case ALIGN_SELF_AUTO:
+ value = CSS_ALIGN_SELF_AUTO;
+ break;
+ }
+ }
+
+ if (css__outranks_existing(getOpcode(opv), isImportant(opv), state,
+ isInherit(opv))) {
+ return set_align_self(state->computed, value);
+ }
+
+ return CSS_OK;
+}
+
+css_error css__set_align_self_from_hint(const css_hint *hint,
+ css_computed_style *style)
+{
+ return set_align_self(style, hint->status);
+}
+
+css_error css__initial_align_self(css_select_state *state)
+{
+ return set_align_self(state->computed, CSS_ALIGN_SELF_AUTO);
+}
+
+css_error css__compose_align_self(const css_computed_style *parent,
+ const css_computed_style *child,
+ css_computed_style *result)
+{
+ uint8_t type = get_align_self(child);
+
+ if (type == CSS_ALIGN_SELF_INHERIT) {
+ type = get_align_self(parent);
+ }
+
+ return set_align_self(result, type);
+}
+
diff --git a/src/select/properties/display.c b/src/select/properties/display.c
index 40c2e3e..510d24a 100644
--- a/src/select/properties/display.c
+++ b/src/select/properties/display.c
@@ -71,6 +71,12 @@ css_error css__cascade_display(uint32_t opv, css_style *style,
case DISPLAY_NONE:
value = CSS_DISPLAY_NONE;
break;
+ case DISPLAY_FLEX:
+ value = CSS_DISPLAY_FLEX;
+ break;
+ case DISPLAY_INLINE_FLEX:
+ value = CSS_DISPLAY_INLINE_FLEX;
+ break;
}
}
diff --git a/src/select/properties/flex_basis.c b/src/select/properties/flex_basis.c
new file mode 100644
index 0000000..1a92a6b
--- /dev/null
+++ b/src/select/properties/flex_basis.c
@@ -0,0 +1,79 @@
+/*
+ * This file is part of LibCSS
+ * Licensed under the MIT License,
+ * http://www.opensource.org/licenses/mit-license.php
+ * Copyright 2017 Lucas Neves <lcneves@gmail.com>
+ */
+
+#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 css__cascade_flex_basis(uint32_t opv, css_style *style,
+ css_select_state *state)
+{
+ uint16_t value = CSS_FLEX_BASIS_INHERIT;
+ css_fixed length = 0;
+ uint32_t unit = UNIT_PX;
+
+ if (isInherit(opv) == false) {
+ switch (getValue(opv)) {
+ case FLEX_BASIS_AUTO:
+ value = CSS_FLEX_BASIS_AUTO;
+ break;
+ case FLEX_BASIS_CONTENT:
+ value = CSS_FLEX_BASIS_CONTENT;
+ break;
+ case FLEX_BASIS_SET:
+ value = CSS_FLEX_BASIS_SET;
+ length = *((css_fixed *) style->bytecode);
+ advance_bytecode(style, sizeof(length));
+ unit = *((uint32_t *) style->bytecode);
+ advance_bytecode(style, sizeof(unit));
+ break;
+ }
+ }
+
+ unit = css__to_css_unit(unit);
+
+ if (css__outranks_existing(getOpcode(opv), isImportant(opv), state,
+ isInherit(opv))) {
+ return set_flex_basis(state->computed, value, length, unit);
+ }
+
+ return CSS_OK;
+}
+
+css_error css__set_flex_basis_from_hint(const css_hint *hint,
+ css_computed_style *style)
+{
+ return set_flex_basis(style, hint->status,
+ hint->data.length.value, hint->data.length.unit);
+}
+
+css_error css__initial_flex_basis(css_select_state *state)
+{
+ return set_flex_basis(state->computed, CSS_FLEX_BASIS_AUTO, 0,
+ CSS_UNIT_PX);
+}
+
+css_error css__compose_flex_basis(const css_computed_style *parent,
+ const css_computed_style *child,
+ css_computed_style *result)
+{
+ css_fixed length = 0;
+ css_unit unit = CSS_UNIT_PX;
+ uint8_t type = get_flex_basis(child, &length, &unit);
+
+ if (type == CSS_FLEX_BASIS_INHERIT) {
+ type = get_flex_basis(parent, &length, &unit);
+ }
+
+ return set_flex_basis(result, type, length, unit);
+}
+
diff --git a/src/select/properties/flex_direction.c b/src/select/properties/flex_direction.c
new file mode 100644
index 0000000..79703be
--- /dev/null
+++ b/src/select/properties/flex_direction.c
@@ -0,0 +1,72 @@
+/*
+ * This file is part of LibCSS
+ * Licensed under the MIT License,
+ * http://www.opensource.org/licenses/mit-license.php
+ * Copyright 2017 Lucas Neves <lcneves@gmail.com>
+ */
+
+#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 css__cascade_flex_direction(uint32_t opv, css_style *style,
+ css_select_state *state)
+{
+ uint16_t value = CSS_FLEX_DIRECTION_INHERIT;
+
+ UNUSED(style);
+
+ if (isInherit(opv) == false) {
+ switch (getValue(opv)) {
+ case FLEX_DIRECTION_ROW:
+ value = CSS_FLEX_DIRECTION_ROW;
+ break;
+ case FLEX_DIRECTION_ROW_REVERSE:
+ value = CSS_FLEX_DIRECTION_ROW_REVERSE;
+ break;
+ case FLEX_DIRECTION_COLUMN:
+ value = CSS_FLEX_DIRECTION_COLUMN;
+ break;
+ case FLEX_DIRECTION_COLUMN_REVERSE:
+ value = CSS_FLEX_DIRECTION_COLUMN_REVERSE;
+ break;
+ }
+ }
+
+ if (css__outranks_existing(getOpcode(opv), isImportant(opv), state,
+ isInherit(opv))) {
+ return set_flex_direction(state->computed, value);
+ }
+
+ return CSS_OK;
+}
+
+css_error css__set_flex_direction_from_hint(const css_hint *hint,
+ css_computed_style *style)
+{
+ return set_flex_direction(style, hint->status);
+}
+
+css_error css__initial_flex_direction(css_select_state *state)
+{
+ return set_flex_direction(state->computed, CSS_FLEX_DIRECTION_ROW);
+}
+
+css_error css__compose_flex_direction(const css_computed_style *parent,
+ const css_computed_style *child,
+ css_computed_style *result)
+{
+ uint8_t type = get_flex_direction(child);
+
+ if (type == CSS_FLEX_DIRECTION_INHERIT) {
+ type = get_flex_direction(parent);
+ }
+
+ return set_flex_direction(result, type);
+}
+
diff --git a/src/select/properties/flex_grow.c b/src/select/properties/flex_grow.c
new file mode 100644
index 0000000..7f37cfe
--- /dev/null
+++ b/src/select/properties/flex_grow.c
@@ -0,0 +1,62 @@
+/*
+ * This file is part of LibCSS
+ * Licensed under the MIT License,
+ * http://www.opensource.org/licenses/mit-license.php
+ * Copyright 2017 Lucas Neves <lcneves@gmail.com>
+ */
+
+#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 css__cascade_flex_grow(uint32_t opv, css_style *style,
+ css_select_state *state)
+{
+ uint16_t value = CSS_FLEX_GROW_INHERIT;
+ css_fixed flex_grow = 0;
+
+ if (isInherit(opv) == false) {
+ value = CSS_FLEX_GROW_SET;
+
+ flex_grow = *((css_fixed *) style->bytecode);
+ advance_bytecode(style, sizeof(flex_grow));
+ }
+
+ if (css__outranks_existing(getOpcode(opv), isImportant(opv), state,
+ isInherit(opv))) {
+ return set_flex_grow(state->computed, value, flex_grow);
+ }
+
+ return CSS_OK;
+}
+
+css_error css__set_flex_grow_from_hint(const css_hint *hint,
+ css_computed_style *style)
+{
+ return set_flex_grow(style, hint->status, hint->data.fixed);
+}
+
+css_error css__initial_flex_grow(css_select_state *state)
+{
+ return set_flex_grow(state->computed, CSS_FLEX_GROW_SET, INTTOFIX(0));
+}
+
+css_error css__compose_flex_grow(const css_computed_style *parent,
+ const css_computed_style *child,
+ css_computed_style *result)
+{
+ css_fixed flex_grow = 0;
+ uint8_t type = get_flex_grow(child, &flex_grow);
+
+ if (type == CSS_FLEX_GROW_INHERIT) {
+ type = get_flex_grow(parent, &flex_grow);
+ }
+
+ return set_flex_grow(result, type, flex_grow);
+}
+
diff --git a/src/select/properties/flex_shrink.c b/src/select/properties/flex_shrink.c
new file mode 100644
index 0000000..d1acd2a
--- /dev/null
+++ b/src/select/properties/flex_shrink.c
@@ -0,0 +1,62 @@
+/*
+ * This file is part of LibCSS
+ * Licensed under the MIT License,
+ * http://www.opensource.org/licenses/mit-license.php
+ * Copyright 2017 Lucas Neves <lcneves@gmail.com>
+ */
+
+#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 css__cascade_flex_shrink(uint32_t opv, css_style *style,
+ css_select_state *state)
+{
+ uint16_t value = CSS_FLEX_SHRINK_INHERIT;
+ css_fixed flex_shrink = 0;
+
+ if (isInherit(opv) == false) {
+ value = CSS_FLEX_SHRINK_SET;
+
+ flex_shrink = *((css_fixed *) style->bytecode);
+ advance_bytecode(style, sizeof(flex_shrink));
+ }
+
+ if (css__outranks_existing(getOpcode(opv), isImportant(opv), state,
+ isInherit(opv))) {
+ return set_flex_shrink(state->computed, value, flex_shrink);
+ }
+
+ return CSS_OK;
+}
+
+css_error css__set_flex_shrink_from_hint(const css_hint *hint,
+ css_computed_style *style)
+{
+ return set_flex_shrink(style, hint->status, hint->data.fixed);
+}
+
+css_error css__initial_flex_shrink(css_select_state *state)
+{
+ return set_flex_shrink(state->computed, CSS_FLEX_SHRINK_SET, INTTOFIX(1));
+}
+
+css_error css__compose_flex_shrink(const css_computed_style *parent,
+ const css_computed_style *child,
+ css_computed_style *result)
+{
+ css_fixed flex_shrink = 0;
+ uint8_t type = get_flex_shrink(child, &flex_shrink);
+
+ if (type == CSS_FLEX_SHRINK_INHERIT) {
+ type = get_flex_shrink(parent, &flex_shrink);
+ }
+
+ return set_flex_shrink(result, type, flex_shrink);
+}
+
diff --git a/src/select/properties/flex_wrap.c b/src/select/properties/flex_wrap.c
new file mode 100644
index 0000000..688a9b6
--- /dev/null
+++ b/src/select/properties/flex_wrap.c
@@ -0,0 +1,69 @@
+/*
+ * This file is part of LibCSS
+ * Licensed under the MIT License,
+ * http://www.opensource.org/licenses/mit-license.php
+ * Copyright 2017 Lucas Neves <lcneves@gmail.com>
+ */
+
+#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 css__cascade_flex_wrap(uint32_t opv, css_style *style,
+ css_select_state *state)
+{
+ uint16_t value = CSS_FLEX_WRAP_INHERIT;
+
+ UNUSED(style);
+
+ if (isInherit(opv) == false) {
+ switch (getValue(opv)) {
+ case FLEX_WRAP_NOWRAP:
+ value = CSS_FLEX_WRAP_NOWRAP;
+ break;
+ case FLEX_WRAP_WRAP:
+ value = CSS_FLEX_WRAP_WRAP;
+ break;
+ case FLEX_WRAP_WRAP_REVERSE:
+ value = CSS_FLEX_WRAP_WRAP_REVERSE;
+ break;
+ }
+ }
+
+ if (css__outranks_existing(getOpcode(opv), isImportant(opv), state,
+ isInherit(opv))) {
+ return set_flex_wrap(state->computed, value);
+ }
+
+ return CSS_OK;
+}
+
+css_error css__set_flex_wrap_from_hint(const css_hint *hint,
+ css_computed_style *style)
+{
+ return set_flex_wrap(style, hint->status);
+}
+
+css_error css__initial_flex_wrap(css_select_state *state)
+{
+ return set_flex_wrap(state->computed, CSS_FLEX_WRAP_NOWRAP);
+}
+
+css_error css__compose_flex_wrap(const css_computed_style *parent,
+ const css_computed_style *child,
+ css_computed_style *result)
+{
+ uint8_t type = get_flex_wrap(child);
+
+ if (type == CSS_FLEX_WRAP_INHERIT) {
+ type = get_flex_wrap(parent);
+ }
+
+ return set_flex_wrap(result, type);
+}
+
diff --git a/src/select/properties/justify_content.c b/src/select/properties/justify_content.c
new file mode 100644
index 0000000..2e17ca5
--- /dev/null
+++ b/src/select/properties/justify_content.c
@@ -0,0 +1,79 @@
+/*
+ * This file is part of LibCSS
+ * Licensed under the MIT License,
+ * http://www.opensource.org/licenses/mit-license.php
+ * Copyright 2017 Lucas Neves <lcneves@gmail.com>
+ */
+
+#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 css__cascade_justify_content(uint32_t opv, css_style *style,
+ css_select_state *state)
+{
+ uint16_t value = CSS_JUSTIFY_CONTENT_INHERIT;
+
+ UNUSED(style);
+
+ if (isInherit(opv) == false) {
+ switch (getValue(opv)) {
+ case JUSTIFY_CONTENT_FLEX_START:
+ value = CSS_JUSTIFY_CONTENT_FLEX_START;
+ break;
+ case JUSTIFY_CONTENT_FLEX_END:
+ value = CSS_JUSTIFY_CONTENT_FLEX_END;
+ break;
+ case JUSTIFY_CONTENT_CENTER:
+ value = CSS_JUSTIFY_CONTENT_CENTER;
+ break;
+ case JUSTIFY_CONTENT_SPACE_BETWEEN:
+ value = CSS_JUSTIFY_CONTENT_SPACE_BETWEEN;
+ break;
+ case JUSTIFY_CONTENT_SPACE_AROUND:
+ value = CSS_JUSTIFY_CONTENT_SPACE_AROUND;
+ break;
+ case JUSTIFY_CONTENT_SPACE_EVENLY:
+ value = CSS_JUSTIFY_CONTENT_SPACE_EVENLY;
+ break;
+ }
+ }
+
+ if (css__outranks_existing(getOpcode(opv), isImportant(opv), state,
+ isInherit(opv))) {
+ return set_justify_content(state->computed, value);
+ }
+
+ return CSS_OK;
+}
+
+css_error css__set_justify_content_from_hint(const css_hint *hint,
+ css_computed_style *style)
+{
+ return set_justify_content(style, hint->status);
+}
+
+css_error css__initial_justify_content(css_select_state *state)
+{
+ return set_justify_content(state->computed,
+ CSS_JUSTIFY_CONTENT_FLEX_START);
+}
+
+css_error css__compose_justify_content(const css_computed_style *parent,
+ const css_computed_style *child,
+ css_computed_style *result)
+{
+ uint8_t type = get_justify_content(child);
+
+ if (type == CSS_JUSTIFY_CONTENT_INHERIT) {
+ type = get_justify_content(parent);
+ }
+
+ return set_justify_content(result, type);
+}
+
diff --git a/src/select/properties/min_height.c b/src/select/properties/min_height.c
index 687d8a1..a5389ce 100644
--- a/src/select/properties/min_height.c
+++ b/src/select/properties/min_height.c
@@ -17,7 +17,7 @@
css_error css__cascade_min_height(uint32_t opv, css_style *style,
css_select_state *state)
{
- return css__cascade_length(opv, style, state, set_min_height);
+ return css__cascade_length_auto(opv, style, state, set_min_height);
}
css_error css__set_min_height_from_hint(const css_hint *hint,
@@ -29,7 +29,7 @@ css_error css__set_min_height_from_hint(const css_hint *hint,
css_error css__initial_min_height(css_select_state *state)
{
- return set_min_height(state->computed, CSS_MIN_HEIGHT_SET,
+ return set_min_height(state->computed, CSS_MIN_HEIGHT_AUTO,
0, CSS_UNIT_PX);
}
diff --git a/src/select/properties/min_width.c b/src/select/properties/min_width.c
index 5365588..8460e01 100644
--- a/src/select/properties/min_width.c
+++ b/src/select/properties/min_width.c
@@ -17,7 +17,7 @@
css_error css__cascade_min_width(uint32_t opv, css_style *style,
css_select_state *state)
{
- return css__cascade_length(opv, style, state, set_min_width);
+ return css__cascade_length_auto(opv, style, state, set_min_width);
}
css_error css__set_min_width_from_hint(const css_hint *hint,
@@ -29,7 +29,8 @@ css_error css__set_min_width_from_hint(const css_hint *hint,
css_error css__initial_min_width(css_select_state *state)
{
- return set_min_width(state->computed, CSS_MIN_WIDTH_SET, 0, CSS_UNIT_PX);
+ return set_min_width(state->computed, CSS_MIN_WIDTH_AUTO,
+ 0, CSS_UNIT_PX);
}
css_error css__compose_min_width(const css_computed_style *parent,
diff --git a/src/select/properties/order.c b/src/select/properties/order.c
new file mode 100644
index 0000000..0366537
--- /dev/null
+++ b/src/select/properties/order.c
@@ -0,0 +1,62 @@
+/*
+ * This file is part of LibCSS
+ * Licensed under the MIT License,
+ * http://www.opensource.org/licenses/mit-license.php
+ * Copyright 2017 Lucas Neves <lcneves@gmail.com>
+ */
+
+#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 css__cascade_order(uint32_t opv, css_style *style,
+ css_select_state *state)
+{
+ uint16_t value = CSS_ORDER_INHERIT;
+ css_fixed order = 0;
+
+ if (isInherit(opv) == false) {
+ value = CSS_ORDER_SET;
+
+ order = FIXTOINT(*((css_fixed *) style->bytecode));
+ advance_bytecode(style, sizeof(order));
+ }
+
+ if (css__outranks_existing(getOpcode(opv), isImportant(opv), state,
+ isInherit(opv))) {
+ return set_order(state->computed, value, order);
+ }
+
+ return CSS_OK;
+}
+
+css_error css__set_order_from_hint(const css_hint *hint,
+ css_computed_style *style)
+{
+ return set_order(style, hint->status, hint->data.integer);
+}
+
+css_error css__initial_order(css_select_state *state)
+{
+ return set_order(state->computed, CSS_ORDER_SET, 0);
+}
+
+css_error css__compose_order(const css_computed_style *parent,
+ const css_computed_style *child,
+ css_computed_style *result)
+{
+ int32_t order = 0;
+ uint8_t type = get_order(child, &order);
+
+ if (type == CSS_ORDER_INHERIT) {
+ type = get_order(parent, &order);
+ }
+
+ return set_order(result, type, order);
+}
+
diff --git a/src/select/properties/properties.h b/src/select/properties/properties.h
index a1ab49f..6eac397 100644
--- a/src/select/properties/properties.h
+++ b/src/select/properties/properties.h
@@ -21,6 +21,9 @@
css_error css__compose_##pname (const css_computed_style *parent, const css_computed_style *child, css_computed_style *result); \
uint32_t destroy_##pname (void *bytecode)
+PROPERTY_FUNCS(align_content);
+PROPERTY_FUNCS(align_items);
+PROPERTY_FUNCS(align_self);
PROPERTY_FUNCS(azimuth);
PROPERTY_FUNCS(background_attachment);
PROPERTY_FUNCS(background_color);
@@ -68,6 +71,11 @@ PROPERTY_FUNCS(direction);
PROPERTY_FUNCS(display);
PROPERTY_FUNCS(elevation);
PROPERTY_FUNCS(empty_cells);
+PROPERTY_FUNCS(flex_basis);
+PROPERTY_FUNCS(flex_direction);
+PROPERTY_FUNCS(flex_grow);
+PROPERTY_FUNCS(flex_shrink);
+PROPERTY_FUNCS(flex_wrap);
PROPERTY_FUNCS(float);
PROPERTY_FUNCS(font_family);
PROPERTY_FUNCS(font_size);
@@ -75,6 +83,7 @@ PROPERTY_FUNCS(font_style);
PROPERTY_FUNCS(font_variant);
PROPERTY_FUNCS(font_weight);
PROPERTY_FUNCS(height);
+PROPERTY_FUNCS(justify_content);
PROPERTY_FUNCS(left);
PROPERTY_FUNCS(letter_spacing);
PROPERTY_FUNCS(line_height);
@@ -90,6 +99,7 @@ PROPERTY_FUNCS(max_width);
PROPERTY_FUNCS(min_height);
PROPERTY_FUNCS(min_width);
PROPERTY_FUNCS(opacity);
+PROPERTY_FUNCS(order);
PROPERTY_FUNCS(orphans);
PROPERTY_FUNCS(outline_color);
PROPERTY_FUNCS(outline_style);