NetSurf
|
HTML layout private interface. More...
Go to the source code of this file.
Macros | |
#define | AUTO INT_MIN |
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... | |
HTML layout private interface.
Definition in file layout_internal.h.
#define AUTO INT_MIN |
Definition at line 27 of file layout_internal.h.
typedef uint8_t(* css_border_color_func) (const css_computed_style *style, css_color *color) |
Definition at line 76 of file layout_internal.h.
typedef uint8_t(* css_border_style_func) (const css_computed_style *style) |
Definition at line 74 of file layout_internal.h.
typedef uint8_t(* css_len_func) (const css_computed_style *style, css_fixed *length, css_unit *unit) |
Definition at line 71 of file layout_internal.h.
|
inlinestatic |
Determine width of margin, borders, and padding on one side of a box.
unit_len_ctx | CSS length conversion context for document |
style | style to measure |
side | side of box to measure |
margin | whether margin width is required |
border | whether border width is required |
padding | whether padding width is required |
fixed | increased by sum of fixed margin, border, and padding |
frac | increased by sum of fractional margin and padding |
Definition at line 313 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().
bool layout_block_context | ( | struct box * | block, |
int | viewport_height, | ||
html_content * | content | ||
) |
Layout a block formatting context.
block | BLOCK, INLINE_BLOCK, or TABLE_CELL to layout |
viewport_height | Height of viewport in pixels or -ve if unknown |
content | Memory pool for any new boxes |
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 3508 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().
|
inlinestatic |
Calculate width, height, and thickness of margins, paddings, and borders.
unit_len_ctx | Length conversion context |
available_width | width of containing block |
viewport_height | height of viewport in pixels or -ve if unknown |
box | current box |
style | style giving width, height, margins, paddings, and borders |
width | updated to width, may be NULL |
height | updated to height, may be NULL |
max_width | updated to max-width, may be NULL |
min_width | updated to min-width, may be NULL |
max_height | updated to max-height, may be NULL |
min_height | updated to min-height, may be NULL |
margin | filled with margins, may be NULL |
padding | filled with paddings, may be NULL |
border | filled with border widths, may be NULL |
Definition at line 430 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, 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().
bool layout_flex | ( | struct box * | flex, |
int | available_width, | ||
html_content * | content | ||
) |
Layout a flex container.
[in] | flex | table to layout |
[in] | available_width | width of containing block |
[in] | content | memory pool for any new boxes |
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().
|
inlinestatic |
Adjust a specified width or height for the box-sizing property.
This turns the specified dimension into a content-box dimension.
unit_len_ctx | Length conversion context |
box | gadget to adjust dimensions of |
available_width | width of containing block |
setwidth | set true if the dimension to be tweaked is a width, else set false for a height |
dimension | current value for given width/height dimension. updated to new value after consideration of gadget properties. |
Definition at line 382 of file layout_internal.h.
References BOTTOM, calculate_mbp_width(), LEFT, RIGHT, box::style, and TOP.
Referenced by layout_find_dimensions().
bool layout_table | ( | struct box * | table, |
int | available_width, | ||
html_content * | content | ||
) |
Layout a table.
table | table to layout |
available_width | width of containing block |
content | memory pool for any new boxes |
Definition at line 1591 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, 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().
|
inlinestatic |
Definition at line 288 of file layout_internal.h.
References box::style.
Referenced by layout_flex__place_line_items_cross().
|
inlinestatic |
Definition at line 161 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().
|
inlinestatic |
Layout helper: Check whether box takes part in inline flow.
Definition at line 113 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().
|
inlinestatic |
Layout helper: Check whether box takes part in inline flow.
Definition at line 120 of file layout_internal.h.
References lh__box_is_flex_container(), and box::parent.
Referenced by layout_minmax_block().
|
inlinestatic |
Layout helper: Check whether box is a float.
Definition at line 96 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().
|
inlinestatic |
Layout helper: Check whether box is inline level.
(Includes BR, floats.)
Definition at line 133 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().
|
inlinestatic |
Layout helper: Check whether box takes part in inline flow.
Definition at line 103 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().
|
inlinestatic |
Layout helper: Check whether box is inline level.
(Includes BR.)
Definition at line 126 of file layout_internal.h.
References BOX_BR, lh__box_is_inline_flow(), and box::type.
Referenced by lh__box_is_inline_content().
|
inlinestatic |
Layout helper: Check whether box is an object.
Definition at line 140 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().
|
inlinestatic |
Layout helper: Check whether box is replaced.
Definition at line 147 of file layout_internal.h.
References box::gadget, and lh__box_is_object().
Referenced by layout_line(), and layout_minmax_line().
|
inlinestatic |
Definition at line 265 of file layout_internal.h.
References box::height, and box::width.
Referenced by layout_flex__place_line_items_main().
|
inlinestatic |
Definition at line 272 of file layout_internal.h.
References box::style.
Referenced by layout_flex__place_line_items_cross().
|
inlinestatic |
Definition at line 251 of file layout_internal.h.
References box::height, and box::width.
Referenced by layout_flex__place_line_items_cross().
|
inlinestatic |
Definition at line 258 of file layout_internal.h.
References box::height, and box::width.
Referenced by layout_flex__place_line_items_main().
|
inlinestatic |
Definition at line 244 of file layout_internal.h.
References box::height, and box::width.
Definition at line 233 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().
|
inlinestatic |
Definition at line 202 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().
Definition at line 222 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().
|
inlinestatic |
Definition at line 212 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().
|
inlinestatic |
Definition at line 184 of file layout_internal.h.
References box::style.
Referenced by layout_flex_ctx__create().
|
inlinestatic |
Definition at line 167 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().
|
inlinestatic |
Layout helper: Check for CSS border on given side.
Definition at line 154 of file layout_internal.h.
References border_style_funcs.
Referenced by calculate_mbp_width().
Definition at line 197 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().
|
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().
|
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().
|
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().
|
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().
|
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().