Index: include/libcss/properties.h
===================================================================
--- include/libcss/properties.h	(revision 13509)
+++ include/libcss/properties.h	(working copy)
@@ -585,6 +585,11 @@
 	CSS_OVERFLOW_AUTO			= 0x4
 };
 
+enum css_orphans_e {
+	CSS_ORPHANS_INHERIT			= 0x0,
+	CSS_ORPHANS_SET				= 0x1,
+};
+
 enum css_padding_e {
 	CSS_PADDING_INHERIT			= 0x0,
 	CSS_PADDING_SET				= 0x1
@@ -718,6 +723,11 @@
 	CSS_WHITE_SPACE_PRE_LINE		= 0x5
 };
 
+enum css_widows_e {
+	CSS_WIDOWS_INHERIT			= 0x0,
+	CSS_WIDOWS_SET				= 0x1,
+};	
+	
 enum css_width_e {
 	CSS_WIDTH_INHERIT			= 0x0,
 	CSS_WIDTH_SET				= 0x1,
Index: include/libcss/computed.h
===================================================================
--- include/libcss/computed.h	(revision 13509)
+++ include/libcss/computed.h	(working copy)
@@ -388,7 +388,12 @@
 uint8_t css_computed_page_break_inside(
 		const css_computed_style *style);
 
+int32_t css_computed_orphans(
+		const css_computed_style *style);
 
+int32_t css_computed_widows(
+		const css_computed_style *style);
+
 #ifdef __cplusplus
 }
 #endif
Index: src/select/computed.c
===================================================================
--- src/select/computed.c	(revision 13509)
+++ src/select/computed.c	(working copy)
@@ -2224,7 +2224,27 @@
 #undef CSS_PAGE_BREAK_INSIDE_INDEX
 
 
+int32_t css_computed_orphans(
+		const css_computed_style *style)
+{
+	if (style->page != NULL) {
+		return FIXTOINT(style->page->orphans);
+	}
 
+	return 2;
+}
+
+int32_t css_computed_widows(
+		const css_computed_style *style)
+{
+	if (style->page != NULL) {
+		return FIXTOINT(style->page->widows);
+	}
+	
+	return 2;
+}
+
+
 /******************************************************************************
  * Library internals                                                          *
  ******************************************************************************/
