summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMichael Drake <tlsa@netsurf-browser.org>2014-12-29 18:21:21 (GMT)
committer Michael Drake <tlsa@netsurf-browser.org>2014-12-29 19:06:20 (GMT)
commit4729e025decd4d92ceeeb40659decf6183594ac6 (patch)
tree0e6499556d4bb8a6d22c4219fcc13d49272b69dd
parent24207928eb8ba5cc40db4ddd60c60866ec8af684 (diff)
downloadlibcss-4729e025decd4d92ceeeb40659decf6183594ac6.tar.gz
libcss-4729e025decd4d92ceeeb40659decf6183594ac6.tar.bz2
Add break-inside property support.
-rw-r--r--include/libcss/computed.h3
-rw-r--r--src/select/computed.c5
-rw-r--r--src/select/properties/break_inside.c40
-rw-r--r--src/select/propget.h22
-rw-r--r--src/select/propset.h22
5 files changed, 62 insertions, 30 deletions
diff --git a/include/libcss/computed.h b/include/libcss/computed.h
index d027b4f..233265c 100644
--- a/include/libcss/computed.h
+++ b/include/libcss/computed.h
@@ -338,6 +338,9 @@ uint8_t css_computed_break_after(
uint8_t css_computed_break_before(
const css_computed_style *style);
+uint8_t css_computed_break_inside(
+ const css_computed_style *style);
+
uint8_t css_computed_column_count(
const css_computed_style *style,
int32_t *column_count);
diff --git a/src/select/computed.c b/src/select/computed.c
index 20fa082..a33b6a2 100644
--- a/src/select/computed.c
+++ b/src/select/computed.c
@@ -797,6 +797,11 @@ uint8_t css_computed_break_before(const css_computed_style *style)
return get_break_before(style);
}
+uint8_t css_computed_break_inside(const css_computed_style *style)
+{
+ return get_break_inside(style);
+}
+
uint8_t css_computed_column_count(const css_computed_style *style,
int32_t *column_count)
{
diff --git a/src/select/properties/break_inside.c b/src/select/properties/break_inside.c
index 82cf09c..58931b3 100644
--- a/src/select/properties/break_inside.c
+++ b/src/select/properties/break_inside.c
@@ -17,51 +17,31 @@
css_error css__cascade_break_inside(uint32_t opv, css_style *style,
css_select_state *state)
{
- UNUSED(style);
-
- if (isInherit(opv) == false) {
- switch (getValue(opv)) {
- case BREAK_INSIDE_AUTO:
- case BREAK_INSIDE_AVOID:
- case BREAK_INSIDE_AVOID_PAGE:
- case BREAK_INSIDE_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_inside);
}
css_error css__set_break_inside_from_hint(const css_hint *hint,
css_computed_style *style)
{
- UNUSED(hint);
- UNUSED(style);
-
- return CSS_OK;
+ return set_break_inside(style, hint->status);
}
css_error css__initial_break_inside(css_select_state *state)
{
- UNUSED(state);
-
- return CSS_OK;
+ return set_break_inside(state->computed, CSS_BREAK_INSIDE_AUTO);
}
css_error css__compose_break_inside(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_inside(child);
+
+ if (type == CSS_BREAK_INSIDE_INHERIT) {
+ type = get_break_inside(parent);
+ }
- return CSS_OK;
+ return set_break_inside(result, type);
}
diff --git a/src/select/propget.h b/src/select/propget.h
index 93d96da..45c773f 100644
--- a/src/select/propget.h
+++ b/src/select/propget.h
@@ -188,6 +188,28 @@ static inline uint8_t get_break_before(
#undef BREAK_BEFORE_SHIFT
#undef BREAK_BEFORE_INDEX
+#define BREAK_INSIDE_INDEX 13
+#define BREAK_INSIDE_SHIFT 4
+#define BREAK_INSIDE_MASK (0xf << 4)
+static inline uint8_t get_break_inside(
+ const css_computed_style *style)
+{
+ if (style->uncommon != NULL) {
+ uint8_t bits = style->uncommon->bits[BREAK_INSIDE_INDEX];
+ bits &= BREAK_INSIDE_MASK;
+ bits >>= BREAK_INSIDE_SHIFT;
+
+ /* 4bits: type */
+ return bits;
+ }
+
+ /* Not inherited; initial value */
+ return CSS_BREAK_INSIDE_AUTO;
+}
+#undef BREAK_INSIDE_MASK
+#undef BREAK_INSIDE_SHIFT
+#undef BREAK_INSIDE_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 d5db8e0..d3d6fb1 100644
--- a/src/select/propset.h
+++ b/src/select/propset.h
@@ -242,6 +242,28 @@ static inline css_error set_break_before(
#undef BREAK_BEFORE_SHIFT
#undef BREAK_BEFORE_INDEX
+#define BREAK_INSIDE_INDEX 13
+#define BREAK_INSIDE_SHIFT 4
+#define BREAK_INSIDE_MASK (0xf << 4)
+static inline css_error set_break_inside(
+ css_computed_style *style, uint8_t type)
+{
+ uint8_t *bits;
+
+ ENSURE_UNCOMMON;
+
+ bits = &style->uncommon->bits[BREAK_INSIDE_INDEX];
+
+ /* 4bits: type */
+ *bits = (*bits & ~BREAK_INSIDE_MASK) |
+ ((type & 0xf) << BREAK_INSIDE_SHIFT);
+
+ return CSS_OK;
+}
+#undef BREAK_INSIDE_MASK
+#undef BREAK_INSIDE_SHIFT
+#undef BREAK_INSIDE_INDEX
+
#define WORD_SPACING_INDEX 3
#define WORD_SPACING_SHIFT 2
#define WORD_SPACING_MASK 0xfc