NetSurf
Macros | Typedefs | Functions | Variables
layout_internal.h File Reference

HTML layout private interface. More...

This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Macros

#define AUTO   INT_MIN
 
#define FPCT_OF_INT_TOINT(a, b)   (FIXTOINT(FDIV((a * b), F_100)))
 

Typedefs

typedef uint8_t(* css_len_func) (const css_computed_style *style, css_fixed *length, css_unit *unit)
 
typedef uint8_t(* css_border_style_func) (const css_computed_style *style)
 
typedef uint8_t(* css_border_color_func) (const css_computed_style *style, css_color *color)
 

Functions

bool layout_block_context (struct box *block, int viewport_height, html_content *content)
 Layout a block formatting context. More...
 
bool layout_table (struct box *table, int available_width, html_content *content)
 Layout a table. More...
 
bool layout_flex (struct box *flex, int available_width, html_content *content)
 Layout a flex container. More...
 
static bool lh__box_is_float_box (const struct box *b)
 Layout helper: Check whether box is a float. More...
 
static bool lh__box_is_inline_flow (const struct box *b)
 Layout helper: Check whether box takes part in inline flow. More...
 
static bool lh__box_is_flex_container (const struct box *b)
 Layout helper: Check whether box takes part in inline flow. More...
 
static bool lh__box_is_flex_item (const struct box *b)
 Layout helper: Check whether box takes part in inline flow. More...
 
static bool lh__box_is_inline_level (const struct box *b)
 Layout helper: Check whether box is inline level. More...
 
static bool lh__box_is_inline_content (const struct box *b)
 Layout helper: Check whether box is inline level. More...
 
static bool lh__box_is_object (const struct box *b)
 Layout helper: Check whether box is an object. More...
 
static bool lh__box_is_replace (const struct box *b)
 Layout helper: Check whether box is replaced. More...
 
static bool lh__have_border (enum box_side side, const css_computed_style *style)
 Layout helper: Check for CSS border on given side. More...
 
static bool lh__box_is_absolute (const struct box *b)
 
static bool lh__flex_main_is_horizontal (const struct box *flex)
 
static bool lh__flex_direction_reversed (const struct box *flex)
 
static int lh__non_auto_margin (const struct box *b, enum box_side side)
 
static int lh__delta_outer_height (const struct box *b)
 
static int lh__delta_outer_width (const struct box *b)
 
static int lh__delta_outer_main (const struct box *flex, const struct box *b)
 
static int lh__delta_outer_cross (const struct box *flex, const struct box *b)
 
static int * lh__box_size_main_ptr (bool horizontal, struct box *b)
 
static int * lh__box_size_cross_ptr (bool horizontal, struct box *b)
 
static int lh__box_size_main (bool horizontal, const struct box *b)
 
static int lh__box_size_cross (bool horizontal, const struct box *b)
 
static bool lh__box_size_cross_is_auto (bool horizontal, struct box *b)
 
static enum css_align_self_e lh__box_align_self (const struct box *flex, const struct box *item)
 
static void calculate_mbp_width (const css_unit_ctx *unit_len_ctx, const css_computed_style *style, unsigned int side, bool margin, bool border, bool padding, int *fixed, float *frac)
 Determine width of margin, borders, and padding on one side of a box. More...
 
static void layout_handle_box_sizing (const css_unit_ctx *unit_len_ctx, const struct box *box, int available_width, bool setwidth, int *dimension)
 Adjust a specified width or height for the box-sizing property. More...
 
static void layout_find_dimensions (const css_unit_ctx *unit_len_ctx, int available_width, int viewport_height, const struct box *box, const css_computed_style *style, int *width, int *height, int *max_width, int *min_width, int *max_height, int *min_height, int margin[4], int padding[4], struct box_border border[4])
 Calculate width, height, and thickness of margins, paddings, and borders. More...
 

Variables

const css_len_func margin_funcs [4]
 Array of per-side access functions for computed style margins. More...
 
const css_len_func padding_funcs [4]
 Array of per-side access functions for computed style paddings. More...
 
const css_len_func border_width_funcs [4]
 Array of per-side access functions for computed style border_widths. More...
 
const css_border_style_func border_style_funcs [4]
 Array of per-side access functions for computed style border styles. More...
 
const css_border_color_func border_color_funcs [4]
 Array of per-side access functions for computed style border colors. More...
 

Detailed Description

HTML layout private interface.

Definition in file layout_internal.h.

Macro Definition Documentation

◆ AUTO

