From f744c9dfa0b283af31eb9bada8ffb63809acb0db Mon Sep 17 00:00:00 2001
From: Michael Drake <tlsa@netsurf-browser.org>
Date: Wed, 2 Mar 2011 17:50:51 +0000
Subject: [PATCH] Make box flags and move new line indicator to it.

svn path=/trunk/netsurf/; revision=11886
---
 render/box.c         |  2 +-
 render/box.h         | 10 +++++++++-
 render/html_redraw.c |  2 +-
 render/layout.c      |  4 ++--
 4 files changed, 13 insertions(+), 5 deletions(-)

diff --git a/render/box.c b/render/box.c
index 9021f3842..0f73cbe57 100644
--- a/render/box.c
+++ b/render/box.c
@@ -131,6 +131,7 @@ struct box * box_create(css_select_results *styles, css_computed_style *style,
 		talloc_set_destructor(box, free_box_style);
 	
 	box->type = BOX_INLINE;
+	box->flags = 0;
 	box->styles = styles;
 	box->style = style;
 	box->style_owned = style_owned;
@@ -156,7 +157,6 @@ struct box * box_create(css_select_results *styles, css_computed_style *style,
 	box->columns = 1;
 	box->rows = 1;
 	box->start_column = 0;
-	box->inline_new_line = false;
 	box->printed = false;
 	box->next = NULL;
 	box->prev = NULL;
diff --git a/render/box.h b/render/box.h
index e49bfddd7..0f3d06f7c 100644
--- a/render/box.h
+++ b/render/box.h
@@ -115,6 +115,12 @@ typedef enum {
 	BOX_INLINE_END, BOX_NONE
 } box_type;
 
+
+/** Type of a struct box. */
+typedef enum {
+	NEW_LINE = 1 << 0	/* first inline on a new line */
+} box_flags;
+
 /* Sides of a box */
 enum box_side { TOP, RIGHT, BOTTOM, LEFT };
 
@@ -132,6 +138,9 @@ struct box {
 	/** Type of box. */
 	box_type type;
 
+	/** Box flags */
+	box_flags flags;
+
 	/** Computed styles for elements and their pseudo elements.  NULL on
 	 *  non-element boxes. */
 	css_select_results *styles;
@@ -219,7 +228,6 @@ struct box {
 	/** INLINE_END box corresponding to this INLINE box, or INLINE box
 	 * corresponding to this INLINE_END box. */
 	struct box *inline_end;
-	bool inline_new_line;
 
 	/** First float child box, or 0. Float boxes are in the tree twice, in
 	 * this list for the block box which defines the area for floats, and
diff --git a/render/html_redraw.c b/render/html_redraw.c
index 75dcf18aa..c69b24610 100644
--- a/render/html_redraw.c
+++ b/render/html_redraw.c
@@ -528,7 +528,7 @@ bool html_redraw_box(struct box *box, int x_parent, int y_parent,
 				ib_b_right = ib->border[RIGHT].width * scale;
 			}
 
-			if (ib->inline_new_line && ib != box) {
+			if ((ib->flags & NEW_LINE) && ib != box) {
 				/* inline element has wrapped, plot background
 				 * and borders */
 				if (!html_redraw_inline_background(
diff --git a/render/layout.c b/render/layout.c
index 568a4da8b..4a6718fe1 100644
--- a/render/layout.c
+++ b/render/layout.c
@@ -2560,7 +2560,7 @@ bool layout_line(struct box *first, int *width, int *y,
 	}
 
 	for (d = first; d != b; d = d->next) {
-		d->inline_new_line = false;
+		d->flags &= ~NEW_LINE;
 
 		if (d->type == BOX_INLINE_BLOCK &&
 				(css_computed_position(d->style) ==
@@ -2601,7 +2601,7 @@ bool layout_line(struct box *first, int *width, int *y,
 		}
 	}
 
-	first->inline_new_line = true;
+	first->flags |= NEW_LINE;
 
 	assert(b != first || (move_y && 0 < used_height && (left || right)));