summaryrefslogtreecommitdiff
path: root/src/select
diff options
context:
space:
mode:
authorMichael Drake <tlsa@netsurf-browser.org>2014-11-06 14:39:07 +0000
committerMichael Drake <tlsa@netsurf-browser.org>2014-11-07 12:24:25 +0000
commitad85983173b7cf21c5b46f7fb3798afdb38e9fea (patch)
tree439979631b3b4de50be4eb7c93835030d75c54c0 /src/select
parenta5c3cbf24c7112238643b58b346d6169ef904881 (diff)
downloadlibcss-ad85983173b7cf21c5b46f7fb3798afdb38e9fea.tar.gz
libcss-ad85983173b7cf21c5b46f7fb3798afdb38e9fea.tar.bz2
Implement selection for column-gap property.
Diffstat (limited to 'src/select')
-rw-r--r--src/select/computed.h13
-rw-r--r--src/select/properties/column_gap.c52
-rw-r--r--src/select/propget.h27
-rw-r--r--src/select/propset.h29
4 files changed, 82 insertions, 39 deletions
diff --git a/src/select/computed.h b/src/select/computed.h
index 23b0cb6..12d160a 100644
--- a/src/select/computed.h
+++ b/src/select/computed.h
@@ -19,12 +19,13 @@ typedef struct css_computed_uncommon {
* clip 2 + 4(4) + 4 4(4)
* column_count 2 4
* column_fill 2 0
+ * column_gap 2 + 4 4
* letter_spacing 2 + 4 4
* outline_color 2 4
* outline_width 3 + 4 4
* word_spacing 2 + 4 4
* --- ---
- * 56 bits 44 bytes
+ * 62 bits 48 bytes
*
* Encode counter_increment and _reset as an array of name, value pairs,
* terminated with a blank entry.
@@ -48,11 +49,11 @@ typedef struct css_computed_uncommon {
* 2 bits sizeof(ptr)
*
* ___ ___
- * 65 bits 44 + 4sizeof(ptr) bytes
+ * 71 bits 48 + 4sizeof(ptr) bytes
*
- * 8 bytes 44 + 4sizeof(ptr) bytes
+ * 10 bytes 48 + 4sizeof(ptr) bytes
* ===================
- * 52 + 4sizeof(ptr) bytes
+ * 58 + 4sizeof(ptr) bytes
*
* Bit allocations:
*
@@ -66,8 +67,9 @@ typedef struct css_computed_uncommon {
* 7 cccccccc clip
* 8 ccccccoo clip | content
* 9 ccff.... column_count | column-fill | <unused>
+ * 10 gggggg.. column-gap | <unused>
*/
- uint8_t bits[9];
+ uint8_t bits[10];
css_fixed border_spacing[2];
@@ -81,6 +83,7 @@ typedef struct css_computed_uncommon {
css_fixed word_spacing;
int32_t column_count;
+ css_fixed column_gap;
css_computed_counter *counter_increment;
css_computed_counter *counter_reset;
diff --git a/src/select/properties/column_gap.c b/src/select/properties/column_gap.c
index 8b7a841..641f529 100644
--- a/src/select/properties/column_gap.c
+++ b/src/select/properties/column_gap.c
@@ -17,54 +17,40 @@
css_error css__cascade_column_gap(uint32_t opv, css_style *style,
css_select_state *state)
{
- css_fixed length = 0;
- uint32_t unit = UNIT_PX;
-
- if (isInherit(opv) == false) {
- switch (getValue(opv)) {
- case COLUMN_GAP_SET:
- length = *((css_fixed *) style->bytecode);
- advance_bytecode(style, sizeof(length));
- unit = *((uint32_t *) style->bytecode);
- advance_bytecode(style, sizeof(unit));
- break;
- case COLUMN_GAP_NORMAL:
- /** \todo convert to public values */
- break;
- }
- }
-
- if (css__outranks_existing(getOpcode(opv), isImportant(opv), state,
- isInherit(opv))) {
- /** \todo set computed elevation */
- }
-
- return CSS_OK;
+ return css__cascade_length_normal(opv, style, state, set_column_gap);
}
css_error css__set_column_gap_from_hint(const css_hint *hint,
css_computed_style *style)
{
- UNUSED(hint);
- UNUSED(style);
-
- return CSS_OK;
+ return set_column_gap(style, hint->status,
+ hint->data.length.value, hint->data.length.unit);
}
css_error css__initial_column_gap(css_select_state *state)
{
- UNUSED(state);
-
- return CSS_OK;
+ return set_column_gap(state->computed, CSS_COLUMN_GAP_NORMAL,
+ INTTOFIX(1), CSS_UNIT_EM);
}
css_error css__compose_column_gap(const css_computed_style *parent,
const css_computed_style *child,
css_computed_style *result)
{
- UNUSED(parent);
- UNUSED(child);
- UNUSED(result);
+ css_fixed length = INTTOFIX(1);
+ css_unit unit = CSS_UNIT_EM;
+ uint8_t type = get_column_gap(child, &length, &unit);
+
+ if ((child->uncommon == NULL && parent->uncommon != NULL) ||
+ type == CSS_COLUMN_GAP_INHERIT ||
+ (child->uncommon != NULL && result != child)) {
+ if ((child->uncommon == NULL && parent->uncommon != NULL) ||
+ type == CSS_COLUMN_GAP_INHERIT) {
+ type = get_column_gap(parent, &length, &unit);
+ }
+
+ return set_column_gap(result, type, length, unit);
+ }
return CSS_OK;
}
diff --git a/src/select/propget.h b/src/select/propget.h
index 7085eba..c450a45 100644
--- a/src/select/propget.h
+++ b/src/select/propget.h
@@ -386,6 +386,33 @@ static inline uint8_t get_column_fill(
#undef COLUMN_FILL_SHIFT
#undef COLUMN_FILL_INDEX
+#define COLUMN_GAP_INDEX 9
+#define COLUMN_GAP_SHIFT 2
+#define COLUMN_GAP_MASK 0xfc
+static inline uint8_t get_column_gap(
+ const css_computed_style *style,
+ css_fixed *length, css_unit *unit)
+{
+ if (style->uncommon != NULL) {
+ uint8_t bits = style->uncommon->bits[COLUMN_GAP_INDEX];
+ bits &= COLUMN_GAP_MASK;
+ bits >>= COLUMN_GAP_SHIFT;
+
+ /* 6bits: uuuutt : units | type */
+ if ((bits & 0x3) == CSS_COLUMN_GAP_SET) {
+ *length = style->uncommon->column_gap;
+ *unit = bits >> 2;
+ }
+
+ return (bits & 0x3);
+ }
+
+ return CSS_COLUMN_GAP_NORMAL;
+}
+#undef COLUMN_GAP_MASK
+#undef COLUMN_GAP_SHIFT
+#undef COLUMN_GAP_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 23d8076..acb2817 100644
--- a/src/select/propset.h
+++ b/src/select/propset.h
@@ -26,7 +26,8 @@ static const css_computed_uncommon default_uncommon = {
0,
0,
(CSS_CLIP_AUTO << 2) | CSS_CONTENT_NORMAL,
- (CSS_COLUMN_COUNT_AUTO << 6) | (CSS_COLUMN_FILL_BALANCE << 4)
+ (CSS_COLUMN_COUNT_AUTO << 6) | (CSS_COLUMN_FILL_BALANCE << 4),
+ (CSS_COLUMN_GAP_NORMAL << 2)
},
{ 0, 0 },
{ 0, 0, 0, 0 },
@@ -35,6 +36,7 @@ static const css_computed_uncommon default_uncommon = {
0,
0,
0,
+ 0,
NULL,
NULL,
NULL,
@@ -452,6 +454,31 @@ static inline css_error set_column_fill(
#undef COLUMN_FILL_SHIFT
#undef COLUMN_FILL_INDEX
+#define COLUMN_GAP_INDEX 9
+#define COLUMN_GAP_SHIFT 2
+#define COLUMN_GAP_MASK 0xfc
+static inline css_error set_column_gap(
+ css_computed_style *style, uint8_t type,
+ css_fixed length, css_unit unit)
+{
+ uint8_t *bits;
+
+ ENSURE_UNCOMMON;
+
+ bits = &style->uncommon->bits[COLUMN_GAP_INDEX];
+
+ /* 6bits: uuuutt : units | type */
+ *bits = (*bits & ~COLUMN_GAP_MASK) |
+ (((type & 0x3) | (unit << 2)) << COLUMN_GAP_SHIFT);
+
+ style->uncommon->column_gap = length;
+
+ return CSS_OK;
+}
+#undef COLUMN_GAP_MASK
+#undef COLUMN_GAP_SHIFT
+#undef COLUMN_GAP_INDEX
+
#define CONTENT_INDEX 7
#define CONTENT_SHIFT 0
#define CONTENT_MASK 0x3