NetSurf
Data Structures | Functions
table.c File Reference

implementation of HTML table processing and layout. More...

#include <assert.h>
#include <dom/dom.h>
#include "utils/log.h"
#include "utils/utils.h"
#include "utils/talloc.h"
#include "css/utils.h"
#include "html/box.h"
#include "html/table.h"
Include dependency graph for table.c:

Go to the source code of this file.

Data Structures

struct  border
 Container for border values during table border calculations. More...
 

Functions

static bool table_border_is_more_eyecatching (const css_unit_ctx *unit_len_ctx, const struct border *a, box_type a_src, const struct border *b, box_type b_src)
 Determine if a border style is more eyecatching than another. More...
 
static void table_cell_top_process_table (const css_unit_ctx *unit_len_ctx, struct box *table, struct border *a, box_type *a_src)
 Process a table. More...
 
static bool table_cell_top_process_row (const css_unit_ctx *unit_len_ctx, struct box *cell, struct box *row, struct border *a, box_type *a_src)
 Process a row. More...
 
static bool table_cell_top_process_group (const css_unit_ctx *unit_len_ctx, struct box *cell, struct box *group, struct border *a, box_type *a_src)
 Process a group. More...
 
static void table_used_left_border_for_cell (const css_unit_ctx *unit_len_ctx, struct box *cell)
 Calculate used values of border-left-{style,color,width}. More...
 
static void table_used_top_border_for_cell (const css_unit_ctx *unit_len_ctx, struct box *cell)
 Calculate used values of border-top-{style,color,width}. More...
 
static void table_used_right_border_for_cell (const css_unit_ctx *unit_len_ctx, struct box *cell)
 Calculate used values of border-right-{style,color,width}. More...
 
static void table_used_bottom_border_for_cell (const css_unit_ctx *unit_len_ctx, struct box *cell)
 Calculate used values of border-bottom-{style,color,width}. More...
 
bool table_calculate_column_types (const css_unit_ctx *unit_len_ctx, struct box *table)
 Determine the column width types for a table. More...
 
void table_used_border_for_cell (const css_unit_ctx *unit_len_ctx, struct box *cell)
 Calculate used values of border-{trbl}-{style,color,width} for table cells. More...
 

Detailed Description

implementation of HTML table processing and layout.

Definition in file table.c.

Function Documentation

◆ table_border_is_more_eyecatching()

static bool table_border_is_more_eyecatching ( const css_unit_ctx *  unit_len_ctx,
const struct border a,
box_type  a_src,
const struct border b,
box_type  b_src 
)
static

Determine if a border style is more eyecatching than another.

Parameters
unit_len_ctxLength conversion context
aReference border style
a_srcSource of a
bCandidate border style
b_srcSource of b
Returns
True if b is more eyecatching than a
Todo:
COL/COL_GROUP
Todo:
COL/COL_GROUP
Todo:
Currently assumes b satisifies this

Definition at line 62 of file table.c.

References BOX_TABLE, BOX_TABLE_CELL, BOX_TABLE_ROW, BOX_TABLE_ROW_GROUP, fallthrough, border::style, border::unit, and border::width.

Referenced by table_cell_top_process_group(), table_cell_top_process_row(), table_cell_top_process_table(), table_used_bottom_border_for_cell(), table_used_left_border_for_cell(), table_used_right_border_for_cell(), and table_used_top_border_for_cell().

Here is the caller graph for this function:

◆ table_calculate_column_types()

bool table_calculate_column_types ( const css_unit_ctx *  unit_len_ctx,
struct box table 
)

Determine the column width types for a table.

Parameters
unit_len_ctxLength conversion context
tablebox of type BOX_TABLE
Returns
true on success, false on memory exhaustion

The table->col array is allocated and type and width are filled in for each column.

Definition at line 813 of file table.c.

References BOX_TABLE_CELL, box::children, box::col, box::columns, box::next, NSLOG, column::positioned, box::start_column, box::style, talloc_array, column::type, box::type, type, column::width, and width.

Referenced by layout_minmax_table().

Here is the caller graph for this function:

◆ table_cell_top_process_group()

static bool table_cell_top_process_group ( const css_unit_ctx *  unit_len_ctx,
struct box cell,
struct box group,
struct border a,
box_type a_src 
)
static

Process a group.

Parameters
unit_len_ctxLength conversion context
cellCell being considered
groupGroup to process
aCurrent border style for cell
a_srcSource of a
Returns
true if group has non-empty rows, false otherwise
Postcondition
a will be updated with most eyecatching style
a_src will be updated also

Definition at line 322 of file table.c.

References BOX_TABLE_ROW_GROUP, border::c, border::color, box::last, box::prev, box::style, border::style, table_border_is_more_eyecatching(), table_cell_top_process_row(), border::unit, and border::width.

Referenced by table_used_top_border_for_cell().

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

◆ table_cell_top_process_row()

static bool table_cell_top_process_row ( const css_unit_ctx *  unit_len_ctx,
struct box cell,
struct box row,
struct border a,
box_type a_src 
)
static

Process a row.

