Gitweb links:

...log 
http://git.netsurf-browser.org/libcss.git/shortlog/14eedd480ab3a6b39effa1bc1405ea5c05cfc1bf
...commit 
http://git.netsurf-browser.org/libcss.git/commit/14eedd480ab3a6b39effa1bc1405ea5c05cfc1bf
...tree 
http://git.netsurf-browser.org/libcss.git/tree/14eedd480ab3a6b39effa1bc1405ea5c05cfc1bf

The branch, tlsa/calc-wip has been updated
  discards  110ee41e0a4d697c5dfb74b4be3b1622c03fba65 (commit)
  discards  bb4f667d633a2640f3673cf269b98af1e1b24ea1 (commit)
  discards  6a361f59639e23e50f0dbd18d6c28ca330e288cb (commit)
  discards  870585f3cd0320e5813a39bec5827cf76f4102b5 (commit)
  discards  93d6d6d2b7480bbbc0b13b69e151870b4cbfb465 (commit)
  discards  88c8258aabef042da70e419141a8d8e198673225 (commit)
  discards  4702422440022bfd64bdf6e221c8f89fd2923fda (commit)
       via  14eedd480ab3a6b39effa1bc1405ea5c05cfc1bf (commit)
       via  f5f4bf1abc8523c7c096cf66d83849bb43cc4c8e (commit)
       via  05a9ed4f74162f8e53a4bc6620d7f8ca06b10434 (commit)
       via  c4eabbb07c93c6f9704121214adbe1207cfd3756 (commit)
       via  8a1f5b2a29ceecf6202ad0635f15b36662d2275b (commit)
       via  11b4249c8ed58468632e25b31ae7d4690f90d102 (commit)
       via  6afa3f74544d124d5c76688701373beb1b554216 (commit)
       via  d6a1adfd3390d063da2e405a208151dcb491fc9d (commit)
       via  f5842253bdb62fef9543e58ae38c232f5b4f982a (commit)
       via  b441838df4b58902c64eef094c635c23c8321895 (commit)
       via  df45c6cfb4c385e8a7d6d85d78b5dca7844c37f5 (commit)

This update added new revisions after undoing existing revisions.  That is
to say, the old revision is not a strict subset of the new revision.  This
situation occurs when you --force push a change and generate a repository
containing something like this:

 * -- * -- B -- O -- O -- O (110ee41e0a4d697c5dfb74b4be3b1622c03fba65)
            \
             N -- N -- N (14eedd480ab3a6b39effa1bc1405ea5c05cfc1bf)

When this happens we assume that you've already had alert emails for all
of the O revisions, and so we here report only the revisions in the N
branch from the common base, B.

Those revisions listed above that are new to this repository have
not appeared on any other notification email; so we list those
revisions in full, below.

- Log -----------------------------------------------------------------
commitdiff 
http://git.netsurf-browser.org/libcss.git/commit/?id=14eedd480ab3a6b39effa1bc1405ea5c05cfc1bf
commit 14eedd480ab3a6b39effa1bc1405ea5c05cfc1bf
Author: Michael Drake <[email protected]>
Commit: Michael Drake <[email protected]>

    WIP: Add calc() handling to appropriate properties

diff --git a/src/select/autogenerated_computed.h 
b/src/select/autogenerated_computed.h
index c65cf98..ae9f09c 100644
--- a/src/select/autogenerated_computed.h
+++ b/src/select/autogenerated_computed.h
@@ -5,6 +5,11 @@
  * Copyright 2017 The NetSurf Project
  */
 
+typedef union {
+       css_fixed value;
+       lwc_string *calc;
+} css_fixed_or_calc;
+
 
 struct css_computed_style_i {
 /*
@@ -209,7 +214,7 @@ struct css_computed_style_i {
        css_fixed background_position_a;
        css_fixed background_position_b;
        css_color border_bottom_color;
-       css_fixed border_bottom_width;
+       css_fixed_or_calc border_bottom_width;
        css_color border_left_color;
        css_fixed border_left_width;
        css_color border_right_color;
@@ -218,7 +223,7 @@ struct css_computed_style_i {
        css_fixed border_spacing_b;
        css_color border_top_color;
        css_fixed border_top_width;
-       css_fixed bottom;
+       css_fixed_or_calc bottom;
        css_fixed clip_a;
        css_fixed clip_b;
        css_fixed clip_c;
diff --git a/src/select/autogenerated_propget.h 
b/src/select/autogenerated_propget.h
index 6c958aa..7b6bac2 100644
--- a/src/select/autogenerated_propget.h
+++ b/src/select/autogenerated_propget.h
@@ -299,7 +299,7 @@ static inline uint8_t get_border_bottom_width_bits(const 
css_computed_style
        return (bits & 0x7);
 }
 static inline uint8_t get_border_bottom_width(const css_computed_style *style,
-               css_fixed *length, css_unit *unit)
+               css_fixed_or_calc *length, css_unit *unit)
 {
        uint32_t bits = style->i.bits[BORDER_BOTTOM_WIDTH_INDEX];
        bits &= BORDER_BOTTOM_WIDTH_MASK;
@@ -650,8 +650,8 @@ static inline uint8_t get_bottom_bits(const 
css_computed_style *style)
        /* 7bits: uuuuutt : unit | type */
        return (bits & 0x3);
 }
-static inline uint8_t get_bottom(const css_computed_style *style, css_fixed
-               *length, css_unit *unit)
+static inline uint8_t get_bottom(const css_computed_style *style,
+               css_fixed_or_calc *length, css_unit *unit)
 {
        uint32_t bits = style->i.bits[BOTTOM_INDEX];
        bits &= BOTTOM_MASK;
diff --git a/src/select/autogenerated_propset.h 
b/src/select/autogenerated_propset.h
index 71d1596..7d29755 100644
--- a/src/select/autogenerated_propset.h
+++ b/src/select/autogenerated_propset.h
@@ -5,8 +5,8 @@
  * Copyright 2017 The NetSurf Project
  */
 
-/** Default values are 'initial value', unless the property is inherited,
- *  in which case it is 'inherit'. */
+#include "select/propget.h"
+
 
 #define ALIGN_CONTENT_INDEX 10
 #define ALIGN_CONTENT_SHIFT 20
@@ -222,15 +222,26 @@ static inline css_error 
set_border_bottom_style(css_computed_style *style,
 #define BORDER_BOTTOM_WIDTH_MASK 0xff
 
 static inline css_error set_border_bottom_width(css_computed_style *style,
-               uint8_t type, css_fixed length, css_unit unit)
+               uint8_t type, css_fixed_or_calc length, css_unit unit)
 {
+       uint32_t orig_bits = get_border_bottom_width_bits(style);
+       
+       /* 8bits: uuuuuttt : unit | type */
+       if ((orig_bits & 0x7) == CSS_BORDER_WIDTH_WIDTH) {
+               if ((orig_bits & 0xf8) >> 3 == CSS_UNIT_CALC) {
+                       lwc_string_unref(style->i.border_bottom_width.calc);
+               }
+       }
+       
        uint32_t *bits = &style->i.bits[BORDER_BOTTOM_WIDTH_INDEX];
        
        /* 8bits: uuuuuttt : unit | type */
        *bits = (*bits & ~BORDER_BOTTOM_WIDTH_MASK) | ((((uint32_t)type & 0x7)
                        | (unit << 3)) << BORDER_BOTTOM_WIDTH_SHIFT);
        
-       style->i.border_bottom_width = length;
+       if (unit == CSS_UNIT_CALC) {
+               style->i.border_bottom_width.calc = lwc_string_ref(length.calc);
+       }
        
        return CSS_OK;
 }
@@ -469,15 +480,26 @@ static inline css_error 
set_border_top_width(css_computed_style *style, uint8_t
 #define BOTTOM_MASK 0x3f800
 
 static inline css_error set_bottom(css_computed_style *style, uint8_t type,
-               css_fixed length, css_unit unit)
+               css_fixed_or_calc length, css_unit unit)
 {
+       uint32_t orig_bits = get_bottom_bits(style);
+       
+       /* 7bits: uuuuutt : unit | type */
+       if ((orig_bits & 0x3) == CSS_BOTTOM_SET) {
+               if ((orig_bits & 0x7c) >> 2 == CSS_UNIT_CALC) {
+                       lwc_string_unref(style->i.bottom.calc);
+               }
+       }
+       
        uint32_t *bits = &style->i.bits[BOTTOM_INDEX];
        
        /* 7bits: uuuuutt : unit | type */
        *bits = (*bits & ~BOTTOM_MASK) | ((((uint32_t)type & 0x3) | (unit <<
                        2)) << BOTTOM_SHIFT);
        
-       style->i.bottom = length;
+       if (unit == CSS_UNIT_CALC) {
+               style->i.bottom.calc = lwc_string_ref(length.calc);
+       }
        
        return CSS_OK;
 }
diff --git a/src/select/computed.c b/src/select/computed.c
index c257f17..85d53e5 100644
--- a/src/select/computed.c
+++ b/src/select/computed.c
@@ -30,6 +30,12 @@ static css_error 
compute_absolute_border_side_width(css_computed_style *style,
                                css_fixed *len, css_unit *unit),
                css_error (*set)(css_computed_style *style, uint8_t type,
                                css_fixed len, css_unit unit));
+static css_error compute_absolute_border_side_width_calc(css_computed_style 
*style,
+               const css_hint_length *ex_size,
+               uint8_t (*get)(const css_computed_style *style,
+                               css_fixed_or_calc *len, css_unit *unit),
+               css_error (*set)(css_computed_style *style, uint8_t type,
+                               css_fixed_or_calc len, css_unit unit));
 static css_error compute_absolute_sides(css_computed_style *style,
                const css_hint_length *ex_size);
 static css_error compute_absolute_clip(css_computed_style *style,
@@ -48,6 +54,12 @@ static css_error compute_absolute_length(css_computed_style 
*style,
                                css_fixed *len, css_unit *unit),
                css_error (*set)(css_computed_style *style, uint8_t type,
                                css_fixed len, css_unit unit));
