NetSurf
Data Structures | Functions
box_normalise.c File Reference

Box tree normalisation implementation. More...

#include <assert.h>
#include <stdbool.h>
#include <string.h>
#include "utils/log.h"
#include "utils/errors.h"
#include "css/select.h"
#include "html/private.h"
#include "html/table.h"
#include "html/box.h"
#include "html/box_manipulate.h"
#include "html/box_normalise.h"
Include dependency graph for box_normalise.c:

Go to the source code of this file.

Data Structures

struct  span_info
 Row spanning information for a cell. More...
 
struct  columns
 Column record for a table. More...
 

Functions

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. More...
 
static bool box_normalise_table_row (struct box *row, const struct box *root, struct columns *col_info, 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_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. More...
 
static bool box_normalise_table (struct box *table, const struct box *root, html_content *c)
 
static bool box_normalise_flex (struct box *flex_container, const struct box *root, html_content *c)
 
static bool box_normalise_inline_container (struct box *cont, const struct box *root, html_content *c)
 
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. More...
 

Detailed Description

Box tree normalisation implementation.

Definition in file box_normalise.c.

Function Documentation

◆ box_normalise_block()

bool box_normalise_block ( struct box block,
const struct box root,
struct html_content c 
)

Ensure the box tree is correctly nested by adding and removing nodes.

Parameters
blockbox of type BLOCK, INLINE_BLOCK, or TABLE_CELL
rootroot box of document
ccontent of boxes
Returns
true on success, false on memory exhaustion

The tree is modified to satisfy the following:

parent permitted child nodes
BLOCK, INLINE_BLOCK BLOCK, INLINE_CONTAINER, TABLE, FLEX
FLEX, INLINE_FLEX BLOCK, INLINE_CONTAINER, TABLE, FLEX
INLINE_CONTAINER INLINE, INLINE_BLOCK, FLOAT_LEFT, FLOAT_RIGHT, BR, TEXT, INLINE_FLEX
INLINE, TEXT none
TABLE at least 1 TABLE_ROW_GROUP
TABLE_ROW_GROUP at least 1 TABLE_ROW
TABLE_ROW at least 1 TABLE_CELL
TABLE_CELL BLOCK, INLINE_CONTAINER, TABLE, FLEX (same as BLOCK)
FLOAT_(LEFT|RIGHT) exactly 1 BLOCK, TABLE or FLEX
@ LEFT
Definition: box.h:98
@ RIGHT
Definition: box.h:98
wimp_w parent
Definition: dialog.c:88

Definition at line 1088 of file box_normalise.c.

References nscss_select_ctx::base_url, html_content::base_url, html_content::bctx, box_add_child(), BOX_BLOCK, BOX_BR, box_create(), BOX_FLEX, BOX_FLOAT_LEFT, BOX_FLOAT_RIGHT, BOX_INLINE, BOX_INLINE_BLOCK, BOX_INLINE_CONTAINER, BOX_INLINE_END, BOX_INLINE_FLEX, box_normalise_block(), box_normalise_flex(), box_normalise_inline_container(), box_normalise_table(), BOX_TABLE, BOX_TABLE_CELL, BOX_TABLE_ROW, BOX_TABLE_ROW_GROUP, BOX_TEXT, box::children, nscss_select_ctx::ctx, box::href, box::last, box::next, nscss_get_blank_style(), NSLOG, box::parent, box::prev, nscss_select_ctx::quirks, html_content::quirks, root, nscss_select_ctx::root_style, html_content::select_ctx, box::style, box::target, box::type, html_content::unit_len_ctx, nscss_select_ctx::universal, and html_content::universal.

Referenced by box_normalise_block(), box_normalise_flex(), box_normalise_inline_container(), box_normalise_table_row(), and convert_xml_to_box().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ box_normalise_flex()

static bool box_normalise_flex ( struct box flex_container,
const struct box root,
html_content c 
)
static

◆ box_normalise_inline_container()

static bool box_normalise_inline_container ( struct box cont,
const struct box root,
html_content c 
)
static

Definition at line 995 of file box_normalise.c.

References BOX_BLOCK, BOX_BR, BOX_FLEX, BOX_FLOAT_LEFT, BOX_FLOAT_RIGHT, box_free(), BOX_INLINE, BOX_INLINE_BLOCK, BOX_INLINE_CONTAINER, BOX_INLINE_END, BOX_INLINE_FLEX, box_normalise_block(), box_normalise_flex(), box_normalise_table(), BOX_TABLE, BOX_TABLE_CELL, BOX_TABLE_ROW, BOX_TABLE_ROW_GROUP, BOX_TEXT, box::children, box::last, box::next, NSLOG, box::parent, box::prev, root, and box::type.

Referenced by box_normalise_block().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ box_normalise_table()

static bool box_normalise_table ( struct box table,
const struct box root,
html_content c 
)
static

◆ box_normalise_table_row()

static bool box_normalise_table_row ( struct box row,
const struct box root,
struct columns col_info,
html_content c 
)
static

◆ box_normalise_table_row_group()

static bool box_normalise_table_row_group ( struct box row_group,
const struct box root,
struct columns col_info,
html_content c 
)
static

◆ box_normalise_table_spans()

static bool box_normalise_table_spans ( struct box table,
const struct box root,
struct span_info spans,
html_content c 
)
static

Normalise table cell column/row counts for colspan/rowspan = 0.

Additionally, generate empty cells.

Parameters
tableTable to process
rootroot box of document
spansArray of length table->columns for use in empty cell detection
cContent containing table
Returns
True on success, false on memory exhaustion.

Definition at line 457 of file box_normalise.c.

References nscss_select_ctx::base_url, html_content::base_url, html_content::bctx, box_create(), BOX_TABLE_CELL, box::children, box::col, box::columns, nscss_select_ctx::ctx, box::href, box::last, box::next, nscss_get_blank_style(), box::parent, box::prev, nscss_select_ctx::quirks, html_content::quirks, root, nscss_select_ctx::root_style, span_info::row_span, box::rows, html_content::select_ctx, box::start_column, box::style, box::target, box::type, html_content::unit_len_ctx, nscss_select_ctx::universal, and html_content::universal.

Referenced by box_normalise_table().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ calculate_table_row()

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

Compute the column index at which the current cell begins.

Additionally, update the column record to reflect row spanning.

Parameters
col_infoColumn record
col_spanNumber of columns that current cell spans
row_spanNumber of rows that current cell spans
start_columnPointer to location to receive column index
cellBox for current table cell
Returns
true on success, false on memory exhaustion

Definition at line 83 of file box_normalise.c.

References span_info::auto_row, columns::current_column, columns::num_columns, box::parent, span_info::rg, span_info::row_span, columns::spans, and box::start_column.

Referenced by box_normalise_table_row().

Here is the caller graph for this function: