summaryrefslogtreecommitdiff
path: root/render/layout.c
diff options
context:
space:
mode:
authorJohn Mark Bell <jmb@netsurf-browser.org>2004-07-16 20:26:49 +0000
committerJohn Mark Bell <jmb@netsurf-browser.org>2004-07-16 20:26:49 +0000
commit51af46fde6b5885d32eab0812189eb8f5e270abf (patch)
tree68d72bf6dfb05988088c3bda1664db5ac1bb4c3b /render/layout.c
parent6560a2ae5f68831bec809e9ee847ac0e36ff011d (diff)
downloadnetsurf-51af46fde6b5885d32eab0812189eb8f5e270abf.tar.gz
netsurf-51af46fde6b5885d32eab0812189eb8f5e270abf.tar.bz2
[project @ 2004-07-16 20:26:49 by jmb]
Preliminary overflow support. This also goes some way to making the horizontal scrollbar work. svn path=/import/netsurf/; revision=1088
Diffstat (limited to 'render/layout.c')
-rw-r--r--render/layout.c49
1 files changed, 49 insertions, 0 deletions
diff --git a/render/layout.c b/render/layout.c
index caf76abe9..26b266547 100644
--- a/render/layout.c
+++ b/render/layout.c
@@ -70,6 +70,18 @@ static void calculate_inline_replaced_widths(struct box *box, int *min,
static void calculate_inline_widths(struct box *box, int *min, int *line_max);
static bool calculate_table_widths(struct box *table);
+/**\todo Do we want to split this into a separate function? */
+#define set_descendant_extent(parent, child) do { \
+ if (child->x+child->descendant_x0 < parent->descendant_x0) \
+ parent->descendant_x0 = child->x+child->descendant_x0; \
+ if (child->x+child->descendant_x1 > parent->descendant_x1) \
+ parent->descendant_x1 = child->x+child->descendant_x1; \
+ if (child->y+child->descendant_y0 < parent->descendant_y0) \
+ parent->descendant_y0 = child->y+child->descendant_y0; \
+ if (child->y+child->descendant_y1 > parent->descendant_y1) \
+ parent->descendant_y1 = child->y+child->descendant_y1; \
+} while (0);
+
/**
* Calculate positions of boxes in a document.
@@ -230,6 +242,9 @@ bool layout_block_context(struct box *block, pool box_pool)
max_pos_margin = max_neg_margin = 0;
margin_box = box;
}
+
+ set_descendant_extent(block, box);
+
continue;
}
if (box->type == BOX_BLOCK && box->height == AUTO)
@@ -246,6 +261,7 @@ bool layout_block_context(struct box *block, pool box_pool)
y = box->y + box->padding[TOP] + box->height +
box->padding[BOTTOM] +
box->border[BOTTOM];
+ set_descendant_extent(box->parent, box);
box = box->parent;
if (box != block && box->height == AUTO)
box->height = y - box->padding[TOP];
@@ -255,6 +271,7 @@ bool layout_block_context(struct box *block, pool box_pool)
max_pos_margin = box->margin[BOTTOM];
else if (max_neg_margin < -box->margin[BOTTOM])
max_neg_margin = -box->margin[BOTTOM];
+ set_descendant_extent(box->parent, box);
} while (box != block && !box->next);
if (box == block)
break;
@@ -265,6 +282,8 @@ bool layout_block_context(struct box *block, pool box_pool)
box = box->next;
box->y = y;
margin_box = box;
+
+ set_descendant_extent(block, box);
}
/* Increase height to contain any floats inside (CSS 2.1 10.6.7). */
@@ -278,6 +297,8 @@ bool layout_block_context(struct box *block, pool box_pool)
if (block->height == AUTO)
block->height = cy - block->padding[TOP];
+ LOG(("Block Content: At: (%d, %d), %d, %d Descendants: %d, %d, %d, %d", block->x, block->y, block->width, block->height, block->descendant_x0, block->descendant_y0, block->descendant_x1, block->descendant_y1));
+
return true;
}
@@ -619,6 +640,8 @@ bool layout_inline_container(struct box *box, int width,
box->width = width;
box->height = y;
+ LOG(("Inline container: At: (%d, %d) %d, %d Descendants: %d, %d, %d, %d", box->x, box->y, box->width, box->height, box->descendant_x0, box->descendant_y0, box->descendant_x1, box->descendant_y1));
+
return true;
}
@@ -1033,6 +1056,15 @@ bool layout_line(struct box *first, int width, int *y,
}
for (d = first; d != b; d = d->next) {
+ /* BOXes_INLINE contain either text, an object or a form
+ * field. Therefore the extent of these is known so fill
+ * in the descendant_* fields. */
+ if (d->type == BOX_INLINE) {
+ d->descendant_x0 = 0;
+ d->descendant_y0 = 0;
+ d->descendant_x1 = d->width;
+ d->descendant_y1 = d->height;
+ }
if (d->type == BOX_INLINE || d->type == BOX_INLINE_BLOCK ||
d->type == BOX_BR) {
d->x += x0;
@@ -1042,6 +1074,13 @@ bool layout_line(struct box *first, int width, int *y,
if (used_height < h)
used_height = h;
}
+
+ /* fill in the parent's descendant_* fields. */
+ if (first->parent) {
+ set_descendant_extent(first->parent, d);
+ }
+
+ LOG(("Inline block: '%s' At: (%d, %d), %d, %d Descendants: %d, %d, %d, %d", d->text?d->text:d->object?d->object->url:d->gadget?"(gadget)":"", d->x, d->y, d->width, d->height, d->descendant_x0, d->descendant_y0, d->descendant_x1, d->descendant_y1));
}
assert(b != first || (move_y && 0 < used_height && (left || right)));
@@ -1376,6 +1415,8 @@ bool layout_table(struct box *table, int available_width,
}
row_span_cell[c->start_column] = c;
c->height = 0;
+
+ set_descendant_extent(row, c);
}
for (i = 0; i != columns; i++)
if (row_span[i] != 0)
@@ -1407,12 +1448,18 @@ bool layout_table(struct box *table, int available_width,
row->width = table_width;
row->height = row_height;
row_group_height += row_height;
+
+ set_descendant_extent(row_group, row);
+ LOG(("Table row: At: (%d, %d), %d, %d Descendants: %d, %d, %d, %d", row->x, row->y, row->width, row->height, row->descendant_x0, row->descendant_y0, row->descendant_x1, row->descendant_y1));
}
row_group->x = 0;
row_group->y = table_height;
row_group->width = table_width;
row_group->height = row_group_height;
table_height += row_group_height;
+
+ set_descendant_extent(table, row_group);
+ LOG(("Table row group: At: (%d, %d), %d, %d Descendants: %d, %d, %d, %d", row_group->x, row_group->y, row_group->width, row_group->height, row_group->descendant_x0, row_group->descendant_y0, row_group->descendant_x1, row_group->descendant_y1));
}
free(col);
@@ -1424,6 +1471,8 @@ bool layout_table(struct box *table, int available_width,
table->width = table_width;
table->height = table_height;
+ LOG(("Table: At: (%d, %d), %d, %d Descendants: %d, %d, %d, %d", table->x, table->y, table->width, table->height, table->descendant_x0, table->descendant_y0, table->descendant_x1, table->descendant_y1));
+
return true;
}