Parameters
unit_len_ctxLength conversion context
cellCell being considered
rowRow to process
aCurrent border style for cell
a_srcSource of a
Returns
true if row has cells, false otherwise
Postcondition
a will be updated with most eyecatching style
a_src will be updated also

Definition at line 211 of file table.c.

References BOX_TABLE_CELL, BOX_TABLE_ROW, border::c, box::children, border::color, box::columns, box::next, box::prev, box::start_column, box::style, border::style, table_border_is_more_eyecatching(), border::unit, and border::width.

Referenced by table_cell_top_process_group(), and table_used_top_border_for_cell().

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

◆ table_cell_top_process_table()

static void table_cell_top_process_table ( const css_unit_ctx *  unit_len_ctx,
struct box table,
struct border a,
box_type a_src 
)
static

Process a table.

Parameters
unit_len_ctxLength conversion context
tableTable to process
aCurrent border style for cell
a_srcSource of a
Postcondition
a will be updated with most eyecatching style
a_src will be updated also

Definition at line 173 of file table.c.

References BOX_TABLE, border::c, border::color, box::style, border::style, table_border_is_more_eyecatching(), border::unit, and border::width.

Referenced by table_used_top_border_for_cell().

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

◆ table_used_border_for_cell()

void table_used_border_for_cell ( const css_unit_ctx *  unit_len_ctx,
struct box cell 
)

Calculate used values of border-{trbl}-{style,color,width} for table cells.

Parameters
unit_len_ctxLength conversion context
cellTable cell to consider
Postcondition
cell's border array is populated

Definition at line 988 of file table.c.

References box::border, BOTTOM, BOX_TABLE_CELL, box_border::c, LEFT, RIGHT, box_border::style, box::style, table_used_bottom_border_for_cell(), table_used_left_border_for_cell(), table_used_right_border_for_cell(), table_used_top_border_for_cell(), TOP, box::type, box_border::width, and width.

Referenced by layout_table().

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

◆ table_used_bottom_border_for_cell()

static void table_used_bottom_border_for_cell ( const css_unit_ctx *  unit_len_ctx,
struct box cell 
)
static

Calculate used values of border-bottom-{style,color,width}.

Parameters
unit_len_ctxLength conversion context
cellTable cell to consider
Todo:
Can cells span row groups?

Definition at line 723 of file table.c.

References box::border, BOTTOM, BOX_TABLE, BOX_TABLE_CELL, BOX_TABLE_ROW, BOX_TABLE_ROW_GROUP, box_border::c, border::c, border::color, box::next, box::parent, box::rows, box_border::style, box::style, border::style, table_border_is_more_eyecatching(), border::unit, box_border::width, and border::width.

Referenced by table_used_border_for_cell().

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

◆ table_used_left_border_for_cell()

static void table_used_left_border_for_cell ( const css_unit_ctx *  unit_len_ctx,
struct box cell 
)
static

Calculate used values of border-left-{style,color,width}.

Parameters
unit_len_ctxLength conversion context
cellTable cell to consider
Todo:
Need column and column_group, too
Todo:
can cells span row groups?

Definition at line 387 of file table.c.

References box::border, BOX_TABLE, BOX_TABLE_CELL, BOX_TABLE_ROW, BOX_TABLE_ROW_GROUP, box_border::c, border::c, box::children, border::color, box::columns, LEFT, box::next, box::parent, box::prev, box::rows, box::start_column, box_border::style, box::style, border::style, table_border_is_more_eyecatching(), border::unit, box_border::width, and border::width.

Referenced by table_used_border_for_cell().

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

◆ table_used_right_border_for_cell()

static void table_used_right_border_for_cell ( const css_unit_ctx *  unit_len_ctx,
struct box cell 
)
static

Calculate used values of border-right-{style,color,width}.

Parameters
unit_len_ctxLength conversion context
cellTable cell to consider
Todo:
Need column and column_group, too
Todo:
can cells span row groups?

Definition at line 619 of file table.c.

References box::border, BOX_TABLE, BOX_TABLE_CELL, BOX_TABLE_ROW, BOX_TABLE_ROW_GROUP, box_border::c, border::c, border::color, box::columns, box::next, box::parent, RIGHT, box::rows, box::start_column, box_border::style, box::style, border::style, table_border_is_more_eyecatching(), border::unit, box_border::width, and border::width.

Referenced by table_used_border_for_cell().

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

◆ table_used_top_border_for_cell()

static void table_used_top_border_for_cell ( const css_unit_ctx *  unit_len_ctx,
struct box cell 
)
static

Calculate used values of border-top-{style,color,width}.

Parameters
unit_len_ctxLength conversion context
cellTable cell to consider

Definition at line 519 of file table.c.

References box::border, BOX_TABLE_CELL, BOX_TABLE_ROW, BOX_TABLE_ROW_GROUP, box_border::c, border::c, border::color, box::parent, box::prev, box_border::style, box::style, border::style, table_border_is_more_eyecatching(), table_cell_top_process_group(), table_cell_top_process_row(), table_cell_top_process_table(), TOP, border::unit, box_border::width, and border::width.

Referenced by table_used_border_for_cell().

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