#define AUTO   INT_MIN

Definition at line 27 of file layout_internal.h.

◆ FPCT_OF_INT_TOINT

#define FPCT_OF_INT_TOINT (   a,
 
)    (FIXTOINT(FDIV((a * b), F_100)))

Definition at line 30 of file layout_internal.h.

Typedef Documentation

◆ css_border_color_func

typedef uint8_t(* css_border_color_func) (const css_computed_style *style, css_color *color)

Definition at line 79 of file layout_internal.h.

◆ css_border_style_func

typedef uint8_t(* css_border_style_func) (const css_computed_style *style)

Definition at line 77 of file layout_internal.h.

◆ css_len_func

typedef uint8_t(* css_len_func) (const css_computed_style *style, css_fixed *length, css_unit *unit)

Definition at line 74 of file layout_internal.h.

Function Documentation

◆ calculate_mbp_width()

static void calculate_mbp_width ( const css_unit_ctx *  unit_len_ctx,
const css_computed_style *  style,
unsigned int  side,
bool  margin,
bool  border,
bool  padding,
int *  fixed,
float *  frac 
)
inlinestatic

Determine width of margin, borders, and padding on one side of a box.

Parameters
unit_len_ctxCSS length conversion context for document
stylestyle to measure
sideside of box to measure
marginwhether margin width is required
borderwhether border width is required
paddingwhether padding width is required
fixedincreased by sum of fixed margin, border, and padding
fracincreased by sum of fractional margin and padding

Definition at line 316 of file layout_internal.h.

References border_width_funcs, lh__have_border(), margin_funcs, padding_funcs, and type.

Referenced by layout_float_find_dimensions(), layout_handle_box_sizing(), layout_minmax_block(), layout_minmax_line(), and layout_minmax_table().

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

◆ layout_block_context()

bool layout_block_context ( struct box block,
int  viewport_height,
html_content content 
)

Layout a block formatting context.

Parameters
blockBLOCK, INLINE_BLOCK, or TABLE_CELL to layout
viewport_heightHeight of viewport in pixels or -ve if unknown
contentMemory pool for any new boxes
Returns
true on success, false on memory exhaustion

This function carries out layout of a block and its children, as described in CSS 2.1 9.4.1.

< current coordinates

Definition at line 3531 of file layout.c.

References AUTO, plot_font_style::background, box::border, BOTTOM, BOX_BLOCK, BOX_FLEX, BOX_INLINE_BLOCK, BOX_INLINE_CONTAINER, BOX_INLINE_FLEX, box_is_first_child(), BOX_TABLE, BOX_TABLE_CELL, box::cached_place_below_level, box::children, box::clear_level, form_control::data, find_sides(), box::flags, box::float_children, font_plot_style_from_css(), box::gadget, GADGET_CHECKBOX, GADGET_PASSWORD, GADGET_RADIO, GADGET_TEXTAREA, GADGET_TEXTBOX, HAS_HEIGHT, box::height, IFRAME, box::iframe, layout_apply_minmax_height(), layout_block_add_scrollbar(), layout_block_context(), layout_block_find_dimensions(), layout_block_object(), layout_clear(), layout_flex(), layout_get_object_dimensions(), layout_inline_container(), layout_next_margin_block(), layout_solve_width(), layout_table(), LEFT, lh__box_is_object(), MAKE_HEIGHT, box::margin, box::next, box::next_float, NS_TRANSPARENT, NSLOG, box::object, box::padding, box::parent, REPLACE_DIM, RIGHT, box::style, textarea_set_layout(), TOP, box::type, form_control::type, UNKNOWN_WIDTH, box_border::width, box::width, width, box::x, and box::y.

Referenced by layout_absolute(), layout_block_context(), layout_document(), layout_flex_item(), layout_float(), and layout_table().

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

◆ layout_find_dimensions()

static void layout_find_dimensions ( const css_unit_ctx *  unit_len_ctx,
int  available_width,
int  viewport_height,
const struct box box,
const css_computed_style *  style,
int *  width,
int *  height,
int *  max_width,
int *  min_width,
int *  max_height,
int *  min_height,
int  margin[4],
int  padding[4],
struct box_border  border[4] 
)
inlinestatic

Calculate width, height, and thickness of margins, paddings, and borders.

