summaryrefslogtreecommitdiff
path: root/src/select/properties/box_sizing.c
diff options
context:
space:
mode:
authorMichael Drake <michael.drake@codethink.co.uk>2017-04-27 14:13:44 +0100
committerMichael Drake <michael.drake@codethink.co.uk>2017-04-27 14:13:44 +0100
commita0d2da319d3c13549e24ac012c9dbb2b22fdb957 (patch)
tree005e54c5b37286c0cc9c355acce149ccd935c439 /src/select/properties/box_sizing.c
parent4729f01919b7ba3f99abfea8900931616fbb8320 (diff)
parentab5bd6f9d75878740cfe98581bdd8f8ba614853d (diff)
downloadlibcss-a0d2da319d3c13549e24ac012c9dbb2b22fdb957.tar.gz
libcss-a0d2da319d3c13549e24ac012c9dbb2b22fdb957.tar.bz2
Merge branch 'tlsa/box-sizing'
Diffstat (limited to 'src/select/properties/box_sizing.c')
-rw-r--r--src/select/properties/box_sizing.c67
1 files changed, 67 insertions, 0 deletions
diff --git a/src/select/properties/box_sizing.c b/src/select/properties/box_sizing.c
new file mode 100644
index 0000000..91c475d
--- /dev/null
+++ b/src/select/properties/box_sizing.c
@@ -0,0 +1,67 @@
+/*
+ * This file is part of LibCSS
+ * Licensed under the MIT License,
+ * http://www.opensource.org/licenses/mit-license.php
+ * Copyright 2017 Michael Drake <tlsa@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 css__cascade_box_sizing(uint32_t opv, css_style *style,
+ css_select_state *state)
+{
+ uint16_t value = CSS_BOX_SIZING_INHERIT;
+
+ UNUSED(style);
+
+ if (isInherit(opv) == false) {
+ switch (getValue(opv)) {
+ case BOX_SIZING_CONTENT_BOX:
+ value = CSS_BOX_SIZING_CONTENT_BOX;
+ break;
+ case BOX_SIZING_BORDER_BOX:
+ value = CSS_BOX_SIZING_BORDER_BOX;
+ break;
+ }
+ }
+
+ if (css__outranks_existing(getOpcode(opv), isImportant(opv), state,
+ isInherit(opv))) {
+ return set_box_sizing(state->computed, value);
+ }
+
+ return CSS_OK;
+}
+
+css_error css__set_box_sizing_from_hint(const css_hint *hint,
+ css_computed_style *style)
+{
+ return set_box_sizing(style, hint->status);
+}
+
+css_error css__initial_box_sizing(css_select_state *state)
+{
+ return set_box_sizing(state->computed, CSS_BOX_SIZING_CONTENT_BOX);
+}
+
+css_error css__compose_box_sizing(
+ const css_computed_style *parent,
+ const css_computed_style *child,
+ css_computed_style *result)
+{
+ uint8_t type = get_box_sizing(child);
+
+ if (type == CSS_BOX_SIZING_INHERIT) {
+ type = get_box_sizing(parent);
+ }
+
+ return set_box_sizing(result, type);
+}
+