make boxes keep reference to the DOM node that causes them

This commit is contained in:
Vincent Sanders 2012-11-30 12:29:54 +00:00
parent 61872ab3a4
commit 31c9ffb4b5
3 changed files with 14 additions and 3 deletions

View File

@ -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;
}

View File

@ -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. */

View File

@ -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 ||