Parameters
unit_len_ctxLength conversion context
available_widthwidth of containing block
viewport_heightheight of viewport in pixels or -ve if unknown
boxcurrent box
stylestyle giving width, height, margins, paddings, and borders
widthupdated to width, may be NULL
heightupdated to height, may be NULL
max_widthupdated to max-width, may be NULL
min_widthupdated to min-width, may be NULL
max_heightupdated to max-height, may be NULL
min_heightupdated to min-height, may be NULL
marginfilled with margins, may be NULL
paddingfilled with paddings, may be NULL
borderfilled with border widths, may be NULL

Definition at line 433 of file layout_internal.h.

References AUTO, border_color_funcs, border_style_funcs, border_width_funcs, BOX_INLINE_CONTAINER, BOX_TABLE, BOX_TABLE_CELL, BOX_TABLE_ROW, BOX_TABLE_ROW_GROUP, border::c, box::float_container, FPCT_OF_INT_TOINT, box::height, height, layout_handle_box_sizing(), box::margin, margin_funcs, box::max_width, box::min_width, ns_computed_min_height(), ns_computed_min_width(), box::padding, padding_funcs, box::parent, box::style, border::style, box::type, type, border::width, and width.

Referenced by layout_absolute(), layout_block_find_dimensions(), layout_flex(), layout_flex_ctx__populate_item_data(), layout_float_find_dimensions(), layout_line(), layout_next_margin_block(), and layout_table().

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

◆ layout_flex()

bool layout_flex ( struct box flex,
int  available_width,
html_content content 
)

Layout a flex container.

Parameters
[in]flextable to layout
[in]available_widthwidth of containing block
[in]contentmemory pool for any new boxes
Returns
true on success, false on memory exhaustion

Definition at line 1046 of file layout_flex.c.

References AUTO, flex_ctx::available_cross, flex_ctx::available_main, box::border, flex_ctx::cross_size, flex_ctx::flex, box::height, flex_ctx::horizontal, layout_find_dimensions(), layout_flex__collect_items_into_lines(), layout_flex__place_lines(), layout_flex_ctx__create(), layout_flex_ctx__destroy(), layout_flex_ctx__populate_item_data(), flex_ctx::main_size, box::margin, min, NSLOG, box::padding, box::style, flex_ctx::unit_len_ctx, and box::width.

Referenced by layout_absolute(), layout_block_context(), layout_flex_item(), and layout_float().

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

◆ layout_handle_box_sizing()

static void layout_handle_box_sizing ( const css_unit_ctx *  unit_len_ctx,
const struct box box,
int  available_width,
bool  setwidth,
int *  dimension 
)
inlinestatic

Adjust a specified width or height for the box-sizing property.

This turns the specified dimension into a content-box dimension.

Parameters
unit_len_ctxLength conversion context
boxgadget to adjust dimensions of
available_widthwidth of containing block
setwidthset true if the dimension to be tweaked is a width, else set false for a height
dimensioncurrent value for given width/height dimension. updated to new value after consideration of gadget properties.

Definition at line 385 of file layout_internal.h.

References BOTTOM, calculate_mbp_width(), LEFT, RIGHT, box::style, and TOP.

Referenced by layout_find_dimensions().

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

◆ layout_table()

bool layout_table ( struct box table,
int  available_width,
html_content content 
)

Layout a table.

Parameters
tabletable to layout
available_widthwidth of containing block
contentmemory pool for any new boxes
Returns
true on success, false on memory exhaustion
Todo:
distribute spare height over the row groups / rows / cells

Definition at line 1604 of file layout.c.

References AUTO, box::border, BOTTOM, BOX_INLINE_CONTAINER, BOX_TABLE, box::cached_place_below_level, box::children, box::col, column::COLUMN_WIDTH_FIXED, column::COLUMN_WIDTH_PERCENT, column::COLUMN_WIDTH_RELATIVE, box::columns, count(), box::descendant_y0, box::descendant_y1, box::float_children, box::float_container, FPCT_OF_INT_TOINT, box::height, layout_block_context(), layout_find_dimensions(), layout_move_children(), LEFT, box::margin, column::max, max, box::max_width, column::min, min, box::min_width, box::next, NSLOG, box::padding, box::parent, column::positioned, RIGHT, box::rows, SCROLLBAR_WIDTH, box::start_column, box::style, table_used_border_for_cell(), TOP, column::type, box::type, type, box_border::width, column::width, box::width, width, box::x, and box::y.

Referenced by layout_absolute(), layout_block_context(), and layout_float().

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

◆ lh__box_align_self()

static enum css_align_self_e lh__box_align_self ( const struct box flex,
const struct box item 
)
inlinestatic

