diff options
author | Michael Drake <tlsa@netsurf-browser.org> | 2018-01-03 16:59:58 +0000 |
---|---|---|
committer | Michael Drake <tlsa@netsurf-browser.org> | 2018-01-05 13:49:51 +0000 |
commit | 5776d3448c50d58af0eac8f3960200aa1b5fc1a0 (patch) | |
tree | 3cee8d98bad02fc012dd53a3bd6d7e45a9d606d3 /render/box_normalise.c | |
parent | d1c656b55f7c21b5fb96bf5e1bd8fedaa55c4fc2 (diff) | |
download | netsurf-5776d3448c50d58af0eac8f3960200aa1b5fc1a0.tar.gz netsurf-5776d3448c50d58af0eac8f3960200aa1b5fc1a0.tar.bz2 |
CSS computed style composition: Update for new CSS units.
Since the nscss_compute_font_size callback now needs to convert
new units to absolute values, and some of these units require info
from the root element's style, there are knock-on changes to ensure
that the required info is available where its needed.
Diffstat (limited to 'render/box_normalise.c')
-rw-r--r-- | render/box_normalise.c | 94 |
1 files changed, 68 insertions, 26 deletions
diff --git a/render/box_normalise.c b/render/box_normalise.c index 9f78f75ac..9c0875b4e 100644 --- a/render/box_normalise.c +++ b/render/box_normalise.c @@ -65,24 +65,38 @@ struct columns { }; -static bool box_normalise_table(struct box *table, html_content *c); -static bool box_normalise_table_spans(struct box *table, - struct span_info *spans, html_content *c); -static bool box_normalise_table_row_group(struct box *row_group, +static bool box_normalise_table( + struct box *table, + const struct box *root, + html_content *c); +static bool box_normalise_table_spans( + struct box *table, + const struct box *root, + struct span_info *spans, + html_content *c); +static bool box_normalise_table_row_group( + struct box *row_group, + const struct box *root, struct columns *col_info, html_content *c); -static bool box_normalise_table_row(struct box *row, +static bool box_normalise_table_row( + struct box *row, + const struct box *root, struct columns *col_info, html_content *c); static bool calculate_table_row(struct columns *col_info, unsigned int col_span, unsigned int row_span, unsigned int *start_column, struct box *cell); -static bool box_normalise_inline_container(struct box *cont, html_content *c); +static bool box_normalise_inline_container( + struct box *cont, + const struct box *root, + html_content *c); /** * Ensure the box tree is correctly nested by adding and removing nodes. * * \param block box of type BLOCK, INLINE_BLOCK, or TABLE_CELL + * \param root root box of document * \param c content of boxes * \return true on success, false on memory exhaustion * @@ -100,7 +114,10 @@ static bool box_normalise_inline_container(struct box *cont, html_content *c); * \endcode */ -bool box_normalise_block(struct box *block, html_content *c) +bool box_normalise_block( + struct box *block, + const struct box *root, + html_content *c) { struct box *child; struct box *next_child; @@ -109,6 +126,9 @@ bool box_normalise_block(struct box *block, html_content *c) nscss_select_ctx ctx; assert(block != NULL); + assert(root != NULL); + + ctx.root_style = root->style; #ifdef BOX_NORMALISE_DEBUG NSLOG(netsurf, INFO, "block %p, block->type %u", block, block->type); @@ -128,15 +148,15 @@ bool box_normalise_block(struct box *block, html_content *c) switch (child->type) { case BOX_BLOCK: /* ok */ - if (box_normalise_block(child, c) == false) + if (box_normalise_block(child, root, c) == false) return false; break; case BOX_INLINE_CONTAINER: - if (box_normalise_inline_container(child, c) == false) + if (box_normalise_inline_container(child, root, c) == false) return false; break; case BOX_TABLE: - if (box_normalise_table(child, c) == false) + if (box_normalise_table(child, root, c) == false) return false; break; case BOX_INLINE: @@ -199,7 +219,7 @@ bool box_normalise_block(struct box *block, html_content *c) block->last = table; table->parent = block; - if (box_normalise_table(table, c) == false) + if (box_normalise_table(table, root, c) == false) return false; break; default: @@ -211,7 +231,10 @@ bool box_normalise_block(struct box *block, html_content *c) } -bool box_normalise_table(struct box *table, html_content * c) +bool box_normalise_table( + struct box *table, + const struct box *root, + html_content * c) { struct box *child; struct box *next_child; @@ -223,6 +246,8 @@ bool box_normalise_table(struct box *table, html_content * c) assert(table != NULL); assert(table->type == BOX_TABLE); + ctx.root_style = root->style; + #ifdef BOX_NORMALISE_DEBUG NSLOG(netsurf, INFO, "table %p", table); #endif @@ -243,7 +268,7 @@ bool box_normalise_table(struct box *table, html_content * c) switch (child->type) { case BOX_TABLE_ROW_GROUP: /* ok */ - if (box_normalise_table_row_group(child, + if (box_normalise_table_row_group(child, root, &col_info, c) == false) { free(col_info.spans); return false; @@ -308,7 +333,7 @@ bool box_normalise_table(struct box *table, html_content * c) table->last = row_group; row_group->parent = table; - if (box_normalise_table_row_group(row_group, + if (box_normalise_table_row_group(row_group, root, &col_info, c) == false) { free(col_info.spans); return false; @@ -390,7 +415,7 @@ bool box_normalise_table(struct box *table, html_content * c) table->rows = 1; } - if (box_normalise_table_spans(table, col_info.spans, c) == false) { + if (box_normalise_table_spans(table, root, col_info.spans, c) == false) { free(col_info.spans); return false; } @@ -413,12 +438,16 @@ bool box_normalise_table(struct box *table, html_content * c) * Additionally, generate empty cells. * * \param table Table to process + * \param root root box of document * \param spans Array of length table->columns for use in empty cell detection * \param c Content containing table * \return True on success, false on memory exhaustion. */ -bool box_normalise_table_spans(struct box *table, struct span_info *spans, +bool box_normalise_table_spans( + struct box *table, + const struct box *root, + struct span_info *spans, html_content *c) { struct box *table_row_group; @@ -429,6 +458,8 @@ bool box_normalise_table_spans(struct box *table, struct span_info *spans, unsigned int col; nscss_select_ctx ctx; + ctx.root_style = root->style; + /* Clear span data */ memset(spans, 0, table->columns * sizeof(struct span_info)); @@ -572,7 +603,9 @@ bool box_normalise_table_spans(struct box *table, struct span_info *spans, } -bool box_normalise_table_row_group(struct box *row_group, +bool box_normalise_table_row_group( + struct box *row_group, + const struct box *root, struct columns *col_info, html_content * c) { @@ -586,6 +619,8 @@ bool box_normalise_table_row_group(struct box *row_group, assert(row_group != 0); assert(row_group->type == BOX_TABLE_ROW_GROUP); + ctx.root_style = root->style; + #ifdef BOX_NORMALISE_DEBUG NSLOG(netsurf, INFO, "row_group %p", row_group); #endif @@ -597,7 +632,7 @@ bool box_normalise_table_row_group(struct box *row_group, case BOX_TABLE_ROW: /* ok */ group_row_count++; - if (box_normalise_table_row(child, col_info, + if (box_normalise_table_row(child, root, col_info, c) == false) return false; break; @@ -657,7 +692,7 @@ bool box_normalise_table_row_group(struct box *row_group, row->parent = row_group; group_row_count++; - if (box_normalise_table_row(row, col_info, + if (box_normalise_table_row(row, root, col_info, c) == false) return false; break; @@ -722,7 +757,9 @@ bool box_normalise_table_row_group(struct box *row_group, } -bool box_normalise_table_row(struct box *row, +bool box_normalise_table_row( + struct box *row, + const struct box *root, struct columns *col_info, html_content * c) { @@ -736,6 +773,8 @@ bool box_normalise_table_row(struct box *row, assert(row != NULL); assert(row->type == BOX_TABLE_ROW); + ctx.root_style = root->style; + #ifdef BOX_NORMALISE_DEBUG NSLOG(netsurf, INFO, "row %p", row); #endif @@ -746,7 +785,7 @@ bool box_normalise_table_row(struct box *row, switch (child->type) { case BOX_TABLE_CELL: /* ok */ - if (box_normalise_block(child, c) == false) + if (box_normalise_block(child, root, c) == false) return false; cell = child; break; @@ -805,7 +844,7 @@ bool box_normalise_table_row(struct box *row, row->last = cell; cell->parent = row; - if (box_normalise_block(cell, c) == false) + if (box_normalise_block(cell, root, c) == false) return false; break; case BOX_INLINE: @@ -928,7 +967,10 @@ bool calculate_table_row(struct columns *col_info, } -bool box_normalise_inline_container(struct box *cont, html_content * c) +bool box_normalise_inline_container( + struct box *cont, + const struct box *root, + html_content * c) { struct box *child; struct box *next_child; @@ -951,7 +993,7 @@ bool box_normalise_inline_container(struct box *cont, html_content * c) break; case BOX_INLINE_BLOCK: /* ok */ - if (box_normalise_block(child, c) == false) + if (box_normalise_block(child, root, c) == false) return false; break; case BOX_FLOAT_LEFT: @@ -961,12 +1003,12 @@ bool box_normalise_inline_container(struct box *cont, html_content * c) switch (child->children->type) { case BOX_BLOCK: - if (box_normalise_block(child->children, + if (box_normalise_block(child->children, root, c) == false) return false; break; case BOX_TABLE: - if (box_normalise_table(child->children, + if (box_normalise_table(child->children, root, c) == false) return false; break; |