summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJames Bursa <james@netsurf-browser.org>2004-08-01 13:08:19 +0000
committerJames Bursa <james@netsurf-browser.org>2004-08-01 13:08:19 +0000
commit9e1dbe3a36c8b33787174850874caa6c5ae94107 (patch)
tree83082b20892bd9d4ea7e83072df639a3796bdc69
parentab67491a376a850f1d1dfe51c4bd644daffbecb1 (diff)
downloadnetsurf-9e1dbe3a36c8b33787174850874caa6c5ae94107.tar.gz
netsurf-9e1dbe3a36c8b33787174850874caa6c5ae94107.tar.bz2
[project @ 2004-08-01 13:08:18 by bursa]
More work on overflow. Modify block centering to left-align when insufficient space. Fix caret positioning for form controls with padding. svn path=/import/netsurf/; revision=1171
-rw-r--r--!NetSurf/Resources/CSS,f7912
-rw-r--r--desktop/browser.c21
-rw-r--r--render/box.c29
-rw-r--r--render/layout.c135
-rw-r--r--riscos/htmlredraw.c153
5 files changed, 186 insertions, 164 deletions
diff --git a/!NetSurf/Resources/CSS,f79 b/!NetSurf/Resources/CSS,f79
index 2b0575d3d..3944d5eec 100644
--- a/!NetSurf/Resources/CSS,f79
+++ b/!NetSurf/Resources/CSS,f79
@@ -1,7 +1,7 @@
/*
* This file is part of NetSurf, http://netsurf.sourceforge.net/
*/
-
+
/* Elements ordered as in the HTML 4.01 specification. */
html { display: block; }
@@ -128,10 +128,12 @@ iframe[align=left] { float: left; }
iframe[align=right] { float: right; }
form { display: block; }
+form > * { margin-left: inherit; margin-right: inherit; }
input { background-color: #fff; color: #000; width: 10em;
height: 1.5em; text-align: left; border-width: 1px;
- border-color: #000; border-style: solid; }
+ border-color: #000; border-style: solid; overflow: hidden;
+ padding: 0 2px; }
input[type=button], input[type=reset], input[type=submit], button {
background-color: #ddd; color: #000; width: auto;
border-width: medium; border-color: #eee #aaa #aaa #eee;
@@ -149,10 +151,12 @@ input[align=right] { float: right; }
select { background-color: #ddd; color: #000; width: 10em;
height: 1.5em; text-align: left; border-width: medium;
- border-color: #aaa #eee #eee #aaa; border-style: inset; }
+ border-color: #aaa #eee #eee #aaa; border-style: inset;
+ overflow: hidden; padding: 0 2px; }
textarea { background-color: #fff; color: #000; text-align: left;
- border-width: 1px; border-color: #000; border-style: solid; }
+ border-width: 1px; border-color: #000; border-style: solid;
+ overflow: scroll; padding: 0 2px; }
fieldset { display: block; border: thin solid #888; }
diff --git a/desktop/browser.c b/desktop/browser.c
index c4dcc5c54..8d1205315 100644
--- a/desktop/browser.c
+++ b/desktop/browser.c
@@ -885,10 +885,12 @@ void browser_window_textarea_click(struct browser_window *bw,
textarea->gadget->caret_inline_container = inline_container;
textarea->gadget->caret_text_box = text_box;
- textarea->gadget->caret_box_offset = textarea->gadget->caret_form_offset = char_offset;
+ textarea->gadget->caret_box_offset =
+ textarea->gadget->caret_form_offset = char_offset;
textarea->gadget->caret_pixel_offset = pixel_offset;
browser_window_place_caret(bw,
- box_x + text_box->x + pixel_offset,
+ box_x + inline_container->x + text_box->x +
+ pixel_offset,
box_y + inline_container->y + text_box->y,
text_box->height,
browser_window_textarea_callback, textarea);
@@ -1152,10 +1154,12 @@ void browser_window_textarea_callback(struct browser_window *bw,
textarea->gadget->caret_inline_container = inline_container;
textarea->gadget->caret_text_box = text_box;
- textarea->gadget->caret_box_offset = textarea->gadget->caret_form_offset = char_offset;
+ textarea->gadget->caret_box_offset =
+ textarea->gadget->caret_form_offset = char_offset;
textarea->gadget->caret_pixel_offset = pixel_offset;
browser_window_place_caret(bw,
- box_x + text_box->x + pixel_offset,
+ box_x + inline_container->x + text_box->x +
+ pixel_offset,
box_y + inline_container->y + text_box->y,
text_box->height,
browser_window_textarea_callback, textarea);
@@ -1227,8 +1231,8 @@ void browser_window_input_click(struct browser_window* bw,
input->gadget->caret_form_offset = offset;
input->gadget->caret_pixel_offset = pixel_offset;
browser_window_place_caret(bw,
- box_x + text_box->x + pixel_offset,
- box_y + text_box->y,
+ box_x + input->children->x + text_box->x + pixel_offset,
+ box_y + input->children->y + text_box->y,
text_box->height,
browser_window_input_callback, input);
@@ -1449,8 +1453,8 @@ void browser_window_input_callback(struct browser_window *bw,
input->gadget->caret_form_offset = form_offset;
browser_window_place_caret(bw,
- box_x + text_box->x + pixel_offset,
- box_y + text_box->y,
+ box_x + input->children->x + text_box->x + pixel_offset,
+ box_y + input->children->y + text_box->y,
text_box->height,
browser_window_input_callback, input);
@@ -1458,6 +1462,7 @@ void browser_window_input_callback(struct browser_window *bw,
browser_redraw_box(bw->current_content, input);
}
+
/**
* Position the caret and assign a callback for key presses.
*/
diff --git a/render/box.c b/render/box.c
index a758adbd5..36d9f2ba3 100644
--- a/render/box.c
+++ b/render/box.c
@@ -1465,7 +1465,7 @@ struct box_result box_button(xmlNode *n, struct box_status *status,
/**
- * print a box tree to stderr
+ * Print a box tree to stderr.
*/
void box_dump(struct box * box, unsigned int depth)
@@ -1476,26 +1476,29 @@ void box_dump(struct box * box, unsigned int depth)
for (i = 0; i < depth; i++)
fprintf(stderr, " ");
- fprintf(stderr, "%p ", box);
+/* fprintf(stderr, "%p ", box); */
fprintf(stderr, "x%i y%i w%i h%i ", box->x, box->y, box->width, box->height);
if ((unsigned long)box->max_width != UNKNOWN_MAX_WIDTH)
fprintf(stderr, "min%i max%i ", box->min_width, box->max_width);
+ fprintf(stderr, "(%i %i %i %i) ",
+ box->descendant_x0, box->descendant_y0,
+ box->descendant_x1, box->descendant_y1);
switch (box->type) {
- case BOX_BLOCK: fprintf(stderr, "BOX_BLOCK "); break;
- case BOX_INLINE_CONTAINER: fprintf(stderr, "BOX_INLINE_CONTAINER "); break;
- case BOX_INLINE: fprintf(stderr, "BOX_INLINE "); break;
- case BOX_INLINE_BLOCK: fprintf(stderr, "BOX_INLINE_BLOCK "); break;
- case BOX_TABLE: fprintf(stderr, "BOX_TABLE [columns %i] ",
+ case BOX_BLOCK: fprintf(stderr, "BLOCK "); break;
+ case BOX_INLINE_CONTAINER: fprintf(stderr, "INLINE_CONTAINER "); break;
+ case BOX_INLINE: fprintf(stderr, "INLINE "); break;
+ case BOX_INLINE_BLOCK: fprintf(stderr, "INLINE_BLOCK "); break;
+ case BOX_TABLE: fprintf(stderr, "TABLE [columns %i] ",
box->columns); break;
- case BOX_TABLE_ROW: fprintf(stderr, "BOX_TABLE_ROW "); break;
- case BOX_TABLE_CELL: fprintf(stderr, "BOX_TABLE_CELL [columns %i, "
+ case BOX_TABLE_ROW: fprintf(stderr, "TABLE_ROW "); break;
+ case BOX_TABLE_CELL: fprintf(stderr, "TABLE_CELL [columns %i, "
"start %i, rows %i] ", box->columns,
box->start_column, box->rows); break;
- case BOX_TABLE_ROW_GROUP: fprintf(stderr, "BOX_TABLE_ROW_GROUP "); break;
- case BOX_FLOAT_LEFT: fprintf(stderr, "BOX_FLOAT_LEFT "); break;
- case BOX_FLOAT_RIGHT: fprintf(stderr, "BOX_FLOAT_RIGHT "); break;
- case BOX_BR: fprintf(stderr, "BOX_BR "); break;
+ case BOX_TABLE_ROW_GROUP: fprintf(stderr, "TABLE_ROW_GROUP "); break;
+ case BOX_FLOAT_LEFT: fprintf(stderr, "FLOAT_LEFT "); break;
+ case BOX_FLOAT_RIGHT: fprintf(stderr, "FLOAT_RIGHT "); break;
+ case BOX_BR: fprintf(stderr, "BR "); break;
default: fprintf(stderr, "Unknown box type ");
}
if (box->text)
diff --git a/render/layout.c b/render/layout.c
index 8b4de6fb8..a4e688f42 100644
--- a/render/layout.c
+++ b/render/layout.c
@@ -67,24 +67,7 @@ static void calculate_inline_replaced_widths(struct box *box, int *min,
int *max, int *line_max);
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);
-
-#define invalidate_descendants(box) do { \
- LOG(("invalidating descendents of %p", box)); \
- box->descendant_x0 = box->descendant_x1 = 0; \
- box->descendant_y0 = box->descendant_y1 = 0; \
-} while (0);
+static void layout_calculate_descendant_bboxes(struct box *box);
/**
@@ -98,6 +81,8 @@ static bool calculate_table_widths(struct box *table);
bool layout_document(struct box *doc, int width, pool box_pool)
{
+ bool ret;
+
doc->float_children = 0;
if (!calculate_widths(doc))
@@ -109,8 +94,12 @@ bool layout_document(struct box *doc, int width, pool box_pool)
width -= doc->margin[LEFT] + doc->border[LEFT] +
doc->border[RIGHT] + doc->margin[RIGHT];
doc->width = width;
- invalidate_descendants(doc);
- return layout_block_context(doc, box_pool);
+
+ ret = layout_block_context(doc, box_pool);
+
+ layout_calculate_descendant_bboxes(doc);
+
+ return ret;
}
@@ -141,8 +130,6 @@ bool layout_block_context(struct box *block, pool box_pool)
gui_multitask();
- invalidate_descendants(block);
-
box = margin_box = block->children;
cx = block->padding[LEFT];
cy = block->padding[TOP];
@@ -162,8 +149,6 @@ bool layout_block_context(struct box *block, pool box_pool)
* correct handling of floats.
*/
- invalidate_descendants(box);
-
if (box->type == BOX_BLOCK)
layout_block_find_dimensions(box->parent->width, box);
else if (box->type == BOX_TABLE) {
@@ -252,8 +237,6 @@ bool layout_block_context(struct box *block, pool box_pool)
margin_box = box;
}
- set_descendant_extent(block, box);
-
continue;
}
if (box->type == BOX_BLOCK && box->height == AUTO)
@@ -270,7 +253,6 @@ 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];
@@ -280,7 +262,6 @@ 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;
@@ -291,8 +272,6 @@ 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). */
@@ -306,8 +285,6 @@ 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;
}
@@ -414,6 +391,10 @@ int layout_solve_width(int available_width, int width,
margin[LEFT] = margin[RIGHT] = (available_width -
(border[LEFT] + padding[LEFT] + width +
padding[RIGHT] + border[RIGHT])) / 2;
+ if (margin[LEFT] < 0) {
+ margin[RIGHT] += margin[LEFT];
+ margin[LEFT] = 0;
+ }
} else if (margin[LEFT] == AUTO) {
margin[LEFT] = available_width -
(border[LEFT] + padding[LEFT] + width +
@@ -637,8 +618,6 @@ bool layout_inline_container(struct box *box, int width,
LOG(("box %p, width %i, cont %p, cx %i, cy %i",
box, width, cont, cx, cy));
- invalidate_descendants(box);
-
for (c = box->children; c; ) {
LOG(("c %p", c));
if (!layout_line(c, width, &y, cx, cy + y, cont, first_line,
@@ -651,8 +630,6 @@ 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;
}
@@ -742,8 +719,6 @@ bool layout_line(struct box *first, int width, int *y,
b->type == BOX_FLOAT_RIGHT ||
b->type == BOX_BR);
- invalidate_descendants(b);
-
if (b->type == BOX_INLINE_BLOCK) {
if (b->width == UNKNOWN_WIDTH)
if (!layout_float(b, width, box_pool))
@@ -1069,15 +1044,6 @@ 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;
@@ -1087,13 +1053,6 @@ 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)));
@@ -1136,7 +1095,6 @@ int layout_text_indent(struct css_style *style, int width)
bool layout_float(struct box *b, int width, pool box_pool)
{
layout_float_find_dimensions(width, b->style, b);
- invalidate_descendants(b);
if (b->type == BOX_TABLE) {
if (!layout_table(b, width, box_pool))
return false;
@@ -1393,15 +1351,11 @@ bool layout_table(struct box *table, int available_width,
row_span_cell[i] = 0;
}
- invalidate_descendants(table);
-
/* position cells */
for (row_group = table->children; row_group != 0; row_group = row_group->next) {
int row_group_height = 0;
- invalidate_descendants(row_group);
for (row = row_group->children; row != 0; row = row->next) {
int row_height = 0;
- invalidate_descendants(row);
for (c = row->children; c != 0; c = c->next) {
assert(c->style != 0);
c->width = xs[c->start_column + c->columns] - xs[c->start_column];
@@ -1433,8 +1387,6 @@ 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)
@@ -1466,18 +1418,12 @@ 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);
@@ -1489,8 +1435,6 @@ 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;
}
@@ -1921,3 +1865,56 @@ bool calculate_table_widths(struct box *table)
return true;
}
+
+
+/**
+ * Recursively calculate the descendant_[xy][01] values for a laid-out box tree.
+ *
+ * \param box tree of boxes to update
+ */
+
+void layout_calculate_descendant_bboxes(struct box *box)
+{
+ struct box *child;
+
+ box->descendant_x0 = -box->border[LEFT];
+ box->descendant_y0 = -box->border[TOP];
+ box->descendant_x1 = box->padding[LEFT] + box->width +
+ box->padding[RIGHT] + box->border[RIGHT];
+ box->descendant_y1 = box->padding[TOP] + box->height +
+ box->padding[BOTTOM] + box->border[BOTTOM];
+
+ for (child = box->children; child; child = child->next) {
+ if (child->type == BOX_FLOAT_LEFT ||
+ child->type == BOX_FLOAT_RIGHT)
+ continue;
+
+ layout_calculate_descendant_bboxes(child);
+
+ if (child->x + child->descendant_x0 < box->descendant_x0)
+ box->descendant_x0 = child->x + child->descendant_x0;
+ if (box->descendant_x1 < child->x + child->descendant_x1)
+ box->descendant_x1 = child->x + child->descendant_x1;
+ if (child->y + child->descendant_y0 < box->descendant_y0)
+ box->descendant_y0 = child->y + child->descendant_y0;
+ if (box->descendant_y1 < child->y + child->descendant_y1)
+ box->descendant_y1 = child->y + child->descendant_y1;
+ }
+
+ for (child = box->float_children; child; child = child->next_float) {
+ if (child->type != BOX_FLOAT_LEFT &&
+ child->type != BOX_FLOAT_RIGHT)
+ continue;
+
+ layout_calculate_descendant_bboxes(child);
+
+ if (child->x + child->descendant_x0 < box->descendant_x0)
+ box->descendant_x0 = child->x + child->descendant_x0;
+ if (box->descendant_x1 < child->x + child->descendant_x1)
+ box->descendant_x1 = child->x + child->descendant_x1;
+ if (child->y + child->descendant_y0 < box->descendant_y0)
+ box->descendant_y0 = child->y + child->descendant_y0;
+ if (box->descendant_y1 < child->y + child->descendant_y1)
+ box->descendant_y1 = child->y + child->descendant_y1;
+ }
+}
diff --git a/riscos/htmlredraw.c b/riscos/htmlredraw.c
index 1b2ef4ec7..6768449e6 100644
--- a/riscos/htmlredraw.c
+++ b/riscos/htmlredraw.c
@@ -6,6 +6,10 @@
* Copyright 2004 James Bursa <bursa@users.sourceforge.net>
*/
+/** \file
+ * Redraw of a CONTENT_HTML (RISC OS implementation).
+ */
+
#include <assert.h>
#include <stdbool.h>
#include <string.h>
@@ -16,29 +20,28 @@
#include "oslib/os.h"
#include "oslib/wimp.h"
#include "netsurf/utils/config.h"
-#include "netsurf/css/css.h"
#include "netsurf/content/content.h"
+#include "netsurf/css/css.h"
#include "netsurf/render/form.h"
#include "netsurf/render/html.h"
#include "netsurf/riscos/gui.h"
#include "netsurf/riscos/options.h"
-#include "netsurf/riscos/ufont.h"
#include "netsurf/riscos/tinct.h"
#include "netsurf/riscos/toolbar.h"
+#include "netsurf/riscos/ufont.h"
#include "netsurf/riscos/wimp.h"
#include "netsurf/utils/log.h"
#include "netsurf/utils/messages.h"
#include "netsurf/utils/utils.h"
-static void html_redraw_box(struct content *content, struct box * box,
- signed long x, signed long y,
+static void html_redraw_box(struct box *box,
+ int x, int y,
unsigned long current_background_color,
- bool *select_on,
- long clip_x0, long clip_y0, long clip_x1, long clip_y1,
+ int clip_x0, int clip_y0, int clip_x1, int clip_y1,
float scale);
-static void html_redraw_clip(long clip_x0, long clip_y0,
- long clip_x1, long clip_y1);
+static void html_redraw_clip(int clip_x0, int clip_y0,
+ int clip_x1, int clip_y1);
static void html_redraw_rectangle(int x0, int y0, int width, int height,
os_colour colour);
static void html_redraw_fill(int x0, int y0, int width, int height,
@@ -53,7 +56,7 @@ static void html_redraw_radio(int x, int y, int width, int height,
bool selected);
static void html_redraw_file(int x, int y, int width, int height,
struct box *box, float scale);
-static void html_redraw_background(long x, long y, int width, int height,
+static void html_redraw_background(int x, int y, int width, int height,
struct box *box, float scale);
bool gui_redraw_debug = false;
@@ -64,12 +67,28 @@ static os_trfm trfm = { {
{ 0, 0 } } };
+/**
+ * Draw a CONTENT_HTML to a RISC OS window.
+ *
+ * \param c content of type CONTENT_HTML
+ * \param x coordinate for top-left of redraw
+ * \param y coordinate for top-left of redraw
+ * \param width available width (not used for HTML redraw)
+ * \param height available height (not used for HTML redraw)
+ * \param clip_x0 clip rectangle
+ * \param clip_y0 clip rectangle
+ * \param clip_x1 clip rectangle
+ * \param clip_y1 clip rectangle
+ * \param scale scale for redraw
+ *
+ * x, y, clip_[xy][01] are in RISC OS screen absolute OS-units.
+ */
+
void html_redraw(struct content *c, int x, int y,
int width, int height,
int clip_x0, int clip_y0, int clip_x1, int clip_y1,
float scale)
{
- bool select_on = false;
unsigned long background_colour = 0xffffff;
struct box *box;
@@ -87,23 +106,36 @@ void html_redraw(struct content *c, int x, int y,
trfm.entries[0][0] = trfm.entries[1][1] = 65536 * scale;
- html_redraw_box(c, box, x, y, background_colour,
- &select_on, clip_x0, clip_y0, clip_x1, clip_y1, scale);
+ html_redraw_box(box, x, y, background_colour,
+ clip_x0, clip_y0, clip_x1, clip_y1, scale);
}
+/**
+ * Recursively draw a box to a RISC OS window.
+ *
+ * \param box box to draw
+ * \param x coordinate of parent box
+ * \param y coordinate of parent box
+ * \param current_background_color background colour under this box
+ * \param clip_x0 clip rectangle
+ * \param clip_y0 clip rectangle
+ * \param clip_x1 clip rectangle
+ * \param clip_y1 clip rectangle
+ * \param scale scale for redraw
+ *
+ * x, y, clip_[xy][01] are in RISC OS screen absolute OS-units.
+ */
-void html_redraw_box(struct content *content, struct box * box,
- signed long x, signed long y,
+void html_redraw_box(struct box *box,
+ int x, int y,
unsigned long current_background_color,
- bool *select_on,
- long clip_x0, long clip_y0, long clip_x1, long clip_y1,
+ int clip_x0, int clip_y0, int clip_x1, int clip_y1,
float scale)
{
struct box *c;
int width, height;
- int padding_left, padding_top;
- int padding_width, padding_height;
+ int padding_left, padding_top, padding_width, padding_height;
int x0, y0, x1, y1;
int colour;
@@ -118,16 +150,23 @@ void html_redraw_box(struct content *content, struct box * box,
padding_height = (box->padding[TOP] + box->height +
box->padding[BOTTOM]) * 2 * scale;
- x0 = x;
- y1 = y - 1;
- x1 = x0 + padding_width - 1;
- y0 = y1 - padding_height + 1;
+ /* calculate clip rectangle for this box */
+ if (box->style && box->style->overflow != CSS_OVERFLOW_VISIBLE) {
+ x0 = x;
+ y0 = y - padding_height;
+ x1 = x + padding_width - 1;
+ y1 = y - 1;
+ } else {
+ x0 = x + box->descendant_x0 * 2 * scale;
+ y0 = y - box->descendant_y1 * 2 * scale;
+ x1 = x + box->descendant_x1 * 2 * scale + 1;
+ y1 = y - box->descendant_y0 * 2 * scale + 1;
+ }
/* if visibility is hidden render children only */
if (box->style && box->style->visibility == CSS_VISIBILITY_HIDDEN) {
for (c = box->children; c; c = c->next)
- html_redraw_box(content, c, x, y, current_background_color,
- select_on,
+ html_redraw_box(c, x, y, current_background_color,
x0, y0, x1, y1, scale);
return;
}
@@ -190,11 +229,8 @@ void html_redraw_box(struct content *content, struct box * box,
y - padding_height - box->border[BOTTOM] *
2 * scale);
- /* return if the box is completely outside the clip rectangle, except
- * for table rows which may contain cells spanning into other rows */
- if (box->type != BOX_TABLE_ROW &&
- (clip_y1 < y0 || y1 < clip_y0 ||
- clip_x1 < x0 || x1 < clip_x0))
+ /* return if the box is completely outside the clip rectangle */
+ if (clip_y1 < y0 || y1 < clip_y0 || clip_x1 < x0 || x1 < clip_x0)
return;
if (box->type == BOX_BLOCK || box->type == BOX_INLINE_BLOCK ||
@@ -227,8 +263,8 @@ void html_redraw_box(struct content *content, struct box * box,
if (box->style->background_color != TRANSPARENT) {
/* optimisation: skip if fully repeated bg image */
if (!box->background ||
- box->style->background_repeat !=
- CSS_BACKGROUND_REPEAT_REPEAT) {
+ box->style->background_repeat !=
+ CSS_BACKGROUND_REPEAT_REPEAT) {
colourtrans_set_gcol(
box->style->background_color << 8,
@@ -239,7 +275,7 @@ void html_redraw_box(struct content *content, struct box * box,
if (px0 < px1 && py0 < py1)
os_plot(os_PLOT_RECTANGLE | os_PLOT_TO,
- px1, py1);
+ px1 - 1, py1 - 1);
}
/* set current background color for font painting */
current_background_color = box->style->background_color;
@@ -258,35 +294,6 @@ void html_redraw_box(struct content *content, struct box * box,
}
}
- /* handle overflow - horrendously broken atm */
-#if 0
- if ((box->type == BOX_BLOCK || box->type == BOX_INLINE_BLOCK ||
- box->type == BOX_TABLE_CELL || box->object) &&
- box->style &&
- box->style->overflow == CSS_OVERFLOW_VISIBLE &&
- box->descendant_x1 && box->descendant_y1) {
- LOG(("Box Coords: %d, %d", box->x, box->y));
- LOG(("Descendants: %d, %d, %d, %d", box->descendant_x0, box->descendant_y0, box->descendant_x1, box->descendant_y1));
- LOG(("Previous vals: %d, %d, %d, %d", x0, y0, x1, y1));
- x0 = (box->x + box->descendant_x0) * 2 * scale;
- y1 = (box->y + box->descendant_y1) * 2 * scale - 1;
- x1 = (box->x + box->descendant_x1) * 2 * scale - 1;
- y0 = (box->y + box->descendant_y0) * 2 * scale + 1;
-
- LOG(("New Coords: %d, %d, %d, %d", x0, y0, x1, y1));
- LOG(("Clipping: %ld, %ld, %ld, %ld", clip_x0, clip_y0, clip_x1, clip_y1));
- /* find intersection of clip rectangle and box */
- if (x0 < clip_x0) x0 = clip_x0;
- if (y0 < clip_y0) y0 = clip_y0;
- if (clip_x1 > x1) x1 = clip_x1;
- if (clip_y1 > y1) y1 = clip_y1;
-
- LOG(("Overflow clip: %d, %d, %d, %d", x0, y0, x1, y1));
- /* clip to it */
- html_redraw_clip(x0, y0, x1, y1);
- }
-#endif
-
if (box->object) {
content_redraw(box->object, x + padding_left, y - padding_top,
width, height, x0, y0, x1, y1, scale);
@@ -368,15 +375,13 @@ void html_redraw_box(struct content *content, struct box * box,
} else {
for (c = box->children; c != 0; c = c->next)
if (c->type != BOX_FLOAT_LEFT && c->type != BOX_FLOAT_RIGHT)
- html_redraw_box(content, c, x,
+ html_redraw_box(c, x,
y, current_background_color,
- select_on,
x0, y0, x1, y1, scale);
for (c = box->float_children; c != 0; c = c->next_float)
- html_redraw_box(content, c, x,
+ html_redraw_box(c, x,
y, current_background_color,
- select_on,
x0, y0, x1, y1, scale);
}
@@ -386,8 +391,12 @@ void html_redraw_box(struct content *content, struct box * box,
}
-void html_redraw_clip(long clip_x0, long clip_y0,
- long clip_x1, long clip_y1)
+/**
+ * Set the clip rectangle.
+ */
+
+void html_redraw_clip(int clip_x0, int clip_y0,
+ int clip_x1, int clip_y1)
{
os_set_graphics_window();
os_writec((char) (clip_x0 & 0xff)); os_writec((char) (clip_x0 >> 8));
@@ -447,6 +456,10 @@ static const draw_line_style line_style = { draw_JOIN_MITRED,
static const int dash_pattern_dotted[] = { 0, 1, 512 };
static const int dash_pattern_dashed[] = { 0, 1, 2048 };
+/**
+ * Draw a border.
+ */
+
void html_redraw_border(colour color, int width, css_border_style style,
int x0, int y0, int x1, int y1)
{
@@ -547,12 +560,12 @@ void html_redraw_file(int x, int y, int width, int height,
/* y - height / 2 - 17, os_ACTION_OVERWRITE); */
}
-void html_redraw_background(long xi, long yi, int width, int height,
+void html_redraw_background(int xi, int yi, int width, int height,
struct box *box, float scale)
{
unsigned int tinct_options = 0;
- long x = 0;
- long y = 0;
+ int x = 0;
+ int y = 0;
unsigned int image_width, image_height;
os_coord image_size;
float multiplier;