Definition at line 291 of file layout_internal.h.

References box::style.

Referenced by layout_flex__place_line_items_cross().

Here is the caller graph for this function:

◆ lh__box_is_absolute()

static bool lh__box_is_absolute ( const struct box b)
inlinestatic

Definition at line 164 of file layout_internal.h.

References box::style.

Referenced by layout_flex__build_line(), layout_flex__item_freeze(), and layout_flex__place_line_items_main().

Here is the caller graph for this function:

◆ lh__box_is_flex_container()

static bool lh__box_is_flex_container ( const struct box b)
inlinestatic

Layout helper: Check whether box takes part in inline flow.

Definition at line 116 of file layout_internal.h.

References BOX_FLEX, BOX_INLINE_FLEX, and box::type.

Referenced by layout_minmax_block(), and lh__box_is_flex_item().

Here is the caller graph for this function:

◆ lh__box_is_flex_item()

static bool lh__box_is_flex_item ( const struct box b)
inlinestatic

Layout helper: Check whether box takes part in inline flow.

Definition at line 123 of file layout_internal.h.

References lh__box_is_flex_container(), and box::parent.

Referenced by layout_minmax_block().

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

◆ lh__box_is_float_box()

static bool lh__box_is_float_box ( const struct box b)
inlinestatic

Layout helper: Check whether box is a float.

Definition at line 99 of file layout_internal.h.

References BOX_FLOAT_LEFT, BOX_FLOAT_RIGHT, and box::type.

Referenced by layout_line(), layout_minmax_block(), layout_minmax_line(), and lh__box_is_inline_content().

Here is the caller graph for this function:

◆ lh__box_is_inline_content()

static bool lh__box_is_inline_content ( const struct box b)
inlinestatic

Layout helper: Check whether box is inline level.

(Includes BR, floats.)

Definition at line 136 of file layout_internal.h.

References lh__box_is_float_box(), and lh__box_is_inline_level().

Referenced by layout_line(), and layout_minmax_line().

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

◆ lh__box_is_inline_flow()

static bool lh__box_is_inline_flow ( const struct box b)
inlinestatic

Layout helper: Check whether box takes part in inline flow.

Definition at line 106 of file layout_internal.h.

References BOX_INLINE, BOX_INLINE_BLOCK, BOX_INLINE_END, BOX_INLINE_FLEX, BOX_TEXT, and box::type.

Referenced by layout_line(), and lh__box_is_inline_level().

Here is the caller graph for this function:

◆ lh__box_is_inline_level()

static bool lh__box_is_inline_level ( const struct box b)
inlinestatic

Layout helper: Check whether box is inline level.

(Includes BR.)

Definition at line 129 of file layout_internal.h.

References BOX_BR, lh__box_is_inline_flow(), and box::type.

Referenced by lh__box_is_inline_content().

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

◆ lh__box_is_object()

static bool lh__box_is_object ( const struct box b)
inlinestatic

Layout helper: Check whether box is an object.

Definition at line 143 of file layout_internal.h.

References box::flags, IFRAME, box::object, and REPLACE_DIM.

Referenced by layout_block_context(), layout_inline_container(), and lh__box_is_replace().

Here is the caller graph for this function:

◆ lh__box_is_replace()

static bool lh__box_is_replace ( const struct box b)
inlinestatic

Layout helper: Check whether box is replaced.

Definition at line 150 of file layout_internal.h.

References box::gadget, and lh__box_is_object().

Referenced by layout_line(), and layout_minmax_line().

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

◆ lh__box_size_cross()

static int lh__box_size_cross ( bool  horizontal,
const struct box b 
)
inlinestatic

Definition at line 268 of file layout_internal.h.

References box::height, and box::width.

Referenced by layout_flex__place_line_items_main().

Here is the caller graph for this function:

◆ lh__box_size_cross_is_auto()

static bool lh__box_size_cross_is_auto ( bool  horizontal,
struct box b 
)
inlinestatic

Definition at line 275 of file layout_internal.h.

References box::style.

Referenced by layout_flex__place_line_items_cross().

Here is the caller graph for this function:

◆ lh__box_size_cross_ptr()

static int * lh__box_size_cross_ptr ( bool  horizontal,
struct box b 
)
inlinestatic

Definition at line 254 of file layout_internal.h.

References box::height, and box::width.

Referenced by layout_flex__place_line_items_cross().

Here is the caller graph for this function:

◆ lh__box_size_main()

static int lh__box_size_main ( bool  horizontal,
const struct box b 
)
inlinestatic

