summaryrefslogtreecommitdiff
path: root/src/select/propset.h
diff options
context:
space:
mode:
authorMichael Drake <tlsa@netsurf-browser.org>2012-04-13 11:43:13 +0000
committerMichael Drake <tlsa@netsurf-browser.org>2012-04-13 11:43:13 +0000
commit89ef7a8acf13143ac0283aa1cfa5ea504b92324b (patch)
tree26564857b03f2c495a05073d3418af7f7a4a5d99 /src/select/propset.h
parent3f008ebef592b39c93b21dd66dfbe2fd23b6860e (diff)
downloadlibcss-89ef7a8acf13143ac0283aa1cfa5ea504b92324b.tar.gz
libcss-89ef7a8acf13143ac0283aa1cfa5ea504b92324b.tar.bz2
Complete widows and orphans support. Thanks to James Montgomerie.
svn path=/trunk/libcss/; revision=13864
Diffstat (limited to 'src/select/propset.h')
-rw-r--r--src/select/propset.h89
1 files changed, 85 insertions, 4 deletions
diff --git a/src/select/propset.h b/src/select/propset.h
index 738ec70..978a667 100644
--- a/src/select/propset.h
+++ b/src/select/propset.h
@@ -52,10 +52,15 @@ static const css_computed_uncommon default_uncommon = {
} while(0)
static const css_computed_page default_page = {
- { (CSS_PAGE_BREAK_INSIDE_AUTO << 6) |
- (CSS_PAGE_BREAK_BEFORE_AUTO << 3) |
- CSS_PAGE_BREAK_AFTER_AUTO
- }
+ {
+ (CSS_PAGE_BREAK_INSIDE_AUTO << 6) |
+ (CSS_PAGE_BREAK_BEFORE_AUTO << 3) |
+ CSS_PAGE_BREAK_AFTER_AUTO,
+ (CSS_WIDOWS_SET << 1) |
+ CSS_ORPHANS_SET
+ },
+ 2 << CSS_RADIX_POINT,
+ 2 << CSS_RADIX_POINT
};
#define ENSURE_PAGE do { \
@@ -1862,6 +1867,12 @@ static inline css_error set_page_break_after(
{
uint8_t *bits;
+ if (style->page == NULL) {
+ if (type == CSS_PAGE_BREAK_AFTER_AUTO) {
+ return CSS_OK;
+ }
+ }
+
ENSURE_PAGE;
bits = &style->page->bits[PAGE_BREAK_AFTER_INDEX];
@@ -1884,6 +1895,12 @@ static inline css_error set_page_break_before(
{
uint8_t *bits;
+ if (style->page == NULL) {
+ if (type == CSS_PAGE_BREAK_BEFORE_AUTO) {
+ return CSS_OK;
+ }
+ }
+
ENSURE_PAGE;
bits = &style->page->bits[PAGE_BREAK_BEFORE_INDEX];
@@ -1906,6 +1923,12 @@ static inline css_error set_page_break_inside(
{
uint8_t *bits;
+ if (style->page == NULL) {
+ if (type == CSS_PAGE_BREAK_INSIDE_AUTO) {
+ return CSS_OK;
+ }
+ }
+
ENSURE_PAGE;
bits = &style->page->bits[PAGE_BREAK_INSIDE_INDEX];
@@ -1920,4 +1943,62 @@ static inline css_error set_page_break_inside(
#undef PAGE_BREAK_INSIDE_SHIFT
#undef PAGE_BREAK_INSIDE_MASK
+#define ORPHANS_INDEX 1
+#define ORPHANS_SHIFT 0
+#define ORPHANS_MASK 0x1
+static inline css_error set_orphans(
+ css_computed_style *style, uint8_t type, css_fixed count)
+{
+ uint8_t *bits;
+
+ if (style->page == NULL) {
+ if (type == CSS_ORPHANS_SET && count == INTTOFIX(2)) {
+ return CSS_OK;
+ }
+ }
+
+ ENSURE_PAGE;
+
+ bits = &style->page->bits[ORPHANS_INDEX];
+
+ /* 1bit: type */
+ *bits = (*bits & ~ORPHANS_MASK) | ((type & 0x1) << ORPHANS_SHIFT);
+
+ style->page->orphans = count;
+
+ return CSS_OK;
+}
+#undef ORPHANS_INDEX
+#undef ORPHANS_SHIFT
+#undef ORPHANS_MASK
+
+#define WIDOWS_INDEX 1
+#define WIDOWS_SHIFT 1
+#define WIDOWS_MASK 0x2
+static inline css_error set_widows(
+ css_computed_style *style, uint8_t type, css_fixed count)
+{
+ uint8_t *bits;
+
+ if (style->page == NULL) {
+ if (type == CSS_WIDOWS_SET && count == INTTOFIX(2)) {
+ return CSS_OK;
+ }
+ }
+
+ ENSURE_PAGE;
+
+ bits = &style->page->bits[WIDOWS_INDEX];
+
+ /* 1bit: type */
+ *bits = (*bits & ~WIDOWS_MASK) | ((type & 0x1) << WIDOWS_SHIFT);
+
+ style->page->widows = count;
+
+ return CSS_OK;
+}
+#undef WIDOWS_INDEX
+#undef WIDOWS_SHIFT
+#undef WIDOWS_MASK
+
#endif