diff options
author | John Mark Bell <jmb@netsurf-browser.org> | 2011-08-23 20:12:41 +0000 |
---|---|---|
committer | John Mark Bell <jmb@netsurf-browser.org> | 2011-08-23 20:12:41 +0000 |
commit | 0b6d7198f4fc46961c57530e654691b5a66b36f0 (patch) | |
tree | 3e2a25ec514b4d9c34ea92dd79c4eafdc6008b76 /src/select/propset.h | |
parent | da47188a8369bb79884d37f3222c8bf8fabb7ea4 (diff) | |
download | libcss-0b6d7198f4fc46961c57530e654691b5a66b36f0.tar.gz libcss-0b6d7198f4fc46961c57530e654691b5a66b36f0.tar.bz2 |
Add support for selecting page-break-{before, after, inside}
Credit: James Montgomerie
svn path=/trunk/libcss/; revision=12645
Diffstat (limited to 'src/select/propset.h')
-rw-r--r-- | src/select/propset.h | 79 |
1 files changed, 79 insertions, 0 deletions
diff --git a/src/select/propset.h b/src/select/propset.h index 7c29db4..6337536 100644 --- a/src/select/propset.h +++ b/src/select/propset.h @@ -51,6 +51,25 @@ 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 + } +}; + +#define ENSURE_PAGE do { \ + if (style->page == NULL) { \ + style->page = style->alloc(NULL, \ + sizeof(css_computed_page), style->pw); \ + if (style->page == NULL) \ + return CSS_NOMEM; \ + \ + memcpy(style->page, &default_page, \ + sizeof(css_computed_page)); \ + } \ +} while(0) + #define LETTER_SPACING_INDEX 0 #define LETTER_SPACING_SHIFT 2 #define LETTER_SPACING_MASK 0xfc @@ -1835,4 +1854,64 @@ static inline uint8_t set_text_align( #undef TEXT_ALIGN_SHIFT #undef TEXT_ALIGN_INDEX +#define PAGE_BREAK_AFTER_INDEX 0 +#define PAGE_BREAK_AFTER_SHIFT 0 +#define PAGE_BREAK_AFTER_MASK 0x7 +static inline css_error set_page_break_after( + css_computed_style *style, uint8_t type) +{ + ENSURE_PAGE; + + uint8_t *bits = &style->page->bits[PAGE_BREAK_AFTER_INDEX]; + + /* 3bits: type */ + *bits = (*bits & ~PAGE_BREAK_AFTER_MASK) | + ((type & 0x7) << PAGE_BREAK_AFTER_SHIFT); + + return CSS_OK; +} +#undef PAGE_BREAK_AFTER_INDEX +#undef PAGE_BREAK_AFTER_SHIFT +#undef PAGE_BREAK_AFTER_MASK + +#define PAGE_BREAK_BEFORE_INDEX 0 +#define PAGE_BREAK_BEFORE_SHIFT 3 +#define PAGE_BREAK_BEFORE_MASK 0x38 +static inline css_error set_page_break_before( + css_computed_style *style, uint8_t type) +{ + ENSURE_PAGE; + + uint8_t *bits = &style->page->bits[PAGE_BREAK_BEFORE_INDEX]; + + /* 3bits: type */ + *bits = (*bits & ~PAGE_BREAK_BEFORE_MASK) | + ((type & 0x7) << PAGE_BREAK_BEFORE_SHIFT); + + return CSS_OK; +} +#undef PAGE_BREAK_BEFORE_INDEX +#undef PAGE_BREAK_BEFORE_SHIFT +#undef PAGE_BREAK_BEFORE_MASK + +#define PAGE_BREAK_INSIDE_INDEX 0 +#define PAGE_BREAK_INSIDE_SHIFT 6 +#define PAGE_BREAK_INSIDE_MASK 0xc0 +static inline css_error set_page_break_inside( + css_computed_style *style, uint8_t type) +{ + ENSURE_PAGE; + + uint8_t *bits = &style->page->bits[PAGE_BREAK_INSIDE_INDEX]; + + /* 2bits: type */ + *bits = (*bits & ~PAGE_BREAK_INSIDE_MASK) | + ((type & 0x3) << PAGE_BREAK_INSIDE_SHIFT); + + return CSS_OK; +} +#undef PAGE_BREAK_INSIDE_INDEX +#undef PAGE_BREAK_INSIDE_SHIFT +#undef PAGE_BREAK_INSIDE_MASK + #endif |