+static css_error compute_absolute_length_calc(css_computed_style *style,
+               const css_hint_length *ex_size,
+               uint8_t (*get)(const css_computed_style *style,
+                               css_fixed_or_calc *len, css_unit *unit),
+               css_error (*set)(css_computed_style *style, uint8_t type,
+                               css_fixed_or_calc len, css_unit unit));
 static css_error compute_absolute_length_pair(css_computed_style *style,
                const css_hint_length *ex_size,
                uint8_t (*get)(const css_computed_style *style,
@@ -419,7 +431,18 @@ uint8_t css_computed_border_right_width(const 
css_computed_style *style,
 uint8_t css_computed_border_bottom_width(const css_computed_style *style,
                css_fixed *length, css_unit *unit)
 {
-       return get_border_bottom_width(style, length, unit);
+       css_fixed_or_calc temp;
+       uint8_t type = get_border_bottom_width(style, &temp, unit);
+
+       if (type == CSS_BORDER_WIDTH_WIDTH) {
+               if (*unit == CSS_UNIT_CALC) {
+                       /* TODO */
+               } else {
+                       *length = temp.value;
+               }
+       }
+
+       return type;
 }
 
 uint8_t css_computed_border_left_width(const css_computed_style *style,
@@ -472,7 +495,7 @@ uint8_t css_computed_top(const css_computed_style *style,
                        *unit = CSS_UNIT_PX;
                } else if (top == CSS_TOP_AUTO) {
                        /* Top is auto => -bottom */
-                       *length = -style->i.bottom;
+                       *length = -style->i.bottom.value;
                        *unit = (css_unit) (bottom >> 2);
                }
 
@@ -1448,7 +1471,7 @@ css_error 
compute_absolute_border_width(css_computed_style *style,
        if (error != CSS_OK)
                return error;
 
-       error = compute_absolute_border_side_width(style, ex_size,
+       error = compute_absolute_border_side_width_calc(style, ex_size,
                        get_border_bottom_width,
                        set_border_bottom_width);
        if (error != CSS_OK)
@@ -1509,6 +1532,51 @@ css_error 
compute_absolute_border_side_width(css_computed_style *style,
 }
 
 /**
+ * Compute an absolute border side width
+ *
+ * \param style      Style to process
+ * \param ex_size    Ex size, in ems
+ * \param get        Function to read length
+ * \param set        Function to write length
+ * \return CSS_OK on success
+ */
+css_error compute_absolute_border_side_width_calc(css_computed_style *style,
+               const css_hint_length *ex_size,
+               uint8_t (*get)(const css_computed_style *style,
+                               css_fixed_or_calc *len, css_unit *unit),
+               css_error (*set)(css_computed_style *style, uint8_t type,
+                               css_fixed_or_calc len, css_unit unit))
+{
+       css_fixed_or_calc length;
+       css_unit unit;
+
+       switch (get(style, &length, &unit)) {
+       case CSS_BORDER_WIDTH_THIN:
+               length.value = INTTOFIX(1);
+               unit = CSS_UNIT_PX;
+               break;
+       case CSS_BORDER_WIDTH_MEDIUM:
+               length.value = INTTOFIX(2);
+               unit = CSS_UNIT_PX;
+               break;
+       case CSS_BORDER_WIDTH_THICK:
+               length.value = INTTOFIX(4);
+               unit = CSS_UNIT_PX;
+               break;
+       case CSS_BORDER_WIDTH_WIDTH:
+               if (unit == CSS_UNIT_EX) {
+                       length.value = FMUL(length.value, ex_size->value);
+                       unit = ex_size->unit;
+               }
+               break;
+       default:
+               return CSS_INVALID;
+       }
+
+       return set(style, CSS_BORDER_WIDTH_WIDTH, length, unit);
+}
+
+/**
  * Compute absolute clip
  *
  * \param style      Style to process
@@ -1613,7 +1681,7 @@ css_error compute_absolute_sides(css_computed_style 
*style,
        if (error != CSS_OK)
                return error;
 
-       error = compute_absolute_length(style, ex_size,
+       error = compute_absolute_length_calc(style, ex_size,
                        get_bottom, set_bottom);
        if (error != CSS_OK)
                return error;
@@ -1759,6 +1827,38 @@ css_error compute_absolute_length(css_computed_style 
*style,
        return CSS_OK;
 }
 
+/**
+ * Compute the absolute value of length
+ *
+ * \param style      Style to process
+ * \param ex_size    Ex size, in ems
+ * \param get        Function to read length
+ * \param set        Function to write length
+ * \return CSS_OK on success
+ */
+css_error compute_absolute_length_calc(css_computed_style *style,
+               const css_hint_length *ex_size,
+               uint8_t (*get)(const css_computed_style *style,
+                               css_fixed_or_calc *len, css_unit *unit),
+               css_error (*set)(css_computed_style *style, uint8_t type,
+                               css_fixed_or_calc len, css_unit unit))
+{
+       css_unit unit = CSS_UNIT_PX;
+       css_fixed_or_calc length;
+       uint8_t type;
+
+       type = get(style, &length, &unit);
+
+       if (type == CSS_WIDTH_SET && unit == CSS_UNIT_EX) {
+               length.value = FMUL(length.value, ex_size->value);
+               unit = ex_size->unit;
+
+               return set(style, type, length, unit);
+       }
+
+       return CSS_OK;
+}
+
 
 /**
  * Compute the absolute value of length pair
diff --git a/src/select/select_config.py b/src/select/select_config.py
index fd9e765..bc22ea4 100644
--- a/src/select/select_config.py
+++ b/src/select/select_config.py
@@ -72,11 +72,11 @@ style = {
     ('border_left_color', 2, 'color'),
     ('border_top_width', 3, 'length', 'CSS_BORDER_WIDTH_WIDTH'),
     ('border_right_width', 3, 'length', 'CSS_BORDER_WIDTH_WIDTH'),
-    ('border_bottom_width', 3, 'length', 'CSS_BORDER_WIDTH_WIDTH'),
+    ('border_bottom_width', 3, (('length', None, 'calc'),), 
'CSS_BORDER_WIDTH_WIDTH'),
     ('border_left_width', 3, 'length', 'CSS_BORDER_WIDTH_WIDTH'),
     ('top', 2, 'length', 'CSS_TOP_SET', None, None, 'get'),
     ('right', 2, 'length', 'CSS_RIGHT_SET', None, None, 'get'),
-    ('bottom', 2, 'length', 'CSS_BOTTOM_SET', None, None, 'get'),
+    ('bottom', 2, (('length', None, 'calc'),), 'CSS_BOTTOM_SET', None, None, 
'get'),
     ('left', 2, 'length', 'CSS_LEFT_SET', None, None, 'get'),
     ('color', 1, 'color'),
     ('flex_basis', 2, 'length', 'CSS_FLEX_BASIS_SET'),


commitdiff 
http://git.netsurf-browser.org/libcss.git/commit/?id=f5f4bf1abc8523c7c096cf66d83849bb43cc4c8e
commit f5f4bf1abc8523c7c096cf66d83849bb43cc4c8e
Author: Michael Drake <[email protected]>
Commit: Michael Drake <[email protected]>

    select: Update computed style data structure for calc()

diff --git a/include/libcss/types.h b/include/libcss/types.h
index 3fb28d3..c0b19da 100644
--- a/include/libcss/types.h
+++ b/include/libcss/types.h
@@ -109,7 +109,9 @@ typedef enum css_unit {
        CSS_UNIT_S                  = 0x1a,
 
        CSS_UNIT_HZ                 = 0x1b,
-       CSS_UNIT_KHZ                = 0x1c
+       CSS_UNIT_KHZ                = 0x1c,
+
+       CSS_UNIT_CALC               = 0x1d  /**< Un-resolved calc() */
 } css_unit;
 
 /**
diff --git a/src/parse/properties/font.c b/src/parse/properties/font.c
index 7ce9701..b77e65c 100644
--- a/src/parse/properties/font.c
+++ b/src/parse/properties/font.c
@@ -45,6 +45,7 @@ static inline uint32_t css__to_parse_unit(css_unit u)
        case CSS_UNIT_S:    return UNIT_S;
        case CSS_UNIT_HZ:   return UNIT_HZ;
        case CSS_UNIT_KHZ:  return UNIT_KHZ;
+       case CSS_UNIT_CALC: assert(0);
        }
 
        return 0;
diff --git a/src/select/assets.py b/src/select/assets.py
index 67c6b6b..7786be4 100644
--- a/src/select/assets.py
+++ b/src/select/assets.py
@@ -12,16 +12,27 @@ copyright = '''\
  */
 '''
 
+include_propget = '''\
+
+#include "select/propget.h"
+'''
+
+calc_unions = '''\
+
+typedef union {
+       css_fixed value;
+       lwc_string *calc;
+} css_fixed_or_calc;
+'''
+
 assets = {}
 
 assets['computed.h'] = {}
-assets['computed.h']['header'] = copyright
+assets['computed.h']['header'] = copyright + calc_unions
 assets['computed.h']['footer'] = ''
 
 assets['propset.h'] = {}
-assets['propset.h']['header'] = copyright + '''
-/** Default values are 'initial value', unless the property is inherited,
- *  in which case it is 'inherit'. */'''
+assets['propset.h']['header'] = copyright + include_propget
 assets['propset.h']['footer'] = ''
 
 assets['propget.h'] = {}
diff --git a/src/select/select_generator.py b/src/select/select_generator.py
index 9e92909..2ea80e1 100644
--- a/src/select/select_generator.py
+++ b/src/select/select_generator.py
@@ -167,6 +167,7 @@ class CSSValue:
         self.size = size #  `None` means sizeof(ptr)
         self.defaults = defaults
         self.suffix = ''
+        self.calc = False
         self.bits = None if bits_size is None else {
             'name': bits_name,
             'type': bits_type,
@@ -223,6 +224,13 @@ class CSSProperty:
 
     def make_values(self, vals):
         """Make list of values for this property."""
+        self.has_calc = False
+
+        if vals is not None and any(len(val) > 2 and val[2] == 'calc' for val 
in vals):
+            self.has_calc = True
+
+        print(f"name: {self.name}, {vals}, has calc: {self.has_calc}")
+
         if vals is None:
             return []
         elif type(vals) is str:
@@ -233,8 +241,10 @@ class CSSProperty:
                 for x in values:
                     if x[0] == v[0]:
                         value = CSSValue(*x)
-                        if len(v) == 2:
+                        if len(v) > 1 and v[1] != None:
                             value.defaults = v[1]
+                        if len(v) > 2 and v[2] == 'calc':
+                            value.calc = True
                         if len(vals) > 1:
                             value.suffix = '_' + string.ascii_lowercase[i]
                         val_list.append(value)
@@ -322,13 +332,14 @@ class CSSProperty:
         """
         vals = []
         for v in self.values:
+            or_calc = '_or_calc' if v.calc else ''
             star = '*' if pointer else ''
             vt, vn = shift_star(v.type, v.name)
             vn = star + vn + v.suffix
             if pointer:
                 if v.name == 'counter_arr' or v.name == 'content_item':
                     vt = 'const ' + vt
-            vals.append((vt, vn))
+            vals.append((vt + or_calc, vn))
             if v.bits is not None:
                 bt = v.bits['type']
                 bn = star + v.bits['name'] + v.suffix
@@ -522,6 +533,25 @@ class CSSGroup:
             t.append('{')
             t.indent(1)
 
+            # Ensure any existing calc() values are freed
+            if p.has_calc:
+                t.append('uint32_t orig_bits = 
get_{}_bits(style);'.format(p.name))
+                t.append()
+
+                type_mask, shift_list, bits_comment = p.get_bits()
+                t.append(bits_comment)
+                t.append('if ((orig_bits & {}) == {}) {{'.format(type_mask, 
p.condition))
+                t.indent(1)
+                for i, v in enumerate(list(reversed(shift_list))):
+                    t.append('if ((orig_bits & 0x{:x}) >> {} == CSS_UNIT_CALC) 
{{'.format(v[2], v[1]))
+                    t.indent(1)
+                    
t.append('lwc_string_unref(style->i.{}.calc);'.format(p.name))
+                    t.indent(-1)
+                    t.append('}')
+                t.indent(-1)
+                t.append('}')
+                t.append()
+
             t.append('uint32_t *bits = 
&style->i.bits[{}_INDEX];'.format(p.name.upper()))
             t.append()
 
@@ -597,8 +627,14 @@ class CSSGroup:
                     t.append('}')
 
                 elif not v.is_ptr:
-                    t.append('style->i.{} = {};'.format(
-                        p.name + v.suffix, v.name + v.suffix))
+                    if p.has_calc:
+                        t.append('if (unit == CSS_UNIT_CALC) {')
+                        t.append('\tstyle->i.{}.calc = 
lwc_string_ref({}.calc);'.format(
+                                 p.name + v.suffix, v.name + v.suffix))
+                        t.append('}')
+                    else:
+                        t.append('style->i.{} = {};'.format(
+                            p.name + v.suffix, v.name + v.suffix))
 
                 else:
                     raise ValueError('Cannot handle value ' + v.name +'!')
@@ -638,6 +674,7 @@ class CSSGroup:
                 t.indent(1)
 
             for v in p.values:
+                print(f"name: {p.name}, has_calc: {p.has_calc}, v.name: 
{v.name}")
                 i_dot = '' if v.is_ptr and v.name != 'string' else 'i.'
                 t.append('*{} = style->{}{};'.format(
                     v.name + v.suffix, i_dot, p.name + v.suffix))
@@ -690,9 +727,12 @@ class CSSGroup:
         r = []
         for p in sorted(self.props, key=(lambda x: x.name)):
             if bool(p.comments) == for_commented:
+                if (p.values == None or len(p.values) == 0):
+                    continue
                 for v in p.values:
+                    or_calc = '_or_calc' if v.calc else ''
                     v_type, v_name = shift_star(v.type, p.name)
-                    r.append('{} {}{};'.format(v_type, v_name, v.suffix))
+                    r.append('{} {}{};'.format(v_type + or_calc, v_name, 
v.suffix))
         return r
 
     def make_text(self, filename):
diff --git a/test/dump_computed.h b/test/dump_computed.h
index 2ce7849..fd6923b 100644
--- a/test/dump_computed.h
+++ b/test/dump_computed.h
@@ -159,6 +159,9 @@ static size_t dump_css_unit(css_fixed val, css_unit unit, 
char *ptr, size_t len)
        case CSS_UNIT_KHZ:
                ret += snprintf(ptr + ret, len - ret, "kHz");
                break;
+       case CSS_UNIT_CALC:
+               ret += snprintf(ptr + ret, len - ret, "calc()");
+               break;
        }
 
        return ret;


-----------------------------------------------------------------------

Summary of changes:
 src/select/assets.py                |   19 +-
 src/select/autogenerated_computed.h |   16 +-
 src/select/autogenerated_propget.h  |   10 +-
 src/select/autogenerated_propset.h  |  440 +++++++++--------------------------
 src/select/computed.c               |  106 ++++++++-
 src/select/select_generator.py      |  234 +++++--------------
 6 files changed, 300 insertions(+), 525 deletions(-)

diff --git a/src/select/assets.py b/src/select/assets.py
index 67c6b6b..7786be4 100644
--- a/src/select/assets.py
+++ b/src/select/assets.py
@@ -12,16 +12,27 @@ copyright = '''\
  */
 '''
 
+include_propget = '''\
+
+#include "select/propget.h"
+'''
+
+calc_unions = '''\
+
+typedef union {
+       css_fixed value;
+       lwc_string *calc;
+} css_fixed_or_calc;
+'''
+
 assets = {}
 
 assets['computed.h'] = {}
-assets['computed.h']['header'] = copyright
+assets['computed.h']['header'] = copyright + calc_unions
 assets['computed.h']['footer'] = ''
 
 assets['propset.h'] = {}
-assets['propset.h']['header'] = copyright + '''
-/** Default values are 'initial value', unless the property is inherited,
- *  in which case it is 'inherit'. */'''
+assets['propset.h']['header'] = copyright + include_propget
 assets['propset.h']['footer'] = ''
 
 assets['propget.h'] = {}
diff --git a/src/select/autogenerated_computed.h 
b/src/select/autogenerated_computed.h
index db779ff..ae9f09c 100644
--- a/src/select/autogenerated_computed.h
+++ b/src/select/autogenerated_computed.h
@@ -5,6 +5,11 @@
  * Copyright 2017 The NetSurf Project
  */
 
+typedef union {
+       css_fixed value;
+       lwc_string *calc;
+} css_fixed_or_calc;
+
 
 struct css_computed_style_i {
 /*
@@ -209,10 +214,7 @@ struct css_computed_style_i {
        css_fixed background_position_a;
        css_fixed background_position_b;
        css_color border_bottom_color;
-       union {
-               css_fixed value;
-               lwc_string *calc;
-       } border_bottom_width;
+       css_fixed_or_calc border_bottom_width;
        css_color border_left_color;
        css_fixed border_left_width;
        css_color border_right_color;
@@ -221,10 +223,7 @@ struct css_computed_style_i {
        css_fixed border_spacing_b;
        css_color border_top_color;
        css_fixed border_top_width;
-       union {
-               css_fixed value;
-               lwc_string *calc;
-       } bottom;
+       css_fixed_or_calc bottom;
        css_fixed clip_a;
        css_fixed clip_b;
        css_fixed clip_c;
@@ -269,7 +268,6 @@ struct css_computed_style_i {
        css_fixed width;
        css_fixed word_spacing;
        int32_t z_index;
-       
 };
 
 struct css_computed_style {
diff --git a/src/select/autogenerated_propget.h 
b/src/select/autogenerated_propget.h
index ef2d74e..7b6bac2 100644
--- a/src/select/autogenerated_propget.h
+++ b/src/select/autogenerated_propget.h
@@ -299,7 +299,7 @@ static inline uint8_t get_border_bottom_width_bits(const 
css_computed_style
        return (bits & 0x7);
 }
 static inline uint8_t get_border_bottom_width(const css_computed_style *style,
-               css_fixed *length, css_unit *unit)
+               css_fixed_or_calc *length, css_unit *unit)
 {
        uint32_t bits = style->i.bits[BORDER_BOTTOM_WIDTH_INDEX];
        bits &= BORDER_BOTTOM_WIDTH_MASK;
@@ -307,7 +307,7 @@ static inline uint8_t get_border_bottom_width(const 
css_computed_style *style,
        
        /* 8bits: uuuuuttt : unit | type */
        if ((bits & 0x7) == CSS_BORDER_WIDTH_WIDTH) {
-               *length = style->i.border_bottom_width.value;
+               *length = style->i.border_bottom_width;
                *unit = bits >> 3;
        }
        
@@ -650,8 +650,8 @@ static inline uint8_t get_bottom_bits(const 
css_computed_style *style)
        /* 7bits: uuuuutt : unit | type */
        return (bits & 0x3);
 }
-static inline uint8_t get_bottom(const css_computed_style *style, css_fixed
-               *length, css_unit *unit)
+static inline uint8_t get_bottom(const css_computed_style *style,
+               css_fixed_or_calc *length, css_unit *unit)
 {
        uint32_t bits = style->i.bits[BOTTOM_INDEX];
        bits &= BOTTOM_MASK;
@@ -659,7 +659,7 @@ static inline uint8_t get_bottom(const css_computed_style 
*style, css_fixed
        
        /* 7bits: uuuuutt : unit | type */
        if ((bits & 0x3) == CSS_BOTTOM_SET) {
-               *length = style->i.bottom.value;
+               *length = style->i.bottom;
                *unit = bits >> 2;
        }
        
diff --git a/src/select/autogenerated_propset.h 
b/src/select/autogenerated_propset.h
index 317fb2a..7d29755 100644
--- a/src/select/autogenerated_propset.h
+++ b/src/select/autogenerated_propset.h
@@ -5,8 +5,8 @@
  * Copyright 2017 The NetSurf Project
  */
 
-/** Default values are 'initial value', unless the property is inherited,
- *  in which case it is 'inherit'. */
+#include "select/propget.h"
+
 
 #define ALIGN_CONTENT_INDEX 10
 #define ALIGN_CONTENT_SHIFT 20
@@ -15,9 +15,7 @@
 static inline css_error set_align_content(css_computed_style *style, uint8_t
                type)
 {
-       uint32_t *bits;
-       
-       bits = &style->i.bits[ALIGN_CONTENT_INDEX];
+       uint32_t *bits = &style->i.bits[ALIGN_CONTENT_INDEX];
        
        /* 3bits: ttt : type */
        *bits = (*bits & ~ALIGN_CONTENT_MASK) | (((uint32_t)type & 0x7) <<
@@ -35,9 +33,7 @@ static inline css_error set_align_content(css_computed_style 
*style, uint8_t
 
 static inline css_error set_align_items(css_computed_style *style, uint8_t 
type)
 {
-       uint32_t *bits;
-       
-       bits = &style->i.bits[ALIGN_ITEMS_INDEX];
+       uint32_t *bits = &style->i.bits[ALIGN_ITEMS_INDEX];
        
        /* 3bits: ttt : type */
        *bits = (*bits & ~ALIGN_ITEMS_MASK) | (((uint32_t)type & 0x7) <<
@@ -55,9 +51,7 @@ static inline css_error set_align_items(css_computed_style 
*style, uint8_t type)
 
 static inline css_error set_align_self(css_computed_style *style, uint8_t type)
 {
-       uint32_t *bits;
-       
-       bits = &style->i.bits[ALIGN_SELF_INDEX];
+       uint32_t *bits = &style->i.bits[ALIGN_SELF_INDEX];
        
        /* 3bits: ttt : type */
        *bits = (*bits & ~ALIGN_SELF_MASK) | (((uint32_t)type & 0x7) <<
@@ -76,9 +70,7 @@ static inline css_error set_align_self(css_computed_style 
*style, uint8_t type)
 static inline css_error set_background_attachment(css_computed_style *style,
                uint8_t type)
 {
-       uint32_t *bits;
-       
-       bits = &style->i.bits[BACKGROUND_ATTACHMENT_INDEX];
+       uint32_t *bits = &style->i.bits[BACKGROUND_ATTACHMENT_INDEX];
        
        /* 2bits: tt : type */
        *bits = (*bits & ~BACKGROUND_ATTACHMENT_MASK) | (((uint32_t)type & 0x3)
@@ -97,9 +89,7 @@ static inline css_error 
set_background_attachment(css_computed_style *style,
 static inline css_error set_background_color(css_computed_style *style, uint8_t
                type, css_color color)
 {
-       uint32_t *bits;
-       
-       bits = &style->i.bits[BACKGROUND_COLOR_INDEX];
+       uint32_t *bits = &style->i.bits[BACKGROUND_COLOR_INDEX];
        
        /* 2bits: tt : type */
        *bits = (*bits & ~BACKGROUND_COLOR_MASK) | (((uint32_t)type & 0x3) <<
@@ -120,9 +110,7 @@ static inline css_error 
set_background_color(css_computed_style *style, uint8_t
 static inline css_error set_background_image(css_computed_style *style, uint8_t
                type, lwc_string *string)
 {
-       uint32_t *bits;
-       
-       bits = &style->i.bits[BACKGROUND_IMAGE_INDEX];
+       uint32_t *bits = &style->i.bits[BACKGROUND_IMAGE_INDEX];
        
        /* 1bit: t : type */
        *bits = (*bits & ~BACKGROUND_IMAGE_MASK) | (((uint32_t)type & 0x1) <<
@@ -153,9 +141,7 @@ static inline css_error 
set_background_position(css_computed_style *style,
                uint8_t type, css_fixed length_a, css_unit unit_a, css_fixed
                length_b, css_unit unit_b)
 {
-       uint32_t *bits;
-       
-       bits = &style->i.bits[BACKGROUND_POSITION_INDEX];
+       uint32_t *bits = &style->i.bits[BACKGROUND_POSITION_INDEX];
        
        /* 11bits: aaaaabbbbbt : unit_a | unit_b | type */
        *bits = (*bits & ~BACKGROUND_POSITION_MASK) | ((((uint32_t)type & 0x1)
@@ -179,9 +165,7 @@ static inline css_error 
set_background_position(css_computed_style *style,
 static inline css_error set_background_repeat(css_computed_style *style,
                uint8_t type)
 {
-       uint32_t *bits;
-       
-       bits = &style->i.bits[BACKGROUND_REPEAT_INDEX];
+       uint32_t *bits = &style->i.bits[BACKGROUND_REPEAT_INDEX];
        
        /* 3bits: ttt : type */
        *bits = (*bits & ~BACKGROUND_REPEAT_MASK) | (((uint32_t)type & 0x7) <<
@@ -200,9 +184,7 @@ static inline css_error 
set_background_repeat(css_computed_style *style,
 static inline css_error set_border_bottom_color(css_computed_style *style,
                uint8_t type, css_color color)
 {
-       uint32_t *bits;
-       
-       bits = &style->i.bits[BORDER_BOTTOM_COLOR_INDEX];
+       uint32_t *bits = &style->i.bits[BORDER_BOTTOM_COLOR_INDEX];
        
        /* 2bits: tt : type */
        *bits = (*bits & ~BORDER_BOTTOM_COLOR_MASK) | (((uint32_t)type & 0x3)
@@ -223,9 +205,7 @@ static inline css_error 
set_border_bottom_color(css_computed_style *style,
 static inline css_error set_border_bottom_style(css_computed_style *style,
                uint8_t type)
 {
-       uint32_t *bits;
-       
-       bits = &style->i.bits[BORDER_BOTTOM_STYLE_INDEX];
+       uint32_t *bits = &style->i.bits[BORDER_BOTTOM_STYLE_INDEX];
        
        /* 4bits: tttt : type */
        *bits = (*bits & ~BORDER_BOTTOM_STYLE_MASK) | (((uint32_t)type & 0xf)
@@ -242,11 +222,9 @@ static inline css_error 
set_border_bottom_style(css_computed_style *style,
 #define BORDER_BOTTOM_WIDTH_MASK 0xff
 
 static inline css_error set_border_bottom_width(css_computed_style *style,
-               uint8_t type, css_fixed length, css_unit unit)
+               uint8_t type, css_fixed_or_calc length, css_unit unit)
 {
-       uint32_t orig_bits = style->i.bits[BORDER_BOTTOM_WIDTH_INDEX];
-       orig_bits &= BORDER_BOTTOM_WIDTH_MASK;
-       orig_bits >>= BORDER_BOTTOM_WIDTH_SHIFT;
+       uint32_t orig_bits = get_border_bottom_width_bits(style);
        
        /* 8bits: uuuuuttt : unit | type */
        if ((orig_bits & 0x7) == CSS_BORDER_WIDTH_WIDTH) {
@@ -255,15 +233,15 @@ static inline css_error 
set_border_bottom_width(css_computed_style *style,
                }
        }
        
-       uint32_t *bits;
-       
-       bits = &style->i.bits[BORDER_BOTTOM_WIDTH_INDEX];
+       uint32_t *bits = &style->i.bits[BORDER_BOTTOM_WIDTH_INDEX];
        
        /* 8bits: uuuuuttt : unit | type */
        *bits = (*bits & ~BORDER_BOTTOM_WIDTH_MASK) | ((((uint32_t)type & 0x7)
                        | (unit << 3)) << BORDER_BOTTOM_WIDTH_SHIFT);
        
-       style->i.border_bottom_width.value = length;
+       if (unit == CSS_UNIT_CALC) {
+               style->i.border_bottom_width.calc = lwc_string_ref(length.calc);
+       }
        
        return CSS_OK;
 }
@@ -278,9 +256,7 @@ static inline css_error 
set_border_bottom_width(css_computed_style *style,
 static inline css_error set_border_collapse(css_computed_style *style, uint8_t
                type)
 {
-       uint32_t *bits;
-       
-       bits = &style->i.bits[BORDER_COLLAPSE_INDEX];
+       uint32_t *bits = &style->i.bits[BORDER_COLLAPSE_INDEX];
        
        /* 2bits: tt : type */
        *bits = (*bits & ~BORDER_COLLAPSE_MASK) | (((uint32_t)type & 0x3) <<
@@ -299,9 +275,7 @@ static inline css_error 
set_border_collapse(css_computed_style *style, uint8_t
 static inline css_error set_border_left_color(css_computed_style *style,
                uint8_t type, css_color color)
 {
-       uint32_t *bits;
-       
-       bits = &style->i.bits[BORDER_LEFT_COLOR_INDEX];
+       uint32_t *bits = &style->i.bits[BORDER_LEFT_COLOR_INDEX];
        
        /* 2bits: tt : type */
        *bits = (*bits & ~BORDER_LEFT_COLOR_MASK) | (((uint32_t)type & 0x3) <<
@@ -322,9 +296,7 @@ static inline css_error 
set_border_left_color(css_computed_style *style,
 static inline css_error set_border_left_style(css_computed_style *style,
                uint8_t type)
 {
-       uint32_t *bits;
-       
-       bits = &style->i.bits[BORDER_LEFT_STYLE_INDEX];
+       uint32_t *bits = &style->i.bits[BORDER_LEFT_STYLE_INDEX];
        
        /* 4bits: tttt : type */
        *bits = (*bits & ~BORDER_LEFT_STYLE_MASK) | (((uint32_t)type & 0xf) <<
@@ -343,9 +315,7 @@ static inline css_error 
set_border_left_style(css_computed_style *style,
 static inline css_error set_border_left_width(css_computed_style *style,
                uint8_t type, css_fixed length, css_unit unit)
 {
-       uint32_t *bits;
-       
-       bits = &style->i.bits[BORDER_LEFT_WIDTH_INDEX];
+       uint32_t *bits = &style->i.bits[BORDER_LEFT_WIDTH_INDEX];
        
        /* 8bits: uuuuuttt : unit | type */
        *bits = (*bits & ~BORDER_LEFT_WIDTH_MASK) | ((((uint32_t)type & 0x7) | (
@@ -366,9 +336,7 @@ static inline css_error 
set_border_left_width(css_computed_style *style,
 static inline css_error set_border_right_color(css_computed_style *style,
                uint8_t type, css_color color)
 {
-       uint32_t *bits;
-       
-       bits = &style->i.bits[BORDER_RIGHT_COLOR_INDEX];
+       uint32_t *bits = &style->i.bits[BORDER_RIGHT_COLOR_INDEX];
        
        /* 2bits: tt : type */
        *bits = (*bits & ~BORDER_RIGHT_COLOR_MASK) | (((uint32_t)type & 0x3) <<
@@ -389,9 +357,7 @@ static inline css_error 
set_border_right_color(css_computed_style *style,
 static inline css_error set_border_right_style(css_computed_style *style,
                uint8_t type)
 {
-       uint32_t *bits;
-       
-       bits = &style->i.bits[BORDER_RIGHT_STYLE_INDEX];
+       uint32_t *bits = &style->i.bits[BORDER_RIGHT_STYLE_INDEX];
        
        /* 4bits: tttt : type */
        *bits = (*bits & ~BORDER_RIGHT_STYLE_MASK) | (((uint32_t)type & 0xf) <<
@@ -410,9 +376,7 @@ static inline css_error 
set_border_right_style(css_computed_style *style,
 static inline css_error set_border_right_width(css_computed_style *style,
                uint8_t type, css_fixed length, css_unit unit)
 {
-       uint32_t *bits;
-       
-       bits = &style->i.bits[BORDER_RIGHT_WIDTH_INDEX];
+       uint32_t *bits = &style->i.bits[BORDER_RIGHT_WIDTH_INDEX];
        
        /* 8bits: uuuuuttt : unit | type */
        *bits = (*bits & ~BORDER_RIGHT_WIDTH_MASK) | ((((uint32_t)type & 0x7) |
@@ -434,9 +398,7 @@ static inline css_error 
set_border_spacing(css_computed_style *style, uint8_t
                type, css_fixed length_a, css_unit unit_a, css_fixed length_b,
                css_unit unit_b)
 {
-       uint32_t *bits;
-       
-       bits = &style->i.bits[BORDER_SPACING_INDEX];
+       uint32_t *bits = &style->i.bits[BORDER_SPACING_INDEX];
        
        /* 11bits: aaaaabbbbbt : unit_a | unit_b | type */
        *bits = (*bits & ~BORDER_SPACING_MASK) | ((((uint32_t)type & 0x1) | (
@@ -459,9 +421,7 @@ static inline css_error 
set_border_spacing(css_computed_style *style, uint8_t
 static inline css_error set_border_top_color(css_computed_style *style, uint8_t
                type, css_color color)
 {
-       uint32_t *bits;
-       
-       bits = &style->i.bits[BORDER_TOP_COLOR_INDEX];
+       uint32_t *bits = &style->i.bits[BORDER_TOP_COLOR_INDEX];
        
        /* 2bits: tt : type */
        *bits = (*bits & ~BORDER_TOP_COLOR_MASK) | (((uint32_t)type & 0x3) <<
@@ -482,9 +442,7 @@ static inline css_error 
set_border_top_color(css_computed_style *style, uint8_t
 static inline css_error set_border_top_style(css_computed_style *style, uint8_t
                type)
 {
-       uint32_t *bits;
-       
-       bits = &style->i.bits[BORDER_TOP_STYLE_INDEX];
+       uint32_t *bits = &style->i.bits[BORDER_TOP_STYLE_INDEX];
        
        /* 4bits: tttt : type */
        *bits = (*bits & ~BORDER_TOP_STYLE_MASK) | (((uint32_t)type & 0xf) <<
@@ -503,9 +461,7 @@ static inline css_error 
set_border_top_style(css_computed_style *style, uint8_t
 static inline css_error set_border_top_width(css_computed_style *style, uint8_t
                type, css_fixed length, css_unit unit)
 {
-       uint32_t *bits;
-       
-       bits = &style->i.bits[BORDER_TOP_WIDTH_INDEX];
+       uint32_t *bits = &style->i.bits[BORDER_TOP_WIDTH_INDEX];
        
        /* 8bits: uuuuuttt : unit | type */
        *bits = (*bits & ~BORDER_TOP_WIDTH_MASK) | ((((uint32_t)type & 0x7) | (
@@ -524,11 +480,9 @@ static inline css_error 
set_border_top_width(css_computed_style *style, uint8_t
 #define BOTTOM_MASK 0x3f800
 
 static inline css_error set_bottom(css_computed_style *style, uint8_t type,
-               css_fixed length, css_unit unit)
+               css_fixed_or_calc length, css_unit unit)
 {
-       uint32_t orig_bits = style->i.bits[BOTTOM_INDEX];
-       orig_bits &= BOTTOM_MASK;
-       orig_bits >>= BOTTOM_SHIFT;
+       uint32_t orig_bits = get_bottom_bits(style);
        
        /* 7bits: uuuuutt : unit | type */
        if ((orig_bits & 0x3) == CSS_BOTTOM_SET) {
@@ -537,15 +491,15 @@ static inline css_error set_bottom(css_computed_style 
*style, uint8_t type,
                }
        }
        
-       uint32_t *bits;
-       
-       bits = &style->i.bits[BOTTOM_INDEX];
+       uint32_t *bits = &style->i.bits[BOTTOM_INDEX];
        
        /* 7bits: uuuuutt : unit | type */
        *bits = (*bits & ~BOTTOM_MASK) | ((((uint32_t)type & 0x3) | (unit <<
                        2)) << BOTTOM_SHIFT);
        
-       style->i.bottom.value = length;
+       if (unit == CSS_UNIT_CALC) {
+               style->i.bottom.calc = lwc_string_ref(length.calc);
+       }
        
        return CSS_OK;
 }
@@ -559,9 +513,7 @@ static inline css_error set_bottom(css_computed_style 
*style, uint8_t type,
 
 static inline css_error set_box_sizing(css_computed_style *style, uint8_t type)
 {
-       uint32_t *bits;
-       
-       bits = &style->i.bits[BOX_SIZING_INDEX];
+       uint32_t *bits = &style->i.bits[BOX_SIZING_INDEX];
        
        /* 2bits: tt : type */
        *bits = (*bits & ~BOX_SIZING_MASK) | (((uint32_t)type & 0x3) <<
@@ -579,9 +531,7 @@ static inline css_error set_box_sizing(css_computed_style 
*style, uint8_t type)
 
 static inline css_error set_break_after(css_computed_style *style, uint8_t 
type)
 {
-       uint32_t *bits;
-       
-       bits = &style->i.bits[BREAK_AFTER_INDEX];
+       uint32_t *bits = &style->i.bits[BREAK_AFTER_INDEX];
        
        /* 4bits: tttt : type */
        *bits = (*bits & ~BREAK_AFTER_MASK) | (((uint32_t)type & 0xf) <<
@@ -600,9 +550,7 @@ static inline css_error set_break_after(css_computed_style 
*style, uint8_t type)
 static inline css_error set_break_before(css_computed_style *style, uint8_t
                type)
 {
-       uint32_t *bits;
-       
-       bits = &style->i.bits[BREAK_BEFORE_INDEX];
+       uint32_t *bits = &style->i.bits[BREAK_BEFORE_INDEX];
        
        /* 4bits: tttt : type */
        *bits = (*bits & ~BREAK_BEFORE_MASK) | (((uint32_t)type & 0xf) <<
@@ -621,9 +569,7 @@ static inline css_error set_break_before(css_computed_style 
*style, uint8_t
 static inline css_error set_break_inside(css_computed_style *style, uint8_t
                type)
 {
-       uint32_t *bits;
-       
-       bits = &style->i.bits[BREAK_INSIDE_INDEX];
+       uint32_t *bits = &style->i.bits[BREAK_INSIDE_INDEX];
        
        /* 4bits: tttt : type */
        *bits = (*bits & ~BREAK_INSIDE_MASK) | (((uint32_t)type & 0xf) <<
@@ -642,9 +588,7 @@ static inline css_error set_break_inside(css_computed_style 
*style, uint8_t
 static inline css_error set_caption_side(css_computed_style *style, uint8_t
                type)
 {
-       uint32_t *bits;
-       
-       bits = &style->i.bits[CAPTION_SIDE_INDEX];
+       uint32_t *bits = &style->i.bits[CAPTION_SIDE_INDEX];
        
        /* 2bits: tt : type */
        *bits = (*bits & ~CAPTION_SIDE_MASK) | (((uint32_t)type & 0x3) <<
@@ -662,9 +606,7 @@ static inline css_error set_caption_side(css_computed_style 
*style, uint8_t
 
 static inline css_error set_clear(css_computed_style *style, uint8_t type)
 {
-       uint32_t *bits;
-       
-       bits = &style->i.bits[CLEAR_INDEX];
+       uint32_t *bits = &style->i.bits[CLEAR_INDEX];
        
        /* 3bits: ttt : type */
        *bits = (*bits & ~CLEAR_MASK) | (((uint32_t)type & 0x7) << CLEAR_SHIFT);
@@ -725,9 +667,7 @@ static inline css_error set_clip(
 static inline css_error set_color(css_computed_style *style, uint8_t type,
                css_color color)
 {
-       uint32_t *bits;
-       
-       bits = &style->i.bits[COLOR_INDEX];
+       uint32_t *bits = &style->i.bits[COLOR_INDEX];
        
        /* 1bit: t : type */
        *bits = (*bits & ~COLOR_MASK) | (((uint32_t)type & 0x1) << COLOR_SHIFT);
@@ -747,9 +687,7 @@ static inline css_error set_color(css_computed_style 
*style, uint8_t type,
 static inline css_error set_column_count(css_computed_style *style, uint8_t
                type, int32_t integer)
 {
-       uint32_t *bits;
-       
-       bits = &style->i.bits[COLUMN_COUNT_INDEX];
+       uint32_t *bits = &style->i.bits[COLUMN_COUNT_INDEX];
        
        /* 2bits: tt : type */
        *bits = (*bits & ~COLUMN_COUNT_MASK) | (((uint32_t)type & 0x3) <<
@@ -769,9 +707,7 @@ static inline css_error set_column_count(css_computed_style 
*style, uint8_t
 
 static inline css_error set_column_fill(css_computed_style *style, uint8_t 
type)
 {
-       uint32_t *bits;
-       
-       bits = &style->i.bits[COLUMN_FILL_INDEX];
+       uint32_t *bits = &style->i.bits[COLUMN_FILL_INDEX];
        
        /* 2bits: tt : type */
        *bits = (*bits & ~COLUMN_FILL_MASK) | (((uint32_t)type & 0x3) <<
@@ -790,9 +726,7 @@ static inline css_error set_column_fill(css_computed_style 
*style, uint8_t type)
 static inline css_error set_column_gap(css_computed_style *style, uint8_t type,
                css_fixed length, css_unit unit)
 {
-       uint32_t *bits;
-       
-       bits = &style->i.bits[COLUMN_GAP_INDEX];
+       uint32_t *bits = &style->i.bits[COLUMN_GAP_INDEX];
        
        /* 7bits: uuuuutt : unit | type */
        *bits = (*bits & ~COLUMN_GAP_MASK) | ((((uint32_t)type & 0x3) | (unit
@@ -813,9 +747,7 @@ static inline css_error set_column_gap(css_computed_style 
*style, uint8_t type,
 static inline css_error set_column_rule_color(css_computed_style *style,
                uint8_t type, css_color color)
 {
-       uint32_t *bits;
-       
-       bits = &style->i.bits[COLUMN_RULE_COLOR_INDEX];
+       uint32_t *bits = &style->i.bits[COLUMN_RULE_COLOR_INDEX];
        
        /* 2bits: tt : type */
        *bits = (*bits & ~COLUMN_RULE_COLOR_MASK) | (((uint32_t)type & 0x3) <<
@@ -836,9 +768,7 @@ static inline css_error 
set_column_rule_color(css_computed_style *style,
 static inline css_error set_column_rule_style(css_computed_style *style,
                uint8_t type)
 {
-       uint32_t *bits;
-       
-       bits = &style->i.bits[COLUMN_RULE_STYLE_INDEX];
+       uint32_t *bits = &style->i.bits[COLUMN_RULE_STYLE_INDEX];
        
        /* 4bits: tttt : type */
        *bits = (*bits & ~COLUMN_RULE_STYLE_MASK) | (((uint32_t)type & 0xf) <<
@@ -857,9 +787,7 @@ static inline css_error 
set_column_rule_style(css_computed_style *style,
 static inline css_error set_column_rule_width(css_computed_style *style,
                uint8_t type, css_fixed length, css_unit unit)
 {
-       uint32_t *bits;
-       
-       bits = &style->i.bits[COLUMN_RULE_WIDTH_INDEX];
+       uint32_t *bits = &style->i.bits[COLUMN_RULE_WIDTH_INDEX];
        
        /* 8bits: uuuuuttt : unit | type */
        *bits = (*bits & ~COLUMN_RULE_WIDTH_MASK) | ((((uint32_t)type & 0x7) | (
@@ -879,9 +807,7 @@ static inline css_error 
set_column_rule_width(css_computed_style *style,
 
 static inline css_error set_column_span(css_computed_style *style, uint8_t 
type)
 {
-       uint32_t *bits;
-       
-       bits = &style->i.bits[COLUMN_SPAN_INDEX];
+       uint32_t *bits = &style->i.bits[COLUMN_SPAN_INDEX];
        
        /* 2bits: tt : type */
        *bits = (*bits & ~COLUMN_SPAN_MASK) | (((uint32_t)type & 0x3) <<
@@ -900,9 +826,7 @@ static inline css_error set_column_span(css_computed_style 
*style, uint8_t type)
 static inline css_error set_column_width(css_computed_style *style, uint8_t
                type, css_fixed length, css_unit unit)
 {
-       uint32_t *bits;
-       
-       bits = &style->i.bits[COLUMN_WIDTH_INDEX];
+       uint32_t *bits = &style->i.bits[COLUMN_WIDTH_INDEX];
        
        /* 7bits: uuuuutt : unit | type */
        *bits = (*bits & ~COLUMN_WIDTH_MASK) | ((((uint32_t)type & 0x3) | (unit
@@ -1006,9 +930,7 @@ static inline css_error set_content(
 static inline css_error set_counter_increment(css_computed_style *style,
                uint8_t type, css_computed_counter *counter_arr)
 {
-       uint32_t *bits;
-       
-       bits = &style->i.bits[COUNTER_INCREMENT_INDEX];
+       uint32_t *bits = &style->i.bits[COUNTER_INCREMENT_INDEX];
        
        /* 1bit: t : type */
        *bits = (*bits & ~COUNTER_INCREMENT_MASK) | (((uint32_t)type & 0x1) <<
@@ -1044,9 +966,7 @@ static inline css_error 
set_counter_increment(css_computed_style *style,
 static inline css_error set_counter_reset(css_computed_style *style, uint8_t
                type, css_computed_counter *counter_arr)
 {
-       uint32_t *bits;
-       
-       bits = &style->i.bits[COUNTER_RESET_INDEX];
+       uint32_t *bits = &style->i.bits[COUNTER_RESET_INDEX];
        
        /* 1bit: t : type */
        *bits = (*bits & ~COUNTER_RESET_MASK) | (((uint32_t)type & 0x1) <<
@@ -1082,9 +1002,7 @@ static inline css_error 
set_counter_reset(css_computed_style *style, uint8_t
 static inline css_error set_cursor(css_computed_style *style, uint8_t type,
                lwc_string **string_arr)
 {
-       uint32_t *bits;
-       
-       bits = &style->i.bits[CURSOR_INDEX];
+       uint32_t *bits = &style->i.bits[CURSOR_INDEX];
        
        /* 5bits: ttttt : type */
        *bits = (*bits & ~CURSOR_MASK) | (((uint32_t)type & 0x1f) <<
@@ -1119,9 +1037,7 @@ static inline css_error set_cursor(css_computed_style 
*style, uint8_t type,
 
 static inline css_error set_direction(css_computed_style *style, uint8_t type)
 {
-       uint32_t *bits;
-       
-       bits = &style->i.bits[DIRECTION_INDEX];
+       uint32_t *bits = &style->i.bits[DIRECTION_INDEX];
        
        /* 2bits: tt : type */
        *bits = (*bits & ~DIRECTION_MASK) | (((uint32_t)type & 0x3) <<
@@ -1139,9 +1055,7 @@ static inline css_error set_direction(css_computed_style 
*style, uint8_t type)
 
 static inline css_error set_display(css_computed_style *style, uint8_t type)
 {
-       uint32_t *bits;
-       
-       bits = &style->i.bits[DISPLAY_INDEX];
+       uint32_t *bits = &style->i.bits[DISPLAY_INDEX];
        
        /* 5bits: ttttt : type */
        *bits = (*bits & ~DISPLAY_MASK) | (((uint32_t)type & 0x1f) <<
@@ -1159,9 +1073,7 @@ static inline css_error set_display(css_computed_style 
*style, uint8_t type)
 
 static inline css_error set_empty_cells(css_computed_style *style, uint8_t 
type)
 {
-       uint32_t *bits;
-       
-       bits = &style->i.bits[EMPTY_CELLS_INDEX];
+       uint32_t *bits = &style->i.bits[EMPTY_CELLS_INDEX];
        
        /* 2bits: tt : type */
        *bits = (*bits & ~EMPTY_CELLS_MASK) | (((uint32_t)type & 0x3) <<
@@ -1180,9 +1092,7 @@ static inline css_error 
set_empty_cells(css_computed_style *style, uint8_t type)
 static inline css_error set_flex_basis(css_computed_style *style, uint8_t type,
                css_fixed length, css_unit unit)
 {
-       uint32_t *bits;
-       
-       bits = &style->i.bits[FLEX_BASIS_INDEX];
+       uint32_t *bits = &style->i.bits[FLEX_BASIS_INDEX];
        
        /* 7bits: uuuuutt : unit | type */
        *bits = (*bits & ~FLEX_BASIS_MASK) | ((((uint32_t)type & 0x3) | (unit
@@ -1203,9 +1113,7 @@ static inline css_error set_flex_basis(css_computed_style 
*style, uint8_t type,
 static inline css_error set_flex_direction(css_computed_style *style, uint8_t
                type)
 {
-       uint32_t *bits;
-       
-       bits = &style->i.bits[FLEX_DIRECTION_INDEX];
+       uint32_t *bits = &style->i.bits[FLEX_DIRECTION_INDEX];
        
        /* 3bits: ttt : type */
        *bits = (*bits & ~FLEX_DIRECTION_MASK) | (((uint32_t)type & 0x7) <<
@@ -1224,9 +1132,7 @@ static inline css_error 
set_flex_direction(css_computed_style *style, uint8_t
 static inline css_error set_flex_grow(css_computed_style *style, uint8_t type,
                css_fixed fixed)
 {
-       uint32_t *bits;
-       
-       bits = &style->i.bits[FLEX_GROW_INDEX];
+       uint32_t *bits = &style->i.bits[FLEX_GROW_INDEX];
        
        /* 1bit: t : type */
        *bits = (*bits & ~FLEX_GROW_MASK) | (((uint32_t)type & 0x1) <<
@@ -1247,9 +1153,7 @@ static inline css_error set_flex_grow(css_computed_style 
*style, uint8_t type,
 static inline css_error set_flex_shrink(css_computed_style *style, uint8_t
                type, css_fixed fixed)
 {
-       uint32_t *bits;
-       
-       bits = &style->i.bits[FLEX_SHRINK_INDEX];
+       uint32_t *bits = &style->i.bits[FLEX_SHRINK_INDEX];
        
        /* 1bit: t : type */
        *bits = (*bits & ~FLEX_SHRINK_MASK) | (((uint32_t)type & 0x1) <<
@@ -1269,9 +1173,7 @@ static inline css_error 
set_flex_shrink(css_computed_style *style, uint8_t
 
 static inline css_error set_flex_wrap(css_computed_style *style, uint8_t type)
 {
-       uint32_t *bits;
-       
-       bits = &style->i.bits[FLEX_WRAP_INDEX];
+       uint32_t *bits = &style->i.bits[FLEX_WRAP_INDEX];
        
        /* 2bits: tt : type */
        *bits = (*bits & ~FLEX_WRAP_MASK) | (((uint32_t)type & 0x3) <<
@@ -1289,9 +1191,7 @@ static inline css_error set_flex_wrap(css_computed_style 
*style, uint8_t type)
 
 static inline css_error set_float(css_computed_style *style, uint8_t type)
 {
-       uint32_t *bits;
-       
-       bits = &style->i.bits[FLOAT_INDEX];
+       uint32_t *bits = &style->i.bits[FLOAT_INDEX];
        
        /* 2bits: tt : type */
        *bits = (*bits & ~FLOAT_MASK) | (((uint32_t)type & 0x3) << FLOAT_SHIFT);
@@ -1309,9 +1209,7 @@ static inline css_error set_float(css_computed_style 
*style, uint8_t type)
 static inline css_error set_font_family(css_computed_style *style, uint8_t
                type, lwc_string **string_arr)
 {
-       uint32_t *bits;
-       
-       bits = &style->i.bits[FONT_FAMILY_INDEX];
+       uint32_t *bits = &style->i.bits[FONT_FAMILY_INDEX];
        
        /* 3bits: ttt : type */
        *bits = (*bits & ~FONT_FAMILY_MASK) | (((uint32_t)type & 0x7) <<
@@ -1347,9 +1245,7 @@ static inline css_error 
set_font_family(css_computed_style *style, uint8_t
 static inline css_error set_font_size(css_computed_style *style, uint8_t type,
                css_fixed length, css_unit unit)
 {
-       uint32_t *bits;
-       
-       bits = &style->i.bits[FONT_SIZE_INDEX];
+       uint32_t *bits = &style->i.bits[FONT_SIZE_INDEX];
        
        /* 9bits: uuuuutttt : unit | type */
        *bits = (*bits & ~FONT_SIZE_MASK) | ((((uint32_t)type & 0xf) | (unit <<
@@ -1369,9 +1265,7 @@ static inline css_error set_font_size(css_computed_style 
*style, uint8_t type,
 
 static inline css_error set_font_style(css_computed_style *style, uint8_t type)
 {
-       uint32_t *bits;
-       
-       bits = &style->i.bits[FONT_STYLE_INDEX];
+       uint32_t *bits = &style->i.bits[FONT_STYLE_INDEX];
        
        /* 2bits: tt : type */
        *bits = (*bits & ~FONT_STYLE_MASK) | (((uint32_t)type & 0x3) <<
@@ -1390,9 +1284,7 @@ static inline css_error set_font_style(css_computed_style 
*style, uint8_t type)
 static inline css_error set_font_variant(css_computed_style *style, uint8_t
                type)
 {
-       uint32_t *bits;
-       
-       bits = &style->i.bits[FONT_VARIANT_INDEX];
+       uint32_t *bits = &style->i.bits[FONT_VARIANT_INDEX];
        
        /* 2bits: tt : type */
        *bits = (*bits & ~FONT_VARIANT_MASK) | (((uint32_t)type & 0x3) <<
@@ -1410,9 +1302,7 @@ static inline css_error 
set_font_variant(css_computed_style *style, uint8_t
 
 static inline css_error set_font_weight(css_computed_style *style, uint8_t 
type)
 {
-       uint32_t *bits;
-       
-       bits = &style->i.bits[FONT_WEIGHT_INDEX];
+       uint32_t *bits = &style->i.bits[FONT_WEIGHT_INDEX];
        
        /* 4bits: tttt : type */
        *bits = (*bits & ~FONT_WEIGHT_MASK) | (((uint32_t)type & 0xf) <<
@@ -1431,9 +1321,7 @@ static inline css_error 
set_font_weight(css_computed_style *style, uint8_t type)
 static inline css_error set_height(css_computed_style *style, uint8_t type,
                css_fixed length, css_unit unit)
 {
-       uint32_t *bits;
-       
-       bits = &style->i.bits[HEIGHT_INDEX];
+       uint32_t *bits = &style->i.bits[HEIGHT_INDEX];
        
        /* 7bits: uuuuutt : unit | type */
        *bits = (*bits & ~HEIGHT_MASK) | ((((uint32_t)type & 0x3) | (unit <<
@@ -1454,9 +1342,7 @@ static inline css_error set_height(css_computed_style 
*style, uint8_t type,
 static inline css_error set_justify_content(css_computed_style *style, uint8_t
                type)
 {
-       uint32_t *bits;
-       
-       bits = &style->i.bits[JUSTIFY_CONTENT_INDEX];
+       uint32_t *bits = &style->i.bits[JUSTIFY_CONTENT_INDEX];
        
        /* 3bits: ttt : type */
        *bits = (*bits & ~JUSTIFY_CONTENT_MASK) | (((uint32_t)type & 0x7) <<
@@ -1475,9 +1361,7 @@ static inline css_error 
set_justify_content(css_computed_style *style, uint8_t
 static inline css_error set_left(css_computed_style *style, uint8_t type,
                css_fixed length, css_unit unit)
 {
-       uint32_t *bits;
-       
-       bits = &style->i.bits[LEFT_INDEX];
+       uint32_t *bits = &style->i.bits[LEFT_INDEX];
        
        /* 7bits: uuuuutt : unit | type */
        *bits = (*bits & ~LEFT_MASK) | ((((uint32_t)type & 0x3) | (unit << 2))
@@ -1498,9 +1382,7 @@ static inline css_error set_left(css_computed_style 
*style, uint8_t type,
 static inline css_error set_letter_spacing(css_computed_style *style, uint8_t
                type, css_fixed length, css_unit unit)
 {
-       uint32_t *bits;
-       
-       bits = &style->i.bits[LETTER_SPACING_INDEX];
+       uint32_t *bits = &style->i.bits[LETTER_SPACING_INDEX];
        
        /* 7bits: uuuuutt : unit | type */
        *bits = (*bits & ~LETTER_SPACING_MASK) | ((((uint32_t)type & 0x3) | (
@@ -1521,9 +1403,7 @@ static inline css_error 
set_letter_spacing(css_computed_style *style, uint8_t
 static inline css_error set_line_height(css_computed_style *style, uint8_t
                type, css_fixed length, css_unit unit)
 {
-       uint32_t *bits;
-       
-       bits = &style->i.bits[LINE_HEIGHT_INDEX];
+       uint32_t *bits = &style->i.bits[LINE_HEIGHT_INDEX];
        
        /* 7bits: uuuuutt : unit | type */
        *bits = (*bits & ~LINE_HEIGHT_MASK) | ((((uint32_t)type & 0x3) | (unit
@@ -1544,9 +1424,7 @@ static inline css_error 
set_line_height(css_computed_style *style, uint8_t
 static inline css_error set_list_style_image(css_computed_style *style, uint8_t
                type, lwc_string *string)
 {
-       uint32_t *bits;
-       
-       bits = &style->i.bits[LIST_STYLE_IMAGE_INDEX];
+       uint32_t *bits = &style->i.bits[LIST_STYLE_IMAGE_INDEX];
        
        /* 1bit: t : type */
        *bits = (*bits & ~LIST_STYLE_IMAGE_MASK) | (((uint32_t)type & 0x1) <<
@@ -1576,9 +1454,7 @@ static inline css_error 
set_list_style_image(css_computed_style *style, uint8_t
 static inline css_error set_list_style_position(css_computed_style *style,
                uint8_t type)
 {
-       uint32_t *bits;
-       
-       bits = &style->i.bits[LIST_STYLE_POSITION_INDEX];
+       uint32_t *bits = &style->i.bits[LIST_STYLE_POSITION_INDEX];
        
        /* 2bits: tt : type */
        *bits = (*bits & ~LIST_STYLE_POSITION_MASK) | (((uint32_t)type & 0x3)
@@ -1597,9 +1473,7 @@ static inline css_error 
set_list_style_position(css_computed_style *style,
 static inline css_error set_list_style_type(css_computed_style *style, uint8_t
                type)
 {
-       uint32_t *bits;
-       
-       bits = &style->i.bits[LIST_STYLE_TYPE_INDEX];
+       uint32_t *bits = &style->i.bits[LIST_STYLE_TYPE_INDEX];
        
        /* 6bits: tttttt : type */
        *bits = (*bits & ~LIST_STYLE_TYPE_MASK) | (((uint32_t)type & 0x3f) <<
@@ -1618,9 +1492,7 @@ static inline css_error 
set_list_style_type(css_computed_style *style, uint8_t
 static inline css_error set_margin_bottom(css_computed_style *style, uint8_t
                type, css_fixed length, css_unit unit)
 {
-       uint32_t *bits;
-       
-       bits = &style->i.bits[MARGIN_BOTTOM_INDEX];
+       uint32_t *bits = &style->i.bits[MARGIN_BOTTOM_INDEX];
        
        /* 7bits: uuuuutt : unit | type */
        *bits = (*bits & ~MARGIN_BOTTOM_MASK) | ((((uint32_t)type & 0x3) | (
@@ -1641,9 +1513,7 @@ static inline css_error 
set_margin_bottom(css_computed_style *style, uint8_t
 static inline css_error set_margin_left(css_computed_style *style, uint8_t
                type, css_fixed length, css_unit unit)
 {
-       uint32_t *bits;
-       
-       bits = &style->i.bits[MARGIN_LEFT_INDEX];
+       uint32_t *bits = &style->i.bits[MARGIN_LEFT_INDEX];
        
        /* 7bits: uuuuutt : unit | type */
        *bits = (*bits & ~MARGIN_LEFT_MASK) | ((((uint32_t)type & 0x3) | (unit
@@ -1664,9 +1534,7 @@ static inline css_error 
set_margin_left(css_computed_style *style, uint8_t
 static inline css_error set_margin_right(css_computed_style *style, uint8_t
                type, css_fixed length, css_unit unit)
 {
-       uint32_t *bits;
-       
-       bits = &style->i.bits[MARGIN_RIGHT_INDEX];
+       uint32_t *bits = &style->i.bits[MARGIN_RIGHT_INDEX];
        
        /* 7bits: uuuuutt : unit | type */
        *bits = (*bits & ~MARGIN_RIGHT_MASK) | ((((uint32_t)type & 0x3) | (unit
@@ -1687,9 +1555,7 @@ static inline css_error 
set_margin_right(css_computed_style *style, uint8_t
 static inline css_error set_margin_top(css_computed_style *style, uint8_t type,
                css_fixed length, css_unit unit)
 {
-       uint32_t *bits;
-       
-       bits = &style->i.bits[MARGIN_TOP_INDEX];
+       uint32_t *bits = &style->i.bits[MARGIN_TOP_INDEX];
        
        /* 7bits: uuuuutt : unit | type */
        *bits = (*bits & ~MARGIN_TOP_MASK) | ((((uint32_t)type & 0x3) | (unit
@@ -1710,9 +1576,7 @@ static inline css_error set_margin_top(css_computed_style 
*style, uint8_t type,
 static inline css_error set_max_height(css_computed_style *style, uint8_t type,
                css_fixed length, css_unit unit)
 {
-       uint32_t *bits;
-       
-       bits = &style->i.bits[MAX_HEIGHT_INDEX];
+       uint32_t *bits = &style->i.bits[MAX_HEIGHT_INDEX];
        
        /* 7bits: uuuuutt : unit | type */
        *bits = (*bits & ~MAX_HEIGHT_MASK) | ((((uint32_t)type & 0x3) | (unit
@@ -1733,9 +1597,7 @@ static inline css_error set_max_height(css_computed_style 
*style, uint8_t type,
 static inline css_error set_max_width(css_computed_style *style, uint8_t type,
                css_fixed length, css_unit unit)
 {
-       uint32_t *bits;
-       
-       bits = &style->i.bits[MAX_WIDTH_INDEX];
+       uint32_t *bits = &style->i.bits[MAX_WIDTH_INDEX];
        
        /* 7bits: uuuuutt : unit | type */
        *bits = (*bits & ~MAX_WIDTH_MASK) | ((((uint32_t)type & 0x3) | (unit <<
@@ -1756,9 +1618,7 @@ static inline css_error set_max_width(css_computed_style 
*style, uint8_t type,
 static inline css_error set_min_height(css_computed_style *style, uint8_t type,
                css_fixed length, css_unit unit)
 {
-       uint32_t *bits;
-       
-       bits = &style->i.bits[MIN_HEIGHT_INDEX];
+       uint32_t *bits = &style->i.bits[MIN_HEIGHT_INDEX];
        
        /* 7bits: uuuuutt : unit | type */
        *bits = (*bits & ~MIN_HEIGHT_MASK) | ((((uint32_t)type & 0x3) | (unit
@@ -1779,9 +1639,7 @@ static inline css_error set_min_height(css_computed_style 
*style, uint8_t type,
 static inline css_error set_min_width(css_computed_style *style, uint8_t type,
                css_fixed length, css_unit unit)
 {
-       uint32_t *bits;
-       
-       bits = &style->i.bits[MIN_WIDTH_INDEX];
+       uint32_t *bits = &style->i.bits[MIN_WIDTH_INDEX];
        
        /* 7bits: uuuuutt : unit | type */
        *bits = (*bits & ~MIN_WIDTH_MASK) | ((((uint32_t)type & 0x3) | (unit <<
@@ -1802,9 +1660,7 @@ static inline css_error set_min_width(css_computed_style 
*style, uint8_t type,
 static inline css_error set_opacity(css_computed_style *style, uint8_t type,
                css_fixed fixed)
 {
-       uint32_t *bits;
-       
-       bits = &style->i.bits[OPACITY_INDEX];
+       uint32_t *bits = &style->i.bits[OPACITY_INDEX];
        
        /* 1bit: t : type */
        *bits = (*bits & ~OPACITY_MASK) | (((uint32_t)type & 0x1) <<
@@ -1825,9 +1681,7 @@ static inline css_error set_opacity(css_computed_style 
*style, uint8_t type,
 static inline css_error set_order(css_computed_style *style, uint8_t type,
                int32_t integer)
 {
-       uint32_t *bits;
-       
-       bits = &style->i.bits[ORDER_INDEX];
+       uint32_t *bits = &style->i.bits[ORDER_INDEX];
        
        /* 1bit: t : type */
        *bits = (*bits & ~ORDER_MASK) | (((uint32_t)type & 0x1) << ORDER_SHIFT);
@@ -1847,9 +1701,7 @@ static inline css_error set_order(css_computed_style 
*style, uint8_t type,
 static inline css_error set_orphans(css_computed_style *style, uint8_t type,
                int32_t integer)
 {
-       uint32_t *bits;
-       
-       bits = &style->i.bits[ORPHANS_INDEX];
+       uint32_t *bits = &style->i.bits[ORPHANS_INDEX];
        
        /* 1bit: t : type */
        *bits = (*bits & ~ORPHANS_MASK) | (((uint32_t)type & 0x1) <<
@@ -1870,9 +1722,7 @@ static inline css_error set_orphans(css_computed_style 
*style, uint8_t type,
 static inline css_error set_outline_color(css_computed_style *style, uint8_t
                type, css_color color)
 {
-       uint32_t *bits;
-       
-       bits = &style->i.bits[OUTLINE_COLOR_INDEX];
+       uint32_t *bits = &style->i.bits[OUTLINE_COLOR_INDEX];
        
        /* 2bits: tt : type */
        *bits = (*bits & ~OUTLINE_COLOR_MASK) | (((uint32_t)type & 0x3) <<
@@ -1893,9 +1743,7 @@ static inline css_error 
set_outline_color(css_computed_style *style, uint8_t
 static inline css_error set_outline_style(css_computed_style *style, uint8_t
                type)
 {
-       uint32_t *bits;
-       
-       bits = &style->i.bits[OUTLINE_STYLE_INDEX];
+       uint32_t *bits = &style->i.bits[OUTLINE_STYLE_INDEX];
        
        /* 4bits: tttt : type */
        *bits = (*bits & ~OUTLINE_STYLE_MASK) | (((uint32_t)type & 0xf) <<
@@ -1914,9 +1762,7 @@ static inline css_error 
set_outline_style(css_computed_style *style, uint8_t
 static inline css_error set_outline_width(css_computed_style *style, uint8_t
                type, css_fixed length, css_unit unit)
 {
-       uint32_t *bits;
-       
-       bits = &style->i.bits[OUTLINE_WIDTH_INDEX];
+       uint32_t *bits = &style->i.bits[OUTLINE_WIDTH_INDEX];
        
        /* 8bits: uuuuuttt : unit | type */
        *bits = (*bits & ~OUTLINE_WIDTH_MASK) | ((((uint32_t)type & 0x7) | (
@@ -1936,9 +1782,7 @@ static inline css_error 
set_outline_width(css_computed_style *style, uint8_t
 
 static inline css_error set_overflow_x(css_computed_style *style, uint8_t type)
 {
-       uint32_t *bits;
-       
-       bits = &style->i.bits[OVERFLOW_X_INDEX];
+       uint32_t *bits = &style->i.bits[OVERFLOW_X_INDEX];
        
        /* 3bits: ttt : type */
        *bits = (*bits & ~OVERFLOW_X_MASK) | (((uint32_t)type & 0x7) <<
@@ -1956,9 +1800,7 @@ static inline css_error set_overflow_x(css_computed_style 
*style, uint8_t type)
 
 static inline css_error set_overflow_y(css_computed_style *style, uint8_t type)
 {
-       uint32_t *bits;
-       
-       bits = &style->i.bits[OVERFLOW_Y_INDEX];
+       uint32_t *bits = &style->i.bits[OVERFLOW_Y_INDEX];
        
        /* 3bits: ttt : type */
        *bits = (*bits & ~OVERFLOW_Y_MASK) | (((uint32_t)type & 0x7) <<
@@ -1977,9 +1819,7 @@ static inline css_error set_overflow_y(css_computed_style 
*style, uint8_t type)
 static inline css_error set_padding_bottom(css_computed_style *style, uint8_t
                type, css_fixed length, css_unit unit)
 {
-       uint32_t *bits;
-       
-       bits = &style->i.bits[PADDING_BOTTOM_INDEX];
+       uint32_t *bits = &style->i.bits[PADDING_BOTTOM_INDEX];
        
        /* 6bits: uuuuut : unit | type */
        *bits = (*bits & ~PADDING_BOTTOM_MASK) | ((((uint32_t)type & 0x1) | (
@@ -2000,9 +1840,7 @@ static inline css_error 
set_padding_bottom(css_computed_style *style, uint8_t
 static inline css_error set_padding_left(css_computed_style *style, uint8_t
                type, css_fixed length, css_unit unit)
 {
-       uint32_t *bits;
-       
-       bits = &style->i.bits[PADDING_LEFT_INDEX];
+       uint32_t *bits = &style->i.bits[PADDING_LEFT_INDEX];
        
        /* 6bits: uuuuut : unit | type */
        *bits = (*bits & ~PADDING_LEFT_MASK) | ((((uint32_t)type & 0x1) | (unit
@@ -2023,9 +1861,7 @@ static inline css_error 
set_padding_left(css_computed_style *style, uint8_t
 static inline css_error set_padding_right(css_computed_style *style, uint8_t
                type, css_fixed length, css_unit unit)
 {
-       uint32_t *bits;
-       
-       bits = &style->i.bits[PADDING_RIGHT_INDEX];
+       uint32_t *bits = &style->i.bits[PADDING_RIGHT_INDEX];
        
        /* 6bits: uuuuut : unit | type */
        *bits = (*bits & ~PADDING_RIGHT_MASK) | ((((uint32_t)type & 0x1) | (
@@ -2046,9 +1882,7 @@ static inline css_error 
set_padding_right(css_computed_style *style, uint8_t
 static inline css_error set_padding_top(css_computed_style *style, uint8_t
                type, css_fixed length, css_unit unit)
 {
-       uint32_t *bits;
-       
-       bits = &style->i.bits[PADDING_TOP_INDEX];
+       uint32_t *bits = &style->i.bits[PADDING_TOP_INDEX];
        
        /* 6bits: uuuuut : unit | type */
        *bits = (*bits & ~PADDING_TOP_MASK) | ((((uint32_t)type & 0x1) | (unit
@@ -2069,9 +1903,7 @@ static inline css_error 
set_padding_top(css_computed_style *style, uint8_t
 static inline css_error set_page_break_after(css_computed_style *style, uint8_t
                type)
 {
-       uint32_t *bits;
-       
-       bits = &style->i.bits[PAGE_BREAK_AFTER_INDEX];
+       uint32_t *bits = &style->i.bits[PAGE_BREAK_AFTER_INDEX];
        
        /* 3bits: ttt : type */
        *bits = (*bits & ~PAGE_BREAK_AFTER_MASK) | (((uint32_t)type & 0x7) <<
@@ -2090,9 +1922,7 @@ static inline css_error 
set_page_break_after(css_computed_style *style, uint8_t
 static inline css_error set_page_break_before(css_computed_style *style,
                uint8_t type)
 {
-       uint32_t *bits;
-       
-       bits = &style->i.bits[PAGE_BREAK_BEFORE_INDEX];
+       uint32_t *bits = &style->i.bits[PAGE_BREAK_BEFORE_INDEX];
        
        /* 3bits: ttt : type */
        *bits = (*bits & ~PAGE_BREAK_BEFORE_MASK) | (((uint32_t)type & 0x7) <<
@@ -2111,9 +1941,7 @@ static inline css_error 
set_page_break_before(css_computed_style *style,
 static inline css_error set_page_break_inside(css_computed_style *style,
                uint8_t type)
 {
-       uint32_t *bits;
-       
-       bits = &style->i.bits[PAGE_BREAK_INSIDE_INDEX];
+       uint32_t *bits = &style->i.bits[PAGE_BREAK_INSIDE_INDEX];
        
        /* 2bits: tt : type */
        *bits = (*bits & ~PAGE_BREAK_INSIDE_MASK) | (((uint32_t)type & 0x3) <<
@@ -2131,9 +1959,7 @@ static inline css_error 
set_page_break_inside(css_computed_style *style,
 
 static inline css_error set_position(css_computed_style *style, uint8_t type)
 {
-       uint32_t *bits;
-       
-       bits = &style->i.bits[POSITION_INDEX];
+       uint32_t *bits = &style->i.bits[POSITION_INDEX];
        
        /* 3bits: ttt : type */
        *bits = (*bits & ~POSITION_MASK) | (((uint32_t)type & 0x7) <<
@@ -2152,9 +1978,7 @@ static inline css_error set_position(css_computed_style 
*style, uint8_t type)
 static inline css_error set_quotes(css_computed_style *style, uint8_t type,
                lwc_string **string_arr)
 {
-       uint32_t *bits;
-       
-       bits = &style->i.bits[QUOTES_INDEX];
+       uint32_t *bits = &style->i.bits[QUOTES_INDEX];
        
        /* 1bit: t : type */
        *bits = (*bits & ~QUOTES_MASK) | (((uint32_t)type & 0x1) <<
@@ -2190,9 +2014,7 @@ static inline css_error set_quotes(css_computed_style 
*style, uint8_t type,
 static inline css_error set_right(css_computed_style *style, uint8_t type,
                css_fixed length, css_unit unit)
 {
-       uint32_t *bits;
-       
-       bits = &style->i.bits[RIGHT_INDEX];
+       uint32_t *bits = &style->i.bits[RIGHT_INDEX];
        
        /* 7bits: uuuuutt : unit | type */
        *bits = (*bits & ~RIGHT_MASK) | ((((uint32_t)type & 0x3) | (unit << 2))
@@ -2213,9 +2035,7 @@ static inline css_error set_right(css_computed_style 
*style, uint8_t type,
 static inline css_error set_table_layout(css_computed_style *style, uint8_t
                type)
 {
-       uint32_t *bits;
-       
-       bits = &style->i.bits[TABLE_LAYOUT_INDEX];
+       uint32_t *bits = &style->i.bits[TABLE_LAYOUT_INDEX];
        
        /* 2bits: tt : type */
        *bits = (*bits & ~TABLE_LAYOUT_MASK) | (((uint32_t)type & 0x3) <<
@@ -2233,9 +2053,7 @@ static inline css_error 
set_table_layout(css_computed_style *style, uint8_t
 
 static inline css_error set_text_align(css_computed_style *style, uint8_t type)
 {
-       uint32_t *bits;
-       
-       bits = &style->i.bits[TEXT_ALIGN_INDEX];
+       uint32_t *bits = &style->i.bits[TEXT_ALIGN_INDEX];
        
        /* 4bits: tttt : type */
        *bits = (*bits & ~TEXT_ALIGN_MASK) | (((uint32_t)type & 0xf) <<
@@ -2254,9 +2072,7 @@ static inline css_error set_text_align(css_computed_style 
*style, uint8_t type)
 static inline css_error set_text_decoration(css_computed_style *style, uint8_t
                type)
 {
-       uint32_t *bits;
-       
-       bits = &style->i.bits[TEXT_DECORATION_INDEX];
+       uint32_t *bits = &style->i.bits[TEXT_DECORATION_INDEX];
        
        /* 5bits: ttttt : type */
        *bits = (*bits & ~TEXT_DECORATION_MASK) | (((uint32_t)type & 0x1f) <<
@@ -2275,9 +2091,7 @@ static inline css_error 
set_text_decoration(css_computed_style *style, uint8_t
 static inline css_error set_text_indent(css_computed_style *style, uint8_t
                type, css_fixed length, css_unit unit)
 {
-       uint32_t *bits;
-       
-       bits = &style->i.bits[TEXT_INDENT_INDEX];
+       uint32_t *bits = &style->i.bits[TEXT_INDENT_INDEX];
        
        /* 6bits: uuuuut : unit | type */
        *bits = (*bits & ~TEXT_INDENT_MASK) | ((((uint32_t)type & 0x1) | (unit
@@ -2298,9 +2112,7 @@ static inline css_error 
set_text_indent(css_computed_style *style, uint8_t
 static inline css_error set_text_transform(css_computed_style *style, uint8_t
                type)
 {
-       uint32_t *bits;
-       
-       bits = &style->i.bits[TEXT_TRANSFORM_INDEX];
+       uint32_t *bits = &style->i.bits[TEXT_TRANSFORM_INDEX];
        
        /* 3bits: ttt : type */
        *bits = (*bits & ~TEXT_TRANSFORM_MASK) | (((uint32_t)type & 0x7) <<
@@ -2319,9 +2131,7 @@ static inline css_error 
set_text_transform(css_computed_style *style, uint8_t
 static inline css_error set_top(css_computed_style *style, uint8_t type,
                css_fixed length, css_unit unit)
 {
-       uint32_t *bits;
-       
-       bits = &style->i.bits[TOP_INDEX];
+       uint32_t *bits = &style->i.bits[TOP_INDEX];
        
        /* 7bits: uuuuutt : unit | type */
        *bits = (*bits & ~TOP_MASK) | ((((uint32_t)type & 0x3) | (unit << 2))
@@ -2342,9 +2152,7 @@ static inline css_error set_top(css_computed_style 
*style, uint8_t type,
 static inline css_error set_unicode_bidi(css_computed_style *style, uint8_t
                type)
 {
-       uint32_t *bits;
-       
-       bits = &style->i.bits[UNICODE_BIDI_INDEX];
+       uint32_t *bits = &style->i.bits[UNICODE_BIDI_INDEX];
        
        /* 2bits: tt : type */
        *bits = (*bits & ~UNICODE_BIDI_MASK) | (((uint32_t)type & 0x3) <<
@@ -2363,9 +2171,7 @@ static inline css_error 
set_unicode_bidi(css_computed_style *style, uint8_t
 static inline css_error set_vertical_align(css_computed_style *style, uint8_t
                type, css_fixed length, css_unit unit)
 {
-       uint32_t *bits;
-       
-       bits = &style->i.bits[VERTICAL_ALIGN_INDEX];
+       uint32_t *bits = &style->i.bits[VERTICAL_ALIGN_INDEX];
        
        /* 9bits: uuuuutttt : unit | type */
        *bits = (*bits & ~VERTICAL_ALIGN_MASK) | ((((uint32_t)type & 0xf) | (
@@ -2385,9 +2191,7 @@ static inline css_error 
set_vertical_align(css_computed_style *style, uint8_t
 
 static inline css_error set_visibility(css_computed_style *style, uint8_t type)
 {
-       uint32_t *bits;
-       
-       bits = &style->i.bits[VISIBILITY_INDEX];
+       uint32_t *bits = &style->i.bits[VISIBILITY_INDEX];
        
        /* 2bits: tt : type */
        *bits = (*bits & ~VISIBILITY_MASK) | (((uint32_t)type & 0x3) <<
@@ -2405,9 +2209,7 @@ static inline css_error set_visibility(css_computed_style 
*style, uint8_t type)
 
 static inline css_error set_white_space(css_computed_style *style, uint8_t 
type)
 {
-       uint32_t *bits;
-       
-       bits = &style->i.bits[WHITE_SPACE_INDEX];
+       uint32_t *bits = &style->i.bits[WHITE_SPACE_INDEX];
        
        /* 3bits: ttt : type */
        *bits = (*bits & ~WHITE_SPACE_MASK) | (((uint32_t)type & 0x7) <<
@@ -2426,9 +2228,7 @@ static inline css_error 
set_white_space(css_computed_style *style, uint8_t type)
 static inline css_error set_widows(css_computed_style *style, uint8_t type,
                int32_t integer)
 {
-       uint32_t *bits;
-       
-       bits = &style->i.bits[WIDOWS_INDEX];
+       uint32_t *bits = &style->i.bits[WIDOWS_INDEX];
        
        /* 1bit: t : type */
        *bits = (*bits & ~WIDOWS_MASK) | (((uint32_t)type & 0x1) <<
@@ -2449,9 +2249,7 @@ static inline css_error set_widows(css_computed_style 
*style, uint8_t type,
 static inline css_error set_width(css_computed_style *style, uint8_t type,
                css_fixed length, css_unit unit)
 {
-       uint32_t *bits;
-       
-       bits = &style->i.bits[WIDTH_INDEX];
+       uint32_t *bits = &style->i.bits[WIDTH_INDEX];
        
        /* 7bits: uuuuutt : unit | type */
        *bits = (*bits & ~WIDTH_MASK) | ((((uint32_t)type & 0x3) | (unit << 2))
@@ -2472,9 +2270,7 @@ static inline css_error set_width(css_computed_style 
*style, uint8_t type,
 static inline css_error set_word_spacing(css_computed_style *style, uint8_t
                type, css_fixed length, css_unit unit)
 {
-       uint32_t *bits;
-       
-       bits = &style->i.bits[WORD_SPACING_INDEX];
+       uint32_t *bits = &style->i.bits[WORD_SPACING_INDEX];
        
        /* 7bits: uuuuutt : unit | type */
        *bits = (*bits & ~WORD_SPACING_MASK) | ((((uint32_t)type & 0x3) | (unit
@@ -2495,9 +2291,7 @@ static inline css_error 
set_word_spacing(css_computed_style *style, uint8_t
 static inline css_error set_writing_mode(css_computed_style *style, uint8_t
                type)
 {
-       uint32_t *bits;
-       
-       bits = &style->i.bits[WRITING_MODE_INDEX];
+       uint32_t *bits = &style->i.bits[WRITING_MODE_INDEX];
        
        /* 2bits: tt : type */
        *bits = (*bits & ~WRITING_MODE_MASK) | (((uint32_t)type & 0x3) <<
@@ -2516,9 +2310,7 @@ static inline css_error 
set_writing_mode(css_computed_style *style, uint8_t
 static inline css_error set_z_index(css_computed_style *style, uint8_t type,
                int32_t integer)
 {
-       uint32_t *bits;
-       
-       bits = &style->i.bits[Z_INDEX_INDEX];
+       uint32_t *bits = &style->i.bits[Z_INDEX_INDEX];
        
        /* 2bits: tt : type */
        *bits = (*bits & ~Z_INDEX_MASK) | (((uint32_t)type & 0x3) <<
diff --git a/src/select/computed.c b/src/select/computed.c
index a520381..85d53e5 100644
--- a/src/select/computed.c
+++ b/src/select/computed.c
@@ -30,6 +30,12 @@ static css_error 
compute_absolute_border_side_width(css_computed_style *style,
                                css_fixed *len, css_unit *unit),
                css_error (*set)(css_computed_style *style, uint8_t type,
                                css_fixed len, css_unit unit));
+static css_error compute_absolute_border_side_width_calc(css_computed_style 
*style,
+               const css_hint_length *ex_size,
+               uint8_t (*get)(const css_computed_style *style,
+                               css_fixed_or_calc *len, css_unit *unit),
+               css_error (*set)(css_computed_style *style, uint8_t type,
+                               css_fixed_or_calc len, css_unit unit));
 static css_error compute_absolute_sides(css_computed_style *style,
                const css_hint_length *ex_size);
 static css_error compute_absolute_clip(css_computed_style *style,
@@ -48,6 +54,12 @@ static css_error compute_absolute_length(css_computed_style 
*style,
                                css_fixed *len, css_unit *unit),
                css_error (*set)(css_computed_style *style, uint8_t type,
                                css_fixed len, css_unit unit));
+static css_error compute_absolute_length_calc(css_computed_style *style,
+               const css_hint_length *ex_size,
+               uint8_t (*get)(const css_computed_style *style,
+                               css_fixed_or_calc *len, css_unit *unit),
+               css_error (*set)(css_computed_style *style, uint8_t type,
+                               css_fixed_or_calc len, css_unit unit));
 static css_error compute_absolute_length_pair(css_computed_style *style,
                const css_hint_length *ex_size,
                uint8_t (*get)(const css_computed_style *style,
@@ -419,7 +431,18 @@ uint8_t css_computed_border_right_width(const 
css_computed_style *style,
 uint8_t css_computed_border_bottom_width(const css_computed_style *style,
                css_fixed *length, css_unit *unit)
 {
-       return get_border_bottom_width(style, length, unit);
+       css_fixed_or_calc temp;
+       uint8_t type = get_border_bottom_width(style, &temp, unit);
+
+       if (type == CSS_BORDER_WIDTH_WIDTH) {
+               if (*unit == CSS_UNIT_CALC) {
+                       /* TODO */
+               } else {
+                       *length = temp.value;
+               }
+       }
+
+       return type;
 }
 
 uint8_t css_computed_border_left_width(const css_computed_style *style,
@@ -1448,7 +1471,7 @@ css_error 
compute_absolute_border_width(css_computed_style *style,
        if (error != CSS_OK)
                return error;
 
-       error = compute_absolute_border_side_width(style, ex_size,
+       error = compute_absolute_border_side_width_calc(style, ex_size,
                        get_border_bottom_width,
                        set_border_bottom_width);
        if (error != CSS_OK)
@@ -1509,6 +1532,51 @@ css_error 
compute_absolute_border_side_width(css_computed_style *style,
 }
 
 /**
+ * Compute an absolute border side width
+ *
+ * \param style      Style to process
+ * \param ex_size    Ex size, in ems
+ * \param get        Function to read length
+ * \param set        Function to write length
+ * \return CSS_OK on success
+ */
+css_error compute_absolute_border_side_width_calc(css_computed_style *style,
+               const css_hint_length *ex_size,
+               uint8_t (*get)(const css_computed_style *style,
+                               css_fixed_or_calc *len, css_unit *unit),
+               css_error (*set)(css_computed_style *style, uint8_t type,
+                               css_fixed_or_calc len, css_unit unit))
+{
+       css_fixed_or_calc length;
+       css_unit unit;
+
+       switch (get(style, &length, &unit)) {
+       case CSS_BORDER_WIDTH_THIN:
+               length.value = INTTOFIX(1);
+               unit = CSS_UNIT_PX;
+               break;
+       case CSS_BORDER_WIDTH_MEDIUM:
+               length.value = INTTOFIX(2);
+               unit = CSS_UNIT_PX;
+               break;
+       case CSS_BORDER_WIDTH_THICK:
+               length.value = INTTOFIX(4);
+               unit = CSS_UNIT_PX;
+               break;
+       case CSS_BORDER_WIDTH_WIDTH:
+               if (unit == CSS_UNIT_EX) {
+                       length.value = FMUL(length.value, ex_size->value);
+                       unit = ex_size->unit;
+               }
+               break;
+       default:
+               return CSS_INVALID;
+       }
+
+       return set(style, CSS_BORDER_WIDTH_WIDTH, length, unit);
+}
+
+/**
  * Compute absolute clip
  *
  * \param style      Style to process
@@ -1613,7 +1681,7 @@ css_error compute_absolute_sides(css_computed_style 
*style,
        if (error != CSS_OK)
                return error;
 
-       error = compute_absolute_length(style, ex_size,
+       error = compute_absolute_length_calc(style, ex_size,
                        get_bottom, set_bottom);
        if (error != CSS_OK)
                return error;
@@ -1759,6 +1827,38 @@ css_error compute_absolute_length(css_computed_style 
*style,
        return CSS_OK;
 }
 
+/**
+ * Compute the absolute value of length
+ *
+ * \param style      Style to process
+ * \param ex_size    Ex size, in ems
+ * \param get        Function to read length
+ * \param set        Function to write length
+ * \return CSS_OK on success
+ */
+css_error compute_absolute_length_calc(css_computed_style *style,
+               const css_hint_length *ex_size,
+               uint8_t (*get)(const css_computed_style *style,
+                               css_fixed_or_calc *len, css_unit *unit),
+               css_error (*set)(css_computed_style *style, uint8_t type,
+                               css_fixed_or_calc len, css_unit unit))
+{
+       css_unit unit = CSS_UNIT_PX;
+       css_fixed_or_calc length;
+       uint8_t type;
+
+       type = get(style, &length, &unit);
+
+       if (type == CSS_WIDTH_SET && unit == CSS_UNIT_EX) {
+               length.value = FMUL(length.value, ex_size->value);
+               unit = ex_size->unit;
+
+               return set(style, type, length, unit);
+       }
+
+       return CSS_OK;
+}
+
 
 /**
  * Compute the absolute value of length pair
diff --git a/src/select/select_generator.py b/src/select/select_generator.py
index b7a447c..2ea80e1 100644
--- a/src/select/select_generator.py
+++ b/src/select/select_generator.py
@@ -332,18 +332,17 @@ class CSSProperty:
         """
         vals = []
         for v in self.values:
+            or_calc = '_or_calc' if v.calc else ''
+            star = '*' if pointer else ''
             vt, vn = shift_star(v.type, v.name)
-            vn += v.suffix
+            vn = star + vn + v.suffix
             if pointer:
-                vn = '*' + vn
                 if v.name == 'counter_arr' or v.name == 'content_item':
                     vt = 'const ' + vt
-            vals.append((vt, vn))
+            vals.append((vt + or_calc, vn))
             if v.bits is not None:
-                bt, bn = shift_star(v.bits['type'], v.bits['name'])
-                bn += v.suffix
-                if pointer:
-                    bn = '*' + bn
+                bt = v.bits['type']
+                bn = star + v.bits['name'] + v.suffix
                 vals.append((bt, bn))
         return vals
 
@@ -439,21 +438,12 @@ class CSSGroup:
 
         return bits_array
 
-    def get_idot_grp(self):
-        """Make parameters for accessing bits and values in this group."""
-        i_dot = '' if self.name == 'page' else 'i.'
-        grp = '' if self.name == 'style' else '->{}{}'.format(
-            '' if self.name == 'page' else i_dot, self.name)
-        return (i_dot, grp)
-
     def make_computed_h(self):
         """Output this group's text for the computed.h file."""
         t = Text()
         t.append()
 
-        typedef = 'typedef ' if self.name == 'page' else ''
-        t.append('{}struct css_computed_{}{} {{'.format(
-            typedef, self.name, '' if self.name == 'page' else '_i'))
+        t.append('struct css_computed_style_i {')
 
         t.comment()
         commented = []
@@ -500,103 +490,28 @@ class CSSGroup:
         t.append()
         t.append(self.make_value_declaration(for_commented=False))
 
-        if self.name == 'style':
-            t.append()
-            for g in css_groups:
-                if g.name != 'style' and g.name != 'page':
-                    t.append('css_computed_{0} *{0};'.format(g.name))
-
         t.indent(-1)
-        t.append('}}{};'.format(
-            ' css_computed_' + self.name if typedef else ''))
+        t.append('};')
 
-        if self.name != 'page':
-            typedef = 'typedef ' if self.name != 'style' else ''
-            t.append()
-            t.append('{}struct css_computed_{} {{'.format(
-                     typedef, self.name))
-            t.indent(1)
-            t.append('struct css_computed_' + self.name + '_i i;')
-            t.append()
-            t.append(self.make_value_declaration(for_commented=True))
-            t.append()
+        t.append()
+        t.append('struct css_computed_style {')
+        t.indent(1)
+        t.append('struct css_computed_style_i i;')
+        t.append()
+        t.append(self.make_value_declaration(for_commented=True))
+        t.append()
 
-            t.append('struct css_computed_' + self.name + ' *next;')
-            t.append('uint32_t count;')
-            t.append('uint32_t bin;')
-            t.indent(-1)
-            t.append('}}{};'.format(
-                ' css_computed_' + self.name if typedef else ''))
+        t.append('struct css_computed_style *next;')
+        t.append('uint32_t count;')
+        t.append('uint32_t bin;')
+        t.indent(-1)
+        t.append('};')
 
         return t.to_string()
 
     def make_propset_h(self):
-        """Output this group's property functions for the propset.h file.
-
-        If group is not `style`, will also output the defaults
-        and the ENSURE_{group} texts.
-        """
+        """Output this group's property functions for the propset.h file."""
         t = Text()
-        i_dot, grp = self.get_idot_grp()
-
-        if self.name != 'style':
-            t.append('static const css_computed_{0} default_{0} = {{'.format(
-                self.name))
-            t.indent(1)
-
-            if self.name != 'page':
-                t.append('.i = {')
-                t.indent(1)
-
-            t.append('.bits = {') 
-            t.indent(1)
-
-            bits_ops = []
-            for b in self.bits_array:
-                or_ops = []
-                for p in b.contents:
-                    or_ops.append('({} << {})'.format(p.defaults, str(p.shift))
-                                  if p.shift else p.defaults)
-                bits_ops.append(' | '.join(or_ops))
-
-            t.append(',\n'.join(bits_ops).split('\n'))
-            t.indent(-1)
-            t.append('},')
-            t.append(',\n'.join(
-                self.make_value_declaration(False, True)).split('\n'))
-
-            if self.name != 'page':
-                t.indent(-1)
-                t.append('},')
-                t.append(',\n'.join(
-                    self.make_value_declaration(True, True) +
-                    [ '.next = NULL', '.count = 0', '.bin = UINT32_MAX' ]
-                    ).split('\n'))
-
-            t.indent(-1)
-            t.append('};')
-
-            t.append()
-            t.escape_newline()
-            t.append('#define ENSURE_{} do {{'.format(self.name.upper()))
-            t.indent(1)
-            t.append('if (style->{}{} == NULL) {{'.format(i_dot, self.name))
-            t.indent(1)
-            t.append('style->{}{n} = malloc(sizeof(css_computed_{n}));'.format(
-                i_dot, n=self.name))
-            t.append('if (style->{}{} == NULL)'.format(i_dot, self.name))
-            t.indent(1)
-            t.append('return CSS_NOMEM;')
-            t.indent(-1)
-            t.append()
-            t.append('memcpy(style->{}{n}, &default_{n}, '
-                     'sizeof(css_computed_{n}));'.format(i_dot, n=self.name))
-            t.indent(-1)
-            t.append('}')
-            t.indent(-1)
-            t.append('} while(0)')
-            t.escape_newline()
-            t.append()
 
         for p in sorted(self.props, key=(lambda x: x.name)):
             defines, undefs = p.def_undefs
@@ -620,10 +535,7 @@ class CSSGroup:
 
             # Ensure any existing calc() values are freed
             if p.has_calc:
-                t.append('uint32_t orig_bits = 
style{}->{}bits[{}_INDEX];'.format(
-                         grp, i_dot, p.name.upper()))
-                t.append('orig_bits &= {}_MASK;'.format(p.name.upper()))
-                t.append('orig_bits >>= {}_SHIFT;'.format(p.name.upper()))
+                t.append('uint32_t orig_bits = 
get_{}_bits(style);'.format(p.name))
                 t.append()
 
                 type_mask, shift_list, bits_comment = p.get_bits()
@@ -633,23 +545,14 @@ class CSSGroup:
                 for i, v in enumerate(list(reversed(shift_list))):
                     t.append('if ((orig_bits & 0x{:x}) >> {} == CSS_UNIT_CALC) 
{{'.format(v[2], v[1]))
                     t.indent(1)
-                    this_idot = i_dot
-                    
t.append('lwc_string_unref(style->{}{}.calc);'.format(this_idot, p.name))
+                    
t.append('lwc_string_unref(style->i.{}.calc);'.format(p.name))
                     t.indent(-1)
                     t.append('}')
                 t.indent(-1)
                 t.append('}')
                 t.append()
 
-            t.append('uint32_t *bits;')
-            t.append()
-
-            if self.name != 'style':
-                t.append('ENSURE_{};'.format(self.name.upper()))
-                t.append()
-
-            t.append('bits = &style{}->{}bits[{}_INDEX];'.format(
-                grp, i_dot, p.name.upper()))
+            t.append('uint32_t *bits = 
&style->i.bits[{}_INDEX];'.format(p.name.upper()))
             t.append()
 
             type_mask, shift_list, bits_comment = p.get_bits()
@@ -670,19 +573,17 @@ class CSSGroup:
                 old_t, old_n_shift = shift_star(v.type, old_n)
 
                 if v.name == 'string':
-                    t.append('{} {} = style{}->{}{};'.format(
-                        old_t, old_n_shift,
-                        grp, i_dot, p.name + v.suffix))
+                    t.append('{} {} = style->i.{};'.format(
+                        old_t, old_n_shift, p.name + v.suffix))
                     t.append()
                     t.append('if ({} != NULL) {{'.format(v.name + v.suffix))
                     t.indent(1)
-                    t.append('style{}->{}{} = lwc_string_ref({});'.format(
-                        grp, i_dot, p.name + v.suffix, v.name + v.suffix))
+                    t.append('style->i.{} = lwc_string_ref({});'.format(
+                        p.name + v.suffix, v.name + v.suffix))
                     t.indent(-1)
                     t.append('} else {')
                     t.indent(1)
-                    t.append('style{}->{}{} = NULL;'.format(
-                        grp, i_dot, p.name + v.suffix))
+                    t.append('style->i.{} = NULL;'.format(p.name + v.suffix))
                     t.indent(-1)
                     t.append('}')
                     t.append()
@@ -694,9 +595,9 @@ class CSSGroup:
                 elif v.name == 'string_arr' or v.name == 'counter_arr':
                     iter_var = 's' if v.name == 'string_arr' else 'c'
                     iter_deref = '*s' if v.name == 'string_arr' else 'c->name'
-                    t.append('{} {} = style{}->{};'.format(
+                    t.append('{} {} = style->{};'.format(
                         old_t, old_n_shift,
-                        grp, p.name + v.suffix))
+                        p.name + v.suffix))
                     t.append('{} {};'.format(old_t,
                                              shift_star(v.type, iter_var)[1]))
                     t.append()
@@ -707,8 +608,8 @@ class CSSGroup:
                     t.append('{0} = lwc_string_ref({0});'.format(iter_deref))
                     t.indent(-1)
                     t.append()
-                    t.append('style{}->{} = {};'.format(
-                        grp, p.name + v.suffix, v.name + v.suffix))
+                    t.append('style->{} = {};'.format(
+                        p.name + v.suffix, v.name + v.suffix))
                     t.append()
                     t.append('/* Free existing array */')
                     t.append('if ({} != NULL) {{'.format(old_n))
@@ -726,9 +627,14 @@ class CSSGroup:
                     t.append('}')
 
                 elif not v.is_ptr:
-                    dot_value = '.value' if p.has_calc else ''
-                    t.append('style->{}{}{} = {};'.format(
-                        i_dot, p.name + v.suffix, dot_value, v.name + 
v.suffix))
+                    if p.has_calc:
+                        t.append('if (unit == CSS_UNIT_CALC) {')
+                        t.append('\tstyle->i.{}.calc = 
lwc_string_ref({}.calc);'.format(
+                                 p.name + v.suffix, v.name + v.suffix))
+                        t.append('}')
+                    else:
+                        t.append('style->i.{} = {};'.format(
+                            p.name + v.suffix, v.name + v.suffix))
 
                 else:
                     raise ValueError('Cannot handle value ' + v.name +'!')
@@ -742,23 +648,18 @@ class CSSGroup:
         return t.to_string()
 
     def print_propget(self, t, p, only_bits=False):
-        i_dot, grp = self.get_idot_grp()
-
         vals = [] if only_bits else p.get_param_values(pointer=True)
         params = ', '.join([ 'css_computed_style *style' ]
                            + [ ' '.join(x) for x in vals ])
+
         underscore_bits = '_bits' if only_bits else ''
         t.append('static inline uint8_t get_{}{}(const {})'.format(
             p.name, underscore_bits, params))
         t.append('{')
         t.indent(1)
 
-        if self.name != 'style':
-            t.append('if (style{} != NULL) {{'.format(grp))
-            t.indent(1)
-
-        t.append('uint32_t bits = style{}->{}bits[{}_INDEX];'.format(
-            grp, i_dot, p.name.upper()))
+        t.append('uint32_t bits = style->i.bits[{}_INDEX];'.format(
+            p.name.upper()))
         t.append('bits &= {}_MASK;'.format(p.name.upper()))
         t.append('bits >>= {}_SHIFT;'.format(p.name.upper()))
         t.append()
@@ -767,7 +668,6 @@ class CSSGroup:
         t.append(bits_comment)
 
         if only_bits == False:
-
             if p.condition:
                 t.append('if ((bits & {}) == {}) {{'.format(
                     type_mask, p.condition))
@@ -775,10 +675,9 @@ class CSSGroup:
 
             for v in p.values:
                 print(f"name: {p.name}, has_calc: {p.has_calc}, v.name: 
{v.name}")
-                this_idot = '' if v.is_ptr and v.name != 'string' else i_dot
-                dot_value = '.value' if p.has_calc else ''
-                t.append('*{} = style->{}{}{};'.format(
-                    v.name + v.suffix, this_idot, p.name + v.suffix, 
dot_value))
+                i_dot = '' if v.is_ptr and v.name != 'string' else 'i.'
+                t.append('*{} = style->{}{};'.format(
+                    v.name + v.suffix, i_dot, p.name + v.suffix))
             for i, v in enumerate(list(reversed(shift_list))):
                 if i == 0:
                     t.append('*{} = bits >> {};'.format(v[0], v[1]))
@@ -793,18 +692,6 @@ class CSSGroup:
 
         t.append('return (bits & {});'.format(type_mask))
 
-        if self.name != 'style':
-            t.indent(-1)
-            t.append('}')
-            t.append()
-            t.append('/* Initial value */')
-            for v in p.values:
-                t.append('*{} = {};'.format(v.name + v.suffix, v.defaults))
-                if v.bits is not None:
-                    t.append('*{} = {};'.format(
-                        v.bits['name'] + v.suffix, v.bits['defaults']))
-                t.append('return {};'.format(p.defaults))
-
         t.indent(-1)
         t.append('}')
 
@@ -829,7 +716,7 @@ class CSSGroup:
 
         return t.to_string()
 
-    def make_value_declaration(self, for_commented, defaults=False):
+    def make_value_declaration(self, for_commented):
         """Output declarations of values for this group's properties.
 
         Args:
@@ -840,25 +727,12 @@ class CSSGroup:
         r = []
         for p in sorted(self.props, key=(lambda x: x.name)):
             if bool(p.comments) == for_commented:
-                if defaults:
-                    for v in p.values:
-                        r.append('.{}{} = {}'.format(p.name, v.suffix,
-                                                     v.defaults))
-                else:
-                    if (p.values == None or len(p.values) == 0):
-                        continue
-                    if p.has_calc == True:
-                        for v in p.values:
-                            r.append('union {')
-                            v_type, v_name = shift_star(v.type, "value")
-                            r.append('\t{} {};'.format(v_type, v_name))
-                            if v.calc:
-                                r.append('\tlwc_string *calc;')
-                            r.append('}} {}{};'.format(p.name, v.suffix))
-                    else:
-                        for v in p.values:
-                            v_type, v_name = shift_star(v.type, p.name)
-                            r.append('{} {}{};'.format(v_type, v_name, 
v.suffix))
+                if (p.values == None or len(p.values) == 0):
+                    continue
+                for v in p.values:
+                    or_calc = '_or_calc' if v.calc else ''
+                    v_type, v_name = shift_star(v.type, p.name)
+                    r.append('{} {}{};'.format(v_type + or_calc, v_name, 
v.suffix))
         return r
 
     def make_text(self, filename):


-- 
Cascading Style Sheets library
_______________________________________________
netsurf-commits mailing list -- [email protected]
To unsubscribe send an email to [email protected]

Reply via email to