Index: src/select/propset.h
===================================================================
--- src/select/propset.h	(revision 13509)
+++ src/select/propset.h	(working copy)
@@ -52,10 +52,15 @@
 } 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 @@
 {
 	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 @@
 {
 	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 @@
 {
 	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,64 @@
 #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
Index: src/select/computed.h
===================================================================
--- src/select/computed.h	(revision 13509)
+++ src/select/computed.h	(working copy)
@@ -87,13 +87,16 @@
 
 typedef struct css_computed_page {
 /*
- * page_break_after		  3
- * page_break_before		  3
- * page_break_inside		  2
- * 				---
- *				  8 bits
+ * Bit allocations:
+ *
+ *    76543210
+ *  1 aaabbbii	page_break_after | page_break_before | page_break_inside
+ *  2 ......wo	widows  | orphans
  */
-    uint8_t bits[1];
+	uint8_t bits[2];
+	
+	css_fixed widows;
+	css_fixed orphans;
 } css_computed_page;
     
 struct css_computed_style {
Index: src/select/propget.h
===================================================================
--- src/select/propget.h	(revision 13509)
+++ src/select/propget.h	(working copy)
@@ -1807,4 +1807,54 @@
 #undef PAGE_BREAK_INSIDE_SHIFT
 #undef PAGE_BREAK_INSIDE_INDEX
 
+#define ORPHANS_INDEX 1
+#define ORPHANS_SHIFT 0
+#define ORPHANS_MASK 0x1
+static inline uint8_t get_orphans(
+		const css_computed_style *style,
+		css_fixed *count)
+{
+	if (style->page != NULL) {
+		uint8_t bits = style->page->bits[ORPHANS_INDEX];
+		bits &= ORPHANS_MASK;
+		bits >>= ORPHANS_SHIFT;
+		
+		*count = style->page->orphans;
+		
+		/* 3bits: type */
+		return bits;
+	}
+	
+	*count = INTTOFIX(2);
+	return CSS_ORPHANS_SET;
+}
+#undef ORPHANS_MASK
+#undef ORPHANS_SHIFT
+#undef ORPHANS_INDEX
+
+#define WIDOWS_INDEX 1
+#define WIDOWS_SHIFT 1
+#define WIDOWS_MASK 0x2
+static inline uint8_t get_widows(
+		const css_computed_style *style,
+		css_fixed *count)
+{
+	if (style->page != NULL) {
+		uint8_t bits = style->page->bits[WIDOWS_INDEX];
+		bits &= WIDOWS_MASK;
+		bits >>= WIDOWS_SHIFT;
+		
+		*count = style->page->orphans;
+		
+		/* 3bits: type */
+		return bits;
+	}
+	
+	*count = INTTOFIX(2);
+	return CSS_WIDOWS_SET;
+}
+#undef WIDOWS_MASK
+#undef WIDOWS_SHIFT
+#undef WIDOWS_INDEX
+
 #endif
Index: src/select/properties/orphans.c
===================================================================
--- src/select/properties/orphans.c	(revision 13509)
+++ src/select/properties/orphans.c	(working copy)
@@ -17,34 +17,31 @@
 css_error css__cascade_orphans(uint32_t opv, css_style *style, 
 		css_select_state *state)
 {
-	/** \todo orphans */
-	return css__cascade_number(opv, style, state, NULL);
+	return css__cascade_number(opv, style, state, set_orphans);
 }
 
 css_error css__set_orphans_from_hint(const css_hint *hint,
 		css_computed_style *style)
 {
-	UNUSED(hint);
-	UNUSED(style);
-
-	return CSS_OK;
+	return set_orphans(style, hint->status, hint->data.fixed);
 }
 
 css_error css__initial_orphans(css_select_state *state)
 {
-	UNUSED(state);
-
-	return CSS_OK;
+	return set_orphans(state->computed, CSS_ORPHANS_SET, INTTOFIX(2));
 }
 
 css_error css__compose_orphans(const css_computed_style *parent,
 		const css_computed_style *child,
 		css_computed_style *result)
 {
-	UNUSED(parent);
-	UNUSED(child);
-	UNUSED(result);
-
-	return CSS_OK;
+	css_fixed count = 0;
+	uint8_t type = get_orphans(child, &count);
+	
+	if (type == CSS_ORPHANS_INHERIT) {
+		type = get_orphans(parent, &count);
+	}
+	
+	return set_orphans(result, type, count);
 }
 
Index: src/select/properties/windows.c
===================================================================
--- src/select/properties/windows.c	(revision 13509)
+++ src/select/properties/windows.c	(working copy)
@@ -17,34 +17,31 @@
 css_error css__cascade_widows(uint32_t opv, css_style *style, 
 		css_select_state *state)
 {
-	/** \todo widows */
-	return css__cascade_number(opv, style, state, NULL);
+	return css__cascade_number(opv, style, state, set_widows);
 }
 
 css_error css__set_widows_from_hint(const css_hint *hint,
 		css_computed_style *style)
 {
-	UNUSED(hint);
-	UNUSED(style);
-
-	return CSS_OK;
+	return set_widows(style, hint->status, hint->data.fixed);
 }
 
 css_error css__initial_widows(css_select_state *state)
 {
-	UNUSED(state);
-
-	return CSS_OK;
+	return set_widows(state->computed, CSS_WIDOWS_SET, INTTOFIX(2));
 }
 
 css_error css__compose_widows(const css_computed_style *parent,
 		const css_computed_style *child,
 		css_computed_style *result)
 {
-	UNUSED(parent);
-	UNUSED(child);
-	UNUSED(result);
-
-	return CSS_OK;
+	css_fixed count = 0;
+	uint8_t type = get_widows(child, &count);
+	
+	if (type == CSS_WIDOWS_INHERIT) {
+		type = get_widows(parent, &count);
+	}
+	
+	return set_widows(result, type, count);
 }
 
