summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDaniel Silverstone <dsilvers@digital-scurf.org>2024-05-25 20:34:07 +0100
committerDaniel Silverstone <dsilvers@digital-scurf.org>2024-05-26 17:01:33 +0100
commit4db86b45b8b793bac0bcb06cf965cc0ff6d9277f (patch)
tree3ccc13dba82e3a1c4d786e9f2ed54aed16e5a253
parent5cf3c54c8500c22e8da283c5a5f66df93cf87d5e (diff)
downloadlibcss-4db86b45b8b793bac0bcb06cf965cc0ff6d9277f.tar.gz
libcss-4db86b45b8b793bac0bcb06cf965cc0ff6d9277f.tar.bz2
select: Turn on width as calc property
Signed-off-by: Daniel Silverstone <dsilvers@digital-scurf.org>
-rw-r--r--src/select/autogenerated_computed.h7
-rw-r--r--src/select/autogenerated_propget.h9
-rw-r--r--src/select/autogenerated_propset.h22
-rw-r--r--src/select/select_config.py2
4 files changed, 34 insertions, 6 deletions
diff --git a/src/select/autogenerated_computed.h b/src/select/autogenerated_computed.h
index 11ba1aa..e663e90 100644
--- a/src/select/autogenerated_computed.h
+++ b/src/select/autogenerated_computed.h
@@ -5,6 +5,9 @@
* Copyright 2017 The NetSurf Project
*/
+#ifndef CSS_COMPUTED_COMPUTED_H_
+#define CSS_COMPUTED_COMPUTED_H_
+
typedef union {
css_fixed value;
lwc_string *calc;
@@ -269,7 +272,7 @@ struct css_computed_style_i {
css_fixed top;
css_fixed vertical_align;
int32_t widows;
- css_fixed width;
+ css_fixed_or_calc width;
css_fixed word_spacing;
int32_t z_index;
};
@@ -288,3 +291,5 @@ struct css_computed_style {
uint32_t count;
uint32_t bin;
};
+
+#endif
diff --git a/src/select/autogenerated_propget.h b/src/select/autogenerated_propget.h
index d1f7ffb..e335132 100644
--- a/src/select/autogenerated_propget.h
+++ b/src/select/autogenerated_propget.h
@@ -5,6 +5,9 @@
* Copyright 2017 The NetSurf Project
*/
+#ifndef CSS_COMPUTED_PROPGET_H_
+#define CSS_COMPUTED_PROPGET_H_
+
#define ALIGN_CONTENT_INDEX 10
#define ALIGN_CONTENT_SHIFT 20
@@ -3009,8 +3012,8 @@ static inline uint8_t get_width_bits(const css_computed_style *style)
/* 7bits: uuuuutt : unit | type */
return (bits & 0x3);
}
-static inline uint8_t get_width(const css_computed_style *style, css_fixed
- *length, css_unit *unit)
+static inline uint8_t get_width(const css_computed_style *style,
+ css_fixed_or_calc *length, css_unit *unit)
{
uint32_t bits = style->i.bits[WIDTH_INDEX];
bits &= WIDTH_MASK;
@@ -3112,3 +3115,5 @@ static inline uint8_t get_z_index(const css_computed_style *style, int32_t
#undef Z_INDEX_INDEX
#undef Z_INDEX_SHIFT
#undef Z_INDEX_MASK
+
+#endif
diff --git a/src/select/autogenerated_propset.h b/src/select/autogenerated_propset.h
index e5ec607..6db1901 100644
--- a/src/select/autogenerated_propset.h
+++ b/src/select/autogenerated_propset.h
@@ -5,6 +5,9 @@
* Copyright 2017 The NetSurf Project
*/
+#ifndef CSS_COMPUTED_PROPSET_H_
+#define CSS_COMPUTED_PROPSET_H_
+
#include "select/propget.h"
@@ -2267,15 +2270,28 @@ static inline css_error set_widows(css_computed_style *style, uint8_t type,
#define WIDTH_MASK 0xfe000000
static inline css_error set_width(css_computed_style *style, uint8_t type,
- css_fixed length, css_unit unit)
+ css_fixed_or_calc length, css_unit unit)
{
+ uint32_t orig_bits = get_width_bits(style);
+
+ /* 7bits: uuuuutt : unit | type */
+ if ((orig_bits & 0x3) == CSS_WIDTH_SET) {
+ if ((orig_bits & 0x7c) >> 2 == CSS_UNIT_CALC) {
+ lwc_string_unref(style->i.width.calc);
+ }
+ }
+
uint32_t *bits = &style->i.bits[WIDTH_INDEX];
/* 7bits: uuuuutt : unit | type */
*bits = (*bits & ~WIDTH_MASK) | ((((uint32_t)type & 0x3) | (unit << 2))
<< WIDTH_SHIFT);
- style->i.width = length;
+ if (unit == CSS_UNIT_CALC) {
+ style->i.width.calc = lwc_string_ref(length.calc);
+ } else {
+ style->i.width.value = length.value;
+ }
return CSS_OK;
}
@@ -2343,3 +2359,5 @@ static inline css_error set_z_index(css_computed_style *style, uint8_t type,
#undef Z_INDEX_INDEX
#undef Z_INDEX_SHIFT
#undef Z_INDEX_MASK
+
+#endif
diff --git a/src/select/select_config.py b/src/select/select_config.py
index 1cfe05c..a4ba423 100644
--- a/src/select/select_config.py
+++ b/src/select/select_config.py
@@ -104,7 +104,7 @@ style = {
('padding_bottom', 1, 'length', 'CSS_PADDING_SET'),
('text_indent', 1, 'length', 'CSS_TEXT_INDENT_SET'),
('vertical_align', 4, 'length', 'CSS_VERTICAL_ALIGN_SET'),
- ('width', 2, 'length', 'CSS_WIDTH_SET'),
+ ('width', 2, (('length', None, 'calc'),), 'CSS_WIDTH_SET'),
('z_index', 2, 'integer'),
# Style group, arrays
('font_family', 3, 'string_arr', None, None,