summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorMichael Drake <tlsa@netsurf-browser.org>2014-12-29 18:19:22 +0000
committerMichael Drake <tlsa@netsurf-browser.org>2014-12-29 19:06:20 +0000
commit30833a1ad59bc1f20a4995b23d2794be17227b51 (patch)
tree696fa80bc1fc9fcb5f20c9f283682e13bf91caf0 /src
parent8bce7365823f887113c73af46ecdfee6322653f9 (diff)
downloadlibcss-30833a1ad59bc1f20a4995b23d2794be17227b51.tar.gz
libcss-30833a1ad59bc1f20a4995b23d2794be17227b51.tar.bz2
Add break-after property support.
Diffstat (limited to 'src')
-rw-r--r--src/select/computed.c5
-rw-r--r--src/select/computed.h15
-rw-r--r--src/select/properties/break_after.c45
-rw-r--r--src/select/propget.h22
-rw-r--r--src/select/propset.h26
5 files changed, 72 insertions, 41 deletions
diff --git a/src/select/computed.c b/src/select/computed.c
index ddaad6e..ff6da17 100644
--- a/src/select/computed.c
+++ b/src/select/computed.c
@@ -787,6 +787,11 @@ uint8_t css_computed_background_position(const css_computed_style *style,
return get_background_position(style, hlength, hunit, vlength, vunit);
}
+uint8_t css_computed_break_after(const css_computed_style *style)
+{
+ return get_break_after(style);
+}
+
uint8_t css_computed_column_count(const css_computed_style *style,
int32_t *column_count)
{
diff --git a/src/select/computed.h b/src/select/computed.h
index 574d36b..0ca01d9 100644
--- a/src/select/computed.h
+++ b/src/select/computed.h
@@ -16,6 +16,9 @@
typedef struct css_computed_uncommon {
/*
* border_spacing 1 + 2(4) 2(4)
+ * break_before 4 0
+ * break_after 4 0
+ * break_inside 4 0
* clip 2 + 4(4) + 4 4(4)
* column_count 2 4
* column_fill 2 0
@@ -30,7 +33,7 @@ typedef struct css_computed_uncommon {
* outline_width 3 + 4 4
* word_spacing 2 + 4 4
* --- ---
- * 83 bits 60 bytes
+ * 95 bits 60 bytes
*
* Encode counter_increment and _reset as an array of name, value pairs,
* terminated with a blank entry.
@@ -54,11 +57,11 @@ typedef struct css_computed_uncommon {
* 2 bits sizeof(ptr)
*
* ___ ___
- * 96 bits 62 + 4sizeof(ptr) bytes
+ * 108 bits 62 + 4sizeof(ptr) bytes
*
- * 12 bytes 62 + 4sizeof(ptr) bytes
+ * 14 bytes 62 + 4sizeof(ptr) bytes
* ===================
- * 72 + 4sizeof(ptr) bytes
+ * 74 + 4sizeof(ptr) bytes
*
* Bit allocations:
*
@@ -75,8 +78,10 @@ typedef struct css_computed_uncommon {
* 10 ggggggcc column-gap | column-rule-color
* 11 wwwwwww. column-rule-width | <unused>
* 12 sswwwwww column-span | column_width
+ * 13 bbbbaaaa break-before | break-after
+ * 14 iiii.... break-inside | <unused>
*/
- uint8_t bits[12];
+ uint8_t bits[14];
css_fixed border_spacing[2];
diff --git a/src/select/properties/break_after.c b/src/select/properties/break_after.c
index 8a2cffc..496a59b 100644
--- a/src/select/properties/break_after.c
+++ b/src/select/properties/break_after.c
@@ -17,56 +17,31 @@
css_error css__cascade_break_after(uint32_t opv, css_style *style,
css_select_state *state)
{
- UNUSED(style);
-
- if (isInherit(opv) == false) {
- switch (getValue(opv)) {
- case BREAK_AFTER_AUTO:
- case BREAK_AFTER_ALWAYS:
- case BREAK_AFTER_AVOID:
- case BREAK_AFTER_LEFT:
- case BREAK_AFTER_RIGHT:
- case BREAK_AFTER_PAGE:
- case BREAK_AFTER_COLUMN:
- case BREAK_AFTER_AVOID_PAGE:
- case BREAK_AFTER_AVOID_COLUMN:
- /** \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_break_after_before_inside(opv, style, state,
+ set_break_after);
}
css_error css__set_break_after_from_hint(const css_hint *hint,
css_computed_style *style)
{
- UNUSED(hint);
- UNUSED(style);
-
- return CSS_OK;
+ return set_break_after(style, hint->status);
}
css_error css__initial_break_after(css_select_state *state)
{
- UNUSED(state);
-
- return CSS_OK;
+ return set_break_after(state->computed, CSS_BREAK_AFTER_AUTO);
}
css_error css__compose_break_after(const css_computed_style *parent,
const css_computed_style *child,
css_computed_style *result)
{
- UNUSED(parent);
- UNUSED(child);
- UNUSED(result);
+ uint8_t type = get_break_after(child);
+
+ if (type == CSS_BREAK_AFTER_INHERIT) {
+ type = get_break_after(parent);
+ }
- return CSS_OK;
+ return set_break_after(result, type);
}
diff --git a/src/select/propget.h b/src/select/propget.h
index d4ec329..756a7b3 100644
--- a/src/select/propget.h
+++ b/src/select/propget.h
@@ -144,6 +144,28 @@ static inline uint8_t get_border_spacing(
#undef BORDER_SPACING_SHIFT
#undef BORDER_SPACING_INDEX
+#define BREAK_AFTER_INDEX 12
+#define BREAK_AFTER_SHIFT 0
+#define BREAK_AFTER_MASK 0xf
+static inline uint8_t get_break_after(
+ const css_computed_style *style)
+{
+ if (style->uncommon != NULL) {
+ uint8_t bits = style->uncommon->bits[BREAK_AFTER_INDEX];
+ bits &= BREAK_AFTER_MASK;
+ bits >>= BREAK_AFTER_SHIFT;
+
+ /* 4bits: type */
+ return bits;
+ }
+
+ /* Not inherited; initial value */
+ return CSS_BREAK_AFTER_AUTO;
+}
+#undef BREAK_AFTER_MASK
+#undef BREAK_AFTER_SHIFT
+#undef BREAK_AFTER_INDEX
+
#define WORD_SPACING_INDEX 3
#define WORD_SPACING_SHIFT 2
#define WORD_SPACING_MASK 0xfc
diff --git a/src/select/propset.h b/src/select/propset.h
index 08a083a..c202ce7 100644
--- a/src/select/propset.h
+++ b/src/select/propset.h
@@ -32,7 +32,9 @@ static const css_computed_uncommon default_uncommon = {
(CSS_COLUMN_RULE_STYLE_NONE << 0),
(CSS_COLUMN_GAP_NORMAL << 2) | (CSS_COLUMN_RULE_COLOR_CURRENT_COLOR),
(CSS_COLUMN_RULE_WIDTH_MEDIUM << 1),
- (CSS_COLUMN_SPAN_NONE << 6) | CSS_COLUMN_WIDTH_AUTO
+ (CSS_COLUMN_SPAN_NONE << 6) | CSS_COLUMN_WIDTH_AUTO,
+ (CSS_BREAK_BEFORE_AUTO << 4) | CSS_BREAK_AFTER_AUTO,
+ (CSS_BREAK_INSIDE_AUTO)
},
{ 0, 0 },
{ 0, 0, 0, 0 },
@@ -196,6 +198,28 @@ static inline css_error set_border_spacing(
#undef BORDER_SPACING_SHIFT
#undef BORDER_SPACING_INDEX
+#define BREAK_AFTER_INDEX 12
+#define BREAK_AFTER_SHIFT 0
+#define BREAK_AFTER_MASK 0xf
+static inline css_error set_break_after(
+ css_computed_style *style, uint8_t type)
+{
+ uint8_t *bits;
+
+ ENSURE_UNCOMMON;
+
+ bits = &style->uncommon->bits[BREAK_AFTER_INDEX];
+
+ /* 4bits: type */
+ *bits = (*bits & ~BREAK_AFTER_MASK) |
+ ((type & 0xf) << BREAK_AFTER_SHIFT);
+
+ return CSS_OK;
+}
+#undef BREAK_AFTER_MASK
+#undef BREAK_AFTER_SHIFT
+#undef BREAK_AFTER_INDEX
+
#define WORD_SPACING_INDEX 3
#define WORD_SPACING_SHIFT 2
#define WORD_SPACING_MASK 0xfc