From 65263651e3c8036a631270976a773f3d4497f474 Mon Sep 17 00:00:00 2001 From: James Bursa Date: Thu, 9 Oct 2003 15:22:48 +0000 Subject: [project @ 2003-10-09 15:22:48 by bursa] Implement box_insert_sibling(). svn path=/import/netsurf/; revision=358 --- render/box.c | 23 ++++++++++++++++++++--- render/box.h | 2 ++ 2 files changed, 22 insertions(+), 3 deletions(-) diff --git a/render/box.c b/render/box.c index 9a9eb2def..77fc99f00 100644 --- a/render/box.c +++ b/render/box.c @@ -44,7 +44,6 @@ struct result { int convert_children; /* children should be converted */ }; -static void box_add_child(struct box * parent, struct box * child); static struct box * convert_xml_to_box(xmlNode * n, struct content *content, struct css_style * parent_style, struct css_selector ** selector, unsigned int depth, @@ -119,7 +118,7 @@ static const struct element_entry element_table[] = { /** - * add a child to a box tree node + * Add a child to a box tree node. */ void box_add_child(struct box * parent, struct box * child) @@ -136,8 +135,9 @@ void box_add_child(struct box * parent, struct box * child) child->parent = parent; } + /** - * create a box tree node + * Create a box tree node. */ struct box * box_create(struct css_style * style, @@ -178,6 +178,23 @@ struct box * box_create(struct css_style * style, } +/** + * Insert a new box as a sibling to a box in a tree. + */ + +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; +} + + /** * make a box tree with style data from an xml tree */ diff --git a/render/box.h b/render/box.h index 2a3b15633..76c9500c9 100644 --- a/render/box.h +++ b/render/box.h @@ -177,6 +177,8 @@ void xml_to_box(xmlNode *n, struct content *c); void box_dump(struct box * box, unsigned int depth); struct box * box_create(struct css_style * style, char *href, char *title); +void box_add_child(struct box * parent, struct box * child); +void box_insert_sibling(struct box *box, struct box *new_box); void box_free(struct box *box); void box_coords(struct box *box, unsigned long *x, unsigned long *y); -- cgit v1.2.3