diff options
author | Vincent Sanders <vince@netsurf-browser.org> | 2012-11-30 12:29:54 +0000 |
---|---|---|
committer | Vincent Sanders <vince@netsurf-browser.org> | 2012-11-30 12:29:54 +0000 |
commit | 31c9ffb4b51b79394f882e5efed629c2df0600d9 (patch) | |
tree | dcd4c81e3d94c6511ec09989d92c2e2305d1864d | |
parent | 61872ab3a493d60ede0e5ca2221b4c5c94708171 (diff) | |
download | netsurf-31c9ffb4b51b79394f882e5efed629c2df0600d9.tar.gz netsurf-31c9ffb4b51b79394f882e5efed629c2df0600d9.tar.bz2 |
make boxes keep reference to the DOM node that causes them
-rw-r--r-- | render/box.c | 10 | ||||
-rw-r--r-- | render/box.h | 2 | ||||
-rw-r--r-- | render/box_construct.c | 5 |
3 files changed, 14 insertions, 3 deletions
diff --git a/render/box.c b/render/box.c index b9d059858..5dfada0c0 100644 --- a/render/box.c +++ b/render/box.c @@ -92,9 +92,14 @@ static int box_talloc_destructor(struct box *b) if (b->href != NULL) nsurl_unref(b->href); - if (b->id != NULL) + if (b->id != NULL) { lwc_string_unref(b->id); - + } + + if (b->node != NULL) { + dom_node_unref(b->node); + } + return 0; } @@ -172,6 +177,7 @@ struct box * box_create(css_select_results *styles, css_computed_style *style, box->object = NULL; box->object_params = NULL; box->iframe = NULL; + box->node = NULL; return box; } diff --git a/render/box.h b/render/box.h index a4622e374..0953d9f88 100644 --- a/render/box.h +++ b/render/box.h @@ -265,6 +265,8 @@ struct box { /** Iframe's browser_window, or NULL if none */ struct browser_window *iframe; + + struct dom_node *node; /**< DOM node that generated this box or NULL */ }; /** Table column data. */ diff --git a/render/box_construct.c b/render/box_construct.c index 63575876e..52c8cfee5 100644 --- a/render/box_construct.c +++ b/render/box_construct.c @@ -994,12 +994,15 @@ bool box_construct_element(struct box_construct_ctx *ctx, return true; } - /* Attach box to DOM node */ + /* Attach DOM node to box */ err = dom_node_set_user_data(ctx->n, kstr_box_key, box, NULL, (void *) &old_box); if (err != DOM_NO_ERR) return false; + /* Attach box to DOM node */ + box->node = dom_node_ref(ctx->n); + if (props.inline_container == NULL && (box->type == BOX_INLINE || box->type == BOX_BR || |