libcss: branch tlsa/calc-wip updated. release/0.9.1-88-g110ee41
by NetSurf Browser Project
Gitweb links:
...log http://git.netsurf-browser.org/libcss.git/shortlog/110ee41e0a4d697c5dfb74...
...commit http://git.netsurf-browser.org/libcss.git/commit/110ee41e0a4d697c5dfb74b4...
...tree http://git.netsurf-browser.org/libcss.git/tree/110ee41e0a4d697c5dfb74b4be...
The branch, tlsa/calc-wip has been updated
discards a28d2e148b5ee756ce284f81598be44b88b319b2 (commit)
via 110ee41e0a4d697c5dfb74b4be3b1622c03fba65 (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 (a28d2e148b5ee756ce284f81598be44b88b319b2)
\
N -- N -- N (110ee41e0a4d697c5dfb74b4be3b1622c03fba65)
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=110ee41e0a4d697c5dfb...
commit 110ee41e0a4d697c5dfb74b4be3b1622c03fba65
Author: Michael Drake <tlsa(a)netsurf-browser.org>
Commit: Michael Drake <tlsa(a)netsurf-browser.org>
WIP: Update computed styles 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/autogenerated_computed.h b/src/select/autogenerated_computed.h
index b26560d..db779ff 100644
--- a/src/select/autogenerated_computed.h
+++ b/src/select/autogenerated_computed.h
@@ -209,7 +209,10 @@ 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;
+ union {
+ css_fixed value;
+ lwc_string *calc;
+ } border_bottom_width;
css_color border_left_color;
css_fixed border_left_width;
css_color border_right_color;
@@ -218,7 +221,10 @@ struct css_computed_style_i {
css_fixed border_spacing_b;
css_color border_top_color;
css_fixed border_top_width;
- css_fixed bottom;
+ union {
+ css_fixed value;
+ lwc_string *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..ef2d74e 100644
--- a/src/select/autogenerated_propget.h
+++ b/src/select/autogenerated_propget.h
@@ -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;
+ *length = style->i.border_bottom_width.value;
*unit = bits >> 3;
}
@@ -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;
+ *length = style->i.bottom.value;
*unit = bits >> 2;
}
diff --git a/src/select/autogenerated_propset.h b/src/select/autogenerated_propset.h
index 036c2ba..317fb2a 100644
--- a/src/select/autogenerated_propset.h
+++ b/src/select/autogenerated_propset.h
@@ -244,6 +244,17 @@ static inline css_error set_border_bottom_style(css_computed_style *style,
static inline css_error set_border_bottom_width(css_computed_style *style,
uint8_t type, css_fixed 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;
+
+ /* 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;
bits = &style->i.bits[BORDER_BOTTOM_WIDTH_INDEX];
@@ -252,7 +263,7 @@ static inline css_error set_border_bottom_width(css_computed_style *style,
*bits = (*bits & ~BORDER_BOTTOM_WIDTH_MASK) | ((((uint32_t)type & 0x7)
| (unit << 3)) << BORDER_BOTTOM_WIDTH_SHIFT);
- style->i.border_bottom_width = length;
+ style->i.border_bottom_width.value = length;
return CSS_OK;
}
@@ -515,6 +526,17 @@ static inline css_error set_border_top_width(css_computed_style *style, uint8_t
static inline css_error set_bottom(css_computed_style *style, uint8_t type,
css_fixed length, css_unit unit)
{
+ uint32_t orig_bits = style->i.bits[BOTTOM_INDEX];
+ orig_bits &= BOTTOM_MASK;
+ orig_bits >>= BOTTOM_SHIFT;
+
+ /* 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;
bits = &style->i.bits[BOTTOM_INDEX];
@@ -523,7 +545,7 @@ static inline css_error set_bottom(css_computed_style *style, uint8_t type,
*bits = (*bits & ~BOTTOM_MASK) | ((((uint32_t)type & 0x3) | (unit <<
2)) << BOTTOM_SHIFT);
- style->i.bottom = length;
+ style->i.bottom.value = length;
return CSS_OK;
}
diff --git a/src/select/computed.c b/src/select/computed.c
index c257f17..a520381 100644
--- a/src/select/computed.c
+++ b/src/select/computed.c
@@ -472,7 +472,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);
}
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'),
diff --git a/src/select/select_generator.py b/src/select/select_generator.py
index 05a4511..b7a447c 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)
@@ -608,6 +618,29 @@ class CSSGroup:
t.append('{')
t.indent(1)
+ # 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()
+
+ 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)
+ this_idot = i_dot
+ t.append('lwc_string_unref(style->{}{}.calc);'.format(this_idot, p.name))
+ t.indent(-1)
+ t.append('}')
+ t.indent(-1)
+ t.append('}')
+ t.append()
+
t.append('uint32_t *bits;')
t.append()
@@ -693,8 +726,9 @@ class CSSGroup:
t.append('}')
elif not v.is_ptr:
- t.append('style{}->{}{} = {};'.format(
- grp, i_dot, p.name + v.suffix, v.name + v.suffix))
+ dot_value = '.value' if p.has_calc else ''
+ t.append('style->{}{}{} = {};'.format(
+ i_dot, p.name + v.suffix, dot_value, v.name + v.suffix))
else:
raise ValueError('Cannot handle value ' + v.name +'!')
@@ -740,9 +774,11 @@ class CSSGroup:
t.indent(1)
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
- t.append('*{} = style{}->{}{};'.format(
- v.name + v.suffix, grp, this_idot, p.name + v.suffix))
+ dot_value = '.value' if p.has_calc else ''
+ t.append('*{} = style->{}{}{};'.format(
+ v.name + v.suffix, this_idot, p.name + v.suffix, dot_value))
for i, v in enumerate(list(reversed(shift_list))):
if i == 0:
t.append('*{} = bits >> {};'.format(v[0], v[1]))
@@ -804,13 +840,25 @@ class CSSGroup:
r = []
for p in sorted(self.props, key=(lambda x: x.name)):
if bool(p.comments) == for_commented:
- for v in p.values:
- if defaults:
+ 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:
- v_type, v_name = shift_star(v.type, p.name)
- r.append('{} {}{};'.format(v_type, v_name, v.suffix))
+ for v in p.values:
+ v_type, v_name = shift_star(v.type, p.name)
+ r.append('{} {}{};'.format(v_type, 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/autogenerated_computed.h | 8 ++++----
src/select/select_config.py | 5 ++---
src/select/select_generator.py | 37 ++++++++++++-----------------------
3 files changed, 18 insertions(+), 32 deletions(-)
diff --git a/src/select/autogenerated_computed.h b/src/select/autogenerated_computed.h
index 62fc731..db779ff 100644
--- a/src/select/autogenerated_computed.h
+++ b/src/select/autogenerated_computed.h
@@ -20,7 +20,7 @@ struct css_computed_style_i {
* background_repeat 3
* border_bottom_color 2 4
* border_bottom_style 4
- * border_bottom_width 3 + 5 4 + sizeof(ptr)
+ * border_bottom_width 3 + 5 4
* border_collapse 2
* border_left_color 2 4
* border_left_style 4
@@ -32,7 +32,7 @@ struct css_computed_style_i {
* border_top_color 2 4
* border_top_style 4
* border_top_width 3 + 5 4
- * bottom 2 + 5 4 + sizeof(ptr)
+ * bottom 2 + 5 4
* box_sizing 2
* break_after 4
* break_before 4
@@ -140,9 +140,9 @@ struct css_computed_style_i {
* quotes 1 sizeof(ptr)
*
* --- --- ---
- * 462 bits 228 + 10sizeof(ptr) bytes
+ * 462 bits 228 + 8sizeof(ptr) bytes
* ===================
- * 286 + 10sizeof(ptr) bytes
+ * 286 + 8sizeof(ptr) bytes
*
* Bit allocations:
*
diff --git a/src/select/select_config.py b/src/select/select_config.py
index 6e1ebeb..bc22ea4 100644
--- a/src/select/select_config.py
+++ b/src/select/select_config.py
@@ -13,7 +13,6 @@ values = {
('integer', 'int32_t', 4, '0'),
('fixed', 'css_fixed', 4, '0'),
('color', 'css_color', 4, '0'),
- ('calc', 'lwc_string*'),
('string', 'lwc_string*'),
('string_arr', 'lwc_string**'),
('counter_arr', 'css_computed_counter*'),
@@ -73,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',), ('calc',)), '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',), ('calc',)), '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'),
diff --git a/src/select/select_generator.py b/src/select/select_generator.py
index 94d44b0..b7a447c 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,
@@ -225,7 +226,7 @@ class CSSProperty:
"""Make list of values for this property."""
self.has_calc = False
- if vals is not None and any(val[0] == 'calc' for val in vals):
+ 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}")
@@ -240,12 +241,11 @@ 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]
- subtraction = 0
- if self.has_calc:
- subtraction = 1
- if len(vals) - subtraction > 1 and v[0] != 'calc':
+ 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)
break
@@ -332,8 +332,6 @@ class CSSProperty:
"""
vals = []
for v in self.values:
- if v.name == 'calc':
- continue
vt, vn = shift_star(v.type, v.name)
vn += v.suffix
if pointer:
@@ -668,9 +666,6 @@ class CSSGroup:
t.append()
for v in p.values:
- if v.name == 'calc':
- continue
-
old_n = 'old_' + v.name + v.suffix
old_t, old_n_shift = shift_star(v.type, old_n)
@@ -780,8 +775,6 @@ class CSSGroup:
for v in p.values:
print(f"name: {p.name}, has_calc: {p.has_calc}, v.name: {v.name}")
- if v.name == 'calc':
- continue
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(
@@ -855,19 +848,13 @@ class CSSGroup:
if (p.values == None or len(p.values) == 0):
continue
if p.has_calc == True:
- calc = None
- for v in p.values:
- if v.name == 'calc':
- calc = v
for v in p.values:
- if v.name != 'calc':
- r.append('union {')
- v_type, v_name = shift_star(v.type, "value")
- r.append('\t{} {};'.format(v_type, v_name))
- if calc != None:
- v_type, v_name = shift_star(calc.type, calc.name)
- r.append('\t{} {}{};'.format(v_type, v_name, calc.suffix))
- r.append('}} {}{};'.format(p.name, v.suffix))
+ 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)
--
Cascading Style Sheets library
6 months, 1 week
libdom: branch master updated. release/0.4.1-25-g7f97358
by NetSurf Browser Project
Gitweb links:
...log http://git.netsurf-browser.org/libdom.git/shortlog/7f97358eab83a5444eb32f...
...commit http://git.netsurf-browser.org/libdom.git/commit/7f97358eab83a5444eb32fdf...
...tree http://git.netsurf-browser.org/libdom.git/tree/7f97358eab83a5444eb32fdfbd...
The branch, master has been updated
via 7f97358eab83a5444eb32fdfbd4bbf600c55dd5c (commit)
from f509cfc624ffcf093348c2e06887e2c16351858c (commit)
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/libdom.git/commit/?id=7f97358eab83a5444eb3...
commit 7f97358eab83a5444eb32fdfbd4bbf600c55dd5c
Author: Daniel Silverstone <dsilvers(a)digital-scurf.org>
Commit: Daniel Silverstone <dsilvers(a)digital-scurf.org>
(tokenlist): Try harder to avoid type punning
Signed-off-by: Daniel Silverstone <dsilvers(a)digital-scurf.org>
diff --git a/src/core/tokenlist.c b/src/core/tokenlist.c
index 4e9f466..cc93a8c 100644
--- a/src/core/tokenlist.c
+++ b/src/core/tokenlist.c
@@ -48,12 +48,12 @@ static void _dom_tokenlist_handle_attrmodified(dom_event *evt, void *pw)
dom_string *value;
{
- dom_node *target;
+ dom_event_target *target;
exc = dom_event_get_target(evt, &target);
if (exc != DOM_NO_ERR)
return;
dom_node_unref(target);
- if (target != (dom_node *)list->ele)
+ if (target != (dom_event_target *)list->ele)
return;
}
-----------------------------------------------------------------------
Summary of changes:
src/core/tokenlist.c | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)
diff --git a/src/core/tokenlist.c b/src/core/tokenlist.c
index 4e9f466..cc93a8c 100644
--- a/src/core/tokenlist.c
+++ b/src/core/tokenlist.c
@@ -48,12 +48,12 @@ static void _dom_tokenlist_handle_attrmodified(dom_event *evt, void *pw)
dom_string *value;
{
- dom_node *target;
+ dom_event_target *target;
exc = dom_event_get_target(evt, &target);
if (exc != DOM_NO_ERR)
return;
dom_node_unref(target);
- if (target != (dom_node *)list->ele)
+ if (target != (dom_event_target *)list->ele)
return;
}
--
Document Object Model library
6 months, 1 week
libdom: branch master updated. release/0.4.1-24-gf509cfc
by NetSurf Browser Project
Gitweb links:
...log http://git.netsurf-browser.org/libdom.git/shortlog/f509cfc624ffcf093348c2...
...commit http://git.netsurf-browser.org/libdom.git/commit/f509cfc624ffcf093348c2e0...
...tree http://git.netsurf-browser.org/libdom.git/tree/f509cfc624ffcf093348c2e068...
The branch, master has been updated
via f509cfc624ffcf093348c2e06887e2c16351858c (commit)
from 79ef33218f7cc9acc7b1735362f9e587d63dd9c7 (commit)
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/libdom.git/commit/?id=f509cfc624ffcf093348...
commit f509cfc624ffcf093348c2e06887e2c16351858c
Author: Daniel Silverstone <dsilvers(a)digital-scurf.org>
Commit: Daniel Silverstone <dsilvers(a)digital-scurf.org>
(tokenlist): Try and avoid type-punned pointer
Signed-off-by: Daniel Silverstone <dsilvers(a)digital-scurf.org>
diff --git a/src/core/tokenlist.c b/src/core/tokenlist.c
index 313b13f..4e9f466 100644
--- a/src/core/tokenlist.c
+++ b/src/core/tokenlist.c
@@ -49,7 +49,7 @@ static void _dom_tokenlist_handle_attrmodified(dom_event *evt, void *pw)
{
dom_node *target;
- exc = dom_event_get_target(mutevt, &target);
+ exc = dom_event_get_target(evt, &target);
if (exc != DOM_NO_ERR)
return;
dom_node_unref(target);
-----------------------------------------------------------------------
Summary of changes:
src/core/tokenlist.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/src/core/tokenlist.c b/src/core/tokenlist.c
index 313b13f..4e9f466 100644
--- a/src/core/tokenlist.c
+++ b/src/core/tokenlist.c
@@ -49,7 +49,7 @@ static void _dom_tokenlist_handle_attrmodified(dom_event *evt, void *pw)
{
dom_node *target;
- exc = dom_event_get_target(mutevt, &target);
+ exc = dom_event_get_target(evt, &target);
if (exc != DOM_NO_ERR)
return;
dom_node_unref(target);
--
Document Object Model library
6 months, 1 week
libparserutils: branch master updated. release/0.2.4-5-g96cdd0f
by NetSurf Browser Project
Gitweb links:
...log http://git.netsurf-browser.org/libparserutils.git/shortlog/96cdd0ff114299...
...commit http://git.netsurf-browser.org/libparserutils.git/commit/96cdd0ff114299f5...
...tree http://git.netsurf-browser.org/libparserutils.git/tree/96cdd0ff114299f520...
The branch, master has been updated
via 96cdd0ff114299f520e76538ab8fde39358b87f9 (commit)
from 010c5f5b3c3db4c07c19e706c9a70c886b614497 (commit)
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/libparserutils.git/commit/?id=96cdd0ff1142...
commit 96cdd0ff114299f520e76538ab8fde39358b87f9
Author: Daniel Silverstone <dsilvers(a)digital-scurf.org>
Commit: Daniel Silverstone <dsilvers(a)digital-scurf.org>
(buffer): Initialise error to OK
Signed-off-by: Daniel Silverstone <dsilvers(a)digital-scurf.org>
diff --git a/src/utils/buffer.c b/src/utils/buffer.c
index b568948..4b68923 100644
--- a/src/utils/buffer.c
+++ b/src/utils/buffer.c
@@ -145,7 +145,7 @@ parserutils_error parserutils_buffer_appendv(parserutils_buffer *buffer,
size_t count, ...)
{
va_list ap;
- parserutils_error error;
+ parserutils_error error = PARSERUTILS_OK;
const uint8_t *data;
size_t len;
-----------------------------------------------------------------------
Summary of changes:
src/utils/buffer.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/src/utils/buffer.c b/src/utils/buffer.c
index b568948..4b68923 100644
--- a/src/utils/buffer.c
+++ b/src/utils/buffer.c
@@ -145,7 +145,7 @@ parserutils_error parserutils_buffer_appendv(parserutils_buffer *buffer,
size_t count, ...)
{
va_list ap;
- parserutils_error error;
+ parserutils_error error = PARSERUTILS_OK;
const uint8_t *data;
size_t len;
--
Lexer/parser utility functions
6 months, 1 week
libdom: branch master updated. release/0.4.1-23-g79ef332
by NetSurf Browser Project
Gitweb links:
...log http://git.netsurf-browser.org/libdom.git/shortlog/79ef33218f7cc9acc7b173...
...commit http://git.netsurf-browser.org/libdom.git/commit/79ef33218f7cc9acc7b17353...
...tree http://git.netsurf-browser.org/libdom.git/tree/79ef33218f7cc9acc7b1735362...
The branch, master has been updated
via 79ef33218f7cc9acc7b1735362f9e587d63dd9c7 (commit)
from ad4cdc900f197c0f373615d454275f38a9c4d181 (commit)
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/libdom.git/commit/?id=79ef33218f7cc9acc7b1...
commit 79ef33218f7cc9acc7b1735362f9e587d63dd9c7
Author: Michael Drake <michael.drake(a)codethink.co.uk>
Commit: Michael Drake <michael.drake(a)codethink.co.uk>
core: tokenlist: Release last_set with dom_string_unref
diff --git a/src/core/tokenlist.c b/src/core/tokenlist.c
index c227b31..313b13f 100644
--- a/src/core/tokenlist.c
+++ b/src/core/tokenlist.c
@@ -227,7 +227,7 @@ static dom_exception _dom_tokenlist_reify(dom_tokenlist *list)
if (list->len == 0) {
if (list->last_set != NULL) {
- dom_node_unref(list->last_set);
+ dom_string_unref(list->last_set);
}
list->last_set = dom_string_ref(
list->ele->base.owner->_memo_empty);
-----------------------------------------------------------------------
Summary of changes:
src/core/tokenlist.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/src/core/tokenlist.c b/src/core/tokenlist.c
index c227b31..313b13f 100644
--- a/src/core/tokenlist.c
+++ b/src/core/tokenlist.c
@@ -227,7 +227,7 @@ static dom_exception _dom_tokenlist_reify(dom_tokenlist *list)
if (list->len == 0) {
if (list->last_set != NULL) {
- dom_node_unref(list->last_set);
+ dom_string_unref(list->last_set);
}
list->last_set = dom_string_ref(
list->ele->base.owner->_memo_empty);
--
Document Object Model library
6 months, 1 week
netsurf: branch master updated. release/3.10-332-g9b57f64
by NetSurf Browser Project
Gitweb links:
...log http://git.netsurf-browser.org/netsurf.git/shortlog/9b57f64c55d244d59ac0c...
...commit http://git.netsurf-browser.org/netsurf.git/commit/9b57f64c55d244d59ac0c00...
...tree http://git.netsurf-browser.org/netsurf.git/tree/9b57f64c55d244d59ac0c0098...
The branch, master has been updated
via 9b57f64c55d244d59ac0c00988ee60c514405d6d (commit)
from 550900b1cbfffcd3ceb5c00631bcbae2b453443c (commit)
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/netsurf.git/commit/?id=9b57f64c55d244d59ac...
commit 9b57f64c55d244d59ac0c00988ee60c514405d6d
Author: Vincent Sanders <vince(a)kyllikki.org>
Commit: Vincent Sanders <vince(a)kyllikki.org>
add rsvg image decoder that uses the new API
diff --git a/content/handlers/image/Makefile b/content/handlers/image/Makefile
index 1c27f74..afc90f4 100644
--- a/content/handlers/image/Makefile
+++ b/content/handlers/image/Makefile
@@ -10,7 +10,7 @@ S_IMAGE_$(NETSURF_USE_JPEG) += jpeg.c
S_IMAGE_$(NETSURF_USE_ROSPRITE) += nssprite.c
S_IMAGE_$(NETSURF_USE_PNG) += png.c
S_IMAGE_$(NETSURF_USE_NSSVG) += svg.c
-S_IMAGE_$(NETSURF_USE_RSVG) += rsvg.c
+S_IMAGE_$(NETSURF_USE_RSVG) += rsvg$(RSVG_API).c
S_IMAGE_$(NETSURF_USE_VIDEO) += video.c
S_IMAGE_$(NETSURF_USE_WEBP) += webp.c
diff --git a/content/handlers/image/rsvg246.c b/content/handlers/image/rsvg246.c
new file mode 100644
index 0000000..1769c50
--- /dev/null
+++ b/content/handlers/image/rsvg246.c
@@ -0,0 +1,265 @@
+/*
+ * Copyright 2022 Vincent Sanders <vince(a)netsurf-browser.org>
+ *
+ * This file is part of NetSurf, http://www.netsurf-browser.org/
+ *
+ * NetSurf is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; version 2 of the License.
+ *
+ * NetSurf is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program. If not, see <http://www.gnu.org/licenses/>.
+ */
+
+/**
+ * \file
+ * implementation of content handler for image/svg using librsvg 2.46 API.
+ *
+ * SVG files are rendered to a NetSurf bitmap by creating a Cairo rendering
+ * surface (content_rsvg_data.cs) over the bitmap's data, creating a Cairo
+ * drawing context using that surface, and then passing that drawing context
+ * to librsvg which then uses Cairo calls to plot the graphic to the bitmap.
+ * We store this in content->bitmap, and then use the usual bitmap plotter
+ * function to render it for redraw requests.
+ */
+
+#include <stdlib.h>
+#include <stdbool.h>
+#include <assert.h>
+#include <string.h>
+#include <sys/types.h>
+
+#include <librsvg/rsvg.h>
+
+#include <nsutils/endian.h>
+
+#include "utils/log.h"
+#include "utils/utils.h"
+#include "utils/messages.h"
+#include "netsurf/plotters.h"
+#include "netsurf/bitmap.h"
+#include "netsurf/content.h"
+#include "content/llcache.h"
+#include "content/content_protected.h"
+#include "content/content_factory.h"
+#include "desktop/gui_internal.h"
+#include "desktop/bitmap.h"
+
+#include "image/image_cache.h"
+
+#include "image/rsvg.h"
+
+
+typedef struct rsvg_content {
+ struct content base;
+
+ RsvgHandle *rsvgh; /**< Context handle for RSVG renderer */
+} rsvg_content;
+
+
+static nserror
+rsvg_create(const content_handler *handler,
+ lwc_string *imime_type,
+ const struct http_parameter *params,
+ llcache_handle *llcache,
+ const char *fallback_charset,
+ bool quirks,
+ struct content **c)
+{
+ rsvg_content *svg;
+ nserror error;
+
+ svg = calloc(1, sizeof(rsvg_content));
+ if (svg == NULL)
+ return NSERROR_NOMEM;
+
+ error = content__init(&svg->base, handler, imime_type, params,
+ llcache, fallback_charset, quirks);
+ if (error != NSERROR_OK) {
+ free(svg);
+ return error;
+ }
+
+ *c = (struct content *)svg;
+
+ return NSERROR_OK;
+}
+
+
+/**
+ * create a bitmap from jpeg content for the image cache.
+ */
+static struct bitmap *
+rsvg_cache_convert(struct content *c)
+{
+ rsvg_content *svgc = (rsvg_content *)c;
+ struct bitmap *bitmap;
+ cairo_surface_t *cs;
+ cairo_t *cr;
+ RsvgRectangle viewport;
+ gboolean renderres;
+
+ if ((bitmap = guit->bitmap->create(c->width, c->height, BITMAP_NONE)) == NULL) {
+ NSLOG(netsurf, INFO, "Failed to create bitmap for rsvg render.");
+ return NULL;
+ }
+
+ if ((cs = cairo_image_surface_create_for_data(
+ (unsigned char *)guit->bitmap->get_buffer(bitmap),
+ CAIRO_FORMAT_ARGB32,
+ c->width, c->height,
+ guit->bitmap->get_rowstride(bitmap))) == NULL) {
+ NSLOG(netsurf, INFO, "Failed to create Cairo image surface for rsvg render.");
+ guit->bitmap->destroy(bitmap);
+ return NULL;
+ }
+ if ((cr = cairo_create(cs)) == NULL) {
+ NSLOG(netsurf, INFO,
+ "Failed to create Cairo drawing context for rsvg render.");
+ cairo_surface_destroy(cs);
+ guit->bitmap->destroy(bitmap);
+ return NULL;
+ }
+
+ viewport.x = 0;
+ viewport.y = 0;
+ viewport.width = c->width;
+ viewport.height = c->height;
+ renderres = rsvg_handle_render_document(svgc->rsvgh, cr, &viewport, NULL);
+ NSLOG(netsurf, DEBUG, "rsvg render:%d, width:%d, height %d", renderres, c->width, c->height);
+
+ bitmap_format_to_client(bitmap, &(bitmap_fmt_t) {
+ .layout = BITMAP_LAYOUT_ARGB8888,
+ });
+ guit->bitmap->modified(bitmap);
+
+ cairo_destroy(cr);
+ cairo_surface_destroy(cs);
+
+ return bitmap;
+}
+
+
+static bool rsvg_convert(struct content *c)
+{
+ rsvg_content *svgc = (rsvg_content *)c;
+ const uint8_t *data; /* content data */
+ size_t size; /* content data size */
+ GInputStream * istream;
+ GError *gerror = NULL;
+ gdouble rwidth, rheight;
+ gboolean gotsize;
+ /* check image header is valid and get width/height */
+
+ data = content__get_source_data(c, &size);
+
+ istream = g_memory_input_stream_new_from_data(data, size, NULL);
+ svgc->rsvgh = rsvg_handle_new_from_stream_sync(istream,
+ NULL,
+ RSVG_HANDLE_FLAGS_NONE,
+ NULL,
+ &gerror);
+ g_object_unref(istream);
+ if (svgc->rsvgh == NULL) {
+ NSLOG(netsurf, INFO, "Failed to create rsvg handle for content.");
+ return false;
+ }
+
+ gotsize = rsvg_handle_get_intrinsic_size_in_pixels(svgc->rsvgh,
+ &rwidth,
+ &rheight);
+ if (gotsize == TRUE) {
+ c->width = rwidth;
+ c->height = rheight;
+ } else {
+ RsvgRectangle ink_rect;
+ RsvgRectangle logical_rect;
+ rsvg_handle_get_geometry_for_element(svgc->rsvgh,
+ NULL,
+ &ink_rect,
+ &logical_rect,
+ NULL);
+ c->width = ink_rect.width;
+ c->height = ink_rect.height;
+ }
+
+ NSLOG(netsurf, DEBUG, "rsvg width:%d height:%d.",c->width, c->height);
+
+ c->size = c->width * c->height * 4;
+
+ image_cache_add(c, NULL, rsvg_cache_convert);
+
+ content_set_ready(c);
+ content_set_done(c);
+ content_set_status(c, ""); /* Done: update status bar */
+
+ return true;
+}
+
+
+static nserror rsvg_clone(const struct content *old, struct content **newc)
+{
+ rsvg_content *svg;
+ nserror error;
+
+ svg = calloc(1, sizeof(rsvg_content));
+ if (svg == NULL)
+ return NSERROR_NOMEM;
+
+ error = content__clone(old, &svg->base);
+ if (error != NSERROR_OK) {
+ content_destroy(&svg->base);
+ return error;
+ }
+
+ /* re-convert if the content is ready */
+ if ((old->status == CONTENT_STATUS_READY) ||
+ (old->status == CONTENT_STATUS_DONE)) {
+ if (rsvg_convert(&svg->base) == false) {
+ content_destroy(&svg->base);
+ return NSERROR_CLONE_FAILED;
+ }
+ }
+
+ *newc = (struct content *)svg;
+
+ return NSERROR_OK;
+}
+
+
+static void rsvg_destroy(struct content *c)
+{
+ rsvg_content *d = (rsvg_content *) c;
+
+ if (d->rsvgh != NULL) {
+ g_object_unref(d->rsvgh);
+ d->rsvgh = NULL;
+ }
+
+ return image_cache_destroy(c);
+}
+
+static const content_handler rsvg_content_handler = {
+ .create = rsvg_create,
+ .data_complete = rsvg_convert,
+ .destroy = rsvg_destroy,
+ .redraw = image_cache_redraw,
+ .clone = rsvg_clone,
+ .get_internal = image_cache_get_internal,
+ .type = image_cache_content_type,
+ .is_opaque = image_cache_is_opaque,
+ .no_share = false,
+};
+
+static const char *rsvg_types[] = {
+ "image/svg",
+ "image/svg+xml"
+};
+
+CONTENT_FACTORY_REGISTER_TYPES(nsrsvg, rsvg_types, rsvg_content_handler);
+
diff --git a/frontends/gtk/Makefile b/frontends/gtk/Makefile
index 4f3fd5f..79f03b3 100644
--- a/frontends/gtk/Makefile
+++ b/frontends/gtk/Makefile
@@ -11,6 +11,8 @@
NETSURF_FEATURE_RSVG_CFLAGS := -DWITH_RSVG
NETSURF_FEATURE_VIDEO_CFLAGS := -DWITH_VIDEO
+# determine if the rsvg library API version
+RSVG_API := $(shell $(PKG_CONFIG) --atleast-version=2.46 librsvg-2.0 && echo 246)
$(eval $(call pkg_config_find_and_add_enabled,RSVG,librsvg-2.0,SVG))
$(eval $(call pkg_config_find_and_add_enabled,VIDEO,gstreamer-0.10,Video))
-----------------------------------------------------------------------
Summary of changes:
content/handlers/image/Makefile | 2 +-
content/handlers/image/rsvg246.c | 265 ++++++++++++++++++++++++++++++++++++++
frontends/gtk/Makefile | 2 +
3 files changed, 268 insertions(+), 1 deletion(-)
create mode 100644 content/handlers/image/rsvg246.c
diff --git a/content/handlers/image/Makefile b/content/handlers/image/Makefile
index 1c27f74..afc90f4 100644
--- a/content/handlers/image/Makefile
+++ b/content/handlers/image/Makefile
@@ -10,7 +10,7 @@ S_IMAGE_$(NETSURF_USE_JPEG) += jpeg.c
S_IMAGE_$(NETSURF_USE_ROSPRITE) += nssprite.c
S_IMAGE_$(NETSURF_USE_PNG) += png.c
S_IMAGE_$(NETSURF_USE_NSSVG) += svg.c
-S_IMAGE_$(NETSURF_USE_RSVG) += rsvg.c
+S_IMAGE_$(NETSURF_USE_RSVG) += rsvg$(RSVG_API).c
S_IMAGE_$(NETSURF_USE_VIDEO) += video.c
S_IMAGE_$(NETSURF_USE_WEBP) += webp.c
diff --git a/content/handlers/image/rsvg246.c b/content/handlers/image/rsvg246.c
new file mode 100644
index 0000000..1769c50
--- /dev/null
+++ b/content/handlers/image/rsvg246.c
@@ -0,0 +1,265 @@
+/*
+ * Copyright 2022 Vincent Sanders <vince(a)netsurf-browser.org>
+ *
+ * This file is part of NetSurf, http://www.netsurf-browser.org/
+ *
+ * NetSurf is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; version 2 of the License.
+ *
+ * NetSurf is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program. If not, see <http://www.gnu.org/licenses/>.
+ */
+
+/**
+ * \file
+ * implementation of content handler for image/svg using librsvg 2.46 API.
+ *
+ * SVG files are rendered to a NetSurf bitmap by creating a Cairo rendering
+ * surface (content_rsvg_data.cs) over the bitmap's data, creating a Cairo
+ * drawing context using that surface, and then passing that drawing context
+ * to librsvg which then uses Cairo calls to plot the graphic to the bitmap.
+ * We store this in content->bitmap, and then use the usual bitmap plotter
+ * function to render it for redraw requests.
+ */
+
+#include <stdlib.h>
+#include <stdbool.h>
+#include <assert.h>
+#include <string.h>
+#include <sys/types.h>
+
+#include <librsvg/rsvg.h>
+
+#include <nsutils/endian.h>
+
+#include "utils/log.h"
+#include "utils/utils.h"
+#include "utils/messages.h"
+#include "netsurf/plotters.h"
+#include "netsurf/bitmap.h"
+#include "netsurf/content.h"
+#include "content/llcache.h"
+#include "content/content_protected.h"
+#include "content/content_factory.h"
+#include "desktop/gui_internal.h"
+#include "desktop/bitmap.h"
+
+#include "image/image_cache.h"
+
+#include "image/rsvg.h"
+
+
+typedef struct rsvg_content {
+ struct content base;
+
+ RsvgHandle *rsvgh; /**< Context handle for RSVG renderer */
+} rsvg_content;
+
+
+static nserror
+rsvg_create(const content_handler *handler,
+ lwc_string *imime_type,
+ const struct http_parameter *params,
+ llcache_handle *llcache,
+ const char *fallback_charset,
+ bool quirks,
+ struct content **c)
+{
+ rsvg_content *svg;
+ nserror error;
+
+ svg = calloc(1, sizeof(rsvg_content));
+ if (svg == NULL)
+ return NSERROR_NOMEM;
+
+ error = content__init(&svg->base, handler, imime_type, params,
+ llcache, fallback_charset, quirks);
+ if (error != NSERROR_OK) {
+ free(svg);
+ return error;
+ }
+
+ *c = (struct content *)svg;
+
+ return NSERROR_OK;
+}
+
+
+/**
+ * create a bitmap from jpeg content for the image cache.
+ */
+static struct bitmap *
+rsvg_cache_convert(struct content *c)
+{
+ rsvg_content *svgc = (rsvg_content *)c;
+ struct bitmap *bitmap;
+ cairo_surface_t *cs;
+ cairo_t *cr;
+ RsvgRectangle viewport;
+ gboolean renderres;
+
+ if ((bitmap = guit->bitmap->create(c->width, c->height, BITMAP_NONE)) == NULL) {
+ NSLOG(netsurf, INFO, "Failed to create bitmap for rsvg render.");
+ return NULL;
+ }
+
+ if ((cs = cairo_image_surface_create_for_data(
+ (unsigned char *)guit->bitmap->get_buffer(bitmap),
+ CAIRO_FORMAT_ARGB32,
+ c->width, c->height,
+ guit->bitmap->get_rowstride(bitmap))) == NULL) {
+ NSLOG(netsurf, INFO, "Failed to create Cairo image surface for rsvg render.");
+ guit->bitmap->destroy(bitmap);
+ return NULL;
+ }
+ if ((cr = cairo_create(cs)) == NULL) {
+ NSLOG(netsurf, INFO,
+ "Failed to create Cairo drawing context for rsvg render.");
+ cairo_surface_destroy(cs);
+ guit->bitmap->destroy(bitmap);
+ return NULL;
+ }
+
+ viewport.x = 0;
+ viewport.y = 0;
+ viewport.width = c->width;
+ viewport.height = c->height;
+ renderres = rsvg_handle_render_document(svgc->rsvgh, cr, &viewport, NULL);
+ NSLOG(netsurf, DEBUG, "rsvg render:%d, width:%d, height %d", renderres, c->width, c->height);
+
+ bitmap_format_to_client(bitmap, &(bitmap_fmt_t) {
+ .layout = BITMAP_LAYOUT_ARGB8888,
+ });
+ guit->bitmap->modified(bitmap);
+
+ cairo_destroy(cr);
+ cairo_surface_destroy(cs);
+
+ return bitmap;
+}
+
+
+static bool rsvg_convert(struct content *c)
+{
+ rsvg_content *svgc = (rsvg_content *)c;
+ const uint8_t *data; /* content data */
+ size_t size; /* content data size */
+ GInputStream * istream;
+ GError *gerror = NULL;
+ gdouble rwidth, rheight;
+ gboolean gotsize;
+ /* check image header is valid and get width/height */
+
+ data = content__get_source_data(c, &size);
+
+ istream = g_memory_input_stream_new_from_data(data, size, NULL);
+ svgc->rsvgh = rsvg_handle_new_from_stream_sync(istream,
+ NULL,
+ RSVG_HANDLE_FLAGS_NONE,
+ NULL,
+ &gerror);
+ g_object_unref(istream);
+ if (svgc->rsvgh == NULL) {
+ NSLOG(netsurf, INFO, "Failed to create rsvg handle for content.");
+ return false;
+ }
+
+ gotsize = rsvg_handle_get_intrinsic_size_in_pixels(svgc->rsvgh,
+ &rwidth,
+ &rheight);
+ if (gotsize == TRUE) {
+ c->width = rwidth;
+ c->height = rheight;
+ } else {
+ RsvgRectangle ink_rect;
+ RsvgRectangle logical_rect;
+ rsvg_handle_get_geometry_for_element(svgc->rsvgh,
+ NULL,
+ &ink_rect,
+ &logical_rect,
+ NULL);
+ c->width = ink_rect.width;
+ c->height = ink_rect.height;
+ }
+
+ NSLOG(netsurf, DEBUG, "rsvg width:%d height:%d.",c->width, c->height);
+
+ c->size = c->width * c->height * 4;
+
+ image_cache_add(c, NULL, rsvg_cache_convert);
+
+ content_set_ready(c);
+ content_set_done(c);
+ content_set_status(c, ""); /* Done: update status bar */
+
+ return true;
+}
+
+
+static nserror rsvg_clone(const struct content *old, struct content **newc)
+{
+ rsvg_content *svg;
+ nserror error;
+
+ svg = calloc(1, sizeof(rsvg_content));
+ if (svg == NULL)
+ return NSERROR_NOMEM;
+
+ error = content__clone(old, &svg->base);
+ if (error != NSERROR_OK) {
+ content_destroy(&svg->base);
+ return error;
+ }
+
+ /* re-convert if the content is ready */
+ if ((old->status == CONTENT_STATUS_READY) ||
+ (old->status == CONTENT_STATUS_DONE)) {
+ if (rsvg_convert(&svg->base) == false) {
+ content_destroy(&svg->base);
+ return NSERROR_CLONE_FAILED;
+ }
+ }
+
+ *newc = (struct content *)svg;
+
+ return NSERROR_OK;
+}
+
+
+static void rsvg_destroy(struct content *c)
+{
+ rsvg_content *d = (rsvg_content *) c;
+
+ if (d->rsvgh != NULL) {
+ g_object_unref(d->rsvgh);
+ d->rsvgh = NULL;
+ }
+
+ return image_cache_destroy(c);
+}
+
+static const content_handler rsvg_content_handler = {
+ .create = rsvg_create,
+ .data_complete = rsvg_convert,
+ .destroy = rsvg_destroy,
+ .redraw = image_cache_redraw,
+ .clone = rsvg_clone,
+ .get_internal = image_cache_get_internal,
+ .type = image_cache_content_type,
+ .is_opaque = image_cache_is_opaque,
+ .no_share = false,
+};
+
+static const char *rsvg_types[] = {
+ "image/svg",
+ "image/svg+xml"
+};
+
+CONTENT_FACTORY_REGISTER_TYPES(nsrsvg, rsvg_types, rsvg_content_handler);
+
diff --git a/frontends/gtk/Makefile b/frontends/gtk/Makefile
index 4f3fd5f..79f03b3 100644
--- a/frontends/gtk/Makefile
+++ b/frontends/gtk/Makefile
@@ -11,6 +11,8 @@
NETSURF_FEATURE_RSVG_CFLAGS := -DWITH_RSVG
NETSURF_FEATURE_VIDEO_CFLAGS := -DWITH_VIDEO
+# determine if the rsvg library API version
+RSVG_API := $(shell $(PKG_CONFIG) --atleast-version=2.46 librsvg-2.0 && echo 246)
$(eval $(call pkg_config_find_and_add_enabled,RSVG,librsvg-2.0,SVG))
$(eval $(call pkg_config_find_and_add_enabled,VIDEO,gstreamer-0.10,Video))
--
NetSurf Browser
6 months, 1 week
libcss: branch tlsa/calc-wip updated. release/0.9.1-88-ga28d2e1
by NetSurf Browser Project
Gitweb links:
...log http://git.netsurf-browser.org/libcss.git/shortlog/a28d2e148b5ee756ce284f...
...commit http://git.netsurf-browser.org/libcss.git/commit/a28d2e148b5ee756ce284f81...
...tree http://git.netsurf-browser.org/libcss.git/tree/a28d2e148b5ee756ce284f8159...
The branch, tlsa/calc-wip has been updated
discards ac9d68a38c4aad45ad4ebf3db2c3b5a7cb971cd1 (commit)
discards 6d58bc4e0278c971ba7fc9623367d8ea241689ee (commit)
discards ad87e675c59bc76a64c445cc89b8cc4522e6f761 (commit)
discards 765404ce9ca85d6eb531f8f9df56b82ed6477315 (commit)
discards 177d9baa45a1b8d325bb42202d7ac72133dd8dc0 (commit)
discards 5b6dcb98c7ff91177c6d26bff06a1d37e21c3438 (commit)
discards cf91e739e7b181d4a734c1394e426c3bb4cc6483 (commit)
via a28d2e148b5ee756ce284f81598be44b88b319b2 (commit)
via bb4f667d633a2640f3673cf269b98af1e1b24ea1 (commit)
via 6a361f59639e23e50f0dbd18d6c28ca330e288cb (commit)
via 870585f3cd0320e5813a39bec5827cf76f4102b5 (commit)
via 93d6d6d2b7480bbbc0b13b69e151870b4cbfb465 (commit)
via 88c8258aabef042da70e419141a8d8e198673225 (commit)
via 4702422440022bfd64bdf6e221c8f89fd2923fda (commit)
via 022a04d022f446b57818dfa7d5b49928f9d63bf4 (commit)
via 609e1623335d5d5147439c5ba600152e963fc951 (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 (ac9d68a38c4aad45ad4ebf3db2c3b5a7cb971cd1)
\
N -- N -- N (a28d2e148b5ee756ce284f81598be44b88b319b2)
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=a28d2e148b5ee756ce28...
commit a28d2e148b5ee756ce284f81598be44b88b319b2
Author: Michael Drake <tlsa(a)netsurf-browser.org>
Commit: Michael Drake <tlsa(a)netsurf-browser.org>
WIP: Update computed styles 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/autogenerated_computed.h b/src/select/autogenerated_computed.h
index b26560d..62fc731 100644
--- a/src/select/autogenerated_computed.h
+++ b/src/select/autogenerated_computed.h
@@ -20,7 +20,7 @@ struct css_computed_style_i {
* background_repeat 3
* border_bottom_color 2 4
* border_bottom_style 4
- * border_bottom_width 3 + 5 4
+ * border_bottom_width 3 + 5 4 + sizeof(ptr)
* border_collapse 2
* border_left_color 2 4
* border_left_style 4
@@ -32,7 +32,7 @@ struct css_computed_style_i {
* border_top_color 2 4
* border_top_style 4
* border_top_width 3 + 5 4
- * bottom 2 + 5 4
+ * bottom 2 + 5 4 + sizeof(ptr)
* box_sizing 2
* break_after 4
* break_before 4
@@ -140,9 +140,9 @@ struct css_computed_style_i {
* quotes 1 sizeof(ptr)
*
* --- --- ---
- * 462 bits 228 + 8sizeof(ptr) bytes
+ * 462 bits 228 + 10sizeof(ptr) bytes
* ===================
- * 286 + 8sizeof(ptr) bytes
+ * 286 + 10sizeof(ptr) bytes
*
* Bit allocations:
*
@@ -209,7 +209,10 @@ 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;
+ union {
+ css_fixed value;
+ lwc_string *calc;
+ } border_bottom_width;
css_color border_left_color;
css_fixed border_left_width;
css_color border_right_color;
@@ -218,7 +221,10 @@ struct css_computed_style_i {
css_fixed border_spacing_b;
css_color border_top_color;
css_fixed border_top_width;
- css_fixed bottom;
+ union {
+ css_fixed value;
+ lwc_string *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..ef2d74e 100644
--- a/src/select/autogenerated_propget.h
+++ b/src/select/autogenerated_propget.h
@@ -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;
+ *length = style->i.border_bottom_width.value;
*unit = bits >> 3;
}
@@ -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;
+ *length = style->i.bottom.value;
*unit = bits >> 2;
}
diff --git a/src/select/autogenerated_propset.h b/src/select/autogenerated_propset.h
index 036c2ba..317fb2a 100644
--- a/src/select/autogenerated_propset.h
+++ b/src/select/autogenerated_propset.h
@@ -244,6 +244,17 @@ static inline css_error set_border_bottom_style(css_computed_style *style,
static inline css_error set_border_bottom_width(css_computed_style *style,
uint8_t type, css_fixed 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;
+
+ /* 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;
bits = &style->i.bits[BORDER_BOTTOM_WIDTH_INDEX];
@@ -252,7 +263,7 @@ static inline css_error set_border_bottom_width(css_computed_style *style,
*bits = (*bits & ~BORDER_BOTTOM_WIDTH_MASK) | ((((uint32_t)type & 0x7)
| (unit << 3)) << BORDER_BOTTOM_WIDTH_SHIFT);
- style->i.border_bottom_width = length;
+ style->i.border_bottom_width.value = length;
return CSS_OK;
}
@@ -515,6 +526,17 @@ static inline css_error set_border_top_width(css_computed_style *style, uint8_t
static inline css_error set_bottom(css_computed_style *style, uint8_t type,
css_fixed length, css_unit unit)
{
+ uint32_t orig_bits = style->i.bits[BOTTOM_INDEX];
+ orig_bits &= BOTTOM_MASK;
+ orig_bits >>= BOTTOM_SHIFT;
+
+ /* 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;
bits = &style->i.bits[BOTTOM_INDEX];
@@ -523,7 +545,7 @@ static inline css_error set_bottom(css_computed_style *style, uint8_t type,
*bits = (*bits & ~BOTTOM_MASK) | ((((uint32_t)type & 0x3) | (unit <<
2)) << BOTTOM_SHIFT);
- style->i.bottom = length;
+ style->i.bottom.value = length;
return CSS_OK;
}
diff --git a/src/select/computed.c b/src/select/computed.c
index c257f17..a520381 100644
--- a/src/select/computed.c
+++ b/src/select/computed.c
@@ -472,7 +472,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);
}
diff --git a/src/select/select_config.py b/src/select/select_config.py
index fd9e765..6e1ebeb 100644
--- a/src/select/select_config.py
+++ b/src/select/select_config.py
@@ -13,6 +13,7 @@ values = {
('integer', 'int32_t', 4, '0'),
('fixed', 'css_fixed', 4, '0'),
('color', 'css_color', 4, '0'),
+ ('calc', 'lwc_string*'),
('string', 'lwc_string*'),
('string_arr', 'lwc_string**'),
('counter_arr', 'css_computed_counter*'),
@@ -72,11 +73,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',), ('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',), ('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'),
diff --git a/src/select/select_generator.py b/src/select/select_generator.py
index 05a4511..94d44b0 100644
--- a/src/select/select_generator.py
+++ b/src/select/select_generator.py
@@ -223,6 +223,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(val[0] == '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:
@@ -235,7 +242,10 @@ class CSSProperty:
value = CSSValue(*x)
if len(v) == 2:
value.defaults = v[1]
- if len(vals) > 1:
+ subtraction = 0
+ if self.has_calc:
+ subtraction = 1
+ if len(vals) - subtraction > 1 and v[0] != 'calc':
value.suffix = '_' + string.ascii_lowercase[i]
val_list.append(value)
break
@@ -322,6 +332,8 @@ class CSSProperty:
"""
vals = []
for v in self.values:
+ if v.name == 'calc':
+ continue
vt, vn = shift_star(v.type, v.name)
vn += v.suffix
if pointer:
@@ -608,6 +620,29 @@ class CSSGroup:
t.append('{')
t.indent(1)
+ # 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()
+
+ 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)
+ this_idot = i_dot
+ t.append('lwc_string_unref(style->{}{}.calc);'.format(this_idot, p.name))
+ t.indent(-1)
+ t.append('}')
+ t.indent(-1)
+ t.append('}')
+ t.append()
+
t.append('uint32_t *bits;')
t.append()
@@ -633,6 +668,9 @@ class CSSGroup:
t.append()
for v in p.values:
+ if v.name == 'calc':
+ continue
+
old_n = 'old_' + v.name + v.suffix
old_t, old_n_shift = shift_star(v.type, old_n)
@@ -693,8 +731,9 @@ class CSSGroup:
t.append('}')
elif not v.is_ptr:
- t.append('style{}->{}{} = {};'.format(
- grp, i_dot, p.name + v.suffix, v.name + v.suffix))
+ dot_value = '.value' if p.has_calc else ''
+ t.append('style->{}{}{} = {};'.format(
+ i_dot, p.name + v.suffix, dot_value, v.name + v.suffix))
else:
raise ValueError('Cannot handle value ' + v.name +'!')
@@ -740,9 +779,13 @@ class CSSGroup:
t.indent(1)
for v in p.values:
+ print(f"name: {p.name}, has_calc: {p.has_calc}, v.name: {v.name}")
+ if v.name == 'calc':
+ continue
this_idot = '' if v.is_ptr and v.name != 'string' else i_dot
- t.append('*{} = style{}->{}{};'.format(
- v.name + v.suffix, grp, this_idot, p.name + v.suffix))
+ dot_value = '.value' if p.has_calc else ''
+ t.append('*{} = style->{}{}{};'.format(
+ v.name + v.suffix, this_idot, p.name + v.suffix, dot_value))
for i, v in enumerate(list(reversed(shift_list))):
if i == 0:
t.append('*{} = bits >> {};'.format(v[0], v[1]))
@@ -804,13 +847,31 @@ class CSSGroup:
r = []
for p in sorted(self.props, key=(lambda x: x.name)):
if bool(p.comments) == for_commented:
- for v in p.values:
- if defaults:
+ 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:
+ calc = None
+ for v in p.values:
+ if v.name == 'calc':
+ calc = v
+ for v in p.values:
+ if v.name != 'calc':
+ r.append('union {')
+ v_type, v_name = shift_star(v.type, "value")
+ r.append('\t{} {};'.format(v_type, v_name))
+ if calc != None:
+ v_type, v_name = shift_star(calc.type, calc.name)
+ r.append('\t{} {}{};'.format(v_type, v_name, calc.suffix))
+ r.append('}} {}{};'.format(p.name, v.suffix))
else:
- v_type, v_name = shift_star(v.type, p.name)
- r.append('{} {}{};'.format(v_type, v_name, v.suffix))
+ for v in p.values:
+ v_type, v_name = shift_star(v.type, p.name)
+ r.append('{} {}{};'.format(v_type, 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;
commitdiff http://git.netsurf-browser.org/libcss.git/commit/?id=bb4f667d633a2640f367...
commit bb4f667d633a2640f3673cf269b98af1e1b24ea1
Author: Daniel Silverstone <dsilvers(a)digital-scurf.org>
Commit: Michael Drake <tlsa(a)netsurf-browser.org>
(calc): Update bytecode for calc() to be in an lwc_string
In order to permit us to share calc expressions between styles
and computed styles, without copying, we embed the calc expression
bytecode into an lwc string. This is effectively using lwc_string
as an interned byte buffer, there may be a nicer way to do this in
the future.
Signed-off-by: Daniel Silverstone <dsilvers(a)digital-scurf.org>
diff --git a/src/parse/properties/utils.c b/src/parse/properties/utils.c
index fe5ee6b..fa8ffbe 100644
--- a/src/parse/properties/utils.c
+++ b/src/parse/properties/utils.c
@@ -1362,16 +1362,17 @@ cleanup:
static css_error
css__parse_calc_sum(css_language *c,
const parserutils_vector *vector, int *ctx,
- css_style *result);
+ parserutils_buffer *result);
static css_error
css__parse_calc_number(
const parserutils_vector *vector, int *ctx,
- css_style *result)
+ parserutils_buffer *result)
{
const css_token *token;
css_fixed num;
size_t consumed;
+ css_code_t push = CALC_PUSH_NUMBER;
/* Consume the number token */
token = parserutils_vector_iterate(vector, ctx);
@@ -1386,13 +1387,18 @@ css__parse_calc_number(
return CSS_INVALID;
}
- return css__stylesheet_style_vappend(result, 2, (css_code_t) CALC_PUSH_NUMBER, (css_code_t)num);
+ return css_error_from_parserutils_error(
+ parserutils_buffer_appendv(result, 2,
+ &push, sizeof(push),
+ &num, sizeof(num)
+ )
+ );
}
static css_error
css__parse_calc_value(css_language *c,
const parserutils_vector *vector, int *ctx,
- css_style *result)
+ parserutils_buffer *result)
{
css_error error;
int orig_ctx = *ctx;
@@ -1426,6 +1432,7 @@ css__parse_calc_value(css_language *c,
{
css_fixed length = 0;
uint32_t unit = 0;
+ css_code_t push = CALC_PUSH_VALUE;
*ctx = orig_ctx;
error = css__parse_unit_specifier(c, vector, ctx, UNIT_CALC_NUMBER, &length, &unit);
@@ -1434,7 +1441,14 @@ css__parse_calc_value(css_language *c,
return error;
}
- error = css__stylesheet_style_vappend(result, 3, (css_code_t) CALC_PUSH_VALUE, length, unit);
+ error = css_error_from_parserutils_error(
+ parserutils_buffer_appendv(result, 3,
+ &push, sizeof(push),
+ &length, sizeof(length),
+ &unit, sizeof(unit)
+ )
+ );
+
}
break;
@@ -1455,12 +1469,11 @@ css__parse_calc_value(css_language *c,
static css_error
css__parse_calc_product(css_language *c,
const parserutils_vector *vector, int *ctx,
- css_style *result)
+ parserutils_buffer *result)
{
css_error error = CSS_OK;
const css_token *token;
- bool multiplication;
-
+ css_code_t operator;
/* First parse a value */
error = css__parse_calc_value(c, vector, ctx, result);
@@ -1480,9 +1493,9 @@ css__parse_calc_product(css_language *c,
tokenIsChar(token, '-'))
break;
else if (tokenIsChar(token, '*'))
- multiplication = true;
+ operator = CALC_MULTIPLY;
else if (tokenIsChar(token, '/'))
- multiplication = false;
+ operator = CALC_DIVIDE;
else {
error = CSS_INVALID;
break;
@@ -1492,7 +1505,7 @@ css__parse_calc_product(css_language *c,
consumeWhitespace(vector, ctx);
- if (multiplication) {
+ if (operator == CALC_MULTIPLY) {
/* parse another value */
error = css__parse_calc_value(c, vector, ctx, result);
} else {
@@ -1502,8 +1515,9 @@ css__parse_calc_product(css_language *c,
break;
/* emit the multiplication/division operator */
- error = css__stylesheet_style_append(result,
- (css_code_t) (multiplication ? CALC_MULTIPLY : CALC_DIVIDE));
+ error = css_error_from_parserutils_error(
+ parserutils_buffer_append(result, (const uint8_t *)&operator, sizeof(operator))
+ );
} while (1);
/* We've fallen off, either we had an error or we're left with ')' */
return error;
@@ -1513,12 +1527,11 @@ css__parse_calc_product(css_language *c,
css_error
css__parse_calc_sum(css_language *c,
const parserutils_vector *vector, int *ctx,
- css_style *result)
+ parserutils_buffer *result)
{
css_error error = CSS_OK;
const css_token *token;
- bool addition;
-
+ css_code_t operator;
/* First parse a product */
error = css__parse_calc_product(c, vector, ctx, result);
@@ -1535,9 +1548,9 @@ css__parse_calc_sum(css_language *c,
} else if (tokenIsChar(token, ')'))
break;
else if (tokenIsChar(token, '+'))
- addition = true;
+ operator = CALC_ADD;
else if (tokenIsChar(token, '-'))
- addition = false;
+ operator = CALC_SUBTRACT;
else {
error = CSS_INVALID;
break;
@@ -1552,7 +1565,9 @@ css__parse_calc_sum(css_language *c,
break;
/* emit the addition/subtraction operator */
- error = css__stylesheet_style_append(result, (css_code_t) (addition ? CALC_ADD : CALC_SUBTRACT));
+ error = css_error_from_parserutils_error(
+ parserutils_buffer_append(result, (const uint8_t *)&operator, sizeof(operator))
+ );
} while (1);
/* We've fallen off, either we had an error or we're left with ')' */
return error;
@@ -1569,6 +1584,10 @@ css_error css__parse_calc(css_language *c,
const css_token *token;
css_error error = CSS_OK;
css_style *calc_style = NULL;
+ parserutils_buffer *calc_buffer = NULL;
+ lwc_string *calc_expr = NULL;
+ uint32_t expr_index = 0;
+ css_code_t finish = CALC_FINISH;
consumeWhitespace(vector, ctx);
@@ -1578,6 +1597,12 @@ css_error css__parse_calc(css_language *c,
return CSS_INVALID;
}
+ if (parserutils_buffer_create(&calc_buffer) != PARSERUTILS_OK) {
+ /* Since &calc_buffer is valid, the only error case is NONMEM */
+ *ctx = orig_ctx;
+ return CSS_NOMEM;
+ }
+
error = css__stylesheet_style_create(c->sheet, &calc_style);
if (error != CSS_OK)
goto cleanup;
@@ -1585,12 +1610,12 @@ css_error css__parse_calc(css_language *c,
error = css__stylesheet_style_append(calc_style, property);
if (error != CSS_OK)
goto cleanup;
-
+
error = css__stylesheet_style_append(calc_style, (css_code_t) unit);
if (error != CSS_OK)
goto cleanup;
- error = css__parse_calc_sum(c, vector, ctx, calc_style);
+ error = css__parse_calc_sum(c, vector, ctx, calc_buffer);
if (error != CSS_OK)
goto cleanup;
@@ -1602,17 +1627,35 @@ css_error css__parse_calc(css_language *c,
goto cleanup;
}
+ /* Append the indicator that the calc is finished */
+ error = css_error_from_parserutils_error(
+ parserutils_buffer_append(calc_buffer, (const uint8_t *)&finish, sizeof(finish))
+ );
+ if (error != CSS_OK)
+ goto cleanup;
+
/* Swallow that close paren */
parserutils_vector_iterate(vector, ctx);
- /* Append the indicator that the calc is finished */
- error = css__stylesheet_style_append(calc_style, (css_code_t) CALC_FINISH);
+ /* Create the lwc string representing the calculation and store it in */
+ error = css_error_from_lwc_error(
+ lwc_intern_string((const char *)calc_buffer->data, calc_buffer->length, &calc_expr)
+ );
if (error != CSS_OK)
goto cleanup;
+ /* This always takes ownership of calc_expr, so we should not use after this */
+ error = css__stylesheet_string_add(calc_style->sheet, calc_expr, &expr_index);
+ if (error != CSS_OK)
+ goto cleanup;
+
+ css__stylesheet_style_append(calc_style, (css_code_t) expr_index);
+
error = css__stylesheet_merge_style(result, calc_style);
cleanup:
css__stylesheet_style_destroy(calc_style);
+ parserutils_buffer_destroy(calc_buffer);
+ /* We do not need to clean up calc_expr, it will never leak */
if (error != CSS_OK) {
*ctx = orig_ctx;
}
diff --git a/test/dump.h b/test/dump.h
index a1fdd1f..eac0a9f 100644
--- a/test/dump.h
+++ b/test/dump.h
@@ -803,15 +803,23 @@ void dump_bytecode(css_style *style, char **ptr, uint32_t depth)
} else if (getFlagValue(opv) == FLAG_VALUE_UNSET) {
*ptr += sprintf(*ptr, "unset");
} else if (isCalc(opv)) {
+ lwc_string *calc_expr = NULL;
+ const uint8_t *codeptr = NULL;
+ css_code_t calc_opcode;
+ uint32_t unit, snum;
/* First entry is a unit */
- uint32_t unit = *((uint32_t *)bytecode);
+ unit = *((uint32_t *)bytecode);
ADVANCE(sizeof(unit));
+ /* Second entry is an lwc_string of the expression */
+ snum = *((uint32_t *)bytecode);
+ ADVANCE(sizeof(snum));
+ css__stylesheet_string_get(style->sheet, snum, &calc_expr);
+ codeptr = (const uint8_t *)lwc_string_data(calc_expr);
*ptr += sprintf(*ptr, "/* -> ");
dump_unit(0, unit, ptr);
*ptr += sprintf(*ptr, " */ calc(");
- css_code_t calc_opcode;
- while ((calc_opcode = *((css_code_t *)bytecode)) != CALC_FINISH) {
- ADVANCE(sizeof(calc_opcode));
+ while ((calc_opcode = *((css_code_t *)codeptr)) != CALC_FINISH) {
+ codeptr += sizeof(calc_opcode);
switch (calc_opcode) {
case CALC_ADD:
*ptr += sprintf(*ptr, "+ ");
@@ -826,17 +834,17 @@ void dump_bytecode(css_style *style, char **ptr, uint32_t depth)
*ptr += sprintf(*ptr, "/ ");
break;
case CALC_PUSH_VALUE: {
- css_fixed num = *((css_fixed *)bytecode);
- ADVANCE(sizeof(num));
- uint32_t unit = *((uint32_t *)bytecode);
- ADVANCE(sizeof(unit));
+ css_fixed num = *((css_fixed *)codeptr);
+ codeptr += sizeof(num);
+ uint32_t unit = *((uint32_t *)codeptr);
+ codeptr += sizeof(unit);
dump_unit(num, unit, ptr);
*ptr += sprintf(*ptr, " ");
break;
}
case CALC_PUSH_NUMBER: {
- css_fixed num = *((css_fixed *)bytecode);
- ADVANCE(sizeof(num));
+ css_fixed num = *((css_fixed *)codeptr);
+ codeptr += sizeof(num);
dump_number(num, ptr);
*ptr += sprintf(*ptr, " ");
break;
@@ -846,7 +854,6 @@ void dump_bytecode(css_style *style, char **ptr, uint32_t depth)
break;
}
}
- ADVANCE(sizeof(calc_opcode));
*ptr += sprintf(*ptr, "=)");
} else {
value = getValue(opv);
commitdiff http://git.netsurf-browser.org/libcss.git/commit/?id=6a361f59639e23e50f0d...
commit 6a361f59639e23e50f0dbd18d6c28ca330e288cb
Author: Michael Drake <tlsa(a)netsurf-browser.org>
Commit: Michael Drake <tlsa(a)netsurf-browser.org>
bytecode: Use define for calc value identifier
diff --git a/src/bytecode/bytecode.h b/src/bytecode/bytecode.h
index e845170..d799194 100644
--- a/src/bytecode/bytecode.h
+++ b/src/bytecode/bytecode.h
@@ -14,6 +14,8 @@
#include <libcss/types.h>
#include <libcss/properties.h>
+#include "bytecode/opcodes.h"
+
typedef uint32_t css_code_t;
typedef enum css_properties_e opcode_t;
@@ -139,8 +141,7 @@ static inline bool isInherit(css_code_t OPV)
static inline bool isCalc(css_code_t OPV)
{
- /* Note, this relies on all _CALC values being the same ultimately */
- return getValue(OPV) == 0x7f;
+ return getValue(OPV) == VALUE_IS_CALC;
}
#endif
diff --git a/src/bytecode/opcodes.h b/src/bytecode/opcodes.h
index 0ff67bb..da420e1 100644
--- a/src/bytecode/opcodes.h
+++ b/src/bytecode/opcodes.h
@@ -10,6 +10,8 @@
#include <inttypes.h>
+#define VALUE_IS_CALC 0x007f
+
enum op_align_content {
ALIGN_CONTENT_STRETCH = 0x0000,
ALIGN_CONTENT_FLEX_START = 0x0001,
@@ -119,7 +121,7 @@ enum op_border_style {
};
enum op_border_width {
- BORDER_WIDTH_CALC = 0x007f,
+ BORDER_WIDTH_CALC = VALUE_IS_CALC,
BORDER_WIDTH_SET = 0x0080,
BORDER_WIDTH_THIN = 0x0000,
BORDER_WIDTH_MEDIUM = 0x0001,
@@ -127,7 +129,7 @@ enum op_border_width {
};
enum op_bottom {
- BOTTOM_CALC = 0x007f,
+ BOTTOM_CALC = VALUE_IS_CALC,
BOTTOM_SET = 0x0080,
BOTTOM_AUTO = 0x0000
};
@@ -200,7 +202,7 @@ enum op_color {
enum op_column_count {
COLUMN_COUNT_AUTO = 0x0000,
- COLUMN_COUNT_CALC = 0x007f,
+ COLUMN_COUNT_CALC = VALUE_IS_CALC,
COLUMN_COUNT_SET = 0x0080
};
@@ -211,7 +213,7 @@ enum op_column_fill {
enum op_column_gap {
COLUMN_GAP_NORMAL = 0x0000,
- COLUMN_GAP_CALC = 0x007f,
+ COLUMN_GAP_CALC = VALUE_IS_CALC,
COLUMN_GAP_SET = 0x0080
};
@@ -249,7 +251,7 @@ enum op_column_span {
enum op_column_width {
COLUMN_WIDTH_AUTO = 0x0000,
- COLUMN_WIDTH_CALC = 0x007f,
+ COLUMN_WIDTH_CALC = VALUE_IS_CALC,
COLUMN_WIDTH_SET = 0x0080
};
@@ -360,7 +362,7 @@ enum op_empty_cells {
enum op_flex_basis {
FLEX_BASIS_AUTO = 0x0000,
FLEX_BASIS_CONTENT = 0x0001,
- FLEX_BASIS_CALC = 0x007f,
+ FLEX_BASIS_CALC = VALUE_IS_CALC,
FLEX_BASIS_SET = 0x0080
};
@@ -372,12 +374,12 @@ enum op_flex_direction {
};
enum op_flex_grow {
- FLEX_GROW_CALC = 0x007f,
+ FLEX_GROW_CALC = VALUE_IS_CALC,
FLEX_GROW_SET = 0x0080
};
enum op_flex_shrink {
- FLEX_SHRINK_CALC = 0x007f,
+ FLEX_SHRINK_CALC = VALUE_IS_CALC,
FLEX_SHRINK_SET = 0x0080
};
@@ -407,7 +409,7 @@ enum op_font_family {
};
enum op_font_size {
- FONT_SIZE_CALC = 0x007f,
+ FONT_SIZE_CALC = VALUE_IS_CALC,
FONT_SIZE_DIMENSION = 0x0080,
FONT_SIZE_XX_SMALL = 0x0000,
@@ -449,7 +451,7 @@ enum op_font_weight {
};
enum op_height {
- HEIGHT_CALC = 0x007f,
+ HEIGHT_CALC = VALUE_IS_CALC,
HEIGHT_SET = 0x0080,
HEIGHT_AUTO = 0x0000
};
@@ -470,13 +472,13 @@ enum op_left {
};
enum op_letter_spacing {
- LETTER_SPACING_CALC = 0x007f,
+ LETTER_SPACING_CALC = VALUE_IS_CALC,
LETTER_SPACING_SET = 0x0080,
LETTER_SPACING_NORMAL = 0x0000
};
enum op_line_height {
- LINE_HEIGHT_CALC = 0x007f,
+ LINE_HEIGHT_CALC = VALUE_IS_CALC,
LINE_HEIGHT_NUMBER = 0x0080,
LINE_HEIGHT_DIMENSION = 0x0081,
LINE_HEIGHT_NORMAL = 0x0000
@@ -548,31 +550,31 @@ enum op_list_style_type {
};
enum op_margin {
- MARGIN_CALC = 0x007f,
+ MARGIN_CALC = VALUE_IS_CALC,
MARGIN_SET = 0x0080,
MARGIN_AUTO = 0x0000
};
enum op_max_height {
- MAX_HEIGHT_CALC = 0x007f,
+ MAX_HEIGHT_CALC = VALUE_IS_CALC,
MAX_HEIGHT_SET = 0x0080,
MAX_HEIGHT_NONE = 0x0000
};
enum op_max_width {
- MAX_WIDTH_CALC = 0x007f,
+ MAX_WIDTH_CALC = VALUE_IS_CALC,
MAX_WIDTH_SET = 0x0080,
MAX_WIDTH_NONE = 0x0000
};
enum op_min_height {
- MIN_HEIGHT_CALC = 0x007f,
+ MIN_HEIGHT_CALC = VALUE_IS_CALC,
MIN_HEIGHT_SET = 0x0080,
MIN_HEIGHT_AUTO = 0x0000
};
enum op_min_width {
- MIN_WIDTH_CALC = 0x007f,
+ MIN_WIDTH_CALC = VALUE_IS_CALC,
MIN_WIDTH_SET = 0x0080,
MIN_WIDTH_AUTO = 0x0000
};
@@ -582,12 +584,12 @@ enum op_opacity {
};
enum op_order {
- ORDER_CALC = 0x007f,
+ ORDER_CALC = VALUE_IS_CALC,
ORDER_SET = 0x0080
};
enum op_orphans {
- ORPHANS_CALC = 0x007f,
+ ORPHANS_CALC = VALUE_IS_CALC,
ORPHANS_SET = 0x0080
};
@@ -626,7 +628,7 @@ enum op_overflow {
};
enum op_padding {
- PADDING_CALC = 0x007f,
+ PADDING_CALC = VALUE_IS_CALC,
PADDING_SET = 0x0080
};
@@ -652,22 +654,22 @@ enum op_page_break_inside {
};
enum op_pause_after {
- PAUSE_AFTER_CALC = 0x007f,
+ PAUSE_AFTER_CALC = VALUE_IS_CALC,
PAUSE_AFTER_SET = 0x0080
};
enum op_pause_before {
- PAUSE_BEFORE_CALC = 0x007f,
+ PAUSE_BEFORE_CALC = VALUE_IS_CALC,
PAUSE_BEFORE_SET = 0x0080
};
enum op_pitch_range {
- PITCH_RANGE_CALC = 0x007f,
+ PITCH_RANGE_CALC = VALUE_IS_CALC,
PITCH_RANGE_SET = 0x0080
};
enum op_pitch {
- PITCH_CALC = 0x007f,
+ PITCH_CALC = VALUE_IS_CALC,
PITCH_FREQUENCY = 0x0080,
PITCH_X_LOW = 0x0000,
@@ -702,7 +704,7 @@ enum op_quotes {
};
enum op_richness {
- RICHNESS_CALC = 0x007f,
+ RICHNESS_CALC = VALUE_IS_CALC,
RICHNESS_SET = 0x0080
};
@@ -733,7 +735,7 @@ enum op_speak {
};
enum op_speech_rate {
- SPEECH_RATE_CALC = 0x007f,
+ SPEECH_RATE_CALC = VALUE_IS_CALC,
SPEECH_RATE_SET = 0x0080,
SPEECH_RATE_X_SLOW = 0x0000,
@@ -746,7 +748,7 @@ enum op_speech_rate {
};
enum op_stress {
- STRESS_CALC = 0x007f,
+ STRESS_CALC = VALUE_IS_CALC,
STRESS_SET = 0x0080
};
@@ -775,7 +777,7 @@ enum op_text_decoration {
};
enum op_text_indent {
- TEXT_INDENT_CALC = 0x007f,
+ TEXT_INDENT_CALC = VALUE_IS_CALC,
TEXT_INDENT_SET = 0x0080
};
@@ -799,7 +801,7 @@ enum op_unicode_bidi {
};
enum op_vertical_align {
- VERTICAL_ALIGN_CALC = 0x007f,
+ VERTICAL_ALIGN_CALC = VALUE_IS_CALC,
VERTICAL_ALIGN_SET = 0x0080,
VERTICAL_ALIGN_BASELINE = 0x0000,
@@ -830,7 +832,7 @@ enum op_voice_family {
};
enum op_volume {
- VOLUME_CALC = 0x007f,
+ VOLUME_CALC = VALUE_IS_CALC,
VOLUME_NUMBER = 0x0080,
VOLUME_DIMENSION = 0x0081,
@@ -851,19 +853,19 @@ enum op_white_space {
};
enum op_widows {
- WIDOWS_CALC = 0x007f,
+ WIDOWS_CALC = VALUE_IS_CALC,
WIDOWS_SET = 0x0080
};
enum op_width {
- WIDTH_CALC = 0x007f,
+ WIDTH_CALC = VALUE_IS_CALC,
WIDTH_SET = 0x0080,
WIDTH_AUTO = 0x0000
};
enum op_word_spacing {
- WORD_SPACING_CALC = 0x007f,
+ WORD_SPACING_CALC = VALUE_IS_CALC,
WORD_SPACING_SET = 0x0080,
WORD_SPACING_NORMAL = 0x0000
@@ -876,7 +878,7 @@ enum op_writing_mode {
};
enum op_z_index {
- Z_INDEX_CALC = 0x007f,
+ Z_INDEX_CALC = VALUE_IS_CALC,
Z_INDEX_SET = 0x0080,
Z_INDEX_AUTO = 0x0000
commitdiff http://git.netsurf-browser.org/libcss.git/commit/?id=870585f3cd0320e5813a...
commit 870585f3cd0320e5813a39bec5827cf76f4102b5
Author: Daniel Silverstone <dsilvers(a)netsurf-browser.org>
Commit: Michael Drake <tlsa(a)netsurf-browser.org>
parse: Tests and fixes for calc() parser.
Co-authored-by: Michael Drake <michael.drake(a)netsurf-browser.org>
diff --git a/src/bytecode/bytecode.h b/src/bytecode/bytecode.h
index 7c21d50..e845170 100644
--- a/src/bytecode/bytecode.h
+++ b/src/bytecode/bytecode.h
@@ -35,12 +35,13 @@ enum flag {
};
enum calc_opcodes {
- CALC_PUSH_VALUE = 'V',
- CALC_ADD = '+',
- CALC_SUBTRACT = '-',
- CALC_MULTIPLY = '*',
- CALC_DIVIDE = '/',
- CALC_FINISH = '=',
+ CALC_PUSH_NUMBER = 'N',
+ CALC_PUSH_VALUE = 'V',
+ CALC_ADD = '+',
+ CALC_SUBTRACT = '-',
+ CALC_MULTIPLY = '*',
+ CALC_DIVIDE = '/',
+ CALC_FINISH = '=',
};
typedef enum unit {
diff --git a/src/parse/properties/utils.c b/src/parse/properties/utils.c
index 7f9d9d2..fe5ee6b 100644
--- a/src/parse/properties/utils.c
+++ b/src/parse/properties/utils.c
@@ -1365,6 +1365,31 @@ css__parse_calc_sum(css_language *c,
css_style *result);
static css_error
+css__parse_calc_number(
+ const parserutils_vector *vector, int *ctx,
+ css_style *result)
+{
+ const css_token *token;
+ css_fixed num;
+ size_t consumed;
+
+ /* Consume the number token */
+ token = parserutils_vector_iterate(vector, ctx);
+ if (token == NULL || token->type != CSS_TOKEN_NUMBER) {
+ return CSS_INVALID;
+ }
+
+ num = css__number_from_string((const uint8_t *)lwc_string_data(token->idata),
+ lwc_string_length(token->idata), false, &consumed);
+
+ if (consumed != lwc_string_length(token->idata)) {
+ return CSS_INVALID;
+ }
+
+ return css__stylesheet_style_vappend(result, 2, (css_code_t) CALC_PUSH_NUMBER, (css_code_t)num);
+}
+
+static css_error
css__parse_calc_value(css_language *c,
const parserutils_vector *vector, int *ctx,
css_style *result)
@@ -1377,6 +1402,7 @@ css__parse_calc_value(css_language *c,
token = parserutils_vector_peek(vector, *ctx);
if (tokenIsChar(token, '(')) {
parserutils_vector_iterate(vector, ctx);
+ consumeWhitespace(vector, ctx);
error = css__parse_calc_sum(c, vector, ctx, result);
if (error != CSS_OK) {
return error;
@@ -1389,7 +1415,12 @@ css__parse_calc_value(css_language *c,
/* Consume the close-paren to complete this value */
parserutils_vector_iterate(vector, ctx);
} else switch (token->type) {
- case CSS_TOKEN_NUMBER: /* Fall through */
+ case CSS_TOKEN_NUMBER:
+ error = css__parse_calc_number(vector, ctx, result);
+ if (error != CSS_OK) {
+ return error;
+ }
+ break;
case CSS_TOKEN_DIMENSION: /* Fall through */
case CSS_TOKEN_PERCENTAGE:
{
@@ -1412,11 +1443,7 @@ css__parse_calc_value(css_language *c,
break;
}
- token = parserutils_vector_peek(vector, *ctx);
- while (token->type == CSS_TOKEN_S) {
- parserutils_vector_iterate(vector, ctx);
- token = parserutils_vector_peek(vector, *ctx);
- }
+ consumeWhitespace(vector, ctx);
return error;
}
@@ -1462,14 +1489,15 @@ css__parse_calc_product(css_language *c,
}
/* Consume that * or / now */
parserutils_vector_iterate(vector, ctx);
- token = parserutils_vector_peek(vector, *ctx);
- while (token->type == CSS_TOKEN_S) {
- parserutils_vector_iterate(vector, ctx);
- token = parserutils_vector_peek(vector, *ctx);
+ consumeWhitespace(vector, ctx);
+
+ if (multiplication) {
+ /* parse another value */
+ error = css__parse_calc_value(c, vector, ctx, result);
+ } else {
+ error = css__parse_calc_number(vector, ctx, result);
}
- /* parse another value */
- error = css__parse_calc_value(c, vector, ctx, result);
if (error != CSS_OK)
break;
@@ -1516,12 +1544,7 @@ css__parse_calc_sum(css_language *c,
}
/* Consume that + or - now */
parserutils_vector_iterate(vector, ctx);
- token = parserutils_vector_peek(vector, *ctx);
-
- while (token->type == CSS_TOKEN_S) {
- parserutils_vector_iterate(vector, ctx);
- token = parserutils_vector_peek(vector, *ctx);
- }
+ consumeWhitespace(vector, ctx);
/* parse another product */
error = css__parse_calc_product(c, vector, ctx, result);
@@ -1547,17 +1570,14 @@ css_error css__parse_calc(css_language *c,
css_error error = CSS_OK;
css_style *calc_style = NULL;
+ consumeWhitespace(vector, ctx);
+
token = parserutils_vector_peek(vector, *ctx);
if (token == NULL) {
*ctx = orig_ctx;
return CSS_INVALID;
}
- while (token->type == CSS_TOKEN_S) {
- parserutils_vector_iterate(vector, ctx);
- token = parserutils_vector_peek(vector, *ctx);
- }
-
error = css__stylesheet_style_create(c->sheet, &calc_style);
if (error != CSS_OK)
goto cleanup;
@@ -1574,11 +1594,8 @@ css_error css__parse_calc(css_language *c,
if (error != CSS_OK)
goto cleanup;
+ consumeWhitespace(vector, ctx);
token = parserutils_vector_peek(vector, *ctx);
- while (token->type == CSS_TOKEN_S) {
- parserutils_vector_iterate(vector, ctx);
- token = parserutils_vector_peek(vector, *ctx);
- }
if (!tokenIsChar(token, ')')) {
/* If we don't get a close-paren, give up now */
error = CSS_INVALID;
diff --git a/test/data/parse2/calc.dat b/test/data/parse2/calc.dat
index 95abf6c..e9d176d 100644
--- a/test/data/parse2/calc.dat
+++ b/test/data/parse2/calc.dat
@@ -4,4 +4,154 @@
#expected
| *
| height: /* -> 0px */ calc(50vh 10px + =)
-#reset
\ No newline at end of file
+#reset
+
+#data
+* { line-height: calc(50vh + 10px)}
+#errors
+#expected
+| *
+| line-height: /* -> 0any */ calc(50vh 10px + =)
+#reset
+
+#data
+* { line-height: calc( / 2)}
+#errors
+#expected
+| *
+#reset
+
+#data
+* { line-height: calc( + 2)}
+#errors
+#expected
+| *
+#reset
+
+#data
+* { line-height: calc(2 / 2px)}
+#errors
+#expected
+| *
+#reset
+
+#data
+* { z-index: calc(50vh + 10px)}
+#errors
+#expected
+| *
+| z-index: /* -> 0number */ calc(50vh 10px + =)
+#reset
+
+#data
+* { z-index: calc(2 * 3)}
+#errors
+#expected
+| *
+| z-index: /* -> 0number */ calc(2 3 * =)
+#reset
+
+#data
+* { z-index: calc(50vh + 10px / 9)}
+#errors
+#expected
+| *
+| z-index: /* -> 0number */ calc(50vh 10px 9 / + =)
+#reset
+
+#data
+* { z-index: calc(1 + 2 + 3 + 4)}
+#errors
+#expected
+| *
+| z-index: /* -> 0number */ calc(1 2 + 3 + 4 + =)
+#reset
+
+#data
+* { z-index: calc(1 + 2 * 3 + 4)}
+#errors
+#expected
+| *
+| z-index: /* -> 0number */ calc(1 2 3 * + 4 + =)
+#reset
+
+#data
+* { z-index: calc((1 + 2) * (3 + 4))}
+#errors
+#expected
+| *
+| z-index: /* -> 0number */ calc(1 2 + 3 4 + * =)
+#reset
+
+#data
+* { z-index: calc(1 + 2}
+#errors
+#expected
+| *
+#reset
+
+#data
+* { z-index: calc(}
+#errors
+#expected
+| *
+#reset
+
+#data
+* { z-index: calc}
+#errors
+#expected
+| *
+#reset
+
+#data
+* { z-index: calc (1 + 2)}
+#errors
+#expected
+| *
+#reset
+
+#data
+* { z-index: calc(1)}
+#errors
+#expected
+| *
+| z-index: /* -> 0number */ calc(1 =)
+#reset
+
+#data
+* { z-index: calc()}
+#errors
+#expected
+| *
+#reset
+
+#data
+* { z-index: calc((1 + 2)}
+#errors
+#expected
+| *
+#reset
+
+#data
+* { z-index: calc(((1 + 2)))}
+#errors
+#expected
+| *
+| z-index: /* -> 0number */ calc(1 2 + =)
+#reset
+
+#data
+* { z-index: calc( ( ( 1 + 2 ) ) )}
+#errors
+#expected
+| *
+| z-index: /* -> 0number */ calc(1 2 + =)
+#reset
+
+#data
+* { z-index: calc( ( 3 / ( 1 + 2 ) ) )}
+#errors
+#expected
+| *
+#reset
diff --git a/test/dump.h b/test/dump.h
index 054194a..a1fdd1f 100644
--- a/test/dump.h
+++ b/test/dump.h
@@ -834,6 +834,13 @@ void dump_bytecode(css_style *style, char **ptr, uint32_t depth)
*ptr += sprintf(*ptr, " ");
break;
}
+ case CALC_PUSH_NUMBER: {
+ css_fixed num = *((css_fixed *)bytecode);
+ ADVANCE(sizeof(num));
+ dump_number(num, ptr);
+ *ptr += sprintf(*ptr, " ");
+ break;
+ }
default:
*ptr += sprintf(*ptr, "??%d ", calc_opcode);
break;
commitdiff http://git.netsurf-browser.org/libcss.git/commit/?id=93d6d6d2b7480bbbc0b1...
commit 93d6d6d2b7480bbbc0b13b69e151870b4cbfb465
Author: Daniel Silverstone <dsilvers(a)netsurf-browser.org>
Commit: Michael Drake <tlsa(a)netsurf-browser.org>
parse: calc() test and fixup.
diff --git a/src/bytecode/bytecode.h b/src/bytecode/bytecode.h
index 92040b4..7c21d50 100644
--- a/src/bytecode/bytecode.h
+++ b/src/bytecode/bytecode.h
@@ -34,6 +34,14 @@ enum flag {
FLAG_UNSET = (FLAG_VALUE_UNSET << 1),
};
+enum calc_opcodes {
+ CALC_PUSH_VALUE = 'V',
+ CALC_ADD = '+',
+ CALC_SUBTRACT = '-',
+ CALC_MULTIPLY = '*',
+ CALC_DIVIDE = '/',
+ CALC_FINISH = '=',
+};
typedef enum unit {
UNIT_LENGTH = (1u << 8),
@@ -128,6 +136,12 @@ static inline bool isInherit(css_code_t OPV)
return getFlagValue(OPV) == FLAG_VALUE_INHERIT;
}
+static inline bool isCalc(css_code_t OPV)
+{
+ /* Note, this relies on all _CALC values being the same ultimately */
+ return getValue(OPV) == 0x7f;
+}
+
#endif
diff --git a/src/parse/properties/css_property_parser_gen.c b/src/parse/properties/css_property_parser_gen.c
index 1260f28..622ce16 100644
--- a/src/parse/properties/css_property_parser_gen.c
+++ b/src/parse/properties/css_property_parser_gen.c
@@ -330,7 +330,7 @@ void output_calc(FILE *outputf, struct keyval *parseid, struct keyval_list *kvli
kind = ckv->key;
fprintf(outputf,
- "if ((token->type == CSS_TOKEN_IDENT) && "
+ "if ((token->type == CSS_TOKEN_FUNCTION) && "
"(lwc_string_caseless_isequal(token->idata, c->strings[CALC], &match) == lwc_error_ok && match))"
" {\n"
"\t\terror = css__parse_calc(c, vector, ctx, result, buildOPV(%s, 0, %s), %s);\n"
diff --git a/src/parse/properties/utils.c b/src/parse/properties/utils.c
index cce9717..7f9d9d2 100644
--- a/src/parse/properties/utils.c
+++ b/src/parse/properties/utils.c
@@ -1373,8 +1373,10 @@ css__parse_calc_value(css_language *c,
int orig_ctx = *ctx;
const css_token *token;
- token = parserutils_vector_iterate(vector, ctx);
+ /* On entry, we are already pointing at the value to parse, so peek it */
+ token = parserutils_vector_peek(vector, *ctx);
if (tokenIsChar(token, '(')) {
+ parserutils_vector_iterate(vector, ctx);
error = css__parse_calc_sum(c, vector, ctx, result);
if (error != CSS_OK) {
return error;
@@ -1384,7 +1386,8 @@ css__parse_calc_value(css_language *c,
if (!tokenIsChar(token, ')')) {
return CSS_INVALID;
}
-
+ /* Consume the close-paren to complete this value */
+ parserutils_vector_iterate(vector, ctx);
} else switch (token->type) {
case CSS_TOKEN_NUMBER: /* Fall through */
case CSS_TOKEN_DIMENSION: /* Fall through */
@@ -1400,7 +1403,7 @@ css__parse_calc_value(css_language *c,
return error;
}
- error = css__stylesheet_style_vappend(result, 3, (css_code_t) 'V', length, unit);
+ error = css__stylesheet_style_vappend(result, 3, (css_code_t) CALC_PUSH_VALUE, length, unit);
}
break;
@@ -1409,6 +1412,11 @@ css__parse_calc_value(css_language *c,
break;
}
+ token = parserutils_vector_peek(vector, *ctx);
+ while (token->type == CSS_TOKEN_S) {
+ parserutils_vector_iterate(vector, ctx);
+ token = parserutils_vector_peek(vector, *ctx);
+ }
return error;
}
@@ -1439,7 +1447,10 @@ css__parse_calc_product(css_language *c,
if (token == NULL) {
error = CSS_INVALID;
break;
- } else if (tokenIsChar(token, ')'))
+ } else if (
+ tokenIsChar(token, ')') ||
+ tokenIsChar(token, '+') ||
+ tokenIsChar(token, '-'))
break;
else if (tokenIsChar(token, '*'))
multiplication = true;
@@ -1450,15 +1461,21 @@ css__parse_calc_product(css_language *c,
break;
}
/* Consume that * or / now */
- token = parserutils_vector_iterate(vector, ctx);
+ parserutils_vector_iterate(vector, ctx);
+ token = parserutils_vector_peek(vector, *ctx);
+ while (token->type == CSS_TOKEN_S) {
+ parserutils_vector_iterate(vector, ctx);
+ token = parserutils_vector_peek(vector, *ctx);
+ }
/* parse another value */
error = css__parse_calc_value(c, vector, ctx, result);
if (error != CSS_OK)
break;
/* emit the multiplication/division operator */
- error = css__stylesheet_style_append(result, (css_code_t) (multiplication ? '*' : '/'));
+ error = css__stylesheet_style_append(result,
+ (css_code_t) (multiplication ? CALC_MULTIPLY : CALC_DIVIDE));
} while (1);
/* We've fallen off, either we had an error or we're left with ')' */
return error;
@@ -1498,7 +1515,13 @@ css__parse_calc_sum(css_language *c,
break;
}
/* Consume that + or - now */
- token = parserutils_vector_iterate(vector, ctx);
+ parserutils_vector_iterate(vector, ctx);
+ token = parserutils_vector_peek(vector, *ctx);
+
+ while (token->type == CSS_TOKEN_S) {
+ parserutils_vector_iterate(vector, ctx);
+ token = parserutils_vector_peek(vector, *ctx);
+ }
/* parse another product */
error = css__parse_calc_product(c, vector, ctx, result);
@@ -1506,7 +1529,7 @@ css__parse_calc_sum(css_language *c,
break;
/* emit the addition/subtraction operator */
- error = css__stylesheet_style_append(result, (css_code_t) (addition ? '+' : '-'));
+ error = css__stylesheet_style_append(result, (css_code_t) (addition ? CALC_ADD : CALC_SUBTRACT));
} while (1);
/* We've fallen off, either we had an error or we're left with ')' */
return error;
@@ -1524,16 +1547,15 @@ css_error css__parse_calc(css_language *c,
css_error error = CSS_OK;
css_style *calc_style = NULL;
- token = parserutils_vector_iterate(vector, ctx);
+ token = parserutils_vector_peek(vector, *ctx);
if (token == NULL) {
*ctx = orig_ctx;
return CSS_INVALID;
}
- if (!tokenIsChar(token, '(')) {
- /* If we don't get an open-paren, give up now */
- *ctx = orig_ctx;
- return CSS_INVALID;
+ while (token->type == CSS_TOKEN_S) {
+ parserutils_vector_iterate(vector, ctx);
+ token = parserutils_vector_peek(vector, *ctx);
}
error = css__stylesheet_style_create(c->sheet, &calc_style);
@@ -1545,27 +1567,33 @@ css_error css__parse_calc(css_language *c,
goto cleanup;
error = css__stylesheet_style_append(calc_style, (css_code_t) unit);
+ if (error != CSS_OK)
+ goto cleanup;
error = css__parse_calc_sum(c, vector, ctx, calc_style);
if (error != CSS_OK)
goto cleanup;
- token = parserutils_vector_iterate(vector, ctx);
+ token = parserutils_vector_peek(vector, *ctx);
+ while (token->type == CSS_TOKEN_S) {
+ parserutils_vector_iterate(vector, ctx);
+ token = parserutils_vector_peek(vector, *ctx);
+ }
if (!tokenIsChar(token, ')')) {
/* If we don't get a close-paren, give up now */
error = CSS_INVALID;
goto cleanup;
}
+ /* Swallow that close paren */
+ parserutils_vector_iterate(vector, ctx);
+
/* Append the indicator that the calc is finished */
- error = css__stylesheet_style_append(calc_style, (css_code_t) '=');
+ error = css__stylesheet_style_append(calc_style, (css_code_t) CALC_FINISH);
if (error != CSS_OK)
goto cleanup;
- /* TODO: Once we're OK to do so, merge the style */
- (void)result;
- /* error = css__stylesheet_style_merge_style(result, calc_style); */
-
+ error = css__stylesheet_merge_style(result, calc_style);
cleanup:
css__stylesheet_style_destroy(calc_style);
if (error != CSS_OK) {
diff --git a/test/data/parse2/INDEX b/test/data/parse2/INDEX
index e4a369c..7bc4295 100644
--- a/test/data/parse2/INDEX
+++ b/test/data/parse2/INDEX
@@ -24,3 +24,4 @@ multicol.dat Multi-column layout property tests
flexbox.dat Flexbox properties and shorthands tests
units.dat Length unit tests
dodgy-media-block.dat Media block with incomplete ruleset
+calc.dat calc() tests
diff --git a/test/data/parse2/calc.dat b/test/data/parse2/calc.dat
new file mode 100644
index 0000000..95abf6c
--- /dev/null
+++ b/test/data/parse2/calc.dat
@@ -0,0 +1,7 @@
+#data
+* { height: calc(50vh + 10px)}
+#errors
+#expected
+| *
+| height: /* -> 0px */ calc(50vh 10px + =)
+#reset
\ No newline at end of file
diff --git a/test/dump.h b/test/dump.h
index f585788..054194a 100644
--- a/test/dump.h
+++ b/test/dump.h
@@ -640,6 +640,12 @@ static void dump_unit(css_fixed val, uint32_t unit, char **ptr)
case UNIT_KHZ:
*ptr += sprintf(*ptr, "kHz");
break;
+ case UNIT_CALC_ANY:
+ *ptr += sprintf(*ptr, "any");
+ break;
+ case UNIT_CALC_NUMBER:
+ *ptr += sprintf(*ptr, "number");
+ break;
}
}
@@ -796,6 +802,45 @@ void dump_bytecode(css_style *style, char **ptr, uint32_t depth)
*ptr += sprintf(*ptr, "revert");
} else if (getFlagValue(opv) == FLAG_VALUE_UNSET) {
*ptr += sprintf(*ptr, "unset");
+ } else if (isCalc(opv)) {
+ /* First entry is a unit */
+ uint32_t unit = *((uint32_t *)bytecode);
+ ADVANCE(sizeof(unit));
+ *ptr += sprintf(*ptr, "/* -> ");
+ dump_unit(0, unit, ptr);
+ *ptr += sprintf(*ptr, " */ calc(");
+ css_code_t calc_opcode;
+ while ((calc_opcode = *((css_code_t *)bytecode)) != CALC_FINISH) {
+ ADVANCE(sizeof(calc_opcode));
+ switch (calc_opcode) {
+ case CALC_ADD:
+ *ptr += sprintf(*ptr, "+ ");
+ break;
+ case CALC_SUBTRACT:
+ *ptr += sprintf(*ptr, "- ");
+ break;
+ case CALC_MULTIPLY:
+ *ptr += sprintf(*ptr, "* ");
+ break;
+ case CALC_DIVIDE:
+ *ptr += sprintf(*ptr, "/ ");
+ break;
+ case CALC_PUSH_VALUE: {
+ css_fixed num = *((css_fixed *)bytecode);
+ ADVANCE(sizeof(num));
+ uint32_t unit = *((uint32_t *)bytecode);
+ ADVANCE(sizeof(unit));
+ dump_unit(num, unit, ptr);
+ *ptr += sprintf(*ptr, " ");
+ break;
+ }
+ default:
+ *ptr += sprintf(*ptr, "??%d ", calc_opcode);
+ break;
+ }
+ }
+ ADVANCE(sizeof(calc_opcode));
+ *ptr += sprintf(*ptr, "=)");
} else {
value = getValue(opv);
commitdiff http://git.netsurf-browser.org/libcss.git/commit/?id=88c8258aabef042da70e...
commit 88c8258aabef042da70e419141a8d8e198673225
Author: Michael Drake <Michael Drake tlsa(a)netsurf-browser.org>
Commit: Michael Drake <tlsa(a)netsurf-browser.org>
parse: Update parser generator to support calc() details.
Co-authored-by: Daniel Silverstone <dsilvers(a)netsurf-browser.org>
diff --git a/src/bytecode/bytecode.h b/src/bytecode/bytecode.h
index ccfdcac..92040b4 100644
--- a/src/bytecode/bytecode.h
+++ b/src/bytecode/bytecode.h
@@ -76,6 +76,10 @@ typedef enum unit {
UNIT_DPI = (1 << 13) + 0,
UNIT_DPCM = (1 << 13) + 1,
UNIT_DPPX = (1 << 13) + 2,
+
+ /* These are special only to the CALC bytecodes */
+ UNIT_CALC_ANY = (1 << 20),
+ UNIT_CALC_NUMBER = (1 << 20) + 1,
} unit;
typedef uint32_t colour;
diff --git a/src/bytecode/opcodes.h b/src/bytecode/opcodes.h
index 8bc05b4..0ff67bb 100644
--- a/src/bytecode/opcodes.h
+++ b/src/bytecode/opcodes.h
@@ -119,6 +119,7 @@ enum op_border_style {
};
enum op_border_width {
+ BORDER_WIDTH_CALC = 0x007f,
BORDER_WIDTH_SET = 0x0080,
BORDER_WIDTH_THIN = 0x0000,
BORDER_WIDTH_MEDIUM = 0x0001,
@@ -126,6 +127,7 @@ enum op_border_width {
};
enum op_bottom {
+ BOTTOM_CALC = 0x007f,
BOTTOM_SET = 0x0080,
BOTTOM_AUTO = 0x0000
};
@@ -198,6 +200,7 @@ enum op_color {
enum op_column_count {
COLUMN_COUNT_AUTO = 0x0000,
+ COLUMN_COUNT_CALC = 0x007f,
COLUMN_COUNT_SET = 0x0080
};
@@ -208,6 +211,7 @@ enum op_column_fill {
enum op_column_gap {
COLUMN_GAP_NORMAL = 0x0000,
+ COLUMN_GAP_CALC = 0x007f,
COLUMN_GAP_SET = 0x0080
};
@@ -231,6 +235,7 @@ enum op_column_rule_style {
};
enum op_column_rule_width {
+ COLUMN_RULE_WIDTH_CALC = BORDER_WIDTH_CALC,
COLUMN_RULE_WIDTH_SET = BORDER_WIDTH_SET,
COLUMN_RULE_WIDTH_THIN = BORDER_WIDTH_THIN,
COLUMN_RULE_WIDTH_MEDIUM = BORDER_WIDTH_MEDIUM,
@@ -244,6 +249,7 @@ enum op_column_span {
enum op_column_width {
COLUMN_WIDTH_AUTO = 0x0000,
+ COLUMN_WIDTH_CALC = 0x007f,
COLUMN_WIDTH_SET = 0x0080
};
@@ -354,6 +360,7 @@ enum op_empty_cells {
enum op_flex_basis {
FLEX_BASIS_AUTO = 0x0000,
FLEX_BASIS_CONTENT = 0x0001,
+ FLEX_BASIS_CALC = 0x007f,
FLEX_BASIS_SET = 0x0080
};
@@ -365,10 +372,12 @@ enum op_flex_direction {
};
enum op_flex_grow {
+ FLEX_GROW_CALC = 0x007f,
FLEX_GROW_SET = 0x0080
};
enum op_flex_shrink {
+ FLEX_SHRINK_CALC = 0x007f,
FLEX_SHRINK_SET = 0x0080
};
@@ -398,6 +407,7 @@ enum op_font_family {
};
enum op_font_size {
+ FONT_SIZE_CALC = 0x007f,
FONT_SIZE_DIMENSION = 0x0080,
FONT_SIZE_XX_SMALL = 0x0000,
@@ -439,6 +449,7 @@ enum op_font_weight {
};
enum op_height {
+ HEIGHT_CALC = 0x007f,
HEIGHT_SET = 0x0080,
HEIGHT_AUTO = 0x0000
};
@@ -453,16 +464,19 @@ enum op_justify_content {
};
enum op_left {
+ LEFT_CALC = BOTTOM_CALC,
LEFT_SET = BOTTOM_SET,
LEFT_AUTO = BOTTOM_AUTO
};
enum op_letter_spacing {
+ LETTER_SPACING_CALC = 0x007f,
LETTER_SPACING_SET = 0x0080,
LETTER_SPACING_NORMAL = 0x0000
};
enum op_line_height {
+ LINE_HEIGHT_CALC = 0x007f,
LINE_HEIGHT_NUMBER = 0x0080,
LINE_HEIGHT_DIMENSION = 0x0081,
LINE_HEIGHT_NORMAL = 0x0000
@@ -534,26 +548,31 @@ enum op_list_style_type {
};
enum op_margin {
+ MARGIN_CALC = 0x007f,
MARGIN_SET = 0x0080,
MARGIN_AUTO = 0x0000
};
enum op_max_height {
+ MAX_HEIGHT_CALC = 0x007f,
MAX_HEIGHT_SET = 0x0080,
MAX_HEIGHT_NONE = 0x0000
};
enum op_max_width {
+ MAX_WIDTH_CALC = 0x007f,
MAX_WIDTH_SET = 0x0080,
MAX_WIDTH_NONE = 0x0000
};
enum op_min_height {
+ MIN_HEIGHT_CALC = 0x007f,
MIN_HEIGHT_SET = 0x0080,
MIN_HEIGHT_AUTO = 0x0000
};
enum op_min_width {
+ MIN_WIDTH_CALC = 0x007f,
MIN_WIDTH_SET = 0x0080,
MIN_WIDTH_AUTO = 0x0000
};
@@ -563,10 +582,12 @@ enum op_opacity {
};
enum op_order {
+ ORDER_CALC = 0x007f,
ORDER_SET = 0x0080
};
enum op_orphans {
+ ORPHANS_CALC = 0x007f,
ORPHANS_SET = 0x0080
};
@@ -605,6 +626,7 @@ enum op_overflow {
};
enum op_padding {
+ PADDING_CALC = 0x007f,
PADDING_SET = 0x0080
};
@@ -630,18 +652,22 @@ enum op_page_break_inside {
};
enum op_pause_after {
+ PAUSE_AFTER_CALC = 0x007f,
PAUSE_AFTER_SET = 0x0080
};
enum op_pause_before {
+ PAUSE_BEFORE_CALC = 0x007f,
PAUSE_BEFORE_SET = 0x0080
};
enum op_pitch_range {
+ PITCH_RANGE_CALC = 0x007f,
PITCH_RANGE_SET = 0x0080
};
enum op_pitch {
+ PITCH_CALC = 0x007f,
PITCH_FREQUENCY = 0x0080,
PITCH_X_LOW = 0x0000,
@@ -676,6 +702,7 @@ enum op_quotes {
};
enum op_richness {
+ RICHNESS_CALC = 0x007f,
RICHNESS_SET = 0x0080
};
@@ -706,6 +733,7 @@ enum op_speak {
};
enum op_speech_rate {
+ SPEECH_RATE_CALC = 0x007f,
SPEECH_RATE_SET = 0x0080,
SPEECH_RATE_X_SLOW = 0x0000,
@@ -718,6 +746,7 @@ enum op_speech_rate {
};
enum op_stress {
+ STRESS_CALC = 0x007f,
STRESS_SET = 0x0080
};
@@ -746,6 +775,7 @@ enum op_text_decoration {
};
enum op_text_indent {
+ TEXT_INDENT_CALC = 0x007f,
TEXT_INDENT_SET = 0x0080
};
@@ -757,6 +787,7 @@ enum op_text_transform {
};
enum op_top {
+ TOP_CALC = BOTTOM_CALC,
TOP_SET = BOTTOM_SET,
TOP_AUTO = BOTTOM_AUTO
};
@@ -768,6 +799,7 @@ enum op_unicode_bidi {
};
enum op_vertical_align {
+ VERTICAL_ALIGN_CALC = 0x007f,
VERTICAL_ALIGN_SET = 0x0080,
VERTICAL_ALIGN_BASELINE = 0x0000,
@@ -798,6 +830,7 @@ enum op_voice_family {
};
enum op_volume {
+ VOLUME_CALC = 0x007f,
VOLUME_NUMBER = 0x0080,
VOLUME_DIMENSION = 0x0081,
@@ -818,16 +851,19 @@ enum op_white_space {
};
enum op_widows {
+ WIDOWS_CALC = 0x007f,
WIDOWS_SET = 0x0080
};
enum op_width {
+ WIDTH_CALC = 0x007f,
WIDTH_SET = 0x0080,
WIDTH_AUTO = 0x0000
};
enum op_word_spacing {
+ WORD_SPACING_CALC = 0x007f,
WORD_SPACING_SET = 0x0080,
WORD_SPACING_NORMAL = 0x0000
@@ -840,6 +876,7 @@ enum op_writing_mode {
};
enum op_z_index {
+ Z_INDEX_CALC = 0x007f,
Z_INDEX_SET = 0x0080,
Z_INDEX_AUTO = 0x0000
diff --git a/src/parse/properties/css_property_parser_gen.c b/src/parse/properties/css_property_parser_gen.c
index 100fba1..1260f28 100644
--- a/src/parse/properties/css_property_parser_gen.c
+++ b/src/parse/properties/css_property_parser_gen.c
@@ -19,6 +19,12 @@
* list_style_position:CSS_PROP_LIST_STYLE_POSITION IDENT:( INHERIT: INSIDE:0,LIST_STYLE_POSITION_INSIDE OUTSIDE:0,LIST_STYLE_POSITION_OUTSIDE IDENT:)
*/
+typedef enum {
+ CALC_ANY,
+ CALC_NUMBER,
+ CALC_UNIT,
+} calc_kind;
+
struct keyval {
char *key;
char *val;
@@ -311,21 +317,34 @@ void output_color(FILE *outputf, struct keyval *parseid, struct keyval_list *kvl
parseid->val);
}
-void output_length_unit(FILE *outputf, struct keyval *parseid, struct keyval_list *kvlist)
+void output_calc(FILE *outputf, struct keyval *parseid, struct keyval_list *kvlist)
{
struct keyval *ckv = kvlist->item[0];
- int ident_count;
+ const char *kind;
+
+ if (strcmp(ckv->key, "NUMBER") == 0)
+ kind = "UNIT_CALC_NUMBER";
+ else if (strcmp(ckv->key, "ANY") == 0)
+ kind = "UNIT_CALC_ANY";
+ else
+ kind = ckv->key;
fprintf(outputf,
"if ((token->type == CSS_TOKEN_IDENT) && "
"(lwc_string_caseless_isequal(token->idata, c->strings[CALC], &match) == lwc_error_ok && match))"
" {\n"
- "\t\terror = css__parse_calc(c, vector, ctx, result, buildOPV(%s, 0, %s /* _CALC */), %s);\n"
+ "\t\terror = css__parse_calc(c, vector, ctx, result, buildOPV(%s, 0, %s), %s);\n"
"\t} else ",
parseid->val,
ckv->val,
- ckv->key
+ kind
);
+}
+
+void output_length_unit(FILE *outputf, struct keyval *parseid, struct keyval_list *kvlist)
+{
+ struct keyval *ckv = kvlist->item[0];
+ int ident_count;
fprintf(outputf,
"{\n"
@@ -533,6 +552,7 @@ int main(int argc, char **argv)
struct keyval_list WRAP;
struct keyval_list NUMBER;
struct keyval_list COLOR;
+ struct keyval_list CALC;
if (argc < 2) {
@@ -565,6 +585,7 @@ int main(int argc, char **argv)
COLOR.count = 0;
LENGTH_UNIT.count = 0;
IDENT_LIST.count = 0;
+ CALC.count = 0;
curlist = &base;
@@ -580,7 +601,7 @@ int main(int argc, char **argv)
if (strcmp(rkv->key, "WRAP") == 0) {
WRAP.item[WRAP.count++] = rkv;
only_ident = false;
- } else if (strcmp(rkv->key, "NUMBER") == 0) {
+ } else if (curlist == &base && strcmp(rkv->key, "NUMBER") == 0) {
if (rkv->val[0] == '(') {
curlist = &NUMBER;
} else if (rkv->val[0] == ')') {
@@ -617,6 +638,14 @@ int main(int argc, char **argv)
}
only_ident = false;
do_token_check = false;
+ } else if (strcmp(rkv->key, "CALC") == 0) {
+ if (rkv->val[0] == '(') {
+ curlist = &CALC;
+ } else if (rkv->val[0] == ')') {
+ curlist = &base;
+ }
+ only_ident = false;
+ do_token_check = false;
} else if (strcmp(rkv->key, "COLOR") == 0) {
COLOR.item[COLOR.count++] = rkv;
do_token_check = false;
@@ -640,7 +669,7 @@ int main(int argc, char **argv)
/* header */
-output_header(outputf, descriptor, base.item[0], is_generic);
+ output_header(outputf, descriptor, base.item[0], is_generic);
if (WRAP.count > 0) {
output_wrap(outputf, base.item[0], &WRAP);
@@ -654,6 +683,10 @@ output_header(outputf, descriptor, base.item[0], is_generic);
if (URI.count > 0)
output_uri(outputf, base.item[0], &URI);
+ if (CALC.count > 0) {
+ output_calc(outputf, base.item[0], &CALC);
+ }
+
if (NUMBER.count > 0)
output_number(outputf, base.item[0], &NUMBER);
diff --git a/src/parse/properties/properties.gen b/src/parse/properties/properties.gen
index b0e797c..3452f81 100644
--- a/src/parse/properties/properties.gen
+++ b/src/parse/properties/properties.gen
@@ -6,6 +6,13 @@
#property:CSS_PROP_ENUM IDENT:( INHERIT: INITIAL: REVERT: UNSET: IDENT:) LENGTH_UNIT:( UNIT_HZ:PITCH_FREQUENCY ALLOW: DISALLOW: RANGE:<0 LENGTH_UNIT:)
#property:CSS_PROP_ENUM WRAP:
+# When a property takes a NUMBER and/or LENGTH_UNIT you may add calc() support:
+# In the below, PROPERTY_FOO_CALC is the opcode enum for the set-but-calculated value bytecode.
+# e.g. HEIGHT_SET (for a LENGTH_UNIT) would be HEIGHT_CALC here.
+# CALC:( UNIT_??:PROPERTY_FOO_CALC CALC:) <-- When a default unit must be considered
+# CALC:( NUMBER:PROPERTY_FOO_CALC CALC:) <-- When a number must be produced (not a dimension)
+# CALC:( ANY:PROPERTY_FOO_CALC CALC:) <-- When a number or dimension is valid (e.g. line-height)
+
background_repeat:CSS_PROP_BACKGROUND_REPEAT IDENT:( INHERIT: INITIAL: REVERT: UNSET: NO_REPEAT:0,BACKGROUND_REPEAT_NO_REPEAT REPEAT_X:0,BACKGROUND_REPEAT_REPEAT_X REPEAT_Y:0,BACKGROUND_REPEAT_REPEAT_Y REPEAT:0,BACKGROUND_REPEAT_REPEAT IDENT:)
border_collapse:CSS_PROP_BORDER_COLLAPSE IDENT:( INHERIT: INITIAL: REVERT: UNSET: COLLAPSE:0,BORDER_COLLAPSE_COLLAPSE SEPARATE:0,BORDER_COLLAPSE_SEPARATE IDENT:)
@@ -22,35 +29,35 @@ empty_cells:CSS_PROP_EMPTY_CELLS IDENT:( INHERIT: INITIAL: REVERT: UNSET: SHOW:0
float:CSS_PROP_FLOAT IDENT:( INHERIT: INITIAL: REVERT: UNSET: LEFT:0,FLOAT_LEFT RIGHT:0,FLOAT_RIGHT NONE:0,FLOAT_NONE IDENT:)
-font_size:CSS_PROP_FONT_SIZE IDENT:( INHERIT: INITIAL: REVERT: UNSET: XX_SMALL:0,FONT_SIZE_XX_SMALL X_SMALL:0,FONT_SIZE_X_SMALL SMALL:0,FONT_SIZE_SMALL MEDIUM:0,FONT_SIZE_MEDIUM LARGE:0,FONT_SIZE_LARGE X_LARGE:0,FONT_SIZE_X_LARGE XX_LARGE:0,FONT_SIZE_XX_LARGE LARGER:0,FONT_SIZE_LARGER SMALLER:0,FONT_SIZE_SMALLER IDENT:) LENGTH_UNIT:( UNIT_PX:FONT_SIZE_DIMENSION MASK:UNIT_MASK_FONT_SIZE RANGE:<0 LENGTH_UNIT:)
+font_size:CSS_PROP_FONT_SIZE IDENT:( INHERIT: INITIAL: REVERT: UNSET: XX_SMALL:0,FONT_SIZE_XX_SMALL X_SMALL:0,FONT_SIZE_X_SMALL SMALL:0,FONT_SIZE_SMALL MEDIUM:0,FONT_SIZE_MEDIUM LARGE:0,FONT_SIZE_LARGE X_LARGE:0,FONT_SIZE_X_LARGE XX_LARGE:0,FONT_SIZE_XX_LARGE LARGER:0,FONT_SIZE_LARGER SMALLER:0,FONT_SIZE_SMALLER IDENT:) LENGTH_UNIT:( UNIT_PX:FONT_SIZE_DIMENSION MASK:UNIT_MASK_FONT_SIZE RANGE:<0 LENGTH_UNIT:) CALC:( UNIT_PX:FONT_SIZE_CALC CALC:)
font_style:CSS_PROP_FONT_STYLE IDENT:( INHERIT: INITIAL: REVERT: UNSET: NORMAL:0,FONT_STYLE_NORMAL ITALIC:0,FONT_STYLE_ITALIC OBLIQUE:0,FONT_STYLE_OBLIQUE IDENT:)
font_variant:CSS_PROP_FONT_VARIANT IDENT:( INHERIT: INITIAL: REVERT: UNSET: NORMAL:0,FONT_VARIANT_NORMAL SMALL_CAPS:0,FONT_VARIANT_SMALL_CAPS IDENT:)
-height:CSS_PROP_HEIGHT IDENT:( INHERIT: INITIAL: REVERT: UNSET: AUTO:0,HEIGHT_AUTO IDENT:) LENGTH_UNIT:( UNIT_PX:HEIGHT_SET MASK:UNIT_MASK_HEIGHT RANGE:<0 LENGTH_UNIT:)
+height:CSS_PROP_HEIGHT IDENT:( INHERIT: INITIAL: REVERT: UNSET: AUTO:0,HEIGHT_AUTO IDENT:) LENGTH_UNIT:( UNIT_PX:HEIGHT_SET MASK:UNIT_MASK_HEIGHT RANGE:<0 LENGTH_UNIT:) CALC:( UNIT_PX:HEIGHT_CALC CALC:)
-letter_spacing:CSS_PROP_LETTER_SPACING IDENT:( INHERIT: INITIAL: REVERT: UNSET: NORMAL:0,LETTER_SPACING_NORMAL IDENT:) LENGTH_UNIT:( UNIT_PX:LETTER_SPACING_SET MASK:UNIT_MASK_LETTER_SPACING LENGTH_UNIT:)
+letter_spacing:CSS_PROP_LETTER_SPACING IDENT:( INHERIT: INITIAL: REVERT: UNSET: NORMAL:0,LETTER_SPACING_NORMAL IDENT:) LENGTH_UNIT:( UNIT_PX:LETTER_SPACING_SET MASK:UNIT_MASK_LETTER_SPACING LENGTH_UNIT:) CALC:( UNIT_PX:LETTER_SPACING_CALC CALC:)
-line_height:CSS_PROP_LINE_HEIGHT IDENT:( INHERIT: INITIAL: REVERT: UNSET: NORMAL:0,LINE_HEIGHT_NORMAL IDENT:) NUMBER:( false:LINE_HEIGHT_NUMBER RANGE:num<0 NUMBER:) LENGTH_UNIT:( UNIT_PX:LINE_HEIGHT_DIMENSION MASK:UNIT_MASK_LINE_HEIGHT RANGE:<0 LENGTH_UNIT:)
+line_height:CSS_PROP_LINE_HEIGHT IDENT:( INHERIT: INITIAL: REVERT: UNSET: NORMAL:0,LINE_HEIGHT_NORMAL IDENT:) NUMBER:( false:LINE_HEIGHT_NUMBER RANGE:num<0 NUMBER:) LENGTH_UNIT:( UNIT_PX:LINE_HEIGHT_DIMENSION MASK:UNIT_MASK_LINE_HEIGHT RANGE:<0 LENGTH_UNIT:) CALC:( ANY:LINE_HEIGHT_CALC CALC:)
border_top:BORDER_SIDE_TOP WRAP:css__parse_border_side
border_bottom:BORDER_SIDE_BOTTOM WRAP:css__parse_border_side
border_left:BORDER_SIDE_LEFT WRAP:css__parse_border_side
border_right:BORDER_SIDE_RIGHT WRAP:css__parse_border_side
-max_height:CSS_PROP_MAX_HEIGHT IDENT:( INHERIT: INITIAL: REVERT: UNSET: NONE:0,MAX_HEIGHT_NONE IDENT:) LENGTH_UNIT:( UNIT_PX:MAX_HEIGHT_SET MASK:UNIT_MASK_MAX_HEIGHT RANGE:<0 LENGTH_UNIT:)
+max_height:CSS_PROP_MAX_HEIGHT IDENT:( INHERIT: INITIAL: REVERT: UNSET: NONE:0,MAX_HEIGHT_NONE IDENT:) LENGTH_UNIT:( UNIT_PX:MAX_HEIGHT_SET MASK:UNIT_MASK_MAX_HEIGHT RANGE:<0 LENGTH_UNIT:) CALC:( UNIT_PX:MAX_HEIGHT_CALC CALC:)
-max_width:CSS_PROP_MAX_WIDTH IDENT:( INHERIT: INITIAL: REVERT: UNSET: NONE:0,MAX_WIDTH_NONE IDENT:) LENGTH_UNIT:( UNIT_PX:MAX_WIDTH_SET MASK:UNIT_MASK_MAX_WIDTH RANGE:<0 LENGTH_UNIT:)
+max_width:CSS_PROP_MAX_WIDTH IDENT:( INHERIT: INITIAL: REVERT: UNSET: NONE:0,MAX_WIDTH_NONE IDENT:) LENGTH_UNIT:( UNIT_PX:MAX_WIDTH_SET MASK:UNIT_MASK_MAX_WIDTH RANGE:<0 LENGTH_UNIT:) CALC:( UNIT_PX:MAX_WIDTH_CALC CALC:)
-min_height:CSS_PROP_MIN_HEIGHT IDENT:( INHERIT: INITIAL: REVERT: UNSET: AUTO:0,MIN_HEIGHT_AUTO IDENT:) LENGTH_UNIT:( UNIT_PX:MIN_HEIGHT_SET MASK:UNIT_MASK_MIN_HEIGHT RANGE:<0 LENGTH_UNIT:)
+min_height:CSS_PROP_MIN_HEIGHT IDENT:( INHERIT: INITIAL: REVERT: UNSET: AUTO:0,MIN_HEIGHT_AUTO IDENT:) LENGTH_UNIT:( UNIT_PX:MIN_HEIGHT_SET MASK:UNIT_MASK_MIN_HEIGHT RANGE:<0 LENGTH_UNIT:) CALC:( UNIT_PX:MIN_HEIGHT_CALC CALC:)
-min_width:CSS_PROP_MIN_WIDTH IDENT:( INHERIT: INITIAL: REVERT: UNSET: AUTO:0,MIN_WIDTH_AUTO IDENT:) LENGTH_UNIT:( UNIT_PX:MIN_WIDTH_SET MASK:UNIT_MASK_MIN_WIDTH RANGE:<0 LENGTH_UNIT:)
+min_width:CSS_PROP_MIN_WIDTH IDENT:( INHERIT: INITIAL: REVERT: UNSET: AUTO:0,MIN_WIDTH_AUTO IDENT:) LENGTH_UNIT:( UNIT_PX:MIN_WIDTH_SET MASK:UNIT_MASK_MIN_WIDTH RANGE:<0 LENGTH_UNIT:) CALC:( UNIT_PX:MIN_WIDTH_CALC CALC:)
color:CSS_PROP_COLOR IDENT:( INHERIT: INITIAL: REVERT: UNSET: IDENT:) COLOR:COLOR_SET
#generic for padding_{top, bottom, left, right}.c
-padding_side:op GENERIC: IDENT:( INHERIT: INITIAL: REVERT: UNSET: IDENT:) LENGTH_UNIT:( UNIT_PX:PADDING_SET MASK:UNIT_MASK_PADDING_SIDE RANGE:<0 LENGTH_UNIT:)
+padding_side:op GENERIC: IDENT:( INHERIT: INITIAL: REVERT: UNSET: IDENT:) LENGTH_UNIT:( UNIT_PX:PADDING_SET MASK:UNIT_MASK_PADDING_SIDE RANGE:<0 LENGTH_UNIT:) CALC:( UNIT_PX:PADDING_CALC CALC:)
padding_bottom:CSS_PROP_PADDING_BOTTOM WRAP:css__parse_padding_side
padding_left:CSS_PROP_PADDING_LEFT WRAP:css__parse_padding_side
@@ -59,7 +66,7 @@ padding_right:CSS_PROP_PADDING_RIGHT WRAP:css__parse_padding_side
#generic for margin_{top, bottom, left, right}.c
-margin_side:op GENERIC IDENT:( INHERIT: INITIAL: REVERT: UNSET: AUTO:0,MARGIN_AUTO IDENT:) LENGTH_UNIT:( UNIT_PX:MARGIN_SET MASK:UNIT_MASK_MARGIN_SIDE LENGTH_UNIT:)
+margin_side:op GENERIC IDENT:( INHERIT: INITIAL: REVERT: UNSET: AUTO:0,MARGIN_AUTO IDENT:) LENGTH_UNIT:( UNIT_PX:MARGIN_SET MASK:UNIT_MASK_MARGIN_SIDE LENGTH_UNIT:) CALC:( UNIT_PX:MARGIN_CALC CALC:)
margin_top:CSS_PROP_MARGIN_TOP WRAP:css__parse_margin_side
margin_bottom:CSS_PROP_MARGIN_BOTTOM WRAP:css__parse_margin_side
@@ -67,7 +74,7 @@ margin_left:CSS_PROP_MARGIN_LEFT WRAP:css__parse_margin_side
margin_right:CSS_PROP_MARGIN_RIGHT WRAP:css__parse_margin_side
#generic for {top, bottom, left, right}.c
-side:op GENERIC: IDENT:( INHERIT: INITIAL: REVERT: UNSET: AUTO:0,BOTTOM_AUTO IDENT:) LENGTH_UNIT:( UNIT_PX:BOTTOM_SET ALLOW:unit&(UNIT_LENGTH|UNIT_PCT) LENGTH_UNIT:)
+side:op GENERIC: IDENT:( INHERIT: INITIAL: REVERT: UNSET: AUTO:0,BOTTOM_AUTO IDENT:) LENGTH_UNIT:( UNIT_PX:BOTTOM_SET ALLOW:unit&(UNIT_LENGTH|UNIT_PCT) LENGTH_UNIT:) CALC:( UNIT_PX:BOTTOM_CALC CALC:)
top:CSS_PROP_TOP WRAP:css__parse_side
bottom:CSS_PROP_BOTTOM WRAP:css__parse_side
@@ -76,7 +83,7 @@ right:CSS_PROP_RIGHT WRAP:css__parse_side
#generic for border_{top, bottom, left, right}_width.c
-border_side_width:op GENERIC: IDENT:( INHERIT: INITIAL: REVERT: UNSET: THIN:0,BORDER_WIDTH_THIN MEDIUM:0,BORDER_WIDTH_MEDIUM THICK:0,BORDER_WIDTH_THICK IDENT:) LENGTH_UNIT:( UNIT_PX:BORDER_WIDTH_SET MASK:UNIT_MASK_BORDER_SIDE_WIDTH RANGE:<0 LENGTH_UNIT:)
+border_side_width:op GENERIC: IDENT:( INHERIT: INITIAL: REVERT: UNSET: THIN:0,BORDER_WIDTH_THIN MEDIUM:0,BORDER_WIDTH_MEDIUM THICK:0,BORDER_WIDTH_THICK IDENT:) LENGTH_UNIT:( UNIT_PX:BORDER_WIDTH_SET MASK:UNIT_MASK_BORDER_SIDE_WIDTH RANGE:<0 LENGTH_UNIT:) CALC:( UNIT_PX:BORDER_WIDTH_CALC CALC:)
border_top_width:CSS_PROP_BORDER_TOP_WIDTH WRAP:css__parse_border_side_width
border_bottom_width:CSS_PROP_BORDER_BOTTOM_WIDTH WRAP:css__parse_border_side_width
@@ -120,7 +127,7 @@ list_style_image:CSS_PROP_LIST_STYLE_IMAGE IDENT:( INHERIT: INITIAL: REVERT: UNS
list_style_position:CSS_PROP_LIST_STYLE_POSITION IDENT:( INHERIT: INITIAL: REVERT: UNSET: INSIDE:0,LIST_STYLE_POSITION_INSIDE OUTSIDE:0,LIST_STYLE_POSITION_OUTSIDE IDENT:)
-orphans:CSS_PROP_ORPHANS IDENT:( INHERIT: INITIAL: REVERT: UNSET: IDENT:) NUMBER:( true:ORPHANS_SET RANGE:num<0 NUMBER:)
+orphans:CSS_PROP_ORPHANS IDENT:( INHERIT: INITIAL: REVERT: UNSET: IDENT:) NUMBER:( true:ORPHANS_SET RANGE:num<0 NUMBER:) CALC:( NUMBER:ORPHANS_CALC CALC:)
outline_color:CSS_PROP_OUTLINE_COLOR IDENT:( INHERIT: INITIAL: REVERT: UNSET: INVERT:0,OUTLINE_COLOR_INVERT IDENT:) COLOR:OUTLINE_COLOR_SET
@@ -133,24 +140,23 @@ overflow_x:CSS_PROP_OVERFLOW_X IDENT:( INHERIT: INITIAL: REVERT: UNSET: VISIBLE:
overflow_y:CSS_PROP_OVERFLOW_Y IDENT:( INHERIT: INITIAL: REVERT: UNSET: VISIBLE:0,OVERFLOW_VISIBLE HIDDEN:0,OVERFLOW_HIDDEN SCROLL:0,OVERFLOW_SCROLL AUTO:0,OVERFLOW_AUTO IDENT:)
-
page_break_after:CSS_PROP_PAGE_BREAK_AFTER IDENT:( INHERIT: INITIAL: REVERT: UNSET: AUTO:0,PAGE_BREAK_AFTER_AUTO ALWAYS:0,PAGE_BREAK_AFTER_ALWAYS AVOID:0,PAGE_BREAK_AFTER_AVOID LEFT:0,PAGE_BREAK_AFTER_LEFT RIGHT:0,PAGE_BREAK_AFTER_RIGHT IDENT:)
page_break_before:CSS_PROP_PAGE_BREAK_BEFORE IDENT:( INHERIT: INITIAL: REVERT: UNSET: AUTO:0,PAGE_BREAK_BEFORE_AUTO ALWAYS:0,PAGE_BREAK_BEFORE_ALWAYS AVOID:0,PAGE_BREAK_BEFORE_AVOID LEFT:0,PAGE_BREAK_BEFORE_LEFT RIGHT:0,PAGE_BREAK_BEFORE_RIGHT IDENT:)
page_break_inside:CSS_PROP_PAGE_BREAK_INSIDE IDENT:( INHERIT: INITIAL: REVERT: UNSET: AUTO:0,PAGE_BREAK_INSIDE_AUTO AVOID:0,PAGE_BREAK_INSIDE_AVOID IDENT:)
-pause_after:CSS_PROP_PAUSE_AFTER IDENT:( INHERIT: INITIAL: REVERT: UNSET: IDENT:) LENGTH_UNIT:( UNIT_S:PAUSE_AFTER_SET MASK:UNIT_MASK_PAUSE_AFTER RANGE:<0 LENGTH_UNIT:)
+pause_after:CSS_PROP_PAUSE_AFTER IDENT:( INHERIT: INITIAL: REVERT: UNSET: IDENT:) LENGTH_UNIT:( UNIT_S:PAUSE_AFTER_SET MASK:UNIT_MASK_PAUSE_AFTER RANGE:<0 LENGTH_UNIT:) CALC:( UNIT_S:PAUSE_AFTER_CALC CALC:)
-pause_before:CSS_PROP_PAUSE_BEFORE IDENT:( INHERIT: INITIAL: REVERT: UNSET: IDENT:) LENGTH_UNIT:( UNIT_S:PAUSE_BEFORE_SET MASK:UNIT_MASK_PAUSE_BEFORE RANGE:<0 LENGTH_UNIT:)
+pause_before:CSS_PROP_PAUSE_BEFORE IDENT:( INHERIT: INITIAL: REVERT: UNSET: IDENT:) LENGTH_UNIT:( UNIT_S:PAUSE_BEFORE_SET MASK:UNIT_MASK_PAUSE_BEFORE RANGE:<0 LENGTH_UNIT:) CALC:( UNIT_S:PAUSE_BEFORE_CALC CALC:)
-pitch:CSS_PROP_PITCH IDENT:( INHERIT: INITIAL: REVERT: UNSET: X_LOW:0,PITCH_X_LOW LOW:0,PITCH_LOW MEDIUM:0,PITCH_MEDIUM HIGH:0,PITCH_HIGH X_HIGH:0,PITCH_X_HIGH IDENT:) LENGTH_UNIT:( UNIT_HZ:PITCH_FREQUENCY MASK:UNIT_MASK_PITCH RANGE:<0 LENGTH_UNIT:)
+pitch:CSS_PROP_PITCH IDENT:( INHERIT: INITIAL: REVERT: UNSET: X_LOW:0,PITCH_X_LOW LOW:0,PITCH_LOW MEDIUM:0,PITCH_MEDIUM HIGH:0,PITCH_HIGH X_HIGH:0,PITCH_X_HIGH IDENT:) LENGTH_UNIT:( UNIT_HZ:PITCH_FREQUENCY MASK:UNIT_MASK_PITCH RANGE:<0 LENGTH_UNIT:) CALC:( UNIT_HZ:PITCH_CALC CALC:)
-pitch_range:CSS_PROP_PITCH_RANGE IDENT:( INHERIT: INITIAL: REVERT: UNSET: IDENT:) NUMBER:( false:PITCH_RANGE_SET RANGE:num<0||num>F_100 NUMBER:)
+pitch_range:CSS_PROP_PITCH_RANGE IDENT:( INHERIT: INITIAL: REVERT: UNSET: IDENT:) NUMBER:( false:PITCH_RANGE_SET RANGE:num<0||num>F_100 NUMBER:) CALC:( NUMBER:PITCH_RANGE_CALC CALC:)
position:CSS_PROP_POSITION IDENT:( INHERIT: INITIAL: REVERT: UNSET: LIBCSS_STATIC:0,POSITION_STATIC RELATIVE:0,POSITION_RELATIVE ABSOLUTE:0,POSITION_ABSOLUTE FIXED:0,POSITION_FIXED STICKY:0,POSITION_STICKY IDENT:)
-richness:CSS_PROP_RICHNESS IDENT:( INHERIT: INITIAL: REVERT: UNSET: IDENT:) NUMBER:( false:RICHNESS_SET RANGE:num<0||num>F_100 NUMBER:)
+richness:CSS_PROP_RICHNESS IDENT:( INHERIT: INITIAL: REVERT: UNSET: IDENT:) NUMBER:( false:RICHNESS_SET RANGE:num<0||num>F_100 NUMBER:) CALC:( NUMBER:RICHNESS_CALC CALC:)
speak:CSS_PROP_SPEAK IDENT:( INHERIT: INITIAL: REVERT: UNSET: NORMAL:0,SPEAK_NORMAL NONE:0,SPEAK_NONE SPELL_OUT:0,SPEAK_SPELL_OUT IDENT:)
@@ -160,37 +166,35 @@ speak_numeral:CSS_PROP_SPEAK_NUMERAL IDENT:( INHERIT: INITIAL: REVERT: UNSET: DI
speak_punctuation:CSS_PROP_SPEAK_PUNCTUATION IDENT:( INHERIT: INITIAL: REVERT: UNSET: CODE:0,SPEAK_PUNCTUATION_CODE NONE:0,SPEAK_PUNCTUATION_NONE IDENT:)
-speech_rate:CSS_PROP_SPEECH_RATE IDENT:( INHERIT: INITIAL: REVERT: UNSET: X_SLOW:0,SPEECH_RATE_X_SLOW SLOW:0,SPEECH_RATE_SLOW MEDIUM:0,SPEECH_RATE_MEDIUM FAST:0,SPEECH_RATE_FAST X_FAST:0,SPEECH_RATE_X_FAST FASTER:0,SPEECH_RATE_FASTER SLOWER:0,SPEECH_RATE_SLOWER IDENT:) NUMBER:( false:SPEECH_RATE_SET RANGE:num<0 NUMBER:)
+speech_rate:CSS_PROP_SPEECH_RATE IDENT:( INHERIT: INITIAL: REVERT: UNSET: X_SLOW:0,SPEECH_RATE_X_SLOW SLOW:0,SPEECH_RATE_SLOW MEDIUM:0,SPEECH_RATE_MEDIUM FAST:0,SPEECH_RATE_FAST X_FAST:0,SPEECH_RATE_X_FAST FASTER:0,SPEECH_RATE_FASTER SLOWER:0,SPEECH_RATE_SLOWER IDENT:) NUMBER:( false:SPEECH_RATE_SET RANGE:num<0 NUMBER:) CALC:( NUMBER:SPEECH_RATE_CALC CALC:)
-stress:CSS_PROP_STRESS IDENT:( INHERIT: INITIAL: REVERT: UNSET: IDENT:) NUMBER:( false:STRESS_SET RANGE:num<0||num>INTTOFIX(100) NUMBER:)
+stress:CSS_PROP_STRESS IDENT:( INHERIT: INITIAL: REVERT: UNSET: IDENT:) NUMBER:( false:STRESS_SET RANGE:num<0||num>INTTOFIX(100) NUMBER:) CALC:( NUMBER:STRESS_CALC CALC:)
table_layout:CSS_PROP_TABLE_LAYOUT IDENT:( INHERIT: INITIAL: REVERT: UNSET: AUTO:0,TABLE_LAYOUT_AUTO FIXED:0,TABLE_LAYOUT_FIXED IDENT:)
text_align:CSS_PROP_TEXT_ALIGN IDENT:( INHERIT: INITIAL: REVERT: UNSET: LEFT:0,TEXT_ALIGN_LEFT RIGHT:0,TEXT_ALIGN_RIGHT CENTER:0,TEXT_ALIGN_CENTER JUSTIFY:0,TEXT_ALIGN_JUSTIFY LIBCSS_LEFT:0,TEXT_ALIGN_LIBCSS_LEFT LIBCSS_CENTER:0,TEXT_ALIGN_LIBCSS_CENTER LIBCSS_RIGHT:0,TEXT_ALIGN_LIBCSS_RIGHT IDENT:)
-text_indent:CSS_PROP_TEXT_INDENT IDENT:( INHERIT: INITIAL: REVERT: UNSET: IDENT:) LENGTH_UNIT:( UNIT_PX:TEXT_INDENT_SET MASK:UNIT_MASK_TEXT_INDENT LENGTH_UNIT:)
+text_indent:CSS_PROP_TEXT_INDENT IDENT:( INHERIT: INITIAL: REVERT: UNSET: IDENT:) LENGTH_UNIT:( UNIT_PX:TEXT_INDENT_SET MASK:UNIT_MASK_TEXT_INDENT LENGTH_UNIT:) CALC:( UNIT_PX:TEXT_INDENT_CALC CALC:)
text_transform:CSS_PROP_TEXT_TRANSFORM IDENT:( INHERIT: INITIAL: REVERT: UNSET: CAPITALIZE:0,TEXT_TRANSFORM_CAPITALIZE UPPERCASE:0,TEXT_TRANSFORM_UPPERCASE LOWERCASE:0,TEXT_TRANSFORM_LOWERCASE NONE:0,TEXT_TRANSFORM_NONE IDENT:)
unicode_bidi:CSS_PROP_UNICODE_BIDI IDENT:( INHERIT: INITIAL: REVERT: UNSET: NORMAL:0,UNICODE_BIDI_NORMAL EMBED:0,UNICODE_BIDI_EMBED BIDI_OVERRIDE:0,UNICODE_BIDI_BIDI_OVERRIDE IDENT:)
-vertical_align:CSS_PROP_VERTICAL_ALIGN IDENT:( INHERIT: INITIAL: REVERT: UNSET: BASELINE:0,VERTICAL_ALIGN_BASELINE SUB:0,VERTICAL_ALIGN_SUB SUPER:0,VERTICAL_ALIGN_SUPER TOP:0,VERTICAL_ALIGN_TOP TEXT_TOP:0,VERTICAL_ALIGN_TEXT_TOP MIDDLE:0,VERTICAL_ALIGN_MIDDLE BOTTOM:0,VERTICAL_ALIGN_BOTTOM TEXT_BOTTOM:0,VERTICAL_ALIGN_TEXT_BOTTOM IDENT:) LENGTH_UNIT:( UNIT_PX:VERTICAL_ALIGN_SET MASK:UNIT_MASK_VERTICAL_ALIGN LENGTH_UNIT:)
+vertical_align:CSS_PROP_VERTICAL_ALIGN IDENT:( INHERIT: INITIAL: REVERT: UNSET: BASELINE:0,VERTICAL_ALIGN_BASELINE SUB:0,VERTICAL_ALIGN_SUB SUPER:0,VERTICAL_ALIGN_SUPER TOP:0,VERTICAL_ALIGN_TOP TEXT_TOP:0,VERTICAL_ALIGN_TEXT_TOP MIDDLE:0,VERTICAL_ALIGN_MIDDLE BOTTOM:0,VERTICAL_ALIGN_BOTTOM TEXT_BOTTOM:0,VERTICAL_ALIGN_TEXT_BOTTOM IDENT:) LENGTH_UNIT:( UNIT_PX:VERTICAL_ALIGN_SET MASK:UNIT_MASK_VERTICAL_ALIGN LENGTH_UNIT:) CALC:( UNIT_PX:VERTICAL_ALIGN_CALC CALC:)
visibility:CSS_PROP_VISIBILITY IDENT:( INHERIT: INITIAL: REVERT: UNSET: VISIBLE:0,VISIBILITY_VISIBLE HIDDEN:0,VISIBILITY_HIDDEN COLLAPSE:0,VISIBILITY_COLLAPSE IDENT:)
-volume:CSS_PROP_VOLUME IDENT:( INHERIT: INITIAL: REVERT: UNSET: SILENT:0,VOLUME_SILENT X_SOFT:0,VOLUME_X_SOFT SOFT:0,VOLUME_SOFT MEDIUM:0,VOLUME_MEDIUM LOUD:0,VOLUME_LOUD X_LOUD:0,VOLUME_X_LOUD IDENT:) NUMBER:( false:VOLUME_NUMBER RANGE:num<0||num>F_100 NUMBER:) LENGTH_UNIT:( UNIT_PX:VOLUME_DIMENSION MASK:UNIT_MASK_VOLUME RANGE:<0 LENGTH_UNIT:)
+volume:CSS_PROP_VOLUME IDENT:( INHERIT: INITIAL: REVERT: UNSET: SILENT:0,VOLUME_SILENT X_SOFT:0,VOLUME_X_SOFT SOFT:0,VOLUME_SOFT MEDIUM:0,VOLUME_MEDIUM LOUD:0,VOLUME_LOUD X_LOUD:0,VOLUME_X_LOUD IDENT:) NUMBER:( false:VOLUME_NUMBER RANGE:num<0||num>F_100 NUMBER:) LENGTH_UNIT:( UNIT_PX:VOLUME_DIMENSION MASK:UNIT_MASK_VOLUME RANGE:<0 LENGTH_UNIT:) CALC:( ANY:VOLUME_CALC CALC:)
white_space:CSS_PROP_WHITE_SPACE IDENT:( INHERIT: INITIAL: REVERT: UNSET: NORMAL:0,WHITE_SPACE_NORMAL PRE:0,WHITE_SPACE_PRE NOWRAP:0,WHITE_SPACE_NOWRAP PRE_WRAP:0,WHITE_SPACE_PRE_WRAP PRE_LINE:0,WHITE_SPACE_PRE_LINE IDENT:)
-widows:CSS_PROP_WIDOWS IDENT:( INHERIT: INITIAL: REVERT: UNSET: IDENT:) NUMBER:( true:WIDOWS_SET RANGE:num<0 NUMBER:)
-
-
-width:CSS_PROP_WIDTH IDENT:( INHERIT: INITIAL: REVERT: UNSET: AUTO:0,WIDTH_AUTO IDENT:) LENGTH_UNIT:( UNIT_PX:WIDTH_SET MASK:UNIT_MASK_WIDTH RANGE:<0 LENGTH_UNIT:)
+widows:CSS_PROP_WIDOWS IDENT:( INHERIT: INITIAL: REVERT: UNSET: IDENT:) NUMBER:( true:WIDOWS_SET RANGE:num<0 NUMBER:) CALC:( NUMBER:WIDOWS_CALC CALC:)
-word_spacing:CSS_PROP_WORD_SPACING IDENT:( INHERIT: INITIAL: REVERT: UNSET: NORMAL:0,WORD_SPACING_NORMAL IDENT:) LENGTH_UNIT:( UNIT_PX:WORD_SPACING_SET MASK:UNIT_MASK_WORD_SPACING LENGTH_UNIT:)
+width:CSS_PROP_WIDTH IDENT:( INHERIT: INITIAL: REVERT: UNSET: AUTO:0,WIDTH_AUTO IDENT:) LENGTH_UNIT:( UNIT_PX:WIDTH_SET MASK:UNIT_MASK_WIDTH RANGE:<0 LENGTH_UNIT:) CALC:( UNIT_PX:WIDTH_CALC CALC:)
-z_index:CSS_PROP_Z_INDEX IDENT:( INHERIT: INITIAL: REVERT: UNSET: AUTO:0,Z_INDEX_AUTO IDENT:) NUMBER:( true:Z_INDEX_SET NUMBER:)
+word_spacing:CSS_PROP_WORD_SPACING IDENT:( INHERIT: INITIAL: REVERT: UNSET: NORMAL:0,WORD_SPACING_NORMAL IDENT:) LENGTH_UNIT:( UNIT_PX:WORD_SPACING_SET MASK:UNIT_MASK_WORD_SPACING LENGTH_UNIT:) CALC:( UNIT_PX:WORD_SPACING_CALC CALC:)
+z_index:CSS_PROP_Z_INDEX IDENT:( INHERIT: INITIAL: REVERT: UNSET: AUTO:0,Z_INDEX_AUTO IDENT:) NUMBER:( true:Z_INDEX_SET NUMBER:) CALC:( NUMBER:Z_INDEX_CALC CALC:)
break_after:CSS_PROP_BREAK_AFTER IDENT:( INHERIT: INITIAL: REVERT: UNSET: AUTO:0,BREAK_AFTER_AUTO ALWAYS:0,BREAK_AFTER_ALWAYS AVOID:0,BREAK_AFTER_AVOID LEFT:0,BREAK_AFTER_LEFT RIGHT:0,BREAK_AFTER_RIGHT PAGE:0,BREAK_AFTER_PAGE COLUMN:0,BREAK_AFTER_COLUMN AVOID_PAGE:0,BREAK_AFTER_AVOID_PAGE AVOID_COLUMN:0,BREAK_AFTER_AVOID_COLUMN IDENT:)
@@ -198,11 +202,11 @@ break_before:CSS_PROP_BREAK_BEFORE IDENT:( INHERIT: INITIAL: REVERT: UNSET: AUTO
break_inside:CSS_PROP_BREAK_INSIDE IDENT:( INHERIT: INITIAL: REVERT: UNSET: AUTO:0,BREAK_INSIDE_AUTO AVOID:0,BREAK_INSIDE_AVOID AVOID_PAGE:0,BREAK_INSIDE_AVOID_PAGE AVOID_COLUMN:0,BREAK_INSIDE_AVOID_COLUMN IDENT:)
-column_count:CSS_PROP_COLUMN_COUNT IDENT:( INHERIT: INITIAL: REVERT: UNSET: AUTO:0,COLUMN_COUNT_AUTO IDENT:) NUMBER:( true:COLUMN_COUNT_SET RANGE:num<0 NUMBER:)
+column_count:CSS_PROP_COLUMN_COUNT IDENT:( INHERIT: INITIAL: REVERT: UNSET: AUTO:0,COLUMN_COUNT_AUTO IDENT:) NUMBER:( true:COLUMN_COUNT_SET RANGE:num<0 NUMBER:) CALC:( NUMBER:COLUMN_COUNT_CALC CALC:)
column_fill:CSS_PROP_COLUMN_FILL IDENT:( INHERIT: INITIAL: REVERT: UNSET: BALANCE:0,COLUMN_FILL_BALANCE AUTO:0,COLUMN_FILL_AUTO IDENT:)
-column_gap:CSS_PROP_COLUMN_GAP IDENT:( INHERIT: INITIAL: REVERT: UNSET: NORMAL:0,COLUMN_GAP_NORMAL IDENT:) LENGTH_UNIT:( UNIT_PX:COLUMN_GAP_SET RANGE:<0 MASK:UNIT_MASK_COLUMN_GAP LENGTH_UNIT:)
+column_gap:CSS_PROP_COLUMN_GAP IDENT:( INHERIT: INITIAL: REVERT: UNSET: NORMAL:0,COLUMN_GAP_NORMAL IDENT:) LENGTH_UNIT:( UNIT_PX:COLUMN_GAP_SET RANGE:<0 MASK:UNIT_MASK_COLUMN_GAP LENGTH_UNIT:) CALC:( UNIT_PX:COLUMN_GAP_CALC CALC:)
column_rule_color:CSS_PROP_COLUMN_RULE_COLOR IDENT:( INHERIT: INITIAL: REVERT: UNSET: IDENT:) COLOR:COLUMN_RULE_COLOR_SET
@@ -212,7 +216,7 @@ column_rule_width:CSS_PROP_COLUMN_RULE_WIDTH WRAP:css__parse_border_side_width
column_span:CSS_PROP_COLUMN_SPAN IDENT:( INHERIT: INITIAL: REVERT: UNSET: NONE:0,COLUMN_SPAN_NONE ALL:0,COLUMN_SPAN_ALL IDENT:)
-column_width:CSS_PROP_COLUMN_WIDTH IDENT:( INHERIT: INITIAL: REVERT: UNSET: AUTO:0,COLUMN_WIDTH_AUTO IDENT:) LENGTH_UNIT:( UNIT_PX:COLUMN_WIDTH_SET MASK:UNIT_MASK_COLUMN_WIDTH LENGTH_UNIT:)
+column_width:CSS_PROP_COLUMN_WIDTH IDENT:( INHERIT: INITIAL: REVERT: UNSET: AUTO:0,COLUMN_WIDTH_AUTO IDENT:) LENGTH_UNIT:( UNIT_PX:COLUMN_WIDTH_SET MASK:UNIT_MASK_COLUMN_WIDTH LENGTH_UNIT:) CALC:( UNIT_PX:COLUMN_WIDTH_CALC CALC:)
writing_mode:CSS_PROP_WRITING_MODE IDENT:( INHERIT: INITIAL: REVERT: UNSET: HORIZONTAL_TB:0,WRITING_MODE_HORIZONTAL_TB VERTICAL_RL:0,WRITING_MODE_VERTICAL_RL VERTICAL_LR:0,WRITING_MODE_VERTICAL_LR IDENT:)
@@ -224,16 +228,16 @@ align_items:CSS_PROP_ALIGN_ITEMS IDENT:( INHERIT: INITIAL: REVERT: UNSET: STRETC
align_self:CSS_PROP_ALIGN_SELF IDENT:( INHERIT: INITIAL: REVERT: UNSET: STRETCH:0,ALIGN_SELF_STRETCH FLEX_START:0,ALIGN_SELF_FLEX_START FLEX_END:0,ALIGN_SELF_FLEX_END CENTER:0,ALIGN_SELF_CENTER BASELINE:0,ALIGN_SELF_BASELINE AUTO:0,ALIGN_SELF_AUTO IDENT:)
-flex_basis:CSS_PROP_FLEX_BASIS IDENT:( INHERIT: INITIAL: REVERT: UNSET: AUTO:0,FLEX_BASIS_AUTO CONTENT:0,FLEX_BASIS_CONTENT IDENT:) LENGTH_UNIT:( UNIT_PX:FLEX_BASIS_SET MASK:UNIT_MASK_FLEX_BASIS RANGE:<0 LENGTH_UNIT:)
+flex_basis:CSS_PROP_FLEX_BASIS IDENT:( INHERIT: INITIAL: REVERT: UNSET: AUTO:0,FLEX_BASIS_AUTO CONTENT:0,FLEX_BASIS_CONTENT IDENT:) LENGTH_UNIT:( UNIT_PX:FLEX_BASIS_SET MASK:UNIT_MASK_FLEX_BASIS RANGE:<0 LENGTH_UNIT:) CALC:( UNIT_PX:FLEX_BASIS_CALC CALC:)
flex_direction:CSS_PROP_FLEX_DIRECTION IDENT:( INHERIT: INITIAL: REVERT: UNSET: ROW:0,FLEX_DIRECTION_ROW ROW_REVERSE:0,FLEX_DIRECTION_ROW_REVERSE COLUMN:0,FLEX_DIRECTION_COLUMN COLUMN_REVERSE:0,FLEX_DIRECTION_COLUMN_REVERSE IDENT:)
-flex_grow:CSS_PROP_FLEX_GROW IDENT:( INHERIT: INITIAL: REVERT: UNSET: IDENT:) NUMBER:( false:FLEX_GROW_SET RANGE:num<0 NUMBER:)
+flex_grow:CSS_PROP_FLEX_GROW IDENT:( INHERIT: INITIAL: REVERT: UNSET: IDENT:) NUMBER:( false:FLEX_GROW_SET RANGE:num<0 NUMBER:) CALC:( NUMBER:FLEX_GROW_CALC CALC:)
-flex_shrink:CSS_PROP_FLEX_SHRINK IDENT:( INHERIT: INITIAL: REVERT: UNSET: IDENT:) NUMBER:( false:FLEX_SHRINK_SET RANGE:num<0 NUMBER:)
+flex_shrink:CSS_PROP_FLEX_SHRINK IDENT:( INHERIT: INITIAL: REVERT: UNSET: IDENT:) NUMBER:( false:FLEX_SHRINK_SET RANGE:num<0 NUMBER:) CALC:( NUMBER:FLEX_SHRINK_CALC CALC:)
flex_wrap:CSS_PROP_FLEX_WRAP IDENT:( INHERIT: INITIAL: REVERT: UNSET: NOWRAP:0,FLEX_WRAP_NOWRAP WRAP_STRING:0,FLEX_WRAP_WRAP WRAP_REVERSE:0,FLEX_WRAP_WRAP_REVERSE IDENT:)
justify_content:CSS_PROP_JUSTIFY_CONTENT IDENT:( INHERIT: INITIAL: REVERT: UNSET: FLEX_START:0,JUSTIFY_CONTENT_FLEX_START FLEX_END:0,JUSTIFY_CONTENT_FLEX_END CENTER:0,JUSTIFY_CONTENT_CENTER SPACE_BETWEEN:0,JUSTIFY_CONTENT_SPACE_BETWEEN SPACE_AROUND:0,JUSTIFY_CONTENT_SPACE_AROUND SPACE_EVENLY:0,JUSTIFY_CONTENT_SPACE_EVENLY IDENT:)
-order:CSS_PROP_ORDER IDENT:( INHERIT: INITIAL: REVERT: UNSET: IDENT:) NUMBER:( true:ORDER_SET NUMBER:)
+order:CSS_PROP_ORDER IDENT:( INHERIT: INITIAL: REVERT: UNSET: IDENT:) NUMBER:( true:ORDER_SET NUMBER:) CALC:( NUMBER:ORDER_CALC CALC:)
diff --git a/src/parse/properties/utils.c b/src/parse/properties/utils.c
index 4739486..cce9717 100644
--- a/src/parse/properties/utils.c
+++ b/src/parse/properties/utils.c
@@ -1351,9 +1351,9 @@ cleanup:
*
*
* calc(10px + (4rem / 2)) =>
- * U 10 px
- * U 4 rem
- * N 2
+ * V 10 px
+ * V 4 rem
+ * V 2 NUMBER
* /
* +
* =
@@ -1362,14 +1362,12 @@ cleanup:
static css_error
css__parse_calc_sum(css_language *c,
const parserutils_vector *vector, int *ctx,
- css_style *result,
- uint32_t unit);
+ css_style *result);
static css_error
css__parse_calc_value(css_language *c,
const parserutils_vector *vector, int *ctx,
- css_style *result,
- uint32_t default_unit)
+ css_style *result)
{
css_error error;
int orig_ctx = *ctx;
@@ -1377,7 +1375,7 @@ css__parse_calc_value(css_language *c,
token = parserutils_vector_iterate(vector, ctx);
if (tokenIsChar(token, '(')) {
- error = css__parse_calc_sum(c, vector, ctx, result, default_unit);
+ error = css__parse_calc_sum(c, vector, ctx, result);
if (error != CSS_OK) {
return error;
}
@@ -1396,13 +1394,13 @@ css__parse_calc_value(css_language *c,
uint32_t unit = 0;
*ctx = orig_ctx;
- error = css__parse_unit_specifier(c, vector, ctx, default_unit, &length, &unit);
+ error = css__parse_unit_specifier(c, vector, ctx, UNIT_CALC_NUMBER, &length, &unit);
if (error != CSS_OK) {
*ctx = orig_ctx;
return error;
}
- error = css__stylesheet_style_vappend(result, 3, (css_code_t) 'U', length, unit);
+ error = css__stylesheet_style_vappend(result, 3, (css_code_t) 'V', length, unit);
}
break;
@@ -1422,8 +1420,7 @@ css__parse_calc_value(css_language *c,
static css_error
css__parse_calc_product(css_language *c,
const parserutils_vector *vector, int *ctx,
- css_style *result,
- uint32_t unit)
+ css_style *result)
{
css_error error = CSS_OK;
const css_token *token;
@@ -1431,7 +1428,7 @@ css__parse_calc_product(css_language *c,
/* First parse a value */
- error = css__parse_calc_value(c, vector, ctx, result, unit);
+ error = css__parse_calc_value(c, vector, ctx, result);
if (error != CSS_OK) {
return error;
}
@@ -1455,33 +1452,10 @@ css__parse_calc_product(css_language *c,
/* Consume that * or / now */
token = parserutils_vector_iterate(vector, ctx);
- if (multiplication) {
- /* parse another value */
- error = css__parse_calc_value(c, vector, ctx, result, unit);
- if (error != CSS_OK)
- break;
- } else {
- css_fixed num;
- size_t consumed;
-
- token = parserutils_vector_iterate(vector, ctx);
- if (token->type != CSS_TOKEN_NUMBER) {
- error = CSS_INVALID;
- break;
- }
- num = css__number_from_lwc_string(token->idata, false, &consumed);
- if (consumed != lwc_string_length(token->idata)) {
- error = CSS_INVALID;
- break;
- }
-
- error = css__stylesheet_style_append(result, (css_code_t) 'N');
- if (error != CSS_OK)
- break;
- error = css__stylesheet_style_append(result, (css_code_t) num);
- if (error != CSS_OK)
- break;
- }
+ /* parse another value */
+ error = css__parse_calc_value(c, vector, ctx, result);
+ if (error != CSS_OK)
+ break;
/* emit the multiplication/division operator */
error = css__stylesheet_style_append(result, (css_code_t) (multiplication ? '*' : '/'));
@@ -1494,8 +1468,7 @@ css__parse_calc_product(css_language *c,
css_error
css__parse_calc_sum(css_language *c,
const parserutils_vector *vector, int *ctx,
- css_style *result,
- uint32_t unit)
+ css_style *result)
{
css_error error = CSS_OK;
const css_token *token;
@@ -1503,7 +1476,7 @@ css__parse_calc_sum(css_language *c,
/* First parse a product */
- error = css__parse_calc_product(c, vector, ctx, result, unit);
+ error = css__parse_calc_product(c, vector, ctx, result);
if (error != CSS_OK) {
return error;
}
@@ -1528,7 +1501,7 @@ css__parse_calc_sum(css_language *c,
token = parserutils_vector_iterate(vector, ctx);
/* parse another product */
- error = css__parse_calc_product(c, vector, ctx, result, unit);
+ error = css__parse_calc_product(c, vector, ctx, result);
if (error != CSS_OK)
break;
@@ -1570,8 +1543,10 @@ css_error css__parse_calc(css_language *c,
error = css__stylesheet_style_append(calc_style, property);
if (error != CSS_OK)
goto cleanup;
+
+ error = css__stylesheet_style_append(calc_style, (css_code_t) unit);
- error = css__parse_calc_sum(c, vector, ctx, calc_style, unit);
+ error = css__parse_calc_sum(c, vector, ctx, calc_style);
if (error != CSS_OK)
goto cleanup;
commitdiff http://git.netsurf-browser.org/libcss.git/commit/?id=4702422440022bfd64bd...
commit 4702422440022bfd64bdf6e221c8f89fd2923fda
Author: Daniel Silverstone <dsilvers(a)netsurf-browser.org>
Commit: Michael Drake <tlsa(a)netsurf-browser.org>
parse: Add calc() parser.
Co-authored-by: Michael Drake <michael.drake(a)netsurf-browser.org>
diff --git a/src/parse/properties/css_property_parser_gen.c b/src/parse/properties/css_property_parser_gen.c
index 1e8b007..100fba1 100644
--- a/src/parse/properties/css_property_parser_gen.c
+++ b/src/parse/properties/css_property_parser_gen.c
@@ -316,6 +316,16 @@ void output_length_unit(FILE *outputf, struct keyval *parseid, struct keyval_lis
struct keyval *ckv = kvlist->item[0];
int ident_count;
+ fprintf(outputf,
+ "if ((token->type == CSS_TOKEN_IDENT) && "
+ "(lwc_string_caseless_isequal(token->idata, c->strings[CALC], &match) == lwc_error_ok && match))"
+ " {\n"
+ "\t\terror = css__parse_calc(c, vector, ctx, result, buildOPV(%s, 0, %s /* _CALC */), %s);\n"
+ "\t} else ",
+ parseid->val,
+ ckv->val,
+ ckv->key
+ );
fprintf(outputf,
"{\n"
diff --git a/src/parse/properties/utils.c b/src/parse/properties/utils.c
index 1e184f8..4739486 100644
--- a/src/parse/properties/utils.c
+++ b/src/parse/properties/utils.c
@@ -1333,3 +1333,269 @@ cleanup:
return error;
}
+
+/******************************************************************************/
+
+/* CALC
+ *
+ * calc( <calc-sum> )
+ *
+ * where
+ * <calc-sum> = <calc-product> [ [ '+' | '-' ] <calc-product> ]*
+ *
+ * where
+ * <calc-product> = <calc-value> [ '*' <calc-value> | '/' <number> ]*
+ *
+ * where
+ * <calc-value> = <number> | <dimension> | <percentage> | ( <calc-sum> )
+ *
+ *
+ * calc(10px + (4rem / 2)) =>
+ * U 10 px
+ * U 4 rem
+ * N 2
+ * /
+ * +
+ * =
+ */
+
+static css_error
+css__parse_calc_sum(css_language *c,
+ const parserutils_vector *vector, int *ctx,
+ css_style *result,
+ uint32_t unit);
+
+static css_error
+css__parse_calc_value(css_language *c,
+ const parserutils_vector *vector, int *ctx,
+ css_style *result,
+ uint32_t default_unit)
+{
+ css_error error;
+ int orig_ctx = *ctx;
+ const css_token *token;
+
+ token = parserutils_vector_iterate(vector, ctx);
+ if (tokenIsChar(token, '(')) {
+ error = css__parse_calc_sum(c, vector, ctx, result, default_unit);
+ if (error != CSS_OK) {
+ return error;
+ }
+
+ token = parserutils_vector_peek(vector, *ctx);
+ if (!tokenIsChar(token, ')')) {
+ return CSS_INVALID;
+ }
+
+ } else switch (token->type) {
+ case CSS_TOKEN_NUMBER: /* Fall through */
+ case CSS_TOKEN_DIMENSION: /* Fall through */
+ case CSS_TOKEN_PERCENTAGE:
+ {
+ css_fixed length = 0;
+ uint32_t unit = 0;
+ *ctx = orig_ctx;
+
+ error = css__parse_unit_specifier(c, vector, ctx, default_unit, &length, &unit);
+ if (error != CSS_OK) {
+ *ctx = orig_ctx;
+ return error;
+ }
+
+ error = css__stylesheet_style_vappend(result, 3, (css_code_t) 'U', length, unit);
+ }
+ break;
+
+ default:
+ error = CSS_INVALID;
+ break;
+ }
+
+ return error;
+}
+
+/* Both this, and css_parse_calc_sum must stop when it encounters a close-paren.
+ * If it hasn't had any useful tokens before that, it's an error. It does not
+ * need to restore ctx before returning an error but it does need to ensure that
+ * the close paren has not been consumed
+ */
+static css_error
+css__parse_calc_product(css_language *c,
+ const parserutils_vector *vector, int *ctx,
+ css_style *result,
+ uint32_t unit)
+{
+ css_error error = CSS_OK;
+ const css_token *token;
+ bool multiplication;
+
+
+ /* First parse a value */
+ error = css__parse_calc_value(c, vector, ctx, result, unit);
+ if (error != CSS_OK) {
+ return error;
+ }
+
+ do {
+ /* What is our next token? */
+ token = parserutils_vector_peek(vector, *ctx);
+ if (token == NULL) {
+ error = CSS_INVALID;
+ break;
+ } else if (tokenIsChar(token, ')'))
+ break;
+ else if (tokenIsChar(token, '*'))
+ multiplication = true;
+ else if (tokenIsChar(token, '/'))
+ multiplication = false;
+ else {
+ error = CSS_INVALID;
+ break;
+ }
+ /* Consume that * or / now */
+ token = parserutils_vector_iterate(vector, ctx);
+
+ if (multiplication) {
+ /* parse another value */
+ error = css__parse_calc_value(c, vector, ctx, result, unit);
+ if (error != CSS_OK)
+ break;
+ } else {
+ css_fixed num;
+ size_t consumed;
+
+ token = parserutils_vector_iterate(vector, ctx);
+ if (token->type != CSS_TOKEN_NUMBER) {
+ error = CSS_INVALID;
+ break;
+ }
+ num = css__number_from_lwc_string(token->idata, false, &consumed);
+ if (consumed != lwc_string_length(token->idata)) {
+ error = CSS_INVALID;
+ break;
+ }
+
+ error = css__stylesheet_style_append(result, (css_code_t) 'N');
+ if (error != CSS_OK)
+ break;
+ error = css__stylesheet_style_append(result, (css_code_t) num);
+ if (error != CSS_OK)
+ break;
+ }
+
+ /* emit the multiplication/division operator */
+ error = css__stylesheet_style_append(result, (css_code_t) (multiplication ? '*' : '/'));
+ } while (1);
+ /* We've fallen off, either we had an error or we're left with ')' */
+ return error;
+}
+
+
+css_error
+css__parse_calc_sum(css_language *c,
+ const parserutils_vector *vector, int *ctx,
+ css_style *result,
+ uint32_t unit)
+{
+ css_error error = CSS_OK;
+ const css_token *token;
+ bool addition;
+
+
+ /* First parse a product */
+ error = css__parse_calc_product(c, vector, ctx, result, unit);
+ if (error != CSS_OK) {
+ return error;
+ }
+
+ do {
+ /* What is our next token? */
+ token = parserutils_vector_peek(vector, *ctx);
+ if (token == NULL) {
+ error = CSS_INVALID;
+ break;
+ } else if (tokenIsChar(token, ')'))
+ break;
+ else if (tokenIsChar(token, '+'))
+ addition = true;
+ else if (tokenIsChar(token, '-'))
+ addition = false;
+ else {
+ error = CSS_INVALID;
+ break;
+ }
+ /* Consume that + or - now */
+ token = parserutils_vector_iterate(vector, ctx);
+
+ /* parse another product */
+ error = css__parse_calc_product(c, vector, ctx, result, unit);
+ if (error != CSS_OK)
+ break;
+
+ /* emit the addition/subtraction operator */
+ error = css__stylesheet_style_append(result, (css_code_t) (addition ? '+' : '-'));
+ } while (1);
+ /* We've fallen off, either we had an error or we're left with ')' */
+ return error;
+}
+
+/* Documented in utils.h */
+css_error css__parse_calc(css_language *c,
+ const parserutils_vector *vector, int *ctx,
+ css_style *result,
+ css_code_t property,
+ uint32_t unit)
+{
+ int orig_ctx = *ctx;
+ const css_token *token;
+ css_error error = CSS_OK;
+ css_style *calc_style = NULL;
+
+ token = parserutils_vector_iterate(vector, ctx);
+ if (token == NULL) {
+ *ctx = orig_ctx;
+ return CSS_INVALID;
+ }
+
+ if (!tokenIsChar(token, '(')) {
+ /* If we don't get an open-paren, give up now */
+ *ctx = orig_ctx;
+ return CSS_INVALID;
+ }
+
+ error = css__stylesheet_style_create(c->sheet, &calc_style);
+ if (error != CSS_OK)
+ goto cleanup;
+
+ error = css__stylesheet_style_append(calc_style, property);
+ if (error != CSS_OK)
+ goto cleanup;
+
+ error = css__parse_calc_sum(c, vector, ctx, calc_style, unit);
+ if (error != CSS_OK)
+ goto cleanup;
+
+ token = parserutils_vector_iterate(vector, ctx);
+ if (!tokenIsChar(token, ')')) {
+ /* If we don't get a close-paren, give up now */
+ error = CSS_INVALID;
+ goto cleanup;
+ }
+
+ /* Append the indicator that the calc is finished */
+ error = css__stylesheet_style_append(calc_style, (css_code_t) '=');
+ if (error != CSS_OK)
+ goto cleanup;
+
+ /* TODO: Once we're OK to do so, merge the style */
+ (void)result;
+ /* error = css__stylesheet_style_merge_style(result, calc_style); */
+
+cleanup:
+ css__stylesheet_style_destroy(calc_style);
+ if (error != CSS_OK) {
+ *ctx = orig_ctx;
+ }
+
+ return error;
+}
diff --git a/src/parse/properties/utils.h b/src/parse/properties/utils.h
index 54a3fd1..02cb220 100644
--- a/src/parse/properties/utils.h
+++ b/src/parse/properties/utils.h
@@ -228,4 +228,28 @@ css_error css__comma_list_to_style(css_language *c,
bool first),
css_style *result);
+/**
+ * Parse a CSS calc() invocation
+ *
+ * Calc can generate a number of kinds of units, so we have to tell the
+ * parser the kind of unit we're aiming for (e.g. UNIT_PX, UNIT_ANGLE, etc.)
+ *
+ * \param[in] c Parsing context
+ * \param[in] vector Vector of tokens to process
+ * \param[in] ctx Pointer to vector iteration context
+ * \param[in] result Pointer to location to receive resulting style
+ * \param[in] property The CSS property we are calculating for
+ * \param[in] unit The kind of unit which we want to come out of this calc()
+ * \return CSS_OK on success,
+ * CSS_NOMEM on memory exhaustion,
+ CSS_INVALID if the input is not valid
+ *
+ * Post condition: \a *ctx is updated with the next token to process
+ * If the input is invalid, then \a *ctx remains unchanged.
+ */
+css_error css__parse_calc(css_language *c,
+ const parserutils_vector *vector, int *ctx,
+ css_style *result,
+ css_code_t property,
+ uint32_t unit);
#endif
diff --git a/src/parse/propstrings.c b/src/parse/propstrings.c
index 786a3b7..aa44333 100644
--- a/src/parse/propstrings.c
+++ b/src/parse/propstrings.c
@@ -489,6 +489,7 @@ const stringmap_entry stringmap[LAST_KNOWN] = {
SMAP("grid"),
SMAP("inline-grid"),
SMAP("sticky"),
+ SMAP("calc"),
SMAP("aliceblue"),
SMAP("antiquewhite"),
diff --git a/src/parse/propstrings.h b/src/parse/propstrings.h
index 6d6dd49..80f75c8 100644
--- a/src/parse/propstrings.h
+++ b/src/parse/propstrings.h
@@ -109,7 +109,7 @@ enum {
VERTICAL_LR, CONTENT_BOX, BORDER_BOX, STRETCH, INLINE_FLEX, FLEX_START,
FLEX_END, SPACE_BETWEEN, SPACE_AROUND, SPACE_EVENLY, ROW, ROW_REVERSE,
COLUMN_REVERSE, WRAP_STRING, WRAP_REVERSE, AND, OR, ONLY, INFINITE,
- GRID, INLINE_GRID, STICKY,
+ GRID, INLINE_GRID, STICKY, CALC,
/* Named colours */
FIRST_COLOUR,
-----------------------------------------------------------------------
Summary of changes:
src/select/autogenerated_propget.h | 1035 ++++++++++++++++++++++++++++++++++--
src/select/computed.c | 2 +-
src/select/overrides.py | 32 --
src/select/select_generator.py | 92 ++--
test/dump_computed.h | 3 +
5 files changed, 1042 insertions(+), 122 deletions(-)
diff --git a/src/select/autogenerated_propget.h b/src/select/autogenerated_propget.h
index 2751a18..ef2d74e 100644
--- a/src/select/autogenerated_propget.h
+++ b/src/select/autogenerated_propget.h
@@ -9,6 +9,15 @@
#define ALIGN_CONTENT_INDEX 10
#define ALIGN_CONTENT_SHIFT 20
#define ALIGN_CONTENT_MASK 0x700000
+static inline uint8_t get_align_content_bits(const css_computed_style *style)
+{
+ uint32_t bits = style->i.bits[ALIGN_CONTENT_INDEX];
+ bits &= ALIGN_CONTENT_MASK;
+ bits >>= ALIGN_CONTENT_SHIFT;
+
+ /* 3bits: ttt : type */
+ return (bits & 0x7);
+}
static inline uint8_t get_align_content(const css_computed_style *style)
{
uint32_t bits = style->i.bits[ALIGN_CONTENT_INDEX];
@@ -26,6 +35,15 @@ static inline uint8_t get_align_content(const css_computed_style *style)
#define ALIGN_ITEMS_INDEX 10
#define ALIGN_ITEMS_SHIFT 23
#define ALIGN_ITEMS_MASK 0x3800000
+static inline uint8_t get_align_items_bits(const css_computed_style *style)
+{
+ uint32_t bits = style->i.bits[ALIGN_ITEMS_INDEX];
+ bits &= ALIGN_ITEMS_MASK;
+ bits >>= ALIGN_ITEMS_SHIFT;
+
+ /* 3bits: ttt : type */
+ return (bits & 0x7);
+}
static inline uint8_t get_align_items(const css_computed_style *style)
{
uint32_t bits = style->i.bits[ALIGN_ITEMS_INDEX];
@@ -43,6 +61,15 @@ static inline uint8_t get_align_items(const css_computed_style *style)
#define ALIGN_SELF_INDEX 10
#define ALIGN_SELF_SHIFT 26
#define ALIGN_SELF_MASK 0x1c000000
+static inline uint8_t get_align_self_bits(const css_computed_style *style)
+{
+ uint32_t bits = style->i.bits[ALIGN_SELF_INDEX];
+ bits &= ALIGN_SELF_MASK;
+ bits >>= ALIGN_SELF_SHIFT;
+
+ /* 3bits: ttt : type */
+ return (bits & 0x7);
+}
static inline uint8_t get_align_self(const css_computed_style *style)
{
uint32_t bits = style->i.bits[ALIGN_SELF_INDEX];
@@ -60,6 +87,16 @@ static inline uint8_t get_align_self(const css_computed_style *style)
#define BACKGROUND_ATTACHMENT_INDEX 14
#define BACKGROUND_ATTACHMENT_SHIFT 28
#define BACKGROUND_ATTACHMENT_MASK 0x30000000
+static inline uint8_t get_background_attachment_bits(const css_computed_style
+ *style)
+{
+ uint32_t bits = style->i.bits[BACKGROUND_ATTACHMENT_INDEX];
+ bits &= BACKGROUND_ATTACHMENT_MASK;
+ bits >>= BACKGROUND_ATTACHMENT_SHIFT;
+
+ /* 2bits: tt : type */
+ return (bits & 0x3);
+}
static inline uint8_t get_background_attachment(const css_computed_style *style)
{
uint32_t bits = style->i.bits[BACKGROUND_ATTACHMENT_INDEX];
@@ -77,6 +114,15 @@ static inline uint8_t get_background_attachment(const css_computed_style *style)
#define BACKGROUND_COLOR_INDEX 14
#define BACKGROUND_COLOR_SHIFT 30
#define BACKGROUND_COLOR_MASK 0xc0000000
+static inline uint8_t get_background_color_bits(const css_computed_style *style)
+{
+ uint32_t bits = style->i.bits[BACKGROUND_COLOR_INDEX];
+ bits &= BACKGROUND_COLOR_MASK;
+ bits >>= BACKGROUND_COLOR_SHIFT;
+
+ /* 2bits: tt : type */
+ return (bits & 0x3);
+}
static inline uint8_t get_background_color(const css_computed_style *style,
css_color *color)
{
@@ -96,6 +142,15 @@ static inline uint8_t get_background_color(const css_computed_style *style,
#define BACKGROUND_IMAGE_INDEX 14
#define BACKGROUND_IMAGE_SHIFT 18
#define BACKGROUND_IMAGE_MASK 0x40000
+static inline uint8_t get_background_image_bits(const css_computed_style *style)
+{
+ uint32_t bits = style->i.bits[BACKGROUND_IMAGE_INDEX];
+ bits &= BACKGROUND_IMAGE_MASK;
+ bits >>= BACKGROUND_IMAGE_SHIFT;
+
+ /* 1bit: t : type */
+ return (bits & 0x1);
+}
static inline uint8_t get_background_image(const css_computed_style *style,
lwc_string **string)
{
@@ -115,6 +170,16 @@ static inline uint8_t get_background_image(const css_computed_style *style,
#define BACKGROUND_POSITION_INDEX 12
#define BACKGROUND_POSITION_SHIFT 10
#define BACKGROUND_POSITION_MASK 0x1ffc00
+static inline uint8_t get_background_position_bits(const css_computed_style
+ *style)
+{
+ uint32_t bits = style->i.bits[BACKGROUND_POSITION_INDEX];
+ bits &= BACKGROUND_POSITION_MASK;
+ bits >>= BACKGROUND_POSITION_SHIFT;
+
+ /* 11bits: aaaaabbbbbt : unit_a | unit_b | type */
+ return (bits & 0x1);
+}
static inline uint8_t get_background_position(const css_computed_style *style,
css_fixed *length_a, css_unit *unit_a, css_fixed *length_b,
css_unit *unit_b)
@@ -140,6 +205,16 @@ static inline uint8_t get_background_position(const css_computed_style *style,
#define BACKGROUND_REPEAT_INDEX 10
#define BACKGROUND_REPEAT_SHIFT 29
#define BACKGROUND_REPEAT_MASK 0xe0000000
+static inline uint8_t get_background_repeat_bits(const css_computed_style
+ *style)
+{
+ uint32_t bits = style->i.bits[BACKGROUND_REPEAT_INDEX];
+ bits &= BACKGROUND_REPEAT_MASK;
+ bits >>= BACKGROUND_REPEAT_SHIFT;
+
+ /* 3bits: ttt : type */
+ return (bits & 0x7);
+}
static inline uint8_t get_background_repeat(const css_computed_style *style)
{
uint32_t bits = style->i.bits[BACKGROUND_REPEAT_INDEX];
@@ -157,6 +232,16 @@ static inline uint8_t get_background_repeat(const css_computed_style *style)
#define BORDER_BOTTOM_COLOR_INDEX 11
#define BORDER_BOTTOM_COLOR_SHIFT 0
#define BORDER_BOTTOM_COLOR_MASK 0x3
+static inline uint8_t get_border_bottom_color_bits(const css_computed_style
+ *style)
+{
+ uint32_t bits = style->i.bits[BORDER_BOTTOM_COLOR_INDEX];
+ bits &= BORDER_BOTTOM_COLOR_MASK;
+ bits >>= BORDER_BOTTOM_COLOR_SHIFT;
+
+ /* 2bits: tt : type */
+ return (bits & 0x3);
+}
static inline uint8_t get_border_bottom_color(const css_computed_style *style,
css_color *color)
{
@@ -176,6 +261,16 @@ static inline uint8_t get_border_bottom_color(const css_computed_style *style,
#define BORDER_BOTTOM_STYLE_INDEX 13
#define BORDER_BOTTOM_STYLE_SHIFT 28
#define BORDER_BOTTOM_STYLE_MASK 0xf0000000
+static inline uint8_t get_border_bottom_style_bits(const css_computed_style
+ *style)
+{
+ uint32_t bits = style->i.bits[BORDER_BOTTOM_STYLE_INDEX];
+ bits &= BORDER_BOTTOM_STYLE_MASK;
+ bits >>= BORDER_BOTTOM_STYLE_SHIFT;
+
+ /* 4bits: tttt : type */
+ return (bits & 0xf);
+}
static inline uint8_t get_border_bottom_style(const css_computed_style *style)
{
uint32_t bits = style->i.bits[BORDER_BOTTOM_STYLE_INDEX];
@@ -193,6 +288,16 @@ static inline uint8_t get_border_bottom_style(const css_computed_style *style)
#define BORDER_BOTTOM_WIDTH_INDEX 0
#define BORDER_BOTTOM_WIDTH_SHIFT 0
#define BORDER_BOTTOM_WIDTH_MASK 0xff
+static inline uint8_t get_border_bottom_width_bits(const css_computed_style
+ *style)
+{
+ uint32_t bits = style->i.bits[BORDER_BOTTOM_WIDTH_INDEX];
+ bits &= BORDER_BOTTOM_WIDTH_MASK;
+ bits >>= BORDER_BOTTOM_WIDTH_SHIFT;
+
+ /* 8bits: uuuuuttt : unit | type */
+ return (bits & 0x7);
+}
static inline uint8_t get_border_bottom_width(const css_computed_style *style,
css_fixed *length, css_unit *unit)
{
@@ -215,6 +320,15 @@ static inline uint8_t get_border_bottom_width(const css_computed_style *style,
#define BORDER_COLLAPSE_INDEX 11
#define BORDER_COLLAPSE_SHIFT 2
#define BORDER_COLLAPSE_MASK 0xc
+static inline uint8_t get_border_collapse_bits(const css_computed_style *style)
+{
+ uint32_t bits = style->i.bits[BORDER_COLLAPSE_INDEX];
+ bits &= BORDER_COLLAPSE_MASK;
+ bits >>= BORDER_COLLAPSE_SHIFT;
+
+ /* 2bits: tt : type */
+ return (bits & 0x3);
+}
static inline uint8_t get_border_collapse(const css_computed_style *style)
{
uint32_t bits = style->i.bits[BORDER_COLLAPSE_INDEX];
@@ -232,6 +346,16 @@ static inline uint8_t get_border_collapse(const css_computed_style *style)
#define BORDER_LEFT_COLOR_INDEX 11
#define BORDER_LEFT_COLOR_SHIFT 4
#define BORDER_LEFT_COLOR_MASK 0x30
+static inline uint8_t get_border_left_color_bits(const css_computed_style
+ *style)
+{
+ uint32_t bits = style->i.bits[BORDER_LEFT_COLOR_INDEX];
+ bits &= BORDER_LEFT_COLOR_MASK;
+ bits >>= BORDER_LEFT_COLOR_SHIFT;
+
+ /* 2bits: tt : type */
+ return (bits & 0x3);
+}
static inline uint8_t get_border_left_color(const css_computed_style *style,
css_color *color)
{
@@ -251,6 +375,16 @@ static inline uint8_t get_border_left_color(const css_computed_style *style,
#define BORDER_LEFT_STYLE_INDEX 9
#define BORDER_LEFT_STYLE_SHIFT 3
#define BORDER_LEFT_STYLE_MASK 0x78
+static inline uint8_t get_border_left_style_bits(const css_computed_style
+ *style)
+{
+ uint32_t bits = style->i.bits[BORDER_LEFT_STYLE_INDEX];
+ bits &= BORDER_LEFT_STYLE_MASK;
+ bits >>= BORDER_LEFT_STYLE_SHIFT;
+
+ /* 4bits: tttt : type */
+ return (bits & 0xf);
+}
static inline uint8_t get_border_left_style(const css_computed_style *style)
{
uint32_t bits = style->i.bits[BORDER_LEFT_STYLE_INDEX];
@@ -268,6 +402,16 @@ static inline uint8_t get_border_left_style(const css_computed_style *style)
#define BORDER_LEFT_WIDTH_INDEX 0
#define BORDER_LEFT_WIDTH_SHIFT 8
#define BORDER_LEFT_WIDTH_MASK 0xff00
+static inline uint8_t get_border_left_width_bits(const css_computed_style
+ *style)
+{
+ uint32_t bits = style->i.bits[BORDER_LEFT_WIDTH_INDEX];
+ bits &= BORDER_LEFT_WIDTH_MASK;
+ bits >>= BORDER_LEFT_WIDTH_SHIFT;
+
+ /* 8bits: uuuuuttt : unit | type */
+ return (bits & 0x7);
+}
static inline uint8_t get_border_left_width(const css_computed_style *style,
css_fixed *length, css_unit *unit)
{
@@ -290,6 +434,16 @@ static inline uint8_t get_border_left_width(const css_computed_style *style,
#define BORDER_RIGHT_COLOR_INDEX 11
#define BORDER_RIGHT_COLOR_SHIFT 6
#define BORDER_RIGHT_COLOR_MASK 0xc0
+static inline uint8_t get_border_right_color_bits(const css_computed_style
+ *style)
+{
+ uint32_t bits = style->i.bits[BORDER_RIGHT_COLOR_INDEX];
+ bits &= BORDER_RIGHT_COLOR_MASK;
+ bits >>= BORDER_RIGHT_COLOR_SHIFT;
+
+ /* 2bits: tt : type */
+ return (bits & 0x3);
+}
static inline uint8_t get_border_right_color(const css_computed_style *style,
css_color *color)
{
@@ -309,6 +463,16 @@ static inline uint8_t get_border_right_color(const css_computed_style *style,
#define BORDER_RIGHT_STYLE_INDEX 9
#define BORDER_RIGHT_STYLE_SHIFT 7
#define BORDER_RIGHT_STYLE_MASK 0x780
+static inline uint8_t get_border_right_style_bits(const css_computed_style
+ *style)
+{
+ uint32_t bits = style->i.bits[BORDER_RIGHT_STYLE_INDEX];
+ bits &= BORDER_RIGHT_STYLE_MASK;
+ bits >>= BORDER_RIGHT_STYLE_SHIFT;
+
+ /* 4bits: tttt : type */
+ return (bits & 0xf);
+}
static inline uint8_t get_border_right_style(const css_computed_style *style)
{
uint32_t bits = style->i.bits[BORDER_RIGHT_STYLE_INDEX];
@@ -326,6 +490,16 @@ static inline uint8_t get_border_right_style(const css_computed_style *style)
#define BORDER_RIGHT_WIDTH_INDEX 0
#define BORDER_RIGHT_WIDTH_SHIFT 16
#define BORDER_RIGHT_WIDTH_MASK 0xff0000
+static inline uint8_t get_border_right_width_bits(const css_computed_style
+ *style)
+{
+ uint32_t bits = style->i.bits[BORDER_RIGHT_WIDTH_INDEX];
+ bits &= BORDER_RIGHT_WIDTH_MASK;
+ bits >>= BORDER_RIGHT_WIDTH_SHIFT;
+
+ /* 8bits: uuuuuttt : unit | type */
+ return (bits & 0x7);
+}
static inline uint8_t get_border_right_width(const css_computed_style *style,
css_fixed *length, css_unit *unit)
{
@@ -348,6 +522,15 @@ static inline uint8_t get_border_right_width(const css_computed_style *style,
#define BORDER_SPACING_INDEX 12
#define BORDER_SPACING_SHIFT 21
#define BORDER_SPACING_MASK 0xffe00000
+static inline uint8_t get_border_spacing_bits(const css_computed_style *style)
+{
+ uint32_t bits = style->i.bits[BORDER_SPACING_INDEX];
+ bits &= BORDER_SPACING_MASK;
+ bits >>= BORDER_SPACING_SHIFT;
+
+ /* 11bits: aaaaabbbbbt : unit_a | unit_b | type */
+ return (bits & 0x1);
+}
static inline uint8_t get_border_spacing(const css_computed_style *style,
css_fixed *length_a, css_unit *unit_a, css_fixed *length_b,
css_unit *unit_b)
@@ -373,6 +556,15 @@ static inline uint8_t get_border_spacing(const css_computed_style *style,
#define BORDER_TOP_COLOR_INDEX 11
#define BORDER_TOP_COLOR_SHIFT 8
#define BORDER_TOP_COLOR_MASK 0x300
+static inline uint8_t get_border_top_color_bits(const css_computed_style *style)
+{
+ uint32_t bits = style->i.bits[BORDER_TOP_COLOR_INDEX];
+ bits &= BORDER_TOP_COLOR_MASK;
+ bits >>= BORDER_TOP_COLOR_SHIFT;
+
+ /* 2bits: tt : type */
+ return (bits & 0x3);
+}
static inline uint8_t get_border_top_color(const css_computed_style *style,
css_color *color)
{
@@ -392,6 +584,15 @@ static inline uint8_t get_border_top_color(const css_computed_style *style,
#define BORDER_TOP_STYLE_INDEX 9
#define BORDER_TOP_STYLE_SHIFT 11
#define BORDER_TOP_STYLE_MASK 0x7800
+static inline uint8_t get_border_top_style_bits(const css_computed_style *style)
+{
+ uint32_t bits = style->i.bits[BORDER_TOP_STYLE_INDEX];
+ bits &= BORDER_TOP_STYLE_MASK;
+ bits >>= BORDER_TOP_STYLE_SHIFT;
+
+ /* 4bits: tttt : type */
+ return (bits & 0xf);
+}
static inline uint8_t get_border_top_style(const css_computed_style *style)
{
uint32_t bits = style->i.bits[BORDER_TOP_STYLE_INDEX];
@@ -409,6 +610,15 @@ static inline uint8_t get_border_top_style(const css_computed_style *style)
#define BORDER_TOP_WIDTH_INDEX 0
#define BORDER_TOP_WIDTH_SHIFT 24
#define BORDER_TOP_WIDTH_MASK 0xff000000
+static inline uint8_t get_border_top_width_bits(const css_computed_style *style)
+{
+ uint32_t bits = style->i.bits[BORDER_TOP_WIDTH_INDEX];
+ bits &= BORDER_TOP_WIDTH_MASK;
+ bits >>= BORDER_TOP_WIDTH_SHIFT;
+
+ /* 8bits: uuuuuttt : unit | type */
+ return (bits & 0x7);
+}
static inline uint8_t get_border_top_width(const css_computed_style *style,
css_fixed *length, css_unit *unit)
{
@@ -431,6 +641,15 @@ static inline uint8_t get_border_top_width(const css_computed_style *style,
#define BOTTOM_INDEX 3
#define BOTTOM_SHIFT 11
#define BOTTOM_MASK 0x3f800
+static inline uint8_t get_bottom_bits(const css_computed_style *style)
+{
+ uint32_t bits = style->i.bits[BOTTOM_INDEX];
+ bits &= BOTTOM_MASK;
+ bits >>= BOTTOM_SHIFT;
+
+ /* 7bits: uuuuutt : unit | type */
+ return (bits & 0x3);
+}
static inline uint8_t get_bottom(const css_computed_style *style, css_fixed
*length, css_unit *unit)
{
@@ -453,6 +672,15 @@ static inline uint8_t get_bottom(const css_computed_style *style, css_fixed
#define BOX_SIZING_INDEX 11
#define BOX_SIZING_SHIFT 10
#define BOX_SIZING_MASK 0xc00
+static inline uint8_t get_box_sizing_bits(const css_computed_style *style)
+{
+ uint32_t bits = style->i.bits[BOX_SIZING_INDEX];
+ bits &= BOX_SIZING_MASK;
+ bits >>= BOX_SIZING_SHIFT;
+
+ /* 2bits: tt : type */
+ return (bits & 0x3);
+}
static inline uint8_t get_box_sizing(const css_computed_style *style)
{
uint32_t bits = style->i.bits[BOX_SIZING_INDEX];
@@ -470,6 +698,15 @@ static inline uint8_t get_box_sizing(const css_computed_style *style)
#define BREAK_AFTER_INDEX 9
#define BREAK_AFTER_SHIFT 15
#define BREAK_AFTER_MASK 0x78000
+static inline uint8_t get_break_after_bits(const css_computed_style *style)
+{
+ uint32_t bits = style->i.bits[BREAK_AFTER_INDEX];
+ bits &= BREAK_AFTER_MASK;
+ bits >>= BREAK_AFTER_SHIFT;
+
+ /* 4bits: tttt : type */
+ return (bits & 0xf);
+}
static inline uint8_t get_break_after(const css_computed_style *style)
{
uint32_t bits = style->i.bits[BREAK_AFTER_INDEX];
@@ -487,6 +724,15 @@ static inline uint8_t get_break_after(const css_computed_style *style)
#define BREAK_BEFORE_INDEX 9
#define BREAK_BEFORE_SHIFT 19
#define BREAK_BEFORE_MASK 0x780000
+static inline uint8_t get_break_before_bits(const css_computed_style *style)
+{
+ uint32_t bits = style->i.bits[BREAK_BEFORE_INDEX];
+ bits &= BREAK_BEFORE_MASK;
+ bits >>= BREAK_BEFORE_SHIFT;
+
+ /* 4bits: tttt : type */
+ return (bits & 0xf);
+}
static inline uint8_t get_break_before(const css_computed_style *style)
{
uint32_t bits = style->i.bits[BREAK_BEFORE_INDEX];
@@ -504,6 +750,15 @@ static inline uint8_t get_break_before(const css_computed_style *style)
#define BREAK_INSIDE_INDEX 9
#define BREAK_INSIDE_SHIFT 23
#define BREAK_INSIDE_MASK 0x7800000
+static inline uint8_t get_break_inside_bits(const css_computed_style *style)
+{
+ uint32_t bits = style->i.bits[BREAK_INSIDE_INDEX];
+ bits &= BREAK_INSIDE_MASK;
+ bits >>= BREAK_INSIDE_SHIFT;
+
+ /* 4bits: tttt : type */
+ return (bits & 0xf);
+}
static inline uint8_t get_break_inside(const css_computed_style *style)
{
uint32_t bits = style->i.bits[BREAK_INSIDE_INDEX];
@@ -521,6 +776,15 @@ static inline uint8_t get_break_inside(const css_computed_style *style)
#define CAPTION_SIDE_INDEX 11
#define CAPTION_SIDE_SHIFT 12
#define CAPTION_SIDE_MASK 0x3000
+static inline uint8_t get_caption_side_bits(const css_computed_style *style)
+{
+ uint32_t bits = style->i.bits[CAPTION_SIDE_INDEX];
+ bits &= CAPTION_SIDE_MASK;
+ bits >>= CAPTION_SIDE_SHIFT;
+
+ /* 2bits: tt : type */
+ return (bits & 0x3);
+}
static inline uint8_t get_caption_side(const css_computed_style *style)
{
uint32_t bits = style->i.bits[CAPTION_SIDE_INDEX];
@@ -538,6 +802,15 @@ static inline uint8_t get_caption_side(const css_computed_style *style)
#define CLEAR_INDEX 13
#define CLEAR_SHIFT 1
#define CLEAR_MASK 0xe
+static inline uint8_t get_clear_bits(const css_computed_style *style)
+{
+ uint32_t bits = style->i.bits[CLEAR_INDEX];
+ bits &= CLEAR_MASK;
+ bits >>= CLEAR_SHIFT;
+
+ /* 3bits: ttt : type */
+ return (bits & 0x7);
+}
static inline uint8_t get_clear(const css_computed_style *style)
{
uint32_t bits = style->i.bits[CLEAR_INDEX];
@@ -555,6 +828,16 @@ static inline uint8_t get_clear(const css_computed_style *style)
#define CLIP_INDEX 2
#define CLIP_SHIFT 6
#define CLIP_MASK 0xffffffc0
+static inline uint8_t get_clip_bits(const css_computed_style *style)
+{
+ uint32_t bits = style->i.bits[CLIP_INDEX];
+ bits &= CLIP_MASK;
+ bits >>= CLIP_SHIFT;
+
+ /* 26bits: aaaaabbbbbcccccdddddtttttt : unit_a | unit_b | unit_c |
+ unit_d | type */
+ return (bits & 0x3f);
+}
static inline uint8_t get_clip(
const css_computed_style *style,
css_computed_clip_rect *rect)
@@ -597,6 +880,15 @@ static inline uint8_t get_clip(
#define COLOR_INDEX 14
#define COLOR_SHIFT 19
#define COLOR_MASK 0x80000
+static inline uint8_t get_color_bits(const css_computed_style *style)
+{
+ uint32_t bits = style->i.bits[COLOR_INDEX];
+ bits &= COLOR_MASK;
+ bits >>= COLOR_SHIFT;
+
+ /* 1bit: t : type */
+ return (bits & 0x1);
+}
static inline uint8_t get_color(const css_computed_style *style, css_color
*color)
{
@@ -616,6 +908,15 @@ static inline uint8_t get_color(const css_computed_style *style, css_color
#define COLUMN_COUNT_INDEX 11
#define COLUMN_COUNT_SHIFT 14
#define COLUMN_COUNT_MASK 0xc000
+static inline uint8_t get_column_count_bits(const css_computed_style *style)
+{
+ uint32_t bits = style->i.bits[COLUMN_COUNT_INDEX];
+ bits &= COLUMN_COUNT_MASK;
+ bits >>= COLUMN_COUNT_SHIFT;
+
+ /* 2bits: tt : type */
+ return (bits & 0x3);
+}
static inline uint8_t get_column_count(const css_computed_style *style, int32_t
*integer)
{
@@ -635,7 +936,16 @@ static inline uint8_t get_column_count(const css_computed_style *style, int32_t
#define COLUMN_FILL_INDEX 11
#define COLUMN_FILL_SHIFT 16
#define COLUMN_FILL_MASK 0x30000
-static inline uint8_t get_column_fill(const css_computed_style *style)
+static inline uint8_t get_column_fill_bits(const css_computed_style *style)
+{
+ uint32_t bits = style->i.bits[COLUMN_FILL_INDEX];
+ bits &= COLUMN_FILL_MASK;
+ bits >>= COLUMN_FILL_SHIFT;
+
+ /* 2bits: tt : type */
+ return (bits & 0x3);
+}
+static inline uint8_t get_column_fill(const css_computed_style *style)
{
uint32_t bits = style->i.bits[COLUMN_FILL_INDEX];
bits &= COLUMN_FILL_MASK;
@@ -652,6 +962,15 @@ static inline uint8_t get_column_fill(const css_computed_style *style)
#define COLUMN_GAP_INDEX 3
#define COLUMN_GAP_SHIFT 18
#define COLUMN_GAP_MASK 0x1fc0000
+static inline uint8_t get_column_gap_bits(const css_computed_style *style)
+{
+ uint32_t bits = style->i.bits[COLUMN_GAP_INDEX];
+ bits &= COLUMN_GAP_MASK;
+ bits >>= COLUMN_GAP_SHIFT;
+
+ /* 7bits: uuuuutt : unit | type */
+ return (bits & 0x3);
+}
static inline uint8_t get_column_gap(const css_computed_style *style, css_fixed
*length, css_unit *unit)
{
@@ -674,6 +993,16 @@ static inline uint8_t get_column_gap(const css_computed_style *style, css_fixed
#define COLUMN_RULE_COLOR_INDEX 11
#define COLUMN_RULE_COLOR_SHIFT 18
#define COLUMN_RULE_COLOR_MASK 0xc0000
+static inline uint8_t get_column_rule_color_bits(const css_computed_style
+ *style)
+{
+ uint32_t bits = style->i.bits[COLUMN_RULE_COLOR_INDEX];
+ bits &= COLUMN_RULE_COLOR_MASK;
+ bits >>= COLUMN_RULE_COLOR_SHIFT;
+
+ /* 2bits: tt : type */
+ return (bits & 0x3);
+}
static inline uint8_t get_column_rule_color(const css_computed_style *style,
css_color *color)
{
@@ -693,6 +1022,16 @@ static inline uint8_t get_column_rule_color(const css_computed_style *style,
#define COLUMN_RULE_STYLE_INDEX 7
#define COLUMN_RULE_STYLE_SHIFT 0
#define COLUMN_RULE_STYLE_MASK 0xf
+static inline uint8_t get_column_rule_style_bits(const css_computed_style
+ *style)
+{
+ uint32_t bits = style->i.bits[COLUMN_RULE_STYLE_INDEX];
+ bits &= COLUMN_RULE_STYLE_MASK;
+ bits >>= COLUMN_RULE_STYLE_SHIFT;
+
+ /* 4bits: tttt : type */
+ return (bits & 0xf);
+}
static inline uint8_t get_column_rule_style(const css_computed_style *style)
{
uint32_t bits = style->i.bits[COLUMN_RULE_STYLE_INDEX];
@@ -710,6 +1049,16 @@ static inline uint8_t get_column_rule_style(const css_computed_style *style)
#define COLUMN_RULE_WIDTH_INDEX 1
#define COLUMN_RULE_WIDTH_SHIFT 7
#define COLUMN_RULE_WIDTH_MASK 0x7f80
+static inline uint8_t get_column_rule_width_bits(const css_computed_style
+ *style)
+{
+ uint32_t bits = style->i.bits[COLUMN_RULE_WIDTH_INDEX];
+ bits &= COLUMN_RULE_WIDTH_MASK;
+ bits >>= COLUMN_RULE_WIDTH_SHIFT;
+
+ /* 8bits: uuuuuttt : unit | type */
+ return (bits & 0x7);
+}
static inline uint8_t get_column_rule_width(const css_computed_style *style,
css_fixed *length, css_unit *unit)
{
@@ -732,6 +1081,15 @@ static inline uint8_t get_column_rule_width(const css_computed_style *style,
#define COLUMN_SPAN_INDEX 11
#define COLUMN_SPAN_SHIFT 20
#define COLUMN_SPAN_MASK 0x300000
+static inline uint8_t get_column_span_bits(const css_computed_style *style)
+{
+ uint32_t bits = style->i.bits[COLUMN_SPAN_INDEX];
+ bits &= COLUMN_SPAN_MASK;
+ bits >>= COLUMN_SPAN_SHIFT;
+
+ /* 2bits: tt : type */
+ return (bits & 0x3);
+}
static inline uint8_t get_column_span(const css_computed_style *style)
{
uint32_t bits = style->i.bits[COLUMN_SPAN_INDEX];
@@ -749,6 +1107,15 @@ static inline uint8_t get_column_span(const css_computed_style *style)
#define COLUMN_WIDTH_INDEX 3
#define COLUMN_WIDTH_SHIFT 25
#define COLUMN_WIDTH_MASK 0xfe000000
+static inline uint8_t get_column_width_bits(const css_computed_style *style)
+{
+ uint32_t bits = style->i.bits[COLUMN_WIDTH_INDEX];
+ bits &= COLUMN_WIDTH_MASK;
+ bits >>= COLUMN_WIDTH_SHIFT;
+
+ /* 7bits: uuuuutt : unit | type */
+ return (bits & 0x3);
+}
static inline uint8_t get_column_width(const css_computed_style *style,
css_fixed *length, css_unit *unit)
{
@@ -771,6 +1138,15 @@ static inline uint8_t get_column_width(const css_computed_style *style,
#define CONTENT_INDEX 11
#define CONTENT_SHIFT 22
#define CONTENT_MASK 0xc00000
+static inline uint8_t get_content_bits(const css_computed_style *style)
+{
+ uint32_t bits = style->i.bits[CONTENT_INDEX];
+ bits &= CONTENT_MASK;
+ bits >>= CONTENT_SHIFT;
+
+ /* 2bits: tt : type */
+ return (bits & 0x3);
+}
static inline uint8_t get_content(const css_computed_style *style, const
css_computed_content_item **content_item)
{
@@ -792,6 +1168,16 @@ static inline uint8_t get_content(const css_computed_style *style, const
#define COUNTER_INCREMENT_INDEX 14
#define COUNTER_INCREMENT_SHIFT 20
#define COUNTER_INCREMENT_MASK 0x100000
+static inline uint8_t get_counter_increment_bits(const css_computed_style
+ *style)
+{
+ uint32_t bits = style->i.bits[COUNTER_INCREMENT_INDEX];
+ bits &= COUNTER_INCREMENT_MASK;
+ bits >>= COUNTER_INCREMENT_SHIFT;
+
+ /* 1bit: t : type */
+ return (bits & 0x1);
+}
static inline uint8_t get_counter_increment(const css_computed_style *style,
const css_computed_counter **counter_arr)
{
@@ -811,6 +1197,15 @@ static inline uint8_t get_counter_increment(const css_computed_style *style,
#define COUNTER_RESET_INDEX 14
#define COUNTER_RESET_SHIFT 21
#define COUNTER_RESET_MASK 0x200000
+static inline uint8_t get_counter_reset_bits(const css_computed_style *style)
+{
+ uint32_t bits = style->i.bits[COUNTER_RESET_INDEX];
+ bits &= COUNTER_RESET_MASK;
+ bits >>= COUNTER_RESET_SHIFT;
+
+ /* 1bit: t : type */
+ return (bits & 0x1);
+}
static inline uint8_t get_counter_reset(const css_computed_style *style, const
css_computed_counter **counter_arr)
{
@@ -830,6 +1225,15 @@ static inline uint8_t get_counter_reset(const css_computed_style *style, const
#define CURSOR_INDEX 9
#define CURSOR_SHIFT 27
#define CURSOR_MASK 0xf8000000
+static inline uint8_t get_cursor_bits(const css_computed_style *style)
+{
+ uint32_t bits = style->i.bits[CURSOR_INDEX];
+ bits &= CURSOR_MASK;
+ bits >>= CURSOR_SHIFT;
+
+ /* 5bits: ttttt : type */
+ return (bits & 0x1f);
+}
static inline uint8_t get_cursor(const css_computed_style *style, lwc_string
***string_arr)
{
@@ -849,6 +1253,15 @@ static inline uint8_t get_cursor(const css_computed_style *style, lwc_string
#define DIRECTION_INDEX 11
#define DIRECTION_SHIFT 24
#define DIRECTION_MASK 0x3000000
+static inline uint8_t get_direction_bits(const css_computed_style *style)
+{
+ uint32_t bits = style->i.bits[DIRECTION_INDEX];
+ bits &= DIRECTION_MASK;
+ bits >>= DIRECTION_SHIFT;
+
+ /* 2bits: tt : type */
+ return (bits & 0x3);
+}
static inline uint8_t get_direction(const css_computed_style *style)
{
uint32_t bits = style->i.bits[DIRECTION_INDEX];
@@ -866,6 +1279,15 @@ static inline uint8_t get_direction(const css_computed_style *style)
#define DISPLAY_INDEX 8
#define DISPLAY_SHIFT 3
#define DISPLAY_MASK 0xf8
+static inline uint8_t get_display_bits(const css_computed_style *style)
+{
+ uint32_t bits = style->i.bits[DISPLAY_INDEX];
+ bits &= DISPLAY_MASK;
+ bits >>= DISPLAY_SHIFT;
+
+ /* 5bits: ttttt : type */
+ return (bits & 0x1f);
+}
static inline uint8_t get_display(const css_computed_style *style)
{
uint32_t bits = style->i.bits[DISPLAY_INDEX];
@@ -883,6 +1305,15 @@ static inline uint8_t get_display(const css_computed_style *style)
#define EMPTY_CELLS_INDEX 11
#define EMPTY_CELLS_SHIFT 26
#define EMPTY_CELLS_MASK 0xc000000
+static inline uint8_t get_empty_cells_bits(const css_computed_style *style)
+{
+ uint32_t bits = style->i.bits[EMPTY_CELLS_INDEX];
+ bits &= EMPTY_CELLS_MASK;
+ bits >>= EMPTY_CELLS_SHIFT;
+
+ /* 2bits: tt : type */
+ return (bits & 0x3);
+}
static inline uint8_t get_empty_cells(const css_computed_style *style)
{
uint32_t bits = style->i.bits[EMPTY_CELLS_INDEX];
@@ -900,6 +1331,15 @@ static inline uint8_t get_empty_cells(const css_computed_style *style)
#define FLEX_BASIS_INDEX 7
#define FLEX_BASIS_SHIFT 4
#define FLEX_BASIS_MASK 0x7f0
+static inline uint8_t get_flex_basis_bits(const css_computed_style *style)
+{
+ uint32_t bits = style->i.bits[FLEX_BASIS_INDEX];
+ bits &= FLEX_BASIS_MASK;
+ bits >>= FLEX_BASIS_SHIFT;
+
+ /* 7bits: uuuuutt : unit | type */
+ return (bits & 0x3);
+}
static inline uint8_t get_flex_basis(const css_computed_style *style, css_fixed
*length, css_unit *unit)
{
@@ -922,6 +1362,15 @@ static inline uint8_t get_flex_basis(const css_computed_style *style, css_fixed
#define FLEX_DIRECTION_INDEX 13
#define FLEX_DIRECTION_SHIFT 4
#define FLEX_DIRECTION_MASK 0x70
+static inline uint8_t get_flex_direction_bits(const css_computed_style *style)
+{
+ uint32_t bits = style->i.bits[FLEX_DIRECTION_INDEX];
+ bits &= FLEX_DIRECTION_MASK;
+ bits >>= FLEX_DIRECTION_SHIFT;
+
+ /* 3bits: ttt : type */
+ return (bits & 0x7);
+}
static inline uint8_t get_flex_direction(const css_computed_style *style)
{
uint32_t bits = style->i.bits[FLEX_DIRECTION_INDEX];
@@ -939,6 +1388,15 @@ static inline uint8_t get_flex_direction(const css_computed_style *style)
#define FLEX_GROW_INDEX 14
#define FLEX_GROW_SHIFT 22
#define FLEX_GROW_MASK 0x400000
+static inline uint8_t get_flex_grow_bits(const css_computed_style *style)
+{
+ uint32_t bits = style->i.bits[FLEX_GROW_INDEX];
+ bits &= FLEX_GROW_MASK;
+ bits >>= FLEX_GROW_SHIFT;
+
+ /* 1bit: t : type */
+ return (bits & 0x1);
+}
static inline uint8_t get_flex_grow(const css_computed_style *style, css_fixed
*fixed)
{
@@ -960,6 +1418,15 @@ static inline uint8_t get_flex_grow(const css_computed_style *style, css_fixed
#define FLEX_SHRINK_INDEX 14
#define FLEX_SHRINK_SHIFT 23
#define FLEX_SHRINK_MASK 0x800000
+static inline uint8_t get_flex_shrink_bits(const css_computed_style *style)
+{
+ uint32_t bits = style->i.bits[FLEX_SHRINK_INDEX];
+ bits &= FLEX_SHRINK_MASK;
+ bits >>= FLEX_SHRINK_SHIFT;
+
+ /* 1bit: t : type */
+ return (bits & 0x1);
+}
static inline uint8_t get_flex_shrink(const css_computed_style *style,
css_fixed *fixed)
{
@@ -981,6 +1448,15 @@ static inline uint8_t get_flex_shrink(const css_computed_style *style,
#define FLEX_WRAP_INDEX 11
#define FLEX_WRAP_SHIFT 28
#define FLEX_WRAP_MASK 0x30000000
+static inline uint8_t get_flex_wrap_bits(const css_computed_style *style)
+{
+ uint32_t bits = style->i.bits[FLEX_WRAP_INDEX];
+ bits &= FLEX_WRAP_MASK;
+ bits >>= FLEX_WRAP_SHIFT;
+
+ /* 2bits: tt : type */
+ return (bits & 0x3);
+}
static inline uint8_t get_flex_wrap(const css_computed_style *style)
{
uint32_t bits = style->i.bits[FLEX_WRAP_INDEX];
@@ -998,6 +1474,15 @@ static inline uint8_t get_flex_wrap(const css_computed_style *style)
#define FLOAT_INDEX 11
#define FLOAT_SHIFT 30
#define FLOAT_MASK 0xc0000000
+static inline uint8_t get_float_bits(const css_computed_style *style)
+{
+ uint32_t bits = style->i.bits[FLOAT_INDEX];
+ bits &= FLOAT_MASK;
+ bits >>= FLOAT_SHIFT;
+
+ /* 2bits: tt : type */
+ return (bits & 0x3);
+}
static inline uint8_t get_float(const css_computed_style *style)
{
uint32_t bits = style->i.bits[FLOAT_INDEX];
@@ -1015,6 +1500,15 @@ static inline uint8_t get_float(const css_computed_style *style)
#define FONT_FAMILY_INDEX 13
#define FONT_FAMILY_SHIFT 7
#define FONT_FAMILY_MASK 0x380
+static inline uint8_t get_font_family_bits(const css_computed_style *style)
+{
+ uint32_t bits = style->i.bits[FONT_FAMILY_INDEX];
+ bits &= FONT_FAMILY_MASK;
+ bits >>= FONT_FAMILY_SHIFT;
+
+ /* 3bits: ttt : type */
+ return (bits & 0x7);
+}
static inline uint8_t get_font_family(const css_computed_style *style,
lwc_string ***string_arr)
{
@@ -1034,6 +1528,15 @@ static inline uint8_t get_font_family(const css_computed_style *style,
#define FONT_SIZE_INDEX 1
#define FONT_SIZE_SHIFT 23
#define FONT_SIZE_MASK 0xff800000
+static inline uint8_t get_font_size_bits(const css_computed_style *style)
+{
+ uint32_t bits = style->i.bits[FONT_SIZE_INDEX];
+ bits &= FONT_SIZE_MASK;
+ bits >>= FONT_SIZE_SHIFT;
+
+ /* 9bits: uuuuutttt : unit | type */
+ return (bits & 0xf);
+}
static inline uint8_t get_font_size(const css_computed_style *style, css_fixed
*length, css_unit *unit)
{
@@ -1056,6 +1559,15 @@ static inline uint8_t get_font_size(const css_computed_style *style, css_fixed
#define FONT_STYLE_INDEX 10
#define FONT_STYLE_SHIFT 0
#define FONT_STYLE_MASK 0x3
+static inline uint8_t get_font_style_bits(const css_computed_style *style)
+{
+ uint32_t bits = style->i.bits[FONT_STYLE_INDEX];
+ bits &= FONT_STYLE_MASK;
+ bits >>= FONT_STYLE_SHIFT;
+
+ /* 2bits: tt : type */
+ return (bits & 0x3);
+}
static inline uint8_t get_font_style(const css_computed_style *style)
{
uint32_t bits = style->i.bits[FONT_STYLE_INDEX];
@@ -1073,6 +1585,15 @@ static inline uint8_t get_font_style(const css_computed_style *style)
#define FONT_VARIANT_INDEX 10
#define FONT_VARIANT_SHIFT 2
#define FONT_VARIANT_MASK 0xc
+static inline uint8_t get_font_variant_bits(const css_computed_style *style)
+{
+ uint32_t bits = style->i.bits[FONT_VARIANT_INDEX];
+ bits &= FONT_VARIANT_MASK;
+ bits >>= FONT_VARIANT_SHIFT;
+
+ /* 2bits: tt : type */
+ return (bits & 0x3);
+}
static inline uint8_t get_font_variant(const css_computed_style *style)
{
uint32_t bits = style->i.bits[FONT_VARIANT_INDEX];
@@ -1090,6 +1611,15 @@ static inline uint8_t get_font_variant(const css_computed_style *style)
#define FONT_WEIGHT_INDEX 6
#define FONT_WEIGHT_SHIFT 0
#define FONT_WEIGHT_MASK 0xf
+static inline uint8_t get_font_weight_bits(const css_computed_style *style)
+{
+ uint32_t bits = style->i.bits[FONT_WEIGHT_INDEX];
+ bits &= FONT_WEIGHT_MASK;
+ bits >>= FONT_WEIGHT_SHIFT;
+
+ /* 4bits: tttt : type */
+ return (bits & 0xf);
+}
static inline uint8_t get_font_weight(const css_computed_style *style)
{
uint32_t bits = style->i.bits[FONT_WEIGHT_INDEX];
@@ -1107,6 +1637,15 @@ static inline uint8_t get_font_weight(const css_computed_style *style)
#define HEIGHT_INDEX 7
#define HEIGHT_SHIFT 11
#define HEIGHT_MASK 0x3f800
+static inline uint8_t get_height_bits(const css_computed_style *style)
+{
+ uint32_t bits = style->i.bits[HEIGHT_INDEX];
+ bits &= HEIGHT_MASK;
+ bits >>= HEIGHT_SHIFT;
+
+ /* 7bits: uuuuutt : unit | type */
+ return (bits & 0x3);
+}
static inline uint8_t get_height(const css_computed_style *style, css_fixed
*length, css_unit *unit)
{
@@ -1129,6 +1668,15 @@ static inline uint8_t get_height(const css_computed_style *style, css_fixed
#define JUSTIFY_CONTENT_INDEX 13
#define JUSTIFY_CONTENT_SHIFT 10
#define JUSTIFY_CONTENT_MASK 0x1c00
+static inline uint8_t get_justify_content_bits(const css_computed_style *style)
+{
+ uint32_t bits = style->i.bits[JUSTIFY_CONTENT_INDEX];
+ bits &= JUSTIFY_CONTENT_MASK;
+ bits >>= JUSTIFY_CONTENT_SHIFT;
+
+ /* 3bits: ttt : type */
+ return (bits & 0x7);
+}
static inline uint8_t get_justify_content(const css_computed_style *style)
{
uint32_t bits = style->i.bits[JUSTIFY_CONTENT_INDEX];
@@ -1146,31 +1694,29 @@ static inline uint8_t get_justify_content(const css_computed_style *style)
#define LEFT_INDEX 7
#define LEFT_SHIFT 18
#define LEFT_MASK 0x1fc0000
-static inline uint8_t get_left(
- const css_computed_style *style,
- css_fixed *length, css_unit *unit)
+static inline uint8_t get_left_bits(const css_computed_style *style)
{
uint32_t bits = style->i.bits[LEFT_INDEX];
bits &= LEFT_MASK;
bits >>= LEFT_SHIFT;
-
- /* 7bits: uuuuutt : units | type */
- if ((bits & 0x3) == CSS_LEFT_SET) {
- *length = style->i.left;
- *unit = bits >> 2;
- }
-
+
+ /* 7bits: uuuuutt : unit | type */
return (bits & 0x3);
}
-static inline uint8_t get_left_bits(
- const css_computed_style *style)
+static inline uint8_t get_left(const css_computed_style *style, css_fixed
+ *length, css_unit *unit)
{
uint32_t bits = style->i.bits[LEFT_INDEX];
bits &= LEFT_MASK;
bits >>= LEFT_SHIFT;
-
- /* 7bits: uuuuutt : units | type */
- return bits;
+
+ /* 7bits: uuuuutt : unit | type */
+ if ((bits & 0x3) == CSS_LEFT_SET) {
+ *length = style->i.left;
+ *unit = bits >> 2;
+ }
+
+ return (bits & 0x3);
}
#undef LEFT_INDEX
#undef LEFT_SHIFT
@@ -1179,6 +1725,15 @@ static inline uint8_t get_left_bits(
#define LETTER_SPACING_INDEX 7
#define LETTER_SPACING_SHIFT 25
#define LETTER_SPACING_MASK 0xfe000000
+static inline uint8_t get_letter_spacing_bits(const css_computed_style *style)
+{
+ uint32_t bits = style->i.bits[LETTER_SPACING_INDEX];
+ bits &= LETTER_SPACING_MASK;
+ bits >>= LETTER_SPACING_SHIFT;
+
+ /* 7bits: uuuuutt : unit | type */
+ return (bits & 0x3);
+}
static inline uint8_t get_letter_spacing(const css_computed_style *style,
css_fixed *length, css_unit *unit)
{
@@ -1201,6 +1756,15 @@ static inline uint8_t get_letter_spacing(const css_computed_style *style,
#define LINE_HEIGHT_INDEX 6
#define LINE_HEIGHT_SHIFT 4
#define LINE_HEIGHT_MASK 0x7f0
+static inline uint8_t get_line_height_bits(const css_computed_style *style)
+{
+ uint32_t bits = style->i.bits[LINE_HEIGHT_INDEX];
+ bits &= LINE_HEIGHT_MASK;
+ bits >>= LINE_HEIGHT_SHIFT;
+
+ /* 7bits: uuuuutt : unit | type */
+ return (bits & 0x3);
+}
static inline uint8_t get_line_height(
const css_computed_style *style,
css_fixed *length, css_unit *unit)
@@ -1228,7 +1792,16 @@ static inline uint8_t get_line_height(
#define LIST_STYLE_IMAGE_INDEX 14
#define LIST_STYLE_IMAGE_SHIFT 24
#define LIST_STYLE_IMAGE_MASK 0x1000000
-static inline uint8_t get_list_style_image(const css_computed_style *style,
+static inline uint8_t get_list_style_image_bits(const css_computed_style *style)
+{
+ uint32_t bits = style->i.bits[LIST_STYLE_IMAGE_INDEX];
+ bits &= LIST_STYLE_IMAGE_MASK;
+ bits >>= LIST_STYLE_IMAGE_SHIFT;
+
+ /* 1bit: t : type */
+ return (bits & 0x1);
+}
+static inline uint8_t get_list_style_image(const css_computed_style *style,
lwc_string **string)
{
uint32_t bits = style->i.bits[LIST_STYLE_IMAGE_INDEX];
@@ -1247,6 +1820,16 @@ static inline uint8_t get_list_style_image(const css_computed_style *style,
#define LIST_STYLE_POSITION_INDEX 10
#define LIST_STYLE_POSITION_SHIFT 4
#define LIST_STYLE_POSITION_MASK 0x30
+static inline uint8_t get_list_style_position_bits(const css_computed_style
+ *style)
+{
+ uint32_t bits = style->i.bits[LIST_STYLE_POSITION_INDEX];
+ bits &= LIST_STYLE_POSITION_MASK;
+ bits >>= LIST_STYLE_POSITION_SHIFT;
+
+ /* 2bits: tt : type */
+ return (bits & 0x3);
+}
static inline uint8_t get_list_style_position(const css_computed_style *style)
{
uint32_t bits = style->i.bits[LIST_STYLE_POSITION_INDEX];
@@ -1264,6 +1847,15 @@ static inline uint8_t get_list_style_position(const css_computed_style *style)
#define LIST_STYLE_TYPE_INDEX 8
#define LIST_STYLE_TYPE_SHIFT 8
#define LIST_STYLE_TYPE_MASK 0x3f00
+static inline uint8_t get_list_style_type_bits(const css_computed_style *style)
+{
+ uint32_t bits = style->i.bits[LIST_STYLE_TYPE_INDEX];
+ bits &= LIST_STYLE_TYPE_MASK;
+ bits >>= LIST_STYLE_TYPE_SHIFT;
+
+ /* 6bits: tttttt : type */
+ return (bits & 0x3f);
+}
static inline uint8_t get_list_style_type(const css_computed_style *style)
{
uint32_t bits = style->i.bits[LIST_STYLE_TYPE_INDEX];
@@ -1281,6 +1873,15 @@ static inline uint8_t get_list_style_type(const css_computed_style *style)
#define MARGIN_BOTTOM_INDEX 6
#define MARGIN_BOTTOM_SHIFT 11
#define MARGIN_BOTTOM_MASK 0x3f800
+static inline uint8_t get_margin_bottom_bits(const css_computed_style *style)
+{
+ uint32_t bits = style->i.bits[MARGIN_BOTTOM_INDEX];
+ bits &= MARGIN_BOTTOM_MASK;
+ bits >>= MARGIN_BOTTOM_SHIFT;
+
+ /* 7bits: uuuuutt : unit | type */
+ return (bits & 0x3);
+}
static inline uint8_t get_margin_bottom(const css_computed_style *style,
css_fixed *length, css_unit *unit)
{
@@ -1303,6 +1904,15 @@ static inline uint8_t get_margin_bottom(const css_computed_style *style,
#define MARGIN_LEFT_INDEX 6
#define MARGIN_LEFT_SHIFT 18
#define MARGIN_LEFT_MASK 0x1fc0000
+static inline uint8_t get_margin_left_bits(const css_computed_style *style)
+{
+ uint32_t bits = style->i.bits[MARGIN_LEFT_INDEX];
+ bits &= MARGIN_LEFT_MASK;
+ bits >>= MARGIN_LEFT_SHIFT;
+
+ /* 7bits: uuuuutt : unit | type */
+ return (bits & 0x3);
+}
static inline uint8_t get_margin_left(const css_computed_style *style,
css_fixed *length, css_unit *unit)
{
@@ -1325,6 +1935,15 @@ static inline uint8_t get_margin_left(const css_computed_style *style,
#define MARGIN_RIGHT_INDEX 6
#define MARGIN_RIGHT_SHIFT 25
#define MARGIN_RIGHT_MASK 0xfe000000
+static inline uint8_t get_margin_right_bits(const css_computed_style *style)
+{
+ uint32_t bits = style->i.bits[MARGIN_RIGHT_INDEX];
+ bits &= MARGIN_RIGHT_MASK;
+ bits >>= MARGIN_RIGHT_SHIFT;
+
+ /* 7bits: uuuuutt : unit | type */
+ return (bits & 0x3);
+}
static inline uint8_t get_margin_right(const css_computed_style *style,
css_fixed *length, css_unit *unit)
{
@@ -1347,6 +1966,15 @@ static inline uint8_t get_margin_right(const css_computed_style *style,
#define MARGIN_TOP_INDEX 5
#define MARGIN_TOP_SHIFT 4
#define MARGIN_TOP_MASK 0x7f0
+static inline uint8_t get_margin_top_bits(const css_computed_style *style)
+{
+ uint32_t bits = style->i.bits[MARGIN_TOP_INDEX];
+ bits &= MARGIN_TOP_MASK;
+ bits >>= MARGIN_TOP_SHIFT;
+
+ /* 7bits: uuuuutt : unit | type */
+ return (bits & 0x3);
+}
static inline uint8_t get_margin_top(const css_computed_style *style, css_fixed
*length, css_unit *unit)
{
@@ -1369,6 +1997,15 @@ static inline uint8_t get_margin_top(const css_computed_style *style, css_fixed
#define MAX_HEIGHT_INDEX 5
#define MAX_HEIGHT_SHIFT 11
#define MAX_HEIGHT_MASK 0x3f800
+static inline uint8_t get_max_height_bits(const css_computed_style *style)
+{
+ uint32_t bits = style->i.bits[MAX_HEIGHT_INDEX];
+ bits &= MAX_HEIGHT_MASK;
+ bits >>= MAX_HEIGHT_SHIFT;
+
+ /* 7bits: uuuuutt : unit | type */
+ return (bits & 0x3);
+}
static inline uint8_t get_max_height(const css_computed_style *style, css_fixed
*length, css_unit *unit)
{
@@ -1391,6 +2028,15 @@ static inline uint8_t get_max_height(const css_computed_style *style, css_fixed
#define MAX_WIDTH_INDEX 5
#define MAX_WIDTH_SHIFT 18
#define MAX_WIDTH_MASK 0x1fc0000
+static inline uint8_t get_max_width_bits(const css_computed_style *style)
+{
+ uint32_t bits = style->i.bits[MAX_WIDTH_INDEX];
+ bits &= MAX_WIDTH_MASK;
+ bits >>= MAX_WIDTH_SHIFT;
+
+ /* 7bits: uuuuutt : unit | type */
+ return (bits & 0x3);
+}
static inline uint8_t get_max_width(const css_computed_style *style, css_fixed
*length, css_unit *unit)
{
@@ -1413,6 +2059,15 @@ static inline uint8_t get_max_width(const css_computed_style *style, css_fixed
#define MIN_HEIGHT_INDEX 5
#define MIN_HEIGHT_SHIFT 25
#define MIN_HEIGHT_MASK 0xfe000000
+static inline uint8_t get_min_height_bits(const css_computed_style *style)
+{
+ uint32_t bits = style->i.bits[MIN_HEIGHT_INDEX];
+ bits &= MIN_HEIGHT_MASK;
+ bits >>= MIN_HEIGHT_SHIFT;
+
+ /* 7bits: uuuuutt : unit | type */
+ return (bits & 0x3);
+}
static inline uint8_t get_min_height(const css_computed_style *style, css_fixed
*length, css_unit *unit)
{
@@ -1435,6 +2090,15 @@ static inline uint8_t get_min_height(const css_computed_style *style, css_fixed
#define MIN_WIDTH_INDEX 4
#define MIN_WIDTH_SHIFT 4
#define MIN_WIDTH_MASK 0x7f0
+static inline uint8_t get_min_width_bits(const css_computed_style *style)
+{
+ uint32_t bits = style->i.bits[MIN_WIDTH_INDEX];
+ bits &= MIN_WIDTH_MASK;
+ bits >>= MIN_WIDTH_SHIFT;
+
+ /* 7bits: uuuuutt : unit | type */
+ return (bits & 0x3);
+}
static inline uint8_t get_min_width(const css_computed_style *style, css_fixed
*length, css_unit *unit)
{
@@ -1457,6 +2121,15 @@ static inline uint8_t get_min_width(const css_computed_style *style, css_fixed
#define OPACITY_INDEX 14
#define OPACITY_SHIFT 25
#define OPACITY_MASK 0x2000000
+static inline uint8_t get_opacity_bits(const css_computed_style *style)
+{
+ uint32_t bits = style->i.bits[OPACITY_INDEX];
+ bits &= OPACITY_MASK;
+ bits >>= OPACITY_SHIFT;
+
+ /* 1bit: t : type */
+ return (bits & 0x1);
+}
static inline uint8_t get_opacity(const css_computed_style *style, css_fixed
*fixed)
{
@@ -1478,6 +2151,15 @@ static inline uint8_t get_opacity(const css_computed_style *style, css_fixed
#define ORDER_INDEX 14
#define ORDER_SHIFT 26
#define ORDER_MASK 0x4000000
+static inline uint8_t get_order_bits(const css_computed_style *style)
+{
+ uint32_t bits = style->i.bits[ORDER_INDEX];
+ bits &= ORDER_MASK;
+ bits >>= ORDER_SHIFT;
+
+ /* 1bit: t : type */
+ return (bits & 0x1);
+}
static inline uint8_t get_order(const css_computed_style *style, int32_t
*integer)
{
@@ -1499,6 +2181,15 @@ static inline uint8_t get_order(const css_computed_style *style, int32_t
#define ORPHANS_INDEX 14
#define ORPHANS_SHIFT 27
#define ORPHANS_MASK 0x8000000
+static inline uint8_t get_orphans_bits(const css_computed_style *style)
+{
+ uint32_t bits = style->i.bits[ORPHANS_INDEX];
+ bits &= ORPHANS_MASK;
+ bits >>= ORPHANS_SHIFT;
+
+ /* 1bit: t : type */
+ return (bits & 0x1);
+}
static inline uint8_t get_orphans(const css_computed_style *style, int32_t
*integer)
{
@@ -1518,6 +2209,15 @@ static inline uint8_t get_orphans(const css_computed_style *style, int32_t
#define OUTLINE_COLOR_INDEX 10
#define OUTLINE_COLOR_SHIFT 6
#define OUTLINE_COLOR_MASK 0xc0
+static inline uint8_t get_outline_color_bits(const css_computed_style *style)
+{
+ uint32_t bits = style->i.bits[OUTLINE_COLOR_INDEX];
+ bits &= OUTLINE_COLOR_MASK;
+ bits >>= OUTLINE_COLOR_SHIFT;
+
+ /* 2bits: tt : type */
+ return (bits & 0x3);
+}
static inline uint8_t get_outline_color(const css_computed_style *style,
css_color *color)
{
@@ -1539,6 +2239,15 @@ static inline uint8_t get_outline_color(const css_computed_style *style,
#define OUTLINE_STYLE_INDEX 5
#define OUTLINE_STYLE_SHIFT 0
#define OUTLINE_STYLE_MASK 0xf
+static inline uint8_t get_outline_style_bits(const css_computed_style *style)
+{
+ uint32_t bits = style->i.bits[OUTLINE_STYLE_INDEX];
+ bits &= OUTLINE_STYLE_MASK;
+ bits >>= OUTLINE_STYLE_SHIFT;
+
+ /* 4bits: tttt : type */
+ return (bits & 0xf);
+}
static inline uint8_t get_outline_style(const css_computed_style *style)
{
uint32_t bits = style->i.bits[OUTLINE_STYLE_INDEX];
@@ -1556,6 +2265,15 @@ static inline uint8_t get_outline_style(const css_computed_style *style)
#define OUTLINE_WIDTH_INDEX 1
#define OUTLINE_WIDTH_SHIFT 15
#define OUTLINE_WIDTH_MASK 0x7f8000
+static inline uint8_t get_outline_width_bits(const css_computed_style *style)
+{
+ uint32_t bits = style->i.bits[OUTLINE_WIDTH_INDEX];
+ bits &= OUTLINE_WIDTH_MASK;
+ bits >>= OUTLINE_WIDTH_SHIFT;
+
+ /* 8bits: uuuuuttt : unit | type */
+ return (bits & 0x7);
+}
static inline uint8_t get_outline_width(const css_computed_style *style,
css_fixed *length, css_unit *unit)
{
@@ -1578,6 +2296,15 @@ static inline uint8_t get_outline_width(const css_computed_style *style,
#define OVERFLOW_X_INDEX 13
#define OVERFLOW_X_SHIFT 13
#define OVERFLOW_X_MASK 0xe000
+static inline uint8_t get_overflow_x_bits(const css_computed_style *style)
+{
+ uint32_t bits = style->i.bits[OVERFLOW_X_INDEX];
+ bits &= OVERFLOW_X_MASK;
+ bits >>= OVERFLOW_X_SHIFT;
+
+ /* 3bits: ttt : type */
+ return (bits & 0x7);
+}
static inline uint8_t get_overflow_x(const css_computed_style *style)
{
uint32_t bits = style->i.bits[OVERFLOW_X_INDEX];
@@ -1595,6 +2322,15 @@ static inline uint8_t get_overflow_x(const css_computed_style *style)
#define OVERFLOW_Y_INDEX 13
#define OVERFLOW_Y_SHIFT 16
#define OVERFLOW_Y_MASK 0x70000
+static inline uint8_t get_overflow_y_bits(const css_computed_style *style)
+{
+ uint32_t bits = style->i.bits[OVERFLOW_Y_INDEX];
+ bits &= OVERFLOW_Y_MASK;
+ bits >>= OVERFLOW_Y_SHIFT;
+
+ /* 3bits: ttt : type */
+ return (bits & 0x7);
+}
static inline uint8_t get_overflow_y(const css_computed_style *style)
{
uint32_t bits = style->i.bits[OVERFLOW_Y_INDEX];
@@ -1612,6 +2348,15 @@ static inline uint8_t get_overflow_y(const css_computed_style *style)
#define PADDING_BOTTOM_INDEX 8
#define PADDING_BOTTOM_SHIFT 14
#define PADDING_BOTTOM_MASK 0xfc000
+static inline uint8_t get_padding_bottom_bits(const css_computed_style *style)
+{
+ uint32_t bits = style->i.bits[PADDING_BOTTOM_INDEX];
+ bits &= PADDING_BOTTOM_MASK;
+ bits >>= PADDING_BOTTOM_SHIFT;
+
+ /* 6bits: uuuuut : unit | type */
+ return (bits & 0x1);
+}
static inline uint8_t get_padding_bottom(const css_computed_style *style,
css_fixed *length, css_unit *unit)
{
@@ -1634,6 +2379,15 @@ static inline uint8_t get_padding_bottom(const css_computed_style *style,
#define PADDING_LEFT_INDEX 8
#define PADDING_LEFT_SHIFT 20
#define PADDING_LEFT_MASK 0x3f00000
+static inline uint8_t get_padding_left_bits(const css_computed_style *style)
+{
+ uint32_t bits = style->i.bits[PADDING_LEFT_INDEX];
+ bits &= PADDING_LEFT_MASK;
+ bits >>= PADDING_LEFT_SHIFT;
+
+ /* 6bits: uuuuut : unit | type */
+ return (bits & 0x1);
+}
static inline uint8_t get_padding_left(const css_computed_style *style,
css_fixed *length, css_unit *unit)
{
@@ -1656,6 +2410,15 @@ static inline uint8_t get_padding_left(const css_computed_style *style,
#define PADDING_RIGHT_INDEX 8
#define PADDING_RIGHT_SHIFT 26
#define PADDING_RIGHT_MASK 0xfc000000
+static inline uint8_t get_padding_right_bits(const css_computed_style *style)
+{
+ uint32_t bits = style->i.bits[PADDING_RIGHT_INDEX];
+ bits &= PADDING_RIGHT_MASK;
+ bits >>= PADDING_RIGHT_SHIFT;
+
+ /* 6bits: uuuuut : unit | type */
+ return (bits & 0x1);
+}
static inline uint8_t get_padding_right(const css_computed_style *style,
css_fixed *length, css_unit *unit)
{
@@ -1678,6 +2441,15 @@ static inline uint8_t get_padding_right(const css_computed_style *style,
#define PADDING_TOP_INDEX 3
#define PADDING_TOP_SHIFT 5
#define PADDING_TOP_MASK 0x7e0
+static inline uint8_t get_padding_top_bits(const css_computed_style *style)
+{
+ uint32_t bits = style->i.bits[PADDING_TOP_INDEX];
+ bits &= PADDING_TOP_MASK;
+ bits >>= PADDING_TOP_SHIFT;
+
+ /* 6bits: uuuuut : unit | type */
+ return (bits & 0x1);
+}
static inline uint8_t get_padding_top(const css_computed_style *style,
css_fixed *length, css_unit *unit)
{
@@ -1700,6 +2472,15 @@ static inline uint8_t get_padding_top(const css_computed_style *style,
#define PAGE_BREAK_AFTER_INDEX 13
#define PAGE_BREAK_AFTER_SHIFT 19
#define PAGE_BREAK_AFTER_MASK 0x380000
+static inline uint8_t get_page_break_after_bits(const css_computed_style *style)
+{
+ uint32_t bits = style->i.bits[PAGE_BREAK_AFTER_INDEX];
+ bits &= PAGE_BREAK_AFTER_MASK;
+ bits >>= PAGE_BREAK_AFTER_SHIFT;
+
+ /* 3bits: ttt : type */
+ return (bits & 0x7);
+}
static inline uint8_t get_page_break_after(const css_computed_style *style)
{
uint32_t bits = style->i.bits[PAGE_BREAK_AFTER_INDEX];
@@ -1717,6 +2498,16 @@ static inline uint8_t get_page_break_after(const css_computed_style *style)
#define PAGE_BREAK_BEFORE_INDEX 13
#define PAGE_BREAK_BEFORE_SHIFT 22
#define PAGE_BREAK_BEFORE_MASK 0x1c00000
+static inline uint8_t get_page_break_before_bits(const css_computed_style
+ *style)
+{
+ uint32_t bits = style->i.bits[PAGE_BREAK_BEFORE_INDEX];
+ bits &= PAGE_BREAK_BEFORE_MASK;
+ bits >>= PAGE_BREAK_BEFORE_SHIFT;
+
+ /* 3bits: ttt : type */
+ return (bits & 0x7);
+}
static inline uint8_t get_page_break_before(const css_computed_style *style)
{
uint32_t bits = style->i.bits[PAGE_BREAK_BEFORE_INDEX];
@@ -1734,6 +2525,16 @@ static inline uint8_t get_page_break_before(const css_computed_style *style)
#define PAGE_BREAK_INSIDE_INDEX 10
#define PAGE_BREAK_INSIDE_SHIFT 8
#define PAGE_BREAK_INSIDE_MASK 0x300
+static inline uint8_t get_page_break_inside_bits(const css_computed_style
+ *style)
+{
+ uint32_t bits = style->i.bits[PAGE_BREAK_INSIDE_INDEX];
+ bits &= PAGE_BREAK_INSIDE_MASK;
+ bits >>= PAGE_BREAK_INSIDE_SHIFT;
+
+ /* 2bits: tt : type */
+ return (bits & 0x3);
+}
static inline uint8_t get_page_break_inside(const css_computed_style *style)
{
uint32_t bits = style->i.bits[PAGE_BREAK_INSIDE_INDEX];
@@ -1751,6 +2552,15 @@ static inline uint8_t get_page_break_inside(const css_computed_style *style)
#define POSITION_INDEX 13
#define POSITION_SHIFT 25
#define POSITION_MASK 0xe000000
+static inline uint8_t get_position_bits(const css_computed_style *style)
+{
+ uint32_t bits = style->i.bits[POSITION_INDEX];
+ bits &= POSITION_MASK;
+ bits >>= POSITION_SHIFT;
+
+ /* 3bits: ttt : type */
+ return (bits & 0x7);
+}
static inline uint8_t get_position(const css_computed_style *style)
{
uint32_t bits = style->i.bits[POSITION_INDEX];
@@ -1768,6 +2578,15 @@ static inline uint8_t get_position(const css_computed_style *style)
#define QUOTES_INDEX 13
#define QUOTES_SHIFT 0
#define QUOTES_MASK 0x1
+static inline uint8_t get_quotes_bits(const css_computed_style *style)
+{
+ uint32_t bits = style->i.bits[QUOTES_INDEX];
+ bits &= QUOTES_MASK;
+ bits >>= QUOTES_SHIFT;
+
+ /* 1bit: t : type */
+ return (bits & 0x1);
+}
static inline uint8_t get_quotes(const css_computed_style *style, lwc_string
***string_arr)
{
@@ -1787,31 +2606,29 @@ static inline uint8_t get_quotes(const css_computed_style *style, lwc_string
#define RIGHT_INDEX 4
#define RIGHT_SHIFT 11
#define RIGHT_MASK 0x3f800
-static inline uint8_t get_right(
- const css_computed_style *style,
- css_fixed *length, css_unit *unit)
+static inline uint8_t get_right_bits(const css_computed_style *style)
{
uint32_t bits = style->i.bits[RIGHT_INDEX];
bits &= RIGHT_MASK;
bits >>= RIGHT_SHIFT;
-
- /* 7bits: uuuuutt : units | type */
- if ((bits & 0x3) == CSS_RIGHT_SET) {
- *length = style->i.right;
- *unit = bits >> 2;
- }
-
+
+ /* 7bits: uuuuutt : unit | type */
return (bits & 0x3);
}
-static inline uint8_t get_right_bits(
- const css_computed_style *style)
+static inline uint8_t get_right(const css_computed_style *style, css_fixed
+ *length, css_unit *unit)
{
uint32_t bits = style->i.bits[RIGHT_INDEX];
bits &= RIGHT_MASK;
bits >>= RIGHT_SHIFT;
-
- /* 7bits: uuuuutt : units | type */
- return bits;
+
+ /* 7bits: uuuuutt : unit | type */
+ if ((bits & 0x3) == CSS_RIGHT_SET) {
+ *length = style->i.right;
+ *unit = bits >> 2;
+ }
+
+ return (bits & 0x3);
}
#undef RIGHT_INDEX
#undef RIGHT_SHIFT
@@ -1820,6 +2637,15 @@ static inline uint8_t get_right_bits(
#define TABLE_LAYOUT_INDEX 10
#define TABLE_LAYOUT_SHIFT 10
#define TABLE_LAYOUT_MASK 0xc00
+static inline uint8_t get_table_layout_bits(const css_computed_style *style)
+{
+ uint32_t bits = style->i.bits[TABLE_LAYOUT_INDEX];
+ bits &= TABLE_LAYOUT_MASK;
+ bits >>= TABLE_LAYOUT_SHIFT;
+
+ /* 2bits: tt : type */
+ return (bits & 0x3);
+}
static inline uint8_t get_table_layout(const css_computed_style *style)
{
uint32_t bits = style->i.bits[TABLE_LAYOUT_INDEX];
@@ -1837,6 +2663,15 @@ static inline uint8_t get_table_layout(const css_computed_style *style)
#define TEXT_ALIGN_INDEX 4
#define TEXT_ALIGN_SHIFT 0
#define TEXT_ALIGN_MASK 0xf
+static inline uint8_t get_text_align_bits(const css_computed_style *style)
+{
+ uint32_t bits = style->i.bits[TEXT_ALIGN_INDEX];
+ bits &= TEXT_ALIGN_MASK;
+ bits >>= TEXT_ALIGN_SHIFT;
+
+ /* 4bits: tttt : type */
+ return (bits & 0xf);
+}
static inline uint8_t get_text_align(const css_computed_style *style)
{
uint32_t bits = style->i.bits[TEXT_ALIGN_INDEX];
@@ -1854,6 +2689,15 @@ static inline uint8_t get_text_align(const css_computed_style *style)
#define TEXT_DECORATION_INDEX 3
#define TEXT_DECORATION_SHIFT 0
#define TEXT_DECORATION_MASK 0x1f
+static inline uint8_t get_text_decoration_bits(const css_computed_style *style)
+{
+ uint32_t bits = style->i.bits[TEXT_DECORATION_INDEX];
+ bits &= TEXT_DECORATION_MASK;
+ bits >>= TEXT_DECORATION_SHIFT;
+
+ /* 5bits: ttttt : type */
+ return (bits & 0x1f);
+}
static inline uint8_t get_text_decoration(const css_computed_style *style)
{
uint32_t bits = style->i.bits[TEXT_DECORATION_INDEX];
@@ -1871,6 +2715,15 @@ static inline uint8_t get_text_decoration(const css_computed_style *style)
#define TEXT_INDENT_INDEX 2
#define TEXT_INDENT_SHIFT 0
#define TEXT_INDENT_MASK 0x3f
+static inline uint8_t get_text_indent_bits(const css_computed_style *style)
+{
+ uint32_t bits = style->i.bits[TEXT_INDENT_INDEX];
+ bits &= TEXT_INDENT_MASK;
+ bits >>= TEXT_INDENT_SHIFT;
+
+ /* 6bits: uuuuut : unit | type */
+ return (bits & 0x1);
+}
static inline uint8_t get_text_indent(const css_computed_style *style,
css_fixed *length, css_unit *unit)
{
@@ -1893,6 +2746,15 @@ static inline uint8_t get_text_indent(const css_computed_style *style,
#define TEXT_TRANSFORM_INDEX 9
#define TEXT_TRANSFORM_SHIFT 0
#define TEXT_TRANSFORM_MASK 0x7
+static inline uint8_t get_text_transform_bits(const css_computed_style *style)
+{
+ uint32_t bits = style->i.bits[TEXT_TRANSFORM_INDEX];
+ bits &= TEXT_TRANSFORM_MASK;
+ bits >>= TEXT_TRANSFORM_SHIFT;
+
+ /* 3bits: ttt : type */
+ return (bits & 0x7);
+}
static inline uint8_t get_text_transform(const css_computed_style *style)
{
uint32_t bits = style->i.bits[TEXT_TRANSFORM_INDEX];
@@ -1910,31 +2772,29 @@ static inline uint8_t get_text_transform(const css_computed_style *style)
#define TOP_INDEX 4
#define TOP_SHIFT 18
#define TOP_MASK 0x1fc0000
-static inline uint8_t get_top(
- const css_computed_style *style,
- css_fixed *length, css_unit *unit)
+static inline uint8_t get_top_bits(const css_computed_style *style)
{
uint32_t bits = style->i.bits[TOP_INDEX];
bits &= TOP_MASK;
bits >>= TOP_SHIFT;
-
- /* 7bits: uuuuutt : units | type */
- if ((bits & 0x3) == CSS_TOP_SET) {
- *length = style->i.top;
- *unit = bits >> 2;
- }
-
+
+ /* 7bits: uuuuutt : unit | type */
return (bits & 0x3);
}
-static inline uint8_t get_top_bits(
- const css_computed_style *style)
+static inline uint8_t get_top(const css_computed_style *style, css_fixed
+ *length, css_unit *unit)
{
uint32_t bits = style->i.bits[TOP_INDEX];
bits &= TOP_MASK;
bits >>= TOP_SHIFT;
-
- /* 7bits: uuuuutt : units | type */
- return bits;
+
+ /* 7bits: uuuuutt : unit | type */
+ if ((bits & 0x3) == CSS_TOP_SET) {
+ *length = style->i.top;
+ *unit = bits >> 2;
+ }
+
+ return (bits & 0x3);
}
#undef TOP_INDEX
#undef TOP_SHIFT
@@ -1943,6 +2803,15 @@ static inline uint8_t get_top_bits(
#define UNICODE_BIDI_INDEX 10
#define UNICODE_BIDI_SHIFT 12
#define UNICODE_BIDI_MASK 0x3000
+static inline uint8_t get_unicode_bidi_bits(const css_computed_style *style)
+{
+ uint32_t bits = style->i.bits[UNICODE_BIDI_INDEX];
+ bits &= UNICODE_BIDI_MASK;
+ bits >>= UNICODE_BIDI_SHIFT;
+
+ /* 2bits: tt : type */
+ return (bits & 0x3);
+}
static inline uint8_t get_unicode_bidi(const css_computed_style *style)
{
uint32_t bits = style->i.bits[UNICODE_BIDI_INDEX];
@@ -1960,6 +2829,15 @@ static inline uint8_t get_unicode_bidi(const css_computed_style *style)
#define VERTICAL_ALIGN_INDEX 12
#define VERTICAL_ALIGN_SHIFT 1
#define VERTICAL_ALIGN_MASK 0x3fe
+static inline uint8_t get_vertical_align_bits(const css_computed_style *style)
+{
+ uint32_t bits = style->i.bits[VERTICAL_ALIGN_INDEX];
+ bits &= VERTICAL_ALIGN_MASK;
+ bits >>= VERTICAL_ALIGN_SHIFT;
+
+ /* 9bits: uuuuutttt : unit | type */
+ return (bits & 0xf);
+}
static inline uint8_t get_vertical_align(const css_computed_style *style,
css_fixed *length, css_unit *unit)
{
@@ -1982,6 +2860,15 @@ static inline uint8_t get_vertical_align(const css_computed_style *style,
#define VISIBILITY_INDEX 10
#define VISIBILITY_SHIFT 14
#define VISIBILITY_MASK 0xc000
+static inline uint8_t get_visibility_bits(const css_computed_style *style)
+{
+ uint32_t bits = style->i.bits[VISIBILITY_INDEX];
+ bits &= VISIBILITY_MASK;
+ bits >>= VISIBILITY_SHIFT;
+
+ /* 2bits: tt : type */
+ return (bits & 0x3);
+}
static inline uint8_t get_visibility(const css_computed_style *style)
{
uint32_t bits = style->i.bits[VISIBILITY_INDEX];
@@ -1999,6 +2886,15 @@ static inline uint8_t get_visibility(const css_computed_style *style)
#define WHITE_SPACE_INDEX 8
#define WHITE_SPACE_SHIFT 0
#define WHITE_SPACE_MASK 0x7
+static inline uint8_t get_white_space_bits(const css_computed_style *style)
+{
+ uint32_t bits = style->i.bits[WHITE_SPACE_INDEX];
+ bits &= WHITE_SPACE_MASK;
+ bits >>= WHITE_SPACE_SHIFT;
+
+ /* 3bits: ttt : type */
+ return (bits & 0x7);
+}
static inline uint8_t get_white_space(const css_computed_style *style)
{
uint32_t bits = style->i.bits[WHITE_SPACE_INDEX];
@@ -2016,6 +2912,15 @@ static inline uint8_t get_white_space(const css_computed_style *style)
#define WIDOWS_INDEX 12
#define WIDOWS_SHIFT 0
#define WIDOWS_MASK 0x1
+static inline uint8_t get_widows_bits(const css_computed_style *style)
+{
+ uint32_t bits = style->i.bits[WIDOWS_INDEX];
+ bits &= WIDOWS_MASK;
+ bits >>= WIDOWS_SHIFT;
+
+ /* 1bit: t : type */
+ return (bits & 0x1);
+}
static inline uint8_t get_widows(const css_computed_style *style, int32_t
*integer)
{
@@ -2035,6 +2940,15 @@ static inline uint8_t get_widows(const css_computed_style *style, int32_t
#define WIDTH_INDEX 4
#define WIDTH_SHIFT 25
#define WIDTH_MASK 0xfe000000
+static inline uint8_t get_width_bits(const css_computed_style *style)
+{
+ uint32_t bits = style->i.bits[WIDTH_INDEX];
+ bits &= WIDTH_MASK;
+ bits >>= WIDTH_SHIFT;
+
+ /* 7bits: uuuuutt : unit | type */
+ return (bits & 0x3);
+}
static inline uint8_t get_width(const css_computed_style *style, css_fixed
*length, css_unit *unit)
{
@@ -2057,6 +2971,15 @@ static inline uint8_t get_width(const css_computed_style *style, css_fixed
#define WORD_SPACING_INDEX 1
#define WORD_SPACING_SHIFT 0
#define WORD_SPACING_MASK 0x7f
+static inline uint8_t get_word_spacing_bits(const css_computed_style *style)
+{
+ uint32_t bits = style->i.bits[WORD_SPACING_INDEX];
+ bits &= WORD_SPACING_MASK;
+ bits >>= WORD_SPACING_SHIFT;
+
+ /* 7bits: uuuuutt : unit | type */
+ return (bits & 0x3);
+}
static inline uint8_t get_word_spacing(const css_computed_style *style,
css_fixed *length, css_unit *unit)
{
@@ -2079,6 +3002,15 @@ static inline uint8_t get_word_spacing(const css_computed_style *style,
#define WRITING_MODE_INDEX 10
#define WRITING_MODE_SHIFT 16
#define WRITING_MODE_MASK 0x30000
+static inline uint8_t get_writing_mode_bits(const css_computed_style *style)
+{
+ uint32_t bits = style->i.bits[WRITING_MODE_INDEX];
+ bits &= WRITING_MODE_MASK;
+ bits >>= WRITING_MODE_SHIFT;
+
+ /* 2bits: tt : type */
+ return (bits & 0x3);
+}
static inline uint8_t get_writing_mode(const css_computed_style *style)
{
uint32_t bits = style->i.bits[WRITING_MODE_INDEX];
@@ -2096,6 +3028,15 @@ static inline uint8_t get_writing_mode(const css_computed_style *style)
#define Z_INDEX_INDEX 10
#define Z_INDEX_SHIFT 18
#define Z_INDEX_MASK 0xc0000
+static inline uint8_t get_z_index_bits(const css_computed_style *style)
+{
+ uint32_t bits = style->i.bits[Z_INDEX_INDEX];
+ bits &= Z_INDEX_MASK;
+ bits >>= Z_INDEX_SHIFT;
+
+ /* 2bits: tt : type */
+ return (bits & 0x3);
+}
static inline uint8_t get_z_index(const css_computed_style *style, int32_t
*integer)
{
diff --git a/src/select/computed.c b/src/select/computed.c
index c257f17..a520381 100644
--- a/src/select/computed.c
+++ b/src/select/computed.c
@@ -472,7 +472,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);
}
diff --git a/src/select/overrides.py b/src/select/overrides.py
index 1336976..869d6ec 100644
--- a/src/select/overrides.py
+++ b/src/select/overrides.py
@@ -183,35 +183,3 @@ static inline css_error set_content(
return CSS_OK;
}'''
-
-get_side = '''\
-static inline uint8_t get_{0}(
- const css_computed_style *style,
- css_fixed *length, css_unit *unit)
-{{
- uint32_t bits = style->i.bits[{1}_INDEX];
- bits &= {1}_MASK;
- bits >>= {1}_SHIFT;
-
- /* 7bits: uuuuutt : units | type */
- if ((bits & 0x3) == CSS_{1}_SET) {{
- *length = style->i.{0};
- *unit = bits >> 2;
- }}
-
- return (bits & 0x3);
-}}
-static inline uint8_t get_{0}_bits(
- const css_computed_style *style)
-{{
- uint32_t bits = style->i.bits[{1}_INDEX];
- bits &= {1}_MASK;
- bits >>= {1}_SHIFT;
-
- /* 7bits: uuuuutt : units | type */
- return bits;
-}}'''
-overrides['get']['top'] = get_side.format('top', 'TOP')
-overrides['get']['right'] = get_side.format('right', 'RIGHT')
-#overrides['get']['bottom'] = get_side.format('bottom', 'BOTTOM')
-overrides['get']['left'] = get_side.format('left', 'LEFT')
diff --git a/src/select/select_generator.py b/src/select/select_generator.py
index 4f6ee68..94d44b0 100644
--- a/src/select/select_generator.py
+++ b/src/select/select_generator.py
@@ -746,42 +746,32 @@ class CSSGroup:
return t.to_string()
- def make_propget_h(self):
- """Output this group's property functions for the propget.h file."""
- t = Text()
+ def print_propget(self, t, p, only_bits=False):
i_dot, grp = self.get_idot_grp()
- for p in sorted(self.props, key=(lambda x: x.name)):
- defines, undefs = p.def_undefs
-
- t.append()
- t.append(defines)
-
- if p.name in overrides['get']:
- t.append(overrides['get'][p.name], pre_formatted=True)
- t.append(undefs)
- continue
+ 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)
- vals = p.get_param_values(pointer=True)
- params = ', '.join([ 'css_computed_style *style' ]
- + [ ' '.join(x) for x in vals ])
- t.append('static inline uint8_t get_{}(const {})'.format(
- p.name, params))
- t.append('{')
+ if self.name != 'style':
+ t.append('if (style{} != NULL) {{'.format(grp))
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('bits &= {}_MASK;'.format(p.name.upper()))
+ t.append('bits >>= {}_SHIFT;'.format(p.name.upper()))
+ t.append()
- t.append('uint32_t bits = style{}->{}bits[{}_INDEX];'.format(
- grp, i_dot, p.name.upper()))
- t.append('bits &= {}_MASK;'.format(p.name.upper()))
- t.append('bits >>= {}_SHIFT;'.format(p.name.upper()))
- t.append()
+ type_mask, shift_list, bits_comment = p.get_bits()
+ t.append(bits_comment)
- type_mask, shift_list, bits_comment = p.get_bits()
- t.append(bits_comment)
+ if only_bits == False:
if p.condition:
t.append('if ((bits & {}) == {}) {{'.format(
@@ -806,24 +796,42 @@ class CSSGroup:
if p.condition:
t.indent(-1)
t.append('}')
-
t.append()
- 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.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('}')
+
+ def make_propget_h(self):
+ """Output this group's property functions for the propget.h file."""
+ t = Text()
+
+ for p in sorted(self.props, key=(lambda x: x.name)):
+ defines, undefs = p.def_undefs
+
+ t.append()
+ t.append(defines)
+
+ self.print_propget(t, p, True)
+
+ if p.name in overrides['get']:
+ t.append(overrides['get'][p.name], pre_formatted=True)
+ else:
+ self.print_propget(t, p)
+
t.append(undefs)
return t.to_string()
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;
--
Cascading Style Sheets library
6 months, 1 week
libcss: branch tlsa/calc updated. release/0.9.1-87-g67364ac
by NetSurf Browser Project
Gitweb links:
...log http://git.netsurf-browser.org/libcss.git/shortlog/67364acc7eeb51ee26b6fd...
...commit http://git.netsurf-browser.org/libcss.git/commit/67364acc7eeb51ee26b6fdab...
...tree http://git.netsurf-browser.org/libcss.git/tree/67364acc7eeb51ee26b6fdab46...
The branch, tlsa/calc has been updated
discards 6d58bc4e0278c971ba7fc9623367d8ea241689ee (commit)
discards ad87e675c59bc76a64c445cc89b8cc4522e6f761 (commit)
discards 765404ce9ca85d6eb531f8f9df56b82ed6477315 (commit)
discards 177d9baa45a1b8d325bb42202d7ac72133dd8dc0 (commit)
discards 5b6dcb98c7ff91177c6d26bff06a1d37e21c3438 (commit)
discards cf91e739e7b181d4a734c1394e426c3bb4cc6483 (commit)
via 67364acc7eeb51ee26b6fdab466ccd930a32f904 (commit)
via 9434b1d08875f0789eb13bef25125db2d8558279 (commit)
via 6ae36f9e473d3a0ed3b10a9205230fa8cdc40af5 (commit)
via 901026e7aad4b68d9dfcb17416df179cfc923ff3 (commit)
via 825ef83e41ea3389a1e1d0ad16b688f3fe9dfc3f (commit)
via ce71fe3d4f6a348ef1b2024389905c844fe8e5fe (commit)
via 022a04d022f446b57818dfa7d5b49928f9d63bf4 (commit)
via 609e1623335d5d5147439c5ba600152e963fc951 (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 (6d58bc4e0278c971ba7fc9623367d8ea241689ee)
\
N -- N -- N (67364acc7eeb51ee26b6fdab466ccd930a32f904)
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=67364acc7eeb51ee26b6...
commit 67364acc7eeb51ee26b6fdab466ccd930a32f904
Author: Daniel Silverstone <dsilvers(a)digital-scurf.org>
Commit: Michael Drake <tlsa(a)netsurf-browser.org>
(calc): Update bytecode for calc() to be in an lwc_string
In order to permit us to share calc expressions between styles
and computed styles, without copying, we embed the calc expression
bytecode into an lwc string. This is effectively using lwc_string
as an interned byte buffer, there may be a nicer way to do this in
the future.
Signed-off-by: Daniel Silverstone <dsilvers(a)digital-scurf.org>
diff --git a/src/parse/properties/utils.c b/src/parse/properties/utils.c
index fe5ee6b..fa8ffbe 100644
--- a/src/parse/properties/utils.c
+++ b/src/parse/properties/utils.c
@@ -1362,16 +1362,17 @@ cleanup:
static css_error
css__parse_calc_sum(css_language *c,
const parserutils_vector *vector, int *ctx,
- css_style *result);
+ parserutils_buffer *result);
static css_error
css__parse_calc_number(
const parserutils_vector *vector, int *ctx,
- css_style *result)
+ parserutils_buffer *result)
{
const css_token *token;
css_fixed num;
size_t consumed;
+ css_code_t push = CALC_PUSH_NUMBER;
/* Consume the number token */
token = parserutils_vector_iterate(vector, ctx);
@@ -1386,13 +1387,18 @@ css__parse_calc_number(
return CSS_INVALID;
}
- return css__stylesheet_style_vappend(result, 2, (css_code_t) CALC_PUSH_NUMBER, (css_code_t)num);
+ return css_error_from_parserutils_error(
+ parserutils_buffer_appendv(result, 2,
+ &push, sizeof(push),
+ &num, sizeof(num)
+ )
+ );
}
static css_error
css__parse_calc_value(css_language *c,
const parserutils_vector *vector, int *ctx,
- css_style *result)
+ parserutils_buffer *result)
{
css_error error;
int orig_ctx = *ctx;
@@ -1426,6 +1432,7 @@ css__parse_calc_value(css_language *c,
{
css_fixed length = 0;
uint32_t unit = 0;
+ css_code_t push = CALC_PUSH_VALUE;
*ctx = orig_ctx;
error = css__parse_unit_specifier(c, vector, ctx, UNIT_CALC_NUMBER, &length, &unit);
@@ -1434,7 +1441,14 @@ css__parse_calc_value(css_language *c,
return error;
}
- error = css__stylesheet_style_vappend(result, 3, (css_code_t) CALC_PUSH_VALUE, length, unit);
+ error = css_error_from_parserutils_error(
+ parserutils_buffer_appendv(result, 3,
+ &push, sizeof(push),
+ &length, sizeof(length),
+ &unit, sizeof(unit)
+ )
+ );
+
}
break;
@@ -1455,12 +1469,11 @@ css__parse_calc_value(css_language *c,
static css_error
css__parse_calc_product(css_language *c,
const parserutils_vector *vector, int *ctx,
- css_style *result)
+ parserutils_buffer *result)
{
css_error error = CSS_OK;
const css_token *token;
- bool multiplication;
-
+ css_code_t operator;
/* First parse a value */
error = css__parse_calc_value(c, vector, ctx, result);
@@ -1480,9 +1493,9 @@ css__parse_calc_product(css_language *c,
tokenIsChar(token, '-'))
break;
else if (tokenIsChar(token, '*'))
- multiplication = true;
+ operator = CALC_MULTIPLY;
else if (tokenIsChar(token, '/'))
- multiplication = false;
+ operator = CALC_DIVIDE;
else {
error = CSS_INVALID;
break;
@@ -1492,7 +1505,7 @@ css__parse_calc_product(css_language *c,
consumeWhitespace(vector, ctx);
- if (multiplication) {
+ if (operator == CALC_MULTIPLY) {
/* parse another value */
error = css__parse_calc_value(c, vector, ctx, result);
} else {
@@ -1502,8 +1515,9 @@ css__parse_calc_product(css_language *c,
break;
/* emit the multiplication/division operator */
- error = css__stylesheet_style_append(result,
- (css_code_t) (multiplication ? CALC_MULTIPLY : CALC_DIVIDE));
+ error = css_error_from_parserutils_error(
+ parserutils_buffer_append(result, (const uint8_t *)&operator, sizeof(operator))
+ );
} while (1);
/* We've fallen off, either we had an error or we're left with ')' */
return error;
@@ -1513,12 +1527,11 @@ css__parse_calc_product(css_language *c,
css_error
css__parse_calc_sum(css_language *c,
const parserutils_vector *vector, int *ctx,
- css_style *result)
+ parserutils_buffer *result)
{
css_error error = CSS_OK;
const css_token *token;
- bool addition;
-
+ css_code_t operator;
/* First parse a product */
error = css__parse_calc_product(c, vector, ctx, result);
@@ -1535,9 +1548,9 @@ css__parse_calc_sum(css_language *c,
} else if (tokenIsChar(token, ')'))
break;
else if (tokenIsChar(token, '+'))
- addition = true;
+ operator = CALC_ADD;
else if (tokenIsChar(token, '-'))
- addition = false;
+ operator = CALC_SUBTRACT;
else {
error = CSS_INVALID;
break;
@@ -1552,7 +1565,9 @@ css__parse_calc_sum(css_language *c,
break;
/* emit the addition/subtraction operator */
- error = css__stylesheet_style_append(result, (css_code_t) (addition ? CALC_ADD : CALC_SUBTRACT));
+ error = css_error_from_parserutils_error(
+ parserutils_buffer_append(result, (const uint8_t *)&operator, sizeof(operator))
+ );
} while (1);
/* We've fallen off, either we had an error or we're left with ')' */
return error;
@@ -1569,6 +1584,10 @@ css_error css__parse_calc(css_language *c,
const css_token *token;
css_error error = CSS_OK;
css_style *calc_style = NULL;
+ parserutils_buffer *calc_buffer = NULL;
+ lwc_string *calc_expr = NULL;
+ uint32_t expr_index = 0;
+ css_code_t finish = CALC_FINISH;
consumeWhitespace(vector, ctx);
@@ -1578,6 +1597,12 @@ css_error css__parse_calc(css_language *c,
return CSS_INVALID;
}
+ if (parserutils_buffer_create(&calc_buffer) != PARSERUTILS_OK) {
+ /* Since &calc_buffer is valid, the only error case is NONMEM */
+ *ctx = orig_ctx;
+ return CSS_NOMEM;
+ }
+
error = css__stylesheet_style_create(c->sheet, &calc_style);
if (error != CSS_OK)
goto cleanup;
@@ -1585,12 +1610,12 @@ css_error css__parse_calc(css_language *c,
error = css__stylesheet_style_append(calc_style, property);
if (error != CSS_OK)
goto cleanup;
-
+
error = css__stylesheet_style_append(calc_style, (css_code_t) unit);
if (error != CSS_OK)
goto cleanup;
- error = css__parse_calc_sum(c, vector, ctx, calc_style);
+ error = css__parse_calc_sum(c, vector, ctx, calc_buffer);
if (error != CSS_OK)
goto cleanup;
@@ -1602,17 +1627,35 @@ css_error css__parse_calc(css_language *c,
goto cleanup;
}
+ /* Append the indicator that the calc is finished */
+ error = css_error_from_parserutils_error(
+ parserutils_buffer_append(calc_buffer, (const uint8_t *)&finish, sizeof(finish))
+ );
+ if (error != CSS_OK)
+ goto cleanup;
+
/* Swallow that close paren */
parserutils_vector_iterate(vector, ctx);
- /* Append the indicator that the calc is finished */
- error = css__stylesheet_style_append(calc_style, (css_code_t) CALC_FINISH);
+ /* Create the lwc string representing the calculation and store it in */
+ error = css_error_from_lwc_error(
+ lwc_intern_string((const char *)calc_buffer->data, calc_buffer->length, &calc_expr)
+ );
if (error != CSS_OK)
goto cleanup;
+ /* This always takes ownership of calc_expr, so we should not use after this */
+ error = css__stylesheet_string_add(calc_style->sheet, calc_expr, &expr_index);
+ if (error != CSS_OK)
+ goto cleanup;
+
+ css__stylesheet_style_append(calc_style, (css_code_t) expr_index);
+
error = css__stylesheet_merge_style(result, calc_style);
cleanup:
css__stylesheet_style_destroy(calc_style);
+ parserutils_buffer_destroy(calc_buffer);
+ /* We do not need to clean up calc_expr, it will never leak */
if (error != CSS_OK) {
*ctx = orig_ctx;
}
diff --git a/test/dump.h b/test/dump.h
index a1fdd1f..eac0a9f 100644
--- a/test/dump.h
+++ b/test/dump.h
@@ -803,15 +803,23 @@ void dump_bytecode(css_style *style, char **ptr, uint32_t depth)
} else if (getFlagValue(opv) == FLAG_VALUE_UNSET) {
*ptr += sprintf(*ptr, "unset");
} else if (isCalc(opv)) {
+ lwc_string *calc_expr = NULL;
+ const uint8_t *codeptr = NULL;
+ css_code_t calc_opcode;
+ uint32_t unit, snum;
/* First entry is a unit */
- uint32_t unit = *((uint32_t *)bytecode);
+ unit = *((uint32_t *)bytecode);
ADVANCE(sizeof(unit));
+ /* Second entry is an lwc_string of the expression */
+ snum = *((uint32_t *)bytecode);
+ ADVANCE(sizeof(snum));
+ css__stylesheet_string_get(style->sheet, snum, &calc_expr);
+ codeptr = (const uint8_t *)lwc_string_data(calc_expr);
*ptr += sprintf(*ptr, "/* -> ");
dump_unit(0, unit, ptr);
*ptr += sprintf(*ptr, " */ calc(");
- css_code_t calc_opcode;
- while ((calc_opcode = *((css_code_t *)bytecode)) != CALC_FINISH) {
- ADVANCE(sizeof(calc_opcode));
+ while ((calc_opcode = *((css_code_t *)codeptr)) != CALC_FINISH) {
+ codeptr += sizeof(calc_opcode);
switch (calc_opcode) {
case CALC_ADD:
*ptr += sprintf(*ptr, "+ ");
@@ -826,17 +834,17 @@ void dump_bytecode(css_style *style, char **ptr, uint32_t depth)
*ptr += sprintf(*ptr, "/ ");
break;
case CALC_PUSH_VALUE: {
- css_fixed num = *((css_fixed *)bytecode);
- ADVANCE(sizeof(num));
- uint32_t unit = *((uint32_t *)bytecode);
- ADVANCE(sizeof(unit));
+ css_fixed num = *((css_fixed *)codeptr);
+ codeptr += sizeof(num);
+ uint32_t unit = *((uint32_t *)codeptr);
+ codeptr += sizeof(unit);
dump_unit(num, unit, ptr);
*ptr += sprintf(*ptr, " ");
break;
}
case CALC_PUSH_NUMBER: {
- css_fixed num = *((css_fixed *)bytecode);
- ADVANCE(sizeof(num));
+ css_fixed num = *((css_fixed *)codeptr);
+ codeptr += sizeof(num);
dump_number(num, ptr);
*ptr += sprintf(*ptr, " ");
break;
@@ -846,7 +854,6 @@ void dump_bytecode(css_style *style, char **ptr, uint32_t depth)
break;
}
}
- ADVANCE(sizeof(calc_opcode));
*ptr += sprintf(*ptr, "=)");
} else {
value = getValue(opv);
commitdiff http://git.netsurf-browser.org/libcss.git/commit/?id=9434b1d08875f0789eb1...
commit 9434b1d08875f0789eb13bef25125db2d8558279
Author: Michael Drake <tlsa(a)netsurf-browser.org>
Commit: Michael Drake <tlsa(a)netsurf-browser.org>
bytecode: Use define for calc value identifier
diff --git a/src/bytecode/bytecode.h b/src/bytecode/bytecode.h
index e845170..d799194 100644
--- a/src/bytecode/bytecode.h
+++ b/src/bytecode/bytecode.h
@@ -14,6 +14,8 @@
#include <libcss/types.h>
#include <libcss/properties.h>
+#include "bytecode/opcodes.h"
+
typedef uint32_t css_code_t;
typedef enum css_properties_e opcode_t;
@@ -139,8 +141,7 @@ static inline bool isInherit(css_code_t OPV)
static inline bool isCalc(css_code_t OPV)
{
- /* Note, this relies on all _CALC values being the same ultimately */
- return getValue(OPV) == 0x7f;
+ return getValue(OPV) == VALUE_IS_CALC;
}
#endif
diff --git a/src/bytecode/opcodes.h b/src/bytecode/opcodes.h
index 0ff67bb..da420e1 100644
--- a/src/bytecode/opcodes.h
+++ b/src/bytecode/opcodes.h
@@ -10,6 +10,8 @@
#include <inttypes.h>
+#define VALUE_IS_CALC 0x007f
+
enum op_align_content {
ALIGN_CONTENT_STRETCH = 0x0000,
ALIGN_CONTENT_FLEX_START = 0x0001,
@@ -119,7 +121,7 @@ enum op_border_style {
};
enum op_border_width {
- BORDER_WIDTH_CALC = 0x007f,
+ BORDER_WIDTH_CALC = VALUE_IS_CALC,
BORDER_WIDTH_SET = 0x0080,
BORDER_WIDTH_THIN = 0x0000,
BORDER_WIDTH_MEDIUM = 0x0001,
@@ -127,7 +129,7 @@ enum op_border_width {
};
enum op_bottom {
- BOTTOM_CALC = 0x007f,
+ BOTTOM_CALC = VALUE_IS_CALC,
BOTTOM_SET = 0x0080,
BOTTOM_AUTO = 0x0000
};
@@ -200,7 +202,7 @@ enum op_color {
enum op_column_count {
COLUMN_COUNT_AUTO = 0x0000,
- COLUMN_COUNT_CALC = 0x007f,
+ COLUMN_COUNT_CALC = VALUE_IS_CALC,
COLUMN_COUNT_SET = 0x0080
};
@@ -211,7 +213,7 @@ enum op_column_fill {
enum op_column_gap {
COLUMN_GAP_NORMAL = 0x0000,
- COLUMN_GAP_CALC = 0x007f,
+ COLUMN_GAP_CALC = VALUE_IS_CALC,
COLUMN_GAP_SET = 0x0080
};
@@ -249,7 +251,7 @@ enum op_column_span {
enum op_column_width {
COLUMN_WIDTH_AUTO = 0x0000,
- COLUMN_WIDTH_CALC = 0x007f,
+ COLUMN_WIDTH_CALC = VALUE_IS_CALC,
COLUMN_WIDTH_SET = 0x0080
};
@@ -360,7 +362,7 @@ enum op_empty_cells {
enum op_flex_basis {
FLEX_BASIS_AUTO = 0x0000,
FLEX_BASIS_CONTENT = 0x0001,
- FLEX_BASIS_CALC = 0x007f,
+ FLEX_BASIS_CALC = VALUE_IS_CALC,
FLEX_BASIS_SET = 0x0080
};
@@ -372,12 +374,12 @@ enum op_flex_direction {
};
enum op_flex_grow {
- FLEX_GROW_CALC = 0x007f,
+ FLEX_GROW_CALC = VALUE_IS_CALC,
FLEX_GROW_SET = 0x0080
};
enum op_flex_shrink {
- FLEX_SHRINK_CALC = 0x007f,
+ FLEX_SHRINK_CALC = VALUE_IS_CALC,
FLEX_SHRINK_SET = 0x0080
};
@@ -407,7 +409,7 @@ enum op_font_family {
};
enum op_font_size {
- FONT_SIZE_CALC = 0x007f,
+ FONT_SIZE_CALC = VALUE_IS_CALC,
FONT_SIZE_DIMENSION = 0x0080,
FONT_SIZE_XX_SMALL = 0x0000,
@@ -449,7 +451,7 @@ enum op_font_weight {
};
enum op_height {
- HEIGHT_CALC = 0x007f,
+ HEIGHT_CALC = VALUE_IS_CALC,
HEIGHT_SET = 0x0080,
HEIGHT_AUTO = 0x0000
};
@@ -470,13 +472,13 @@ enum op_left {
};
enum op_letter_spacing {
- LETTER_SPACING_CALC = 0x007f,
+ LETTER_SPACING_CALC = VALUE_IS_CALC,
LETTER_SPACING_SET = 0x0080,
LETTER_SPACING_NORMAL = 0x0000
};
enum op_line_height {
- LINE_HEIGHT_CALC = 0x007f,
+ LINE_HEIGHT_CALC = VALUE_IS_CALC,
LINE_HEIGHT_NUMBER = 0x0080,
LINE_HEIGHT_DIMENSION = 0x0081,
LINE_HEIGHT_NORMAL = 0x0000
@@ -548,31 +550,31 @@ enum op_list_style_type {
};
enum op_margin {
- MARGIN_CALC = 0x007f,
+ MARGIN_CALC = VALUE_IS_CALC,
MARGIN_SET = 0x0080,
MARGIN_AUTO = 0x0000
};
enum op_max_height {
- MAX_HEIGHT_CALC = 0x007f,
+ MAX_HEIGHT_CALC = VALUE_IS_CALC,
MAX_HEIGHT_SET = 0x0080,
MAX_HEIGHT_NONE = 0x0000
};
enum op_max_width {
- MAX_WIDTH_CALC = 0x007f,
+ MAX_WIDTH_CALC = VALUE_IS_CALC,
MAX_WIDTH_SET = 0x0080,
MAX_WIDTH_NONE = 0x0000
};
enum op_min_height {
- MIN_HEIGHT_CALC = 0x007f,
+ MIN_HEIGHT_CALC = VALUE_IS_CALC,
MIN_HEIGHT_SET = 0x0080,
MIN_HEIGHT_AUTO = 0x0000
};
enum op_min_width {
- MIN_WIDTH_CALC = 0x007f,
+ MIN_WIDTH_CALC = VALUE_IS_CALC,
MIN_WIDTH_SET = 0x0080,
MIN_WIDTH_AUTO = 0x0000
};
@@ -582,12 +584,12 @@ enum op_opacity {
};
enum op_order {
- ORDER_CALC = 0x007f,
+ ORDER_CALC = VALUE_IS_CALC,
ORDER_SET = 0x0080
};
enum op_orphans {
- ORPHANS_CALC = 0x007f,
+ ORPHANS_CALC = VALUE_IS_CALC,
ORPHANS_SET = 0x0080
};
@@ -626,7 +628,7 @@ enum op_overflow {
};
enum op_padding {
- PADDING_CALC = 0x007f,
+ PADDING_CALC = VALUE_IS_CALC,
PADDING_SET = 0x0080
};
@@ -652,22 +654,22 @@ enum op_page_break_inside {
};
enum op_pause_after {
- PAUSE_AFTER_CALC = 0x007f,
+ PAUSE_AFTER_CALC = VALUE_IS_CALC,
PAUSE_AFTER_SET = 0x0080
};
enum op_pause_before {
- PAUSE_BEFORE_CALC = 0x007f,
+ PAUSE_BEFORE_CALC = VALUE_IS_CALC,
PAUSE_BEFORE_SET = 0x0080
};
enum op_pitch_range {
- PITCH_RANGE_CALC = 0x007f,
+ PITCH_RANGE_CALC = VALUE_IS_CALC,
PITCH_RANGE_SET = 0x0080
};
enum op_pitch {
- PITCH_CALC = 0x007f,
+ PITCH_CALC = VALUE_IS_CALC,
PITCH_FREQUENCY = 0x0080,
PITCH_X_LOW = 0x0000,
@@ -702,7 +704,7 @@ enum op_quotes {
};
enum op_richness {
- RICHNESS_CALC = 0x007f,
+ RICHNESS_CALC = VALUE_IS_CALC,
RICHNESS_SET = 0x0080
};
@@ -733,7 +735,7 @@ enum op_speak {
};
enum op_speech_rate {
- SPEECH_RATE_CALC = 0x007f,
+ SPEECH_RATE_CALC = VALUE_IS_CALC,
SPEECH_RATE_SET = 0x0080,
SPEECH_RATE_X_SLOW = 0x0000,
@@ -746,7 +748,7 @@ enum op_speech_rate {
};
enum op_stress {
- STRESS_CALC = 0x007f,
+ STRESS_CALC = VALUE_IS_CALC,
STRESS_SET = 0x0080
};
@@ -775,7 +777,7 @@ enum op_text_decoration {
};
enum op_text_indent {
- TEXT_INDENT_CALC = 0x007f,
+ TEXT_INDENT_CALC = VALUE_IS_CALC,
TEXT_INDENT_SET = 0x0080
};
@@ -799,7 +801,7 @@ enum op_unicode_bidi {
};
enum op_vertical_align {
- VERTICAL_ALIGN_CALC = 0x007f,
+ VERTICAL_ALIGN_CALC = VALUE_IS_CALC,
VERTICAL_ALIGN_SET = 0x0080,
VERTICAL_ALIGN_BASELINE = 0x0000,
@@ -830,7 +832,7 @@ enum op_voice_family {
};
enum op_volume {
- VOLUME_CALC = 0x007f,
+ VOLUME_CALC = VALUE_IS_CALC,
VOLUME_NUMBER = 0x0080,
VOLUME_DIMENSION = 0x0081,
@@ -851,19 +853,19 @@ enum op_white_space {
};
enum op_widows {
- WIDOWS_CALC = 0x007f,
+ WIDOWS_CALC = VALUE_IS_CALC,
WIDOWS_SET = 0x0080
};
enum op_width {
- WIDTH_CALC = 0x007f,
+ WIDTH_CALC = VALUE_IS_CALC,
WIDTH_SET = 0x0080,
WIDTH_AUTO = 0x0000
};
enum op_word_spacing {
- WORD_SPACING_CALC = 0x007f,
+ WORD_SPACING_CALC = VALUE_IS_CALC,
WORD_SPACING_SET = 0x0080,
WORD_SPACING_NORMAL = 0x0000
@@ -876,7 +878,7 @@ enum op_writing_mode {
};
enum op_z_index {
- Z_INDEX_CALC = 0x007f,
+ Z_INDEX_CALC = VALUE_IS_CALC,
Z_INDEX_SET = 0x0080,
Z_INDEX_AUTO = 0x0000
commitdiff http://git.netsurf-browser.org/libcss.git/commit/?id=6ae36f9e473d3a0ed3b1...
commit 6ae36f9e473d3a0ed3b10a9205230fa8cdc40af5
Author: Daniel Silverstone <dsilvers(a)netsurf-browser.org>
Commit: Michael Drake <tlsa(a)netsurf-browser.org>
parse: Tests and fixes for calc() parser.
Co-authored-by: Michael Drake <michael.drake(a)netsurf-browser.org>
diff --git a/src/bytecode/bytecode.h b/src/bytecode/bytecode.h
index 7c21d50..e845170 100644
--- a/src/bytecode/bytecode.h
+++ b/src/bytecode/bytecode.h
@@ -35,12 +35,13 @@ enum flag {
};
enum calc_opcodes {
- CALC_PUSH_VALUE = 'V',
- CALC_ADD = '+',
- CALC_SUBTRACT = '-',
- CALC_MULTIPLY = '*',
- CALC_DIVIDE = '/',
- CALC_FINISH = '=',
+ CALC_PUSH_NUMBER = 'N',
+ CALC_PUSH_VALUE = 'V',
+ CALC_ADD = '+',
+ CALC_SUBTRACT = '-',
+ CALC_MULTIPLY = '*',
+ CALC_DIVIDE = '/',
+ CALC_FINISH = '=',
};
typedef enum unit {
diff --git a/src/parse/properties/utils.c b/src/parse/properties/utils.c
index 7f9d9d2..fe5ee6b 100644
--- a/src/parse/properties/utils.c
+++ b/src/parse/properties/utils.c
@@ -1365,6 +1365,31 @@ css__parse_calc_sum(css_language *c,
css_style *result);
static css_error
+css__parse_calc_number(
+ const parserutils_vector *vector, int *ctx,
+ css_style *result)
+{
+ const css_token *token;
+ css_fixed num;
+ size_t consumed;
+
+ /* Consume the number token */
+ token = parserutils_vector_iterate(vector, ctx);
+ if (token == NULL || token->type != CSS_TOKEN_NUMBER) {
+ return CSS_INVALID;
+ }
+
+ num = css__number_from_string((const uint8_t *)lwc_string_data(token->idata),
+ lwc_string_length(token->idata), false, &consumed);
+
+ if (consumed != lwc_string_length(token->idata)) {
+ return CSS_INVALID;
+ }
+
+ return css__stylesheet_style_vappend(result, 2, (css_code_t) CALC_PUSH_NUMBER, (css_code_t)num);
+}
+
+static css_error
css__parse_calc_value(css_language *c,
const parserutils_vector *vector, int *ctx,
css_style *result)
@@ -1377,6 +1402,7 @@ css__parse_calc_value(css_language *c,
token = parserutils_vector_peek(vector, *ctx);
if (tokenIsChar(token, '(')) {
parserutils_vector_iterate(vector, ctx);
+ consumeWhitespace(vector, ctx);
error = css__parse_calc_sum(c, vector, ctx, result);
if (error != CSS_OK) {
return error;
@@ -1389,7 +1415,12 @@ css__parse_calc_value(css_language *c,
/* Consume the close-paren to complete this value */
parserutils_vector_iterate(vector, ctx);
} else switch (token->type) {
- case CSS_TOKEN_NUMBER: /* Fall through */
+ case CSS_TOKEN_NUMBER:
+ error = css__parse_calc_number(vector, ctx, result);
+ if (error != CSS_OK) {
+ return error;
+ }
+ break;
case CSS_TOKEN_DIMENSION: /* Fall through */
case CSS_TOKEN_PERCENTAGE:
{
@@ -1412,11 +1443,7 @@ css__parse_calc_value(css_language *c,
break;
}
- token = parserutils_vector_peek(vector, *ctx);
- while (token->type == CSS_TOKEN_S) {
- parserutils_vector_iterate(vector, ctx);
- token = parserutils_vector_peek(vector, *ctx);
- }
+ consumeWhitespace(vector, ctx);
return error;
}
@@ -1462,14 +1489,15 @@ css__parse_calc_product(css_language *c,
}
/* Consume that * or / now */
parserutils_vector_iterate(vector, ctx);
- token = parserutils_vector_peek(vector, *ctx);
- while (token->type == CSS_TOKEN_S) {
- parserutils_vector_iterate(vector, ctx);
- token = parserutils_vector_peek(vector, *ctx);
+ consumeWhitespace(vector, ctx);
+
+ if (multiplication) {
+ /* parse another value */
+ error = css__parse_calc_value(c, vector, ctx, result);
+ } else {
+ error = css__parse_calc_number(vector, ctx, result);
}
- /* parse another value */
- error = css__parse_calc_value(c, vector, ctx, result);
if (error != CSS_OK)
break;
@@ -1516,12 +1544,7 @@ css__parse_calc_sum(css_language *c,
}
/* Consume that + or - now */
parserutils_vector_iterate(vector, ctx);
- token = parserutils_vector_peek(vector, *ctx);
-
- while (token->type == CSS_TOKEN_S) {
- parserutils_vector_iterate(vector, ctx);
- token = parserutils_vector_peek(vector, *ctx);
- }
+ consumeWhitespace(vector, ctx);
/* parse another product */
error = css__parse_calc_product(c, vector, ctx, result);
@@ -1547,17 +1570,14 @@ css_error css__parse_calc(css_language *c,
css_error error = CSS_OK;
css_style *calc_style = NULL;
+ consumeWhitespace(vector, ctx);
+
token = parserutils_vector_peek(vector, *ctx);
if (token == NULL) {
*ctx = orig_ctx;
return CSS_INVALID;
}
- while (token->type == CSS_TOKEN_S) {
- parserutils_vector_iterate(vector, ctx);
- token = parserutils_vector_peek(vector, *ctx);
- }
-
error = css__stylesheet_style_create(c->sheet, &calc_style);
if (error != CSS_OK)
goto cleanup;
@@ -1574,11 +1594,8 @@ css_error css__parse_calc(css_language *c,
if (error != CSS_OK)
goto cleanup;
+ consumeWhitespace(vector, ctx);
token = parserutils_vector_peek(vector, *ctx);
- while (token->type == CSS_TOKEN_S) {
- parserutils_vector_iterate(vector, ctx);
- token = parserutils_vector_peek(vector, *ctx);
- }
if (!tokenIsChar(token, ')')) {
/* If we don't get a close-paren, give up now */
error = CSS_INVALID;
diff --git a/test/data/parse2/calc.dat b/test/data/parse2/calc.dat
index 95abf6c..e9d176d 100644
--- a/test/data/parse2/calc.dat
+++ b/test/data/parse2/calc.dat
@@ -4,4 +4,154 @@
#expected
| *
| height: /* -> 0px */ calc(50vh 10px + =)
-#reset
\ No newline at end of file
+#reset
+
+#data
+* { line-height: calc(50vh + 10px)}
+#errors
+#expected
+| *
+| line-height: /* -> 0any */ calc(50vh 10px + =)
+#reset
+
+#data
+* { line-height: calc( / 2)}
+#errors
+#expected
+| *
+#reset
+
+#data
+* { line-height: calc( + 2)}
+#errors
+#expected
+| *
+#reset
+
+#data
+* { line-height: calc(2 / 2px)}
+#errors
+#expected
+| *
+#reset
+
+#data
+* { z-index: calc(50vh + 10px)}
+#errors
+#expected
+| *
+| z-index: /* -> 0number */ calc(50vh 10px + =)
+#reset
+
+#data
+* { z-index: calc(2 * 3)}
+#errors
+#expected
+| *
+| z-index: /* -> 0number */ calc(2 3 * =)
+#reset
+
+#data
+* { z-index: calc(50vh + 10px / 9)}
+#errors
+#expected
+| *
+| z-index: /* -> 0number */ calc(50vh 10px 9 / + =)
+#reset
+
+#data
+* { z-index: calc(1 + 2 + 3 + 4)}
+#errors
+#expected
+| *
+| z-index: /* -> 0number */ calc(1 2 + 3 + 4 + =)
+#reset
+
+#data
+* { z-index: calc(1 + 2 * 3 + 4)}
+#errors
+#expected
+| *
+| z-index: /* -> 0number */ calc(1 2 3 * + 4 + =)
+#reset
+
+#data
+* { z-index: calc((1 + 2) * (3 + 4))}
+#errors
+#expected
+| *
+| z-index: /* -> 0number */ calc(1 2 + 3 4 + * =)
+#reset
+
+#data
+* { z-index: calc(1 + 2}
+#errors
+#expected
+| *
+#reset
+
+#data
+* { z-index: calc(}
+#errors
+#expected
+| *
+#reset
+
+#data
+* { z-index: calc}
+#errors
+#expected
+| *
+#reset
+
+#data
+* { z-index: calc (1 + 2)}
+#errors
+#expected
+| *
+#reset
+
+#data
+* { z-index: calc(1)}
+#errors
+#expected
+| *
+| z-index: /* -> 0number */ calc(1 =)
+#reset
+
+#data
+* { z-index: calc()}
+#errors
+#expected
+| *
+#reset
+
+#data
+* { z-index: calc((1 + 2)}
+#errors
+#expected
+| *
+#reset
+
+#data
+* { z-index: calc(((1 + 2)))}
+#errors
+#expected
+| *
+| z-index: /* -> 0number */ calc(1 2 + =)
+#reset
+
+#data
+* { z-index: calc( ( ( 1 + 2 ) ) )}
+#errors
+#expected
+| *
+| z-index: /* -> 0number */ calc(1 2 + =)
+#reset
+
+#data
+* { z-index: calc( ( 3 / ( 1 + 2 ) ) )}
+#errors
+#expected
+| *
+#reset
diff --git a/test/dump.h b/test/dump.h
index 054194a..a1fdd1f 100644
--- a/test/dump.h
+++ b/test/dump.h
@@ -834,6 +834,13 @@ void dump_bytecode(css_style *style, char **ptr, uint32_t depth)
*ptr += sprintf(*ptr, " ");
break;
}
+ case CALC_PUSH_NUMBER: {
+ css_fixed num = *((css_fixed *)bytecode);
+ ADVANCE(sizeof(num));
+ dump_number(num, ptr);
+ *ptr += sprintf(*ptr, " ");
+ break;
+ }
default:
*ptr += sprintf(*ptr, "??%d ", calc_opcode);
break;
commitdiff http://git.netsurf-browser.org/libcss.git/commit/?id=901026e7aad4b68d9dfc...
commit 901026e7aad4b68d9dfcb17416df179cfc923ff3
Author: Daniel Silverstone <dsilvers(a)netsurf-browser.org>
Commit: Michael Drake <tlsa(a)netsurf-browser.org>
parse: calc() test and fixup.
diff --git a/src/bytecode/bytecode.h b/src/bytecode/bytecode.h
index 92040b4..7c21d50 100644
--- a/src/bytecode/bytecode.h
+++ b/src/bytecode/bytecode.h
@@ -34,6 +34,14 @@ enum flag {
FLAG_UNSET = (FLAG_VALUE_UNSET << 1),
};
+enum calc_opcodes {
+ CALC_PUSH_VALUE = 'V',
+ CALC_ADD = '+',
+ CALC_SUBTRACT = '-',
+ CALC_MULTIPLY = '*',
+ CALC_DIVIDE = '/',
+ CALC_FINISH = '=',
+};
typedef enum unit {
UNIT_LENGTH = (1u << 8),
@@ -128,6 +136,12 @@ static inline bool isInherit(css_code_t OPV)
return getFlagValue(OPV) == FLAG_VALUE_INHERIT;
}
+static inline bool isCalc(css_code_t OPV)
+{
+ /* Note, this relies on all _CALC values being the same ultimately */
+ return getValue(OPV) == 0x7f;
+}
+
#endif
diff --git a/src/parse/properties/css_property_parser_gen.c b/src/parse/properties/css_property_parser_gen.c
index 1260f28..622ce16 100644
--- a/src/parse/properties/css_property_parser_gen.c
+++ b/src/parse/properties/css_property_parser_gen.c
@@ -330,7 +330,7 @@ void output_calc(FILE *outputf, struct keyval *parseid, struct keyval_list *kvli
kind = ckv->key;
fprintf(outputf,
- "if ((token->type == CSS_TOKEN_IDENT) && "
+ "if ((token->type == CSS_TOKEN_FUNCTION) && "
"(lwc_string_caseless_isequal(token->idata, c->strings[CALC], &match) == lwc_error_ok && match))"
" {\n"
"\t\terror = css__parse_calc(c, vector, ctx, result, buildOPV(%s, 0, %s), %s);\n"
diff --git a/src/parse/properties/utils.c b/src/parse/properties/utils.c
index cce9717..7f9d9d2 100644
--- a/src/parse/properties/utils.c
+++ b/src/parse/properties/utils.c
@@ -1373,8 +1373,10 @@ css__parse_calc_value(css_language *c,
int orig_ctx = *ctx;
const css_token *token;
- token = parserutils_vector_iterate(vector, ctx);
+ /* On entry, we are already pointing at the value to parse, so peek it */
+ token = parserutils_vector_peek(vector, *ctx);
if (tokenIsChar(token, '(')) {
+ parserutils_vector_iterate(vector, ctx);
error = css__parse_calc_sum(c, vector, ctx, result);
if (error != CSS_OK) {
return error;
@@ -1384,7 +1386,8 @@ css__parse_calc_value(css_language *c,
if (!tokenIsChar(token, ')')) {
return CSS_INVALID;
}
-
+ /* Consume the close-paren to complete this value */
+ parserutils_vector_iterate(vector, ctx);
} else switch (token->type) {
case CSS_TOKEN_NUMBER: /* Fall through */
case CSS_TOKEN_DIMENSION: /* Fall through */
@@ -1400,7 +1403,7 @@ css__parse_calc_value(css_language *c,
return error;
}
- error = css__stylesheet_style_vappend(result, 3, (css_code_t) 'V', length, unit);
+ error = css__stylesheet_style_vappend(result, 3, (css_code_t) CALC_PUSH_VALUE, length, unit);
}
break;
@@ -1409,6 +1412,11 @@ css__parse_calc_value(css_language *c,
break;
}
+ token = parserutils_vector_peek(vector, *ctx);
+ while (token->type == CSS_TOKEN_S) {
+ parserutils_vector_iterate(vector, ctx);
+ token = parserutils_vector_peek(vector, *ctx);
+ }
return error;
}
@@ -1439,7 +1447,10 @@ css__parse_calc_product(css_language *c,
if (token == NULL) {
error = CSS_INVALID;
break;
- } else if (tokenIsChar(token, ')'))
+ } else if (
+ tokenIsChar(token, ')') ||
+ tokenIsChar(token, '+') ||
+ tokenIsChar(token, '-'))
break;
else if (tokenIsChar(token, '*'))
multiplication = true;
@@ -1450,15 +1461,21 @@ css__parse_calc_product(css_language *c,
break;
}
/* Consume that * or / now */
- token = parserutils_vector_iterate(vector, ctx);
+ parserutils_vector_iterate(vector, ctx);
+ token = parserutils_vector_peek(vector, *ctx);
+ while (token->type == CSS_TOKEN_S) {
+ parserutils_vector_iterate(vector, ctx);
+ token = parserutils_vector_peek(vector, *ctx);
+ }
/* parse another value */
error = css__parse_calc_value(c, vector, ctx, result);
if (error != CSS_OK)
break;
/* emit the multiplication/division operator */
- error = css__stylesheet_style_append(result, (css_code_t) (multiplication ? '*' : '/'));
+ error = css__stylesheet_style_append(result,
+ (css_code_t) (multiplication ? CALC_MULTIPLY : CALC_DIVIDE));
} while (1);
/* We've fallen off, either we had an error or we're left with ')' */
return error;
@@ -1498,7 +1515,13 @@ css__parse_calc_sum(css_language *c,
break;
}
/* Consume that + or - now */
- token = parserutils_vector_iterate(vector, ctx);
+ parserutils_vector_iterate(vector, ctx);
+ token = parserutils_vector_peek(vector, *ctx);
+
+ while (token->type == CSS_TOKEN_S) {
+ parserutils_vector_iterate(vector, ctx);
+ token = parserutils_vector_peek(vector, *ctx);
+ }
/* parse another product */
error = css__parse_calc_product(c, vector, ctx, result);
@@ -1506,7 +1529,7 @@ css__parse_calc_sum(css_language *c,
break;
/* emit the addition/subtraction operator */
- error = css__stylesheet_style_append(result, (css_code_t) (addition ? '+' : '-'));
+ error = css__stylesheet_style_append(result, (css_code_t) (addition ? CALC_ADD : CALC_SUBTRACT));
} while (1);
/* We've fallen off, either we had an error or we're left with ')' */
return error;
@@ -1524,16 +1547,15 @@ css_error css__parse_calc(css_language *c,
css_error error = CSS_OK;
css_style *calc_style = NULL;
- token = parserutils_vector_iterate(vector, ctx);
+ token = parserutils_vector_peek(vector, *ctx);
if (token == NULL) {
*ctx = orig_ctx;
return CSS_INVALID;
}
- if (!tokenIsChar(token, '(')) {
- /* If we don't get an open-paren, give up now */
- *ctx = orig_ctx;
- return CSS_INVALID;
+ while (token->type == CSS_TOKEN_S) {
+ parserutils_vector_iterate(vector, ctx);
+ token = parserutils_vector_peek(vector, *ctx);
}
error = css__stylesheet_style_create(c->sheet, &calc_style);
@@ -1545,27 +1567,33 @@ css_error css__parse_calc(css_language *c,
goto cleanup;
error = css__stylesheet_style_append(calc_style, (css_code_t) unit);
+ if (error != CSS_OK)
+ goto cleanup;
error = css__parse_calc_sum(c, vector, ctx, calc_style);
if (error != CSS_OK)
goto cleanup;
- token = parserutils_vector_iterate(vector, ctx);
+ token = parserutils_vector_peek(vector, *ctx);
+ while (token->type == CSS_TOKEN_S) {
+ parserutils_vector_iterate(vector, ctx);
+ token = parserutils_vector_peek(vector, *ctx);
+ }
if (!tokenIsChar(token, ')')) {
/* If we don't get a close-paren, give up now */
error = CSS_INVALID;
goto cleanup;
}
+ /* Swallow that close paren */
+ parserutils_vector_iterate(vector, ctx);
+
/* Append the indicator that the calc is finished */
- error = css__stylesheet_style_append(calc_style, (css_code_t) '=');
+ error = css__stylesheet_style_append(calc_style, (css_code_t) CALC_FINISH);
if (error != CSS_OK)
goto cleanup;
- /* TODO: Once we're OK to do so, merge the style */
- (void)result;
- /* error = css__stylesheet_style_merge_style(result, calc_style); */
-
+ error = css__stylesheet_merge_style(result, calc_style);
cleanup:
css__stylesheet_style_destroy(calc_style);
if (error != CSS_OK) {
diff --git a/test/data/parse2/INDEX b/test/data/parse2/INDEX
index e4a369c..7bc4295 100644
--- a/test/data/parse2/INDEX
+++ b/test/data/parse2/INDEX
@@ -24,3 +24,4 @@ multicol.dat Multi-column layout property tests
flexbox.dat Flexbox properties and shorthands tests
units.dat Length unit tests
dodgy-media-block.dat Media block with incomplete ruleset
+calc.dat calc() tests
diff --git a/test/data/parse2/calc.dat b/test/data/parse2/calc.dat
new file mode 100644
index 0000000..95abf6c
--- /dev/null
+++ b/test/data/parse2/calc.dat
@@ -0,0 +1,7 @@
+#data
+* { height: calc(50vh + 10px)}
+#errors
+#expected
+| *
+| height: /* -> 0px */ calc(50vh 10px + =)
+#reset
\ No newline at end of file
diff --git a/test/dump.h b/test/dump.h
index f585788..054194a 100644
--- a/test/dump.h
+++ b/test/dump.h
@@ -640,6 +640,12 @@ static void dump_unit(css_fixed val, uint32_t unit, char **ptr)
case UNIT_KHZ:
*ptr += sprintf(*ptr, "kHz");
break;
+ case UNIT_CALC_ANY:
+ *ptr += sprintf(*ptr, "any");
+ break;
+ case UNIT_CALC_NUMBER:
+ *ptr += sprintf(*ptr, "number");
+ break;
}
}
@@ -796,6 +802,45 @@ void dump_bytecode(css_style *style, char **ptr, uint32_t depth)
*ptr += sprintf(*ptr, "revert");
} else if (getFlagValue(opv) == FLAG_VALUE_UNSET) {
*ptr += sprintf(*ptr, "unset");
+ } else if (isCalc(opv)) {
+ /* First entry is a unit */
+ uint32_t unit = *((uint32_t *)bytecode);
+ ADVANCE(sizeof(unit));
+ *ptr += sprintf(*ptr, "/* -> ");
+ dump_unit(0, unit, ptr);
+ *ptr += sprintf(*ptr, " */ calc(");
+ css_code_t calc_opcode;
+ while ((calc_opcode = *((css_code_t *)bytecode)) != CALC_FINISH) {
+ ADVANCE(sizeof(calc_opcode));
+ switch (calc_opcode) {
+ case CALC_ADD:
+ *ptr += sprintf(*ptr, "+ ");
+ break;
+ case CALC_SUBTRACT:
+ *ptr += sprintf(*ptr, "- ");
+ break;
+ case CALC_MULTIPLY:
+ *ptr += sprintf(*ptr, "* ");
+ break;
+ case CALC_DIVIDE:
+ *ptr += sprintf(*ptr, "/ ");
+ break;
+ case CALC_PUSH_VALUE: {
+ css_fixed num = *((css_fixed *)bytecode);
+ ADVANCE(sizeof(num));
+ uint32_t unit = *((uint32_t *)bytecode);
+ ADVANCE(sizeof(unit));
+ dump_unit(num, unit, ptr);
+ *ptr += sprintf(*ptr, " ");
+ break;
+ }
+ default:
+ *ptr += sprintf(*ptr, "??%d ", calc_opcode);
+ break;
+ }
+ }
+ ADVANCE(sizeof(calc_opcode));
+ *ptr += sprintf(*ptr, "=)");
} else {
value = getValue(opv);
commitdiff http://git.netsurf-browser.org/libcss.git/commit/?id=825ef83e41ea3389a1e1...
commit 825ef83e41ea3389a1e1d0ad16b688f3fe9dfc3f
Author: Michael Drake <Michael Drake tlsa(a)netsurf-browser.org>
Commit: Michael Drake <tlsa(a)netsurf-browser.org>
parse: Update parser generator to support calc() details.
Co-authored-by: Daniel Silverstone <dsilvers(a)netsurf-browser.org>
diff --git a/src/bytecode/bytecode.h b/src/bytecode/bytecode.h
index ccfdcac..92040b4 100644
--- a/src/bytecode/bytecode.h
+++ b/src/bytecode/bytecode.h
@@ -76,6 +76,10 @@ typedef enum unit {
UNIT_DPI = (1 << 13) + 0,
UNIT_DPCM = (1 << 13) + 1,
UNIT_DPPX = (1 << 13) + 2,
+
+ /* These are special only to the CALC bytecodes */
+ UNIT_CALC_ANY = (1 << 20),
+ UNIT_CALC_NUMBER = (1 << 20) + 1,
} unit;
typedef uint32_t colour;
diff --git a/src/bytecode/opcodes.h b/src/bytecode/opcodes.h
index 8bc05b4..0ff67bb 100644
--- a/src/bytecode/opcodes.h
+++ b/src/bytecode/opcodes.h
@@ -119,6 +119,7 @@ enum op_border_style {
};
enum op_border_width {
+ BORDER_WIDTH_CALC = 0x007f,
BORDER_WIDTH_SET = 0x0080,
BORDER_WIDTH_THIN = 0x0000,
BORDER_WIDTH_MEDIUM = 0x0001,
@@ -126,6 +127,7 @@ enum op_border_width {
};
enum op_bottom {
+ BOTTOM_CALC = 0x007f,
BOTTOM_SET = 0x0080,
BOTTOM_AUTO = 0x0000
};
@@ -198,6 +200,7 @@ enum op_color {
enum op_column_count {
COLUMN_COUNT_AUTO = 0x0000,
+ COLUMN_COUNT_CALC = 0x007f,
COLUMN_COUNT_SET = 0x0080
};
@@ -208,6 +211,7 @@ enum op_column_fill {
enum op_column_gap {
COLUMN_GAP_NORMAL = 0x0000,
+ COLUMN_GAP_CALC = 0x007f,
COLUMN_GAP_SET = 0x0080
};
@@ -231,6 +235,7 @@ enum op_column_rule_style {
};
enum op_column_rule_width {
+ COLUMN_RULE_WIDTH_CALC = BORDER_WIDTH_CALC,
COLUMN_RULE_WIDTH_SET = BORDER_WIDTH_SET,
COLUMN_RULE_WIDTH_THIN = BORDER_WIDTH_THIN,
COLUMN_RULE_WIDTH_MEDIUM = BORDER_WIDTH_MEDIUM,
@@ -244,6 +249,7 @@ enum op_column_span {
enum op_column_width {
COLUMN_WIDTH_AUTO = 0x0000,
+ COLUMN_WIDTH_CALC = 0x007f,
COLUMN_WIDTH_SET = 0x0080
};
@@ -354,6 +360,7 @@ enum op_empty_cells {
enum op_flex_basis {
FLEX_BASIS_AUTO = 0x0000,
FLEX_BASIS_CONTENT = 0x0001,
+ FLEX_BASIS_CALC = 0x007f,
FLEX_BASIS_SET = 0x0080
};
@@ -365,10 +372,12 @@ enum op_flex_direction {
};
enum op_flex_grow {
+ FLEX_GROW_CALC = 0x007f,
FLEX_GROW_SET = 0x0080
};
enum op_flex_shrink {
+ FLEX_SHRINK_CALC = 0x007f,
FLEX_SHRINK_SET = 0x0080
};
@@ -398,6 +407,7 @@ enum op_font_family {
};
enum op_font_size {
+ FONT_SIZE_CALC = 0x007f,
FONT_SIZE_DIMENSION = 0x0080,
FONT_SIZE_XX_SMALL = 0x0000,
@@ -439,6 +449,7 @@ enum op_font_weight {
};
enum op_height {
+ HEIGHT_CALC = 0x007f,
HEIGHT_SET = 0x0080,
HEIGHT_AUTO = 0x0000
};
@@ -453,16 +464,19 @@ enum op_justify_content {
};
enum op_left {
+ LEFT_CALC = BOTTOM_CALC,
LEFT_SET = BOTTOM_SET,
LEFT_AUTO = BOTTOM_AUTO
};
enum op_letter_spacing {
+ LETTER_SPACING_CALC = 0x007f,
LETTER_SPACING_SET = 0x0080,
LETTER_SPACING_NORMAL = 0x0000
};
enum op_line_height {
+ LINE_HEIGHT_CALC = 0x007f,
LINE_HEIGHT_NUMBER = 0x0080,
LINE_HEIGHT_DIMENSION = 0x0081,
LINE_HEIGHT_NORMAL = 0x0000
@@ -534,26 +548,31 @@ enum op_list_style_type {
};
enum op_margin {
+ MARGIN_CALC = 0x007f,
MARGIN_SET = 0x0080,
MARGIN_AUTO = 0x0000
};
enum op_max_height {
+ MAX_HEIGHT_CALC = 0x007f,
MAX_HEIGHT_SET = 0x0080,
MAX_HEIGHT_NONE = 0x0000
};
enum op_max_width {
+ MAX_WIDTH_CALC = 0x007f,
MAX_WIDTH_SET = 0x0080,
MAX_WIDTH_NONE = 0x0000
};
enum op_min_height {
+ MIN_HEIGHT_CALC = 0x007f,
MIN_HEIGHT_SET = 0x0080,
MIN_HEIGHT_AUTO = 0x0000
};
enum op_min_width {
+ MIN_WIDTH_CALC = 0x007f,
MIN_WIDTH_SET = 0x0080,
MIN_WIDTH_AUTO = 0x0000
};
@@ -563,10 +582,12 @@ enum op_opacity {
};
enum op_order {
+ ORDER_CALC = 0x007f,
ORDER_SET = 0x0080
};
enum op_orphans {
+ ORPHANS_CALC = 0x007f,
ORPHANS_SET = 0x0080
};
@@ -605,6 +626,7 @@ enum op_overflow {
};
enum op_padding {
+ PADDING_CALC = 0x007f,
PADDING_SET = 0x0080
};
@@ -630,18 +652,22 @@ enum op_page_break_inside {
};
enum op_pause_after {
+ PAUSE_AFTER_CALC = 0x007f,
PAUSE_AFTER_SET = 0x0080
};
enum op_pause_before {
+ PAUSE_BEFORE_CALC = 0x007f,
PAUSE_BEFORE_SET = 0x0080
};
enum op_pitch_range {
+ PITCH_RANGE_CALC = 0x007f,
PITCH_RANGE_SET = 0x0080
};
enum op_pitch {
+ PITCH_CALC = 0x007f,
PITCH_FREQUENCY = 0x0080,
PITCH_X_LOW = 0x0000,
@@ -676,6 +702,7 @@ enum op_quotes {
};
enum op_richness {
+ RICHNESS_CALC = 0x007f,
RICHNESS_SET = 0x0080
};
@@ -706,6 +733,7 @@ enum op_speak {
};
enum op_speech_rate {
+ SPEECH_RATE_CALC = 0x007f,
SPEECH_RATE_SET = 0x0080,
SPEECH_RATE_X_SLOW = 0x0000,
@@ -718,6 +746,7 @@ enum op_speech_rate {
};
enum op_stress {
+ STRESS_CALC = 0x007f,
STRESS_SET = 0x0080
};
@@ -746,6 +775,7 @@ enum op_text_decoration {
};
enum op_text_indent {
+ TEXT_INDENT_CALC = 0x007f,
TEXT_INDENT_SET = 0x0080
};
@@ -757,6 +787,7 @@ enum op_text_transform {
};
enum op_top {
+ TOP_CALC = BOTTOM_CALC,
TOP_SET = BOTTOM_SET,
TOP_AUTO = BOTTOM_AUTO
};
@@ -768,6 +799,7 @@ enum op_unicode_bidi {
};
enum op_vertical_align {
+ VERTICAL_ALIGN_CALC = 0x007f,
VERTICAL_ALIGN_SET = 0x0080,
VERTICAL_ALIGN_BASELINE = 0x0000,
@@ -798,6 +830,7 @@ enum op_voice_family {
};
enum op_volume {
+ VOLUME_CALC = 0x007f,
VOLUME_NUMBER = 0x0080,
VOLUME_DIMENSION = 0x0081,
@@ -818,16 +851,19 @@ enum op_white_space {
};
enum op_widows {
+ WIDOWS_CALC = 0x007f,
WIDOWS_SET = 0x0080
};
enum op_width {
+ WIDTH_CALC = 0x007f,
WIDTH_SET = 0x0080,
WIDTH_AUTO = 0x0000
};
enum op_word_spacing {
+ WORD_SPACING_CALC = 0x007f,
WORD_SPACING_SET = 0x0080,
WORD_SPACING_NORMAL = 0x0000
@@ -840,6 +876,7 @@ enum op_writing_mode {
};
enum op_z_index {
+ Z_INDEX_CALC = 0x007f,
Z_INDEX_SET = 0x0080,
Z_INDEX_AUTO = 0x0000
diff --git a/src/parse/properties/css_property_parser_gen.c b/src/parse/properties/css_property_parser_gen.c
index 100fba1..1260f28 100644
--- a/src/parse/properties/css_property_parser_gen.c
+++ b/src/parse/properties/css_property_parser_gen.c
@@ -19,6 +19,12 @@
* list_style_position:CSS_PROP_LIST_STYLE_POSITION IDENT:( INHERIT: INSIDE:0,LIST_STYLE_POSITION_INSIDE OUTSIDE:0,LIST_STYLE_POSITION_OUTSIDE IDENT:)
*/
+typedef enum {
+ CALC_ANY,
+ CALC_NUMBER,
+ CALC_UNIT,
+} calc_kind;
+
struct keyval {
char *key;
char *val;
@@ -311,21 +317,34 @@ void output_color(FILE *outputf, struct keyval *parseid, struct keyval_list *kvl
parseid->val);
}
-void output_length_unit(FILE *outputf, struct keyval *parseid, struct keyval_list *kvlist)
+void output_calc(FILE *outputf, struct keyval *parseid, struct keyval_list *kvlist)
{
struct keyval *ckv = kvlist->item[0];
- int ident_count;
+ const char *kind;
+
+ if (strcmp(ckv->key, "NUMBER") == 0)
+ kind = "UNIT_CALC_NUMBER";
+ else if (strcmp(ckv->key, "ANY") == 0)
+ kind = "UNIT_CALC_ANY";
+ else
+ kind = ckv->key;
fprintf(outputf,
"if ((token->type == CSS_TOKEN_IDENT) && "
"(lwc_string_caseless_isequal(token->idata, c->strings[CALC], &match) == lwc_error_ok && match))"
" {\n"
- "\t\terror = css__parse_calc(c, vector, ctx, result, buildOPV(%s, 0, %s /* _CALC */), %s);\n"
+ "\t\terror = css__parse_calc(c, vector, ctx, result, buildOPV(%s, 0, %s), %s);\n"
"\t} else ",
parseid->val,
ckv->val,
- ckv->key
+ kind
);
+}
+
+void output_length_unit(FILE *outputf, struct keyval *parseid, struct keyval_list *kvlist)
+{
+ struct keyval *ckv = kvlist->item[0];
+ int ident_count;
fprintf(outputf,
"{\n"
@@ -533,6 +552,7 @@ int main(int argc, char **argv)
struct keyval_list WRAP;
struct keyval_list NUMBER;
struct keyval_list COLOR;
+ struct keyval_list CALC;
if (argc < 2) {
@@ -565,6 +585,7 @@ int main(int argc, char **argv)
COLOR.count = 0;
LENGTH_UNIT.count = 0;
IDENT_LIST.count = 0;
+ CALC.count = 0;
curlist = &base;
@@ -580,7 +601,7 @@ int main(int argc, char **argv)
if (strcmp(rkv->key, "WRAP") == 0) {
WRAP.item[WRAP.count++] = rkv;
only_ident = false;
- } else if (strcmp(rkv->key, "NUMBER") == 0) {
+ } else if (curlist == &base && strcmp(rkv->key, "NUMBER") == 0) {
if (rkv->val[0] == '(') {
curlist = &NUMBER;
} else if (rkv->val[0] == ')') {
@@ -617,6 +638,14 @@ int main(int argc, char **argv)
}
only_ident = false;
do_token_check = false;
+ } else if (strcmp(rkv->key, "CALC") == 0) {
+ if (rkv->val[0] == '(') {
+ curlist = &CALC;
+ } else if (rkv->val[0] == ')') {
+ curlist = &base;
+ }
+ only_ident = false;
+ do_token_check = false;
} else if (strcmp(rkv->key, "COLOR") == 0) {
COLOR.item[COLOR.count++] = rkv;
do_token_check = false;
@@ -640,7 +669,7 @@ int main(int argc, char **argv)
/* header */
-output_header(outputf, descriptor, base.item[0], is_generic);
+ output_header(outputf, descriptor, base.item[0], is_generic);
if (WRAP.count > 0) {
output_wrap(outputf, base.item[0], &WRAP);
@@ -654,6 +683,10 @@ output_header(outputf, descriptor, base.item[0], is_generic);
if (URI.count > 0)
output_uri(outputf, base.item[0], &URI);
+ if (CALC.count > 0) {
+ output_calc(outputf, base.item[0], &CALC);
+ }
+
if (NUMBER.count > 0)
output_number(outputf, base.item[0], &NUMBER);
diff --git a/src/parse/properties/properties.gen b/src/parse/properties/properties.gen
index b0e797c..3452f81 100644
--- a/src/parse/properties/properties.gen
+++ b/src/parse/properties/properties.gen
@@ -6,6 +6,13 @@
#property:CSS_PROP_ENUM IDENT:( INHERIT: INITIAL: REVERT: UNSET: IDENT:) LENGTH_UNIT:( UNIT_HZ:PITCH_FREQUENCY ALLOW: DISALLOW: RANGE:<0 LENGTH_UNIT:)
#property:CSS_PROP_ENUM WRAP:
+# When a property takes a NUMBER and/or LENGTH_UNIT you may add calc() support:
+# In the below, PROPERTY_FOO_CALC is the opcode enum for the set-but-calculated value bytecode.
+# e.g. HEIGHT_SET (for a LENGTH_UNIT) would be HEIGHT_CALC here.
+# CALC:( UNIT_??:PROPERTY_FOO_CALC CALC:) <-- When a default unit must be considered
+# CALC:( NUMBER:PROPERTY_FOO_CALC CALC:) <-- When a number must be produced (not a dimension)
+# CALC:( ANY:PROPERTY_FOO_CALC CALC:) <-- When a number or dimension is valid (e.g. line-height)
+
background_repeat:CSS_PROP_BACKGROUND_REPEAT IDENT:( INHERIT: INITIAL: REVERT: UNSET: NO_REPEAT:0,BACKGROUND_REPEAT_NO_REPEAT REPEAT_X:0,BACKGROUND_REPEAT_REPEAT_X REPEAT_Y:0,BACKGROUND_REPEAT_REPEAT_Y REPEAT:0,BACKGROUND_REPEAT_REPEAT IDENT:)
border_collapse:CSS_PROP_BORDER_COLLAPSE IDENT:( INHERIT: INITIAL: REVERT: UNSET: COLLAPSE:0,BORDER_COLLAPSE_COLLAPSE SEPARATE:0,BORDER_COLLAPSE_SEPARATE IDENT:)
@@ -22,35 +29,35 @@ empty_cells:CSS_PROP_EMPTY_CELLS IDENT:( INHERIT: INITIAL: REVERT: UNSET: SHOW:0
float:CSS_PROP_FLOAT IDENT:( INHERIT: INITIAL: REVERT: UNSET: LEFT:0,FLOAT_LEFT RIGHT:0,FLOAT_RIGHT NONE:0,FLOAT_NONE IDENT:)
-font_size:CSS_PROP_FONT_SIZE IDENT:( INHERIT: INITIAL: REVERT: UNSET: XX_SMALL:0,FONT_SIZE_XX_SMALL X_SMALL:0,FONT_SIZE_X_SMALL SMALL:0,FONT_SIZE_SMALL MEDIUM:0,FONT_SIZE_MEDIUM LARGE:0,FONT_SIZE_LARGE X_LARGE:0,FONT_SIZE_X_LARGE XX_LARGE:0,FONT_SIZE_XX_LARGE LARGER:0,FONT_SIZE_LARGER SMALLER:0,FONT_SIZE_SMALLER IDENT:) LENGTH_UNIT:( UNIT_PX:FONT_SIZE_DIMENSION MASK:UNIT_MASK_FONT_SIZE RANGE:<0 LENGTH_UNIT:)
+font_size:CSS_PROP_FONT_SIZE IDENT:( INHERIT: INITIAL: REVERT: UNSET: XX_SMALL:0,FONT_SIZE_XX_SMALL X_SMALL:0,FONT_SIZE_X_SMALL SMALL:0,FONT_SIZE_SMALL MEDIUM:0,FONT_SIZE_MEDIUM LARGE:0,FONT_SIZE_LARGE X_LARGE:0,FONT_SIZE_X_LARGE XX_LARGE:0,FONT_SIZE_XX_LARGE LARGER:0,FONT_SIZE_LARGER SMALLER:0,FONT_SIZE_SMALLER IDENT:) LENGTH_UNIT:( UNIT_PX:FONT_SIZE_DIMENSION MASK:UNIT_MASK_FONT_SIZE RANGE:<0 LENGTH_UNIT:) CALC:( UNIT_PX:FONT_SIZE_CALC CALC:)
font_style:CSS_PROP_FONT_STYLE IDENT:( INHERIT: INITIAL: REVERT: UNSET: NORMAL:0,FONT_STYLE_NORMAL ITALIC:0,FONT_STYLE_ITALIC OBLIQUE:0,FONT_STYLE_OBLIQUE IDENT:)
font_variant:CSS_PROP_FONT_VARIANT IDENT:( INHERIT: INITIAL: REVERT: UNSET: NORMAL:0,FONT_VARIANT_NORMAL SMALL_CAPS:0,FONT_VARIANT_SMALL_CAPS IDENT:)
-height:CSS_PROP_HEIGHT IDENT:( INHERIT: INITIAL: REVERT: UNSET: AUTO:0,HEIGHT_AUTO IDENT:) LENGTH_UNIT:( UNIT_PX:HEIGHT_SET MASK:UNIT_MASK_HEIGHT RANGE:<0 LENGTH_UNIT:)
+height:CSS_PROP_HEIGHT IDENT:( INHERIT: INITIAL: REVERT: UNSET: AUTO:0,HEIGHT_AUTO IDENT:) LENGTH_UNIT:( UNIT_PX:HEIGHT_SET MASK:UNIT_MASK_HEIGHT RANGE:<0 LENGTH_UNIT:) CALC:( UNIT_PX:HEIGHT_CALC CALC:)
-letter_spacing:CSS_PROP_LETTER_SPACING IDENT:( INHERIT: INITIAL: REVERT: UNSET: NORMAL:0,LETTER_SPACING_NORMAL IDENT:) LENGTH_UNIT:( UNIT_PX:LETTER_SPACING_SET MASK:UNIT_MASK_LETTER_SPACING LENGTH_UNIT:)
+letter_spacing:CSS_PROP_LETTER_SPACING IDENT:( INHERIT: INITIAL: REVERT: UNSET: NORMAL:0,LETTER_SPACING_NORMAL IDENT:) LENGTH_UNIT:( UNIT_PX:LETTER_SPACING_SET MASK:UNIT_MASK_LETTER_SPACING LENGTH_UNIT:) CALC:( UNIT_PX:LETTER_SPACING_CALC CALC:)
-line_height:CSS_PROP_LINE_HEIGHT IDENT:( INHERIT: INITIAL: REVERT: UNSET: NORMAL:0,LINE_HEIGHT_NORMAL IDENT:) NUMBER:( false:LINE_HEIGHT_NUMBER RANGE:num<0 NUMBER:) LENGTH_UNIT:( UNIT_PX:LINE_HEIGHT_DIMENSION MASK:UNIT_MASK_LINE_HEIGHT RANGE:<0 LENGTH_UNIT:)
+line_height:CSS_PROP_LINE_HEIGHT IDENT:( INHERIT: INITIAL: REVERT: UNSET: NORMAL:0,LINE_HEIGHT_NORMAL IDENT:) NUMBER:( false:LINE_HEIGHT_NUMBER RANGE:num<0 NUMBER:) LENGTH_UNIT:( UNIT_PX:LINE_HEIGHT_DIMENSION MASK:UNIT_MASK_LINE_HEIGHT RANGE:<0 LENGTH_UNIT:) CALC:( ANY:LINE_HEIGHT_CALC CALC:)
border_top:BORDER_SIDE_TOP WRAP:css__parse_border_side
border_bottom:BORDER_SIDE_BOTTOM WRAP:css__parse_border_side
border_left:BORDER_SIDE_LEFT WRAP:css__parse_border_side
border_right:BORDER_SIDE_RIGHT WRAP:css__parse_border_side
-max_height:CSS_PROP_MAX_HEIGHT IDENT:( INHERIT: INITIAL: REVERT: UNSET: NONE:0,MAX_HEIGHT_NONE IDENT:) LENGTH_UNIT:( UNIT_PX:MAX_HEIGHT_SET MASK:UNIT_MASK_MAX_HEIGHT RANGE:<0 LENGTH_UNIT:)
+max_height:CSS_PROP_MAX_HEIGHT IDENT:( INHERIT: INITIAL: REVERT: UNSET: NONE:0,MAX_HEIGHT_NONE IDENT:) LENGTH_UNIT:( UNIT_PX:MAX_HEIGHT_SET MASK:UNIT_MASK_MAX_HEIGHT RANGE:<0 LENGTH_UNIT:) CALC:( UNIT_PX:MAX_HEIGHT_CALC CALC:)
-max_width:CSS_PROP_MAX_WIDTH IDENT:( INHERIT: INITIAL: REVERT: UNSET: NONE:0,MAX_WIDTH_NONE IDENT:) LENGTH_UNIT:( UNIT_PX:MAX_WIDTH_SET MASK:UNIT_MASK_MAX_WIDTH RANGE:<0 LENGTH_UNIT:)
+max_width:CSS_PROP_MAX_WIDTH IDENT:( INHERIT: INITIAL: REVERT: UNSET: NONE:0,MAX_WIDTH_NONE IDENT:) LENGTH_UNIT:( UNIT_PX:MAX_WIDTH_SET MASK:UNIT_MASK_MAX_WIDTH RANGE:<0 LENGTH_UNIT:) CALC:( UNIT_PX:MAX_WIDTH_CALC CALC:)
-min_height:CSS_PROP_MIN_HEIGHT IDENT:( INHERIT: INITIAL: REVERT: UNSET: AUTO:0,MIN_HEIGHT_AUTO IDENT:) LENGTH_UNIT:( UNIT_PX:MIN_HEIGHT_SET MASK:UNIT_MASK_MIN_HEIGHT RANGE:<0 LENGTH_UNIT:)
+min_height:CSS_PROP_MIN_HEIGHT IDENT:( INHERIT: INITIAL: REVERT: UNSET: AUTO:0,MIN_HEIGHT_AUTO IDENT:) LENGTH_UNIT:( UNIT_PX:MIN_HEIGHT_SET MASK:UNIT_MASK_MIN_HEIGHT RANGE:<0 LENGTH_UNIT:) CALC:( UNIT_PX:MIN_HEIGHT_CALC CALC:)
-min_width:CSS_PROP_MIN_WIDTH IDENT:( INHERIT: INITIAL: REVERT: UNSET: AUTO:0,MIN_WIDTH_AUTO IDENT:) LENGTH_UNIT:( UNIT_PX:MIN_WIDTH_SET MASK:UNIT_MASK_MIN_WIDTH RANGE:<0 LENGTH_UNIT:)
+min_width:CSS_PROP_MIN_WIDTH IDENT:( INHERIT: INITIAL: REVERT: UNSET: AUTO:0,MIN_WIDTH_AUTO IDENT:) LENGTH_UNIT:( UNIT_PX:MIN_WIDTH_SET MASK:UNIT_MASK_MIN_WIDTH RANGE:<0 LENGTH_UNIT:) CALC:( UNIT_PX:MIN_WIDTH_CALC CALC:)
color:CSS_PROP_COLOR IDENT:( INHERIT: INITIAL: REVERT: UNSET: IDENT:) COLOR:COLOR_SET
#generic for padding_{top, bottom, left, right}.c
-padding_side:op GENERIC: IDENT:( INHERIT: INITIAL: REVERT: UNSET: IDENT:) LENGTH_UNIT:( UNIT_PX:PADDING_SET MASK:UNIT_MASK_PADDING_SIDE RANGE:<0 LENGTH_UNIT:)
+padding_side:op GENERIC: IDENT:( INHERIT: INITIAL: REVERT: UNSET: IDENT:) LENGTH_UNIT:( UNIT_PX:PADDING_SET MASK:UNIT_MASK_PADDING_SIDE RANGE:<0 LENGTH_UNIT:) CALC:( UNIT_PX:PADDING_CALC CALC:)
padding_bottom:CSS_PROP_PADDING_BOTTOM WRAP:css__parse_padding_side
padding_left:CSS_PROP_PADDING_LEFT WRAP:css__parse_padding_side
@@ -59,7 +66,7 @@ padding_right:CSS_PROP_PADDING_RIGHT WRAP:css__parse_padding_side
#generic for margin_{top, bottom, left, right}.c
-margin_side:op GENERIC IDENT:( INHERIT: INITIAL: REVERT: UNSET: AUTO:0,MARGIN_AUTO IDENT:) LENGTH_UNIT:( UNIT_PX:MARGIN_SET MASK:UNIT_MASK_MARGIN_SIDE LENGTH_UNIT:)
+margin_side:op GENERIC IDENT:( INHERIT: INITIAL: REVERT: UNSET: AUTO:0,MARGIN_AUTO IDENT:) LENGTH_UNIT:( UNIT_PX:MARGIN_SET MASK:UNIT_MASK_MARGIN_SIDE LENGTH_UNIT:) CALC:( UNIT_PX:MARGIN_CALC CALC:)
margin_top:CSS_PROP_MARGIN_TOP WRAP:css__parse_margin_side
margin_bottom:CSS_PROP_MARGIN_BOTTOM WRAP:css__parse_margin_side
@@ -67,7 +74,7 @@ margin_left:CSS_PROP_MARGIN_LEFT WRAP:css__parse_margin_side
margin_right:CSS_PROP_MARGIN_RIGHT WRAP:css__parse_margin_side
#generic for {top, bottom, left, right}.c
-side:op GENERIC: IDENT:( INHERIT: INITIAL: REVERT: UNSET: AUTO:0,BOTTOM_AUTO IDENT:) LENGTH_UNIT:( UNIT_PX:BOTTOM_SET ALLOW:unit&(UNIT_LENGTH|UNIT_PCT) LENGTH_UNIT:)
+side:op GENERIC: IDENT:( INHERIT: INITIAL: REVERT: UNSET: AUTO:0,BOTTOM_AUTO IDENT:) LENGTH_UNIT:( UNIT_PX:BOTTOM_SET ALLOW:unit&(UNIT_LENGTH|UNIT_PCT) LENGTH_UNIT:) CALC:( UNIT_PX:BOTTOM_CALC CALC:)
top:CSS_PROP_TOP WRAP:css__parse_side
bottom:CSS_PROP_BOTTOM WRAP:css__parse_side
@@ -76,7 +83,7 @@ right:CSS_PROP_RIGHT WRAP:css__parse_side
#generic for border_{top, bottom, left, right}_width.c
-border_side_width:op GENERIC: IDENT:( INHERIT: INITIAL: REVERT: UNSET: THIN:0,BORDER_WIDTH_THIN MEDIUM:0,BORDER_WIDTH_MEDIUM THICK:0,BORDER_WIDTH_THICK IDENT:) LENGTH_UNIT:( UNIT_PX:BORDER_WIDTH_SET MASK:UNIT_MASK_BORDER_SIDE_WIDTH RANGE:<0 LENGTH_UNIT:)
+border_side_width:op GENERIC: IDENT:( INHERIT: INITIAL: REVERT: UNSET: THIN:0,BORDER_WIDTH_THIN MEDIUM:0,BORDER_WIDTH_MEDIUM THICK:0,BORDER_WIDTH_THICK IDENT:) LENGTH_UNIT:( UNIT_PX:BORDER_WIDTH_SET MASK:UNIT_MASK_BORDER_SIDE_WIDTH RANGE:<0 LENGTH_UNIT:) CALC:( UNIT_PX:BORDER_WIDTH_CALC CALC:)
border_top_width:CSS_PROP_BORDER_TOP_WIDTH WRAP:css__parse_border_side_width
border_bottom_width:CSS_PROP_BORDER_BOTTOM_WIDTH WRAP:css__parse_border_side_width
@@ -120,7 +127,7 @@ list_style_image:CSS_PROP_LIST_STYLE_IMAGE IDENT:( INHERIT: INITIAL: REVERT: UNS
list_style_position:CSS_PROP_LIST_STYLE_POSITION IDENT:( INHERIT: INITIAL: REVERT: UNSET: INSIDE:0,LIST_STYLE_POSITION_INSIDE OUTSIDE:0,LIST_STYLE_POSITION_OUTSIDE IDENT:)
-orphans:CSS_PROP_ORPHANS IDENT:( INHERIT: INITIAL: REVERT: UNSET: IDENT:) NUMBER:( true:ORPHANS_SET RANGE:num<0 NUMBER:)
+orphans:CSS_PROP_ORPHANS IDENT:( INHERIT: INITIAL: REVERT: UNSET: IDENT:) NUMBER:( true:ORPHANS_SET RANGE:num<0 NUMBER:) CALC:( NUMBER:ORPHANS_CALC CALC:)
outline_color:CSS_PROP_OUTLINE_COLOR IDENT:( INHERIT: INITIAL: REVERT: UNSET: INVERT:0,OUTLINE_COLOR_INVERT IDENT:) COLOR:OUTLINE_COLOR_SET
@@ -133,24 +140,23 @@ overflow_x:CSS_PROP_OVERFLOW_X IDENT:( INHERIT: INITIAL: REVERT: UNSET: VISIBLE:
overflow_y:CSS_PROP_OVERFLOW_Y IDENT:( INHERIT: INITIAL: REVERT: UNSET: VISIBLE:0,OVERFLOW_VISIBLE HIDDEN:0,OVERFLOW_HIDDEN SCROLL:0,OVERFLOW_SCROLL AUTO:0,OVERFLOW_AUTO IDENT:)
-
page_break_after:CSS_PROP_PAGE_BREAK_AFTER IDENT:( INHERIT: INITIAL: REVERT: UNSET: AUTO:0,PAGE_BREAK_AFTER_AUTO ALWAYS:0,PAGE_BREAK_AFTER_ALWAYS AVOID:0,PAGE_BREAK_AFTER_AVOID LEFT:0,PAGE_BREAK_AFTER_LEFT RIGHT:0,PAGE_BREAK_AFTER_RIGHT IDENT:)
page_break_before:CSS_PROP_PAGE_BREAK_BEFORE IDENT:( INHERIT: INITIAL: REVERT: UNSET: AUTO:0,PAGE_BREAK_BEFORE_AUTO ALWAYS:0,PAGE_BREAK_BEFORE_ALWAYS AVOID:0,PAGE_BREAK_BEFORE_AVOID LEFT:0,PAGE_BREAK_BEFORE_LEFT RIGHT:0,PAGE_BREAK_BEFORE_RIGHT IDENT:)
page_break_inside:CSS_PROP_PAGE_BREAK_INSIDE IDENT:( INHERIT: INITIAL: REVERT: UNSET: AUTO:0,PAGE_BREAK_INSIDE_AUTO AVOID:0,PAGE_BREAK_INSIDE_AVOID IDENT:)
-pause_after:CSS_PROP_PAUSE_AFTER IDENT:( INHERIT: INITIAL: REVERT: UNSET: IDENT:) LENGTH_UNIT:( UNIT_S:PAUSE_AFTER_SET MASK:UNIT_MASK_PAUSE_AFTER RANGE:<0 LENGTH_UNIT:)
+pause_after:CSS_PROP_PAUSE_AFTER IDENT:( INHERIT: INITIAL: REVERT: UNSET: IDENT:) LENGTH_UNIT:( UNIT_S:PAUSE_AFTER_SET MASK:UNIT_MASK_PAUSE_AFTER RANGE:<0 LENGTH_UNIT:) CALC:( UNIT_S:PAUSE_AFTER_CALC CALC:)
-pause_before:CSS_PROP_PAUSE_BEFORE IDENT:( INHERIT: INITIAL: REVERT: UNSET: IDENT:) LENGTH_UNIT:( UNIT_S:PAUSE_BEFORE_SET MASK:UNIT_MASK_PAUSE_BEFORE RANGE:<0 LENGTH_UNIT:)
+pause_before:CSS_PROP_PAUSE_BEFORE IDENT:( INHERIT: INITIAL: REVERT: UNSET: IDENT:) LENGTH_UNIT:( UNIT_S:PAUSE_BEFORE_SET MASK:UNIT_MASK_PAUSE_BEFORE RANGE:<0 LENGTH_UNIT:) CALC:( UNIT_S:PAUSE_BEFORE_CALC CALC:)
-pitch:CSS_PROP_PITCH IDENT:( INHERIT: INITIAL: REVERT: UNSET: X_LOW:0,PITCH_X_LOW LOW:0,PITCH_LOW MEDIUM:0,PITCH_MEDIUM HIGH:0,PITCH_HIGH X_HIGH:0,PITCH_X_HIGH IDENT:) LENGTH_UNIT:( UNIT_HZ:PITCH_FREQUENCY MASK:UNIT_MASK_PITCH RANGE:<0 LENGTH_UNIT:)
+pitch:CSS_PROP_PITCH IDENT:( INHERIT: INITIAL: REVERT: UNSET: X_LOW:0,PITCH_X_LOW LOW:0,PITCH_LOW MEDIUM:0,PITCH_MEDIUM HIGH:0,PITCH_HIGH X_HIGH:0,PITCH_X_HIGH IDENT:) LENGTH_UNIT:( UNIT_HZ:PITCH_FREQUENCY MASK:UNIT_MASK_PITCH RANGE:<0 LENGTH_UNIT:) CALC:( UNIT_HZ:PITCH_CALC CALC:)
-pitch_range:CSS_PROP_PITCH_RANGE IDENT:( INHERIT: INITIAL: REVERT: UNSET: IDENT:) NUMBER:( false:PITCH_RANGE_SET RANGE:num<0||num>F_100 NUMBER:)
+pitch_range:CSS_PROP_PITCH_RANGE IDENT:( INHERIT: INITIAL: REVERT: UNSET: IDENT:) NUMBER:( false:PITCH_RANGE_SET RANGE:num<0||num>F_100 NUMBER:) CALC:( NUMBER:PITCH_RANGE_CALC CALC:)
position:CSS_PROP_POSITION IDENT:( INHERIT: INITIAL: REVERT: UNSET: LIBCSS_STATIC:0,POSITION_STATIC RELATIVE:0,POSITION_RELATIVE ABSOLUTE:0,POSITION_ABSOLUTE FIXED:0,POSITION_FIXED STICKY:0,POSITION_STICKY IDENT:)
-richness:CSS_PROP_RICHNESS IDENT:( INHERIT: INITIAL: REVERT: UNSET: IDENT:) NUMBER:( false:RICHNESS_SET RANGE:num<0||num>F_100 NUMBER:)
+richness:CSS_PROP_RICHNESS IDENT:( INHERIT: INITIAL: REVERT: UNSET: IDENT:) NUMBER:( false:RICHNESS_SET RANGE:num<0||num>F_100 NUMBER:) CALC:( NUMBER:RICHNESS_CALC CALC:)
speak:CSS_PROP_SPEAK IDENT:( INHERIT: INITIAL: REVERT: UNSET: NORMAL:0,SPEAK_NORMAL NONE:0,SPEAK_NONE SPELL_OUT:0,SPEAK_SPELL_OUT IDENT:)
@@ -160,37 +166,35 @@ speak_numeral:CSS_PROP_SPEAK_NUMERAL IDENT:( INHERIT: INITIAL: REVERT: UNSET: DI
speak_punctuation:CSS_PROP_SPEAK_PUNCTUATION IDENT:( INHERIT: INITIAL: REVERT: UNSET: CODE:0,SPEAK_PUNCTUATION_CODE NONE:0,SPEAK_PUNCTUATION_NONE IDENT:)
-speech_rate:CSS_PROP_SPEECH_RATE IDENT:( INHERIT: INITIAL: REVERT: UNSET: X_SLOW:0,SPEECH_RATE_X_SLOW SLOW:0,SPEECH_RATE_SLOW MEDIUM:0,SPEECH_RATE_MEDIUM FAST:0,SPEECH_RATE_FAST X_FAST:0,SPEECH_RATE_X_FAST FASTER:0,SPEECH_RATE_FASTER SLOWER:0,SPEECH_RATE_SLOWER IDENT:) NUMBER:( false:SPEECH_RATE_SET RANGE:num<0 NUMBER:)
+speech_rate:CSS_PROP_SPEECH_RATE IDENT:( INHERIT: INITIAL: REVERT: UNSET: X_SLOW:0,SPEECH_RATE_X_SLOW SLOW:0,SPEECH_RATE_SLOW MEDIUM:0,SPEECH_RATE_MEDIUM FAST:0,SPEECH_RATE_FAST X_FAST:0,SPEECH_RATE_X_FAST FASTER:0,SPEECH_RATE_FASTER SLOWER:0,SPEECH_RATE_SLOWER IDENT:) NUMBER:( false:SPEECH_RATE_SET RANGE:num<0 NUMBER:) CALC:( NUMBER:SPEECH_RATE_CALC CALC:)
-stress:CSS_PROP_STRESS IDENT:( INHERIT: INITIAL: REVERT: UNSET: IDENT:) NUMBER:( false:STRESS_SET RANGE:num<0||num>INTTOFIX(100) NUMBER:)
+stress:CSS_PROP_STRESS IDENT:( INHERIT: INITIAL: REVERT: UNSET: IDENT:) NUMBER:( false:STRESS_SET RANGE:num<0||num>INTTOFIX(100) NUMBER:) CALC:( NUMBER:STRESS_CALC CALC:)
table_layout:CSS_PROP_TABLE_LAYOUT IDENT:( INHERIT: INITIAL: REVERT: UNSET: AUTO:0,TABLE_LAYOUT_AUTO FIXED:0,TABLE_LAYOUT_FIXED IDENT:)
text_align:CSS_PROP_TEXT_ALIGN IDENT:( INHERIT: INITIAL: REVERT: UNSET: LEFT:0,TEXT_ALIGN_LEFT RIGHT:0,TEXT_ALIGN_RIGHT CENTER:0,TEXT_ALIGN_CENTER JUSTIFY:0,TEXT_ALIGN_JUSTIFY LIBCSS_LEFT:0,TEXT_ALIGN_LIBCSS_LEFT LIBCSS_CENTER:0,TEXT_ALIGN_LIBCSS_CENTER LIBCSS_RIGHT:0,TEXT_ALIGN_LIBCSS_RIGHT IDENT:)
-text_indent:CSS_PROP_TEXT_INDENT IDENT:( INHERIT: INITIAL: REVERT: UNSET: IDENT:) LENGTH_UNIT:( UNIT_PX:TEXT_INDENT_SET MASK:UNIT_MASK_TEXT_INDENT LENGTH_UNIT:)
+text_indent:CSS_PROP_TEXT_INDENT IDENT:( INHERIT: INITIAL: REVERT: UNSET: IDENT:) LENGTH_UNIT:( UNIT_PX:TEXT_INDENT_SET MASK:UNIT_MASK_TEXT_INDENT LENGTH_UNIT:) CALC:( UNIT_PX:TEXT_INDENT_CALC CALC:)
text_transform:CSS_PROP_TEXT_TRANSFORM IDENT:( INHERIT: INITIAL: REVERT: UNSET: CAPITALIZE:0,TEXT_TRANSFORM_CAPITALIZE UPPERCASE:0,TEXT_TRANSFORM_UPPERCASE LOWERCASE:0,TEXT_TRANSFORM_LOWERCASE NONE:0,TEXT_TRANSFORM_NONE IDENT:)
unicode_bidi:CSS_PROP_UNICODE_BIDI IDENT:( INHERIT: INITIAL: REVERT: UNSET: NORMAL:0,UNICODE_BIDI_NORMAL EMBED:0,UNICODE_BIDI_EMBED BIDI_OVERRIDE:0,UNICODE_BIDI_BIDI_OVERRIDE IDENT:)
-vertical_align:CSS_PROP_VERTICAL_ALIGN IDENT:( INHERIT: INITIAL: REVERT: UNSET: BASELINE:0,VERTICAL_ALIGN_BASELINE SUB:0,VERTICAL_ALIGN_SUB SUPER:0,VERTICAL_ALIGN_SUPER TOP:0,VERTICAL_ALIGN_TOP TEXT_TOP:0,VERTICAL_ALIGN_TEXT_TOP MIDDLE:0,VERTICAL_ALIGN_MIDDLE BOTTOM:0,VERTICAL_ALIGN_BOTTOM TEXT_BOTTOM:0,VERTICAL_ALIGN_TEXT_BOTTOM IDENT:) LENGTH_UNIT:( UNIT_PX:VERTICAL_ALIGN_SET MASK:UNIT_MASK_VERTICAL_ALIGN LENGTH_UNIT:)
+vertical_align:CSS_PROP_VERTICAL_ALIGN IDENT:( INHERIT: INITIAL: REVERT: UNSET: BASELINE:0,VERTICAL_ALIGN_BASELINE SUB:0,VERTICAL_ALIGN_SUB SUPER:0,VERTICAL_ALIGN_SUPER TOP:0,VERTICAL_ALIGN_TOP TEXT_TOP:0,VERTICAL_ALIGN_TEXT_TOP MIDDLE:0,VERTICAL_ALIGN_MIDDLE BOTTOM:0,VERTICAL_ALIGN_BOTTOM TEXT_BOTTOM:0,VERTICAL_ALIGN_TEXT_BOTTOM IDENT:) LENGTH_UNIT:( UNIT_PX:VERTICAL_ALIGN_SET MASK:UNIT_MASK_VERTICAL_ALIGN LENGTH_UNIT:) CALC:( UNIT_PX:VERTICAL_ALIGN_CALC CALC:)
visibility:CSS_PROP_VISIBILITY IDENT:( INHERIT: INITIAL: REVERT: UNSET: VISIBLE:0,VISIBILITY_VISIBLE HIDDEN:0,VISIBILITY_HIDDEN COLLAPSE:0,VISIBILITY_COLLAPSE IDENT:)
-volume:CSS_PROP_VOLUME IDENT:( INHERIT: INITIAL: REVERT: UNSET: SILENT:0,VOLUME_SILENT X_SOFT:0,VOLUME_X_SOFT SOFT:0,VOLUME_SOFT MEDIUM:0,VOLUME_MEDIUM LOUD:0,VOLUME_LOUD X_LOUD:0,VOLUME_X_LOUD IDENT:) NUMBER:( false:VOLUME_NUMBER RANGE:num<0||num>F_100 NUMBER:) LENGTH_UNIT:( UNIT_PX:VOLUME_DIMENSION MASK:UNIT_MASK_VOLUME RANGE:<0 LENGTH_UNIT:)
+volume:CSS_PROP_VOLUME IDENT:( INHERIT: INITIAL: REVERT: UNSET: SILENT:0,VOLUME_SILENT X_SOFT:0,VOLUME_X_SOFT SOFT:0,VOLUME_SOFT MEDIUM:0,VOLUME_MEDIUM LOUD:0,VOLUME_LOUD X_LOUD:0,VOLUME_X_LOUD IDENT:) NUMBER:( false:VOLUME_NUMBER RANGE:num<0||num>F_100 NUMBER:) LENGTH_UNIT:( UNIT_PX:VOLUME_DIMENSION MASK:UNIT_MASK_VOLUME RANGE:<0 LENGTH_UNIT:) CALC:( ANY:VOLUME_CALC CALC:)
white_space:CSS_PROP_WHITE_SPACE IDENT:( INHERIT: INITIAL: REVERT: UNSET: NORMAL:0,WHITE_SPACE_NORMAL PRE:0,WHITE_SPACE_PRE NOWRAP:0,WHITE_SPACE_NOWRAP PRE_WRAP:0,WHITE_SPACE_PRE_WRAP PRE_LINE:0,WHITE_SPACE_PRE_LINE IDENT:)
-widows:CSS_PROP_WIDOWS IDENT:( INHERIT: INITIAL: REVERT: UNSET: IDENT:) NUMBER:( true:WIDOWS_SET RANGE:num<0 NUMBER:)
-
-
-width:CSS_PROP_WIDTH IDENT:( INHERIT: INITIAL: REVERT: UNSET: AUTO:0,WIDTH_AUTO IDENT:) LENGTH_UNIT:( UNIT_PX:WIDTH_SET MASK:UNIT_MASK_WIDTH RANGE:<0 LENGTH_UNIT:)
+widows:CSS_PROP_WIDOWS IDENT:( INHERIT: INITIAL: REVERT: UNSET: IDENT:) NUMBER:( true:WIDOWS_SET RANGE:num<0 NUMBER:) CALC:( NUMBER:WIDOWS_CALC CALC:)
-word_spacing:CSS_PROP_WORD_SPACING IDENT:( INHERIT: INITIAL: REVERT: UNSET: NORMAL:0,WORD_SPACING_NORMAL IDENT:) LENGTH_UNIT:( UNIT_PX:WORD_SPACING_SET MASK:UNIT_MASK_WORD_SPACING LENGTH_UNIT:)
+width:CSS_PROP_WIDTH IDENT:( INHERIT: INITIAL: REVERT: UNSET: AUTO:0,WIDTH_AUTO IDENT:) LENGTH_UNIT:( UNIT_PX:WIDTH_SET MASK:UNIT_MASK_WIDTH RANGE:<0 LENGTH_UNIT:) CALC:( UNIT_PX:WIDTH_CALC CALC:)
-z_index:CSS_PROP_Z_INDEX IDENT:( INHERIT: INITIAL: REVERT: UNSET: AUTO:0,Z_INDEX_AUTO IDENT:) NUMBER:( true:Z_INDEX_SET NUMBER:)
+word_spacing:CSS_PROP_WORD_SPACING IDENT:( INHERIT: INITIAL: REVERT: UNSET: NORMAL:0,WORD_SPACING_NORMAL IDENT:) LENGTH_UNIT:( UNIT_PX:WORD_SPACING_SET MASK:UNIT_MASK_WORD_SPACING LENGTH_UNIT:) CALC:( UNIT_PX:WORD_SPACING_CALC CALC:)
+z_index:CSS_PROP_Z_INDEX IDENT:( INHERIT: INITIAL: REVERT: UNSET: AUTO:0,Z_INDEX_AUTO IDENT:) NUMBER:( true:Z_INDEX_SET NUMBER:) CALC:( NUMBER:Z_INDEX_CALC CALC:)
break_after:CSS_PROP_BREAK_AFTER IDENT:( INHERIT: INITIAL: REVERT: UNSET: AUTO:0,BREAK_AFTER_AUTO ALWAYS:0,BREAK_AFTER_ALWAYS AVOID:0,BREAK_AFTER_AVOID LEFT:0,BREAK_AFTER_LEFT RIGHT:0,BREAK_AFTER_RIGHT PAGE:0,BREAK_AFTER_PAGE COLUMN:0,BREAK_AFTER_COLUMN AVOID_PAGE:0,BREAK_AFTER_AVOID_PAGE AVOID_COLUMN:0,BREAK_AFTER_AVOID_COLUMN IDENT:)
@@ -198,11 +202,11 @@ break_before:CSS_PROP_BREAK_BEFORE IDENT:( INHERIT: INITIAL: REVERT: UNSET: AUTO
break_inside:CSS_PROP_BREAK_INSIDE IDENT:( INHERIT: INITIAL: REVERT: UNSET: AUTO:0,BREAK_INSIDE_AUTO AVOID:0,BREAK_INSIDE_AVOID AVOID_PAGE:0,BREAK_INSIDE_AVOID_PAGE AVOID_COLUMN:0,BREAK_INSIDE_AVOID_COLUMN IDENT:)
-column_count:CSS_PROP_COLUMN_COUNT IDENT:( INHERIT: INITIAL: REVERT: UNSET: AUTO:0,COLUMN_COUNT_AUTO IDENT:) NUMBER:( true:COLUMN_COUNT_SET RANGE:num<0 NUMBER:)
+column_count:CSS_PROP_COLUMN_COUNT IDENT:( INHERIT: INITIAL: REVERT: UNSET: AUTO:0,COLUMN_COUNT_AUTO IDENT:) NUMBER:( true:COLUMN_COUNT_SET RANGE:num<0 NUMBER:) CALC:( NUMBER:COLUMN_COUNT_CALC CALC:)
column_fill:CSS_PROP_COLUMN_FILL IDENT:( INHERIT: INITIAL: REVERT: UNSET: BALANCE:0,COLUMN_FILL_BALANCE AUTO:0,COLUMN_FILL_AUTO IDENT:)
-column_gap:CSS_PROP_COLUMN_GAP IDENT:( INHERIT: INITIAL: REVERT: UNSET: NORMAL:0,COLUMN_GAP_NORMAL IDENT:) LENGTH_UNIT:( UNIT_PX:COLUMN_GAP_SET RANGE:<0 MASK:UNIT_MASK_COLUMN_GAP LENGTH_UNIT:)
+column_gap:CSS_PROP_COLUMN_GAP IDENT:( INHERIT: INITIAL: REVERT: UNSET: NORMAL:0,COLUMN_GAP_NORMAL IDENT:) LENGTH_UNIT:( UNIT_PX:COLUMN_GAP_SET RANGE:<0 MASK:UNIT_MASK_COLUMN_GAP LENGTH_UNIT:) CALC:( UNIT_PX:COLUMN_GAP_CALC CALC:)
column_rule_color:CSS_PROP_COLUMN_RULE_COLOR IDENT:( INHERIT: INITIAL: REVERT: UNSET: IDENT:) COLOR:COLUMN_RULE_COLOR_SET
@@ -212,7 +216,7 @@ column_rule_width:CSS_PROP_COLUMN_RULE_WIDTH WRAP:css__parse_border_side_width
column_span:CSS_PROP_COLUMN_SPAN IDENT:( INHERIT: INITIAL: REVERT: UNSET: NONE:0,COLUMN_SPAN_NONE ALL:0,COLUMN_SPAN_ALL IDENT:)
-column_width:CSS_PROP_COLUMN_WIDTH IDENT:( INHERIT: INITIAL: REVERT: UNSET: AUTO:0,COLUMN_WIDTH_AUTO IDENT:) LENGTH_UNIT:( UNIT_PX:COLUMN_WIDTH_SET MASK:UNIT_MASK_COLUMN_WIDTH LENGTH_UNIT:)
+column_width:CSS_PROP_COLUMN_WIDTH IDENT:( INHERIT: INITIAL: REVERT: UNSET: AUTO:0,COLUMN_WIDTH_AUTO IDENT:) LENGTH_UNIT:( UNIT_PX:COLUMN_WIDTH_SET MASK:UNIT_MASK_COLUMN_WIDTH LENGTH_UNIT:) CALC:( UNIT_PX:COLUMN_WIDTH_CALC CALC:)
writing_mode:CSS_PROP_WRITING_MODE IDENT:( INHERIT: INITIAL: REVERT: UNSET: HORIZONTAL_TB:0,WRITING_MODE_HORIZONTAL_TB VERTICAL_RL:0,WRITING_MODE_VERTICAL_RL VERTICAL_LR:0,WRITING_MODE_VERTICAL_LR IDENT:)
@@ -224,16 +228,16 @@ align_items:CSS_PROP_ALIGN_ITEMS IDENT:( INHERIT: INITIAL: REVERT: UNSET: STRETC
align_self:CSS_PROP_ALIGN_SELF IDENT:( INHERIT: INITIAL: REVERT: UNSET: STRETCH:0,ALIGN_SELF_STRETCH FLEX_START:0,ALIGN_SELF_FLEX_START FLEX_END:0,ALIGN_SELF_FLEX_END CENTER:0,ALIGN_SELF_CENTER BASELINE:0,ALIGN_SELF_BASELINE AUTO:0,ALIGN_SELF_AUTO IDENT:)
-flex_basis:CSS_PROP_FLEX_BASIS IDENT:( INHERIT: INITIAL: REVERT: UNSET: AUTO:0,FLEX_BASIS_AUTO CONTENT:0,FLEX_BASIS_CONTENT IDENT:) LENGTH_UNIT:( UNIT_PX:FLEX_BASIS_SET MASK:UNIT_MASK_FLEX_BASIS RANGE:<0 LENGTH_UNIT:)
+flex_basis:CSS_PROP_FLEX_BASIS IDENT:( INHERIT: INITIAL: REVERT: UNSET: AUTO:0,FLEX_BASIS_AUTO CONTENT:0,FLEX_BASIS_CONTENT IDENT:) LENGTH_UNIT:( UNIT_PX:FLEX_BASIS_SET MASK:UNIT_MASK_FLEX_BASIS RANGE:<0 LENGTH_UNIT:) CALC:( UNIT_PX:FLEX_BASIS_CALC CALC:)
flex_direction:CSS_PROP_FLEX_DIRECTION IDENT:( INHERIT: INITIAL: REVERT: UNSET: ROW:0,FLEX_DIRECTION_ROW ROW_REVERSE:0,FLEX_DIRECTION_ROW_REVERSE COLUMN:0,FLEX_DIRECTION_COLUMN COLUMN_REVERSE:0,FLEX_DIRECTION_COLUMN_REVERSE IDENT:)
-flex_grow:CSS_PROP_FLEX_GROW IDENT:( INHERIT: INITIAL: REVERT: UNSET: IDENT:) NUMBER:( false:FLEX_GROW_SET RANGE:num<0 NUMBER:)
+flex_grow:CSS_PROP_FLEX_GROW IDENT:( INHERIT: INITIAL: REVERT: UNSET: IDENT:) NUMBER:( false:FLEX_GROW_SET RANGE:num<0 NUMBER:) CALC:( NUMBER:FLEX_GROW_CALC CALC:)
-flex_shrink:CSS_PROP_FLEX_SHRINK IDENT:( INHERIT: INITIAL: REVERT: UNSET: IDENT:) NUMBER:( false:FLEX_SHRINK_SET RANGE:num<0 NUMBER:)
+flex_shrink:CSS_PROP_FLEX_SHRINK IDENT:( INHERIT: INITIAL: REVERT: UNSET: IDENT:) NUMBER:( false:FLEX_SHRINK_SET RANGE:num<0 NUMBER:) CALC:( NUMBER:FLEX_SHRINK_CALC CALC:)
flex_wrap:CSS_PROP_FLEX_WRAP IDENT:( INHERIT: INITIAL: REVERT: UNSET: NOWRAP:0,FLEX_WRAP_NOWRAP WRAP_STRING:0,FLEX_WRAP_WRAP WRAP_REVERSE:0,FLEX_WRAP_WRAP_REVERSE IDENT:)
justify_content:CSS_PROP_JUSTIFY_CONTENT IDENT:( INHERIT: INITIAL: REVERT: UNSET: FLEX_START:0,JUSTIFY_CONTENT_FLEX_START FLEX_END:0,JUSTIFY_CONTENT_FLEX_END CENTER:0,JUSTIFY_CONTENT_CENTER SPACE_BETWEEN:0,JUSTIFY_CONTENT_SPACE_BETWEEN SPACE_AROUND:0,JUSTIFY_CONTENT_SPACE_AROUND SPACE_EVENLY:0,JUSTIFY_CONTENT_SPACE_EVENLY IDENT:)
-order:CSS_PROP_ORDER IDENT:( INHERIT: INITIAL: REVERT: UNSET: IDENT:) NUMBER:( true:ORDER_SET NUMBER:)
+order:CSS_PROP_ORDER IDENT:( INHERIT: INITIAL: REVERT: UNSET: IDENT:) NUMBER:( true:ORDER_SET NUMBER:) CALC:( NUMBER:ORDER_CALC CALC:)
diff --git a/src/parse/properties/utils.c b/src/parse/properties/utils.c
index 4739486..cce9717 100644
--- a/src/parse/properties/utils.c
+++ b/src/parse/properties/utils.c
@@ -1351,9 +1351,9 @@ cleanup:
*
*
* calc(10px + (4rem / 2)) =>
- * U 10 px
- * U 4 rem
- * N 2
+ * V 10 px
+ * V 4 rem
+ * V 2 NUMBER
* /
* +
* =
@@ -1362,14 +1362,12 @@ cleanup:
static css_error
css__parse_calc_sum(css_language *c,
const parserutils_vector *vector, int *ctx,
- css_style *result,
- uint32_t unit);
+ css_style *result);
static css_error
css__parse_calc_value(css_language *c,
const parserutils_vector *vector, int *ctx,
- css_style *result,
- uint32_t default_unit)
+ css_style *result)
{
css_error error;
int orig_ctx = *ctx;
@@ -1377,7 +1375,7 @@ css__parse_calc_value(css_language *c,
token = parserutils_vector_iterate(vector, ctx);
if (tokenIsChar(token, '(')) {
- error = css__parse_calc_sum(c, vector, ctx, result, default_unit);
+ error = css__parse_calc_sum(c, vector, ctx, result);
if (error != CSS_OK) {
return error;
}
@@ -1396,13 +1394,13 @@ css__parse_calc_value(css_language *c,
uint32_t unit = 0;
*ctx = orig_ctx;
- error = css__parse_unit_specifier(c, vector, ctx, default_unit, &length, &unit);
+ error = css__parse_unit_specifier(c, vector, ctx, UNIT_CALC_NUMBER, &length, &unit);
if (error != CSS_OK) {
*ctx = orig_ctx;
return error;
}
- error = css__stylesheet_style_vappend(result, 3, (css_code_t) 'U', length, unit);
+ error = css__stylesheet_style_vappend(result, 3, (css_code_t) 'V', length, unit);
}
break;
@@ -1422,8 +1420,7 @@ css__parse_calc_value(css_language *c,
static css_error
css__parse_calc_product(css_language *c,
const parserutils_vector *vector, int *ctx,
- css_style *result,
- uint32_t unit)
+ css_style *result)
{
css_error error = CSS_OK;
const css_token *token;
@@ -1431,7 +1428,7 @@ css__parse_calc_product(css_language *c,
/* First parse a value */
- error = css__parse_calc_value(c, vector, ctx, result, unit);
+ error = css__parse_calc_value(c, vector, ctx, result);
if (error != CSS_OK) {
return error;
}
@@ -1455,33 +1452,10 @@ css__parse_calc_product(css_language *c,
/* Consume that * or / now */
token = parserutils_vector_iterate(vector, ctx);
- if (multiplication) {
- /* parse another value */
- error = css__parse_calc_value(c, vector, ctx, result, unit);
- if (error != CSS_OK)
- break;
- } else {
- css_fixed num;
- size_t consumed;
-
- token = parserutils_vector_iterate(vector, ctx);
- if (token->type != CSS_TOKEN_NUMBER) {
- error = CSS_INVALID;
- break;
- }
- num = css__number_from_lwc_string(token->idata, false, &consumed);
- if (consumed != lwc_string_length(token->idata)) {
- error = CSS_INVALID;
- break;
- }
-
- error = css__stylesheet_style_append(result, (css_code_t) 'N');
- if (error != CSS_OK)
- break;
- error = css__stylesheet_style_append(result, (css_code_t) num);
- if (error != CSS_OK)
- break;
- }
+ /* parse another value */
+ error = css__parse_calc_value(c, vector, ctx, result);
+ if (error != CSS_OK)
+ break;
/* emit the multiplication/division operator */
error = css__stylesheet_style_append(result, (css_code_t) (multiplication ? '*' : '/'));
@@ -1494,8 +1468,7 @@ css__parse_calc_product(css_language *c,
css_error
css__parse_calc_sum(css_language *c,
const parserutils_vector *vector, int *ctx,
- css_style *result,
- uint32_t unit)
+ css_style *result)
{
css_error error = CSS_OK;
const css_token *token;
@@ -1503,7 +1476,7 @@ css__parse_calc_sum(css_language *c,
/* First parse a product */
- error = css__parse_calc_product(c, vector, ctx, result, unit);
+ error = css__parse_calc_product(c, vector, ctx, result);
if (error != CSS_OK) {
return error;
}
@@ -1528,7 +1501,7 @@ css__parse_calc_sum(css_language *c,
token = parserutils_vector_iterate(vector, ctx);
/* parse another product */
- error = css__parse_calc_product(c, vector, ctx, result, unit);
+ error = css__parse_calc_product(c, vector, ctx, result);
if (error != CSS_OK)
break;
@@ -1570,8 +1543,10 @@ css_error css__parse_calc(css_language *c,
error = css__stylesheet_style_append(calc_style, property);
if (error != CSS_OK)
goto cleanup;
+
+ error = css__stylesheet_style_append(calc_style, (css_code_t) unit);
- error = css__parse_calc_sum(c, vector, ctx, calc_style, unit);
+ error = css__parse_calc_sum(c, vector, ctx, calc_style);
if (error != CSS_OK)
goto cleanup;
commitdiff http://git.netsurf-browser.org/libcss.git/commit/?id=ce71fe3d4f6a348ef1b2...
commit ce71fe3d4f6a348ef1b2024389905c844fe8e5fe
Author: Daniel Silverstone <dsilvers(a)netsurf-browser.org>
Commit: Michael Drake <tlsa(a)netsurf-browser.org>
parse: Add calc() parser.
Co-authored-by: Michael Drake <michael.drake(a)netsurf-browser.org>
diff --git a/src/parse/properties/css_property_parser_gen.c b/src/parse/properties/css_property_parser_gen.c
index 1e8b007..100fba1 100644
--- a/src/parse/properties/css_property_parser_gen.c
+++ b/src/parse/properties/css_property_parser_gen.c
@@ -316,6 +316,16 @@ void output_length_unit(FILE *outputf, struct keyval *parseid, struct keyval_lis
struct keyval *ckv = kvlist->item[0];
int ident_count;
+ fprintf(outputf,
+ "if ((token->type == CSS_TOKEN_IDENT) && "
+ "(lwc_string_caseless_isequal(token->idata, c->strings[CALC], &match) == lwc_error_ok && match))"
+ " {\n"
+ "\t\terror = css__parse_calc(c, vector, ctx, result, buildOPV(%s, 0, %s /* _CALC */), %s);\n"
+ "\t} else ",
+ parseid->val,
+ ckv->val,
+ ckv->key
+ );
fprintf(outputf,
"{\n"
diff --git a/src/parse/properties/utils.c b/src/parse/properties/utils.c
index 1e184f8..4739486 100644
--- a/src/parse/properties/utils.c
+++ b/src/parse/properties/utils.c
@@ -1333,3 +1333,269 @@ cleanup:
return error;
}
+
+/******************************************************************************/
+
+/* CALC
+ *
+ * calc( <calc-sum> )
+ *
+ * where
+ * <calc-sum> = <calc-product> [ [ '+' | '-' ] <calc-product> ]*
+ *
+ * where
+ * <calc-product> = <calc-value> [ '*' <calc-value> | '/' <number> ]*
+ *
+ * where
+ * <calc-value> = <number> | <dimension> | <percentage> | ( <calc-sum> )
+ *
+ *
+ * calc(10px + (4rem / 2)) =>
+ * U 10 px
+ * U 4 rem
+ * N 2
+ * /
+ * +
+ * =
+ */
+
+static css_error
+css__parse_calc_sum(css_language *c,
+ const parserutils_vector *vector, int *ctx,
+ css_style *result,
+ uint32_t unit);
+
+static css_error
+css__parse_calc_value(css_language *c,
+ const parserutils_vector *vector, int *ctx,
+ css_style *result,
+ uint32_t default_unit)
+{
+ css_error error;
+ int orig_ctx = *ctx;
+ const css_token *token;
+
+ token = parserutils_vector_iterate(vector, ctx);
+ if (tokenIsChar(token, '(')) {
+ error = css__parse_calc_sum(c, vector, ctx, result, default_unit);
+ if (error != CSS_OK) {
+ return error;
+ }
+
+ token = parserutils_vector_peek(vector, *ctx);
+ if (!tokenIsChar(token, ')')) {
+ return CSS_INVALID;
+ }
+
+ } else switch (token->type) {
+ case CSS_TOKEN_NUMBER: /* Fall through */
+ case CSS_TOKEN_DIMENSION: /* Fall through */
+ case CSS_TOKEN_PERCENTAGE:
+ {
+ css_fixed length = 0;
+ uint32_t unit = 0;
+ *ctx = orig_ctx;
+
+ error = css__parse_unit_specifier(c, vector, ctx, default_unit, &length, &unit);
+ if (error != CSS_OK) {
+ *ctx = orig_ctx;
+ return error;
+ }
+
+ error = css__stylesheet_style_vappend(result, 3, (css_code_t) 'U', length, unit);
+ }
+ break;
+
+ default:
+ error = CSS_INVALID;
+ break;
+ }
+
+ return error;
+}
+
+/* Both this, and css_parse_calc_sum must stop when it encounters a close-paren.
+ * If it hasn't had any useful tokens before that, it's an error. It does not
+ * need to restore ctx before returning an error but it does need to ensure that
+ * the close paren has not been consumed
+ */
+static css_error
+css__parse_calc_product(css_language *c,
+ const parserutils_vector *vector, int *ctx,
+ css_style *result,
+ uint32_t unit)
+{
+ css_error error = CSS_OK;
+ const css_token *token;
+ bool multiplication;
+
+
+ /* First parse a value */
+ error = css__parse_calc_value(c, vector, ctx, result, unit);
+ if (error != CSS_OK) {
+ return error;
+ }
+
+ do {
+ /* What is our next token? */
+ token = parserutils_vector_peek(vector, *ctx);
+ if (token == NULL) {
+ error = CSS_INVALID;
+ break;
+ } else if (tokenIsChar(token, ')'))
+ break;
+ else if (tokenIsChar(token, '*'))
+ multiplication = true;
+ else if (tokenIsChar(token, '/'))
+ multiplication = false;
+ else {
+ error = CSS_INVALID;
+ break;
+ }
+ /* Consume that * or / now */
+ token = parserutils_vector_iterate(vector, ctx);
+
+ if (multiplication) {
+ /* parse another value */
+ error = css__parse_calc_value(c, vector, ctx, result, unit);
+ if (error != CSS_OK)
+ break;
+ } else {
+ css_fixed num;
+ size_t consumed;
+
+ token = parserutils_vector_iterate(vector, ctx);
+ if (token->type != CSS_TOKEN_NUMBER) {
+ error = CSS_INVALID;
+ break;
+ }
+ num = css__number_from_lwc_string(token->idata, false, &consumed);
+ if (consumed != lwc_string_length(token->idata)) {
+ error = CSS_INVALID;
+ break;
+ }
+
+ error = css__stylesheet_style_append(result, (css_code_t) 'N');
+ if (error != CSS_OK)
+ break;
+ error = css__stylesheet_style_append(result, (css_code_t) num);
+ if (error != CSS_OK)
+ break;
+ }
+
+ /* emit the multiplication/division operator */
+ error = css__stylesheet_style_append(result, (css_code_t) (multiplication ? '*' : '/'));
+ } while (1);
+ /* We've fallen off, either we had an error or we're left with ')' */
+ return error;
+}
+
+
+css_error
+css__parse_calc_sum(css_language *c,
+ const parserutils_vector *vector, int *ctx,
+ css_style *result,
+ uint32_t unit)
+{
+ css_error error = CSS_OK;
+ const css_token *token;
+ bool addition;
+
+
+ /* First parse a product */
+ error = css__parse_calc_product(c, vector, ctx, result, unit);
+ if (error != CSS_OK) {
+ return error;
+ }
+
+ do {
+ /* What is our next token? */
+ token = parserutils_vector_peek(vector, *ctx);
+ if (token == NULL) {
+ error = CSS_INVALID;
+ break;
+ } else if (tokenIsChar(token, ')'))
+ break;
+ else if (tokenIsChar(token, '+'))
+ addition = true;
+ else if (tokenIsChar(token, '-'))
+ addition = false;
+ else {
+ error = CSS_INVALID;
+ break;
+ }
+ /* Consume that + or - now */
+ token = parserutils_vector_iterate(vector, ctx);
+
+ /* parse another product */
+ error = css__parse_calc_product(c, vector, ctx, result, unit);
+ if (error != CSS_OK)
+ break;
+
+ /* emit the addition/subtraction operator */
+ error = css__stylesheet_style_append(result, (css_code_t) (addition ? '+' : '-'));
+ } while (1);
+ /* We've fallen off, either we had an error or we're left with ')' */
+ return error;
+}
+
+/* Documented in utils.h */
+css_error css__parse_calc(css_language *c,
+ const parserutils_vector *vector, int *ctx,
+ css_style *result,
+ css_code_t property,
+ uint32_t unit)
+{
+ int orig_ctx = *ctx;
+ const css_token *token;
+ css_error error = CSS_OK;
+ css_style *calc_style = NULL;
+
+ token = parserutils_vector_iterate(vector, ctx);
+ if (token == NULL) {
+ *ctx = orig_ctx;
+ return CSS_INVALID;
+ }
+
+ if (!tokenIsChar(token, '(')) {
+ /* If we don't get an open-paren, give up now */
+ *ctx = orig_ctx;
+ return CSS_INVALID;
+ }
+
+ error = css__stylesheet_style_create(c->sheet, &calc_style);
+ if (error != CSS_OK)
+ goto cleanup;
+
+ error = css__stylesheet_style_append(calc_style, property);
+ if (error != CSS_OK)
+ goto cleanup;
+
+ error = css__parse_calc_sum(c, vector, ctx, calc_style, unit);
+ if (error != CSS_OK)
+ goto cleanup;
+
+ token = parserutils_vector_iterate(vector, ctx);
+ if (!tokenIsChar(token, ')')) {
+ /* If we don't get a close-paren, give up now */
+ error = CSS_INVALID;
+ goto cleanup;
+ }
+
+ /* Append the indicator that the calc is finished */
+ error = css__stylesheet_style_append(calc_style, (css_code_t) '=');
+ if (error != CSS_OK)
+ goto cleanup;
+
+ /* TODO: Once we're OK to do so, merge the style */
+ (void)result;
+ /* error = css__stylesheet_style_merge_style(result, calc_style); */
+
+cleanup:
+ css__stylesheet_style_destroy(calc_style);
+ if (error != CSS_OK) {
+ *ctx = orig_ctx;
+ }
+
+ return error;
+}
diff --git a/src/parse/properties/utils.h b/src/parse/properties/utils.h
index 54a3fd1..02cb220 100644
--- a/src/parse/properties/utils.h
+++ b/src/parse/properties/utils.h
@@ -228,4 +228,28 @@ css_error css__comma_list_to_style(css_language *c,
bool first),
css_style *result);
+/**
+ * Parse a CSS calc() invocation
+ *
+ * Calc can generate a number of kinds of units, so we have to tell the
+ * parser the kind of unit we're aiming for (e.g. UNIT_PX, UNIT_ANGLE, etc.)
+ *
+ * \param[in] c Parsing context
+ * \param[in] vector Vector of tokens to process
+ * \param[in] ctx Pointer to vector iteration context
+ * \param[in] result Pointer to location to receive resulting style
+ * \param[in] property The CSS property we are calculating for
+ * \param[in] unit The kind of unit which we want to come out of this calc()
+ * \return CSS_OK on success,
+ * CSS_NOMEM on memory exhaustion,
+ CSS_INVALID if the input is not valid
+ *
+ * Post condition: \a *ctx is updated with the next token to process
+ * If the input is invalid, then \a *ctx remains unchanged.
+ */
+css_error css__parse_calc(css_language *c,
+ const parserutils_vector *vector, int *ctx,
+ css_style *result,
+ css_code_t property,
+ uint32_t unit);
#endif
diff --git a/src/parse/propstrings.c b/src/parse/propstrings.c
index 786a3b7..aa44333 100644
--- a/src/parse/propstrings.c
+++ b/src/parse/propstrings.c
@@ -489,6 +489,7 @@ const stringmap_entry stringmap[LAST_KNOWN] = {
SMAP("grid"),
SMAP("inline-grid"),
SMAP("sticky"),
+ SMAP("calc"),
SMAP("aliceblue"),
SMAP("antiquewhite"),
diff --git a/src/parse/propstrings.h b/src/parse/propstrings.h
index 6d6dd49..80f75c8 100644
--- a/src/parse/propstrings.h
+++ b/src/parse/propstrings.h
@@ -109,7 +109,7 @@ enum {
VERTICAL_LR, CONTENT_BOX, BORDER_BOX, STRETCH, INLINE_FLEX, FLEX_START,
FLEX_END, SPACE_BETWEEN, SPACE_AROUND, SPACE_EVENLY, ROW, ROW_REVERSE,
COLUMN_REVERSE, WRAP_STRING, WRAP_REVERSE, AND, OR, ONLY, INFINITE,
- GRID, INLINE_GRID, STICKY,
+ GRID, INLINE_GRID, STICKY, CALC,
/* Named colours */
FIRST_COLOUR,
-----------------------------------------------------------------------
Summary of changes:
src/select/autogenerated_propget.h | 1070 +++++++++++++++++++++++++++++++++---
src/select/overrides.py | 32 --
src/select/select_generator.py | 92 ++--
3 files changed, 1050 insertions(+), 144 deletions(-)
diff --git a/src/select/autogenerated_propget.h b/src/select/autogenerated_propget.h
index cf82c86..6c958aa 100644
--- a/src/select/autogenerated_propget.h
+++ b/src/select/autogenerated_propget.h
@@ -9,6 +9,15 @@
#define ALIGN_CONTENT_INDEX 10
#define ALIGN_CONTENT_SHIFT 20
#define ALIGN_CONTENT_MASK 0x700000
+static inline uint8_t get_align_content_bits(const css_computed_style *style)
+{
+ uint32_t bits = style->i.bits[ALIGN_CONTENT_INDEX];
+ bits &= ALIGN_CONTENT_MASK;
+ bits >>= ALIGN_CONTENT_SHIFT;
+
+ /* 3bits: ttt : type */
+ return (bits & 0x7);
+}
static inline uint8_t get_align_content(const css_computed_style *style)
{
uint32_t bits = style->i.bits[ALIGN_CONTENT_INDEX];
@@ -26,6 +35,15 @@ static inline uint8_t get_align_content(const css_computed_style *style)
#define ALIGN_ITEMS_INDEX 10
#define ALIGN_ITEMS_SHIFT 23
#define ALIGN_ITEMS_MASK 0x3800000
+static inline uint8_t get_align_items_bits(const css_computed_style *style)
+{
+ uint32_t bits = style->i.bits[ALIGN_ITEMS_INDEX];
+ bits &= ALIGN_ITEMS_MASK;
+ bits >>= ALIGN_ITEMS_SHIFT;
+
+ /* 3bits: ttt : type */
+ return (bits & 0x7);
+}
static inline uint8_t get_align_items(const css_computed_style *style)
{
uint32_t bits = style->i.bits[ALIGN_ITEMS_INDEX];
@@ -43,6 +61,15 @@ static inline uint8_t get_align_items(const css_computed_style *style)
#define ALIGN_SELF_INDEX 10
#define ALIGN_SELF_SHIFT 26
#define ALIGN_SELF_MASK 0x1c000000
+static inline uint8_t get_align_self_bits(const css_computed_style *style)
+{
+ uint32_t bits = style->i.bits[ALIGN_SELF_INDEX];
+ bits &= ALIGN_SELF_MASK;
+ bits >>= ALIGN_SELF_SHIFT;
+
+ /* 3bits: ttt : type */
+ return (bits & 0x7);
+}
static inline uint8_t get_align_self(const css_computed_style *style)
{
uint32_t bits = style->i.bits[ALIGN_SELF_INDEX];
@@ -60,6 +87,16 @@ static inline uint8_t get_align_self(const css_computed_style *style)
#define BACKGROUND_ATTACHMENT_INDEX 14
#define BACKGROUND_ATTACHMENT_SHIFT 28
#define BACKGROUND_ATTACHMENT_MASK 0x30000000
+static inline uint8_t get_background_attachment_bits(const css_computed_style
+ *style)
+{
+ uint32_t bits = style->i.bits[BACKGROUND_ATTACHMENT_INDEX];
+ bits &= BACKGROUND_ATTACHMENT_MASK;
+ bits >>= BACKGROUND_ATTACHMENT_SHIFT;
+
+ /* 2bits: tt : type */
+ return (bits & 0x3);
+}
static inline uint8_t get_background_attachment(const css_computed_style *style)
{
uint32_t bits = style->i.bits[BACKGROUND_ATTACHMENT_INDEX];
@@ -77,6 +114,15 @@ static inline uint8_t get_background_attachment(const css_computed_style *style)
#define BACKGROUND_COLOR_INDEX 14
#define BACKGROUND_COLOR_SHIFT 30
#define BACKGROUND_COLOR_MASK 0xc0000000
+static inline uint8_t get_background_color_bits(const css_computed_style *style)
+{
+ uint32_t bits = style->i.bits[BACKGROUND_COLOR_INDEX];
+ bits &= BACKGROUND_COLOR_MASK;
+ bits >>= BACKGROUND_COLOR_SHIFT;
+
+ /* 2bits: tt : type */
+ return (bits & 0x3);
+}
static inline uint8_t get_background_color(const css_computed_style *style,
css_color *color)
{
@@ -96,6 +142,15 @@ static inline uint8_t get_background_color(const css_computed_style *style,
#define BACKGROUND_IMAGE_INDEX 14
#define BACKGROUND_IMAGE_SHIFT 18
#define BACKGROUND_IMAGE_MASK 0x40000
+static inline uint8_t get_background_image_bits(const css_computed_style *style)
+{
+ uint32_t bits = style->i.bits[BACKGROUND_IMAGE_INDEX];
+ bits &= BACKGROUND_IMAGE_MASK;
+ bits >>= BACKGROUND_IMAGE_SHIFT;
+
+ /* 1bit: t : type */
+ return (bits & 0x1);
+}
static inline uint8_t get_background_image(const css_computed_style *style,
lwc_string **string)
{
@@ -115,6 +170,16 @@ static inline uint8_t get_background_image(const css_computed_style *style,
#define BACKGROUND_POSITION_INDEX 12
#define BACKGROUND_POSITION_SHIFT 10
#define BACKGROUND_POSITION_MASK 0x1ffc00
+static inline uint8_t get_background_position_bits(const css_computed_style
+ *style)
+{
+ uint32_t bits = style->i.bits[BACKGROUND_POSITION_INDEX];
+ bits &= BACKGROUND_POSITION_MASK;
+ bits >>= BACKGROUND_POSITION_SHIFT;
+
+ /* 11bits: aaaaabbbbbt : unit_a | unit_b | type */
+ return (bits & 0x1);
+}
static inline uint8_t get_background_position(const css_computed_style *style,
css_fixed *length_a, css_unit *unit_a, css_fixed *length_b,
css_unit *unit_b)
@@ -140,6 +205,16 @@ static inline uint8_t get_background_position(const css_computed_style *style,
#define BACKGROUND_REPEAT_INDEX 10
#define BACKGROUND_REPEAT_SHIFT 29
#define BACKGROUND_REPEAT_MASK 0xe0000000
+static inline uint8_t get_background_repeat_bits(const css_computed_style
+ *style)
+{
+ uint32_t bits = style->i.bits[BACKGROUND_REPEAT_INDEX];
+ bits &= BACKGROUND_REPEAT_MASK;
+ bits >>= BACKGROUND_REPEAT_SHIFT;
+
+ /* 3bits: ttt : type */
+ return (bits & 0x7);
+}
static inline uint8_t get_background_repeat(const css_computed_style *style)
{
uint32_t bits = style->i.bits[BACKGROUND_REPEAT_INDEX];
@@ -157,6 +232,16 @@ static inline uint8_t get_background_repeat(const css_computed_style *style)
#define BORDER_BOTTOM_COLOR_INDEX 11
#define BORDER_BOTTOM_COLOR_SHIFT 0
#define BORDER_BOTTOM_COLOR_MASK 0x3
+static inline uint8_t get_border_bottom_color_bits(const css_computed_style
+ *style)
+{
+ uint32_t bits = style->i.bits[BORDER_BOTTOM_COLOR_INDEX];
+ bits &= BORDER_BOTTOM_COLOR_MASK;
+ bits >>= BORDER_BOTTOM_COLOR_SHIFT;
+
+ /* 2bits: tt : type */
+ return (bits & 0x3);
+}
static inline uint8_t get_border_bottom_color(const css_computed_style *style,
css_color *color)
{
@@ -176,6 +261,16 @@ static inline uint8_t get_border_bottom_color(const css_computed_style *style,
#define BORDER_BOTTOM_STYLE_INDEX 13
#define BORDER_BOTTOM_STYLE_SHIFT 28
#define BORDER_BOTTOM_STYLE_MASK 0xf0000000
+static inline uint8_t get_border_bottom_style_bits(const css_computed_style
+ *style)
+{
+ uint32_t bits = style->i.bits[BORDER_BOTTOM_STYLE_INDEX];
+ bits &= BORDER_BOTTOM_STYLE_MASK;
+ bits >>= BORDER_BOTTOM_STYLE_SHIFT;
+
+ /* 4bits: tttt : type */
+ return (bits & 0xf);
+}
static inline uint8_t get_border_bottom_style(const css_computed_style *style)
{
uint32_t bits = style->i.bits[BORDER_BOTTOM_STYLE_INDEX];
@@ -193,6 +288,16 @@ static inline uint8_t get_border_bottom_style(const css_computed_style *style)
#define BORDER_BOTTOM_WIDTH_INDEX 0
#define BORDER_BOTTOM_WIDTH_SHIFT 0
#define BORDER_BOTTOM_WIDTH_MASK 0xff
+static inline uint8_t get_border_bottom_width_bits(const css_computed_style
+ *style)
+{
+ uint32_t bits = style->i.bits[BORDER_BOTTOM_WIDTH_INDEX];
+ bits &= BORDER_BOTTOM_WIDTH_MASK;
+ bits >>= BORDER_BOTTOM_WIDTH_SHIFT;
+
+ /* 8bits: uuuuuttt : unit | type */
+ return (bits & 0x7);
+}
static inline uint8_t get_border_bottom_width(const css_computed_style *style,
css_fixed *length, css_unit *unit)
{
@@ -215,6 +320,15 @@ static inline uint8_t get_border_bottom_width(const css_computed_style *style,
#define BORDER_COLLAPSE_INDEX 11
#define BORDER_COLLAPSE_SHIFT 2
#define BORDER_COLLAPSE_MASK 0xc
+static inline uint8_t get_border_collapse_bits(const css_computed_style *style)
+{
+ uint32_t bits = style->i.bits[BORDER_COLLAPSE_INDEX];
+ bits &= BORDER_COLLAPSE_MASK;
+ bits >>= BORDER_COLLAPSE_SHIFT;
+
+ /* 2bits: tt : type */
+ return (bits & 0x3);
+}
static inline uint8_t get_border_collapse(const css_computed_style *style)
{
uint32_t bits = style->i.bits[BORDER_COLLAPSE_INDEX];
@@ -232,6 +346,16 @@ static inline uint8_t get_border_collapse(const css_computed_style *style)
#define BORDER_LEFT_COLOR_INDEX 11
#define BORDER_LEFT_COLOR_SHIFT 4
#define BORDER_LEFT_COLOR_MASK 0x30
+static inline uint8_t get_border_left_color_bits(const css_computed_style
+ *style)
+{
+ uint32_t bits = style->i.bits[BORDER_LEFT_COLOR_INDEX];
+ bits &= BORDER_LEFT_COLOR_MASK;
+ bits >>= BORDER_LEFT_COLOR_SHIFT;
+
+ /* 2bits: tt : type */
+ return (bits & 0x3);
+}
static inline uint8_t get_border_left_color(const css_computed_style *style,
css_color *color)
{
@@ -251,6 +375,16 @@ static inline uint8_t get_border_left_color(const css_computed_style *style,
#define BORDER_LEFT_STYLE_INDEX 9
#define BORDER_LEFT_STYLE_SHIFT 3
#define BORDER_LEFT_STYLE_MASK 0x78
+static inline uint8_t get_border_left_style_bits(const css_computed_style
+ *style)
+{
+ uint32_t bits = style->i.bits[BORDER_LEFT_STYLE_INDEX];
+ bits &= BORDER_LEFT_STYLE_MASK;
+ bits >>= BORDER_LEFT_STYLE_SHIFT;
+
+ /* 4bits: tttt : type */
+ return (bits & 0xf);
+}
static inline uint8_t get_border_left_style(const css_computed_style *style)
{
uint32_t bits = style->i.bits[BORDER_LEFT_STYLE_INDEX];
@@ -268,6 +402,16 @@ static inline uint8_t get_border_left_style(const css_computed_style *style)
#define BORDER_LEFT_WIDTH_INDEX 0
#define BORDER_LEFT_WIDTH_SHIFT 8
#define BORDER_LEFT_WIDTH_MASK 0xff00
+static inline uint8_t get_border_left_width_bits(const css_computed_style
+ *style)
+{
+ uint32_t bits = style->i.bits[BORDER_LEFT_WIDTH_INDEX];
+ bits &= BORDER_LEFT_WIDTH_MASK;
+ bits >>= BORDER_LEFT_WIDTH_SHIFT;
+
+ /* 8bits: uuuuuttt : unit | type */
+ return (bits & 0x7);
+}
static inline uint8_t get_border_left_width(const css_computed_style *style,
css_fixed *length, css_unit *unit)
{
@@ -290,6 +434,16 @@ static inline uint8_t get_border_left_width(const css_computed_style *style,
#define BORDER_RIGHT_COLOR_INDEX 11
#define BORDER_RIGHT_COLOR_SHIFT 6
#define BORDER_RIGHT_COLOR_MASK 0xc0
+static inline uint8_t get_border_right_color_bits(const css_computed_style
+ *style)
+{
+ uint32_t bits = style->i.bits[BORDER_RIGHT_COLOR_INDEX];
+ bits &= BORDER_RIGHT_COLOR_MASK;
+ bits >>= BORDER_RIGHT_COLOR_SHIFT;
+
+ /* 2bits: tt : type */
+ return (bits & 0x3);
+}
static inline uint8_t get_border_right_color(const css_computed_style *style,
css_color *color)
{
@@ -309,6 +463,16 @@ static inline uint8_t get_border_right_color(const css_computed_style *style,
#define BORDER_RIGHT_STYLE_INDEX 9
#define BORDER_RIGHT_STYLE_SHIFT 7
#define BORDER_RIGHT_STYLE_MASK 0x780
+static inline uint8_t get_border_right_style_bits(const css_computed_style
+ *style)
+{
+ uint32_t bits = style->i.bits[BORDER_RIGHT_STYLE_INDEX];
+ bits &= BORDER_RIGHT_STYLE_MASK;
+ bits >>= BORDER_RIGHT_STYLE_SHIFT;
+
+ /* 4bits: tttt : type */
+ return (bits & 0xf);
+}
static inline uint8_t get_border_right_style(const css_computed_style *style)
{
uint32_t bits = style->i.bits[BORDER_RIGHT_STYLE_INDEX];
@@ -326,6 +490,16 @@ static inline uint8_t get_border_right_style(const css_computed_style *style)
#define BORDER_RIGHT_WIDTH_INDEX 0
#define BORDER_RIGHT_WIDTH_SHIFT 16
#define BORDER_RIGHT_WIDTH_MASK 0xff0000
+static inline uint8_t get_border_right_width_bits(const css_computed_style
+ *style)
+{
+ uint32_t bits = style->i.bits[BORDER_RIGHT_WIDTH_INDEX];
+ bits &= BORDER_RIGHT_WIDTH_MASK;
+ bits >>= BORDER_RIGHT_WIDTH_SHIFT;
+
+ /* 8bits: uuuuuttt : unit | type */
+ return (bits & 0x7);
+}
static inline uint8_t get_border_right_width(const css_computed_style *style,
css_fixed *length, css_unit *unit)
{
@@ -348,6 +522,15 @@ static inline uint8_t get_border_right_width(const css_computed_style *style,
#define BORDER_SPACING_INDEX 12
#define BORDER_SPACING_SHIFT 21
#define BORDER_SPACING_MASK 0xffe00000
+static inline uint8_t get_border_spacing_bits(const css_computed_style *style)
+{
+ uint32_t bits = style->i.bits[BORDER_SPACING_INDEX];
+ bits &= BORDER_SPACING_MASK;
+ bits >>= BORDER_SPACING_SHIFT;
+
+ /* 11bits: aaaaabbbbbt : unit_a | unit_b | type */
+ return (bits & 0x1);
+}
static inline uint8_t get_border_spacing(const css_computed_style *style,
css_fixed *length_a, css_unit *unit_a, css_fixed *length_b,
css_unit *unit_b)
@@ -373,6 +556,15 @@ static inline uint8_t get_border_spacing(const css_computed_style *style,
#define BORDER_TOP_COLOR_INDEX 11
#define BORDER_TOP_COLOR_SHIFT 8
#define BORDER_TOP_COLOR_MASK 0x300
+static inline uint8_t get_border_top_color_bits(const css_computed_style *style)
+{
+ uint32_t bits = style->i.bits[BORDER_TOP_COLOR_INDEX];
+ bits &= BORDER_TOP_COLOR_MASK;
+ bits >>= BORDER_TOP_COLOR_SHIFT;
+
+ /* 2bits: tt : type */
+ return (bits & 0x3);
+}
static inline uint8_t get_border_top_color(const css_computed_style *style,
css_color *color)
{
@@ -392,6 +584,15 @@ static inline uint8_t get_border_top_color(const css_computed_style *style,
#define BORDER_TOP_STYLE_INDEX 9
#define BORDER_TOP_STYLE_SHIFT 11
#define BORDER_TOP_STYLE_MASK 0x7800
+static inline uint8_t get_border_top_style_bits(const css_computed_style *style)
+{
+ uint32_t bits = style->i.bits[BORDER_TOP_STYLE_INDEX];
+ bits &= BORDER_TOP_STYLE_MASK;
+ bits >>= BORDER_TOP_STYLE_SHIFT;
+
+ /* 4bits: tttt : type */
+ return (bits & 0xf);
+}
static inline uint8_t get_border_top_style(const css_computed_style *style)
{
uint32_t bits = style->i.bits[BORDER_TOP_STYLE_INDEX];
@@ -409,6 +610,15 @@ static inline uint8_t get_border_top_style(const css_computed_style *style)
#define BORDER_TOP_WIDTH_INDEX 0
#define BORDER_TOP_WIDTH_SHIFT 24
#define BORDER_TOP_WIDTH_MASK 0xff000000
+static inline uint8_t get_border_top_width_bits(const css_computed_style *style)
+{
+ uint32_t bits = style->i.bits[BORDER_TOP_WIDTH_INDEX];
+ bits &= BORDER_TOP_WIDTH_MASK;
+ bits >>= BORDER_TOP_WIDTH_SHIFT;
+
+ /* 8bits: uuuuuttt : unit | type */
+ return (bits & 0x7);
+}
static inline uint8_t get_border_top_width(const css_computed_style *style,
css_fixed *length, css_unit *unit)
{
@@ -431,31 +641,29 @@ static inline uint8_t get_border_top_width(const css_computed_style *style,
#define BOTTOM_INDEX 3
#define BOTTOM_SHIFT 11
#define BOTTOM_MASK 0x3f800
-static inline uint8_t get_bottom(
- const css_computed_style *style,
- css_fixed *length, css_unit *unit)
+static inline uint8_t get_bottom_bits(const css_computed_style *style)
{
uint32_t bits = style->i.bits[BOTTOM_INDEX];
bits &= BOTTOM_MASK;
bits >>= BOTTOM_SHIFT;
-
- /* 7bits: uuuuutt : units | type */
- if ((bits & 0x3) == CSS_BOTTOM_SET) {
- *length = style->i.bottom;
- *unit = bits >> 2;
- }
-
+
+ /* 7bits: uuuuutt : unit | type */
return (bits & 0x3);
}
-static inline uint8_t get_bottom_bits(
- const css_computed_style *style)
+static inline uint8_t get_bottom(const css_computed_style *style, css_fixed
+ *length, css_unit *unit)
{
uint32_t bits = style->i.bits[BOTTOM_INDEX];
bits &= BOTTOM_MASK;
bits >>= BOTTOM_SHIFT;
-
- /* 7bits: uuuuutt : units | type */
- return bits;
+
+ /* 7bits: uuuuutt : unit | type */
+ if ((bits & 0x3) == CSS_BOTTOM_SET) {
+ *length = style->i.bottom;
+ *unit = bits >> 2;
+ }
+
+ return (bits & 0x3);
}
#undef BOTTOM_INDEX
#undef BOTTOM_SHIFT
@@ -464,6 +672,15 @@ static inline uint8_t get_bottom_bits(
#define BOX_SIZING_INDEX 11
#define BOX_SIZING_SHIFT 10
#define BOX_SIZING_MASK 0xc00
+static inline uint8_t get_box_sizing_bits(const css_computed_style *style)
+{
+ uint32_t bits = style->i.bits[BOX_SIZING_INDEX];
+ bits &= BOX_SIZING_MASK;
+ bits >>= BOX_SIZING_SHIFT;
+
+ /* 2bits: tt : type */
+ return (bits & 0x3);
+}
static inline uint8_t get_box_sizing(const css_computed_style *style)
{
uint32_t bits = style->i.bits[BOX_SIZING_INDEX];
@@ -481,6 +698,15 @@ static inline uint8_t get_box_sizing(const css_computed_style *style)
#define BREAK_AFTER_INDEX 9
#define BREAK_AFTER_SHIFT 15
#define BREAK_AFTER_MASK 0x78000
+static inline uint8_t get_break_after_bits(const css_computed_style *style)
+{
+ uint32_t bits = style->i.bits[BREAK_AFTER_INDEX];
+ bits &= BREAK_AFTER_MASK;
+ bits >>= BREAK_AFTER_SHIFT;
+
+ /* 4bits: tttt : type */
+ return (bits & 0xf);
+}
static inline uint8_t get_break_after(const css_computed_style *style)
{
uint32_t bits = style->i.bits[BREAK_AFTER_INDEX];
@@ -498,6 +724,15 @@ static inline uint8_t get_break_after(const css_computed_style *style)
#define BREAK_BEFORE_INDEX 9
#define BREAK_BEFORE_SHIFT 19
#define BREAK_BEFORE_MASK 0x780000
+static inline uint8_t get_break_before_bits(const css_computed_style *style)
+{
+ uint32_t bits = style->i.bits[BREAK_BEFORE_INDEX];
+ bits &= BREAK_BEFORE_MASK;
+ bits >>= BREAK_BEFORE_SHIFT;
+
+ /* 4bits: tttt : type */
+ return (bits & 0xf);
+}
static inline uint8_t get_break_before(const css_computed_style *style)
{
uint32_t bits = style->i.bits[BREAK_BEFORE_INDEX];
@@ -515,6 +750,15 @@ static inline uint8_t get_break_before(const css_computed_style *style)
#define BREAK_INSIDE_INDEX 9
#define BREAK_INSIDE_SHIFT 23
#define BREAK_INSIDE_MASK 0x7800000
+static inline uint8_t get_break_inside_bits(const css_computed_style *style)
+{
+ uint32_t bits = style->i.bits[BREAK_INSIDE_INDEX];
+ bits &= BREAK_INSIDE_MASK;
+ bits >>= BREAK_INSIDE_SHIFT;
+
+ /* 4bits: tttt : type */
+ return (bits & 0xf);
+}
static inline uint8_t get_break_inside(const css_computed_style *style)
{
uint32_t bits = style->i.bits[BREAK_INSIDE_INDEX];
@@ -532,6 +776,15 @@ static inline uint8_t get_break_inside(const css_computed_style *style)
#define CAPTION_SIDE_INDEX 11
#define CAPTION_SIDE_SHIFT 12
#define CAPTION_SIDE_MASK 0x3000
+static inline uint8_t get_caption_side_bits(const css_computed_style *style)
+{
+ uint32_t bits = style->i.bits[CAPTION_SIDE_INDEX];
+ bits &= CAPTION_SIDE_MASK;
+ bits >>= CAPTION_SIDE_SHIFT;
+
+ /* 2bits: tt : type */
+ return (bits & 0x3);
+}
static inline uint8_t get_caption_side(const css_computed_style *style)
{
uint32_t bits = style->i.bits[CAPTION_SIDE_INDEX];
@@ -549,6 +802,15 @@ static inline uint8_t get_caption_side(const css_computed_style *style)
#define CLEAR_INDEX 13
#define CLEAR_SHIFT 1
#define CLEAR_MASK 0xe
+static inline uint8_t get_clear_bits(const css_computed_style *style)
+{
+ uint32_t bits = style->i.bits[CLEAR_INDEX];
+ bits &= CLEAR_MASK;
+ bits >>= CLEAR_SHIFT;
+
+ /* 3bits: ttt : type */
+ return (bits & 0x7);
+}
static inline uint8_t get_clear(const css_computed_style *style)
{
uint32_t bits = style->i.bits[CLEAR_INDEX];
@@ -566,6 +828,16 @@ static inline uint8_t get_clear(const css_computed_style *style)
#define CLIP_INDEX 2
#define CLIP_SHIFT 6
#define CLIP_MASK 0xffffffc0
+static inline uint8_t get_clip_bits(const css_computed_style *style)
+{
+ uint32_t bits = style->i.bits[CLIP_INDEX];
+ bits &= CLIP_MASK;
+ bits >>= CLIP_SHIFT;
+
+ /* 26bits: aaaaabbbbbcccccdddddtttttt : unit_a | unit_b | unit_c |
+ unit_d | type */
+ return (bits & 0x3f);
+}
static inline uint8_t get_clip(
const css_computed_style *style,
css_computed_clip_rect *rect)
@@ -608,15 +880,24 @@ static inline uint8_t get_clip(
#define COLOR_INDEX 14
#define COLOR_SHIFT 19
#define COLOR_MASK 0x80000
-static inline uint8_t get_color(const css_computed_style *style, css_color
- *color)
+static inline uint8_t get_color_bits(const css_computed_style *style)
{
uint32_t bits = style->i.bits[COLOR_INDEX];
bits &= COLOR_MASK;
bits >>= COLOR_SHIFT;
/* 1bit: t : type */
- *color = style->i.color;
+ return (bits & 0x1);
+}
+static inline uint8_t get_color(const css_computed_style *style, css_color
+ *color)
+{
+ uint32_t bits = style->i.bits[COLOR_INDEX];
+ bits &= COLOR_MASK;
+ bits >>= COLOR_SHIFT;
+
+ /* 1bit: t : type */
+ *color = style->i.color;
return (bits & 0x1);
}
@@ -627,6 +908,15 @@ static inline uint8_t get_color(const css_computed_style *style, css_color
#define COLUMN_COUNT_INDEX 11
#define COLUMN_COUNT_SHIFT 14
#define COLUMN_COUNT_MASK 0xc000
+static inline uint8_t get_column_count_bits(const css_computed_style *style)
+{
+ uint32_t bits = style->i.bits[COLUMN_COUNT_INDEX];
+ bits &= COLUMN_COUNT_MASK;
+ bits >>= COLUMN_COUNT_SHIFT;
+
+ /* 2bits: tt : type */
+ return (bits & 0x3);
+}
static inline uint8_t get_column_count(const css_computed_style *style, int32_t
*integer)
{
@@ -646,6 +936,15 @@ static inline uint8_t get_column_count(const css_computed_style *style, int32_t
#define COLUMN_FILL_INDEX 11
#define COLUMN_FILL_SHIFT 16
#define COLUMN_FILL_MASK 0x30000
+static inline uint8_t get_column_fill_bits(const css_computed_style *style)
+{
+ uint32_t bits = style->i.bits[COLUMN_FILL_INDEX];
+ bits &= COLUMN_FILL_MASK;
+ bits >>= COLUMN_FILL_SHIFT;
+
+ /* 2bits: tt : type */
+ return (bits & 0x3);
+}
static inline uint8_t get_column_fill(const css_computed_style *style)
{
uint32_t bits = style->i.bits[COLUMN_FILL_INDEX];
@@ -663,6 +962,15 @@ static inline uint8_t get_column_fill(const css_computed_style *style)
#define COLUMN_GAP_INDEX 3
#define COLUMN_GAP_SHIFT 18
#define COLUMN_GAP_MASK 0x1fc0000
+static inline uint8_t get_column_gap_bits(const css_computed_style *style)
+{
+ uint32_t bits = style->i.bits[COLUMN_GAP_INDEX];
+ bits &= COLUMN_GAP_MASK;
+ bits >>= COLUMN_GAP_SHIFT;
+
+ /* 7bits: uuuuutt : unit | type */
+ return (bits & 0x3);
+}
static inline uint8_t get_column_gap(const css_computed_style *style, css_fixed
*length, css_unit *unit)
{
@@ -685,6 +993,16 @@ static inline uint8_t get_column_gap(const css_computed_style *style, css_fixed
#define COLUMN_RULE_COLOR_INDEX 11
#define COLUMN_RULE_COLOR_SHIFT 18
#define COLUMN_RULE_COLOR_MASK 0xc0000
+static inline uint8_t get_column_rule_color_bits(const css_computed_style
+ *style)
+{
+ uint32_t bits = style->i.bits[COLUMN_RULE_COLOR_INDEX];
+ bits &= COLUMN_RULE_COLOR_MASK;
+ bits >>= COLUMN_RULE_COLOR_SHIFT;
+
+ /* 2bits: tt : type */
+ return (bits & 0x3);
+}
static inline uint8_t get_column_rule_color(const css_computed_style *style,
css_color *color)
{
@@ -704,6 +1022,16 @@ static inline uint8_t get_column_rule_color(const css_computed_style *style,
#define COLUMN_RULE_STYLE_INDEX 7
#define COLUMN_RULE_STYLE_SHIFT 0
#define COLUMN_RULE_STYLE_MASK 0xf
+static inline uint8_t get_column_rule_style_bits(const css_computed_style
+ *style)
+{
+ uint32_t bits = style->i.bits[COLUMN_RULE_STYLE_INDEX];
+ bits &= COLUMN_RULE_STYLE_MASK;
+ bits >>= COLUMN_RULE_STYLE_SHIFT;
+
+ /* 4bits: tttt : type */
+ return (bits & 0xf);
+}
static inline uint8_t get_column_rule_style(const css_computed_style *style)
{
uint32_t bits = style->i.bits[COLUMN_RULE_STYLE_INDEX];
@@ -721,6 +1049,16 @@ static inline uint8_t get_column_rule_style(const css_computed_style *style)
#define COLUMN_RULE_WIDTH_INDEX 1
#define COLUMN_RULE_WIDTH_SHIFT 7
#define COLUMN_RULE_WIDTH_MASK 0x7f80
+static inline uint8_t get_column_rule_width_bits(const css_computed_style
+ *style)
+{
+ uint32_t bits = style->i.bits[COLUMN_RULE_WIDTH_INDEX];
+ bits &= COLUMN_RULE_WIDTH_MASK;
+ bits >>= COLUMN_RULE_WIDTH_SHIFT;
+
+ /* 8bits: uuuuuttt : unit | type */
+ return (bits & 0x7);
+}
static inline uint8_t get_column_rule_width(const css_computed_style *style,
css_fixed *length, css_unit *unit)
{
@@ -743,6 +1081,15 @@ static inline uint8_t get_column_rule_width(const css_computed_style *style,
#define COLUMN_SPAN_INDEX 11
#define COLUMN_SPAN_SHIFT 20
#define COLUMN_SPAN_MASK 0x300000
+static inline uint8_t get_column_span_bits(const css_computed_style *style)
+{
+ uint32_t bits = style->i.bits[COLUMN_SPAN_INDEX];
+ bits &= COLUMN_SPAN_MASK;
+ bits >>= COLUMN_SPAN_SHIFT;
+
+ /* 2bits: tt : type */
+ return (bits & 0x3);
+}
static inline uint8_t get_column_span(const css_computed_style *style)
{
uint32_t bits = style->i.bits[COLUMN_SPAN_INDEX];
@@ -760,6 +1107,15 @@ static inline uint8_t get_column_span(const css_computed_style *style)
#define COLUMN_WIDTH_INDEX 3
#define COLUMN_WIDTH_SHIFT 25
#define COLUMN_WIDTH_MASK 0xfe000000
+static inline uint8_t get_column_width_bits(const css_computed_style *style)
+{
+ uint32_t bits = style->i.bits[COLUMN_WIDTH_INDEX];
+ bits &= COLUMN_WIDTH_MASK;
+ bits >>= COLUMN_WIDTH_SHIFT;
+
+ /* 7bits: uuuuutt : unit | type */
+ return (bits & 0x3);
+}
static inline uint8_t get_column_width(const css_computed_style *style,
css_fixed *length, css_unit *unit)
{
@@ -782,6 +1138,15 @@ static inline uint8_t get_column_width(const css_computed_style *style,
#define CONTENT_INDEX 11
#define CONTENT_SHIFT 22
#define CONTENT_MASK 0xc00000
+static inline uint8_t get_content_bits(const css_computed_style *style)
+{
+ uint32_t bits = style->i.bits[CONTENT_INDEX];
+ bits &= CONTENT_MASK;
+ bits >>= CONTENT_SHIFT;
+
+ /* 2bits: tt : type */
+ return (bits & 0x3);
+}
static inline uint8_t get_content(const css_computed_style *style, const
css_computed_content_item **content_item)
{
@@ -803,6 +1168,16 @@ static inline uint8_t get_content(const css_computed_style *style, const
#define COUNTER_INCREMENT_INDEX 14
#define COUNTER_INCREMENT_SHIFT 20
#define COUNTER_INCREMENT_MASK 0x100000
+static inline uint8_t get_counter_increment_bits(const css_computed_style
+ *style)
+{
+ uint32_t bits = style->i.bits[COUNTER_INCREMENT_INDEX];
+ bits &= COUNTER_INCREMENT_MASK;
+ bits >>= COUNTER_INCREMENT_SHIFT;
+
+ /* 1bit: t : type */
+ return (bits & 0x1);
+}
static inline uint8_t get_counter_increment(const css_computed_style *style,
const css_computed_counter **counter_arr)
{
@@ -822,6 +1197,15 @@ static inline uint8_t get_counter_increment(const css_computed_style *style,
#define COUNTER_RESET_INDEX 14
#define COUNTER_RESET_SHIFT 21
#define COUNTER_RESET_MASK 0x200000
+static inline uint8_t get_counter_reset_bits(const css_computed_style *style)
+{
+ uint32_t bits = style->i.bits[COUNTER_RESET_INDEX];
+ bits &= COUNTER_RESET_MASK;
+ bits >>= COUNTER_RESET_SHIFT;
+
+ /* 1bit: t : type */
+ return (bits & 0x1);
+}
static inline uint8_t get_counter_reset(const css_computed_style *style, const
css_computed_counter **counter_arr)
{
@@ -841,6 +1225,15 @@ static inline uint8_t get_counter_reset(const css_computed_style *style, const
#define CURSOR_INDEX 9
#define CURSOR_SHIFT 27
#define CURSOR_MASK 0xf8000000
+static inline uint8_t get_cursor_bits(const css_computed_style *style)
+{
+ uint32_t bits = style->i.bits[CURSOR_INDEX];
+ bits &= CURSOR_MASK;
+ bits >>= CURSOR_SHIFT;
+
+ /* 5bits: ttttt : type */
+ return (bits & 0x1f);
+}
static inline uint8_t get_cursor(const css_computed_style *style, lwc_string
***string_arr)
{
@@ -860,6 +1253,15 @@ static inline uint8_t get_cursor(const css_computed_style *style, lwc_string
#define DIRECTION_INDEX 11
#define DIRECTION_SHIFT 24
#define DIRECTION_MASK 0x3000000
+static inline uint8_t get_direction_bits(const css_computed_style *style)
+{
+ uint32_t bits = style->i.bits[DIRECTION_INDEX];
+ bits &= DIRECTION_MASK;
+ bits >>= DIRECTION_SHIFT;
+
+ /* 2bits: tt : type */
+ return (bits & 0x3);
+}
static inline uint8_t get_direction(const css_computed_style *style)
{
uint32_t bits = style->i.bits[DIRECTION_INDEX];
@@ -877,6 +1279,15 @@ static inline uint8_t get_direction(const css_computed_style *style)
#define DISPLAY_INDEX 8
#define DISPLAY_SHIFT 3
#define DISPLAY_MASK 0xf8
+static inline uint8_t get_display_bits(const css_computed_style *style)
+{
+ uint32_t bits = style->i.bits[DISPLAY_INDEX];
+ bits &= DISPLAY_MASK;
+ bits >>= DISPLAY_SHIFT;
+
+ /* 5bits: ttttt : type */
+ return (bits & 0x1f);
+}
static inline uint8_t get_display(const css_computed_style *style)
{
uint32_t bits = style->i.bits[DISPLAY_INDEX];
@@ -894,6 +1305,15 @@ static inline uint8_t get_display(const css_computed_style *style)
#define EMPTY_CELLS_INDEX 11
#define EMPTY_CELLS_SHIFT 26
#define EMPTY_CELLS_MASK 0xc000000
+static inline uint8_t get_empty_cells_bits(const css_computed_style *style)
+{
+ uint32_t bits = style->i.bits[EMPTY_CELLS_INDEX];
+ bits &= EMPTY_CELLS_MASK;
+ bits >>= EMPTY_CELLS_SHIFT;
+
+ /* 2bits: tt : type */
+ return (bits & 0x3);
+}
static inline uint8_t get_empty_cells(const css_computed_style *style)
{
uint32_t bits = style->i.bits[EMPTY_CELLS_INDEX];
@@ -911,6 +1331,15 @@ static inline uint8_t get_empty_cells(const css_computed_style *style)
#define FLEX_BASIS_INDEX 7
#define FLEX_BASIS_SHIFT 4
#define FLEX_BASIS_MASK 0x7f0
+static inline uint8_t get_flex_basis_bits(const css_computed_style *style)
+{
+ uint32_t bits = style->i.bits[FLEX_BASIS_INDEX];
+ bits &= FLEX_BASIS_MASK;
+ bits >>= FLEX_BASIS_SHIFT;
+
+ /* 7bits: uuuuutt : unit | type */
+ return (bits & 0x3);
+}
static inline uint8_t get_flex_basis(const css_computed_style *style, css_fixed
*length, css_unit *unit)
{
@@ -933,6 +1362,15 @@ static inline uint8_t get_flex_basis(const css_computed_style *style, css_fixed
#define FLEX_DIRECTION_INDEX 13
#define FLEX_DIRECTION_SHIFT 4
#define FLEX_DIRECTION_MASK 0x70
+static inline uint8_t get_flex_direction_bits(const css_computed_style *style)
+{
+ uint32_t bits = style->i.bits[FLEX_DIRECTION_INDEX];
+ bits &= FLEX_DIRECTION_MASK;
+ bits >>= FLEX_DIRECTION_SHIFT;
+
+ /* 3bits: ttt : type */
+ return (bits & 0x7);
+}
static inline uint8_t get_flex_direction(const css_computed_style *style)
{
uint32_t bits = style->i.bits[FLEX_DIRECTION_INDEX];
@@ -950,6 +1388,15 @@ static inline uint8_t get_flex_direction(const css_computed_style *style)
#define FLEX_GROW_INDEX 14
#define FLEX_GROW_SHIFT 22
#define FLEX_GROW_MASK 0x400000
+static inline uint8_t get_flex_grow_bits(const css_computed_style *style)
+{
+ uint32_t bits = style->i.bits[FLEX_GROW_INDEX];
+ bits &= FLEX_GROW_MASK;
+ bits >>= FLEX_GROW_SHIFT;
+
+ /* 1bit: t : type */
+ return (bits & 0x1);
+}
static inline uint8_t get_flex_grow(const css_computed_style *style, css_fixed
*fixed)
{
@@ -971,6 +1418,15 @@ static inline uint8_t get_flex_grow(const css_computed_style *style, css_fixed
#define FLEX_SHRINK_INDEX 14
#define FLEX_SHRINK_SHIFT 23
#define FLEX_SHRINK_MASK 0x800000
+static inline uint8_t get_flex_shrink_bits(const css_computed_style *style)
+{
+ uint32_t bits = style->i.bits[FLEX_SHRINK_INDEX];
+ bits &= FLEX_SHRINK_MASK;
+ bits >>= FLEX_SHRINK_SHIFT;
+
+ /* 1bit: t : type */
+ return (bits & 0x1);
+}
static inline uint8_t get_flex_shrink(const css_computed_style *style,
css_fixed *fixed)
{
@@ -992,6 +1448,15 @@ static inline uint8_t get_flex_shrink(const css_computed_style *style,
#define FLEX_WRAP_INDEX 11
#define FLEX_WRAP_SHIFT 28
#define FLEX_WRAP_MASK 0x30000000
+static inline uint8_t get_flex_wrap_bits(const css_computed_style *style)
+{
+ uint32_t bits = style->i.bits[FLEX_WRAP_INDEX];
+ bits &= FLEX_WRAP_MASK;
+ bits >>= FLEX_WRAP_SHIFT;
+
+ /* 2bits: tt : type */
+ return (bits & 0x3);
+}
static inline uint8_t get_flex_wrap(const css_computed_style *style)
{
uint32_t bits = style->i.bits[FLEX_WRAP_INDEX];
@@ -1009,6 +1474,15 @@ static inline uint8_t get_flex_wrap(const css_computed_style *style)
#define FLOAT_INDEX 11
#define FLOAT_SHIFT 30
#define FLOAT_MASK 0xc0000000
+static inline uint8_t get_float_bits(const css_computed_style *style)
+{
+ uint32_t bits = style->i.bits[FLOAT_INDEX];
+ bits &= FLOAT_MASK;
+ bits >>= FLOAT_SHIFT;
+
+ /* 2bits: tt : type */
+ return (bits & 0x3);
+}
static inline uint8_t get_float(const css_computed_style *style)
{
uint32_t bits = style->i.bits[FLOAT_INDEX];
@@ -1026,6 +1500,15 @@ static inline uint8_t get_float(const css_computed_style *style)
#define FONT_FAMILY_INDEX 13
#define FONT_FAMILY_SHIFT 7
#define FONT_FAMILY_MASK 0x380
+static inline uint8_t get_font_family_bits(const css_computed_style *style)
+{
+ uint32_t bits = style->i.bits[FONT_FAMILY_INDEX];
+ bits &= FONT_FAMILY_MASK;
+ bits >>= FONT_FAMILY_SHIFT;
+
+ /* 3bits: ttt : type */
+ return (bits & 0x7);
+}
static inline uint8_t get_font_family(const css_computed_style *style,
lwc_string ***string_arr)
{
@@ -1045,6 +1528,15 @@ static inline uint8_t get_font_family(const css_computed_style *style,
#define FONT_SIZE_INDEX 1
#define FONT_SIZE_SHIFT 23
#define FONT_SIZE_MASK 0xff800000
+static inline uint8_t get_font_size_bits(const css_computed_style *style)
+{
+ uint32_t bits = style->i.bits[FONT_SIZE_INDEX];
+ bits &= FONT_SIZE_MASK;
+ bits >>= FONT_SIZE_SHIFT;
+
+ /* 9bits: uuuuutttt : unit | type */
+ return (bits & 0xf);
+}
static inline uint8_t get_font_size(const css_computed_style *style, css_fixed
*length, css_unit *unit)
{
@@ -1067,6 +1559,15 @@ static inline uint8_t get_font_size(const css_computed_style *style, css_fixed
#define FONT_STYLE_INDEX 10
#define FONT_STYLE_SHIFT 0
#define FONT_STYLE_MASK 0x3
+static inline uint8_t get_font_style_bits(const css_computed_style *style)
+{
+ uint32_t bits = style->i.bits[FONT_STYLE_INDEX];
+ bits &= FONT_STYLE_MASK;
+ bits >>= FONT_STYLE_SHIFT;
+
+ /* 2bits: tt : type */
+ return (bits & 0x3);
+}
static inline uint8_t get_font_style(const css_computed_style *style)
{
uint32_t bits = style->i.bits[FONT_STYLE_INDEX];
@@ -1084,6 +1585,15 @@ static inline uint8_t get_font_style(const css_computed_style *style)
#define FONT_VARIANT_INDEX 10
#define FONT_VARIANT_SHIFT 2
#define FONT_VARIANT_MASK 0xc
+static inline uint8_t get_font_variant_bits(const css_computed_style *style)
+{
+ uint32_t bits = style->i.bits[FONT_VARIANT_INDEX];
+ bits &= FONT_VARIANT_MASK;
+ bits >>= FONT_VARIANT_SHIFT;
+
+ /* 2bits: tt : type */
+ return (bits & 0x3);
+}
static inline uint8_t get_font_variant(const css_computed_style *style)
{
uint32_t bits = style->i.bits[FONT_VARIANT_INDEX];
@@ -1101,6 +1611,15 @@ static inline uint8_t get_font_variant(const css_computed_style *style)
#define FONT_WEIGHT_INDEX 6
#define FONT_WEIGHT_SHIFT 0
#define FONT_WEIGHT_MASK 0xf
+static inline uint8_t get_font_weight_bits(const css_computed_style *style)
+{
+ uint32_t bits = style->i.bits[FONT_WEIGHT_INDEX];
+ bits &= FONT_WEIGHT_MASK;
+ bits >>= FONT_WEIGHT_SHIFT;
+
+ /* 4bits: tttt : type */
+ return (bits & 0xf);
+}
static inline uint8_t get_font_weight(const css_computed_style *style)
{
uint32_t bits = style->i.bits[FONT_WEIGHT_INDEX];
@@ -1118,6 +1637,15 @@ static inline uint8_t get_font_weight(const css_computed_style *style)
#define HEIGHT_INDEX 7
#define HEIGHT_SHIFT 11
#define HEIGHT_MASK 0x3f800
+static inline uint8_t get_height_bits(const css_computed_style *style)
+{
+ uint32_t bits = style->i.bits[HEIGHT_INDEX];
+ bits &= HEIGHT_MASK;
+ bits >>= HEIGHT_SHIFT;
+
+ /* 7bits: uuuuutt : unit | type */
+ return (bits & 0x3);
+}
static inline uint8_t get_height(const css_computed_style *style, css_fixed
*length, css_unit *unit)
{
@@ -1140,6 +1668,15 @@ static inline uint8_t get_height(const css_computed_style *style, css_fixed
#define JUSTIFY_CONTENT_INDEX 13
#define JUSTIFY_CONTENT_SHIFT 10
#define JUSTIFY_CONTENT_MASK 0x1c00
+static inline uint8_t get_justify_content_bits(const css_computed_style *style)
+{
+ uint32_t bits = style->i.bits[JUSTIFY_CONTENT_INDEX];
+ bits &= JUSTIFY_CONTENT_MASK;
+ bits >>= JUSTIFY_CONTENT_SHIFT;
+
+ /* 3bits: ttt : type */
+ return (bits & 0x7);
+}
static inline uint8_t get_justify_content(const css_computed_style *style)
{
uint32_t bits = style->i.bits[JUSTIFY_CONTENT_INDEX];
@@ -1157,39 +1694,46 @@ static inline uint8_t get_justify_content(const css_computed_style *style)
#define LEFT_INDEX 7
#define LEFT_SHIFT 18
#define LEFT_MASK 0x1fc0000
-static inline uint8_t get_left(
- const css_computed_style *style,
- css_fixed *length, css_unit *unit)
+static inline uint8_t get_left_bits(const css_computed_style *style)
{
uint32_t bits = style->i.bits[LEFT_INDEX];
bits &= LEFT_MASK;
bits >>= LEFT_SHIFT;
-
- /* 7bits: uuuuutt : units | type */
- if ((bits & 0x3) == CSS_LEFT_SET) {
- *length = style->i.left;
- *unit = bits >> 2;
- }
-
+
+ /* 7bits: uuuuutt : unit | type */
return (bits & 0x3);
}
-static inline uint8_t get_left_bits(
- const css_computed_style *style)
+static inline uint8_t get_left(const css_computed_style *style, css_fixed
+ *length, css_unit *unit)
{
uint32_t bits = style->i.bits[LEFT_INDEX];
bits &= LEFT_MASK;
bits >>= LEFT_SHIFT;
-
- /* 7bits: uuuuutt : units | type */
- return bits;
-}
-#undef LEFT_INDEX
-#undef LEFT_SHIFT
-#undef LEFT_MASK
-
-#define LETTER_SPACING_INDEX 7
-#define LETTER_SPACING_SHIFT 25
+
+ /* 7bits: uuuuutt : unit | type */
+ if ((bits & 0x3) == CSS_LEFT_SET) {
+ *length = style->i.left;
+ *unit = bits >> 2;
+ }
+
+ return (bits & 0x3);
+}
+#undef LEFT_INDEX
+#undef LEFT_SHIFT
+#undef LEFT_MASK
+
+#define LETTER_SPACING_INDEX 7
+#define LETTER_SPACING_SHIFT 25
#define LETTER_SPACING_MASK 0xfe000000
+static inline uint8_t get_letter_spacing_bits(const css_computed_style *style)
+{
+ uint32_t bits = style->i.bits[LETTER_SPACING_INDEX];
+ bits &= LETTER_SPACING_MASK;
+ bits >>= LETTER_SPACING_SHIFT;
+
+ /* 7bits: uuuuutt : unit | type */
+ return (bits & 0x3);
+}
static inline uint8_t get_letter_spacing(const css_computed_style *style,
css_fixed *length, css_unit *unit)
{
@@ -1212,6 +1756,15 @@ static inline uint8_t get_letter_spacing(const css_computed_style *style,
#define LINE_HEIGHT_INDEX 6
#define LINE_HEIGHT_SHIFT 4
#define LINE_HEIGHT_MASK 0x7f0
+static inline uint8_t get_line_height_bits(const css_computed_style *style)
+{
+ uint32_t bits = style->i.bits[LINE_HEIGHT_INDEX];
+ bits &= LINE_HEIGHT_MASK;
+ bits >>= LINE_HEIGHT_SHIFT;
+
+ /* 7bits: uuuuutt : unit | type */
+ return (bits & 0x3);
+}
static inline uint8_t get_line_height(
const css_computed_style *style,
css_fixed *length, css_unit *unit)
@@ -1239,6 +1792,15 @@ static inline uint8_t get_line_height(
#define LIST_STYLE_IMAGE_INDEX 14
#define LIST_STYLE_IMAGE_SHIFT 24
#define LIST_STYLE_IMAGE_MASK 0x1000000
+static inline uint8_t get_list_style_image_bits(const css_computed_style *style)
+{
+ uint32_t bits = style->i.bits[LIST_STYLE_IMAGE_INDEX];
+ bits &= LIST_STYLE_IMAGE_MASK;
+ bits >>= LIST_STYLE_IMAGE_SHIFT;
+
+ /* 1bit: t : type */
+ return (bits & 0x1);
+}
static inline uint8_t get_list_style_image(const css_computed_style *style,
lwc_string **string)
{
@@ -1258,6 +1820,16 @@ static inline uint8_t get_list_style_image(const css_computed_style *style,
#define LIST_STYLE_POSITION_INDEX 10
#define LIST_STYLE_POSITION_SHIFT 4
#define LIST_STYLE_POSITION_MASK 0x30
+static inline uint8_t get_list_style_position_bits(const css_computed_style
+ *style)
+{
+ uint32_t bits = style->i.bits[LIST_STYLE_POSITION_INDEX];
+ bits &= LIST_STYLE_POSITION_MASK;
+ bits >>= LIST_STYLE_POSITION_SHIFT;
+
+ /* 2bits: tt : type */
+ return (bits & 0x3);
+}
static inline uint8_t get_list_style_position(const css_computed_style *style)
{
uint32_t bits = style->i.bits[LIST_STYLE_POSITION_INDEX];
@@ -1275,6 +1847,15 @@ static inline uint8_t get_list_style_position(const css_computed_style *style)
#define LIST_STYLE_TYPE_INDEX 8
#define LIST_STYLE_TYPE_SHIFT 8
#define LIST_STYLE_TYPE_MASK 0x3f00
+static inline uint8_t get_list_style_type_bits(const css_computed_style *style)
+{
+ uint32_t bits = style->i.bits[LIST_STYLE_TYPE_INDEX];
+ bits &= LIST_STYLE_TYPE_MASK;
+ bits >>= LIST_STYLE_TYPE_SHIFT;
+
+ /* 6bits: tttttt : type */
+ return (bits & 0x3f);
+}
static inline uint8_t get_list_style_type(const css_computed_style *style)
{
uint32_t bits = style->i.bits[LIST_STYLE_TYPE_INDEX];
@@ -1292,6 +1873,15 @@ static inline uint8_t get_list_style_type(const css_computed_style *style)
#define MARGIN_BOTTOM_INDEX 6
#define MARGIN_BOTTOM_SHIFT 11
#define MARGIN_BOTTOM_MASK 0x3f800
+static inline uint8_t get_margin_bottom_bits(const css_computed_style *style)
+{
+ uint32_t bits = style->i.bits[MARGIN_BOTTOM_INDEX];
+ bits &= MARGIN_BOTTOM_MASK;
+ bits >>= MARGIN_BOTTOM_SHIFT;
+
+ /* 7bits: uuuuutt : unit | type */
+ return (bits & 0x3);
+}
static inline uint8_t get_margin_bottom(const css_computed_style *style,
css_fixed *length, css_unit *unit)
{
@@ -1314,6 +1904,15 @@ static inline uint8_t get_margin_bottom(const css_computed_style *style,
#define MARGIN_LEFT_INDEX 6
#define MARGIN_LEFT_SHIFT 18
#define MARGIN_LEFT_MASK 0x1fc0000
+static inline uint8_t get_margin_left_bits(const css_computed_style *style)
+{
+ uint32_t bits = style->i.bits[MARGIN_LEFT_INDEX];
+ bits &= MARGIN_LEFT_MASK;
+ bits >>= MARGIN_LEFT_SHIFT;
+
+ /* 7bits: uuuuutt : unit | type */
+ return (bits & 0x3);
+}
static inline uint8_t get_margin_left(const css_computed_style *style,
css_fixed *length, css_unit *unit)
{
@@ -1336,6 +1935,15 @@ static inline uint8_t get_margin_left(const css_computed_style *style,
#define MARGIN_RIGHT_INDEX 6
#define MARGIN_RIGHT_SHIFT 25
#define MARGIN_RIGHT_MASK 0xfe000000
+static inline uint8_t get_margin_right_bits(const css_computed_style *style)
+{
+ uint32_t bits = style->i.bits[MARGIN_RIGHT_INDEX];
+ bits &= MARGIN_RIGHT_MASK;
+ bits >>= MARGIN_RIGHT_SHIFT;
+
+ /* 7bits: uuuuutt : unit | type */
+ return (bits & 0x3);
+}
static inline uint8_t get_margin_right(const css_computed_style *style,
css_fixed *length, css_unit *unit)
{
@@ -1358,6 +1966,15 @@ static inline uint8_t get_margin_right(const css_computed_style *style,
#define MARGIN_TOP_INDEX 5
#define MARGIN_TOP_SHIFT 4
#define MARGIN_TOP_MASK 0x7f0
+static inline uint8_t get_margin_top_bits(const css_computed_style *style)
+{
+ uint32_t bits = style->i.bits[MARGIN_TOP_INDEX];
+ bits &= MARGIN_TOP_MASK;
+ bits >>= MARGIN_TOP_SHIFT;
+
+ /* 7bits: uuuuutt : unit | type */
+ return (bits & 0x3);
+}
static inline uint8_t get_margin_top(const css_computed_style *style, css_fixed
*length, css_unit *unit)
{
@@ -1380,6 +1997,15 @@ static inline uint8_t get_margin_top(const css_computed_style *style, css_fixed
#define MAX_HEIGHT_INDEX 5
#define MAX_HEIGHT_SHIFT 11
#define MAX_HEIGHT_MASK 0x3f800
+static inline uint8_t get_max_height_bits(const css_computed_style *style)
+{
+ uint32_t bits = style->i.bits[MAX_HEIGHT_INDEX];
+ bits &= MAX_HEIGHT_MASK;
+ bits >>= MAX_HEIGHT_SHIFT;
+
+ /* 7bits: uuuuutt : unit | type */
+ return (bits & 0x3);
+}
static inline uint8_t get_max_height(const css_computed_style *style, css_fixed
*length, css_unit *unit)
{
@@ -1402,6 +2028,15 @@ static inline uint8_t get_max_height(const css_computed_style *style, css_fixed
#define MAX_WIDTH_INDEX 5
#define MAX_WIDTH_SHIFT 18
#define MAX_WIDTH_MASK 0x1fc0000
+static inline uint8_t get_max_width_bits(const css_computed_style *style)
+{
+ uint32_t bits = style->i.bits[MAX_WIDTH_INDEX];
+ bits &= MAX_WIDTH_MASK;
+ bits >>= MAX_WIDTH_SHIFT;
+
+ /* 7bits: uuuuutt : unit | type */
+ return (bits & 0x3);
+}
static inline uint8_t get_max_width(const css_computed_style *style, css_fixed
*length, css_unit *unit)
{
@@ -1424,6 +2059,15 @@ static inline uint8_t get_max_width(const css_computed_style *style, css_fixed
#define MIN_HEIGHT_INDEX 5
#define MIN_HEIGHT_SHIFT 25
#define MIN_HEIGHT_MASK 0xfe000000
+static inline uint8_t get_min_height_bits(const css_computed_style *style)
+{
+ uint32_t bits = style->i.bits[MIN_HEIGHT_INDEX];
+ bits &= MIN_HEIGHT_MASK;
+ bits >>= MIN_HEIGHT_SHIFT;
+
+ /* 7bits: uuuuutt : unit | type */
+ return (bits & 0x3);
+}
static inline uint8_t get_min_height(const css_computed_style *style, css_fixed
*length, css_unit *unit)
{
@@ -1446,6 +2090,15 @@ static inline uint8_t get_min_height(const css_computed_style *style, css_fixed
#define MIN_WIDTH_INDEX 4
#define MIN_WIDTH_SHIFT 4
#define MIN_WIDTH_MASK 0x7f0
+static inline uint8_t get_min_width_bits(const css_computed_style *style)
+{
+ uint32_t bits = style->i.bits[MIN_WIDTH_INDEX];
+ bits &= MIN_WIDTH_MASK;
+ bits >>= MIN_WIDTH_SHIFT;
+
+ /* 7bits: uuuuutt : unit | type */
+ return (bits & 0x3);
+}
static inline uint8_t get_min_width(const css_computed_style *style, css_fixed
*length, css_unit *unit)
{
@@ -1468,6 +2121,15 @@ static inline uint8_t get_min_width(const css_computed_style *style, css_fixed
#define OPACITY_INDEX 14
#define OPACITY_SHIFT 25
#define OPACITY_MASK 0x2000000
+static inline uint8_t get_opacity_bits(const css_computed_style *style)
+{
+ uint32_t bits = style->i.bits[OPACITY_INDEX];
+ bits &= OPACITY_MASK;
+ bits >>= OPACITY_SHIFT;
+
+ /* 1bit: t : type */
+ return (bits & 0x1);
+}
static inline uint8_t get_opacity(const css_computed_style *style, css_fixed
*fixed)
{
@@ -1489,6 +2151,15 @@ static inline uint8_t get_opacity(const css_computed_style *style, css_fixed
#define ORDER_INDEX 14
#define ORDER_SHIFT 26
#define ORDER_MASK 0x4000000
+static inline uint8_t get_order_bits(const css_computed_style *style)
+{
+ uint32_t bits = style->i.bits[ORDER_INDEX];
+ bits &= ORDER_MASK;
+ bits >>= ORDER_SHIFT;
+
+ /* 1bit: t : type */
+ return (bits & 0x1);
+}
static inline uint8_t get_order(const css_computed_style *style, int32_t
*integer)
{
@@ -1510,6 +2181,15 @@ static inline uint8_t get_order(const css_computed_style *style, int32_t
#define ORPHANS_INDEX 14
#define ORPHANS_SHIFT 27
#define ORPHANS_MASK 0x8000000
+static inline uint8_t get_orphans_bits(const css_computed_style *style)
+{
+ uint32_t bits = style->i.bits[ORPHANS_INDEX];
+ bits &= ORPHANS_MASK;
+ bits >>= ORPHANS_SHIFT;
+
+ /* 1bit: t : type */
+ return (bits & 0x1);
+}
static inline uint8_t get_orphans(const css_computed_style *style, int32_t
*integer)
{
@@ -1529,6 +2209,15 @@ static inline uint8_t get_orphans(const css_computed_style *style, int32_t
#define OUTLINE_COLOR_INDEX 10
#define OUTLINE_COLOR_SHIFT 6
#define OUTLINE_COLOR_MASK 0xc0
+static inline uint8_t get_outline_color_bits(const css_computed_style *style)
+{
+ uint32_t bits = style->i.bits[OUTLINE_COLOR_INDEX];
+ bits &= OUTLINE_COLOR_MASK;
+ bits >>= OUTLINE_COLOR_SHIFT;
+
+ /* 2bits: tt : type */
+ return (bits & 0x3);
+}
static inline uint8_t get_outline_color(const css_computed_style *style,
css_color *color)
{
@@ -1550,6 +2239,15 @@ static inline uint8_t get_outline_color(const css_computed_style *style,
#define OUTLINE_STYLE_INDEX 5
#define OUTLINE_STYLE_SHIFT 0
#define OUTLINE_STYLE_MASK 0xf
+static inline uint8_t get_outline_style_bits(const css_computed_style *style)
+{
+ uint32_t bits = style->i.bits[OUTLINE_STYLE_INDEX];
+ bits &= OUTLINE_STYLE_MASK;
+ bits >>= OUTLINE_STYLE_SHIFT;
+
+ /* 4bits: tttt : type */
+ return (bits & 0xf);
+}
static inline uint8_t get_outline_style(const css_computed_style *style)
{
uint32_t bits = style->i.bits[OUTLINE_STYLE_INDEX];
@@ -1567,6 +2265,15 @@ static inline uint8_t get_outline_style(const css_computed_style *style)
#define OUTLINE_WIDTH_INDEX 1
#define OUTLINE_WIDTH_SHIFT 15
#define OUTLINE_WIDTH_MASK 0x7f8000
+static inline uint8_t get_outline_width_bits(const css_computed_style *style)
+{
+ uint32_t bits = style->i.bits[OUTLINE_WIDTH_INDEX];
+ bits &= OUTLINE_WIDTH_MASK;
+ bits >>= OUTLINE_WIDTH_SHIFT;
+
+ /* 8bits: uuuuuttt : unit | type */
+ return (bits & 0x7);
+}
static inline uint8_t get_outline_width(const css_computed_style *style,
css_fixed *length, css_unit *unit)
{
@@ -1589,6 +2296,15 @@ static inline uint8_t get_outline_width(const css_computed_style *style,
#define OVERFLOW_X_INDEX 13
#define OVERFLOW_X_SHIFT 13
#define OVERFLOW_X_MASK 0xe000
+static inline uint8_t get_overflow_x_bits(const css_computed_style *style)
+{
+ uint32_t bits = style->i.bits[OVERFLOW_X_INDEX];
+ bits &= OVERFLOW_X_MASK;
+ bits >>= OVERFLOW_X_SHIFT;
+
+ /* 3bits: ttt : type */
+ return (bits & 0x7);
+}
static inline uint8_t get_overflow_x(const css_computed_style *style)
{
uint32_t bits = style->i.bits[OVERFLOW_X_INDEX];
@@ -1606,6 +2322,15 @@ static inline uint8_t get_overflow_x(const css_computed_style *style)
#define OVERFLOW_Y_INDEX 13
#define OVERFLOW_Y_SHIFT 16
#define OVERFLOW_Y_MASK 0x70000
+static inline uint8_t get_overflow_y_bits(const css_computed_style *style)
+{
+ uint32_t bits = style->i.bits[OVERFLOW_Y_INDEX];
+ bits &= OVERFLOW_Y_MASK;
+ bits >>= OVERFLOW_Y_SHIFT;
+
+ /* 3bits: ttt : type */
+ return (bits & 0x7);
+}
static inline uint8_t get_overflow_y(const css_computed_style *style)
{
uint32_t bits = style->i.bits[OVERFLOW_Y_INDEX];
@@ -1623,6 +2348,15 @@ static inline uint8_t get_overflow_y(const css_computed_style *style)
#define PADDING_BOTTOM_INDEX 8
#define PADDING_BOTTOM_SHIFT 14
#define PADDING_BOTTOM_MASK 0xfc000
+static inline uint8_t get_padding_bottom_bits(const css_computed_style *style)
+{
+ uint32_t bits = style->i.bits[PADDING_BOTTOM_INDEX];
+ bits &= PADDING_BOTTOM_MASK;
+ bits >>= PADDING_BOTTOM_SHIFT;
+
+ /* 6bits: uuuuut : unit | type */
+ return (bits & 0x1);
+}
static inline uint8_t get_padding_bottom(const css_computed_style *style,
css_fixed *length, css_unit *unit)
{
@@ -1645,6 +2379,15 @@ static inline uint8_t get_padding_bottom(const css_computed_style *style,
#define PADDING_LEFT_INDEX 8
#define PADDING_LEFT_SHIFT 20
#define PADDING_LEFT_MASK 0x3f00000
+static inline uint8_t get_padding_left_bits(const css_computed_style *style)
+{
+ uint32_t bits = style->i.bits[PADDING_LEFT_INDEX];
+ bits &= PADDING_LEFT_MASK;
+ bits >>= PADDING_LEFT_SHIFT;
+
+ /* 6bits: uuuuut : unit | type */
+ return (bits & 0x1);
+}
static inline uint8_t get_padding_left(const css_computed_style *style,
css_fixed *length, css_unit *unit)
{
@@ -1667,6 +2410,15 @@ static inline uint8_t get_padding_left(const css_computed_style *style,
#define PADDING_RIGHT_INDEX 8
#define PADDING_RIGHT_SHIFT 26
#define PADDING_RIGHT_MASK 0xfc000000
+static inline uint8_t get_padding_right_bits(const css_computed_style *style)
+{
+ uint32_t bits = style->i.bits[PADDING_RIGHT_INDEX];
+ bits &= PADDING_RIGHT_MASK;
+ bits >>= PADDING_RIGHT_SHIFT;
+
+ /* 6bits: uuuuut : unit | type */
+ return (bits & 0x1);
+}
static inline uint8_t get_padding_right(const css_computed_style *style,
css_fixed *length, css_unit *unit)
{
@@ -1689,6 +2441,15 @@ static inline uint8_t get_padding_right(const css_computed_style *style,
#define PADDING_TOP_INDEX 3
#define PADDING_TOP_SHIFT 5
#define PADDING_TOP_MASK 0x7e0
+static inline uint8_t get_padding_top_bits(const css_computed_style *style)
+{
+ uint32_t bits = style->i.bits[PADDING_TOP_INDEX];
+ bits &= PADDING_TOP_MASK;
+ bits >>= PADDING_TOP_SHIFT;
+
+ /* 6bits: uuuuut : unit | type */
+ return (bits & 0x1);
+}
static inline uint8_t get_padding_top(const css_computed_style *style,
css_fixed *length, css_unit *unit)
{
@@ -1711,6 +2472,15 @@ static inline uint8_t get_padding_top(const css_computed_style *style,
#define PAGE_BREAK_AFTER_INDEX 13
#define PAGE_BREAK_AFTER_SHIFT 19
#define PAGE_BREAK_AFTER_MASK 0x380000
+static inline uint8_t get_page_break_after_bits(const css_computed_style *style)
+{
+ uint32_t bits = style->i.bits[PAGE_BREAK_AFTER_INDEX];
+ bits &= PAGE_BREAK_AFTER_MASK;
+ bits >>= PAGE_BREAK_AFTER_SHIFT;
+
+ /* 3bits: ttt : type */
+ return (bits & 0x7);
+}
static inline uint8_t get_page_break_after(const css_computed_style *style)
{
uint32_t bits = style->i.bits[PAGE_BREAK_AFTER_INDEX];
@@ -1728,6 +2498,16 @@ static inline uint8_t get_page_break_after(const css_computed_style *style)
#define PAGE_BREAK_BEFORE_INDEX 13
#define PAGE_BREAK_BEFORE_SHIFT 22
#define PAGE_BREAK_BEFORE_MASK 0x1c00000
+static inline uint8_t get_page_break_before_bits(const css_computed_style
+ *style)
+{
+ uint32_t bits = style->i.bits[PAGE_BREAK_BEFORE_INDEX];
+ bits &= PAGE_BREAK_BEFORE_MASK;
+ bits >>= PAGE_BREAK_BEFORE_SHIFT;
+
+ /* 3bits: ttt : type */
+ return (bits & 0x7);
+}
static inline uint8_t get_page_break_before(const css_computed_style *style)
{
uint32_t bits = style->i.bits[PAGE_BREAK_BEFORE_INDEX];
@@ -1745,6 +2525,16 @@ static inline uint8_t get_page_break_before(const css_computed_style *style)
#define PAGE_BREAK_INSIDE_INDEX 10
#define PAGE_BREAK_INSIDE_SHIFT 8
#define PAGE_BREAK_INSIDE_MASK 0x300
+static inline uint8_t get_page_break_inside_bits(const css_computed_style
+ *style)
+{
+ uint32_t bits = style->i.bits[PAGE_BREAK_INSIDE_INDEX];
+ bits &= PAGE_BREAK_INSIDE_MASK;
+ bits >>= PAGE_BREAK_INSIDE_SHIFT;
+
+ /* 2bits: tt : type */
+ return (bits & 0x3);
+}
static inline uint8_t get_page_break_inside(const css_computed_style *style)
{
uint32_t bits = style->i.bits[PAGE_BREAK_INSIDE_INDEX];
@@ -1762,6 +2552,15 @@ static inline uint8_t get_page_break_inside(const css_computed_style *style)
#define POSITION_INDEX 13
#define POSITION_SHIFT 25
#define POSITION_MASK 0xe000000
+static inline uint8_t get_position_bits(const css_computed_style *style)
+{
+ uint32_t bits = style->i.bits[POSITION_INDEX];
+ bits &= POSITION_MASK;
+ bits >>= POSITION_SHIFT;
+
+ /* 3bits: ttt : type */
+ return (bits & 0x7);
+}
static inline uint8_t get_position(const css_computed_style *style)
{
uint32_t bits = style->i.bits[POSITION_INDEX];
@@ -1779,6 +2578,15 @@ static inline uint8_t get_position(const css_computed_style *style)
#define QUOTES_INDEX 13
#define QUOTES_SHIFT 0
#define QUOTES_MASK 0x1
+static inline uint8_t get_quotes_bits(const css_computed_style *style)
+{
+ uint32_t bits = style->i.bits[QUOTES_INDEX];
+ bits &= QUOTES_MASK;
+ bits >>= QUOTES_SHIFT;
+
+ /* 1bit: t : type */
+ return (bits & 0x1);
+}
static inline uint8_t get_quotes(const css_computed_style *style, lwc_string
***string_arr)
{
@@ -1798,31 +2606,29 @@ static inline uint8_t get_quotes(const css_computed_style *style, lwc_string
#define RIGHT_INDEX 4
#define RIGHT_SHIFT 11
#define RIGHT_MASK 0x3f800
-static inline uint8_t get_right(
- const css_computed_style *style,
- css_fixed *length, css_unit *unit)
+static inline uint8_t get_right_bits(const css_computed_style *style)
{
uint32_t bits = style->i.bits[RIGHT_INDEX];
bits &= RIGHT_MASK;
bits >>= RIGHT_SHIFT;
-
- /* 7bits: uuuuutt : units | type */
- if ((bits & 0x3) == CSS_RIGHT_SET) {
- *length = style->i.right;
- *unit = bits >> 2;
- }
-
+
+ /* 7bits: uuuuutt : unit | type */
return (bits & 0x3);
}
-static inline uint8_t get_right_bits(
- const css_computed_style *style)
+static inline uint8_t get_right(const css_computed_style *style, css_fixed
+ *length, css_unit *unit)
{
uint32_t bits = style->i.bits[RIGHT_INDEX];
bits &= RIGHT_MASK;
bits >>= RIGHT_SHIFT;
-
- /* 7bits: uuuuutt : units | type */
- return bits;
+
+ /* 7bits: uuuuutt : unit | type */
+ if ((bits & 0x3) == CSS_RIGHT_SET) {
+ *length = style->i.right;
+ *unit = bits >> 2;
+ }
+
+ return (bits & 0x3);
}
#undef RIGHT_INDEX
#undef RIGHT_SHIFT
@@ -1831,6 +2637,15 @@ static inline uint8_t get_right_bits(
#define TABLE_LAYOUT_INDEX 10
#define TABLE_LAYOUT_SHIFT 10
#define TABLE_LAYOUT_MASK 0xc00
+static inline uint8_t get_table_layout_bits(const css_computed_style *style)
+{
+ uint32_t bits = style->i.bits[TABLE_LAYOUT_INDEX];
+ bits &= TABLE_LAYOUT_MASK;
+ bits >>= TABLE_LAYOUT_SHIFT;
+
+ /* 2bits: tt : type */
+ return (bits & 0x3);
+}
static inline uint8_t get_table_layout(const css_computed_style *style)
{
uint32_t bits = style->i.bits[TABLE_LAYOUT_INDEX];
@@ -1848,6 +2663,15 @@ static inline uint8_t get_table_layout(const css_computed_style *style)
#define TEXT_ALIGN_INDEX 4
#define TEXT_ALIGN_SHIFT 0
#define TEXT_ALIGN_MASK 0xf
+static inline uint8_t get_text_align_bits(const css_computed_style *style)
+{
+ uint32_t bits = style->i.bits[TEXT_ALIGN_INDEX];
+ bits &= TEXT_ALIGN_MASK;
+ bits >>= TEXT_ALIGN_SHIFT;
+
+ /* 4bits: tttt : type */
+ return (bits & 0xf);
+}
static inline uint8_t get_text_align(const css_computed_style *style)
{
uint32_t bits = style->i.bits[TEXT_ALIGN_INDEX];
@@ -1865,6 +2689,15 @@ static inline uint8_t get_text_align(const css_computed_style *style)
#define TEXT_DECORATION_INDEX 3
#define TEXT_DECORATION_SHIFT 0
#define TEXT_DECORATION_MASK 0x1f
+static inline uint8_t get_text_decoration_bits(const css_computed_style *style)
+{
+ uint32_t bits = style->i.bits[TEXT_DECORATION_INDEX];
+ bits &= TEXT_DECORATION_MASK;
+ bits >>= TEXT_DECORATION_SHIFT;
+
+ /* 5bits: ttttt : type */
+ return (bits & 0x1f);
+}
static inline uint8_t get_text_decoration(const css_computed_style *style)
{
uint32_t bits = style->i.bits[TEXT_DECORATION_INDEX];
@@ -1882,6 +2715,15 @@ static inline uint8_t get_text_decoration(const css_computed_style *style)
#define TEXT_INDENT_INDEX 2
#define TEXT_INDENT_SHIFT 0
#define TEXT_INDENT_MASK 0x3f
+static inline uint8_t get_text_indent_bits(const css_computed_style *style)
+{
+ uint32_t bits = style->i.bits[TEXT_INDENT_INDEX];
+ bits &= TEXT_INDENT_MASK;
+ bits >>= TEXT_INDENT_SHIFT;
+
+ /* 6bits: uuuuut : unit | type */
+ return (bits & 0x1);
+}
static inline uint8_t get_text_indent(const css_computed_style *style,
css_fixed *length, css_unit *unit)
{
@@ -1904,6 +2746,15 @@ static inline uint8_t get_text_indent(const css_computed_style *style,
#define TEXT_TRANSFORM_INDEX 9
#define TEXT_TRANSFORM_SHIFT 0
#define TEXT_TRANSFORM_MASK 0x7
+static inline uint8_t get_text_transform_bits(const css_computed_style *style)
+{
+ uint32_t bits = style->i.bits[TEXT_TRANSFORM_INDEX];
+ bits &= TEXT_TRANSFORM_MASK;
+ bits >>= TEXT_TRANSFORM_SHIFT;
+
+ /* 3bits: ttt : type */
+ return (bits & 0x7);
+}
static inline uint8_t get_text_transform(const css_computed_style *style)
{
uint32_t bits = style->i.bits[TEXT_TRANSFORM_INDEX];
@@ -1921,31 +2772,29 @@ static inline uint8_t get_text_transform(const css_computed_style *style)
#define TOP_INDEX 4
#define TOP_SHIFT 18
#define TOP_MASK 0x1fc0000
-static inline uint8_t get_top(
- const css_computed_style *style,
- css_fixed *length, css_unit *unit)
+static inline uint8_t get_top_bits(const css_computed_style *style)
{
uint32_t bits = style->i.bits[TOP_INDEX];
bits &= TOP_MASK;
bits >>= TOP_SHIFT;
-
- /* 7bits: uuuuutt : units | type */
- if ((bits & 0x3) == CSS_TOP_SET) {
- *length = style->i.top;
- *unit = bits >> 2;
- }
-
+
+ /* 7bits: uuuuutt : unit | type */
return (bits & 0x3);
}
-static inline uint8_t get_top_bits(
- const css_computed_style *style)
+static inline uint8_t get_top(const css_computed_style *style, css_fixed
+ *length, css_unit *unit)
{
uint32_t bits = style->i.bits[TOP_INDEX];
bits &= TOP_MASK;
bits >>= TOP_SHIFT;
-
- /* 7bits: uuuuutt : units | type */
- return bits;
+
+ /* 7bits: uuuuutt : unit | type */
+ if ((bits & 0x3) == CSS_TOP_SET) {
+ *length = style->i.top;
+ *unit = bits >> 2;
+ }
+
+ return (bits & 0x3);
}
#undef TOP_INDEX
#undef TOP_SHIFT
@@ -1954,6 +2803,15 @@ static inline uint8_t get_top_bits(
#define UNICODE_BIDI_INDEX 10
#define UNICODE_BIDI_SHIFT 12
#define UNICODE_BIDI_MASK 0x3000
+static inline uint8_t get_unicode_bidi_bits(const css_computed_style *style)
+{
+ uint32_t bits = style->i.bits[UNICODE_BIDI_INDEX];
+ bits &= UNICODE_BIDI_MASK;
+ bits >>= UNICODE_BIDI_SHIFT;
+
+ /* 2bits: tt : type */
+ return (bits & 0x3);
+}
static inline uint8_t get_unicode_bidi(const css_computed_style *style)
{
uint32_t bits = style->i.bits[UNICODE_BIDI_INDEX];
@@ -1971,6 +2829,15 @@ static inline uint8_t get_unicode_bidi(const css_computed_style *style)
#define VERTICAL_ALIGN_INDEX 12
#define VERTICAL_ALIGN_SHIFT 1
#define VERTICAL_ALIGN_MASK 0x3fe
+static inline uint8_t get_vertical_align_bits(const css_computed_style *style)
+{
+ uint32_t bits = style->i.bits[VERTICAL_ALIGN_INDEX];
+ bits &= VERTICAL_ALIGN_MASK;
+ bits >>= VERTICAL_ALIGN_SHIFT;
+
+ /* 9bits: uuuuutttt : unit | type */
+ return (bits & 0xf);
+}
static inline uint8_t get_vertical_align(const css_computed_style *style,
css_fixed *length, css_unit *unit)
{
@@ -1993,6 +2860,15 @@ static inline uint8_t get_vertical_align(const css_computed_style *style,
#define VISIBILITY_INDEX 10
#define VISIBILITY_SHIFT 14
#define VISIBILITY_MASK 0xc000
+static inline uint8_t get_visibility_bits(const css_computed_style *style)
+{
+ uint32_t bits = style->i.bits[VISIBILITY_INDEX];
+ bits &= VISIBILITY_MASK;
+ bits >>= VISIBILITY_SHIFT;
+
+ /* 2bits: tt : type */
+ return (bits & 0x3);
+}
static inline uint8_t get_visibility(const css_computed_style *style)
{
uint32_t bits = style->i.bits[VISIBILITY_INDEX];
@@ -2010,6 +2886,15 @@ static inline uint8_t get_visibility(const css_computed_style *style)
#define WHITE_SPACE_INDEX 8
#define WHITE_SPACE_SHIFT 0
#define WHITE_SPACE_MASK 0x7
+static inline uint8_t get_white_space_bits(const css_computed_style *style)
+{
+ uint32_t bits = style->i.bits[WHITE_SPACE_INDEX];
+ bits &= WHITE_SPACE_MASK;
+ bits >>= WHITE_SPACE_SHIFT;
+
+ /* 3bits: ttt : type */
+ return (bits & 0x7);
+}
static inline uint8_t get_white_space(const css_computed_style *style)
{
uint32_t bits = style->i.bits[WHITE_SPACE_INDEX];
@@ -2027,6 +2912,15 @@ static inline uint8_t get_white_space(const css_computed_style *style)
#define WIDOWS_INDEX 12
#define WIDOWS_SHIFT 0
#define WIDOWS_MASK 0x1
+static inline uint8_t get_widows_bits(const css_computed_style *style)
+{
+ uint32_t bits = style->i.bits[WIDOWS_INDEX];
+ bits &= WIDOWS_MASK;
+ bits >>= WIDOWS_SHIFT;
+
+ /* 1bit: t : type */
+ return (bits & 0x1);
+}
static inline uint8_t get_widows(const css_computed_style *style, int32_t
*integer)
{
@@ -2046,6 +2940,15 @@ static inline uint8_t get_widows(const css_computed_style *style, int32_t
#define WIDTH_INDEX 4
#define WIDTH_SHIFT 25
#define WIDTH_MASK 0xfe000000
+static inline uint8_t get_width_bits(const css_computed_style *style)
+{
+ uint32_t bits = style->i.bits[WIDTH_INDEX];
+ bits &= WIDTH_MASK;
+ bits >>= WIDTH_SHIFT;
+
+ /* 7bits: uuuuutt : unit | type */
+ return (bits & 0x3);
+}
static inline uint8_t get_width(const css_computed_style *style, css_fixed
*length, css_unit *unit)
{
@@ -2068,6 +2971,15 @@ static inline uint8_t get_width(const css_computed_style *style, css_fixed
#define WORD_SPACING_INDEX 1
#define WORD_SPACING_SHIFT 0
#define WORD_SPACING_MASK 0x7f
+static inline uint8_t get_word_spacing_bits(const css_computed_style *style)
+{
+ uint32_t bits = style->i.bits[WORD_SPACING_INDEX];
+ bits &= WORD_SPACING_MASK;
+ bits >>= WORD_SPACING_SHIFT;
+
+ /* 7bits: uuuuutt : unit | type */
+ return (bits & 0x3);
+}
static inline uint8_t get_word_spacing(const css_computed_style *style,
css_fixed *length, css_unit *unit)
{
@@ -2090,6 +3002,15 @@ static inline uint8_t get_word_spacing(const css_computed_style *style,
#define WRITING_MODE_INDEX 10
#define WRITING_MODE_SHIFT 16
#define WRITING_MODE_MASK 0x30000
+static inline uint8_t get_writing_mode_bits(const css_computed_style *style)
+{
+ uint32_t bits = style->i.bits[WRITING_MODE_INDEX];
+ bits &= WRITING_MODE_MASK;
+ bits >>= WRITING_MODE_SHIFT;
+
+ /* 2bits: tt : type */
+ return (bits & 0x3);
+}
static inline uint8_t get_writing_mode(const css_computed_style *style)
{
uint32_t bits = style->i.bits[WRITING_MODE_INDEX];
@@ -2107,6 +3028,15 @@ static inline uint8_t get_writing_mode(const css_computed_style *style)
#define Z_INDEX_INDEX 10
#define Z_INDEX_SHIFT 18
#define Z_INDEX_MASK 0xc0000
+static inline uint8_t get_z_index_bits(const css_computed_style *style)
+{
+ uint32_t bits = style->i.bits[Z_INDEX_INDEX];
+ bits &= Z_INDEX_MASK;
+ bits >>= Z_INDEX_SHIFT;
+
+ /* 2bits: tt : type */
+ return (bits & 0x3);
+}
static inline uint8_t get_z_index(const css_computed_style *style, int32_t
*integer)
{
diff --git a/src/select/overrides.py b/src/select/overrides.py
index b4d349a..869d6ec 100644
--- a/src/select/overrides.py
+++ b/src/select/overrides.py
@@ -183,35 +183,3 @@ static inline css_error set_content(
return CSS_OK;
}'''
-
-get_side = '''\
-static inline uint8_t get_{0}(
- const css_computed_style *style,
- css_fixed *length, css_unit *unit)
-{{
- uint32_t bits = style->i.bits[{1}_INDEX];
- bits &= {1}_MASK;
- bits >>= {1}_SHIFT;
-
- /* 7bits: uuuuutt : units | type */
- if ((bits & 0x3) == CSS_{1}_SET) {{
- *length = style->i.{0};
- *unit = bits >> 2;
- }}
-
- return (bits & 0x3);
-}}
-static inline uint8_t get_{0}_bits(
- const css_computed_style *style)
-{{
- uint32_t bits = style->i.bits[{1}_INDEX];
- bits &= {1}_MASK;
- bits >>= {1}_SHIFT;
-
- /* 7bits: uuuuutt : units | type */
- return bits;
-}}'''
-overrides['get']['top'] = get_side.format('top', 'TOP')
-overrides['get']['right'] = get_side.format('right', 'RIGHT')
-overrides['get']['bottom'] = get_side.format('bottom', 'BOTTOM')
-overrides['get']['left'] = get_side.format('left', 'LEFT')
diff --git a/src/select/select_generator.py b/src/select/select_generator.py
index ece7a91..05a4511 100644
--- a/src/select/select_generator.py
+++ b/src/select/select_generator.py
@@ -707,42 +707,32 @@ class CSSGroup:
return t.to_string()
- def make_propget_h(self):
- """Output this group's property functions for the propget.h file."""
- t = Text()
+ def print_propget(self, t, p, only_bits=False):
i_dot, grp = self.get_idot_grp()
- for p in sorted(self.props, key=(lambda x: x.name)):
- defines, undefs = p.def_undefs
-
- t.append()
- t.append(defines)
-
- if p.name in overrides['get']:
- t.append(overrides['get'][p.name], pre_formatted=True)
- t.append(undefs)
- continue
+ 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)
- vals = p.get_param_values(pointer=True)
- params = ', '.join([ 'css_computed_style *style' ]
- + [ ' '.join(x) for x in vals ])
- t.append('static inline uint8_t get_{}(const {})'.format(
- p.name, params))
- t.append('{')
+ if self.name != 'style':
+ t.append('if (style{} != NULL) {{'.format(grp))
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('bits &= {}_MASK;'.format(p.name.upper()))
+ t.append('bits >>= {}_SHIFT;'.format(p.name.upper()))
+ t.append()
- t.append('uint32_t bits = style{}->{}bits[{}_INDEX];'.format(
- grp, i_dot, p.name.upper()))
- t.append('bits &= {}_MASK;'.format(p.name.upper()))
- t.append('bits >>= {}_SHIFT;'.format(p.name.upper()))
- t.append()
+ type_mask, shift_list, bits_comment = p.get_bits()
+ t.append(bits_comment)
- type_mask, shift_list, bits_comment = p.get_bits()
- t.append(bits_comment)
+ if only_bits == False:
if p.condition:
t.append('if ((bits & {}) == {}) {{'.format(
@@ -763,24 +753,42 @@ class CSSGroup:
if p.condition:
t.indent(-1)
t.append('}')
-
t.append()
- 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.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('}')
+
+ def make_propget_h(self):
+ """Output this group's property functions for the propget.h file."""
+ t = Text()
+
+ for p in sorted(self.props, key=(lambda x: x.name)):
+ defines, undefs = p.def_undefs
+
+ t.append()
+ t.append(defines)
+
+ self.print_propget(t, p, True)
+
+ if p.name in overrides['get']:
+ t.append(overrides['get'][p.name], pre_formatted=True)
+ else:
+ self.print_propget(t, p)
+
t.append(undefs)
return t.to_string()
--
Cascading Style Sheets library
6 months, 1 week
libcss: branch master updated. release/0.9.1-81-g022a04d
by NetSurf Browser Project
Gitweb links:
...log http://git.netsurf-browser.org/libcss.git/shortlog/022a04d022f446b57818df...
...commit http://git.netsurf-browser.org/libcss.git/commit/022a04d022f446b57818dfa7...
...tree http://git.netsurf-browser.org/libcss.git/tree/022a04d022f446b57818dfa7d5...
The branch, master has been updated
via 022a04d022f446b57818dfa7d5b49928f9d63bf4 (commit)
via 609e1623335d5d5147439c5ba600152e963fc951 (commit)
from 64f864c7e3ce9dcbd5964c5084075f07af169b0d (commit)
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=022a04d022f446b57818...
commit 022a04d022f446b57818dfa7d5b49928f9d63bf4
Author: Michael Drake <tlsa(a)netsurf-browser.org>
Commit: Michael Drake <mdrake.unique(a)gmail.com>
select: generator: Generate _bits variants
This avoids having overrides to provide trivially
generated variants.
diff --git a/src/select/autogenerated_propget.h b/src/select/autogenerated_propget.h
index cf82c86..6c958aa 100644
--- a/src/select/autogenerated_propget.h
+++ b/src/select/autogenerated_propget.h
@@ -9,6 +9,15 @@
#define ALIGN_CONTENT_INDEX 10
#define ALIGN_CONTENT_SHIFT 20
#define ALIGN_CONTENT_MASK 0x700000
+static inline uint8_t get_align_content_bits(const css_computed_style *style)
+{
+ uint32_t bits = style->i.bits[ALIGN_CONTENT_INDEX];
+ bits &= ALIGN_CONTENT_MASK;
+ bits >>= ALIGN_CONTENT_SHIFT;
+
+ /* 3bits: ttt : type */
+ return (bits & 0x7);
+}
static inline uint8_t get_align_content(const css_computed_style *style)
{
uint32_t bits = style->i.bits[ALIGN_CONTENT_INDEX];
@@ -26,6 +35,15 @@ static inline uint8_t get_align_content(const css_computed_style *style)
#define ALIGN_ITEMS_INDEX 10
#define ALIGN_ITEMS_SHIFT 23
#define ALIGN_ITEMS_MASK 0x3800000
+static inline uint8_t get_align_items_bits(const css_computed_style *style)
+{
+ uint32_t bits = style->i.bits[ALIGN_ITEMS_INDEX];
+ bits &= ALIGN_ITEMS_MASK;
+ bits >>= ALIGN_ITEMS_SHIFT;
+
+ /* 3bits: ttt : type */
+ return (bits & 0x7);
+}
static inline uint8_t get_align_items(const css_computed_style *style)
{
uint32_t bits = style->i.bits[ALIGN_ITEMS_INDEX];
@@ -43,6 +61,15 @@ static inline uint8_t get_align_items(const css_computed_style *style)
#define ALIGN_SELF_INDEX 10
#define ALIGN_SELF_SHIFT 26
#define ALIGN_SELF_MASK 0x1c000000
+static inline uint8_t get_align_self_bits(const css_computed_style *style)
+{
+ uint32_t bits = style->i.bits[ALIGN_SELF_INDEX];
+ bits &= ALIGN_SELF_MASK;
+ bits >>= ALIGN_SELF_SHIFT;
+
+ /* 3bits: ttt : type */
+ return (bits & 0x7);
+}
static inline uint8_t get_align_self(const css_computed_style *style)
{
uint32_t bits = style->i.bits[ALIGN_SELF_INDEX];
@@ -60,6 +87,16 @@ static inline uint8_t get_align_self(const css_computed_style *style)
#define BACKGROUND_ATTACHMENT_INDEX 14
#define BACKGROUND_ATTACHMENT_SHIFT 28
#define BACKGROUND_ATTACHMENT_MASK 0x30000000
+static inline uint8_t get_background_attachment_bits(const css_computed_style
+ *style)
+{
+ uint32_t bits = style->i.bits[BACKGROUND_ATTACHMENT_INDEX];
+ bits &= BACKGROUND_ATTACHMENT_MASK;
+ bits >>= BACKGROUND_ATTACHMENT_SHIFT;
+
+ /* 2bits: tt : type */
+ return (bits & 0x3);
+}
static inline uint8_t get_background_attachment(const css_computed_style *style)
{
uint32_t bits = style->i.bits[BACKGROUND_ATTACHMENT_INDEX];
@@ -77,6 +114,15 @@ static inline uint8_t get_background_attachment(const css_computed_style *style)
#define BACKGROUND_COLOR_INDEX 14
#define BACKGROUND_COLOR_SHIFT 30
#define BACKGROUND_COLOR_MASK 0xc0000000
+static inline uint8_t get_background_color_bits(const css_computed_style *style)
+{
+ uint32_t bits = style->i.bits[BACKGROUND_COLOR_INDEX];
+ bits &= BACKGROUND_COLOR_MASK;
+ bits >>= BACKGROUND_COLOR_SHIFT;
+
+ /* 2bits: tt : type */
+ return (bits & 0x3);
+}
static inline uint8_t get_background_color(const css_computed_style *style,
css_color *color)
{
@@ -96,6 +142,15 @@ static inline uint8_t get_background_color(const css_computed_style *style,
#define BACKGROUND_IMAGE_INDEX 14
#define BACKGROUND_IMAGE_SHIFT 18
#define BACKGROUND_IMAGE_MASK 0x40000
+static inline uint8_t get_background_image_bits(const css_computed_style *style)
+{
+ uint32_t bits = style->i.bits[BACKGROUND_IMAGE_INDEX];
+ bits &= BACKGROUND_IMAGE_MASK;
+ bits >>= BACKGROUND_IMAGE_SHIFT;
+
+ /* 1bit: t : type */
+ return (bits & 0x1);
+}
static inline uint8_t get_background_image(const css_computed_style *style,
lwc_string **string)
{
@@ -115,6 +170,16 @@ static inline uint8_t get_background_image(const css_computed_style *style,
#define BACKGROUND_POSITION_INDEX 12
#define BACKGROUND_POSITION_SHIFT 10
#define BACKGROUND_POSITION_MASK 0x1ffc00
+static inline uint8_t get_background_position_bits(const css_computed_style
+ *style)
+{
+ uint32_t bits = style->i.bits[BACKGROUND_POSITION_INDEX];
+ bits &= BACKGROUND_POSITION_MASK;
+ bits >>= BACKGROUND_POSITION_SHIFT;
+
+ /* 11bits: aaaaabbbbbt : unit_a | unit_b | type */
+ return (bits & 0x1);
+}
static inline uint8_t get_background_position(const css_computed_style *style,
css_fixed *length_a, css_unit *unit_a, css_fixed *length_b,
css_unit *unit_b)
@@ -140,6 +205,16 @@ static inline uint8_t get_background_position(const css_computed_style *style,
#define BACKGROUND_REPEAT_INDEX 10
#define BACKGROUND_REPEAT_SHIFT 29
#define BACKGROUND_REPEAT_MASK 0xe0000000
+static inline uint8_t get_background_repeat_bits(const css_computed_style
+ *style)
+{
+ uint32_t bits = style->i.bits[BACKGROUND_REPEAT_INDEX];
+ bits &= BACKGROUND_REPEAT_MASK;
+ bits >>= BACKGROUND_REPEAT_SHIFT;
+
+ /* 3bits: ttt : type */
+ return (bits & 0x7);
+}
static inline uint8_t get_background_repeat(const css_computed_style *style)
{
uint32_t bits = style->i.bits[BACKGROUND_REPEAT_INDEX];
@@ -157,6 +232,16 @@ static inline uint8_t get_background_repeat(const css_computed_style *style)
#define BORDER_BOTTOM_COLOR_INDEX 11
#define BORDER_BOTTOM_COLOR_SHIFT 0
#define BORDER_BOTTOM_COLOR_MASK 0x3
+static inline uint8_t get_border_bottom_color_bits(const css_computed_style
+ *style)
+{
+ uint32_t bits = style->i.bits[BORDER_BOTTOM_COLOR_INDEX];
+ bits &= BORDER_BOTTOM_COLOR_MASK;
+ bits >>= BORDER_BOTTOM_COLOR_SHIFT;
+
+ /* 2bits: tt : type */
+ return (bits & 0x3);
+}
static inline uint8_t get_border_bottom_color(const css_computed_style *style,
css_color *color)
{
@@ -176,6 +261,16 @@ static inline uint8_t get_border_bottom_color(const css_computed_style *style,
#define BORDER_BOTTOM_STYLE_INDEX 13
#define BORDER_BOTTOM_STYLE_SHIFT 28
#define BORDER_BOTTOM_STYLE_MASK 0xf0000000
+static inline uint8_t get_border_bottom_style_bits(const css_computed_style
+ *style)
+{
+ uint32_t bits = style->i.bits[BORDER_BOTTOM_STYLE_INDEX];
+ bits &= BORDER_BOTTOM_STYLE_MASK;
+ bits >>= BORDER_BOTTOM_STYLE_SHIFT;
+
+ /* 4bits: tttt : type */
+ return (bits & 0xf);
+}
static inline uint8_t get_border_bottom_style(const css_computed_style *style)
{
uint32_t bits = style->i.bits[BORDER_BOTTOM_STYLE_INDEX];
@@ -193,6 +288,16 @@ static inline uint8_t get_border_bottom_style(const css_computed_style *style)
#define BORDER_BOTTOM_WIDTH_INDEX 0
#define BORDER_BOTTOM_WIDTH_SHIFT 0
#define BORDER_BOTTOM_WIDTH_MASK 0xff
+static inline uint8_t get_border_bottom_width_bits(const css_computed_style
+ *style)
+{
+ uint32_t bits = style->i.bits[BORDER_BOTTOM_WIDTH_INDEX];
+ bits &= BORDER_BOTTOM_WIDTH_MASK;
+ bits >>= BORDER_BOTTOM_WIDTH_SHIFT;
+
+ /* 8bits: uuuuuttt : unit | type */
+ return (bits & 0x7);
+}
static inline uint8_t get_border_bottom_width(const css_computed_style *style,
css_fixed *length, css_unit *unit)
{
@@ -215,6 +320,15 @@ static inline uint8_t get_border_bottom_width(const css_computed_style *style,
#define BORDER_COLLAPSE_INDEX 11
#define BORDER_COLLAPSE_SHIFT 2
#define BORDER_COLLAPSE_MASK 0xc
+static inline uint8_t get_border_collapse_bits(const css_computed_style *style)
+{
+ uint32_t bits = style->i.bits[BORDER_COLLAPSE_INDEX];
+ bits &= BORDER_COLLAPSE_MASK;
+ bits >>= BORDER_COLLAPSE_SHIFT;
+
+ /* 2bits: tt : type */
+ return (bits & 0x3);
+}
static inline uint8_t get_border_collapse(const css_computed_style *style)
{
uint32_t bits = style->i.bits[BORDER_COLLAPSE_INDEX];
@@ -232,6 +346,16 @@ static inline uint8_t get_border_collapse(const css_computed_style *style)
#define BORDER_LEFT_COLOR_INDEX 11
#define BORDER_LEFT_COLOR_SHIFT 4
#define BORDER_LEFT_COLOR_MASK 0x30
+static inline uint8_t get_border_left_color_bits(const css_computed_style
+ *style)
+{
+ uint32_t bits = style->i.bits[BORDER_LEFT_COLOR_INDEX];
+ bits &= BORDER_LEFT_COLOR_MASK;
+ bits >>= BORDER_LEFT_COLOR_SHIFT;
+
+ /* 2bits: tt : type */
+ return (bits & 0x3);
+}
static inline uint8_t get_border_left_color(const css_computed_style *style,
css_color *color)
{
@@ -251,6 +375,16 @@ static inline uint8_t get_border_left_color(const css_computed_style *style,
#define BORDER_LEFT_STYLE_INDEX 9
#define BORDER_LEFT_STYLE_SHIFT 3
#define BORDER_LEFT_STYLE_MASK 0x78
+static inline uint8_t get_border_left_style_bits(const css_computed_style
+ *style)
+{
+ uint32_t bits = style->i.bits[BORDER_LEFT_STYLE_INDEX];
+ bits &= BORDER_LEFT_STYLE_MASK;
+ bits >>= BORDER_LEFT_STYLE_SHIFT;
+
+ /* 4bits: tttt : type */
+ return (bits & 0xf);
+}
static inline uint8_t get_border_left_style(const css_computed_style *style)
{
uint32_t bits = style->i.bits[BORDER_LEFT_STYLE_INDEX];
@@ -268,6 +402,16 @@ static inline uint8_t get_border_left_style(const css_computed_style *style)
#define BORDER_LEFT_WIDTH_INDEX 0
#define BORDER_LEFT_WIDTH_SHIFT 8
#define BORDER_LEFT_WIDTH_MASK 0xff00
+static inline uint8_t get_border_left_width_bits(const css_computed_style
+ *style)
+{
+ uint32_t bits = style->i.bits[BORDER_LEFT_WIDTH_INDEX];
+ bits &= BORDER_LEFT_WIDTH_MASK;
+ bits >>= BORDER_LEFT_WIDTH_SHIFT;
+
+ /* 8bits: uuuuuttt : unit | type */
+ return (bits & 0x7);
+}
static inline uint8_t get_border_left_width(const css_computed_style *style,
css_fixed *length, css_unit *unit)
{
@@ -290,6 +434,16 @@ static inline uint8_t get_border_left_width(const css_computed_style *style,
#define BORDER_RIGHT_COLOR_INDEX 11
#define BORDER_RIGHT_COLOR_SHIFT 6
#define BORDER_RIGHT_COLOR_MASK 0xc0
+static inline uint8_t get_border_right_color_bits(const css_computed_style
+ *style)
+{
+ uint32_t bits = style->i.bits[BORDER_RIGHT_COLOR_INDEX];
+ bits &= BORDER_RIGHT_COLOR_MASK;
+ bits >>= BORDER_RIGHT_COLOR_SHIFT;
+
+ /* 2bits: tt : type */
+ return (bits & 0x3);
+}
static inline uint8_t get_border_right_color(const css_computed_style *style,
css_color *color)
{
@@ -309,6 +463,16 @@ static inline uint8_t get_border_right_color(const css_computed_style *style,
#define BORDER_RIGHT_STYLE_INDEX 9
#define BORDER_RIGHT_STYLE_SHIFT 7
#define BORDER_RIGHT_STYLE_MASK 0x780
+static inline uint8_t get_border_right_style_bits(const css_computed_style
+ *style)
+{
+ uint32_t bits = style->i.bits[BORDER_RIGHT_STYLE_INDEX];
+ bits &= BORDER_RIGHT_STYLE_MASK;
+ bits >>= BORDER_RIGHT_STYLE_SHIFT;
+
+ /* 4bits: tttt : type */
+ return (bits & 0xf);
+}
static inline uint8_t get_border_right_style(const css_computed_style *style)
{
uint32_t bits = style->i.bits[BORDER_RIGHT_STYLE_INDEX];
@@ -326,6 +490,16 @@ static inline uint8_t get_border_right_style(const css_computed_style *style)
#define BORDER_RIGHT_WIDTH_INDEX 0
#define BORDER_RIGHT_WIDTH_SHIFT 16
#define BORDER_RIGHT_WIDTH_MASK 0xff0000
+static inline uint8_t get_border_right_width_bits(const css_computed_style
+ *style)
+{
+ uint32_t bits = style->i.bits[BORDER_RIGHT_WIDTH_INDEX];
+ bits &= BORDER_RIGHT_WIDTH_MASK;
+ bits >>= BORDER_RIGHT_WIDTH_SHIFT;
+
+ /* 8bits: uuuuuttt : unit | type */
+ return (bits & 0x7);
+}
static inline uint8_t get_border_right_width(const css_computed_style *style,
css_fixed *length, css_unit *unit)
{
@@ -348,6 +522,15 @@ static inline uint8_t get_border_right_width(const css_computed_style *style,
#define BORDER_SPACING_INDEX 12
#define BORDER_SPACING_SHIFT 21
#define BORDER_SPACING_MASK 0xffe00000
+static inline uint8_t get_border_spacing_bits(const css_computed_style *style)
+{
+ uint32_t bits = style->i.bits[BORDER_SPACING_INDEX];
+ bits &= BORDER_SPACING_MASK;
+ bits >>= BORDER_SPACING_SHIFT;
+
+ /* 11bits: aaaaabbbbbt : unit_a | unit_b | type */
+ return (bits & 0x1);
+}
static inline uint8_t get_border_spacing(const css_computed_style *style,
css_fixed *length_a, css_unit *unit_a, css_fixed *length_b,
css_unit *unit_b)
@@ -373,6 +556,15 @@ static inline uint8_t get_border_spacing(const css_computed_style *style,
#define BORDER_TOP_COLOR_INDEX 11
#define BORDER_TOP_COLOR_SHIFT 8
#define BORDER_TOP_COLOR_MASK 0x300
+static inline uint8_t get_border_top_color_bits(const css_computed_style *style)
+{
+ uint32_t bits = style->i.bits[BORDER_TOP_COLOR_INDEX];
+ bits &= BORDER_TOP_COLOR_MASK;
+ bits >>= BORDER_TOP_COLOR_SHIFT;
+
+ /* 2bits: tt : type */
+ return (bits & 0x3);
+}
static inline uint8_t get_border_top_color(const css_computed_style *style,
css_color *color)
{
@@ -392,6 +584,15 @@ static inline uint8_t get_border_top_color(const css_computed_style *style,
#define BORDER_TOP_STYLE_INDEX 9
#define BORDER_TOP_STYLE_SHIFT 11
#define BORDER_TOP_STYLE_MASK 0x7800
+static inline uint8_t get_border_top_style_bits(const css_computed_style *style)
+{
+ uint32_t bits = style->i.bits[BORDER_TOP_STYLE_INDEX];
+ bits &= BORDER_TOP_STYLE_MASK;
+ bits >>= BORDER_TOP_STYLE_SHIFT;
+
+ /* 4bits: tttt : type */
+ return (bits & 0xf);
+}
static inline uint8_t get_border_top_style(const css_computed_style *style)
{
uint32_t bits = style->i.bits[BORDER_TOP_STYLE_INDEX];
@@ -409,6 +610,15 @@ static inline uint8_t get_border_top_style(const css_computed_style *style)
#define BORDER_TOP_WIDTH_INDEX 0
#define BORDER_TOP_WIDTH_SHIFT 24
#define BORDER_TOP_WIDTH_MASK 0xff000000
+static inline uint8_t get_border_top_width_bits(const css_computed_style *style)
+{
+ uint32_t bits = style->i.bits[BORDER_TOP_WIDTH_INDEX];
+ bits &= BORDER_TOP_WIDTH_MASK;
+ bits >>= BORDER_TOP_WIDTH_SHIFT;
+
+ /* 8bits: uuuuuttt : unit | type */
+ return (bits & 0x7);
+}
static inline uint8_t get_border_top_width(const css_computed_style *style,
css_fixed *length, css_unit *unit)
{
@@ -431,31 +641,29 @@ static inline uint8_t get_border_top_width(const css_computed_style *style,
#define BOTTOM_INDEX 3
#define BOTTOM_SHIFT 11
#define BOTTOM_MASK 0x3f800
-static inline uint8_t get_bottom(
- const css_computed_style *style,
- css_fixed *length, css_unit *unit)
+static inline uint8_t get_bottom_bits(const css_computed_style *style)
{
uint32_t bits = style->i.bits[BOTTOM_INDEX];
bits &= BOTTOM_MASK;
bits >>= BOTTOM_SHIFT;
-
- /* 7bits: uuuuutt : units | type */
- if ((bits & 0x3) == CSS_BOTTOM_SET) {
- *length = style->i.bottom;
- *unit = bits >> 2;
- }
-
+
+ /* 7bits: uuuuutt : unit | type */
return (bits & 0x3);
}
-static inline uint8_t get_bottom_bits(
- const css_computed_style *style)
+static inline uint8_t get_bottom(const css_computed_style *style, css_fixed
+ *length, css_unit *unit)
{
uint32_t bits = style->i.bits[BOTTOM_INDEX];
bits &= BOTTOM_MASK;
bits >>= BOTTOM_SHIFT;
-
- /* 7bits: uuuuutt : units | type */
- return bits;
+
+ /* 7bits: uuuuutt : unit | type */
+ if ((bits & 0x3) == CSS_BOTTOM_SET) {
+ *length = style->i.bottom;
+ *unit = bits >> 2;
+ }
+
+ return (bits & 0x3);
}
#undef BOTTOM_INDEX
#undef BOTTOM_SHIFT
@@ -464,6 +672,15 @@ static inline uint8_t get_bottom_bits(
#define BOX_SIZING_INDEX 11
#define BOX_SIZING_SHIFT 10
#define BOX_SIZING_MASK 0xc00
+static inline uint8_t get_box_sizing_bits(const css_computed_style *style)
+{
+ uint32_t bits = style->i.bits[BOX_SIZING_INDEX];
+ bits &= BOX_SIZING_MASK;
+ bits >>= BOX_SIZING_SHIFT;
+
+ /* 2bits: tt : type */
+ return (bits & 0x3);
+}
static inline uint8_t get_box_sizing(const css_computed_style *style)
{
uint32_t bits = style->i.bits[BOX_SIZING_INDEX];
@@ -481,6 +698,15 @@ static inline uint8_t get_box_sizing(const css_computed_style *style)
#define BREAK_AFTER_INDEX 9
#define BREAK_AFTER_SHIFT 15
#define BREAK_AFTER_MASK 0x78000
+static inline uint8_t get_break_after_bits(const css_computed_style *style)
+{
+ uint32_t bits = style->i.bits[BREAK_AFTER_INDEX];
+ bits &= BREAK_AFTER_MASK;
+ bits >>= BREAK_AFTER_SHIFT;
+
+ /* 4bits: tttt : type */
+ return (bits & 0xf);
+}
static inline uint8_t get_break_after(const css_computed_style *style)
{
uint32_t bits = style->i.bits[BREAK_AFTER_INDEX];
@@ -498,6 +724,15 @@ static inline uint8_t get_break_after(const css_computed_style *style)
#define BREAK_BEFORE_INDEX 9
#define BREAK_BEFORE_SHIFT 19
#define BREAK_BEFORE_MASK 0x780000
+static inline uint8_t get_break_before_bits(const css_computed_style *style)
+{
+ uint32_t bits = style->i.bits[BREAK_BEFORE_INDEX];
+ bits &= BREAK_BEFORE_MASK;
+ bits >>= BREAK_BEFORE_SHIFT;
+
+ /* 4bits: tttt : type */
+ return (bits & 0xf);
+}
static inline uint8_t get_break_before(const css_computed_style *style)
{
uint32_t bits = style->i.bits[BREAK_BEFORE_INDEX];
@@ -515,6 +750,15 @@ static inline uint8_t get_break_before(const css_computed_style *style)
#define BREAK_INSIDE_INDEX 9
#define BREAK_INSIDE_SHIFT 23
#define BREAK_INSIDE_MASK 0x7800000
+static inline uint8_t get_break_inside_bits(const css_computed_style *style)
+{
+ uint32_t bits = style->i.bits[BREAK_INSIDE_INDEX];
+ bits &= BREAK_INSIDE_MASK;
+ bits >>= BREAK_INSIDE_SHIFT;
+
+ /* 4bits: tttt : type */
+ return (bits & 0xf);
+}
static inline uint8_t get_break_inside(const css_computed_style *style)
{
uint32_t bits = style->i.bits[BREAK_INSIDE_INDEX];
@@ -532,6 +776,15 @@ static inline uint8_t get_break_inside(const css_computed_style *style)
#define CAPTION_SIDE_INDEX 11
#define CAPTION_SIDE_SHIFT 12
#define CAPTION_SIDE_MASK 0x3000
+static inline uint8_t get_caption_side_bits(const css_computed_style *style)
+{
+ uint32_t bits = style->i.bits[CAPTION_SIDE_INDEX];
+ bits &= CAPTION_SIDE_MASK;
+ bits >>= CAPTION_SIDE_SHIFT;
+
+ /* 2bits: tt : type */
+ return (bits & 0x3);
+}
static inline uint8_t get_caption_side(const css_computed_style *style)
{
uint32_t bits = style->i.bits[CAPTION_SIDE_INDEX];
@@ -549,6 +802,15 @@ static inline uint8_t get_caption_side(const css_computed_style *style)
#define CLEAR_INDEX 13
#define CLEAR_SHIFT 1
#define CLEAR_MASK 0xe
+static inline uint8_t get_clear_bits(const css_computed_style *style)
+{
+ uint32_t bits = style->i.bits[CLEAR_INDEX];
+ bits &= CLEAR_MASK;
+ bits >>= CLEAR_SHIFT;
+
+ /* 3bits: ttt : type */
+ return (bits & 0x7);
+}
static inline uint8_t get_clear(const css_computed_style *style)
{
uint32_t bits = style->i.bits[CLEAR_INDEX];
@@ -566,6 +828,16 @@ static inline uint8_t get_clear(const css_computed_style *style)
#define CLIP_INDEX 2
#define CLIP_SHIFT 6
#define CLIP_MASK 0xffffffc0
+static inline uint8_t get_clip_bits(const css_computed_style *style)
+{
+ uint32_t bits = style->i.bits[CLIP_INDEX];
+ bits &= CLIP_MASK;
+ bits >>= CLIP_SHIFT;
+
+ /* 26bits: aaaaabbbbbcccccdddddtttttt : unit_a | unit_b | unit_c |
+ unit_d | type */
+ return (bits & 0x3f);
+}
static inline uint8_t get_clip(
const css_computed_style *style,
css_computed_clip_rect *rect)
@@ -608,15 +880,24 @@ static inline uint8_t get_clip(
#define COLOR_INDEX 14
#define COLOR_SHIFT 19
#define COLOR_MASK 0x80000
-static inline uint8_t get_color(const css_computed_style *style, css_color
- *color)
+static inline uint8_t get_color_bits(const css_computed_style *style)
{
uint32_t bits = style->i.bits[COLOR_INDEX];
bits &= COLOR_MASK;
bits >>= COLOR_SHIFT;
/* 1bit: t : type */
- *color = style->i.color;
+ return (bits & 0x1);
+}
+static inline uint8_t get_color(const css_computed_style *style, css_color
+ *color)
+{
+ uint32_t bits = style->i.bits[COLOR_INDEX];
+ bits &= COLOR_MASK;
+ bits >>= COLOR_SHIFT;
+
+ /* 1bit: t : type */
+ *color = style->i.color;
return (bits & 0x1);
}
@@ -627,6 +908,15 @@ static inline uint8_t get_color(const css_computed_style *style, css_color
#define COLUMN_COUNT_INDEX 11
#define COLUMN_COUNT_SHIFT 14
#define COLUMN_COUNT_MASK 0xc000
+static inline uint8_t get_column_count_bits(const css_computed_style *style)
+{
+ uint32_t bits = style->i.bits[COLUMN_COUNT_INDEX];
+ bits &= COLUMN_COUNT_MASK;
+ bits >>= COLUMN_COUNT_SHIFT;
+
+ /* 2bits: tt : type */
+ return (bits & 0x3);
+}
static inline uint8_t get_column_count(const css_computed_style *style, int32_t
*integer)
{
@@ -646,6 +936,15 @@ static inline uint8_t get_column_count(const css_computed_style *style, int32_t
#define COLUMN_FILL_INDEX 11
#define COLUMN_FILL_SHIFT 16
#define COLUMN_FILL_MASK 0x30000
+static inline uint8_t get_column_fill_bits(const css_computed_style *style)
+{
+ uint32_t bits = style->i.bits[COLUMN_FILL_INDEX];
+ bits &= COLUMN_FILL_MASK;
+ bits >>= COLUMN_FILL_SHIFT;
+
+ /* 2bits: tt : type */
+ return (bits & 0x3);
+}
static inline uint8_t get_column_fill(const css_computed_style *style)
{
uint32_t bits = style->i.bits[COLUMN_FILL_INDEX];
@@ -663,6 +962,15 @@ static inline uint8_t get_column_fill(const css_computed_style *style)
#define COLUMN_GAP_INDEX 3
#define COLUMN_GAP_SHIFT 18
#define COLUMN_GAP_MASK 0x1fc0000
+static inline uint8_t get_column_gap_bits(const css_computed_style *style)
+{
+ uint32_t bits = style->i.bits[COLUMN_GAP_INDEX];
+ bits &= COLUMN_GAP_MASK;
+ bits >>= COLUMN_GAP_SHIFT;
+
+ /* 7bits: uuuuutt : unit | type */
+ return (bits & 0x3);
+}
static inline uint8_t get_column_gap(const css_computed_style *style, css_fixed
*length, css_unit *unit)
{
@@ -685,6 +993,16 @@ static inline uint8_t get_column_gap(const css_computed_style *style, css_fixed
#define COLUMN_RULE_COLOR_INDEX 11
#define COLUMN_RULE_COLOR_SHIFT 18
#define COLUMN_RULE_COLOR_MASK 0xc0000
+static inline uint8_t get_column_rule_color_bits(const css_computed_style
+ *style)
+{
+ uint32_t bits = style->i.bits[COLUMN_RULE_COLOR_INDEX];
+ bits &= COLUMN_RULE_COLOR_MASK;
+ bits >>= COLUMN_RULE_COLOR_SHIFT;
+
+ /* 2bits: tt : type */
+ return (bits & 0x3);
+}
static inline uint8_t get_column_rule_color(const css_computed_style *style,
css_color *color)
{
@@ -704,6 +1022,16 @@ static inline uint8_t get_column_rule_color(const css_computed_style *style,
#define COLUMN_RULE_STYLE_INDEX 7
#define COLUMN_RULE_STYLE_SHIFT 0
#define COLUMN_RULE_STYLE_MASK 0xf
+static inline uint8_t get_column_rule_style_bits(const css_computed_style
+ *style)
+{
+ uint32_t bits = style->i.bits[COLUMN_RULE_STYLE_INDEX];
+ bits &= COLUMN_RULE_STYLE_MASK;
+ bits >>= COLUMN_RULE_STYLE_SHIFT;
+
+ /* 4bits: tttt : type */
+ return (bits & 0xf);
+}
static inline uint8_t get_column_rule_style(const css_computed_style *style)
{
uint32_t bits = style->i.bits[COLUMN_RULE_STYLE_INDEX];
@@ -721,6 +1049,16 @@ static inline uint8_t get_column_rule_style(const css_computed_style *style)
#define COLUMN_RULE_WIDTH_INDEX 1
#define COLUMN_RULE_WIDTH_SHIFT 7
#define COLUMN_RULE_WIDTH_MASK 0x7f80
+static inline uint8_t get_column_rule_width_bits(const css_computed_style
+ *style)
+{
+ uint32_t bits = style->i.bits[COLUMN_RULE_WIDTH_INDEX];
+ bits &= COLUMN_RULE_WIDTH_MASK;
+ bits >>= COLUMN_RULE_WIDTH_SHIFT;
+
+ /* 8bits: uuuuuttt : unit | type */
+ return (bits & 0x7);
+}
static inline uint8_t get_column_rule_width(const css_computed_style *style,
css_fixed *length, css_unit *unit)
{
@@ -743,6 +1081,15 @@ static inline uint8_t get_column_rule_width(const css_computed_style *style,
#define COLUMN_SPAN_INDEX 11
#define COLUMN_SPAN_SHIFT 20
#define COLUMN_SPAN_MASK 0x300000
+static inline uint8_t get_column_span_bits(const css_computed_style *style)
+{
+ uint32_t bits = style->i.bits[COLUMN_SPAN_INDEX];
+ bits &= COLUMN_SPAN_MASK;
+ bits >>= COLUMN_SPAN_SHIFT;
+
+ /* 2bits: tt : type */
+ return (bits & 0x3);
+}
static inline uint8_t get_column_span(const css_computed_style *style)
{
uint32_t bits = style->i.bits[COLUMN_SPAN_INDEX];
@@ -760,6 +1107,15 @@ static inline uint8_t get_column_span(const css_computed_style *style)
#define COLUMN_WIDTH_INDEX 3
#define COLUMN_WIDTH_SHIFT 25
#define COLUMN_WIDTH_MASK 0xfe000000
+static inline uint8_t get_column_width_bits(const css_computed_style *style)
+{
+ uint32_t bits = style->i.bits[COLUMN_WIDTH_INDEX];
+ bits &= COLUMN_WIDTH_MASK;
+ bits >>= COLUMN_WIDTH_SHIFT;
+
+ /* 7bits: uuuuutt : unit | type */
+ return (bits & 0x3);
+}
static inline uint8_t get_column_width(const css_computed_style *style,
css_fixed *length, css_unit *unit)
{
@@ -782,6 +1138,15 @@ static inline uint8_t get_column_width(const css_computed_style *style,
#define CONTENT_INDEX 11
#define CONTENT_SHIFT 22
#define CONTENT_MASK 0xc00000
+static inline uint8_t get_content_bits(const css_computed_style *style)
+{
+ uint32_t bits = style->i.bits[CONTENT_INDEX];
+ bits &= CONTENT_MASK;
+ bits >>= CONTENT_SHIFT;
+
+ /* 2bits: tt : type */
+ return (bits & 0x3);
+}
static inline uint8_t get_content(const css_computed_style *style, const
css_computed_content_item **content_item)
{
@@ -803,6 +1168,16 @@ static inline uint8_t get_content(const css_computed_style *style, const
#define COUNTER_INCREMENT_INDEX 14
#define COUNTER_INCREMENT_SHIFT 20
#define COUNTER_INCREMENT_MASK 0x100000
+static inline uint8_t get_counter_increment_bits(const css_computed_style
+ *style)
+{
+ uint32_t bits = style->i.bits[COUNTER_INCREMENT_INDEX];
+ bits &= COUNTER_INCREMENT_MASK;
+ bits >>= COUNTER_INCREMENT_SHIFT;
+
+ /* 1bit: t : type */
+ return (bits & 0x1);
+}
static inline uint8_t get_counter_increment(const css_computed_style *style,
const css_computed_counter **counter_arr)
{
@@ -822,6 +1197,15 @@ static inline uint8_t get_counter_increment(const css_computed_style *style,
#define COUNTER_RESET_INDEX 14
#define COUNTER_RESET_SHIFT 21
#define COUNTER_RESET_MASK 0x200000
+static inline uint8_t get_counter_reset_bits(const css_computed_style *style)
+{
+ uint32_t bits = style->i.bits[COUNTER_RESET_INDEX];
+ bits &= COUNTER_RESET_MASK;
+ bits >>= COUNTER_RESET_SHIFT;
+
+ /* 1bit: t : type */
+ return (bits & 0x1);
+}
static inline uint8_t get_counter_reset(const css_computed_style *style, const
css_computed_counter **counter_arr)
{
@@ -841,6 +1225,15 @@ static inline uint8_t get_counter_reset(const css_computed_style *style, const
#define CURSOR_INDEX 9
#define CURSOR_SHIFT 27
#define CURSOR_MASK 0xf8000000
+static inline uint8_t get_cursor_bits(const css_computed_style *style)
+{
+ uint32_t bits = style->i.bits[CURSOR_INDEX];
+ bits &= CURSOR_MASK;
+ bits >>= CURSOR_SHIFT;
+
+ /* 5bits: ttttt : type */
+ return (bits & 0x1f);
+}
static inline uint8_t get_cursor(const css_computed_style *style, lwc_string
***string_arr)
{
@@ -860,6 +1253,15 @@ static inline uint8_t get_cursor(const css_computed_style *style, lwc_string
#define DIRECTION_INDEX 11
#define DIRECTION_SHIFT 24
#define DIRECTION_MASK 0x3000000
+static inline uint8_t get_direction_bits(const css_computed_style *style)
+{
+ uint32_t bits = style->i.bits[DIRECTION_INDEX];
+ bits &= DIRECTION_MASK;
+ bits >>= DIRECTION_SHIFT;
+
+ /* 2bits: tt : type */
+ return (bits & 0x3);
+}
static inline uint8_t get_direction(const css_computed_style *style)
{
uint32_t bits = style->i.bits[DIRECTION_INDEX];
@@ -877,6 +1279,15 @@ static inline uint8_t get_direction(const css_computed_style *style)
#define DISPLAY_INDEX 8
#define DISPLAY_SHIFT 3
#define DISPLAY_MASK 0xf8
+static inline uint8_t get_display_bits(const css_computed_style *style)
+{
+ uint32_t bits = style->i.bits[DISPLAY_INDEX];
+ bits &= DISPLAY_MASK;
+ bits >>= DISPLAY_SHIFT;
+
+ /* 5bits: ttttt : type */
+ return (bits & 0x1f);
+}
static inline uint8_t get_display(const css_computed_style *style)
{
uint32_t bits = style->i.bits[DISPLAY_INDEX];
@@ -894,6 +1305,15 @@ static inline uint8_t get_display(const css_computed_style *style)
#define EMPTY_CELLS_INDEX 11
#define EMPTY_CELLS_SHIFT 26
#define EMPTY_CELLS_MASK 0xc000000
+static inline uint8_t get_empty_cells_bits(const css_computed_style *style)
+{
+ uint32_t bits = style->i.bits[EMPTY_CELLS_INDEX];
+ bits &= EMPTY_CELLS_MASK;
+ bits >>= EMPTY_CELLS_SHIFT;
+
+ /* 2bits: tt : type */
+ return (bits & 0x3);
+}
static inline uint8_t get_empty_cells(const css_computed_style *style)
{
uint32_t bits = style->i.bits[EMPTY_CELLS_INDEX];
@@ -911,6 +1331,15 @@ static inline uint8_t get_empty_cells(const css_computed_style *style)
#define FLEX_BASIS_INDEX 7
#define FLEX_BASIS_SHIFT 4
#define FLEX_BASIS_MASK 0x7f0
+static inline uint8_t get_flex_basis_bits(const css_computed_style *style)
+{
+ uint32_t bits = style->i.bits[FLEX_BASIS_INDEX];
+ bits &= FLEX_BASIS_MASK;
+ bits >>= FLEX_BASIS_SHIFT;
+
+ /* 7bits: uuuuutt : unit | type */
+ return (bits & 0x3);
+}
static inline uint8_t get_flex_basis(const css_computed_style *style, css_fixed
*length, css_unit *unit)
{
@@ -933,6 +1362,15 @@ static inline uint8_t get_flex_basis(const css_computed_style *style, css_fixed
#define FLEX_DIRECTION_INDEX 13
#define FLEX_DIRECTION_SHIFT 4
#define FLEX_DIRECTION_MASK 0x70
+static inline uint8_t get_flex_direction_bits(const css_computed_style *style)
+{
+ uint32_t bits = style->i.bits[FLEX_DIRECTION_INDEX];
+ bits &= FLEX_DIRECTION_MASK;
+ bits >>= FLEX_DIRECTION_SHIFT;
+
+ /* 3bits: ttt : type */
+ return (bits & 0x7);
+}
static inline uint8_t get_flex_direction(const css_computed_style *style)
{
uint32_t bits = style->i.bits[FLEX_DIRECTION_INDEX];
@@ -950,6 +1388,15 @@ static inline uint8_t get_flex_direction(const css_computed_style *style)
#define FLEX_GROW_INDEX 14
#define FLEX_GROW_SHIFT 22
#define FLEX_GROW_MASK 0x400000
+static inline uint8_t get_flex_grow_bits(const css_computed_style *style)
+{
+ uint32_t bits = style->i.bits[FLEX_GROW_INDEX];
+ bits &= FLEX_GROW_MASK;
+ bits >>= FLEX_GROW_SHIFT;
+
+ /* 1bit: t : type */
+ return (bits & 0x1);
+}
static inline uint8_t get_flex_grow(const css_computed_style *style, css_fixed
*fixed)
{
@@ -971,6 +1418,15 @@ static inline uint8_t get_flex_grow(const css_computed_style *style, css_fixed
#define FLEX_SHRINK_INDEX 14
#define FLEX_SHRINK_SHIFT 23
#define FLEX_SHRINK_MASK 0x800000
+static inline uint8_t get_flex_shrink_bits(const css_computed_style *style)
+{
+ uint32_t bits = style->i.bits[FLEX_SHRINK_INDEX];
+ bits &= FLEX_SHRINK_MASK;
+ bits >>= FLEX_SHRINK_SHIFT;
+
+ /* 1bit: t : type */
+ return (bits & 0x1);
+}
static inline uint8_t get_flex_shrink(const css_computed_style *style,
css_fixed *fixed)
{
@@ -992,6 +1448,15 @@ static inline uint8_t get_flex_shrink(const css_computed_style *style,
#define FLEX_WRAP_INDEX 11
#define FLEX_WRAP_SHIFT 28
#define FLEX_WRAP_MASK 0x30000000
+static inline uint8_t get_flex_wrap_bits(const css_computed_style *style)
+{
+ uint32_t bits = style->i.bits[FLEX_WRAP_INDEX];
+ bits &= FLEX_WRAP_MASK;
+ bits >>= FLEX_WRAP_SHIFT;
+
+ /* 2bits: tt : type */
+ return (bits & 0x3);
+}
static inline uint8_t get_flex_wrap(const css_computed_style *style)
{
uint32_t bits = style->i.bits[FLEX_WRAP_INDEX];
@@ -1009,6 +1474,15 @@ static inline uint8_t get_flex_wrap(const css_computed_style *style)
#define FLOAT_INDEX 11
#define FLOAT_SHIFT 30
#define FLOAT_MASK 0xc0000000
+static inline uint8_t get_float_bits(const css_computed_style *style)
+{
+ uint32_t bits = style->i.bits[FLOAT_INDEX];
+ bits &= FLOAT_MASK;
+ bits >>= FLOAT_SHIFT;
+
+ /* 2bits: tt : type */
+ return (bits & 0x3);
+}
static inline uint8_t get_float(const css_computed_style *style)
{
uint32_t bits = style->i.bits[FLOAT_INDEX];
@@ -1026,6 +1500,15 @@ static inline uint8_t get_float(const css_computed_style *style)
#define FONT_FAMILY_INDEX 13
#define FONT_FAMILY_SHIFT 7
#define FONT_FAMILY_MASK 0x380
+static inline uint8_t get_font_family_bits(const css_computed_style *style)
+{
+ uint32_t bits = style->i.bits[FONT_FAMILY_INDEX];
+ bits &= FONT_FAMILY_MASK;
+ bits >>= FONT_FAMILY_SHIFT;
+
+ /* 3bits: ttt : type */
+ return (bits & 0x7);
+}
static inline uint8_t get_font_family(const css_computed_style *style,
lwc_string ***string_arr)
{
@@ -1045,6 +1528,15 @@ static inline uint8_t get_font_family(const css_computed_style *style,
#define FONT_SIZE_INDEX 1
#define FONT_SIZE_SHIFT 23
#define FONT_SIZE_MASK 0xff800000
+static inline uint8_t get_font_size_bits(const css_computed_style *style)
+{
+ uint32_t bits = style->i.bits[FONT_SIZE_INDEX];
+ bits &= FONT_SIZE_MASK;
+ bits >>= FONT_SIZE_SHIFT;
+
+ /* 9bits: uuuuutttt : unit | type */
+ return (bits & 0xf);
+}
static inline uint8_t get_font_size(const css_computed_style *style, css_fixed
*length, css_unit *unit)
{
@@ -1067,6 +1559,15 @@ static inline uint8_t get_font_size(const css_computed_style *style, css_fixed
#define FONT_STYLE_INDEX 10
#define FONT_STYLE_SHIFT 0
#define FONT_STYLE_MASK 0x3
+static inline uint8_t get_font_style_bits(const css_computed_style *style)
+{
+ uint32_t bits = style->i.bits[FONT_STYLE_INDEX];
+ bits &= FONT_STYLE_MASK;
+ bits >>= FONT_STYLE_SHIFT;
+
+ /* 2bits: tt : type */
+ return (bits & 0x3);
+}
static inline uint8_t get_font_style(const css_computed_style *style)
{
uint32_t bits = style->i.bits[FONT_STYLE_INDEX];
@@ -1084,6 +1585,15 @@ static inline uint8_t get_font_style(const css_computed_style *style)
#define FONT_VARIANT_INDEX 10
#define FONT_VARIANT_SHIFT 2
#define FONT_VARIANT_MASK 0xc
+static inline uint8_t get_font_variant_bits(const css_computed_style *style)
+{
+ uint32_t bits = style->i.bits[FONT_VARIANT_INDEX];
+ bits &= FONT_VARIANT_MASK;
+ bits >>= FONT_VARIANT_SHIFT;
+
+ /* 2bits: tt : type */
+ return (bits & 0x3);
+}
static inline uint8_t get_font_variant(const css_computed_style *style)
{
uint32_t bits = style->i.bits[FONT_VARIANT_INDEX];
@@ -1101,6 +1611,15 @@ static inline uint8_t get_font_variant(const css_computed_style *style)
#define FONT_WEIGHT_INDEX 6
#define FONT_WEIGHT_SHIFT 0
#define FONT_WEIGHT_MASK 0xf
+static inline uint8_t get_font_weight_bits(const css_computed_style *style)
+{
+ uint32_t bits = style->i.bits[FONT_WEIGHT_INDEX];
+ bits &= FONT_WEIGHT_MASK;
+ bits >>= FONT_WEIGHT_SHIFT;
+
+ /* 4bits: tttt : type */
+ return (bits & 0xf);
+}
static inline uint8_t get_font_weight(const css_computed_style *style)
{
uint32_t bits = style->i.bits[FONT_WEIGHT_INDEX];
@@ -1118,6 +1637,15 @@ static inline uint8_t get_font_weight(const css_computed_style *style)
#define HEIGHT_INDEX 7
#define HEIGHT_SHIFT 11
#define HEIGHT_MASK 0x3f800
+static inline uint8_t get_height_bits(const css_computed_style *style)
+{
+ uint32_t bits = style->i.bits[HEIGHT_INDEX];
+ bits &= HEIGHT_MASK;
+ bits >>= HEIGHT_SHIFT;
+
+ /* 7bits: uuuuutt : unit | type */
+ return (bits & 0x3);
+}
static inline uint8_t get_height(const css_computed_style *style, css_fixed
*length, css_unit *unit)
{
@@ -1140,6 +1668,15 @@ static inline uint8_t get_height(const css_computed_style *style, css_fixed
#define JUSTIFY_CONTENT_INDEX 13
#define JUSTIFY_CONTENT_SHIFT 10
#define JUSTIFY_CONTENT_MASK 0x1c00
+static inline uint8_t get_justify_content_bits(const css_computed_style *style)
+{
+ uint32_t bits = style->i.bits[JUSTIFY_CONTENT_INDEX];
+ bits &= JUSTIFY_CONTENT_MASK;
+ bits >>= JUSTIFY_CONTENT_SHIFT;
+
+ /* 3bits: ttt : type */
+ return (bits & 0x7);
+}
static inline uint8_t get_justify_content(const css_computed_style *style)
{
uint32_t bits = style->i.bits[JUSTIFY_CONTENT_INDEX];
@@ -1157,39 +1694,46 @@ static inline uint8_t get_justify_content(const css_computed_style *style)
#define LEFT_INDEX 7
#define LEFT_SHIFT 18
#define LEFT_MASK 0x1fc0000
-static inline uint8_t get_left(
- const css_computed_style *style,
- css_fixed *length, css_unit *unit)
+static inline uint8_t get_left_bits(const css_computed_style *style)
{
uint32_t bits = style->i.bits[LEFT_INDEX];
bits &= LEFT_MASK;
bits >>= LEFT_SHIFT;
-
- /* 7bits: uuuuutt : units | type */
- if ((bits & 0x3) == CSS_LEFT_SET) {
- *length = style->i.left;
- *unit = bits >> 2;
- }
-
+
+ /* 7bits: uuuuutt : unit | type */
return (bits & 0x3);
}
-static inline uint8_t get_left_bits(
- const css_computed_style *style)
+static inline uint8_t get_left(const css_computed_style *style, css_fixed
+ *length, css_unit *unit)
{
uint32_t bits = style->i.bits[LEFT_INDEX];
bits &= LEFT_MASK;
bits >>= LEFT_SHIFT;
-
- /* 7bits: uuuuutt : units | type */
- return bits;
-}
-#undef LEFT_INDEX
-#undef LEFT_SHIFT
-#undef LEFT_MASK
-
-#define LETTER_SPACING_INDEX 7
-#define LETTER_SPACING_SHIFT 25
+
+ /* 7bits: uuuuutt : unit | type */
+ if ((bits & 0x3) == CSS_LEFT_SET) {
+ *length = style->i.left;
+ *unit = bits >> 2;
+ }
+
+ return (bits & 0x3);
+}
+#undef LEFT_INDEX
+#undef LEFT_SHIFT
+#undef LEFT_MASK
+
+#define LETTER_SPACING_INDEX 7
+#define LETTER_SPACING_SHIFT 25
#define LETTER_SPACING_MASK 0xfe000000
+static inline uint8_t get_letter_spacing_bits(const css_computed_style *style)
+{
+ uint32_t bits = style->i.bits[LETTER_SPACING_INDEX];
+ bits &= LETTER_SPACING_MASK;
+ bits >>= LETTER_SPACING_SHIFT;
+
+ /* 7bits: uuuuutt : unit | type */
+ return (bits & 0x3);
+}
static inline uint8_t get_letter_spacing(const css_computed_style *style,
css_fixed *length, css_unit *unit)
{
@@ -1212,6 +1756,15 @@ static inline uint8_t get_letter_spacing(const css_computed_style *style,
#define LINE_HEIGHT_INDEX 6
#define LINE_HEIGHT_SHIFT 4
#define LINE_HEIGHT_MASK 0x7f0
+static inline uint8_t get_line_height_bits(const css_computed_style *style)
+{
+ uint32_t bits = style->i.bits[LINE_HEIGHT_INDEX];
+ bits &= LINE_HEIGHT_MASK;
+ bits >>= LINE_HEIGHT_SHIFT;
+
+ /* 7bits: uuuuutt : unit | type */
+ return (bits & 0x3);
+}
static inline uint8_t get_line_height(
const css_computed_style *style,
css_fixed *length, css_unit *unit)
@@ -1239,6 +1792,15 @@ static inline uint8_t get_line_height(
#define LIST_STYLE_IMAGE_INDEX 14
#define LIST_STYLE_IMAGE_SHIFT 24
#define LIST_STYLE_IMAGE_MASK 0x1000000
+static inline uint8_t get_list_style_image_bits(const css_computed_style *style)
+{
+ uint32_t bits = style->i.bits[LIST_STYLE_IMAGE_INDEX];
+ bits &= LIST_STYLE_IMAGE_MASK;
+ bits >>= LIST_STYLE_IMAGE_SHIFT;
+
+ /* 1bit: t : type */
+ return (bits & 0x1);
+}
static inline uint8_t get_list_style_image(const css_computed_style *style,
lwc_string **string)
{
@@ -1258,6 +1820,16 @@ static inline uint8_t get_list_style_image(const css_computed_style *style,
#define LIST_STYLE_POSITION_INDEX 10
#define LIST_STYLE_POSITION_SHIFT 4
#define LIST_STYLE_POSITION_MASK 0x30
+static inline uint8_t get_list_style_position_bits(const css_computed_style
+ *style)
+{
+ uint32_t bits = style->i.bits[LIST_STYLE_POSITION_INDEX];
+ bits &= LIST_STYLE_POSITION_MASK;
+ bits >>= LIST_STYLE_POSITION_SHIFT;
+
+ /* 2bits: tt : type */
+ return (bits & 0x3);
+}
static inline uint8_t get_list_style_position(const css_computed_style *style)
{
uint32_t bits = style->i.bits[LIST_STYLE_POSITION_INDEX];
@@ -1275,6 +1847,15 @@ static inline uint8_t get_list_style_position(const css_computed_style *style)
#define LIST_STYLE_TYPE_INDEX 8
#define LIST_STYLE_TYPE_SHIFT 8
#define LIST_STYLE_TYPE_MASK 0x3f00
+static inline uint8_t get_list_style_type_bits(const css_computed_style *style)
+{
+ uint32_t bits = style->i.bits[LIST_STYLE_TYPE_INDEX];
+ bits &= LIST_STYLE_TYPE_MASK;
+ bits >>= LIST_STYLE_TYPE_SHIFT;
+
+ /* 6bits: tttttt : type */
+ return (bits & 0x3f);
+}
static inline uint8_t get_list_style_type(const css_computed_style *style)
{
uint32_t bits = style->i.bits[LIST_STYLE_TYPE_INDEX];
@@ -1292,6 +1873,15 @@ static inline uint8_t get_list_style_type(const css_computed_style *style)
#define MARGIN_BOTTOM_INDEX 6
#define MARGIN_BOTTOM_SHIFT 11
#define MARGIN_BOTTOM_MASK 0x3f800
+static inline uint8_t get_margin_bottom_bits(const css_computed_style *style)
+{
+ uint32_t bits = style->i.bits[MARGIN_BOTTOM_INDEX];
+ bits &= MARGIN_BOTTOM_MASK;
+ bits >>= MARGIN_BOTTOM_SHIFT;
+
+ /* 7bits: uuuuutt : unit | type */
+ return (bits & 0x3);
+}
static inline uint8_t get_margin_bottom(const css_computed_style *style,
css_fixed *length, css_unit *unit)
{
@@ -1314,6 +1904,15 @@ static inline uint8_t get_margin_bottom(const css_computed_style *style,
#define MARGIN_LEFT_INDEX 6
#define MARGIN_LEFT_SHIFT 18
#define MARGIN_LEFT_MASK 0x1fc0000
+static inline uint8_t get_margin_left_bits(const css_computed_style *style)
+{
+ uint32_t bits = style->i.bits[MARGIN_LEFT_INDEX];
+ bits &= MARGIN_LEFT_MASK;
+ bits >>= MARGIN_LEFT_SHIFT;
+
+ /* 7bits: uuuuutt : unit | type */
+ return (bits & 0x3);
+}
static inline uint8_t get_margin_left(const css_computed_style *style,
css_fixed *length, css_unit *unit)
{
@@ -1336,6 +1935,15 @@ static inline uint8_t get_margin_left(const css_computed_style *style,
#define MARGIN_RIGHT_INDEX 6
#define MARGIN_RIGHT_SHIFT 25
#define MARGIN_RIGHT_MASK 0xfe000000
+static inline uint8_t get_margin_right_bits(const css_computed_style *style)
+{
+ uint32_t bits = style->i.bits[MARGIN_RIGHT_INDEX];
+ bits &= MARGIN_RIGHT_MASK;
+ bits >>= MARGIN_RIGHT_SHIFT;
+
+ /* 7bits: uuuuutt : unit | type */
+ return (bits & 0x3);
+}
static inline uint8_t get_margin_right(const css_computed_style *style,
css_fixed *length, css_unit *unit)
{
@@ -1358,6 +1966,15 @@ static inline uint8_t get_margin_right(const css_computed_style *style,
#define MARGIN_TOP_INDEX 5
#define MARGIN_TOP_SHIFT 4
#define MARGIN_TOP_MASK 0x7f0
+static inline uint8_t get_margin_top_bits(const css_computed_style *style)
+{
+ uint32_t bits = style->i.bits[MARGIN_TOP_INDEX];
+ bits &= MARGIN_TOP_MASK;
+ bits >>= MARGIN_TOP_SHIFT;
+
+ /* 7bits: uuuuutt : unit | type */
+ return (bits & 0x3);
+}
static inline uint8_t get_margin_top(const css_computed_style *style, css_fixed
*length, css_unit *unit)
{
@@ -1380,6 +1997,15 @@ static inline uint8_t get_margin_top(const css_computed_style *style, css_fixed
#define MAX_HEIGHT_INDEX 5
#define MAX_HEIGHT_SHIFT 11
#define MAX_HEIGHT_MASK 0x3f800
+static inline uint8_t get_max_height_bits(const css_computed_style *style)
+{
+ uint32_t bits = style->i.bits[MAX_HEIGHT_INDEX];
+ bits &= MAX_HEIGHT_MASK;
+ bits >>= MAX_HEIGHT_SHIFT;
+
+ /* 7bits: uuuuutt : unit | type */
+ return (bits & 0x3);
+}
static inline uint8_t get_max_height(const css_computed_style *style, css_fixed
*length, css_unit *unit)
{
@@ -1402,6 +2028,15 @@ static inline uint8_t get_max_height(const css_computed_style *style, css_fixed
#define MAX_WIDTH_INDEX 5
#define MAX_WIDTH_SHIFT 18
#define MAX_WIDTH_MASK 0x1fc0000
+static inline uint8_t get_max_width_bits(const css_computed_style *style)
+{
+ uint32_t bits = style->i.bits[MAX_WIDTH_INDEX];
+ bits &= MAX_WIDTH_MASK;
+ bits >>= MAX_WIDTH_SHIFT;
+
+ /* 7bits: uuuuutt : unit | type */
+ return (bits & 0x3);
+}
static inline uint8_t get_max_width(const css_computed_style *style, css_fixed
*length, css_unit *unit)
{
@@ -1424,6 +2059,15 @@ static inline uint8_t get_max_width(const css_computed_style *style, css_fixed
#define MIN_HEIGHT_INDEX 5
#define MIN_HEIGHT_SHIFT 25
#define MIN_HEIGHT_MASK 0xfe000000
+static inline uint8_t get_min_height_bits(const css_computed_style *style)
+{
+ uint32_t bits = style->i.bits[MIN_HEIGHT_INDEX];
+ bits &= MIN_HEIGHT_MASK;
+ bits >>= MIN_HEIGHT_SHIFT;
+
+ /* 7bits: uuuuutt : unit | type */
+ return (bits & 0x3);
+}
static inline uint8_t get_min_height(const css_computed_style *style, css_fixed
*length, css_unit *unit)
{
@@ -1446,6 +2090,15 @@ static inline uint8_t get_min_height(const css_computed_style *style, css_fixed
#define MIN_WIDTH_INDEX 4
#define MIN_WIDTH_SHIFT 4
#define MIN_WIDTH_MASK 0x7f0
+static inline uint8_t get_min_width_bits(const css_computed_style *style)
+{
+ uint32_t bits = style->i.bits[MIN_WIDTH_INDEX];
+ bits &= MIN_WIDTH_MASK;
+ bits >>= MIN_WIDTH_SHIFT;
+
+ /* 7bits: uuuuutt : unit | type */
+ return (bits & 0x3);
+}
static inline uint8_t get_min_width(const css_computed_style *style, css_fixed
*length, css_unit *unit)
{
@@ -1468,6 +2121,15 @@ static inline uint8_t get_min_width(const css_computed_style *style, css_fixed
#define OPACITY_INDEX 14
#define OPACITY_SHIFT 25
#define OPACITY_MASK 0x2000000
+static inline uint8_t get_opacity_bits(const css_computed_style *style)
+{
+ uint32_t bits = style->i.bits[OPACITY_INDEX];
+ bits &= OPACITY_MASK;
+ bits >>= OPACITY_SHIFT;
+
+ /* 1bit: t : type */
+ return (bits & 0x1);
+}
static inline uint8_t get_opacity(const css_computed_style *style, css_fixed
*fixed)
{
@@ -1489,6 +2151,15 @@ static inline uint8_t get_opacity(const css_computed_style *style, css_fixed
#define ORDER_INDEX 14
#define ORDER_SHIFT 26
#define ORDER_MASK 0x4000000
+static inline uint8_t get_order_bits(const css_computed_style *style)
+{
+ uint32_t bits = style->i.bits[ORDER_INDEX];
+ bits &= ORDER_MASK;
+ bits >>= ORDER_SHIFT;
+
+ /* 1bit: t : type */
+ return (bits & 0x1);
+}
static inline uint8_t get_order(const css_computed_style *style, int32_t
*integer)
{
@@ -1510,6 +2181,15 @@ static inline uint8_t get_order(const css_computed_style *style, int32_t
#define ORPHANS_INDEX 14
#define ORPHANS_SHIFT 27
#define ORPHANS_MASK 0x8000000
+static inline uint8_t get_orphans_bits(const css_computed_style *style)
+{
+ uint32_t bits = style->i.bits[ORPHANS_INDEX];
+ bits &= ORPHANS_MASK;
+ bits >>= ORPHANS_SHIFT;
+
+ /* 1bit: t : type */
+ return (bits & 0x1);
+}
static inline uint8_t get_orphans(const css_computed_style *style, int32_t
*integer)
{
@@ -1529,6 +2209,15 @@ static inline uint8_t get_orphans(const css_computed_style *style, int32_t
#define OUTLINE_COLOR_INDEX 10
#define OUTLINE_COLOR_SHIFT 6
#define OUTLINE_COLOR_MASK 0xc0
+static inline uint8_t get_outline_color_bits(const css_computed_style *style)
+{
+ uint32_t bits = style->i.bits[OUTLINE_COLOR_INDEX];
+ bits &= OUTLINE_COLOR_MASK;
+ bits >>= OUTLINE_COLOR_SHIFT;
+
+ /* 2bits: tt : type */
+ return (bits & 0x3);
+}
static inline uint8_t get_outline_color(const css_computed_style *style,
css_color *color)
{
@@ -1550,6 +2239,15 @@ static inline uint8_t get_outline_color(const css_computed_style *style,
#define OUTLINE_STYLE_INDEX 5
#define OUTLINE_STYLE_SHIFT 0
#define OUTLINE_STYLE_MASK 0xf
+static inline uint8_t get_outline_style_bits(const css_computed_style *style)
+{
+ uint32_t bits = style->i.bits[OUTLINE_STYLE_INDEX];
+ bits &= OUTLINE_STYLE_MASK;
+ bits >>= OUTLINE_STYLE_SHIFT;
+
+ /* 4bits: tttt : type */
+ return (bits & 0xf);
+}
static inline uint8_t get_outline_style(const css_computed_style *style)
{
uint32_t bits = style->i.bits[OUTLINE_STYLE_INDEX];
@@ -1567,6 +2265,15 @@ static inline uint8_t get_outline_style(const css_computed_style *style)
#define OUTLINE_WIDTH_INDEX 1
#define OUTLINE_WIDTH_SHIFT 15
#define OUTLINE_WIDTH_MASK 0x7f8000
+static inline uint8_t get_outline_width_bits(const css_computed_style *style)
+{
+ uint32_t bits = style->i.bits[OUTLINE_WIDTH_INDEX];
+ bits &= OUTLINE_WIDTH_MASK;
+ bits >>= OUTLINE_WIDTH_SHIFT;
+
+ /* 8bits: uuuuuttt : unit | type */
+ return (bits & 0x7);
+}
static inline uint8_t get_outline_width(const css_computed_style *style,
css_fixed *length, css_unit *unit)
{
@@ -1589,6 +2296,15 @@ static inline uint8_t get_outline_width(const css_computed_style *style,
#define OVERFLOW_X_INDEX 13
#define OVERFLOW_X_SHIFT 13
#define OVERFLOW_X_MASK 0xe000
+static inline uint8_t get_overflow_x_bits(const css_computed_style *style)
+{
+ uint32_t bits = style->i.bits[OVERFLOW_X_INDEX];
+ bits &= OVERFLOW_X_MASK;
+ bits >>= OVERFLOW_X_SHIFT;
+
+ /* 3bits: ttt : type */
+ return (bits & 0x7);
+}
static inline uint8_t get_overflow_x(const css_computed_style *style)
{
uint32_t bits = style->i.bits[OVERFLOW_X_INDEX];
@@ -1606,6 +2322,15 @@ static inline uint8_t get_overflow_x(const css_computed_style *style)
#define OVERFLOW_Y_INDEX 13
#define OVERFLOW_Y_SHIFT 16
#define OVERFLOW_Y_MASK 0x70000
+static inline uint8_t get_overflow_y_bits(const css_computed_style *style)
+{
+ uint32_t bits = style->i.bits[OVERFLOW_Y_INDEX];
+ bits &= OVERFLOW_Y_MASK;
+ bits >>= OVERFLOW_Y_SHIFT;
+
+ /* 3bits: ttt : type */
+ return (bits & 0x7);
+}
static inline uint8_t get_overflow_y(const css_computed_style *style)
{
uint32_t bits = style->i.bits[OVERFLOW_Y_INDEX];
@@ -1623,6 +2348,15 @@ static inline uint8_t get_overflow_y(const css_computed_style *style)
#define PADDING_BOTTOM_INDEX 8
#define PADDING_BOTTOM_SHIFT 14
#define PADDING_BOTTOM_MASK 0xfc000
+static inline uint8_t get_padding_bottom_bits(const css_computed_style *style)
+{
+ uint32_t bits = style->i.bits[PADDING_BOTTOM_INDEX];
+ bits &= PADDING_BOTTOM_MASK;
+ bits >>= PADDING_BOTTOM_SHIFT;
+
+ /* 6bits: uuuuut : unit | type */
+ return (bits & 0x1);
+}
static inline uint8_t get_padding_bottom(const css_computed_style *style,
css_fixed *length, css_unit *unit)
{
@@ -1645,6 +2379,15 @@ static inline uint8_t get_padding_bottom(const css_computed_style *style,
#define PADDING_LEFT_INDEX 8
#define PADDING_LEFT_SHIFT 20
#define PADDING_LEFT_MASK 0x3f00000
+static inline uint8_t get_padding_left_bits(const css_computed_style *style)
+{
+ uint32_t bits = style->i.bits[PADDING_LEFT_INDEX];
+ bits &= PADDING_LEFT_MASK;
+ bits >>= PADDING_LEFT_SHIFT;
+
+ /* 6bits: uuuuut : unit | type */
+ return (bits & 0x1);
+}
static inline uint8_t get_padding_left(const css_computed_style *style,
css_fixed *length, css_unit *unit)
{
@@ -1667,6 +2410,15 @@ static inline uint8_t get_padding_left(const css_computed_style *style,
#define PADDING_RIGHT_INDEX 8
#define PADDING_RIGHT_SHIFT 26
#define PADDING_RIGHT_MASK 0xfc000000
+static inline uint8_t get_padding_right_bits(const css_computed_style *style)
+{
+ uint32_t bits = style->i.bits[PADDING_RIGHT_INDEX];
+ bits &= PADDING_RIGHT_MASK;
+ bits >>= PADDING_RIGHT_SHIFT;
+
+ /* 6bits: uuuuut : unit | type */
+ return (bits & 0x1);
+}
static inline uint8_t get_padding_right(const css_computed_style *style,
css_fixed *length, css_unit *unit)
{
@@ -1689,6 +2441,15 @@ static inline uint8_t get_padding_right(const css_computed_style *style,
#define PADDING_TOP_INDEX 3
#define PADDING_TOP_SHIFT 5
#define PADDING_TOP_MASK 0x7e0
+static inline uint8_t get_padding_top_bits(const css_computed_style *style)
+{
+ uint32_t bits = style->i.bits[PADDING_TOP_INDEX];
+ bits &= PADDING_TOP_MASK;
+ bits >>= PADDING_TOP_SHIFT;
+
+ /* 6bits: uuuuut : unit | type */
+ return (bits & 0x1);
+}
static inline uint8_t get_padding_top(const css_computed_style *style,
css_fixed *length, css_unit *unit)
{
@@ -1711,6 +2472,15 @@ static inline uint8_t get_padding_top(const css_computed_style *style,
#define PAGE_BREAK_AFTER_INDEX 13
#define PAGE_BREAK_AFTER_SHIFT 19
#define PAGE_BREAK_AFTER_MASK 0x380000
+static inline uint8_t get_page_break_after_bits(const css_computed_style *style)
+{
+ uint32_t bits = style->i.bits[PAGE_BREAK_AFTER_INDEX];
+ bits &= PAGE_BREAK_AFTER_MASK;
+ bits >>= PAGE_BREAK_AFTER_SHIFT;
+
+ /* 3bits: ttt : type */
+ return (bits & 0x7);
+}
static inline uint8_t get_page_break_after(const css_computed_style *style)
{
uint32_t bits = style->i.bits[PAGE_BREAK_AFTER_INDEX];
@@ -1728,6 +2498,16 @@ static inline uint8_t get_page_break_after(const css_computed_style *style)
#define PAGE_BREAK_BEFORE_INDEX 13
#define PAGE_BREAK_BEFORE_SHIFT 22
#define PAGE_BREAK_BEFORE_MASK 0x1c00000
+static inline uint8_t get_page_break_before_bits(const css_computed_style
+ *style)
+{
+ uint32_t bits = style->i.bits[PAGE_BREAK_BEFORE_INDEX];
+ bits &= PAGE_BREAK_BEFORE_MASK;
+ bits >>= PAGE_BREAK_BEFORE_SHIFT;
+
+ /* 3bits: ttt : type */
+ return (bits & 0x7);
+}
static inline uint8_t get_page_break_before(const css_computed_style *style)
{
uint32_t bits = style->i.bits[PAGE_BREAK_BEFORE_INDEX];
@@ -1745,6 +2525,16 @@ static inline uint8_t get_page_break_before(const css_computed_style *style)
#define PAGE_BREAK_INSIDE_INDEX 10
#define PAGE_BREAK_INSIDE_SHIFT 8
#define PAGE_BREAK_INSIDE_MASK 0x300
+static inline uint8_t get_page_break_inside_bits(const css_computed_style
+ *style)
+{
+ uint32_t bits = style->i.bits[PAGE_BREAK_INSIDE_INDEX];
+ bits &= PAGE_BREAK_INSIDE_MASK;
+ bits >>= PAGE_BREAK_INSIDE_SHIFT;
+
+ /* 2bits: tt : type */
+ return (bits & 0x3);
+}
static inline uint8_t get_page_break_inside(const css_computed_style *style)
{
uint32_t bits = style->i.bits[PAGE_BREAK_INSIDE_INDEX];
@@ -1762,6 +2552,15 @@ static inline uint8_t get_page_break_inside(const css_computed_style *style)
#define POSITION_INDEX 13
#define POSITION_SHIFT 25
#define POSITION_MASK 0xe000000
+static inline uint8_t get_position_bits(const css_computed_style *style)
+{
+ uint32_t bits = style->i.bits[POSITION_INDEX];
+ bits &= POSITION_MASK;
+ bits >>= POSITION_SHIFT;
+
+ /* 3bits: ttt : type */
+ return (bits & 0x7);
+}
static inline uint8_t get_position(const css_computed_style *style)
{
uint32_t bits = style->i.bits[POSITION_INDEX];
@@ -1779,6 +2578,15 @@ static inline uint8_t get_position(const css_computed_style *style)
#define QUOTES_INDEX 13
#define QUOTES_SHIFT 0
#define QUOTES_MASK 0x1
+static inline uint8_t get_quotes_bits(const css_computed_style *style)
+{
+ uint32_t bits = style->i.bits[QUOTES_INDEX];
+ bits &= QUOTES_MASK;
+ bits >>= QUOTES_SHIFT;
+
+ /* 1bit: t : type */
+ return (bits & 0x1);
+}
static inline uint8_t get_quotes(const css_computed_style *style, lwc_string
***string_arr)
{
@@ -1798,31 +2606,29 @@ static inline uint8_t get_quotes(const css_computed_style *style, lwc_string
#define RIGHT_INDEX 4
#define RIGHT_SHIFT 11
#define RIGHT_MASK 0x3f800
-static inline uint8_t get_right(
- const css_computed_style *style,
- css_fixed *length, css_unit *unit)
+static inline uint8_t get_right_bits(const css_computed_style *style)
{
uint32_t bits = style->i.bits[RIGHT_INDEX];
bits &= RIGHT_MASK;
bits >>= RIGHT_SHIFT;
-
- /* 7bits: uuuuutt : units | type */
- if ((bits & 0x3) == CSS_RIGHT_SET) {
- *length = style->i.right;
- *unit = bits >> 2;
- }
-
+
+ /* 7bits: uuuuutt : unit | type */
return (bits & 0x3);
}
-static inline uint8_t get_right_bits(
- const css_computed_style *style)
+static inline uint8_t get_right(const css_computed_style *style, css_fixed
+ *length, css_unit *unit)
{
uint32_t bits = style->i.bits[RIGHT_INDEX];
bits &= RIGHT_MASK;
bits >>= RIGHT_SHIFT;
-
- /* 7bits: uuuuutt : units | type */
- return bits;
+
+ /* 7bits: uuuuutt : unit | type */
+ if ((bits & 0x3) == CSS_RIGHT_SET) {
+ *length = style->i.right;
+ *unit = bits >> 2;
+ }
+
+ return (bits & 0x3);
}
#undef RIGHT_INDEX
#undef RIGHT_SHIFT
@@ -1831,6 +2637,15 @@ static inline uint8_t get_right_bits(
#define TABLE_LAYOUT_INDEX 10
#define TABLE_LAYOUT_SHIFT 10
#define TABLE_LAYOUT_MASK 0xc00
+static inline uint8_t get_table_layout_bits(const css_computed_style *style)
+{
+ uint32_t bits = style->i.bits[TABLE_LAYOUT_INDEX];
+ bits &= TABLE_LAYOUT_MASK;
+ bits >>= TABLE_LAYOUT_SHIFT;
+
+ /* 2bits: tt : type */
+ return (bits & 0x3);
+}
static inline uint8_t get_table_layout(const css_computed_style *style)
{
uint32_t bits = style->i.bits[TABLE_LAYOUT_INDEX];
@@ -1848,6 +2663,15 @@ static inline uint8_t get_table_layout(const css_computed_style *style)
#define TEXT_ALIGN_INDEX 4
#define TEXT_ALIGN_SHIFT 0
#define TEXT_ALIGN_MASK 0xf
+static inline uint8_t get_text_align_bits(const css_computed_style *style)
+{
+ uint32_t bits = style->i.bits[TEXT_ALIGN_INDEX];
+ bits &= TEXT_ALIGN_MASK;
+ bits >>= TEXT_ALIGN_SHIFT;
+
+ /* 4bits: tttt : type */
+ return (bits & 0xf);
+}
static inline uint8_t get_text_align(const css_computed_style *style)
{
uint32_t bits = style->i.bits[TEXT_ALIGN_INDEX];
@@ -1865,6 +2689,15 @@ static inline uint8_t get_text_align(const css_computed_style *style)
#define TEXT_DECORATION_INDEX 3
#define TEXT_DECORATION_SHIFT 0
#define TEXT_DECORATION_MASK 0x1f
+static inline uint8_t get_text_decoration_bits(const css_computed_style *style)
+{
+ uint32_t bits = style->i.bits[TEXT_DECORATION_INDEX];
+ bits &= TEXT_DECORATION_MASK;
+ bits >>= TEXT_DECORATION_SHIFT;
+
+ /* 5bits: ttttt : type */
+ return (bits & 0x1f);
+}
static inline uint8_t get_text_decoration(const css_computed_style *style)
{
uint32_t bits = style->i.bits[TEXT_DECORATION_INDEX];
@@ -1882,6 +2715,15 @@ static inline uint8_t get_text_decoration(const css_computed_style *style)
#define TEXT_INDENT_INDEX 2
#define TEXT_INDENT_SHIFT 0
#define TEXT_INDENT_MASK 0x3f
+static inline uint8_t get_text_indent_bits(const css_computed_style *style)
+{
+ uint32_t bits = style->i.bits[TEXT_INDENT_INDEX];
+ bits &= TEXT_INDENT_MASK;
+ bits >>= TEXT_INDENT_SHIFT;
+
+ /* 6bits: uuuuut : unit | type */
+ return (bits & 0x1);
+}
static inline uint8_t get_text_indent(const css_computed_style *style,
css_fixed *length, css_unit *unit)
{
@@ -1904,6 +2746,15 @@ static inline uint8_t get_text_indent(const css_computed_style *style,
#define TEXT_TRANSFORM_INDEX 9
#define TEXT_TRANSFORM_SHIFT 0
#define TEXT_TRANSFORM_MASK 0x7
+static inline uint8_t get_text_transform_bits(const css_computed_style *style)
+{
+ uint32_t bits = style->i.bits[TEXT_TRANSFORM_INDEX];
+ bits &= TEXT_TRANSFORM_MASK;
+ bits >>= TEXT_TRANSFORM_SHIFT;
+
+ /* 3bits: ttt : type */
+ return (bits & 0x7);
+}
static inline uint8_t get_text_transform(const css_computed_style *style)
{
uint32_t bits = style->i.bits[TEXT_TRANSFORM_INDEX];
@@ -1921,31 +2772,29 @@ static inline uint8_t get_text_transform(const css_computed_style *style)
#define TOP_INDEX 4
#define TOP_SHIFT 18
#define TOP_MASK 0x1fc0000
-static inline uint8_t get_top(
- const css_computed_style *style,
- css_fixed *length, css_unit *unit)
+static inline uint8_t get_top_bits(const css_computed_style *style)
{
uint32_t bits = style->i.bits[TOP_INDEX];
bits &= TOP_MASK;
bits >>= TOP_SHIFT;
-
- /* 7bits: uuuuutt : units | type */
- if ((bits & 0x3) == CSS_TOP_SET) {
- *length = style->i.top;
- *unit = bits >> 2;
- }
-
+
+ /* 7bits: uuuuutt : unit | type */
return (bits & 0x3);
}
-static inline uint8_t get_top_bits(
- const css_computed_style *style)
+static inline uint8_t get_top(const css_computed_style *style, css_fixed
+ *length, css_unit *unit)
{
uint32_t bits = style->i.bits[TOP_INDEX];
bits &= TOP_MASK;
bits >>= TOP_SHIFT;
-
- /* 7bits: uuuuutt : units | type */
- return bits;
+
+ /* 7bits: uuuuutt : unit | type */
+ if ((bits & 0x3) == CSS_TOP_SET) {
+ *length = style->i.top;
+ *unit = bits >> 2;
+ }
+
+ return (bits & 0x3);
}
#undef TOP_INDEX
#undef TOP_SHIFT
@@ -1954,6 +2803,15 @@ static inline uint8_t get_top_bits(
#define UNICODE_BIDI_INDEX 10
#define UNICODE_BIDI_SHIFT 12
#define UNICODE_BIDI_MASK 0x3000
+static inline uint8_t get_unicode_bidi_bits(const css_computed_style *style)
+{
+ uint32_t bits = style->i.bits[UNICODE_BIDI_INDEX];
+ bits &= UNICODE_BIDI_MASK;
+ bits >>= UNICODE_BIDI_SHIFT;
+
+ /* 2bits: tt : type */
+ return (bits & 0x3);
+}
static inline uint8_t get_unicode_bidi(const css_computed_style *style)
{
uint32_t bits = style->i.bits[UNICODE_BIDI_INDEX];
@@ -1971,6 +2829,15 @@ static inline uint8_t get_unicode_bidi(const css_computed_style *style)
#define VERTICAL_ALIGN_INDEX 12
#define VERTICAL_ALIGN_SHIFT 1
#define VERTICAL_ALIGN_MASK 0x3fe
+static inline uint8_t get_vertical_align_bits(const css_computed_style *style)
+{
+ uint32_t bits = style->i.bits[VERTICAL_ALIGN_INDEX];
+ bits &= VERTICAL_ALIGN_MASK;
+ bits >>= VERTICAL_ALIGN_SHIFT;
+
+ /* 9bits: uuuuutttt : unit | type */
+ return (bits & 0xf);
+}
static inline uint8_t get_vertical_align(const css_computed_style *style,
css_fixed *length, css_unit *unit)
{
@@ -1993,6 +2860,15 @@ static inline uint8_t get_vertical_align(const css_computed_style *style,
#define VISIBILITY_INDEX 10
#define VISIBILITY_SHIFT 14
#define VISIBILITY_MASK 0xc000
+static inline uint8_t get_visibility_bits(const css_computed_style *style)
+{
+ uint32_t bits = style->i.bits[VISIBILITY_INDEX];
+ bits &= VISIBILITY_MASK;
+ bits >>= VISIBILITY_SHIFT;
+
+ /* 2bits: tt : type */
+ return (bits & 0x3);
+}
static inline uint8_t get_visibility(const css_computed_style *style)
{
uint32_t bits = style->i.bits[VISIBILITY_INDEX];
@@ -2010,6 +2886,15 @@ static inline uint8_t get_visibility(const css_computed_style *style)
#define WHITE_SPACE_INDEX 8
#define WHITE_SPACE_SHIFT 0
#define WHITE_SPACE_MASK 0x7
+static inline uint8_t get_white_space_bits(const css_computed_style *style)
+{
+ uint32_t bits = style->i.bits[WHITE_SPACE_INDEX];
+ bits &= WHITE_SPACE_MASK;
+ bits >>= WHITE_SPACE_SHIFT;
+
+ /* 3bits: ttt : type */
+ return (bits & 0x7);
+}
static inline uint8_t get_white_space(const css_computed_style *style)
{
uint32_t bits = style->i.bits[WHITE_SPACE_INDEX];
@@ -2027,6 +2912,15 @@ static inline uint8_t get_white_space(const css_computed_style *style)
#define WIDOWS_INDEX 12
#define WIDOWS_SHIFT 0
#define WIDOWS_MASK 0x1
+static inline uint8_t get_widows_bits(const css_computed_style *style)
+{
+ uint32_t bits = style->i.bits[WIDOWS_INDEX];
+ bits &= WIDOWS_MASK;
+ bits >>= WIDOWS_SHIFT;
+
+ /* 1bit: t : type */
+ return (bits & 0x1);
+}
static inline uint8_t get_widows(const css_computed_style *style, int32_t
*integer)
{
@@ -2046,6 +2940,15 @@ static inline uint8_t get_widows(const css_computed_style *style, int32_t
#define WIDTH_INDEX 4
#define WIDTH_SHIFT 25
#define WIDTH_MASK 0xfe000000
+static inline uint8_t get_width_bits(const css_computed_style *style)
+{
+ uint32_t bits = style->i.bits[WIDTH_INDEX];
+ bits &= WIDTH_MASK;
+ bits >>= WIDTH_SHIFT;
+
+ /* 7bits: uuuuutt : unit | type */
+ return (bits & 0x3);
+}
static inline uint8_t get_width(const css_computed_style *style, css_fixed
*length, css_unit *unit)
{
@@ -2068,6 +2971,15 @@ static inline uint8_t get_width(const css_computed_style *style, css_fixed
#define WORD_SPACING_INDEX 1
#define WORD_SPACING_SHIFT 0
#define WORD_SPACING_MASK 0x7f
+static inline uint8_t get_word_spacing_bits(const css_computed_style *style)
+{
+ uint32_t bits = style->i.bits[WORD_SPACING_INDEX];
+ bits &= WORD_SPACING_MASK;
+ bits >>= WORD_SPACING_SHIFT;
+
+ /* 7bits: uuuuutt : unit | type */
+ return (bits & 0x3);
+}
static inline uint8_t get_word_spacing(const css_computed_style *style,
css_fixed *length, css_unit *unit)
{
@@ -2090,6 +3002,15 @@ static inline uint8_t get_word_spacing(const css_computed_style *style,
#define WRITING_MODE_INDEX 10
#define WRITING_MODE_SHIFT 16
#define WRITING_MODE_MASK 0x30000
+static inline uint8_t get_writing_mode_bits(const css_computed_style *style)
+{
+ uint32_t bits = style->i.bits[WRITING_MODE_INDEX];
+ bits &= WRITING_MODE_MASK;
+ bits >>= WRITING_MODE_SHIFT;
+
+ /* 2bits: tt : type */
+ return (bits & 0x3);
+}
static inline uint8_t get_writing_mode(const css_computed_style *style)
{
uint32_t bits = style->i.bits[WRITING_MODE_INDEX];
@@ -2107,6 +3028,15 @@ static inline uint8_t get_writing_mode(const css_computed_style *style)
#define Z_INDEX_INDEX 10
#define Z_INDEX_SHIFT 18
#define Z_INDEX_MASK 0xc0000
+static inline uint8_t get_z_index_bits(const css_computed_style *style)
+{
+ uint32_t bits = style->i.bits[Z_INDEX_INDEX];
+ bits &= Z_INDEX_MASK;
+ bits >>= Z_INDEX_SHIFT;
+
+ /* 2bits: tt : type */
+ return (bits & 0x3);
+}
static inline uint8_t get_z_index(const css_computed_style *style, int32_t
*integer)
{
diff --git a/src/select/overrides.py b/src/select/overrides.py
index b4d349a..869d6ec 100644
--- a/src/select/overrides.py
+++ b/src/select/overrides.py
@@ -183,35 +183,3 @@ static inline css_error set_content(
return CSS_OK;
}'''
-
-get_side = '''\
-static inline uint8_t get_{0}(
- const css_computed_style *style,
- css_fixed *length, css_unit *unit)
-{{
- uint32_t bits = style->i.bits[{1}_INDEX];
- bits &= {1}_MASK;
- bits >>= {1}_SHIFT;
-
- /* 7bits: uuuuutt : units | type */
- if ((bits & 0x3) == CSS_{1}_SET) {{
- *length = style->i.{0};
- *unit = bits >> 2;
- }}
-
- return (bits & 0x3);
-}}
-static inline uint8_t get_{0}_bits(
- const css_computed_style *style)
-{{
- uint32_t bits = style->i.bits[{1}_INDEX];
- bits &= {1}_MASK;
- bits >>= {1}_SHIFT;
-
- /* 7bits: uuuuutt : units | type */
- return bits;
-}}'''
-overrides['get']['top'] = get_side.format('top', 'TOP')
-overrides['get']['right'] = get_side.format('right', 'RIGHT')
-overrides['get']['bottom'] = get_side.format('bottom', 'BOTTOM')
-overrides['get']['left'] = get_side.format('left', 'LEFT')
diff --git a/src/select/select_generator.py b/src/select/select_generator.py
index dcb0429..05a4511 100644
--- a/src/select/select_generator.py
+++ b/src/select/select_generator.py
@@ -707,14 +707,15 @@ class CSSGroup:
return t.to_string()
- def print_propget(self, t, p):
+ def print_propget(self, t, p, only_bits=False):
i_dot, grp = self.get_idot_grp()
- vals = p.get_param_values(pointer=True)
+ vals = [] if only_bits else p.get_param_values(pointer=True)
params = ', '.join([ 'css_computed_style *style' ]
+ [ ' '.join(x) for x in vals ])
- t.append('static inline uint8_t get_{}(const {})'.format(
- p.name, params))
+ 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)
@@ -731,27 +732,29 @@ class CSSGroup:
type_mask, shift_list, bits_comment = p.get_bits()
t.append(bits_comment)
- if p.condition:
- t.append('if ((bits & {}) == {}) {{'.format(
- type_mask, p.condition))
- t.indent(1)
+ if only_bits == False:
- for v in p.values:
- this_idot = '' if v.is_ptr and v.name != 'string' else i_dot
- t.append('*{} = style{}->{}{};'.format(
- v.name + v.suffix, grp, this_idot, p.name + v.suffix))
- for i, v in enumerate(list(reversed(shift_list))):
- if i == 0:
- t.append('*{} = bits >> {};'.format(v[0], v[1]))
- else:
- t.append('*{} = (bits & 0x{:x}) >> {};'.format(
- v[0], v[2], v[1]).lower())
+ if p.condition:
+ t.append('if ((bits & {}) == {}) {{'.format(
+ type_mask, p.condition))
+ t.indent(1)
- if p.condition:
- t.indent(-1)
- t.append('}')
+ for v in p.values:
+ this_idot = '' if v.is_ptr and v.name != 'string' else i_dot
+ t.append('*{} = style{}->{}{};'.format(
+ v.name + v.suffix, grp, this_idot, p.name + v.suffix))
+ for i, v in enumerate(list(reversed(shift_list))):
+ if i == 0:
+ t.append('*{} = bits >> {};'.format(v[0], v[1]))
+ else:
+ t.append('*{} = (bits & 0x{:x}) >> {};'.format(
+ v[0], v[2], v[1]).lower())
+
+ if p.condition:
+ t.indent(-1)
+ t.append('}')
+ t.append()
- t.append()
t.append('return (bits & {});'.format(type_mask))
if self.name != 'style':
@@ -779,6 +782,8 @@ class CSSGroup:
t.append()
t.append(defines)
+ self.print_propget(t, p, True)
+
if p.name in overrides['get']:
t.append(overrides['get'][p.name], pre_formatted=True)
else:
commitdiff http://git.netsurf-browser.org/libcss.git/commit/?id=609e1623335d5d514743...
commit 609e1623335d5d5147439c5ba600152e963fc951
Author: Michael Drake <tlsa(a)netsurf-browser.org>
Commit: Michael Drake <mdrake.unique(a)gmail.com>
select: generator: Split out propget printer
diff --git a/src/select/select_generator.py b/src/select/select_generator.py
index ece7a91..dcb0429 100644
--- a/src/select/select_generator.py
+++ b/src/select/select_generator.py
@@ -707,80 +707,83 @@ class CSSGroup:
return t.to_string()
- def make_propget_h(self):
- """Output this group's property functions for the propget.h file."""
- t = Text()
+ def print_propget(self, t, p):
i_dot, grp = self.get_idot_grp()
- for p in sorted(self.props, key=(lambda x: x.name)):
- defines, undefs = p.def_undefs
+ vals = p.get_param_values(pointer=True)
+ params = ', '.join([ 'css_computed_style *style' ]
+ + [ ' '.join(x) for x in vals ])
+ t.append('static inline uint8_t get_{}(const {})'.format(
+ p.name, params))
+ t.append('{')
+ t.indent(1)
- t.append()
- t.append(defines)
+ if self.name != 'style':
+ t.append('if (style{} != NULL) {{'.format(grp))
+ t.indent(1)
- if p.name in overrides['get']:
- t.append(overrides['get'][p.name], pre_formatted=True)
- t.append(undefs)
- continue
+ t.append('uint32_t bits = style{}->{}bits[{}_INDEX];'.format(
+ grp, i_dot, p.name.upper()))
+ t.append('bits &= {}_MASK;'.format(p.name.upper()))
+ t.append('bits >>= {}_SHIFT;'.format(p.name.upper()))
+ t.append()
- vals = p.get_param_values(pointer=True)
- params = ', '.join([ 'css_computed_style *style' ]
- + [ ' '.join(x) for x in vals ])
- t.append('static inline uint8_t get_{}(const {})'.format(
- p.name, params))
- t.append('{')
- t.indent(1)
+ type_mask, shift_list, bits_comment = p.get_bits()
+ t.append(bits_comment)
- if self.name != 'style':
- t.append('if (style{} != NULL) {{'.format(grp))
- t.indent(1)
+ if p.condition:
+ t.append('if ((bits & {}) == {}) {{'.format(
+ type_mask, p.condition))
+ t.indent(1)
- t.append('uint32_t bits = style{}->{}bits[{}_INDEX];'.format(
- grp, i_dot, p.name.upper()))
- t.append('bits &= {}_MASK;'.format(p.name.upper()))
- t.append('bits >>= {}_SHIFT;'.format(p.name.upper()))
- t.append()
+ for v in p.values:
+ this_idot = '' if v.is_ptr and v.name != 'string' else i_dot
+ t.append('*{} = style{}->{}{};'.format(
+ v.name + v.suffix, grp, this_idot, p.name + v.suffix))
+ for i, v in enumerate(list(reversed(shift_list))):
+ if i == 0:
+ t.append('*{} = bits >> {};'.format(v[0], v[1]))
+ else:
+ t.append('*{} = (bits & 0x{:x}) >> {};'.format(
+ v[0], v[2], v[1]).lower())
- type_mask, shift_list, bits_comment = p.get_bits()
- t.append(bits_comment)
+ if p.condition:
+ t.indent(-1)
+ t.append('}')
- if p.condition:
- t.append('if ((bits & {}) == {}) {{'.format(
- type_mask, p.condition))
- t.indent(1)
+ t.append()
+ 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:
- this_idot = '' if v.is_ptr and v.name != 'string' else i_dot
- t.append('*{} = style{}->{}{};'.format(
- v.name + v.suffix, grp, this_idot, p.name + v.suffix))
- for i, v in enumerate(list(reversed(shift_list))):
- if i == 0:
- t.append('*{} = bits >> {};'.format(v[0], v[1]))
- else:
- t.append('*{} = (bits & 0x{:x}) >> {};'.format(
- v[0], v[2], v[1]).lower())
+ 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))
- if p.condition:
- t.indent(-1)
- t.append('}')
+ t.indent(-1)
+ t.append('}')
+
+ def make_propget_h(self):
+ """Output this group's property functions for the propget.h file."""
+ t = Text()
+
+ for p in sorted(self.props, key=(lambda x: x.name)):
+ defines, undefs = p.def_undefs
t.append()
- t.append('return (bits & {});'.format(type_mask))
+ t.append(defines)
- 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))
+ if p.name in overrides['get']:
+ t.append(overrides['get'][p.name], pre_formatted=True)
+ else:
+ self.print_propget(t, p)
- t.indent(-1)
- t.append('}')
t.append(undefs)
return t.to_string()
-----------------------------------------------------------------------
Summary of changes:
src/select/autogenerated_propget.h | 1070 +++++++++++++++++++++++++++++++++---
src/select/overrides.py | 32 --
src/select/select_generator.py | 92 ++--
3 files changed, 1050 insertions(+), 144 deletions(-)
diff --git a/src/select/autogenerated_propget.h b/src/select/autogenerated_propget.h
index cf82c86..6c958aa 100644
--- a/src/select/autogenerated_propget.h
+++ b/src/select/autogenerated_propget.h
@@ -9,6 +9,15 @@
#define ALIGN_CONTENT_INDEX 10
#define ALIGN_CONTENT_SHIFT 20
#define ALIGN_CONTENT_MASK 0x700000
+static inline uint8_t get_align_content_bits(const css_computed_style *style)
+{
+ uint32_t bits = style->i.bits[ALIGN_CONTENT_INDEX];
+ bits &= ALIGN_CONTENT_MASK;
+ bits >>= ALIGN_CONTENT_SHIFT;
+
+ /* 3bits: ttt : type */
+ return (bits & 0x7);
+}
static inline uint8_t get_align_content(const css_computed_style *style)
{
uint32_t bits = style->i.bits[ALIGN_CONTENT_INDEX];
@@ -26,6 +35,15 @@ static inline uint8_t get_align_content(const css_computed_style *style)
#define ALIGN_ITEMS_INDEX 10
#define ALIGN_ITEMS_SHIFT 23
#define ALIGN_ITEMS_MASK 0x3800000
+static inline uint8_t get_align_items_bits(const css_computed_style *style)
+{
+ uint32_t bits = style->i.bits[ALIGN_ITEMS_INDEX];
+ bits &= ALIGN_ITEMS_MASK;
+ bits >>= ALIGN_ITEMS_SHIFT;
+
+ /* 3bits: ttt : type */
+ return (bits & 0x7);
+}
static inline uint8_t get_align_items(const css_computed_style *style)
{
uint32_t bits = style->i.bits[ALIGN_ITEMS_INDEX];
@@ -43,6 +61,15 @@ static inline uint8_t get_align_items(const css_computed_style *style)
#define ALIGN_SELF_INDEX 10
#define ALIGN_SELF_SHIFT 26
#define ALIGN_SELF_MASK 0x1c000000
+static inline uint8_t get_align_self_bits(const css_computed_style *style)
+{
+ uint32_t bits = style->i.bits[ALIGN_SELF_INDEX];
+ bits &= ALIGN_SELF_MASK;
+ bits >>= ALIGN_SELF_SHIFT;
+
+ /* 3bits: ttt : type */
+ return (bits & 0x7);
+}
static inline uint8_t get_align_self(const css_computed_style *style)
{
uint32_t bits = style->i.bits[ALIGN_SELF_INDEX];
@@ -60,6 +87,16 @@ static inline uint8_t get_align_self(const css_computed_style *style)
#define BACKGROUND_ATTACHMENT_INDEX 14
#define BACKGROUND_ATTACHMENT_SHIFT 28
#define BACKGROUND_ATTACHMENT_MASK 0x30000000
+static inline uint8_t get_background_attachment_bits(const css_computed_style
+ *style)
+{
+ uint32_t bits = style->i.bits[BACKGROUND_ATTACHMENT_INDEX];
+ bits &= BACKGROUND_ATTACHMENT_MASK;
+ bits >>= BACKGROUND_ATTACHMENT_SHIFT;
+
+ /* 2bits: tt : type */
+ return (bits & 0x3);
+}
static inline uint8_t get_background_attachment(const css_computed_style *style)
{
uint32_t bits = style->i.bits[BACKGROUND_ATTACHMENT_INDEX];
@@ -77,6 +114,15 @@ static inline uint8_t get_background_attachment(const css_computed_style *style)
#define BACKGROUND_COLOR_INDEX 14
#define BACKGROUND_COLOR_SHIFT 30
#define BACKGROUND_COLOR_MASK 0xc0000000
+static inline uint8_t get_background_color_bits(const css_computed_style *style)
+{
+ uint32_t bits = style->i.bits[BACKGROUND_COLOR_INDEX];
+ bits &= BACKGROUND_COLOR_MASK;
+ bits >>= BACKGROUND_COLOR_SHIFT;
+
+ /* 2bits: tt : type */
+ return (bits & 0x3);
+}
static inline uint8_t get_background_color(const css_computed_style *style,
css_color *color)
{
@@ -96,6 +142,15 @@ static inline uint8_t get_background_color(const css_computed_style *style,
#define BACKGROUND_IMAGE_INDEX 14
#define BACKGROUND_IMAGE_SHIFT 18
#define BACKGROUND_IMAGE_MASK 0x40000
+static inline uint8_t get_background_image_bits(const css_computed_style *style)
+{
+ uint32_t bits = style->i.bits[BACKGROUND_IMAGE_INDEX];
+ bits &= BACKGROUND_IMAGE_MASK;
+ bits >>= BACKGROUND_IMAGE_SHIFT;
+
+ /* 1bit: t : type */
+ return (bits & 0x1);
+}
static inline uint8_t get_background_image(const css_computed_style *style,
lwc_string **string)
{
@@ -115,6 +170,16 @@ static inline uint8_t get_background_image(const css_computed_style *style,
#define BACKGROUND_POSITION_INDEX 12
#define BACKGROUND_POSITION_SHIFT 10
#define BACKGROUND_POSITION_MASK 0x1ffc00
+static inline uint8_t get_background_position_bits(const css_computed_style
+ *style)
+{
+ uint32_t bits = style->i.bits[BACKGROUND_POSITION_INDEX];
+ bits &= BACKGROUND_POSITION_MASK;
+ bits >>= BACKGROUND_POSITION_SHIFT;
+
+ /* 11bits: aaaaabbbbbt : unit_a | unit_b | type */
+ return (bits & 0x1);
+}
static inline uint8_t get_background_position(const css_computed_style *style,
css_fixed *length_a, css_unit *unit_a, css_fixed *length_b,
css_unit *unit_b)
@@ -140,6 +205,16 @@ static inline uint8_t get_background_position(const css_computed_style *style,
#define BACKGROUND_REPEAT_INDEX 10
#define BACKGROUND_REPEAT_SHIFT 29
#define BACKGROUND_REPEAT_MASK 0xe0000000
+static inline uint8_t get_background_repeat_bits(const css_computed_style
+ *style)
+{
+ uint32_t bits = style->i.bits[BACKGROUND_REPEAT_INDEX];
+ bits &= BACKGROUND_REPEAT_MASK;
+ bits >>= BACKGROUND_REPEAT_SHIFT;
+
+ /* 3bits: ttt : type */
+ return (bits & 0x7);
+}
static inline uint8_t get_background_repeat(const css_computed_style *style)
{
uint32_t bits = style->i.bits[BACKGROUND_REPEAT_INDEX];
@@ -157,6 +232,16 @@ static inline uint8_t get_background_repeat(const css_computed_style *style)
#define BORDER_BOTTOM_COLOR_INDEX 11
#define BORDER_BOTTOM_COLOR_SHIFT 0
#define BORDER_BOTTOM_COLOR_MASK 0x3
+static inline uint8_t get_border_bottom_color_bits(const css_computed_style
+ *style)
+{
+ uint32_t bits = style->i.bits[BORDER_BOTTOM_COLOR_INDEX];
+ bits &= BORDER_BOTTOM_COLOR_MASK;
+ bits >>= BORDER_BOTTOM_COLOR_SHIFT;
+
+ /* 2bits: tt : type */
+ return (bits & 0x3);
+}
static inline uint8_t get_border_bottom_color(const css_computed_style *style,
css_color *color)
{
@@ -176,6 +261,16 @@ static inline uint8_t get_border_bottom_color(const css_computed_style *style,
#define BORDER_BOTTOM_STYLE_INDEX 13
#define BORDER_BOTTOM_STYLE_SHIFT 28
#define BORDER_BOTTOM_STYLE_MASK 0xf0000000
+static inline uint8_t get_border_bottom_style_bits(const css_computed_style
+ *style)
+{
+ uint32_t bits = style->i.bits[BORDER_BOTTOM_STYLE_INDEX];
+ bits &= BORDER_BOTTOM_STYLE_MASK;
+ bits >>= BORDER_BOTTOM_STYLE_SHIFT;
+
+ /* 4bits: tttt : type */
+ return (bits & 0xf);
+}
static inline uint8_t get_border_bottom_style(const css_computed_style *style)
{
uint32_t bits = style->i.bits[BORDER_BOTTOM_STYLE_INDEX];
@@ -193,6 +288,16 @@ static inline uint8_t get_border_bottom_style(const css_computed_style *style)
#define BORDER_BOTTOM_WIDTH_INDEX 0
#define BORDER_BOTTOM_WIDTH_SHIFT 0
#define BORDER_BOTTOM_WIDTH_MASK 0xff
+static inline uint8_t get_border_bottom_width_bits(const css_computed_style
+ *style)
+{
+ uint32_t bits = style->i.bits[BORDER_BOTTOM_WIDTH_INDEX];
+ bits &= BORDER_BOTTOM_WIDTH_MASK;
+ bits >>= BORDER_BOTTOM_WIDTH_SHIFT;
+
+ /* 8bits: uuuuuttt : unit | type */
+ return (bits & 0x7);
+}
static inline uint8_t get_border_bottom_width(const css_computed_style *style,
css_fixed *length, css_unit *unit)
{
@@ -215,6 +320,15 @@ static inline uint8_t get_border_bottom_width(const css_computed_style *style,
#define BORDER_COLLAPSE_INDEX 11
#define BORDER_COLLAPSE_SHIFT 2
#define BORDER_COLLAPSE_MASK 0xc
+static inline uint8_t get_border_collapse_bits(const css_computed_style *style)
+{
+ uint32_t bits = style->i.bits[BORDER_COLLAPSE_INDEX];
+ bits &= BORDER_COLLAPSE_MASK;
+ bits >>= BORDER_COLLAPSE_SHIFT;
+
+ /* 2bits: tt : type */
+ return (bits & 0x3);
+}
static inline uint8_t get_border_collapse(const css_computed_style *style)
{
uint32_t bits = style->i.bits[BORDER_COLLAPSE_INDEX];
@@ -232,6 +346,16 @@ static inline uint8_t get_border_collapse(const css_computed_style *style)
#define BORDER_LEFT_COLOR_INDEX 11
#define BORDER_LEFT_COLOR_SHIFT 4
#define BORDER_LEFT_COLOR_MASK 0x30
+static inline uint8_t get_border_left_color_bits(const css_computed_style
+ *style)
+{
+ uint32_t bits = style->i.bits[BORDER_LEFT_COLOR_INDEX];
+ bits &= BORDER_LEFT_COLOR_MASK;
+ bits >>= BORDER_LEFT_COLOR_SHIFT;
+
+ /* 2bits: tt : type */
+ return (bits & 0x3);
+}
static inline uint8_t get_border_left_color(const css_computed_style *style,
css_color *color)
{
@@ -251,6 +375,16 @@ static inline uint8_t get_border_left_color(const css_computed_style *style,
#define BORDER_LEFT_STYLE_INDEX 9
#define BORDER_LEFT_STYLE_SHIFT 3
#define BORDER_LEFT_STYLE_MASK 0x78
+static inline uint8_t get_border_left_style_bits(const css_computed_style
+ *style)
+{
+ uint32_t bits = style->i.bits[BORDER_LEFT_STYLE_INDEX];
+ bits &= BORDER_LEFT_STYLE_MASK;
+ bits >>= BORDER_LEFT_STYLE_SHIFT;
+
+ /* 4bits: tttt : type */
+ return (bits & 0xf);
+}
static inline uint8_t get_border_left_style(const css_computed_style *style)
{
uint32_t bits = style->i.bits[BORDER_LEFT_STYLE_INDEX];
@@ -268,6 +402,16 @@ static inline uint8_t get_border_left_style(const css_computed_style *style)
#define BORDER_LEFT_WIDTH_INDEX 0
#define BORDER_LEFT_WIDTH_SHIFT 8
#define BORDER_LEFT_WIDTH_MASK 0xff00
+static inline uint8_t get_border_left_width_bits(const css_computed_style
+ *style)
+{
+ uint32_t bits = style->i.bits[BORDER_LEFT_WIDTH_INDEX];
+ bits &= BORDER_LEFT_WIDTH_MASK;
+ bits >>= BORDER_LEFT_WIDTH_SHIFT;
+
+ /* 8bits: uuuuuttt : unit | type */
+ return (bits & 0x7);
+}
static inline uint8_t get_border_left_width(const css_computed_style *style,
css_fixed *length, css_unit *unit)
{
@@ -290,6 +434,16 @@ static inline uint8_t get_border_left_width(const css_computed_style *style,
#define BORDER_RIGHT_COLOR_INDEX 11
#define BORDER_RIGHT_COLOR_SHIFT 6
#define BORDER_RIGHT_COLOR_MASK 0xc0
+static inline uint8_t get_border_right_color_bits(const css_computed_style
+ *style)
+{
+ uint32_t bits = style->i.bits[BORDER_RIGHT_COLOR_INDEX];
+ bits &= BORDER_RIGHT_COLOR_MASK;
+ bits >>= BORDER_RIGHT_COLOR_SHIFT;
+
+ /* 2bits: tt : type */
+ return (bits & 0x3);
+}
static inline uint8_t get_border_right_color(const css_computed_style *style,
css_color *color)
{
@@ -309,6 +463,16 @@ static inline uint8_t get_border_right_color(const css_computed_style *style,
#define BORDER_RIGHT_STYLE_INDEX 9
#define BORDER_RIGHT_STYLE_SHIFT 7
#define BORDER_RIGHT_STYLE_MASK 0x780
+static inline uint8_t get_border_right_style_bits(const css_computed_style
+ *style)
+{
+ uint32_t bits = style->i.bits[BORDER_RIGHT_STYLE_INDEX];
+ bits &= BORDER_RIGHT_STYLE_MASK;
+ bits >>= BORDER_RIGHT_STYLE_SHIFT;
+
+ /* 4bits: tttt : type */
+ return (bits & 0xf);
+}
static inline uint8_t get_border_right_style(const css_computed_style *style)
{
uint32_t bits = style->i.bits[BORDER_RIGHT_STYLE_INDEX];
@@ -326,6 +490,16 @@ static inline uint8_t get_border_right_style(const css_computed_style *style)
#define BORDER_RIGHT_WIDTH_INDEX 0
#define BORDER_RIGHT_WIDTH_SHIFT 16
#define BORDER_RIGHT_WIDTH_MASK 0xff0000
+static inline uint8_t get_border_right_width_bits(const css_computed_style
+ *style)
+{
+ uint32_t bits = style->i.bits[BORDER_RIGHT_WIDTH_INDEX];
+ bits &= BORDER_RIGHT_WIDTH_MASK;
+ bits >>= BORDER_RIGHT_WIDTH_SHIFT;
+
+ /* 8bits: uuuuuttt : unit | type */
+ return (bits & 0x7);
+}
static inline uint8_t get_border_right_width(const css_computed_style *style,
css_fixed *length, css_unit *unit)
{
@@ -348,6 +522,15 @@ static inline uint8_t get_border_right_width(const css_computed_style *style,
#define BORDER_SPACING_INDEX 12
#define BORDER_SPACING_SHIFT 21
#define BORDER_SPACING_MASK 0xffe00000
+static inline uint8_t get_border_spacing_bits(const css_computed_style *style)
+{
+ uint32_t bits = style->i.bits[BORDER_SPACING_INDEX];
+ bits &= BORDER_SPACING_MASK;
+ bits >>= BORDER_SPACING_SHIFT;
+
+ /* 11bits: aaaaabbbbbt : unit_a | unit_b | type */
+ return (bits & 0x1);
+}
static inline uint8_t get_border_spacing(const css_computed_style *style,
css_fixed *length_a, css_unit *unit_a, css_fixed *length_b,
css_unit *unit_b)
@@ -373,6 +556,15 @@ static inline uint8_t get_border_spacing(const css_computed_style *style,
#define BORDER_TOP_COLOR_INDEX 11
#define BORDER_TOP_COLOR_SHIFT 8
#define BORDER_TOP_COLOR_MASK 0x300
+static inline uint8_t get_border_top_color_bits(const css_computed_style *style)
+{
+ uint32_t bits = style->i.bits[BORDER_TOP_COLOR_INDEX];
+ bits &= BORDER_TOP_COLOR_MASK;
+ bits >>= BORDER_TOP_COLOR_SHIFT;
+
+ /* 2bits: tt : type */
+ return (bits & 0x3);
+}
static inline uint8_t get_border_top_color(const css_computed_style *style,
css_color *color)
{
@@ -392,6 +584,15 @@ static inline uint8_t get_border_top_color(const css_computed_style *style,
#define BORDER_TOP_STYLE_INDEX 9
#define BORDER_TOP_STYLE_SHIFT 11
#define BORDER_TOP_STYLE_MASK 0x7800
+static inline uint8_t get_border_top_style_bits(const css_computed_style *style)
+{
+ uint32_t bits = style->i.bits[BORDER_TOP_STYLE_INDEX];
+ bits &= BORDER_TOP_STYLE_MASK;
+ bits >>= BORDER_TOP_STYLE_SHIFT;
+
+ /* 4bits: tttt : type */
+ return (bits & 0xf);
+}
static inline uint8_t get_border_top_style(const css_computed_style *style)
{
uint32_t bits = style->i.bits[BORDER_TOP_STYLE_INDEX];
@@ -409,6 +610,15 @@ static inline uint8_t get_border_top_style(const css_computed_style *style)
#define BORDER_TOP_WIDTH_INDEX 0
#define BORDER_TOP_WIDTH_SHIFT 24
#define BORDER_TOP_WIDTH_MASK 0xff000000
+static inline uint8_t get_border_top_width_bits(const css_computed_style *style)
+{
+ uint32_t bits = style->i.bits[BORDER_TOP_WIDTH_INDEX];
+ bits &= BORDER_TOP_WIDTH_MASK;
+ bits >>= BORDER_TOP_WIDTH_SHIFT;
+
+ /* 8bits: uuuuuttt : unit | type */
+ return (bits & 0x7);
+}
static inline uint8_t get_border_top_width(const css_computed_style *style,
css_fixed *length, css_unit *unit)
{
@@ -431,31 +641,29 @@ static inline uint8_t get_border_top_width(const css_computed_style *style,
#define BOTTOM_INDEX 3
#define BOTTOM_SHIFT 11
#define BOTTOM_MASK 0x3f800
-static inline uint8_t get_bottom(
- const css_computed_style *style,
- css_fixed *length, css_unit *unit)
+static inline uint8_t get_bottom_bits(const css_computed_style *style)
{
uint32_t bits = style->i.bits[BOTTOM_INDEX];
bits &= BOTTOM_MASK;
bits >>= BOTTOM_SHIFT;
-
- /* 7bits: uuuuutt : units | type */
- if ((bits & 0x3) == CSS_BOTTOM_SET) {
- *length = style->i.bottom;
- *unit = bits >> 2;
- }
-
+
+ /* 7bits: uuuuutt : unit | type */
return (bits & 0x3);
}
-static inline uint8_t get_bottom_bits(
- const css_computed_style *style)
+static inline uint8_t get_bottom(const css_computed_style *style, css_fixed
+ *length, css_unit *unit)
{
uint32_t bits = style->i.bits[BOTTOM_INDEX];
bits &= BOTTOM_MASK;
bits >>= BOTTOM_SHIFT;
-
- /* 7bits: uuuuutt : units | type */
- return bits;
+
+ /* 7bits: uuuuutt : unit | type */
+ if ((bits & 0x3) == CSS_BOTTOM_SET) {
+ *length = style->i.bottom;
+ *unit = bits >> 2;
+ }
+
+ return (bits & 0x3);
}
#undef BOTTOM_INDEX
#undef BOTTOM_SHIFT
@@ -464,6 +672,15 @@ static inline uint8_t get_bottom_bits(
#define BOX_SIZING_INDEX 11
#define BOX_SIZING_SHIFT 10
#define BOX_SIZING_MASK 0xc00
+static inline uint8_t get_box_sizing_bits(const css_computed_style *style)
+{
+ uint32_t bits = style->i.bits[BOX_SIZING_INDEX];
+ bits &= BOX_SIZING_MASK;
+ bits >>= BOX_SIZING_SHIFT;
+
+ /* 2bits: tt : type */
+ return (bits & 0x3);
+}
static inline uint8_t get_box_sizing(const css_computed_style *style)
{
uint32_t bits = style->i.bits[BOX_SIZING_INDEX];
@@ -481,6 +698,15 @@ static inline uint8_t get_box_sizing(const css_computed_style *style)
#define BREAK_AFTER_INDEX 9
#define BREAK_AFTER_SHIFT 15
#define BREAK_AFTER_MASK 0x78000
+static inline uint8_t get_break_after_bits(const css_computed_style *style)
+{
+ uint32_t bits = style->i.bits[BREAK_AFTER_INDEX];
+ bits &= BREAK_AFTER_MASK;
+ bits >>= BREAK_AFTER_SHIFT;
+
+ /* 4bits: tttt : type */
+ return (bits & 0xf);
+}
static inline uint8_t get_break_after(const css_computed_style *style)
{
uint32_t bits = style->i.bits[BREAK_AFTER_INDEX];
@@ -498,6 +724,15 @@ static inline uint8_t get_break_after(const css_computed_style *style)
#define BREAK_BEFORE_INDEX 9
#define BREAK_BEFORE_SHIFT 19
#define BREAK_BEFORE_MASK 0x780000
+static inline uint8_t get_break_before_bits(const css_computed_style *style)
+{
+ uint32_t bits = style->i.bits[BREAK_BEFORE_INDEX];
+ bits &= BREAK_BEFORE_MASK;
+ bits >>= BREAK_BEFORE_SHIFT;
+
+ /* 4bits: tttt : type */
+ return (bits & 0xf);
+}
static inline uint8_t get_break_before(const css_computed_style *style)
{
uint32_t bits = style->i.bits[BREAK_BEFORE_INDEX];
@@ -515,6 +750,15 @@ static inline uint8_t get_break_before(const css_computed_style *style)
#define BREAK_INSIDE_INDEX 9
#define BREAK_INSIDE_SHIFT 23
#define BREAK_INSIDE_MASK 0x7800000
+static inline uint8_t get_break_inside_bits(const css_computed_style *style)
+{
+ uint32_t bits = style->i.bits[BREAK_INSIDE_INDEX];
+ bits &= BREAK_INSIDE_MASK;
+ bits >>= BREAK_INSIDE_SHIFT;
+
+ /* 4bits: tttt : type */
+ return (bits & 0xf);
+}
static inline uint8_t get_break_inside(const css_computed_style *style)
{
uint32_t bits = style->i.bits[BREAK_INSIDE_INDEX];
@@ -532,6 +776,15 @@ static inline uint8_t get_break_inside(const css_computed_style *style)
#define CAPTION_SIDE_INDEX 11
#define CAPTION_SIDE_SHIFT 12
#define CAPTION_SIDE_MASK 0x3000
+static inline uint8_t get_caption_side_bits(const css_computed_style *style)
+{
+ uint32_t bits = style->i.bits[CAPTION_SIDE_INDEX];
+ bits &= CAPTION_SIDE_MASK;
+ bits >>= CAPTION_SIDE_SHIFT;
+
+ /* 2bits: tt : type */
+ return (bits & 0x3);
+}
static inline uint8_t get_caption_side(const css_computed_style *style)
{
uint32_t bits = style->i.bits[CAPTION_SIDE_INDEX];
@@ -549,6 +802,15 @@ static inline uint8_t get_caption_side(const css_computed_style *style)
#define CLEAR_INDEX 13
#define CLEAR_SHIFT 1
#define CLEAR_MASK 0xe
+static inline uint8_t get_clear_bits(const css_computed_style *style)
+{
+ uint32_t bits = style->i.bits[CLEAR_INDEX];
+ bits &= CLEAR_MASK;
+ bits >>= CLEAR_SHIFT;
+
+ /* 3bits: ttt : type */
+ return (bits & 0x7);
+}
static inline uint8_t get_clear(const css_computed_style *style)
{
uint32_t bits = style->i.bits[CLEAR_INDEX];
@@ -566,6 +828,16 @@ static inline uint8_t get_clear(const css_computed_style *style)
#define CLIP_INDEX 2
#define CLIP_SHIFT 6
#define CLIP_MASK 0xffffffc0
+static inline uint8_t get_clip_bits(const css_computed_style *style)
+{
+ uint32_t bits = style->i.bits[CLIP_INDEX];
+ bits &= CLIP_MASK;
+ bits >>= CLIP_SHIFT;
+
+ /* 26bits: aaaaabbbbbcccccdddddtttttt : unit_a | unit_b | unit_c |
+ unit_d | type */
+ return (bits & 0x3f);
+}
static inline uint8_t get_clip(
const css_computed_style *style,
css_computed_clip_rect *rect)
@@ -608,15 +880,24 @@ static inline uint8_t get_clip(
#define COLOR_INDEX 14
#define COLOR_SHIFT 19
#define COLOR_MASK 0x80000
-static inline uint8_t get_color(const css_computed_style *style, css_color
- *color)
+static inline uint8_t get_color_bits(const css_computed_style *style)
{
uint32_t bits = style->i.bits[COLOR_INDEX];
bits &= COLOR_MASK;
bits >>= COLOR_SHIFT;
/* 1bit: t : type */
- *color = style->i.color;
+ return (bits & 0x1);
+}
+static inline uint8_t get_color(const css_computed_style *style, css_color
+ *color)
+{
+ uint32_t bits = style->i.bits[COLOR_INDEX];
+ bits &= COLOR_MASK;
+ bits >>= COLOR_SHIFT;
+
+ /* 1bit: t : type */
+ *color = style->i.color;
return (bits & 0x1);
}
@@ -627,6 +908,15 @@ static inline uint8_t get_color(const css_computed_style *style, css_color
#define COLUMN_COUNT_INDEX 11
#define COLUMN_COUNT_SHIFT 14
#define COLUMN_COUNT_MASK 0xc000
+static inline uint8_t get_column_count_bits(const css_computed_style *style)
+{
+ uint32_t bits = style->i.bits[COLUMN_COUNT_INDEX];
+ bits &= COLUMN_COUNT_MASK;
+ bits >>= COLUMN_COUNT_SHIFT;
+
+ /* 2bits: tt : type */
+ return (bits & 0x3);
+}
static inline uint8_t get_column_count(const css_computed_style *style, int32_t
*integer)
{
@@ -646,6 +936,15 @@ static inline uint8_t get_column_count(const css_computed_style *style, int32_t
#define COLUMN_FILL_INDEX 11
#define COLUMN_FILL_SHIFT 16
#define COLUMN_FILL_MASK 0x30000
+static inline uint8_t get_column_fill_bits(const css_computed_style *style)
+{
+ uint32_t bits = style->i.bits[COLUMN_FILL_INDEX];
+ bits &= COLUMN_FILL_MASK;
+ bits >>= COLUMN_FILL_SHIFT;
+
+ /* 2bits: tt : type */
+ return (bits & 0x3);
+}
static inline uint8_t get_column_fill(const css_computed_style *style)
{
uint32_t bits = style->i.bits[COLUMN_FILL_INDEX];
@@ -663,6 +962,15 @@ static inline uint8_t get_column_fill(const css_computed_style *style)
#define COLUMN_GAP_INDEX 3
#define COLUMN_GAP_SHIFT 18
#define COLUMN_GAP_MASK 0x1fc0000
+static inline uint8_t get_column_gap_bits(const css_computed_style *style)
+{
+ uint32_t bits = style->i.bits[COLUMN_GAP_INDEX];
+ bits &= COLUMN_GAP_MASK;
+ bits >>= COLUMN_GAP_SHIFT;
+
+ /* 7bits: uuuuutt : unit | type */
+ return (bits & 0x3);
+}
static inline uint8_t get_column_gap(const css_computed_style *style, css_fixed
*length, css_unit *unit)
{
@@ -685,6 +993,16 @@ static inline uint8_t get_column_gap(const css_computed_style *style, css_fixed
#define COLUMN_RULE_COLOR_INDEX 11
#define COLUMN_RULE_COLOR_SHIFT 18
#define COLUMN_RULE_COLOR_MASK 0xc0000
+static inline uint8_t get_column_rule_color_bits(const css_computed_style
+ *style)
+{
+ uint32_t bits = style->i.bits[COLUMN_RULE_COLOR_INDEX];
+ bits &= COLUMN_RULE_COLOR_MASK;
+ bits >>= COLUMN_RULE_COLOR_SHIFT;
+
+ /* 2bits: tt : type */
+ return (bits & 0x3);
+}
static inline uint8_t get_column_rule_color(const css_computed_style *style,
css_color *color)
{
@@ -704,6 +1022,16 @@ static inline uint8_t get_column_rule_color(const css_computed_style *style,
#define COLUMN_RULE_STYLE_INDEX 7
#define COLUMN_RULE_STYLE_SHIFT 0
#define COLUMN_RULE_STYLE_MASK 0xf
+static inline uint8_t get_column_rule_style_bits(const css_computed_style
+ *style)
+{
+ uint32_t bits = style->i.bits[COLUMN_RULE_STYLE_INDEX];
+ bits &= COLUMN_RULE_STYLE_MASK;
+ bits >>= COLUMN_RULE_STYLE_SHIFT;
+
+ /* 4bits: tttt : type */
+ return (bits & 0xf);
+}
static inline uint8_t get_column_rule_style(const css_computed_style *style)
{
uint32_t bits = style->i.bits[COLUMN_RULE_STYLE_INDEX];
@@ -721,6 +1049,16 @@ static inline uint8_t get_column_rule_style(const css_computed_style *style)
#define COLUMN_RULE_WIDTH_INDEX 1
#define COLUMN_RULE_WIDTH_SHIFT 7
#define COLUMN_RULE_WIDTH_MASK 0x7f80
+static inline uint8_t get_column_rule_width_bits(const css_computed_style
+ *style)
+{
+ uint32_t bits = style->i.bits[COLUMN_RULE_WIDTH_INDEX];
+ bits &= COLUMN_RULE_WIDTH_MASK;
+ bits >>= COLUMN_RULE_WIDTH_SHIFT;
+
+ /* 8bits: uuuuuttt : unit | type */
+ return (bits & 0x7);
+}
static inline uint8_t get_column_rule_width(const css_computed_style *style,
css_fixed *length, css_unit *unit)
{
@@ -743,6 +1081,15 @@ static inline uint8_t get_column_rule_width(const css_computed_style *style,
#define COLUMN_SPAN_INDEX 11
#define COLUMN_SPAN_SHIFT 20
#define COLUMN_SPAN_MASK 0x300000
+static inline uint8_t get_column_span_bits(const css_computed_style *style)
+{
+ uint32_t bits = style->i.bits[COLUMN_SPAN_INDEX];
+ bits &= COLUMN_SPAN_MASK;
+ bits >>= COLUMN_SPAN_SHIFT;
+
+ /* 2bits: tt : type */
+ return (bits & 0x3);
+}
static inline uint8_t get_column_span(const css_computed_style *style)
{
uint32_t bits = style->i.bits[COLUMN_SPAN_INDEX];
@@ -760,6 +1107,15 @@ static inline uint8_t get_column_span(const css_computed_style *style)
#define COLUMN_WIDTH_INDEX 3
#define COLUMN_WIDTH_SHIFT 25
#define COLUMN_WIDTH_MASK 0xfe000000
+static inline uint8_t get_column_width_bits(const css_computed_style *style)
+{
+ uint32_t bits = style->i.bits[COLUMN_WIDTH_INDEX];
+ bits &= COLUMN_WIDTH_MASK;
+ bits >>= COLUMN_WIDTH_SHIFT;
+
+ /* 7bits: uuuuutt : unit | type */
+ return (bits & 0x3);
+}
static inline uint8_t get_column_width(const css_computed_style *style,
css_fixed *length, css_unit *unit)
{
@@ -782,6 +1138,15 @@ static inline uint8_t get_column_width(const css_computed_style *style,
#define CONTENT_INDEX 11
#define CONTENT_SHIFT 22
#define CONTENT_MASK 0xc00000
+static inline uint8_t get_content_bits(const css_computed_style *style)
+{
+ uint32_t bits = style->i.bits[CONTENT_INDEX];
+ bits &= CONTENT_MASK;
+ bits >>= CONTENT_SHIFT;
+
+ /* 2bits: tt : type */
+ return (bits & 0x3);
+}
static inline uint8_t get_content(const css_computed_style *style, const
css_computed_content_item **content_item)
{
@@ -803,6 +1168,16 @@ static inline uint8_t get_content(const css_computed_style *style, const
#define COUNTER_INCREMENT_INDEX 14
#define COUNTER_INCREMENT_SHIFT 20
#define COUNTER_INCREMENT_MASK 0x100000
+static inline uint8_t get_counter_increment_bits(const css_computed_style
+ *style)
+{
+ uint32_t bits = style->i.bits[COUNTER_INCREMENT_INDEX];
+ bits &= COUNTER_INCREMENT_MASK;
+ bits >>= COUNTER_INCREMENT_SHIFT;
+
+ /* 1bit: t : type */
+ return (bits & 0x1);
+}
static inline uint8_t get_counter_increment(const css_computed_style *style,
const css_computed_counter **counter_arr)
{
@@ -822,6 +1197,15 @@ static inline uint8_t get_counter_increment(const css_computed_style *style,
#define COUNTER_RESET_INDEX 14
#define COUNTER_RESET_SHIFT 21
#define COUNTER_RESET_MASK 0x200000
+static inline uint8_t get_counter_reset_bits(const css_computed_style *style)
+{
+ uint32_t bits = style->i.bits[COUNTER_RESET_INDEX];
+ bits &= COUNTER_RESET_MASK;
+ bits >>= COUNTER_RESET_SHIFT;
+
+ /* 1bit: t : type */
+ return (bits & 0x1);
+}
static inline uint8_t get_counter_reset(const css_computed_style *style, const
css_computed_counter **counter_arr)
{
@@ -841,6 +1225,15 @@ static inline uint8_t get_counter_reset(const css_computed_style *style, const
#define CURSOR_INDEX 9
#define CURSOR_SHIFT 27
#define CURSOR_MASK 0xf8000000
+static inline uint8_t get_cursor_bits(const css_computed_style *style)
+{
+ uint32_t bits = style->i.bits[CURSOR_INDEX];
+ bits &= CURSOR_MASK;
+ bits >>= CURSOR_SHIFT;
+
+ /* 5bits: ttttt : type */
+ return (bits & 0x1f);
+}
static inline uint8_t get_cursor(const css_computed_style *style, lwc_string
***string_arr)
{
@@ -860,6 +1253,15 @@ static inline uint8_t get_cursor(const css_computed_style *style, lwc_string
#define DIRECTION_INDEX 11
#define DIRECTION_SHIFT 24
#define DIRECTION_MASK 0x3000000
+static inline uint8_t get_direction_bits(const css_computed_style *style)
+{
+ uint32_t bits = style->i.bits[DIRECTION_INDEX];
+ bits &= DIRECTION_MASK;
+ bits >>= DIRECTION_SHIFT;
+
+ /* 2bits: tt : type */
+ return (bits & 0x3);
+}
static inline uint8_t get_direction(const css_computed_style *style)
{
uint32_t bits = style->i.bits[DIRECTION_INDEX];
@@ -877,6 +1279,15 @@ static inline uint8_t get_direction(const css_computed_style *style)
#define DISPLAY_INDEX 8
#define DISPLAY_SHIFT 3
#define DISPLAY_MASK 0xf8
+static inline uint8_t get_display_bits(const css_computed_style *style)
+{
+ uint32_t bits = style->i.bits[DISPLAY_INDEX];
+ bits &= DISPLAY_MASK;
+ bits >>= DISPLAY_SHIFT;
+
+ /* 5bits: ttttt : type */
+ return (bits & 0x1f);
+}
static inline uint8_t get_display(const css_computed_style *style)
{
uint32_t bits = style->i.bits[DISPLAY_INDEX];
@@ -894,6 +1305,15 @@ static inline uint8_t get_display(const css_computed_style *style)
#define EMPTY_CELLS_INDEX 11
#define EMPTY_CELLS_SHIFT 26
#define EMPTY_CELLS_MASK 0xc000000
+static inline uint8_t get_empty_cells_bits(const css_computed_style *style)
+{
+ uint32_t bits = style->i.bits[EMPTY_CELLS_INDEX];
+ bits &= EMPTY_CELLS_MASK;
+ bits >>= EMPTY_CELLS_SHIFT;
+
+ /* 2bits: tt : type */
+ return (bits & 0x3);
+}
static inline uint8_t get_empty_cells(const css_computed_style *style)
{
uint32_t bits = style->i.bits[EMPTY_CELLS_INDEX];
@@ -911,6 +1331,15 @@ static inline uint8_t get_empty_cells(const css_computed_style *style)
#define FLEX_BASIS_INDEX 7
#define FLEX_BASIS_SHIFT 4
#define FLEX_BASIS_MASK 0x7f0
+static inline uint8_t get_flex_basis_bits(const css_computed_style *style)
+{
+ uint32_t bits = style->i.bits[FLEX_BASIS_INDEX];
+ bits &= FLEX_BASIS_MASK;
+ bits >>= FLEX_BASIS_SHIFT;
+
+ /* 7bits: uuuuutt : unit | type */
+ return (bits & 0x3);
+}
static inline uint8_t get_flex_basis(const css_computed_style *style, css_fixed
*length, css_unit *unit)
{
@@ -933,6 +1362,15 @@ static inline uint8_t get_flex_basis(const css_computed_style *style, css_fixed
#define FLEX_DIRECTION_INDEX 13
#define FLEX_DIRECTION_SHIFT 4
#define FLEX_DIRECTION_MASK 0x70
+static inline uint8_t get_flex_direction_bits(const css_computed_style *style)
+{
+ uint32_t bits = style->i.bits[FLEX_DIRECTION_INDEX];
+ bits &= FLEX_DIRECTION_MASK;
+ bits >>= FLEX_DIRECTION_SHIFT;
+
+ /* 3bits: ttt : type */
+ return (bits & 0x7);
+}
static inline uint8_t get_flex_direction(const css_computed_style *style)
{
uint32_t bits = style->i.bits[FLEX_DIRECTION_INDEX];
@@ -950,6 +1388,15 @@ static inline uint8_t get_flex_direction(const css_computed_style *style)
#define FLEX_GROW_INDEX 14
#define FLEX_GROW_SHIFT 22
#define FLEX_GROW_MASK 0x400000
+static inline uint8_t get_flex_grow_bits(const css_computed_style *style)
+{
+ uint32_t bits = style->i.bits[FLEX_GROW_INDEX];
+ bits &= FLEX_GROW_MASK;
+ bits >>= FLEX_GROW_SHIFT;
+
+ /* 1bit: t : type */
+ return (bits & 0x1);
+}
static inline uint8_t get_flex_grow(const css_computed_style *style, css_fixed
*fixed)
{
@@ -971,6 +1418,15 @@ static inline uint8_t get_flex_grow(const css_computed_style *style, css_fixed
#define FLEX_SHRINK_INDEX 14
#define FLEX_SHRINK_SHIFT 23
#define FLEX_SHRINK_MASK 0x800000
+static inline uint8_t get_flex_shrink_bits(const css_computed_style *style)
+{
+ uint32_t bits = style->i.bits[FLEX_SHRINK_INDEX];
+ bits &= FLEX_SHRINK_MASK;
+ bits >>= FLEX_SHRINK_SHIFT;
+
+ /* 1bit: t : type */
+ return (bits & 0x1);
+}
static inline uint8_t get_flex_shrink(const css_computed_style *style,
css_fixed *fixed)
{
@@ -992,6 +1448,15 @@ static inline uint8_t get_flex_shrink(const css_computed_style *style,
#define FLEX_WRAP_INDEX 11
#define FLEX_WRAP_SHIFT 28
#define FLEX_WRAP_MASK 0x30000000
+static inline uint8_t get_flex_wrap_bits(const css_computed_style *style)
+{
+ uint32_t bits = style->i.bits[FLEX_WRAP_INDEX];
+ bits &= FLEX_WRAP_MASK;
+ bits >>= FLEX_WRAP_SHIFT;
+
+ /* 2bits: tt : type */
+ return (bits & 0x3);
+}
static inline uint8_t get_flex_wrap(const css_computed_style *style)
{
uint32_t bits = style->i.bits[FLEX_WRAP_INDEX];
@@ -1009,6 +1474,15 @@ static inline uint8_t get_flex_wrap(const css_computed_style *style)
#define FLOAT_INDEX 11
#define FLOAT_SHIFT 30
#define FLOAT_MASK 0xc0000000
+static inline uint8_t get_float_bits(const css_computed_style *style)
+{
+ uint32_t bits = style->i.bits[FLOAT_INDEX];
+ bits &= FLOAT_MASK;
+ bits >>= FLOAT_SHIFT;
+
+ /* 2bits: tt : type */
+ return (bits & 0x3);
+}
static inline uint8_t get_float(const css_computed_style *style)
{
uint32_t bits = style->i.bits[FLOAT_INDEX];
@@ -1026,6 +1500,15 @@ static inline uint8_t get_float(const css_computed_style *style)
#define FONT_FAMILY_INDEX 13
#define FONT_FAMILY_SHIFT 7
#define FONT_FAMILY_MASK 0x380
+static inline uint8_t get_font_family_bits(const css_computed_style *style)
+{
+ uint32_t bits = style->i.bits[FONT_FAMILY_INDEX];
+ bits &= FONT_FAMILY_MASK;
+ bits >>= FONT_FAMILY_SHIFT;
+
+ /* 3bits: ttt : type */
+ return (bits & 0x7);
+}
static inline uint8_t get_font_family(const css_computed_style *style,
lwc_string ***string_arr)
{
@@ -1045,6 +1528,15 @@ static inline uint8_t get_font_family(const css_computed_style *style,
#define FONT_SIZE_INDEX 1
#define FONT_SIZE_SHIFT 23
#define FONT_SIZE_MASK 0xff800000
+static inline uint8_t get_font_size_bits(const css_computed_style *style)
+{
+ uint32_t bits = style->i.bits[FONT_SIZE_INDEX];
+ bits &= FONT_SIZE_MASK;
+ bits >>= FONT_SIZE_SHIFT;
+
+ /* 9bits: uuuuutttt : unit | type */
+ return (bits & 0xf);
+}
static inline uint8_t get_font_size(const css_computed_style *style, css_fixed
*length, css_unit *unit)
{
@@ -1067,6 +1559,15 @@ static inline uint8_t get_font_size(const css_computed_style *style, css_fixed
#define FONT_STYLE_INDEX 10
#define FONT_STYLE_SHIFT 0
#define FONT_STYLE_MASK 0x3
+static inline uint8_t get_font_style_bits(const css_computed_style *style)
+{
+ uint32_t bits = style->i.bits[FONT_STYLE_INDEX];
+ bits &= FONT_STYLE_MASK;
+ bits >>= FONT_STYLE_SHIFT;
+
+ /* 2bits: tt : type */
+ return (bits & 0x3);
+}
static inline uint8_t get_font_style(const css_computed_style *style)
{
uint32_t bits = style->i.bits[FONT_STYLE_INDEX];
@@ -1084,6 +1585,15 @@ static inline uint8_t get_font_style(const css_computed_style *style)
#define FONT_VARIANT_INDEX 10
#define FONT_VARIANT_SHIFT 2
#define FONT_VARIANT_MASK 0xc
+static inline uint8_t get_font_variant_bits(const css_computed_style *style)
+{
+ uint32_t bits = style->i.bits[FONT_VARIANT_INDEX];
+ bits &= FONT_VARIANT_MASK;
+ bits >>= FONT_VARIANT_SHIFT;
+
+ /* 2bits: tt : type */
+ return (bits & 0x3);
+}
static inline uint8_t get_font_variant(const css_computed_style *style)
{
uint32_t bits = style->i.bits[FONT_VARIANT_INDEX];
@@ -1101,6 +1611,15 @@ static inline uint8_t get_font_variant(const css_computed_style *style)
#define FONT_WEIGHT_INDEX 6
#define FONT_WEIGHT_SHIFT 0
#define FONT_WEIGHT_MASK 0xf
+static inline uint8_t get_font_weight_bits(const css_computed_style *style)
+{
+ uint32_t bits = style->i.bits[FONT_WEIGHT_INDEX];
+ bits &= FONT_WEIGHT_MASK;
+ bits >>= FONT_WEIGHT_SHIFT;
+
+ /* 4bits: tttt : type */
+ return (bits & 0xf);
+}
static inline uint8_t get_font_weight(const css_computed_style *style)
{
uint32_t bits = style->i.bits[FONT_WEIGHT_INDEX];
@@ -1118,6 +1637,15 @@ static inline uint8_t get_font_weight(const css_computed_style *style)
#define HEIGHT_INDEX 7
#define HEIGHT_SHIFT 11
#define HEIGHT_MASK 0x3f800
+static inline uint8_t get_height_bits(const css_computed_style *style)
+{
+ uint32_t bits = style->i.bits[HEIGHT_INDEX];
+ bits &= HEIGHT_MASK;
+ bits >>= HEIGHT_SHIFT;
+
+ /* 7bits: uuuuutt : unit | type */
+ return (bits & 0x3);
+}
static inline uint8_t get_height(const css_computed_style *style, css_fixed
*length, css_unit *unit)
{
@@ -1140,6 +1668,15 @@ static inline uint8_t get_height(const css_computed_style *style, css_fixed
#define JUSTIFY_CONTENT_INDEX 13
#define JUSTIFY_CONTENT_SHIFT 10
#define JUSTIFY_CONTENT_MASK 0x1c00
+static inline uint8_t get_justify_content_bits(const css_computed_style *style)
+{
+ uint32_t bits = style->i.bits[JUSTIFY_CONTENT_INDEX];
+ bits &= JUSTIFY_CONTENT_MASK;
+ bits >>= JUSTIFY_CONTENT_SHIFT;
+
+ /* 3bits: ttt : type */
+ return (bits & 0x7);
+}
static inline uint8_t get_justify_content(const css_computed_style *style)
{
uint32_t bits = style->i.bits[JUSTIFY_CONTENT_INDEX];
@@ -1157,39 +1694,46 @@ static inline uint8_t get_justify_content(const css_computed_style *style)
#define LEFT_INDEX 7
#define LEFT_SHIFT 18
#define LEFT_MASK 0x1fc0000
-static inline uint8_t get_left(
- const css_computed_style *style,
- css_fixed *length, css_unit *unit)
+static inline uint8_t get_left_bits(const css_computed_style *style)
{
uint32_t bits = style->i.bits[LEFT_INDEX];
bits &= LEFT_MASK;
bits >>= LEFT_SHIFT;
-
- /* 7bits: uuuuutt : units | type */
- if ((bits & 0x3) == CSS_LEFT_SET) {
- *length = style->i.left;
- *unit = bits >> 2;
- }
-
+
+ /* 7bits: uuuuutt : unit | type */
return (bits & 0x3);
}
-static inline uint8_t get_left_bits(
- const css_computed_style *style)
+static inline uint8_t get_left(const css_computed_style *style, css_fixed
+ *length, css_unit *unit)
{
uint32_t bits = style->i.bits[LEFT_INDEX];
bits &= LEFT_MASK;
bits >>= LEFT_SHIFT;
-
- /* 7bits: uuuuutt : units | type */
- return bits;
-}
-#undef LEFT_INDEX
-#undef LEFT_SHIFT
-#undef LEFT_MASK
-
-#define LETTER_SPACING_INDEX 7
-#define LETTER_SPACING_SHIFT 25
+
+ /* 7bits: uuuuutt : unit | type */
+ if ((bits & 0x3) == CSS_LEFT_SET) {
+ *length = style->i.left;
+ *unit = bits >> 2;
+ }
+
+ return (bits & 0x3);
+}
+#undef LEFT_INDEX
+#undef LEFT_SHIFT
+#undef LEFT_MASK
+
+#define LETTER_SPACING_INDEX 7
+#define LETTER_SPACING_SHIFT 25
#define LETTER_SPACING_MASK 0xfe000000
+static inline uint8_t get_letter_spacing_bits(const css_computed_style *style)
+{
+ uint32_t bits = style->i.bits[LETTER_SPACING_INDEX];
+ bits &= LETTER_SPACING_MASK;
+ bits >>= LETTER_SPACING_SHIFT;
+
+ /* 7bits: uuuuutt : unit | type */
+ return (bits & 0x3);
+}
static inline uint8_t get_letter_spacing(const css_computed_style *style,
css_fixed *length, css_unit *unit)
{
@@ -1212,6 +1756,15 @@ static inline uint8_t get_letter_spacing(const css_computed_style *style,
#define LINE_HEIGHT_INDEX 6
#define LINE_HEIGHT_SHIFT 4
#define LINE_HEIGHT_MASK 0x7f0
+static inline uint8_t get_line_height_bits(const css_computed_style *style)
+{
+ uint32_t bits = style->i.bits[LINE_HEIGHT_INDEX];
+ bits &= LINE_HEIGHT_MASK;
+ bits >>= LINE_HEIGHT_SHIFT;
+
+ /* 7bits: uuuuutt : unit | type */
+ return (bits & 0x3);
+}
static inline uint8_t get_line_height(
const css_computed_style *style,
css_fixed *length, css_unit *unit)
@@ -1239,6 +1792,15 @@ static inline uint8_t get_line_height(
#define LIST_STYLE_IMAGE_INDEX 14
#define LIST_STYLE_IMAGE_SHIFT 24
#define LIST_STYLE_IMAGE_MASK 0x1000000
+static inline uint8_t get_list_style_image_bits(const css_computed_style *style)
+{
+ uint32_t bits = style->i.bits[LIST_STYLE_IMAGE_INDEX];
+ bits &= LIST_STYLE_IMAGE_MASK;
+ bits >>= LIST_STYLE_IMAGE_SHIFT;
+
+ /* 1bit: t : type */
+ return (bits & 0x1);
+}
static inline uint8_t get_list_style_image(const css_computed_style *style,
lwc_string **string)
{
@@ -1258,6 +1820,16 @@ static inline uint8_t get_list_style_image(const css_computed_style *style,
#define LIST_STYLE_POSITION_INDEX 10
#define LIST_STYLE_POSITION_SHIFT 4
#define LIST_STYLE_POSITION_MASK 0x30
+static inline uint8_t get_list_style_position_bits(const css_computed_style
+ *style)
+{
+ uint32_t bits = style->i.bits[LIST_STYLE_POSITION_INDEX];
+ bits &= LIST_STYLE_POSITION_MASK;
+ bits >>= LIST_STYLE_POSITION_SHIFT;
+
+ /* 2bits: tt : type */
+ return (bits & 0x3);
+}
static inline uint8_t get_list_style_position(const css_computed_style *style)
{
uint32_t bits = style->i.bits[LIST_STYLE_POSITION_INDEX];
@@ -1275,6 +1847,15 @@ static inline uint8_t get_list_style_position(const css_computed_style *style)
#define LIST_STYLE_TYPE_INDEX 8
#define LIST_STYLE_TYPE_SHIFT 8
#define LIST_STYLE_TYPE_MASK 0x3f00
+static inline uint8_t get_list_style_type_bits(const css_computed_style *style)
+{
+ uint32_t bits = style->i.bits[LIST_STYLE_TYPE_INDEX];
+ bits &= LIST_STYLE_TYPE_MASK;
+ bits >>= LIST_STYLE_TYPE_SHIFT;
+
+ /* 6bits: tttttt : type */
+ return (bits & 0x3f);
+}
static inline uint8_t get_list_style_type(const css_computed_style *style)
{
uint32_t bits = style->i.bits[LIST_STYLE_TYPE_INDEX];
@@ -1292,6 +1873,15 @@ static inline uint8_t get_list_style_type(const css_computed_style *style)
#define MARGIN_BOTTOM_INDEX 6
#define MARGIN_BOTTOM_SHIFT 11
#define MARGIN_BOTTOM_MASK 0x3f800
+static inline uint8_t get_margin_bottom_bits(const css_computed_style *style)
+{
+ uint32_t bits = style->i.bits[MARGIN_BOTTOM_INDEX];
+ bits &= MARGIN_BOTTOM_MASK;
+ bits >>= MARGIN_BOTTOM_SHIFT;
+
+ /* 7bits: uuuuutt : unit | type */
+ return (bits & 0x3);
+}
static inline uint8_t get_margin_bottom(const css_computed_style *style,
css_fixed *length, css_unit *unit)
{
@@ -1314,6 +1904,15 @@ static inline uint8_t get_margin_bottom(const css_computed_style *style,
#define MARGIN_LEFT_INDEX 6
#define MARGIN_LEFT_SHIFT 18
#define MARGIN_LEFT_MASK 0x1fc0000
+static inline uint8_t get_margin_left_bits(const css_computed_style *style)
+{
+ uint32_t bits = style->i.bits[MARGIN_LEFT_INDEX];
+ bits &= MARGIN_LEFT_MASK;
+ bits >>= MARGIN_LEFT_SHIFT;
+
+ /* 7bits: uuuuutt : unit | type */
+ return (bits & 0x3);
+}
static inline uint8_t get_margin_left(const css_computed_style *style,
css_fixed *length, css_unit *unit)
{
@@ -1336,6 +1935,15 @@ static inline uint8_t get_margin_left(const css_computed_style *style,
#define MARGIN_RIGHT_INDEX 6
#define MARGIN_RIGHT_SHIFT 25
#define MARGIN_RIGHT_MASK 0xfe000000
+static inline uint8_t get_margin_right_bits(const css_computed_style *style)
+{
+ uint32_t bits = style->i.bits[MARGIN_RIGHT_INDEX];
+ bits &= MARGIN_RIGHT_MASK;
+ bits >>= MARGIN_RIGHT_SHIFT;
+
+ /* 7bits: uuuuutt : unit | type */
+ return (bits & 0x3);
+}
static inline uint8_t get_margin_right(const css_computed_style *style,
css_fixed *length, css_unit *unit)
{
@@ -1358,6 +1966,15 @@ static inline uint8_t get_margin_right(const css_computed_style *style,
#define MARGIN_TOP_INDEX 5
#define MARGIN_TOP_SHIFT 4
#define MARGIN_TOP_MASK 0x7f0
+static inline uint8_t get_margin_top_bits(const css_computed_style *style)
+{
+ uint32_t bits = style->i.bits[MARGIN_TOP_INDEX];
+ bits &= MARGIN_TOP_MASK;
+ bits >>= MARGIN_TOP_SHIFT;
+
+ /* 7bits: uuuuutt : unit | type */
+ return (bits & 0x3);
+}
static inline uint8_t get_margin_top(const css_computed_style *style, css_fixed
*length, css_unit *unit)
{
@@ -1380,6 +1997,15 @@ static inline uint8_t get_margin_top(const css_computed_style *style, css_fixed
#define MAX_HEIGHT_INDEX 5
#define MAX_HEIGHT_SHIFT 11
#define MAX_HEIGHT_MASK 0x3f800
+static inline uint8_t get_max_height_bits(const css_computed_style *style)
+{
+ uint32_t bits = style->i.bits[MAX_HEIGHT_INDEX];
+ bits &= MAX_HEIGHT_MASK;
+ bits >>= MAX_HEIGHT_SHIFT;
+
+ /* 7bits: uuuuutt : unit | type */
+ return (bits & 0x3);
+}
static inline uint8_t get_max_height(const css_computed_style *style, css_fixed
*length, css_unit *unit)
{
@@ -1402,6 +2028,15 @@ static inline uint8_t get_max_height(const css_computed_style *style, css_fixed
#define MAX_WIDTH_INDEX 5
#define MAX_WIDTH_SHIFT 18
#define MAX_WIDTH_MASK 0x1fc0000
+static inline uint8_t get_max_width_bits(const css_computed_style *style)
+{
+ uint32_t bits = style->i.bits[MAX_WIDTH_INDEX];
+ bits &= MAX_WIDTH_MASK;
+ bits >>= MAX_WIDTH_SHIFT;
+
+ /* 7bits: uuuuutt : unit | type */
+ return (bits & 0x3);
+}
static inline uint8_t get_max_width(const css_computed_style *style, css_fixed
*length, css_unit *unit)
{
@@ -1424,6 +2059,15 @@ static inline uint8_t get_max_width(const css_computed_style *style, css_fixed
#define MIN_HEIGHT_INDEX 5
#define MIN_HEIGHT_SHIFT 25
#define MIN_HEIGHT_MASK 0xfe000000
+static inline uint8_t get_min_height_bits(const css_computed_style *style)
+{
+ uint32_t bits = style->i.bits[MIN_HEIGHT_INDEX];
+ bits &= MIN_HEIGHT_MASK;
+ bits >>= MIN_HEIGHT_SHIFT;
+
+ /* 7bits: uuuuutt : unit | type */
+ return (bits & 0x3);
+}
static inline uint8_t get_min_height(const css_computed_style *style, css_fixed
*length, css_unit *unit)
{
@@ -1446,6 +2090,15 @@ static inline uint8_t get_min_height(const css_computed_style *style, css_fixed
#define MIN_WIDTH_INDEX 4
#define MIN_WIDTH_SHIFT 4
#define MIN_WIDTH_MASK 0x7f0
+static inline uint8_t get_min_width_bits(const css_computed_style *style)
+{
+ uint32_t bits = style->i.bits[MIN_WIDTH_INDEX];
+ bits &= MIN_WIDTH_MASK;
+ bits >>= MIN_WIDTH_SHIFT;
+
+ /* 7bits: uuuuutt : unit | type */
+ return (bits & 0x3);
+}
static inline uint8_t get_min_width(const css_computed_style *style, css_fixed
*length, css_unit *unit)
{
@@ -1468,6 +2121,15 @@ static inline uint8_t get_min_width(const css_computed_style *style, css_fixed
#define OPACITY_INDEX 14
#define OPACITY_SHIFT 25
#define OPACITY_MASK 0x2000000
+static inline uint8_t get_opacity_bits(const css_computed_style *style)
+{
+ uint32_t bits = style->i.bits[OPACITY_INDEX];
+ bits &= OPACITY_MASK;
+ bits >>= OPACITY_SHIFT;
+
+ /* 1bit: t : type */
+ return (bits & 0x1);
+}
static inline uint8_t get_opacity(const css_computed_style *style, css_fixed
*fixed)
{
@@ -1489,6 +2151,15 @@ static inline uint8_t get_opacity(const css_computed_style *style, css_fixed
#define ORDER_INDEX 14
#define ORDER_SHIFT 26
#define ORDER_MASK 0x4000000
+static inline uint8_t get_order_bits(const css_computed_style *style)
+{
+ uint32_t bits = style->i.bits[ORDER_INDEX];
+ bits &= ORDER_MASK;
+ bits >>= ORDER_SHIFT;
+
+ /* 1bit: t : type */
+ return (bits & 0x1);
+}
static inline uint8_t get_order(const css_computed_style *style, int32_t
*integer)
{
@@ -1510,6 +2181,15 @@ static inline uint8_t get_order(const css_computed_style *style, int32_t
#define ORPHANS_INDEX 14
#define ORPHANS_SHIFT 27
#define ORPHANS_MASK 0x8000000
+static inline uint8_t get_orphans_bits(const css_computed_style *style)
+{
+ uint32_t bits = style->i.bits[ORPHANS_INDEX];
+ bits &= ORPHANS_MASK;
+ bits >>= ORPHANS_SHIFT;
+
+ /* 1bit: t : type */
+ return (bits & 0x1);
+}
static inline uint8_t get_orphans(const css_computed_style *style, int32_t
*integer)
{
@@ -1529,6 +2209,15 @@ static inline uint8_t get_orphans(const css_computed_style *style, int32_t
#define OUTLINE_COLOR_INDEX 10
#define OUTLINE_COLOR_SHIFT 6
#define OUTLINE_COLOR_MASK 0xc0
+static inline uint8_t get_outline_color_bits(const css_computed_style *style)
+{
+ uint32_t bits = style->i.bits[OUTLINE_COLOR_INDEX];
+ bits &= OUTLINE_COLOR_MASK;
+ bits >>= OUTLINE_COLOR_SHIFT;
+
+ /* 2bits: tt : type */
+ return (bits & 0x3);
+}
static inline uint8_t get_outline_color(const css_computed_style *style,
css_color *color)
{
@@ -1550,6 +2239,15 @@ static inline uint8_t get_outline_color(const css_computed_style *style,
#define OUTLINE_STYLE_INDEX 5
#define OUTLINE_STYLE_SHIFT 0
#define OUTLINE_STYLE_MASK 0xf
+static inline uint8_t get_outline_style_bits(const css_computed_style *style)
+{
+ uint32_t bits = style->i.bits[OUTLINE_STYLE_INDEX];
+ bits &= OUTLINE_STYLE_MASK;
+ bits >>= OUTLINE_STYLE_SHIFT;
+
+ /* 4bits: tttt : type */
+ return (bits & 0xf);
+}
static inline uint8_t get_outline_style(const css_computed_style *style)
{
uint32_t bits = style->i.bits[OUTLINE_STYLE_INDEX];
@@ -1567,6 +2265,15 @@ static inline uint8_t get_outline_style(const css_computed_style *style)
#define OUTLINE_WIDTH_INDEX 1
#define OUTLINE_WIDTH_SHIFT 15
#define OUTLINE_WIDTH_MASK 0x7f8000
+static inline uint8_t get_outline_width_bits(const css_computed_style *style)
+{
+ uint32_t bits = style->i.bits[OUTLINE_WIDTH_INDEX];
+ bits &= OUTLINE_WIDTH_MASK;
+ bits >>= OUTLINE_WIDTH_SHIFT;
+
+ /* 8bits: uuuuuttt : unit | type */
+ return (bits & 0x7);
+}
static inline uint8_t get_outline_width(const css_computed_style *style,
css_fixed *length, css_unit *unit)
{
@@ -1589,6 +2296,15 @@ static inline uint8_t get_outline_width(const css_computed_style *style,
#define OVERFLOW_X_INDEX 13
#define OVERFLOW_X_SHIFT 13
#define OVERFLOW_X_MASK 0xe000
+static inline uint8_t get_overflow_x_bits(const css_computed_style *style)
+{
+ uint32_t bits = style->i.bits[OVERFLOW_X_INDEX];
+ bits &= OVERFLOW_X_MASK;
+ bits >>= OVERFLOW_X_SHIFT;
+
+ /* 3bits: ttt : type */
+ return (bits & 0x7);
+}
static inline uint8_t get_overflow_x(const css_computed_style *style)
{
uint32_t bits = style->i.bits[OVERFLOW_X_INDEX];
@@ -1606,6 +2322,15 @@ static inline uint8_t get_overflow_x(const css_computed_style *style)
#define OVERFLOW_Y_INDEX 13
#define OVERFLOW_Y_SHIFT 16
#define OVERFLOW_Y_MASK 0x70000
+static inline uint8_t get_overflow_y_bits(const css_computed_style *style)
+{
+ uint32_t bits = style->i.bits[OVERFLOW_Y_INDEX];
+ bits &= OVERFLOW_Y_MASK;
+ bits >>= OVERFLOW_Y_SHIFT;
+
+ /* 3bits: ttt : type */
+ return (bits & 0x7);
+}
static inline uint8_t get_overflow_y(const css_computed_style *style)
{
uint32_t bits = style->i.bits[OVERFLOW_Y_INDEX];
@@ -1623,6 +2348,15 @@ static inline uint8_t get_overflow_y(const css_computed_style *style)
#define PADDING_BOTTOM_INDEX 8
#define PADDING_BOTTOM_SHIFT 14
#define PADDING_BOTTOM_MASK 0xfc000
+static inline uint8_t get_padding_bottom_bits(const css_computed_style *style)
+{
+ uint32_t bits = style->i.bits[PADDING_BOTTOM_INDEX];
+ bits &= PADDING_BOTTOM_MASK;
+ bits >>= PADDING_BOTTOM_SHIFT;
+
+ /* 6bits: uuuuut : unit | type */
+ return (bits & 0x1);
+}
static inline uint8_t get_padding_bottom(const css_computed_style *style,
css_fixed *length, css_unit *unit)
{
@@ -1645,6 +2379,15 @@ static inline uint8_t get_padding_bottom(const css_computed_style *style,
#define PADDING_LEFT_INDEX 8
#define PADDING_LEFT_SHIFT 20
#define PADDING_LEFT_MASK 0x3f00000
+static inline uint8_t get_padding_left_bits(const css_computed_style *style)
+{
+ uint32_t bits = style->i.bits[PADDING_LEFT_INDEX];
+ bits &= PADDING_LEFT_MASK;
+ bits >>= PADDING_LEFT_SHIFT;
+
+ /* 6bits: uuuuut : unit | type */
+ return (bits & 0x1);
+}
static inline uint8_t get_padding_left(const css_computed_style *style,
css_fixed *length, css_unit *unit)
{
@@ -1667,6 +2410,15 @@ static inline uint8_t get_padding_left(const css_computed_style *style,
#define PADDING_RIGHT_INDEX 8
#define PADDING_RIGHT_SHIFT 26
#define PADDING_RIGHT_MASK 0xfc000000
+static inline uint8_t get_padding_right_bits(const css_computed_style *style)
+{
+ uint32_t bits = style->i.bits[PADDING_RIGHT_INDEX];
+ bits &= PADDING_RIGHT_MASK;
+ bits >>= PADDING_RIGHT_SHIFT;
+
+ /* 6bits: uuuuut : unit | type */
+ return (bits & 0x1);
+}
static inline uint8_t get_padding_right(const css_computed_style *style,
css_fixed *length, css_unit *unit)
{
@@ -1689,6 +2441,15 @@ static inline uint8_t get_padding_right(const css_computed_style *style,
#define PADDING_TOP_INDEX 3
#define PADDING_TOP_SHIFT 5
#define PADDING_TOP_MASK 0x7e0
+static inline uint8_t get_padding_top_bits(const css_computed_style *style)
+{
+ uint32_t bits = style->i.bits[PADDING_TOP_INDEX];
+ bits &= PADDING_TOP_MASK;
+ bits >>= PADDING_TOP_SHIFT;
+
+ /* 6bits: uuuuut : unit | type */
+ return (bits & 0x1);
+}
static inline uint8_t get_padding_top(const css_computed_style *style,
css_fixed *length, css_unit *unit)
{
@@ -1711,6 +2472,15 @@ static inline uint8_t get_padding_top(const css_computed_style *style,
#define PAGE_BREAK_AFTER_INDEX 13
#define PAGE_BREAK_AFTER_SHIFT 19
#define PAGE_BREAK_AFTER_MASK 0x380000
+static inline uint8_t get_page_break_after_bits(const css_computed_style *style)
+{
+ uint32_t bits = style->i.bits[PAGE_BREAK_AFTER_INDEX];
+ bits &= PAGE_BREAK_AFTER_MASK;
+ bits >>= PAGE_BREAK_AFTER_SHIFT;
+
+ /* 3bits: ttt : type */
+ return (bits & 0x7);
+}
static inline uint8_t get_page_break_after(const css_computed_style *style)
{
uint32_t bits = style->i.bits[PAGE_BREAK_AFTER_INDEX];
@@ -1728,6 +2498,16 @@ static inline uint8_t get_page_break_after(const css_computed_style *style)
#define PAGE_BREAK_BEFORE_INDEX 13
#define PAGE_BREAK_BEFORE_SHIFT 22
#define PAGE_BREAK_BEFORE_MASK 0x1c00000
+static inline uint8_t get_page_break_before_bits(const css_computed_style
+ *style)
+{
+ uint32_t bits = style->i.bits[PAGE_BREAK_BEFORE_INDEX];
+ bits &= PAGE_BREAK_BEFORE_MASK;
+ bits >>= PAGE_BREAK_BEFORE_SHIFT;
+
+ /* 3bits: ttt : type */
+ return (bits & 0x7);
+}
static inline uint8_t get_page_break_before(const css_computed_style *style)
{
uint32_t bits = style->i.bits[PAGE_BREAK_BEFORE_INDEX];
@@ -1745,6 +2525,16 @@ static inline uint8_t get_page_break_before(const css_computed_style *style)
#define PAGE_BREAK_INSIDE_INDEX 10
#define PAGE_BREAK_INSIDE_SHIFT 8
#define PAGE_BREAK_INSIDE_MASK 0x300
+static inline uint8_t get_page_break_inside_bits(const css_computed_style
+ *style)
+{
+ uint32_t bits = style->i.bits[PAGE_BREAK_INSIDE_INDEX];
+ bits &= PAGE_BREAK_INSIDE_MASK;
+ bits >>= PAGE_BREAK_INSIDE_SHIFT;
+
+ /* 2bits: tt : type */
+ return (bits & 0x3);
+}
static inline uint8_t get_page_break_inside(const css_computed_style *style)
{
uint32_t bits = style->i.bits[PAGE_BREAK_INSIDE_INDEX];
@@ -1762,6 +2552,15 @@ static inline uint8_t get_page_break_inside(const css_computed_style *style)
#define POSITION_INDEX 13
#define POSITION_SHIFT 25
#define POSITION_MASK 0xe000000
+static inline uint8_t get_position_bits(const css_computed_style *style)
+{
+ uint32_t bits = style->i.bits[POSITION_INDEX];
+ bits &= POSITION_MASK;
+ bits >>= POSITION_SHIFT;
+
+ /* 3bits: ttt : type */
+ return (bits & 0x7);
+}
static inline uint8_t get_position(const css_computed_style *style)
{
uint32_t bits = style->i.bits[POSITION_INDEX];
@@ -1779,6 +2578,15 @@ static inline uint8_t get_position(const css_computed_style *style)
#define QUOTES_INDEX 13
#define QUOTES_SHIFT 0
#define QUOTES_MASK 0x1
+static inline uint8_t get_quotes_bits(const css_computed_style *style)
+{
+ uint32_t bits = style->i.bits[QUOTES_INDEX];
+ bits &= QUOTES_MASK;
+ bits >>= QUOTES_SHIFT;
+
+ /* 1bit: t : type */
+ return (bits & 0x1);
+}
static inline uint8_t get_quotes(const css_computed_style *style, lwc_string
***string_arr)
{
@@ -1798,31 +2606,29 @@ static inline uint8_t get_quotes(const css_computed_style *style, lwc_string
#define RIGHT_INDEX 4
#define RIGHT_SHIFT 11
#define RIGHT_MASK 0x3f800
-static inline uint8_t get_right(
- const css_computed_style *style,
- css_fixed *length, css_unit *unit)
+static inline uint8_t get_right_bits(const css_computed_style *style)
{
uint32_t bits = style->i.bits[RIGHT_INDEX];
bits &= RIGHT_MASK;
bits >>= RIGHT_SHIFT;
-
- /* 7bits: uuuuutt : units | type */
- if ((bits & 0x3) == CSS_RIGHT_SET) {
- *length = style->i.right;
- *unit = bits >> 2;
- }
-
+
+ /* 7bits: uuuuutt : unit | type */
return (bits & 0x3);
}
-static inline uint8_t get_right_bits(
- const css_computed_style *style)
+static inline uint8_t get_right(const css_computed_style *style, css_fixed
+ *length, css_unit *unit)
{
uint32_t bits = style->i.bits[RIGHT_INDEX];
bits &= RIGHT_MASK;
bits >>= RIGHT_SHIFT;
-
- /* 7bits: uuuuutt : units | type */
- return bits;
+
+ /* 7bits: uuuuutt : unit | type */
+ if ((bits & 0x3) == CSS_RIGHT_SET) {
+ *length = style->i.right;
+ *unit = bits >> 2;
+ }
+
+ return (bits & 0x3);
}
#undef RIGHT_INDEX
#undef RIGHT_SHIFT
@@ -1831,6 +2637,15 @@ static inline uint8_t get_right_bits(
#define TABLE_LAYOUT_INDEX 10
#define TABLE_LAYOUT_SHIFT 10
#define TABLE_LAYOUT_MASK 0xc00
+static inline uint8_t get_table_layout_bits(const css_computed_style *style)
+{
+ uint32_t bits = style->i.bits[TABLE_LAYOUT_INDEX];
+ bits &= TABLE_LAYOUT_MASK;
+ bits >>= TABLE_LAYOUT_SHIFT;
+
+ /* 2bits: tt : type */
+ return (bits & 0x3);
+}
static inline uint8_t get_table_layout(const css_computed_style *style)
{
uint32_t bits = style->i.bits[TABLE_LAYOUT_INDEX];
@@ -1848,6 +2663,15 @@ static inline uint8_t get_table_layout(const css_computed_style *style)
#define TEXT_ALIGN_INDEX 4
#define TEXT_ALIGN_SHIFT 0
#define TEXT_ALIGN_MASK 0xf
+static inline uint8_t get_text_align_bits(const css_computed_style *style)
+{
+ uint32_t bits = style->i.bits[TEXT_ALIGN_INDEX];
+ bits &= TEXT_ALIGN_MASK;
+ bits >>= TEXT_ALIGN_SHIFT;
+
+ /* 4bits: tttt : type */
+ return (bits & 0xf);
+}
static inline uint8_t get_text_align(const css_computed_style *style)
{
uint32_t bits = style->i.bits[TEXT_ALIGN_INDEX];
@@ -1865,6 +2689,15 @@ static inline uint8_t get_text_align(const css_computed_style *style)
#define TEXT_DECORATION_INDEX 3
#define TEXT_DECORATION_SHIFT 0
#define TEXT_DECORATION_MASK 0x1f
+static inline uint8_t get_text_decoration_bits(const css_computed_style *style)
+{
+ uint32_t bits = style->i.bits[TEXT_DECORATION_INDEX];
+ bits &= TEXT_DECORATION_MASK;
+ bits >>= TEXT_DECORATION_SHIFT;
+
+ /* 5bits: ttttt : type */
+ return (bits & 0x1f);
+}
static inline uint8_t get_text_decoration(const css_computed_style *style)
{
uint32_t bits = style->i.bits[TEXT_DECORATION_INDEX];
@@ -1882,6 +2715,15 @@ static inline uint8_t get_text_decoration(const css_computed_style *style)
#define TEXT_INDENT_INDEX 2
#define TEXT_INDENT_SHIFT 0
#define TEXT_INDENT_MASK 0x3f
+static inline uint8_t get_text_indent_bits(const css_computed_style *style)
+{
+ uint32_t bits = style->i.bits[TEXT_INDENT_INDEX];
+ bits &= TEXT_INDENT_MASK;
+ bits >>= TEXT_INDENT_SHIFT;
+
+ /* 6bits: uuuuut : unit | type */
+ return (bits & 0x1);
+}
static inline uint8_t get_text_indent(const css_computed_style *style,
css_fixed *length, css_unit *unit)
{
@@ -1904,6 +2746,15 @@ static inline uint8_t get_text_indent(const css_computed_style *style,
#define TEXT_TRANSFORM_INDEX 9
#define TEXT_TRANSFORM_SHIFT 0
#define TEXT_TRANSFORM_MASK 0x7
+static inline uint8_t get_text_transform_bits(const css_computed_style *style)
+{
+ uint32_t bits = style->i.bits[TEXT_TRANSFORM_INDEX];
+ bits &= TEXT_TRANSFORM_MASK;
+ bits >>= TEXT_TRANSFORM_SHIFT;
+
+ /* 3bits: ttt : type */
+ return (bits & 0x7);
+}
static inline uint8_t get_text_transform(const css_computed_style *style)
{
uint32_t bits = style->i.bits[TEXT_TRANSFORM_INDEX];
@@ -1921,31 +2772,29 @@ static inline uint8_t get_text_transform(const css_computed_style *style)
#define TOP_INDEX 4
#define TOP_SHIFT 18
#define TOP_MASK 0x1fc0000
-static inline uint8_t get_top(
- const css_computed_style *style,
- css_fixed *length, css_unit *unit)
+static inline uint8_t get_top_bits(const css_computed_style *style)
{
uint32_t bits = style->i.bits[TOP_INDEX];
bits &= TOP_MASK;
bits >>= TOP_SHIFT;
-
- /* 7bits: uuuuutt : units | type */
- if ((bits & 0x3) == CSS_TOP_SET) {
- *length = style->i.top;
- *unit = bits >> 2;
- }
-
+
+ /* 7bits: uuuuutt : unit | type */
return (bits & 0x3);
}
-static inline uint8_t get_top_bits(
- const css_computed_style *style)
+static inline uint8_t get_top(const css_computed_style *style, css_fixed
+ *length, css_unit *unit)
{
uint32_t bits = style->i.bits[TOP_INDEX];
bits &= TOP_MASK;
bits >>= TOP_SHIFT;
-
- /* 7bits: uuuuutt : units | type */
- return bits;
+
+ /* 7bits: uuuuutt : unit | type */
+ if ((bits & 0x3) == CSS_TOP_SET) {
+ *length = style->i.top;
+ *unit = bits >> 2;
+ }
+
+ return (bits & 0x3);
}
#undef TOP_INDEX
#undef TOP_SHIFT
@@ -1954,6 +2803,15 @@ static inline uint8_t get_top_bits(
#define UNICODE_BIDI_INDEX 10
#define UNICODE_BIDI_SHIFT 12
#define UNICODE_BIDI_MASK 0x3000
+static inline uint8_t get_unicode_bidi_bits(const css_computed_style *style)
+{
+ uint32_t bits = style->i.bits[UNICODE_BIDI_INDEX];
+ bits &= UNICODE_BIDI_MASK;
+ bits >>= UNICODE_BIDI_SHIFT;
+
+ /* 2bits: tt : type */
+ return (bits & 0x3);
+}
static inline uint8_t get_unicode_bidi(const css_computed_style *style)
{
uint32_t bits = style->i.bits[UNICODE_BIDI_INDEX];
@@ -1971,6 +2829,15 @@ static inline uint8_t get_unicode_bidi(const css_computed_style *style)
#define VERTICAL_ALIGN_INDEX 12
#define VERTICAL_ALIGN_SHIFT 1
#define VERTICAL_ALIGN_MASK 0x3fe
+static inline uint8_t get_vertical_align_bits(const css_computed_style *style)
+{
+ uint32_t bits = style->i.bits[VERTICAL_ALIGN_INDEX];
+ bits &= VERTICAL_ALIGN_MASK;
+ bits >>= VERTICAL_ALIGN_SHIFT;
+
+ /* 9bits: uuuuutttt : unit | type */
+ return (bits & 0xf);
+}
static inline uint8_t get_vertical_align(const css_computed_style *style,
css_fixed *length, css_unit *unit)
{
@@ -1993,6 +2860,15 @@ static inline uint8_t get_vertical_align(const css_computed_style *style,
#define VISIBILITY_INDEX 10
#define VISIBILITY_SHIFT 14
#define VISIBILITY_MASK 0xc000
+static inline uint8_t get_visibility_bits(const css_computed_style *style)
+{
+ uint32_t bits = style->i.bits[VISIBILITY_INDEX];
+ bits &= VISIBILITY_MASK;
+ bits >>= VISIBILITY_SHIFT;
+
+ /* 2bits: tt : type */
+ return (bits & 0x3);
+}
static inline uint8_t get_visibility(const css_computed_style *style)
{
uint32_t bits = style->i.bits[VISIBILITY_INDEX];
@@ -2010,6 +2886,15 @@ static inline uint8_t get_visibility(const css_computed_style *style)
#define WHITE_SPACE_INDEX 8
#define WHITE_SPACE_SHIFT 0
#define WHITE_SPACE_MASK 0x7
+static inline uint8_t get_white_space_bits(const css_computed_style *style)
+{
+ uint32_t bits = style->i.bits[WHITE_SPACE_INDEX];
+ bits &= WHITE_SPACE_MASK;
+ bits >>= WHITE_SPACE_SHIFT;
+
+ /* 3bits: ttt : type */
+ return (bits & 0x7);
+}
static inline uint8_t get_white_space(const css_computed_style *style)
{
uint32_t bits = style->i.bits[WHITE_SPACE_INDEX];
@@ -2027,6 +2912,15 @@ static inline uint8_t get_white_space(const css_computed_style *style)
#define WIDOWS_INDEX 12
#define WIDOWS_SHIFT 0
#define WIDOWS_MASK 0x1
+static inline uint8_t get_widows_bits(const css_computed_style *style)
+{
+ uint32_t bits = style->i.bits[WIDOWS_INDEX];
+ bits &= WIDOWS_MASK;
+ bits >>= WIDOWS_SHIFT;
+
+ /* 1bit: t : type */
+ return (bits & 0x1);
+}
static inline uint8_t get_widows(const css_computed_style *style, int32_t
*integer)
{
@@ -2046,6 +2940,15 @@ static inline uint8_t get_widows(const css_computed_style *style, int32_t
#define WIDTH_INDEX 4
#define WIDTH_SHIFT 25
#define WIDTH_MASK 0xfe000000
+static inline uint8_t get_width_bits(const css_computed_style *style)
+{
+ uint32_t bits = style->i.bits[WIDTH_INDEX];
+ bits &= WIDTH_MASK;
+ bits >>= WIDTH_SHIFT;
+
+ /* 7bits: uuuuutt : unit | type */
+ return (bits & 0x3);
+}
static inline uint8_t get_width(const css_computed_style *style, css_fixed
*length, css_unit *unit)
{
@@ -2068,6 +2971,15 @@ static inline uint8_t get_width(const css_computed_style *style, css_fixed
#define WORD_SPACING_INDEX 1
#define WORD_SPACING_SHIFT 0
#define WORD_SPACING_MASK 0x7f
+static inline uint8_t get_word_spacing_bits(const css_computed_style *style)
+{
+ uint32_t bits = style->i.bits[WORD_SPACING_INDEX];
+ bits &= WORD_SPACING_MASK;
+ bits >>= WORD_SPACING_SHIFT;
+
+ /* 7bits: uuuuutt : unit | type */
+ return (bits & 0x3);
+}
static inline uint8_t get_word_spacing(const css_computed_style *style,
css_fixed *length, css_unit *unit)
{
@@ -2090,6 +3002,15 @@ static inline uint8_t get_word_spacing(const css_computed_style *style,
#define WRITING_MODE_INDEX 10
#define WRITING_MODE_SHIFT 16
#define WRITING_MODE_MASK 0x30000
+static inline uint8_t get_writing_mode_bits(const css_computed_style *style)
+{
+ uint32_t bits = style->i.bits[WRITING_MODE_INDEX];
+ bits &= WRITING_MODE_MASK;
+ bits >>= WRITING_MODE_SHIFT;
+
+ /* 2bits: tt : type */
+ return (bits & 0x3);
+}
static inline uint8_t get_writing_mode(const css_computed_style *style)
{
uint32_t bits = style->i.bits[WRITING_MODE_INDEX];
@@ -2107,6 +3028,15 @@ static inline uint8_t get_writing_mode(const css_computed_style *style)
#define Z_INDEX_INDEX 10
#define Z_INDEX_SHIFT 18
#define Z_INDEX_MASK 0xc0000
+static inline uint8_t get_z_index_bits(const css_computed_style *style)
+{
+ uint32_t bits = style->i.bits[Z_INDEX_INDEX];
+ bits &= Z_INDEX_MASK;
+ bits >>= Z_INDEX_SHIFT;
+
+ /* 2bits: tt : type */
+ return (bits & 0x3);
+}
static inline uint8_t get_z_index(const css_computed_style *style, int32_t
*integer)
{
diff --git a/src/select/overrides.py b/src/select/overrides.py
index b4d349a..869d6ec 100644
--- a/src/select/overrides.py
+++ b/src/select/overrides.py
@@ -183,35 +183,3 @@ static inline css_error set_content(
return CSS_OK;
}'''
-
-get_side = '''\
-static inline uint8_t get_{0}(
- const css_computed_style *style,
- css_fixed *length, css_unit *unit)
-{{
- uint32_t bits = style->i.bits[{1}_INDEX];
- bits &= {1}_MASK;
- bits >>= {1}_SHIFT;
-
- /* 7bits: uuuuutt : units | type */
- if ((bits & 0x3) == CSS_{1}_SET) {{
- *length = style->i.{0};
- *unit = bits >> 2;
- }}
-
- return (bits & 0x3);
-}}
-static inline uint8_t get_{0}_bits(
- const css_computed_style *style)
-{{
- uint32_t bits = style->i.bits[{1}_INDEX];
- bits &= {1}_MASK;
- bits >>= {1}_SHIFT;
-
- /* 7bits: uuuuutt : units | type */
- return bits;
-}}'''
-overrides['get']['top'] = get_side.format('top', 'TOP')
-overrides['get']['right'] = get_side.format('right', 'RIGHT')
-overrides['get']['bottom'] = get_side.format('bottom', 'BOTTOM')
-overrides['get']['left'] = get_side.format('left', 'LEFT')
diff --git a/src/select/select_generator.py b/src/select/select_generator.py
index ece7a91..05a4511 100644
--- a/src/select/select_generator.py
+++ b/src/select/select_generator.py
@@ -707,42 +707,32 @@ class CSSGroup:
return t.to_string()
- def make_propget_h(self):
- """Output this group's property functions for the propget.h file."""
- t = Text()
+ def print_propget(self, t, p, only_bits=False):
i_dot, grp = self.get_idot_grp()
- for p in sorted(self.props, key=(lambda x: x.name)):
- defines, undefs = p.def_undefs
-
- t.append()
- t.append(defines)
-
- if p.name in overrides['get']:
- t.append(overrides['get'][p.name], pre_formatted=True)
- t.append(undefs)
- continue
+ 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)
- vals = p.get_param_values(pointer=True)
- params = ', '.join([ 'css_computed_style *style' ]
- + [ ' '.join(x) for x in vals ])
- t.append('static inline uint8_t get_{}(const {})'.format(
- p.name, params))
- t.append('{')
+ if self.name != 'style':
+ t.append('if (style{} != NULL) {{'.format(grp))
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('bits &= {}_MASK;'.format(p.name.upper()))
+ t.append('bits >>= {}_SHIFT;'.format(p.name.upper()))
+ t.append()
- t.append('uint32_t bits = style{}->{}bits[{}_INDEX];'.format(
- grp, i_dot, p.name.upper()))
- t.append('bits &= {}_MASK;'.format(p.name.upper()))
- t.append('bits >>= {}_SHIFT;'.format(p.name.upper()))
- t.append()
+ type_mask, shift_list, bits_comment = p.get_bits()
+ t.append(bits_comment)
- type_mask, shift_list, bits_comment = p.get_bits()
- t.append(bits_comment)
+ if only_bits == False:
if p.condition:
t.append('if ((bits & {}) == {}) {{'.format(
@@ -763,24 +753,42 @@ class CSSGroup:
if p.condition:
t.indent(-1)
t.append('}')
-
t.append()
- 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.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('}')
+
+ def make_propget_h(self):
+ """Output this group's property functions for the propget.h file."""
+ t = Text()
+
+ for p in sorted(self.props, key=(lambda x: x.name)):
+ defines, undefs = p.def_undefs
+
+ t.append()
+ t.append(defines)
+
+ self.print_propget(t, p, True)
+
+ if p.name in overrides['get']:
+ t.append(overrides['get'][p.name], pre_formatted=True)
+ else:
+ self.print_propget(t, p)
+
t.append(undefs)
return t.to_string()
--
Cascading Style Sheets library
6 months, 1 week