summaryrefslogtreecommitdiff
path: root/src/select
diff options
context:
space:
mode:
Diffstat (limited to 'src/select')
-rw-r--r--src/select/computed.c6
-rw-r--r--src/select/computed.h14
-rw-r--r--src/select/properties/column_count.c31
-rw-r--r--src/select/propget.h23
-rw-r--r--src/select/propset.h28
5 files changed, 84 insertions, 18 deletions
diff --git a/src/select/computed.c b/src/select/computed.c
index 9b59dc4..81c7bc7 100644
--- a/src/select/computed.c
+++ b/src/select/computed.c
@@ -787,6 +787,12 @@ uint8_t css_computed_background_position(const css_computed_style *style,
return get_background_position(style, hlength, hunit, vlength, vunit);
}
+uint8_t css_computed_column_count(const css_computed_style *style,
+ int32_t *column_count)
+{
+ return get_column_count(style, column_count);
+}
+
uint8_t css_computed_display(const css_computed_style *style,
bool root)
{
diff --git a/src/select/computed.h b/src/select/computed.h
index e7f3742..ff52df3 100644
--- a/src/select/computed.h
+++ b/src/select/computed.h
@@ -17,12 +17,13 @@ typedef struct css_computed_uncommon {
/*
* border_spacing 1 + 2(4) 2(4)
* clip 2 + 4(4) + 4 4(4)
+ * column_count 2 4
* letter_spacing 2 + 4 4
* outline_color 2 4
* outline_width 3 + 4 4
* word_spacing 2 + 4 4
* --- ---
- * 52 bits 40 bytes
+ * 54 bits 44 bytes
*
* Encode counter_increment and _reset as an array of name, value pairs,
* terminated with a blank entry.
@@ -46,11 +47,11 @@ typedef struct css_computed_uncommon {
* 2 bits sizeof(ptr)
*
* ___ ___
- * 61 bits 40 + 4sizeof(ptr) bytes
+ * 63 bits 44 + 4sizeof(ptr) bytes
*
- * 8 bytes 40 + 4sizeof(ptr) bytes
+ * 8 bytes 44 + 4sizeof(ptr) bytes
* ===================
- * 48 + 4sizeof(ptr) bytes
+ * 52 + 4sizeof(ptr) bytes
*
* Bit allocations:
*
@@ -63,8 +64,9 @@ typedef struct css_computed_uncommon {
* 6 cccccccc clip
* 7 cccccccc clip
* 8 ccccccoo clip | content
+ * 9 cc...... column_count | <unused>
*/
- uint8_t bits[8];
+ uint8_t bits[9];
css_fixed border_spacing[2];
@@ -77,6 +79,8 @@ typedef struct css_computed_uncommon {
css_fixed word_spacing;
+ int32_t column_count;
+
css_computed_counter *counter_increment;
css_computed_counter *counter_reset;
diff --git a/src/select/properties/column_count.c b/src/select/properties/column_count.c
index 5fe7465..ecee5f3 100644
--- a/src/select/properties/column_count.c
+++ b/src/select/properties/column_count.c
@@ -17,23 +17,25 @@
css_error css__cascade_column_count(uint32_t opv, css_style *style,
css_select_state *state)
{
+ uint16_t value = CSS_COLUMN_COUNT_INHERIT;
css_fixed count = 0;
if (isInherit(opv) == false) {
switch (getValue(opv)) {
case COLUMN_COUNT_SET:
+ value = CSS_COLUMN_COUNT_SET;
count = *((css_fixed *) style->bytecode);
advance_bytecode(style, sizeof(count));
break;
case COLUMN_COUNT_AUTO:
- /** \todo convert to public values */
+ value = CSS_COLUMN_COUNT_AUTO;
break;
}
}
if (css__outranks_existing(getOpcode(opv), isImportant(opv), state,
isInherit(opv))) {
- /** \todo set computed elevation */
+ return set_column_count(state->computed, value, count);
}
return CSS_OK;
@@ -42,26 +44,31 @@ css_error css__cascade_column_count(uint32_t opv, css_style *style,
css_error css__set_column_count_from_hint(const css_hint *hint,
css_computed_style *style)
{
- UNUSED(hint);
- UNUSED(style);
-
- return CSS_OK;
+ return set_column_count(style, hint->status, hint->data.integer);
}
css_error css__initial_column_count(css_select_state *state)
{
- UNUSED(state);
-
- return CSS_OK;
+ return set_column_count(state->computed, CSS_COLUMN_COUNT_AUTO, 0);
}
css_error css__compose_column_count(const css_computed_style *parent,
const css_computed_style *child,
css_computed_style *result)
{
- UNUSED(parent);
- UNUSED(child);
- UNUSED(result);
+ int32_t count = 0;
+ uint8_t type = get_column_count(child, &count);
+
+ if ((child->uncommon == NULL && parent->uncommon != NULL) ||
+ type == CSS_COLUMN_COUNT_INHERIT ||
+ (child->uncommon != NULL && result != child)) {
+ if ((child->uncommon == NULL && parent->uncommon != NULL) ||
+ type == CSS_OUTLINE_COLOR_INHERIT) {
+ type = get_column_count(parent, &count);
+ }
+
+ return set_column_count(result, type, count);
+ }
return CSS_OK;
}
diff --git a/src/select/propget.h b/src/select/propget.h
index b124cfe..a9b8edc 100644
--- a/src/select/propget.h
+++ b/src/select/propget.h
@@ -342,6 +342,29 @@ static inline uint8_t get_clip(
#undef CLIP_SHIFT
#undef CLIP_INDEX
+#define COLUMN_COUNT_INDEX 8
+#define COLUMN_COUNT_SHIFT 6
+#define COLUMN_COUNT_MASK 0xc0
+static inline uint8_t get_column_count(
+ const css_computed_style *style, int32_t *count)
+{
+ if (style->uncommon != NULL) {
+ uint8_t bits = style->uncommon->bits[COLUMN_COUNT_INDEX];
+ bits &= COLUMN_COUNT_MASK;
+ bits >>= COLUMN_COUNT_SHIFT;
+
+ /* 2bits: tt : type */
+ *count = style->uncommon->column_count;
+
+ return bits;
+ }
+
+ return CSS_COLUMN_COUNT_AUTO;
+}
+#undef COLUMN_COUNT_MASK
+#undef COLUMN_COUNT_SHIFT
+#undef COLUMN_COUNT_INDEX
+
#define CONTENT_INDEX 7
#define CONTENT_SHIFT 0
#define CONTENT_MASK 0x3
diff --git a/src/select/propset.h b/src/select/propset.h
index b7da5a6..52d9d8a 100644
--- a/src/select/propset.h
+++ b/src/select/propset.h
@@ -25,7 +25,8 @@ static const css_computed_uncommon default_uncommon = {
(CSS_CURSOR_INHERIT << 3) | (CSS_WRITING_MODE_INHERIT << 1) | 0,
0,
0,
- (CSS_CLIP_AUTO << 2) | CSS_CONTENT_NORMAL
+ (CSS_CLIP_AUTO << 2) | CSS_CONTENT_NORMAL,
+ (CSS_COLUMN_COUNT_AUTO << 6)
},
{ 0, 0 },
{ 0, 0, 0, 0 },
@@ -33,6 +34,7 @@ static const css_computed_uncommon default_uncommon = {
0,
0,
0,
+ 0,
NULL,
NULL,
NULL,
@@ -404,6 +406,30 @@ static inline css_error set_clip(
#undef CLIP_SHIFT
#undef CLIP_INDEX
+#define COLUMN_COUNT_INDEX 8
+#define COLUMN_COUNT_SHIFT 6
+#define COLUMN_COUNT_MASK 0xc0
+static inline css_error set_column_count(
+ css_computed_style *style, uint8_t type, int32_t count)
+{
+ uint8_t *bits;
+
+ ENSURE_UNCOMMON;
+
+ bits = &style->uncommon->bits[COLUMN_COUNT_INDEX];
+
+ /* 2bits: tt : type */
+ *bits = (*bits & ~COLUMN_COUNT_MASK) |
+ ((type & 0x3) << COLUMN_COUNT_SHIFT);
+
+ style->uncommon->column_count = count;
+
+ return CSS_OK;
+}
+#undef COLUMN_COUNT_MASK
+#undef COLUMN_COUNT_SHIFT
+#undef COLUMN_COUNT_INDEX
+
#define CONTENT_INDEX 7
#define CONTENT_SHIFT 0
#define CONTENT_MASK 0x3