diff options
Diffstat (limited to 'render')
-rw-r--r-- | render/box.c | 30 | ||||
-rw-r--r-- | render/box.h | 1 |
2 files changed, 30 insertions, 1 deletions
diff --git a/render/box.c b/render/box.c index 7e0df2483..f00b8aa1d 100644 --- a/render/box.c +++ b/render/box.c @@ -133,7 +133,35 @@ void box_insert_sibling(struct box *box, struct box *new_box) /** - * Free the a box tree recursively. + * 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. * * \param box box to free recursively * diff --git a/render/box.h b/render/box.h index bcdf79005..60aba1ba5 100644 --- a/render/box.h +++ b/render/box.h @@ -234,6 +234,7 @@ struct box * box_create(struct css_style *style, char *id, void *context); void box_add_child(struct box *parent, struct box *child); void box_insert_sibling(struct box *box, struct box *new_box); +void box_unlink_and_free(struct box *box); void box_free(struct box *box); void box_free_box(struct box *box); void box_free_object_params(struct object_params *op); |