42#undef BOX_NORMALISE_DEBUG
84 unsigned int col_span,
86 unsigned int *start_column,
90 unsigned int cell_end_col;
99 col_info->
spans[cell_start_col].
rg == rg) {
111 cell_end_col = cell_start_col + col_span;
117 spans = realloc(col_info->
spans,
118 sizeof *spans * (cell_end_col + 1));
122 col_info->
spans = spans;
133 for (i = cell_start_col; i < cell_end_col; i++) {
134 col_info->
spans[i].
row_span = (row_span == 0) ? 1 : row_span;
155 struct box *next_child;
156 struct box *cell = NULL;
157 css_computed_style *
style;
166#ifdef BOX_NORMALISE_DEBUG
167 NSLOG(netsurf, INFO,
"row %p", row);
170 for (child = row->
children; child != NULL; child = next_child) {
171 next_child = child->
next;
173 switch (child->
type) {
187 assert(row->
style != NULL);
190 ctx.
quirks = (c->
quirks == DOM_DOCUMENT_QUIRKS_MODE_FULL);
202 css_computed_style_destroy(
style);
207 if (child->
prev == NULL)
214 while (child != NULL && (
223 next_child = child->
next;
228 assert(cell->
last != NULL);
231 cell->
next = next_child = child;
232 if (cell->
next != NULL)
279#ifdef BOX_NORMALISE_DEBUG
280 NSLOG(netsurf, INFO,
"row %p done", row);
294 struct box *next_child;
296 css_computed_style *
style;
298 unsigned int group_row_count = 0;
300 assert(row_group != 0);
305#ifdef BOX_NORMALISE_DEBUG
306 NSLOG(netsurf, INFO,
"row_group %p", row_group);
309 for (child = row_group->
children; child != NULL; child = next_child) {
310 next_child = child->
next;
312 switch (child->
type) {
327 assert(row_group->
style != NULL);
330 ctx.
quirks = (c->
quirks == DOM_DOCUMENT_QUIRKS_MODE_FULL);
342 css_computed_style_destroy(
style);
347 if (child->
prev == NULL)
354 while (child != NULL && (
363 next_child = child->
next;
368 assert(row->
last != NULL);
371 row->
next = next_child = child;
372 if (row->
next != NULL)
375 row_group->
last = row;
401#ifdef BOX_NORMALISE_DEBUG
403 "row_group->children == 0, inserting implied row");
406 assert(row_group->
style != NULL);
409 ctx.
quirks = (c->
quirks == DOM_DOCUMENT_QUIRKS_MODE_FULL);
422 css_computed_style_destroy(
style);
436 row_group->
rows = group_row_count;
438#ifdef BOX_NORMALISE_DEBUG
439 NSLOG(netsurf, INFO,
"row_group %p done", row_group);
462 struct box *table_row_group;
463 struct box *table_row;
464 struct box *table_cell;
465 unsigned int rows_left = table->
rows;
466 unsigned int group_rows_left;
477 for (table_row_group = table->
children;
478 table_row_group != NULL;
479 table_row_group = table_row_group->
next) {
481 group_rows_left = table_row_group->
rows;
483 for (table_row = table_row_group->
children;
485 table_row = table_row->
next) {
487 for (table_cell = table_row->
children;
489 table_cell = table_cell->
next) {
492 if (table_cell->
columns == 0) {
500 if (table_cell->
rows == 0) {
501 table_cell->
rows = group_rows_left;
505 if (table_cell->
rows > group_rows_left) {
506 table_cell->
rows = group_rows_left;
519 if (spans[
col].row_span == 0) {
520 unsigned int start =
col;
521 css_computed_style *
style;
529 assert(table_row->
style != NULL);
533 spans[
col].row_span ==
540 DOM_DOCUMENT_QUIRKS_MODE_FULL);
553 NULL, NULL, c->
bctx);
555 css_computed_style_destroy(
583 table_row->
last = cell;
592 table_row->
last = cell;
604 assert(rows_left > 0);
620 struct box *next_child;
621 struct box *row_group;
622 css_computed_style *
style;
626 assert(table != NULL);
629 ctx.root_style =
root->style;
631#ifdef BOX_NORMALISE_DEBUG
632 NSLOG(netsurf, INFO,
"table %p", table);
637 col_info.
spans = malloc(2 *
sizeof *col_info.
spans);
638 if (col_info.
spans == NULL)
646 for (child = table->
children; child != NULL; child = next_child) {
647 next_child = child->
next;
648 switch (child->
type) {
652 &col_info, c) ==
false) {
653 free(col_info.
spans);
664 assert(table->
style != NULL);
667 ctx.quirks = (c->
quirks == DOM_DOCUMENT_QUIRKS_MODE_FULL);
674 free(col_info.
spans);
680 if (row_group == NULL) {
681 css_computed_style_destroy(style);
682 free(col_info.
spans);
688 if (child->
prev == NULL)
695 while (child != NULL && (
704 next_child = child->
next;
709 assert(row_group->
last != NULL);
712 row_group->
next = next_child = child;
713 if (row_group->
next != NULL)
716 table->
last = row_group;
717 row_group->
parent = table;
720 &col_info, c) ==
false) {
721 free(col_info.
spans);
738 fprintf(stderr,
"%i\n", child->
type);
749#ifdef BOX_NORMALISE_DEBUG
751 "table->children == 0, creating implied row");
754 assert(table->
style != NULL);
757 ctx.quirks = (c->
quirks == DOM_DOCUMENT_QUIRKS_MODE_FULL);
764 free(col_info.
spans);
770 if (row_group == NULL) {
771 css_computed_style_destroy(
style);
772 free(col_info.
spans);
781 free(col_info.
spans);
788 css_computed_style_destroy(
style);
790 free(col_info.
spans);
798 row_group->
parent = table;
805 free(col_info.
spans);
809 free(col_info.
spans);
811#ifdef BOX_NORMALISE_DEBUG
812 NSLOG(netsurf, INFO,
"table %p done", table);
819 struct box *flex_container,
824 struct box *next_child;
825 struct box *implied_flex_item;
826 css_computed_style *
style;
829 assert(flex_container != NULL);
830 assert(
root != NULL);
834#ifdef BOX_NORMALISE_DEBUG
835 NSLOG(netsurf, INFO,
"flex_container %p, flex_container->type %u",
836 flex_container, flex_container->
type);
842 for (child = flex_container->
children; child != NULL; child = next_child) {
843#ifdef BOX_NORMALISE_DEBUG
844 NSLOG(netsurf, INFO,
"child %p, child->type = %d",
848 next_child = child->
next;
850 switch (child->
type) {
863 assert(flex_container->
style != NULL);
866 ctx.
quirks = (c->
quirks == DOM_DOCUMENT_QUIRKS_MODE_FULL);
871 flex_container->
style);
876 flex_container->
href,
878 NULL, NULL, c->
bctx);
879 if (implied_flex_item == NULL) {
880 css_computed_style_destroy(
style);
885 if (child->
prev == NULL)
886 flex_container->
children = implied_flex_item;
888 child->
prev->
next = implied_flex_item;
890 implied_flex_item->
prev = child->
prev;
892 while (child != NULL &&
896 next_child = child->
next;
901 implied_flex_item->
last->
next = NULL;
902 implied_flex_item->
next = next_child = child;
903 if (implied_flex_item->
next != NULL)
904 implied_flex_item->
next->
prev = implied_flex_item;
906 flex_container->
last = implied_flex_item;
907 implied_flex_item->
parent = flex_container;
934 assert(flex_container->
style != NULL);
937 ctx.
quirks = (c->
quirks == DOM_DOCUMENT_QUIRKS_MODE_FULL);
942 flex_container->
style);
947 flex_container->
href,
949 NULL, NULL, c->
bctx);
950 if (implied_flex_item == NULL) {
951 css_computed_style_destroy(
style);
956 if (child->
prev == NULL)
957 flex_container->
children = implied_flex_item;
959 child->
prev->
next = implied_flex_item;
961 implied_flex_item->
prev = child->
prev;
963 while (child != NULL && (
969 next_child = child->
next;
974 implied_flex_item->
last->
next = NULL;
975 implied_flex_item->
next = next_child = child;
976 if (implied_flex_item->
next != NULL)
977 implied_flex_item->
next->
prev = implied_flex_item;
979 flex_container->
last = implied_flex_item;
980 implied_flex_item->
parent = flex_container;
1000 struct box *next_child;
1002 assert(cont != NULL);
1005#ifdef BOX_NORMALISE_DEBUG
1006 NSLOG(netsurf, INFO,
"cont %p", cont);
1009 for (child = cont->
children; child != NULL; child = next_child) {
1010 next_child = child->
next;
1011 switch (child->
type) {
1055 if (child->
prev == NULL)
1059 if (child->
next != NULL)
1079#ifdef BOX_NORMALISE_DEBUG
1080 NSLOG(netsurf, INFO,
"cont %p done", cont);
1091 struct box *next_child;
1093 css_computed_style *
style;
1096 assert(block != NULL);
1097 assert(
root != NULL);
1101#ifdef BOX_NORMALISE_DEBUG
1102 NSLOG(netsurf, INFO,
"block %p, block->type %u", block, block->
type);
1108 for (child = block->
children; child != NULL; child = next_child) {
1109#ifdef BOX_NORMALISE_DEBUG
1110 NSLOG(netsurf, INFO,
"child %p, child->type = %d", child,
1114 next_child = child->
next;
1116 switch (child->
type) {
1151 assert(block->
style != NULL);
1154 ctx.
quirks = (c->
quirks == DOM_DOCUMENT_QUIRKS_MODE_FULL);
1165 if (table == NULL) {
1166 css_computed_style_destroy(
style);
1171 if (child->
prev == NULL)
1178 while (child != NULL && (
1184 next_child = child->
next;
1190 table->
next = next_child = child;
1191 if (table->
next != NULL)
1194 block->
last = table;
struct box * box_create(css_select_results *styles, css_computed_style *style, bool style_owned, nsurl *href, const char *target, const char *title, lwc_string *id, void *context)
Create a box tree node.
void box_free(struct box *box)
Free a box tree recursively.
void box_add_child(struct box *parent, struct box *child)
Add a child to a box tree node.
Box tree manipulation interface.
static bool box_normalise_flex(struct box *flex_container, const struct box *root, html_content *c)
static bool box_normalise_table(struct box *table, const struct box *root, html_content *c)
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)
Compute the column index at which the current cell begins.
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_spans(struct box *table, const struct box *root, struct span_info *spans, html_content *c)
Normalise table cell column/row counts for colspan/rowspan = 0.
bool box_normalise_block(struct box *block, const struct box *root, html_content *c)
Ensure the box tree is correctly nested by adding and removing nodes.
static bool box_normalise_inline_container(struct box *cont, const struct box *root, html_content *c)
HTML Box tree normalise interface.
static struct directory * root
#define NSLOG(catname, level, logmsg, args...)
Private data for text/html content.
css_computed_style * nscss_get_blank_style(nscss_select_ctx *ctx, const css_unit_ctx *unit_len_ctx, const css_computed_style *parent)
Get a blank style.
Interface to utility string handling.
struct box * parent
Parent box, or NULL.
struct column * col
Array of table column data for TABLE only.
struct box * children
First child box, or NULL.
struct box * prev
Previous sibling box, or NULL.
const char * target
Link target, or NULL.
struct box * last
Last child box, or NULL.
struct box * next
Next sibling box, or NULL.
unsigned int start_column
Start column for TABLE_CELL only.
box_type type
Type of box.
struct nsurl * href
Link, or NULL.
css_computed_style * style
Style for this box.
unsigned int rows
Number of rows for TABLE only.
unsigned int columns
Number of columns for TABLE / TABLE_CELL.
Column record for a table.
unsigned int num_columns
Number of columns in main part of table 1..max columns.
unsigned int num_rows
Number of rows in table.
unsigned int current_column
Current column index.
struct span_info * spans
Information about columns in main table, array [0, num_columns)
Data specific to CONTENT_HTML.
dom_document_quirks_mode quirks
Quirkyness of document.
int * bctx
A talloc context purely for the render box tree.
struct nsurl * base_url
Base URL (may be a copy of content->url).
css_select_ctx * select_ctx
Style selection media specification.
css_unit_ctx unit_len_ctx
CSS length conversion context for document.
const css_computed_style * root_style
Row spanning information for a cell.
unsigned int row_span
Number of rows this cell spans.
bool auto_row
The cell in this column spans all rows until the end of the table.
struct box * rg
Row group of cell.
Interface to HTML table processing and layout.