diff options
author | Michael Drake <tlsa@netsurf-browser.org> | 2015-01-27 19:01:16 +0000 |
---|---|---|
committer | Michael Drake <tlsa@netsurf-browser.org> | 2015-01-27 21:08:52 +0000 |
commit | 2007dd0ccda9ab624fdc76232589be51e973beef (patch) | |
tree | f95cd85fc26684ad09099c4d4d91054da61b041e /render/box_normalise.c | |
parent | 4c4c7225df773db8a46975a84ad13237e92503b4 (diff) | |
download | netsurf-2007dd0ccda9ab624fdc76232589be51e973beef.tar.gz netsurf-2007dd0ccda9ab624fdc76232589be51e973beef.tar.bz2 |
Revert removal of implied table adding.
Even if the DOM is always sanitised, CSS display property can cause
other boxes to be required.
Diffstat (limited to 'render/box_normalise.c')
-rw-r--r-- | render/box_normalise.c | 54 |
1 files changed, 52 insertions, 2 deletions
diff --git a/render/box_normalise.c b/render/box_normalise.c index 3e1b01468..861ad741e 100644 --- a/render/box_normalise.c +++ b/render/box_normalise.c @@ -102,6 +102,9 @@ bool box_normalise_block(struct box *block, html_content *c) { struct box *child; struct box *next_child; + struct box *table; + css_computed_style *style; + nscss_select_ctx ctx; assert(block != NULL); @@ -147,8 +150,55 @@ bool box_normalise_block(struct box *block, html_content *c) case BOX_TABLE_ROW_GROUP: case BOX_TABLE_ROW: case BOX_TABLE_CELL: - /* DOM should not have these outside a table. */ - assert(0); + /* insert implied table */ + assert(block->style != NULL); + + ctx.ctx = c->select_ctx; + ctx.quirks = (c->quirks == DOM_DOCUMENT_QUIRKS_MODE_FULL); + ctx.base_url = c->base_url; + ctx.universal = c->universal; + + style = nscss_get_blank_style(&ctx, block->style); + if (style == NULL) + return false; + + table = box_create(NULL, style, true, block->href, + block->target, NULL, NULL, c->bctx); + if (table == NULL) { + css_computed_style_destroy(style); + return false; + } + table->type = BOX_TABLE; + + if (child->prev == NULL) + block->children = table; + else + child->prev->next = table; + + table->prev = child->prev; + + while (child != NULL && ( + child->type == BOX_TABLE_ROW_GROUP || + child->type == BOX_TABLE_ROW || + child->type == BOX_TABLE_CELL)) { + box_add_child(table, child); + + next_child = child->next; + child->next = NULL; + child = next_child; + } + + table->last->next = NULL; + table->next = next_child = child; + if (table->next != NULL) + table->next->prev = table; + else + block->last = table; + table->parent = block; + + if (box_normalise_table(table, c) == false) + return false; + break; default: assert(0); } |