2003-06-30 16:44:03 +04:00
|
|
|
/*
|
|
|
|
* This file is part of NetSurf, http://netsurf.sourceforge.net/
|
|
|
|
* Licensed under the GNU General Public License,
|
|
|
|
* http://www.opensource.org/licenses/gpl-license
|
2005-03-26 04:12:27 +03:00
|
|
|
* Copyright 2005 James Bursa <bursa@users.sourceforge.net>
|
2003-06-30 16:44:03 +04:00
|
|
|
* Copyright 2003 Phil Mellor <monkeyson@users.sourceforge.net>
|
2005-03-26 04:12:27 +03:00
|
|
|
* Copyright 2005 John M Bell <jmb202@ecs.soton.ac.uk>
|
2002-05-04 23:57:18 +04:00
|
|
|
*/
|
|
|
|
|
2004-07-19 18:31:31 +04:00
|
|
|
/** \file
|
2005-03-26 04:12:27 +03:00
|
|
|
* Box tree manipulation (implementation).
|
2004-07-19 18:31:31 +04:00
|
|
|
*/
|
|
|
|
|
2002-05-04 23:57:18 +04:00
|
|
|
#include <assert.h>
|
2003-07-15 02:57:45 +04:00
|
|
|
#include <stdbool.h>
|
2002-05-04 23:57:18 +04:00
|
|
|
#include <string.h>
|
2003-10-25 18:13:49 +04:00
|
|
|
#include "netsurf/content/content.h"
|
2003-04-04 19:19:32 +04:00
|
|
|
#include "netsurf/css/css.h"
|
2002-08-18 20:46:45 +04:00
|
|
|
#include "netsurf/render/box.h"
|
2003-10-25 04:35:49 +04:00
|
|
|
#include "netsurf/render/form.h"
|
2005-04-09 13:47:37 +04:00
|
|
|
#include "netsurf/utils/talloc.h"
|
2005-03-26 04:12:27 +03:00
|
|
|
|
|
|
|
|
2004-10-18 01:10:19 +04:00
|
|
|
static bool box_contains_point(struct box *box, int x, int y);
|
2003-07-05 01:17:53 +04:00
|
|
|
|
2004-08-02 00:28:02 +04:00
|
|
|
#define box_is_float(box) (box->type == BOX_FLOAT_LEFT || \
|
|
|
|
box->type == BOX_FLOAT_RIGHT)
|
|
|
|
|
2003-10-09 19:22:48 +04:00
|
|
|
|
2002-06-27 03:27:30 +04:00
|
|
|
/**
|
2003-10-09 19:22:48 +04:00
|
|
|
* Create a box tree node.
|
2004-12-10 01:22:13 +03:00
|
|
|
*
|
|
|
|
* \param style style for the box (not copied)
|
2005-04-09 13:47:37 +04:00
|
|
|
* \param href href for the box (not copied), or 0
|
|
|
|
* \param title title for the box (not copied), or 0
|
|
|
|
* \param id id for the box (not copied), or 0
|
|
|
|
* \param context context for allocations
|
2004-12-10 01:22:13 +03:00
|
|
|
* \return allocated and initialised box, or 0 on memory exhaustion
|
2002-06-27 03:27:30 +04:00
|
|
|
*/
|
|
|
|
|
2005-03-26 04:12:27 +03:00
|
|
|
struct box * box_create(struct css_style *style,
|
2005-04-09 13:47:37 +04:00
|
|
|
char *href, char *title, char *id,
|
|
|
|
void *context)
|
2002-06-27 03:27:30 +04:00
|
|
|
{
|
2004-02-02 03:22:59 +03:00
|
|
|
unsigned int i;
|
2004-08-14 16:57:02 +04:00
|
|
|
struct box *box;
|
2004-12-10 01:22:13 +03:00
|
|
|
|
2005-04-09 13:47:37 +04:00
|
|
|
box = talloc(context, struct box);
|
|
|
|
if (!box)
|
2004-12-10 01:22:13 +03:00
|
|
|
return 0;
|
2004-08-14 16:57:02 +04:00
|
|
|
|
2003-07-05 20:16:15 +04:00
|
|
|
box->type = BOX_INLINE;
|
2002-06-27 03:27:30 +04:00
|
|
|
box->style = style;
|
2004-08-14 16:57:02 +04:00
|
|
|
box->x = box->y = 0;
|
2002-09-19 23:54:43 +04:00
|
|
|
box->width = UNKNOWN_WIDTH;
|
2004-08-14 16:57:02 +04:00
|
|
|
box->height = 0;
|
|
|
|
box->descendant_x0 = box->descendant_y0 = 0;
|
|
|
|
box->descendant_x1 = box->descendant_y1 = 0;
|
|
|
|
for (i = 0; i != 4; i++)
|
|
|
|
box->margin[i] = box->padding[i] = box->border[i] = 0;
|
2004-08-26 03:56:49 +04:00
|
|
|
box->scroll_x = box->scroll_y = 0;
|
2004-08-14 16:57:02 +04:00
|
|
|
box->min_width = 0;
|
2002-09-18 23:36:28 +04:00
|
|
|
box->max_width = UNKNOWN_MAX_WIDTH;
|
2004-08-14 16:57:02 +04:00
|
|
|
box->text = NULL;
|
|
|
|
box->length = 0;
|
2003-07-05 01:17:53 +04:00
|
|
|
box->space = 0;
|
2003-09-10 01:43:44 +04:00
|
|
|
box->clone = 0;
|
2005-04-09 13:47:37 +04:00
|
|
|
box->href = href;
|
|
|
|
box->title = title;
|
2004-08-14 16:57:02 +04:00
|
|
|
box->columns = 1;
|
|
|
|
box->rows = 1;
|
2003-07-07 01:10:12 +04:00
|
|
|
box->start_column = 0;
|
2004-08-14 16:57:02 +04:00
|
|
|
box->next = NULL;
|
|
|
|
box->prev = NULL;
|
|
|
|
box->children = NULL;
|
|
|
|
box->last = NULL;
|
|
|
|
box->parent = NULL;
|
2005-04-14 01:58:28 +04:00
|
|
|
box->fallback = NULL;
|
2005-06-06 00:54:37 +04:00
|
|
|
box->inline_end = NULL;
|
2004-08-14 16:57:02 +04:00
|
|
|
box->float_children = NULL;
|
|
|
|
box->next_float = NULL;
|
|
|
|
box->col = NULL;
|
|
|
|
box->gadget = NULL;
|
|
|
|
box->usemap = NULL;
|
2005-04-09 13:47:37 +04:00
|
|
|
box->id = id;
|
2004-08-14 16:57:02 +04:00
|
|
|
box->background = NULL;
|
|
|
|
box->object = NULL;
|
|
|
|
box->object_params = NULL;
|
|
|
|
|
2002-06-27 03:27:30 +04:00
|
|
|
return box;
|
|
|
|
}
|
2002-05-04 23:57:18 +04:00
|
|
|
|
2002-09-12 01:19:24 +04:00
|
|
|
|
2003-10-09 19:22:48 +04:00
|
|
|
/**
|
2005-03-26 04:12:27 +03:00
|
|
|
* Add a child to a box tree node.
|
2005-01-01 17:51:35 +03:00
|
|
|
*
|
2005-03-26 04:12:27 +03:00
|
|
|
* \param parent box giving birth
|
|
|
|
* \param child box to link as last child of parent
|
2002-08-18 20:46:45 +04:00
|
|
|
*/
|
|
|
|
|
2005-03-26 04:12:27 +03:00
|
|
|
void box_add_child(struct box *parent, struct box *child)
|
2002-08-18 20:46:45 +04:00
|
|
|
{
|
2005-06-06 00:54:37 +04:00
|
|
|
assert(parent);
|
|
|
|
assert(child);
|
|
|
|
|
2005-03-26 04:12:27 +03:00
|
|
|
if (parent->children != 0) { /* has children already */
|
|
|
|
parent->last->next = child;
|
|
|
|
child->prev = parent->last;
|
|
|
|
} else { /* this is the first child */
|
|
|
|
parent->children = child;
|
|
|
|
child->prev = 0;
|
2003-01-02 16:26:43 +03:00
|
|
|
}
|
|
|
|
|
2005-03-26 04:12:27 +03:00
|
|
|
parent->last = child;
|
|
|
|
child->parent = parent;
|
2002-08-18 20:46:45 +04:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2005-03-26 04:12:27 +03:00
|
|
|
/**
|
|
|
|
* Insert a new box as a sibling to a box in a tree.
|
|
|
|
*
|
|
|
|
* \param box box already in tree
|
|
|
|
* \param new_box box to link into tree as next sibling
|
|
|
|
*/
|
2005-01-01 17:51:35 +03:00
|
|
|
|
2005-03-26 04:12:27 +03:00
|
|
|
void box_insert_sibling(struct box *box, struct box *new_box)
|
|
|
|
{
|
|
|
|
new_box->parent = box->parent;
|
|
|
|
new_box->prev = box;
|
|
|
|
new_box->next = box->next;
|
|
|
|
box->next = new_box;
|
|
|
|
if (new_box->next)
|
|
|
|
new_box->next->prev = new_box;
|
|
|
|
else if (new_box->parent)
|
|
|
|
new_box->parent->last = new_box;
|
2002-08-18 20:46:45 +04:00
|
|
|
}
|
2002-09-08 22:11:56 +04:00
|
|
|
|
|
|
|
|
|
|
|
/**
|
2005-04-20 16:24:41 +04:00
|
|
|
* Unlink a box from the box tree and then free it recursively.
|
|
|
|
*
|
|
|
|
* \param box box to unlink and free recursively.
|
|
|
|
*/
|
|
|
|
|
|
|
|
void box_unlink_and_free(struct box *box)
|
|
|
|
{
|
|
|
|
struct box *parent = box->parent;
|
|
|
|
struct box *next = box->next;
|
|
|
|
struct box *prev = box->prev;
|
|
|
|
|
|
|
|
if (parent) {
|
|
|
|
if (parent->children == box)
|
|
|
|
parent->children = next;
|
|
|
|
if (parent->last == box)
|
|
|
|
parent->last = next ? next : prev;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (prev)
|
|
|
|
prev->next = next;
|
|
|
|
if (next)
|
|
|
|
next->prev = prev;
|
|
|
|
|
|
|
|
box_free(box);
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Free a box tree recursively.
|
2005-03-26 04:12:27 +03:00
|
|
|
*
|
|
|
|
* \param box box to free recursively
|
|
|
|
*
|
2005-04-09 13:47:37 +04:00
|
|
|
* The box and all its children is freed.
|
2002-09-08 22:11:56 +04:00
|
|
|
*/
|
|
|
|
|
|
|
|
void box_free(struct box *box)
|
|
|
|
{
|
2003-09-20 01:23:19 +04:00
|
|
|
struct box *child, *next;
|
2002-09-08 22:11:56 +04:00
|
|
|
|
2003-09-20 01:23:19 +04:00
|
|
|
/* free children first */
|
|
|
|
for (child = box->children; child; child = next) {
|
|
|
|
next = child->next;
|
|
|
|
box_free(child);
|
|
|
|
}
|
2002-09-08 22:11:56 +04:00
|
|
|
|
|
|
|
/* last this box */
|
2003-01-02 16:26:43 +03:00
|
|
|
box_free_box(box);
|
|
|
|
}
|
|
|
|
|
2004-05-21 18:26:59 +04:00
|
|
|
|
|
|
|
/**
|
2005-03-26 04:12:27 +03:00
|
|
|
* Free the data in a single box structure.
|
|
|
|
*
|
|
|
|
* \param box box to free
|
2004-05-21 18:26:59 +04:00
|
|
|
*/
|
|
|
|
|
2003-01-02 16:26:43 +03:00
|
|
|
void box_free_box(struct box *box)
|
|
|
|
{
|
2003-09-20 01:23:19 +04:00
|
|
|
if (!box->clone) {
|
2004-05-21 18:26:59 +04:00
|
|
|
if (box->gadget)
|
|
|
|
form_free_control(box->gadget);
|
2002-12-30 01:27:35 +03:00
|
|
|
}
|
2002-12-30 05:06:03 +03:00
|
|
|
|
2005-04-09 13:47:37 +04:00
|
|
|
talloc_free(box);
|
2002-09-08 22:11:56 +04:00
|
|
|
}
|
2002-12-30 01:27:35 +03:00
|
|
|
|
2005-03-26 04:12:27 +03:00
|
|
|
|
2004-07-18 03:32:09 +04:00
|
|
|
/**
|
|
|
|
* Find the absolute coordinates of a box.
|
|
|
|
*
|
|
|
|
* \param box the box to calculate coordinates of
|
|
|
|
* \param x updated to x coordinate
|
|
|
|
* \param y updated to y coordinate
|
|
|
|
*/
|
|
|
|
|
|
|
|
void box_coords(struct box *box, int *x, int *y)
|
|
|
|
{
|
|
|
|
*x = box->x;
|
|
|
|
*y = box->y;
|
|
|
|
while (box->parent) {
|
2004-08-02 00:28:02 +04:00
|
|
|
if (box_is_float(box)) {
|
2004-07-18 03:32:09 +04:00
|
|
|
do {
|
|
|
|
box = box->parent;
|
|
|
|
} while (!box->float_children);
|
|
|
|
} else
|
|
|
|
box = box->parent;
|
2004-10-18 01:10:19 +04:00
|
|
|
*x += box->x - box->scroll_x;
|
|
|
|
*y += box->y - box->scroll_y;
|
2004-07-18 03:32:09 +04:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Find the boxes at a point.
|
|
|
|
*
|
|
|
|
* \param box box to search children of
|
2004-10-18 01:10:19 +04:00
|
|
|
* \param x point to find, in global document coordinates
|
2004-07-18 03:32:09 +04:00
|
|
|
* \param y point to find, in global document coordinates
|
|
|
|
* \param box_x position of box, in global document coordinates, updated
|
|
|
|
* to position of returned box, if any
|
|
|
|
* \param box_y position of box, in global document coordinates, updated
|
|
|
|
* to position of returned box, if any
|
|
|
|
* \param content updated to content of object that returned box is in, if any
|
|
|
|
* \return box at given point, or 0 if none found
|
|
|
|
*
|
|
|
|
* To find all the boxes in the heirarchy at a certain point, use code like
|
|
|
|
* this:
|
|
|
|
* \code
|
|
|
|
* struct box *box = top_of_document_to_search;
|
|
|
|
* int box_x = 0, box_y = 0;
|
|
|
|
* struct content *content = document_to_search;
|
|
|
|
*
|
|
|
|
* while ((box = box_at_point(box, x, y, &box_x, &box_y, &content))) {
|
|
|
|
* // process box
|
|
|
|
* }
|
|
|
|
* \endcode
|
|
|
|
*/
|
|
|
|
|
|
|
|
struct box *box_at_point(struct box *box, int x, int y,
|
|
|
|
int *box_x, int *box_y,
|
|
|
|
struct content **content)
|
|
|
|
{
|
2004-08-02 00:28:02 +04:00
|
|
|
int bx = *box_x, by = *box_y;
|
|
|
|
struct box *child, *sibling;
|
2004-07-18 03:32:09 +04:00
|
|
|
|
|
|
|
assert(box);
|
|
|
|
|
|
|
|
/* drill into HTML objects */
|
|
|
|
if (box->object) {
|
|
|
|
if (box->object->type == CONTENT_HTML &&
|
|
|
|
box->object->data.html.layout) {
|
|
|
|
*content = box->object;
|
|
|
|
box = box->object->data.html.layout;
|
|
|
|
} else {
|
2004-08-02 00:28:02 +04:00
|
|
|
goto siblings;
|
2004-07-18 03:32:09 +04:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
/* consider floats first, since they will often overlap other boxes */
|
|
|
|
for (child = box->float_children; child; child = child->next_float) {
|
2004-10-18 01:10:19 +04:00
|
|
|
if (box_contains_point(child, x - bx, y - by)) {
|
|
|
|
*box_x += child->x - child->scroll_x;
|
|
|
|
*box_y += child->y - child->scroll_y;
|
2004-07-18 03:32:09 +04:00
|
|
|
return child;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
/* non-float children */
|
|
|
|
for (child = box->children; child; child = child->next) {
|
2004-08-02 00:28:02 +04:00
|
|
|
if (box_is_float(child))
|
2004-07-18 03:32:09 +04:00
|
|
|
continue;
|
2004-10-18 01:10:19 +04:00
|
|
|
if (box_contains_point(child, x - bx, y - by)) {
|
|
|
|
*box_x += child->x - child->scroll_x;
|
|
|
|
*box_y += child->y - child->scroll_y;
|
2004-07-18 03:32:09 +04:00
|
|
|
return child;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2004-08-02 00:28:02 +04:00
|
|
|
siblings:
|
|
|
|
/* siblings and siblings of ancestors */
|
|
|
|
while (box) {
|
|
|
|
if (!box_is_float(box)) {
|
2004-10-18 01:10:19 +04:00
|
|
|
bx -= box->x - box->scroll_x;
|
|
|
|
by -= box->y - box->scroll_y;
|
2004-08-02 00:28:02 +04:00
|
|
|
for (sibling = box->next; sibling;
|
|
|
|
sibling = sibling->next) {
|
|
|
|
if (box_is_float(sibling))
|
|
|
|
continue;
|
2004-10-18 01:10:19 +04:00
|
|
|
if (box_contains_point(sibling,
|
|
|
|
x - bx, y - by)) {
|
|
|
|
*box_x = bx + sibling->x -
|
|
|
|
sibling->scroll_x;
|
|
|
|
*box_y = by + sibling->y -
|
|
|
|
sibling->scroll_y;
|
2004-08-02 00:28:02 +04:00
|
|
|
return sibling;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
box = box->parent;
|
|
|
|
} else {
|
2004-10-18 01:10:19 +04:00
|
|
|
bx -= box->x - box->scroll_x;
|
|
|
|
by -= box->y - box->scroll_y;
|
2004-08-02 00:28:02 +04:00
|
|
|
for (sibling = box->next_float; sibling;
|
|
|
|
sibling = sibling->next_float) {
|
2004-10-18 01:10:19 +04:00
|
|
|
if (box_contains_point(sibling,
|
|
|
|
x - bx, y - by)) {
|
|
|
|
*box_x = bx + sibling->x -
|
|
|
|
sibling->scroll_x;
|
|
|
|
*box_y = by + sibling->y -
|
|
|
|
sibling->scroll_y;
|
2004-08-02 00:28:02 +04:00
|
|
|
return sibling;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
do {
|
|
|
|
box = box->parent;
|
|
|
|
} while (!box->float_children);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2004-07-18 03:32:09 +04:00
|
|
|
return 0;
|
|
|
|
}
|
2004-07-18 21:38:01 +04:00
|
|
|
|
|
|
|
|
2004-10-18 01:10:19 +04:00
|
|
|
/**
|
|
|
|
* Determine if a point lies within a box.
|
|
|
|
*
|
|
|
|
* \param box box to consider
|
|
|
|
* \param x coordinate relative to box parent
|
|
|
|
* \param y coordinate relative to box parent
|
|
|
|
* \return true if the point is within the box or a descendant box
|
|
|
|
*
|
|
|
|
* This is a helper function for box_at_point().
|
|
|
|
*/
|
|
|
|
|
|
|
|
bool box_contains_point(struct box *box, int x, int y)
|
|
|
|
{
|
2005-08-15 01:43:36 +04:00
|
|
|
if ((box->style && box->style->overflow != CSS_OVERFLOW_VISIBLE) ||
|
|
|
|
box->inline_end) {
|
2005-03-19 17:23:47 +03:00
|
|
|
if (box->x <= x + box->border[LEFT] &&
|
|
|
|
x < box->x + box->padding[LEFT] + box->width +
|
2005-03-19 02:50:36 +03:00
|
|
|
box->border[RIGHT] + box->padding[RIGHT] &&
|
2005-03-19 17:23:47 +03:00
|
|
|
box->y <= y + box->border[TOP] &&
|
|
|
|
y < box->y + box->padding[TOP] + box->height +
|
2005-03-19 02:50:36 +03:00
|
|
|
box->border[BOTTOM] + box->padding[BOTTOM])
|
2004-10-18 01:10:19 +04:00
|
|
|
return true;
|
|
|
|
} else {
|
|
|
|
if (box->x + box->descendant_x0 <= x &&
|
|
|
|
x < box->x + box->descendant_x1 &&
|
|
|
|
box->y + box->descendant_y0 <= y &&
|
|
|
|
y < box->y + box->descendant_y1)
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2004-07-18 21:38:01 +04:00
|
|
|
/**
|
|
|
|
* Find the box containing an object at the given coordinates, if any.
|
|
|
|
*
|
|
|
|
* \param c content to search, must have type CONTENT_HTML
|
|
|
|
* \param x coordinates in document units
|
|
|
|
* \param y coordinates in document units
|
|
|
|
*/
|
|
|
|
|
|
|
|
struct box *box_object_at_point(struct content *c, int x, int y)
|
|
|
|
{
|
|
|
|
struct box *box = c->data.html.layout;
|
|
|
|
int box_x = 0, box_y = 0;
|
|
|
|
struct content *content = c;
|
|
|
|
struct box *object_box = 0;
|
|
|
|
|
|
|
|
assert(c->type == CONTENT_HTML);
|
|
|
|
|
2005-03-26 04:12:27 +03:00
|
|
|
while ((box = box_at_point(box, x, y, &box_x, &box_y, &content))) {
|
2004-07-18 21:38:01 +04:00
|
|
|
if (box->style &&
|
|
|
|
box->style->visibility == CSS_VISIBILITY_HIDDEN)
|
|
|
|
continue;
|
|
|
|
|
|
|
|
if (box->object)
|
|
|
|
object_box = box;
|
|
|
|
}
|
|
|
|
|
|
|
|
return object_box;
|
|
|
|
}
|
2004-08-07 02:19:13 +04:00
|
|
|
|
2004-08-26 02:11:38 +04:00
|
|
|
|
2004-08-07 02:19:13 +04:00
|
|
|
/**
|
2004-08-26 02:11:38 +04:00
|
|
|
* Find a box based upon its id attribute.
|
2004-08-07 02:19:13 +04:00
|
|
|
*
|
2005-03-26 04:12:27 +03:00
|
|
|
* \param box box tree to search
|
|
|
|
* \param id id to look for
|
|
|
|
* \return the box or 0 if not found
|
2004-08-07 02:19:13 +04:00
|
|
|
*/
|
2005-03-26 04:12:27 +03:00
|
|
|
|
2004-08-14 18:30:12 +04:00
|
|
|
struct box *box_find_by_id(struct box *box, const char *id)
|
2004-08-07 02:19:13 +04:00
|
|
|
{
|
|
|
|
struct box *a, *b;
|
|
|
|
|
2004-08-26 02:11:38 +04:00
|
|
|
if (box->id != NULL && strcmp(id, box->id) == 0)
|
2004-08-07 02:19:13 +04:00
|
|
|
return box;
|
|
|
|
|
|
|
|
for (a = box->children; a; a = a->next) {
|
2004-08-26 02:11:38 +04:00
|
|
|
if ((b = box_find_by_id(a, id)) != NULL)
|
2004-08-07 02:19:13 +04:00
|
|
|
return b;
|
|
|
|
}
|
|
|
|
|
2004-08-14 18:30:12 +04:00
|
|
|
return NULL;
|
2004-08-07 02:19:13 +04:00
|
|
|
}
|
2005-03-26 04:12:27 +03:00
|
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Print a box tree to stderr.
|
|
|
|
*/
|
|
|
|
|
|
|
|
void box_dump(struct box *box, unsigned int depth)
|
|
|
|
{
|
|
|
|
unsigned int i;
|
2005-04-14 01:58:28 +04:00
|
|
|
struct box *c, *prev;
|
2005-03-26 04:12:27 +03:00
|
|
|
|
|
|
|
for (i = 0; i != depth; i++)
|
|
|
|
fprintf(stderr, " ");
|
|
|
|
|
|
|
|
fprintf(stderr, "%p ", box);
|
|
|
|
fprintf(stderr, "x%i y%i w%i h%i ", box->x, box->y,
|
|
|
|
box->width, box->height);
|
|
|
|
if (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, "BLOCK "); break;
|
|
|
|
case BOX_INLINE_CONTAINER: fprintf(stderr, "INLINE_CONTAINER "); break;
|
|
|
|
case BOX_INLINE: fprintf(stderr, "INLINE "); break;
|
2005-06-06 00:54:37 +04:00
|
|
|
case BOX_INLINE_END: fprintf(stderr, "INLINE_END "); break;
|
2005-03-26 04:12:27 +03:00
|
|
|
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, "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, "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;
|
2005-05-23 01:50:14 +04:00
|
|
|
case BOX_TEXT: fprintf(stderr, "TEXT "); break;
|
2005-03-26 04:12:27 +03:00
|
|
|
default: fprintf(stderr, "Unknown box type ");
|
|
|
|
}
|
|
|
|
|
|
|
|
if (box->text)
|
|
|
|
fprintf(stderr, "'%.*s' ", (int) box->length, box->text);
|
|
|
|
if (box->space)
|
|
|
|
fprintf(stderr, "space ");
|
|
|
|
if (box->object)
|
|
|
|
fprintf(stderr, "(object '%s') ", box->object->url);
|
|
|
|
if (box->style)
|
|
|
|
css_dump_style(box->style);
|
|
|
|
if (box->href != 0)
|
|
|
|
fprintf(stderr, " -> '%s'", box->href);
|
|
|
|
if (box->title != 0)
|
|
|
|
fprintf(stderr, " [%s]", box->title);
|
|
|
|
if (box->id != 0)
|
|
|
|
fprintf(stderr, " <%s>", box->id);
|
2005-06-06 00:54:37 +04:00
|
|
|
if (box->type == BOX_INLINE || box->type == BOX_INLINE_END)
|
|
|
|
fprintf(stderr, " inline_end %p", box->inline_end);
|
2005-03-26 04:12:27 +03:00
|
|
|
if (box->float_children)
|
|
|
|
fprintf(stderr, " float_children %p", box->float_children);
|
|
|
|
if (box->next_float)
|
|
|
|
fprintf(stderr, " next_float %p", box->next_float);
|
2005-07-02 21:49:40 +04:00
|
|
|
if (box->col) {
|
|
|
|
fprintf(stderr, " (columns");
|
|
|
|
for (i = 0; i != box->columns; i++)
|
|
|
|
fprintf(stderr, " (%s %i %i %i)",
|
|
|
|
((const char *[]) {"UNKNOWN", "FIXED",
|
|
|
|
"AUTO", "PERCENT", "RELATIVE"})
|
|
|
|
[box->col[i].type],
|
|
|
|
box->col[i].width,
|
|
|
|
box->col[i].min, box->col[i].max);
|
|
|
|
fprintf(stderr, ")");
|
|
|
|
}
|
2005-03-26 04:12:27 +03:00
|
|
|
fprintf(stderr, "\n");
|
|
|
|
|
2005-04-17 20:42:37 +04:00
|
|
|
for (c = box->children; c && c->next; c = c->next)
|
2005-04-14 01:58:28 +04:00
|
|
|
;
|
|
|
|
if (box->last != c)
|
|
|
|
fprintf(stderr, "warning: box->last %p (should be %p) "
|
|
|
|
"(box %p)\n", box->last, c, box);
|
|
|
|
for (prev = 0, c = box->children; c; prev = c, c = c->next) {
|
|
|
|
if (c->parent != box)
|
|
|
|
fprintf(stderr, "warning: box->parent %p (should be "
|
|
|
|
"%p) (box on next line)\n",
|
|
|
|
c->parent, box);
|
|
|
|
if (c->prev != prev)
|
|
|
|
fprintf(stderr, "warning: box->prev %p (should be "
|
|
|
|
"%p) (box on next line)\n",
|
|
|
|
c->prev, prev);
|
2005-03-26 04:12:27 +03:00
|
|
|
box_dump(c, depth + 1);
|
2005-04-14 01:58:28 +04:00
|
|
|
}
|
|
|
|
if (box->fallback) {
|
|
|
|
for (i = 0; i != depth; i++)
|
|
|
|
fprintf(stderr, " ");
|
|
|
|
fprintf(stderr, "fallback:\n");
|
|
|
|
for (c = box->fallback; c; c = c->next)
|
|
|
|
box_dump(c, depth + 1);
|
|
|
|
}
|
2005-03-26 04:12:27 +03:00
|
|
|
}
|