diff options
author | Michael Drake <tlsa@netsurf-browser.org> | 2011-02-22 14:57:04 +0000 |
---|---|---|
committer | Michael Drake <tlsa@netsurf-browser.org> | 2011-02-22 14:57:04 +0000 |
commit | 474cbe917ea936b905371cc54162870361c33f0a (patch) | |
tree | 7eebfb8d9571900af0a04b01e18ddf70b1e5c939 | |
parent | 9a8341cb39844238a3987071f9e16883dffb997f (diff) | |
download | netsurf-474cbe917ea936b905371cc54162870361c33f0a.tar.gz netsurf-474cbe917ea936b905371cc54162870361c33f0a.tar.bz2 |
Add function to get a box's border edge bbox, and use it to find initial descendant bbox.
svn path=/trunk/netsurf/; revision=11754
-rw-r--r-- | render/layout.c | 32 |
1 files changed, 26 insertions, 6 deletions
diff --git a/render/layout.c b/render/layout.c index bbd8d0613..9cf7c4472 100644 --- a/render/layout.c +++ b/render/layout.c @@ -4487,6 +4487,28 @@ void layout_compute_offsets(struct box *box, /** + * Find a box's bounding box relative to itself, i.e. the box's border edge box + * + * \param box box find bounding box of + * \param desc_x0 updated to left of box's bbox + * \param desc_y0 updated to top of box's bbox + * \param desc_x1 updated to right of box's bbox + * \param desc_y1 updated to bottom of box's bbox + */ + +static void layout_get_box_bbox(struct box *box, int *desc_x0, int *desc_y0, + int *desc_x1, int *desc_y1) +{ + *desc_x0 = -box->border[LEFT].width; + *desc_y0 = -box->border[TOP].width; + *desc_x1 = box->padding[LEFT] + box->width + box->padding[RIGHT] + + box->border[RIGHT].width; + *desc_y1 = box->padding[TOP] + box->height + box->padding[BOTTOM] + + box->border[BOTTOM].width; +} + + +/** * Apply changes to box descendant_[xy][01] values due to given child. * * \param box box to update @@ -4539,13 +4561,11 @@ void layout_calculate_descendant_bboxes(struct box *box) assert(0); } - box->descendant_x0 = -box->border[LEFT].width; - box->descendant_y0 = -box->border[TOP].width; - box->descendant_x1 = box->padding[LEFT] + box->width + - box->padding[RIGHT] + box->border[RIGHT].width; - box->descendant_y1 = box->padding[TOP] + box->height + - box->padding[BOTTOM] + box->border[BOTTOM].width; + /* Initialise box's descendant box to border edge box */ + layout_get_box_bbox(box, &box->descendant_x0, &box->descendant_y0, + &box->descendant_x1, &box->descendant_y1); + /* Extend it to contain HTML contents if box is replaced */ if (box->object && content_get_type(box->object) == CONTENT_HTML) { if (box->descendant_x1 < content_get_width(box->object)) box->descendant_x1 = content_get_width(box->object); |