diff options
author | Adrian Lees <adrian@aemulor.com> | 2006-02-15 23:09:55 +0000 |
---|---|---|
committer | Adrian Lees <adrian@aemulor.com> | 2006-02-15 23:09:55 +0000 |
commit | dbfdafdf1820a95995c3b260e147c55125468874 (patch) | |
tree | 8ef69f8cbc4733490f82b462edeb167c0ee08fb8 /render/box.c | |
parent | 07d55db910095415d15cc2b6509fd44efa79a875 (diff) | |
download | netsurf-dbfdafdf1820a95995c3b260e147c55125468874.tar.gz netsurf-dbfdafdf1820a95995c3b260e147c55125468874.tar.bz2 |
[project @ 2006-02-15 23:09:53 by adrianl]
Extend text selection, copying, saving and searching code to handle textplain contents; modified textplain code to accept other line terminators
svn path=/import/netsurf/; revision=2081
Diffstat (limited to 'render/box.c')
-rw-r--r-- | render/box.c | 27 |
1 files changed, 25 insertions, 2 deletions
diff --git a/render/box.c b/render/box.c index e527cdde3..5ceb0376c 100644 --- a/render/box.c +++ b/render/box.c @@ -47,8 +47,9 @@ struct box * box_create(struct css_style *style, struct box *box; box = talloc(context, struct box); - if (!box) + if (!box) { return 0; + } box->type = BOX_INLINE; box->style = style; @@ -232,6 +233,27 @@ void box_coords(struct box *box, int *x, int *y) /** + * Find the bounds of a box. + * + * \param box the box to calculate bounds of + * \param r receives bounds + */ + +void box_bounds(struct box *box, struct rect *r) +{ + int width, height; + + box_coords(box, &r->x0, &r->y0); + + width = box->padding[LEFT] + box->width + box->padding[RIGHT]; + height = box->padding[TOP] + box->height + box->padding[BOTTOM]; + + r->x1 = r->x0 + width; + r->y1 = r->y0 + height; +} + + +/** * Find the boxes at a point. * * \param box box to search children of @@ -244,7 +266,7 @@ void box_coords(struct box *box, int *x, int *y) * \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 + * To find all the boxes in the hierarchy at a certain point, use code like * this: * \code * struct box *box = top_of_document_to_search; @@ -469,6 +491,7 @@ void box_dump(struct box *box, unsigned int depth) default: fprintf(stderr, "Unknown box type "); } + fprintf(stderr, "ofst %d", box->byte_offset); if (box->text) fprintf(stderr, "'%.*s' ", (int) box->length, box->text); if (box->space) |