summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMichael Drake <tlsa@netsurf-browser.org>2014-11-15 20:50:33 +0000
committerMichael Drake <tlsa@netsurf-browser.org>2014-11-15 20:50:33 +0000
commitf30a2de02b63140a4f8194419cef20c7375d6756 (patch)
tree66265ad7d4d0d36956b1233e7702e79f62e4f136
parent4f240a620321b64354f64d07b382fdf3caa09109 (diff)
downloadlibcss-f30a2de02b63140a4f8194419cef20c7375d6756.tar.gz
libcss-f30a2de02b63140a4f8194419cef20c7375d6756.tar.bz2
Add column-rule-color to computed styles.
-rw-r--r--src/select/computed.h12
-rw-r--r--src/select/properties/column_rule_color.c42
-rw-r--r--src/select/propget.h25
-rw-r--r--src/select/propset.h28
4 files changed, 83 insertions, 24 deletions
diff --git a/src/select/computed.h b/src/select/computed.h
index 12d160a..2f90985 100644
--- a/src/select/computed.h
+++ b/src/select/computed.h
@@ -20,12 +20,13 @@ typedef struct css_computed_uncommon {
* column_count 2 4
* column_fill 2 0
* column_gap 2 + 4 4
+ * column_rule_color 2 4
* letter_spacing 2 + 4 4
* outline_color 2 4
* outline_width 3 + 4 4
* word_spacing 2 + 4 4
* --- ---
- * 62 bits 48 bytes
+ * 64 bits 52 bytes
*
* Encode counter_increment and _reset as an array of name, value pairs,
* terminated with a blank entry.
@@ -49,11 +50,11 @@ typedef struct css_computed_uncommon {
* 2 bits sizeof(ptr)
*
* ___ ___
- * 71 bits 48 + 4sizeof(ptr) bytes
+ * 73 bits 52 + 4sizeof(ptr) bytes
*
- * 10 bytes 48 + 4sizeof(ptr) bytes
+ * 10 bytes 52 + 4sizeof(ptr) bytes
* ===================
- * 58 + 4sizeof(ptr) bytes
+ * 62 + 4sizeof(ptr) bytes
*
* Bit allocations:
*
@@ -67,7 +68,7 @@ typedef struct css_computed_uncommon {
* 7 cccccccc clip
* 8 ccccccoo clip | content
* 9 ccff.... column_count | column-fill | <unused>
- * 10 gggggg.. column-gap | <unused>
+ * 10 ggggggcc column-gap | column-rule-color
*/
uint8_t bits[10];
@@ -84,6 +85,7 @@ typedef struct css_computed_uncommon {
int32_t column_count;
css_fixed column_gap;
+ css_color column_rule_color;
css_computed_counter *counter_increment;
css_computed_counter *counter_reset;
diff --git a/src/select/properties/column_rule_color.c b/src/select/properties/column_rule_color.c
index 933cb60..d4b0e77 100644
--- a/src/select/properties/column_rule_color.c
+++ b/src/select/properties/column_rule_color.c
@@ -17,24 +17,31 @@
css_error css__cascade_column_rule_color(uint32_t opv, css_style *style,
css_select_state *state)
{
+ bool inherit = isInherit(opv);
+ uint16_t value = CSS_COLUMN_RULE_COLOR_INHERIT;
css_color color = 0;
if (isInherit(opv) == false) {
switch (getValue(opv)) {
- case COLUMN_RULE_COLOR_SET:
- color = *((css_fixed *) style->bytecode);
- advance_bytecode(style, sizeof(color));
- break;
case COLUMN_RULE_COLOR_TRANSPARENT:
+ value = CSS_COLUMN_RULE_COLOR_COLOR;
+ break;
case COLUMN_RULE_COLOR_CURRENT_COLOR:
- /** \todo convert to public values */
+ /* color: currentColor always computes to inherit */
+ value = CSS_COLUMN_RULE_COLOR_INHERIT;
+ inherit = true;
+ break;
+ case COLUMN_RULE_COLOR_SET:
+ value = CSS_COLUMN_RULE_COLOR_COLOR;
+ color = *((css_fixed *) style->bytecode);
+ advance_bytecode(style, sizeof(color));
break;
}
}
if (css__outranks_existing(getOpcode(opv), isImportant(opv), state,
- isInherit(opv))) {
- /** \todo set computed elevation */
+ inherit)) {
+ return set_column_rule_color(state->computed, value, color);
}
return CSS_OK;
@@ -43,27 +50,26 @@ css_error css__cascade_column_rule_color(uint32_t opv, css_style *style,
css_error css__set_column_rule_color_from_hint(const css_hint *hint,
css_computed_style *style)
{
- UNUSED(hint);
- UNUSED(style);
-
- return CSS_OK;
+ return set_column_rule_color(style, hint->status, hint->data.color);
}
css_error css__initial_column_rule_color(css_select_state *state)
{
- UNUSED(state);
-
- return CSS_OK;
+ return set_column_rule_color(state->computed,
+ CSS_COLUMN_RULE_COLOR_INHERIT, 0);
}
css_error css__compose_column_rule_color(const css_computed_style *parent,
const css_computed_style *child,
css_computed_style *result)
{
- UNUSED(parent);
- UNUSED(child);
- UNUSED(result);
+ css_color color;
+ uint8_t type = get_column_rule_color(child, &color);
- return CSS_OK;
+ if (type == CSS_COLUMN_RULE_COLOR_INHERIT) {
+ type = get_column_rule_color(parent, &color);
+ }
+
+ return set_column_rule_color(result, type, color);
}
diff --git a/src/select/propget.h b/src/select/propget.h
index 63eea95..6150ff7 100644
--- a/src/select/propget.h
+++ b/src/select/propget.h
@@ -413,6 +413,31 @@ static inline uint8_t get_column_gap(
#undef COLUMN_GAP_SHIFT
#undef COLUMN_GAP_INDEX
+#define COLUMN_RULE_COLOR_INDEX 9
+#define COLUMN_RULE_COLOR_SHIFT 0
+#define COLUMN_RULE_COLOR_MASK 0x3
+static inline uint8_t get_column_rule_color(
+ const css_computed_style *style,
+ css_color *color)
+{
+ if (style->uncommon != NULL) {
+ uint8_t bits = style->uncommon->bits[COLUMN_RULE_COLOR_INDEX];
+ bits &= COLUMN_RULE_COLOR_MASK;
+ bits >>= COLUMN_RULE_COLOR_SHIFT;
+
+ /* 2bits: type */
+ *color = style->uncommon->column_rule_color;
+
+ return bits;
+ }
+
+ *color = 0;
+ return CSS_COLUMN_RULE_COLOR_CURRENT_COLOR;
+}
+#undef COLUMN_RULE_COLOR_MASK
+#undef COLUMN_RULE_COLOR_SHIFT
+#undef COLUMN_RULE_COLOR_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 8d43301..834ed77 100644
--- a/src/select/propset.h
+++ b/src/select/propset.h
@@ -27,7 +27,7 @@ static const css_computed_uncommon default_uncommon = {
0,
(CSS_CLIP_AUTO << 2) | CSS_CONTENT_NORMAL,
(CSS_COLUMN_COUNT_AUTO << 6) | (CSS_COLUMN_FILL_BALANCE << 4),
- (CSS_COLUMN_GAP_NORMAL << 2)
+ (CSS_COLUMN_GAP_NORMAL << 2) | (CSS_COLUMN_RULE_COLOR_CURRENT_COLOR)
},
{ 0, 0 },
{ 0, 0, 0, 0 },
@@ -37,6 +37,7 @@ static const css_computed_uncommon default_uncommon = {
0,
0,
0,
+ 0,
NULL,
NULL,
NULL,
@@ -479,6 +480,31 @@ static inline css_error set_column_gap(
#undef COLUMN_GAP_SHIFT
#undef COLUMN_GAP_INDEX
+#define COLUMN_RULE_COLOR_INDEX 9
+#define COLUMN_RULE_COLOR_SHIFT 0
+#define COLUMN_RULE_COLOR_MASK 0x3
+static inline css_error set_column_rule_color(
+ css_computed_style *style, uint8_t type,
+ css_color color)
+{
+ uint8_t *bits;
+
+ ENSURE_UNCOMMON;
+
+ bits = &style->uncommon->bits[COLUMN_RULE_COLOR_INDEX];
+
+ /* 2bits: type */
+ *bits = (*bits & ~COLUMN_RULE_COLOR_MASK) |
+ ((type & 0x3) << COLUMN_RULE_COLOR_SHIFT);
+
+ style->uncommon->column_rule_color = color;
+
+ return CSS_OK;
+}
+#undef COLUMN_RULE_COLOR_MASK
+#undef COLUMN_RULE_COLOR_SHIFT
+#undef COLUMN_RULE_COLOR_INDEX
+
#define CONTENT_INDEX 7
#define CONTENT_SHIFT 0
#define CONTENT_MASK 0x3