Definition at line 261 of file layout_internal.h.

References box::height, and box::width.

Referenced by layout_flex__place_line_items_main().

Here is the caller graph for this function:

◆ lh__box_size_main_ptr()

static int * lh__box_size_main_ptr ( bool  horizontal,
struct box b 
)
inlinestatic

Definition at line 247 of file layout_internal.h.

References box::height, and box::width.

◆ lh__delta_outer_cross()

static int lh__delta_outer_cross ( const struct box flex,
const struct box b 
)
inlinestatic

Definition at line 236 of file layout_internal.h.

References lh__delta_outer_height(), lh__delta_outer_width(), and lh__flex_main_is_horizontal().

Referenced by layout_flex__place_line_items_cross(), and layout_flex__place_line_items_main().

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

◆ lh__delta_outer_height()

static int lh__delta_outer_height ( const struct box b)
inlinestatic

Definition at line 205 of file layout_internal.h.

References box::border, BOTTOM, lh__non_auto_margin(), box::padding, TOP, and box_border::width.

Referenced by lh__delta_outer_cross(), and lh__delta_outer_main().

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

◆ lh__delta_outer_main()

static int lh__delta_outer_main ( const struct box flex,
const struct box b 
)
inlinestatic

Definition at line 225 of file layout_internal.h.

References lh__delta_outer_height(), lh__delta_outer_width(), and lh__flex_main_is_horizontal().

Referenced by layout_flex__base_and_main_sizes(), layout_flex__build_line(), and layout_flex__place_line_items_main().

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

◆ lh__delta_outer_width()

static int lh__delta_outer_width ( const struct box b)
inlinestatic

Definition at line 215 of file layout_internal.h.

References box::border, LEFT, lh__non_auto_margin(), box::padding, RIGHT, and box_border::width.

Referenced by layout_flex__base_and_main_sizes(), layout_flex__place_line_items_main(), lh__delta_outer_cross(), and lh__delta_outer_main().

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

◆ lh__flex_direction_reversed()

static bool lh__flex_direction_reversed ( const struct box flex)
inlinestatic

Definition at line 187 of file layout_internal.h.

References box::style.

Referenced by layout_flex_ctx__create().

Here is the caller graph for this function:

◆ lh__flex_main_is_horizontal()

static bool lh__flex_main_is_horizontal ( const struct box flex)
inlinestatic

Definition at line 170 of file layout_internal.h.

References box::style.

Referenced by layout_flex_ctx__create(), layout_minmax_block(), lh__delta_outer_cross(), and lh__delta_outer_main().

Here is the caller graph for this function:

◆ lh__have_border()

static bool lh__have_border ( enum box_side  side,
const css_computed_style *  style 
)
inlinestatic

Layout helper: Check for CSS border on given side.

Definition at line 157 of file layout_internal.h.

References border_style_funcs.

Referenced by calculate_mbp_width().

Here is the caller graph for this function:

◆ lh__non_auto_margin()

static int lh__non_auto_margin ( const struct box b,
enum box_side  side 
)
inlinestatic

Definition at line 200 of file layout_internal.h.

References AUTO, and box::margin.

Referenced by layout_flex__place_line_items_cross(), layout_flex__place_line_items_main(), lh__delta_outer_height(), and lh__delta_outer_width().

Here is the caller graph for this function:

Variable Documentation

◆ border_color_funcs

const css_border_color_func border_color_funcs[4]
extern

Array of per-side access functions for computed style border colors.

Definition at line 106 of file layout.c.

Referenced by layout_find_dimensions().

◆ border_style_funcs

const css_border_style_func border_style_funcs[4]
extern

Array of per-side access functions for computed style border styles.

Definition at line 98 of file layout.c.

Referenced by layout_find_dimensions(), and lh__have_border().

◆ border_width_funcs

const css_len_func border_width_funcs[4]
extern

Array of per-side access functions for computed style border_widths.

Definition at line 90 of file layout.c.

Referenced by calculate_mbp_width(), and layout_find_dimensions().

◆ margin_funcs

const css_len_func margin_funcs[4]
extern

Array of per-side access functions for computed style margins.

Definition at line 74 of file layout.c.

Referenced by calculate_mbp_width(), and layout_find_dimensions().

◆ padding_funcs

const css_len_func padding_funcs[4]
extern

Array of per-side access functions for computed style paddings.

Definition at line 82 of file layout.c.

Referenced by calculate_mbp_width(), and layout_find_dimensions().