NetSurf
|
HTML layout implementation. More...
#include <assert.h>
#include <limits.h>
#include <stdbool.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <math.h>
#include <dom/dom.h>
#include "utils/log.h"
#include "utils/talloc.h"
#include "utils/utils.h"
#include "utils/nsoption.h"
#include "utils/corestrings.h"
#include "utils/nsurl.h"
#include "netsurf/inttypes.h"
#include "netsurf/content.h"
#include "netsurf/browser_window.h"
#include "netsurf/layout.h"
#include "content/content.h"
#include "content/content_protected.h"
#include "css/utils.h"
#include "desktop/scrollbar.h"
#include "desktop/textarea.h"
#include "html/html.h"
#include "html/html_save.h"
#include "html/private.h"
#include "html/box.h"
#include "html/box_inspect.h"
#include "html/font.h"
#include "html/form_internal.h"
#include "html/layout.h"
#include "html/layout_internal.h"
#include "html/table.h"
Go to the source code of this file.
Functions | |
static void | layout_minmax_block (struct box *block, const struct gui_layout_table *font_func, const html_content *content) |
Calculate minimum and maximum width of a block. More... | |
static void | layout_get_object_dimensions (struct box *box, int *width, int *height, int min_width, int max_width, int min_height, int max_height) |
Compute the size of replaced boxes with auto dimensions, according to content. More... | |
static int | layout_text_indent (const css_unit_ctx *unit_len_ctx, const css_computed_style *style, int width) |
Calculate the text-indent length. More... | |
static void | layout_minmax_table (struct box *table, const struct gui_layout_table *font_func, const html_content *content) |
Calculate minimum and maximum width of a table. More... | |
static bool | box_has_percentage_max_width (struct box *b) |
Helper to check if a box has percentage max width. More... | |
static struct box * | layout_minmax_line (struct box *first, int *line_min, int *line_max, bool first_line, bool *line_has_height, const struct gui_layout_table *font_func, const html_content *content) |
Calculate minimum and maximum width of a line. More... | |
static void | layout_minmax_inline_container (struct box *inline_container, bool *has_height, const struct gui_layout_table *font_func, const html_content *content) |
Calculate minimum and maximum width of an inline container. More... | |
static struct box * | layout_next_margin_block (const css_unit_ctx *unit_len_ctx, struct box *box, struct box *block, int viewport_height, int *max_pos_margin, int *max_neg_margin) |
Find next block that current margin collapses to. More... | |
static int | layout_clear (struct box *fl, enum css_clear_e clear) |
Find y coordinate which clears all floats on left and/or right. More... | |
static void | find_sides (struct box *fl, int y0, int y1, int *x0, int *x1, struct box **left, struct box **right) |
Find left and right edges in a vertical range. More... | |
static int | layout_solve_width (struct box *box, int available_width, int width, int lm, int rm, int max_width, int min_width) |
Solve the width constraint as given in CSS 2.1 section 10.3.3. More... | |
static void | layout_block_find_dimensions (const css_unit_ctx *unit_len_ctx, int available_width, int viewport_height, int lm, int rm, struct box *box) |
Compute dimensions of box, margins, paddings, and borders for a block-level element. More... | |
static void | layout_block_add_scrollbar (struct box *box, int which) |
Manipulate a block's [RB]padding/height/width to accommodate scrollbars. More... | |
static void | layout_move_children (struct box *box, int x, int y) |
Moves the children of a box by a specified amount. More... | |
bool | layout_table (struct box *table, int available_width, html_content *content) |
Layout a table. More... | |
static bool | layout_apply_minmax_height (const css_unit_ctx *unit_len_ctx, struct box *box, struct box *container) |
Manimpulate box height according to CSS min-height and max-height properties. More... | |
static bool | layout_block_object (struct box *block) |
Layout a block which contains an object. More... | |
static void | add_float_to_container (struct box *cont, struct box *b) |
Insert a float into a container. More... | |
static bool | layout_text_box_split (html_content *content, plot_font_style_t *fstyle, struct box *split_box, size_t new_length, int new_width) |
Split a text box. More... | |
static void | layout_float_find_dimensions (const css_unit_ctx *unit_len_ctx, int available_width, const css_computed_style *style, struct box *box) |
Compute dimensions of box, margins, paddings, and borders for a floating element using shrink-to-fit. More... | |
static bool | layout_float (struct box *b, int width, html_content *content) |
Layout the contents of a float or inline block. More... | |
static void | place_float_below (struct box *c, int width, int cx, int y, struct box *cont) |
Position a float in the first available space. More... | |
static int | line_height (const css_unit_ctx *unit_len_ctx, const css_computed_style *style) |
Calculate line height from a style. More... | |
static bool | layout_line (struct box *first, int *width, int *y, int cx, int cy, struct box *cont, bool indent, bool has_text_children, html_content *content, struct box **next_box) |
Position a line of boxes in inline formatting context. More... | |
static bool | layout_inline_container (struct box *inline_container, int width, struct box *cont, int cx, int cy, html_content *content) |
Layout lines of text or inline boxes with floats. More... | |
bool | layout_block_context (struct box *block, int viewport_height, html_content *content) |
Layout a block formatting context. More... | |
static bool | layout__get_element_tag (const dom_node *node, dom_html_element_type *type) |
Get a dom node's element tag type. More... | |
static bool | layout__check_element_type (const dom_node *node, dom_html_element_type type) |
Check a node's tag type. More... | |
static bool | layout__get_li_value (dom_node *li_node, dom_long *value_out) |
Helper to get attribute value from a LI node. More... | |
static bool | layout__get_ol_start (dom_node *ol_node, dom_long *start_out) |
Helper to get start attribute value from a OL node. More... | |
static bool | layout__get_ol_reversed (dom_node *ol_node) |
Helper to get reversed attribute value from a OL node. More... | |
static bool | layout__get_list_item_count (dom_node *list_owner, dom_long *count_out) |
Get the number of list items for a list owner. More... | |
static void | layout__ordered_list_count (struct box *box) |
Handle list item counting, if this is a list owner box. More... | |
static void | layout__set_numerical_marker_text (const html_content *content, struct box *box) |
Set up the marker text for a numerical list item. More... | |
static bool | layout__list_item_is_numerical (const struct box *b) |
Find out if box's style represents a numerical list style type. More... | |
static void | layout_lists (const html_content *content, struct box *box) |
Layout list markers. More... | |
static void | layout_compute_offsets (const css_unit_ctx *unit_len_ctx, struct box *box, struct box *containing_block, int *top, int *right, int *bottom, int *left) |
Compute box offsets for a relatively or absolutely positioned box with respect to a box. More... | |
static bool | layout_absolute (struct box *box, struct box *containing_block, int cx, int cy, html_content *content) |
Layout and position an absolutely positioned box. More... | |
static bool | layout_position_absolute (struct box *box, struct box *containing_block, int cx, int cy, html_content *content) |
Recursively layout and position absolutely positioned boxes. More... | |
static void | layout_compute_relative_offset (const css_unit_ctx *unit_len_ctx, struct box *box, int *x, int *y) |
Compute a box's relative offset as per CSS 2.1 9.4.3. More... | |
static void | layout_position_relative (const css_unit_ctx *unit_len_ctx, struct box *root, struct box *fp, int fx, int fy) |
Adjust positions of relatively positioned boxes. More... | |
static void | layout_get_box_bbox (const css_unit_ctx *unit_len_ctx, struct box *box, int *desc_x0, int *desc_y0, int *desc_x1, int *desc_y1) |
Find a box's bounding box relative to itself, i.e. More... | |
static void | layout_update_descendant_bbox (const css_unit_ctx *unit_len_ctx, struct box *box, struct box *child, int off_x, int off_y) |
Apply changes to box descendant_[xy][01] values due to given child. More... | |
static void | layout_calculate_descendant_bboxes (const css_unit_ctx *unit_len_ctx, struct box *box) |
Recursively calculate the descendant_[xy][01] values for a laid-out box tree and inform iframe browser windows of their size and position. More... | |
bool | layout_document (html_content *content, int width, int height) |
Calculate positions of boxes in a document. 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 implementation.
Layout is carried out in two stages:
In most cases the functions for the two stages are a corresponding pair layout_minmax_X() and layout_X().
Definition in file layout.c.
Insert a float into a container.
cont | block formatting context block, used to contain float |
b | box to add to float |
This sorts floats in order of descending bottom edges.
Definition at line 2305 of file layout.c.
References BOX_FLOAT_LEFT, BOX_FLOAT_RIGHT, box::float_children, box::height, box::next_float, box::prev, box::type, and box::y.
Referenced by layout_line().
|
inlinestatic |
Helper to check if a box has percentage max width.
[in] | b | Box to check. |
Definition at line 438 of file layout.c.
References box::style, and type.
Referenced by layout_minmax_line().
|
static |
Find left and right edges in a vertical range.
fl | first float in float list |
y0 | start of y range to search |
y1 | end of y range to search |
x0 | start left edge, updated to available left edge |
x1 | start right edge, updated to available right edge |
left | returns float on left if present |
right | returns float on right if present |
Definition at line 1285 of file layout.c.
References BOX_FLOAT_LEFT, box::height, box::next_float, NSLOG, box::type, box::width, box::x, and box::y.
Referenced by layout_block_context(), layout_line(), and place_float_below().
|
inlinestatic |
Check a node's tag type.
[in] | node | Node to check tag type of. |
[in] | type | Tag type to test for. |
Definition at line 4050 of file layout.c.
References layout__get_element_tag(), box::node, and type.
Referenced by layout__get_list_item_count(), and layout__ordered_list_count().
|
static |
Get a dom node's element tag type.
[in] | node | Node to get tag type of. |
[in] | type | Returns element tag type on success. |
Definition at line 4018 of file layout.c.
References box::node, and type.
Referenced by layout__check_element_type(), layout__get_list_item_count(), and layout__ordered_list_count().
|
static |
Helper to get attribute value from a LI node.
[in] | li_node | DOM node for the LI element; |
[out] | value_out | Returns the value on success. |
This helps for the common case of no value. However we should fix libdom to have some kind of sane interface to get numerical attributes.
Definition at line 4072 of file layout.c.
Referenced by layout__ordered_list_count().
|
static |
Get the number of list items for a list owner.
[in] | list_owner | DOM node to count list items for. |
[in] | count_out | Returns list item count on success. |
Definition at line 4173 of file layout.c.
References count(), layout__check_element_type(), layout__get_element_tag(), and box::list_marker.
Referenced by layout__ordered_list_count().
|
static |
Helper to get reversed attribute value from a OL node.
[in] | ol_node | DOM node for the OL element; |
Definition at line 4149 of file layout.c.
Referenced by layout__ordered_list_count().
|
static |
Helper to get start attribute value from a OL node.
[in] | ol_node | DOM node for the OL element; |
[out] | start_out | Returns the value on success. |
Definition at line 4114 of file layout.c.
Referenced by layout__ordered_list_count().
|
static |
Find out if box's style represents a numerical list style type.
[in] | b | Box with style to test. |
Definition at line 4375 of file layout.c.
References box::style.
Referenced by layout_lists().
|
static |
Handle list item counting, if this is a list owner box.
[in] | box | Box to do list item counting for. |
Definition at line 4239 of file layout.c.
References layout__check_element_type(), layout__get_element_tag(), layout__get_li_value(), layout__get_list_item_count(), layout__get_ol_reversed(), layout__get_ol_start(), box::list_marker, box::list_value, box::next, and box::node.
Referenced by layout_lists().
|
static |
Set up the marker text for a numerical list item.
[in] | content | The HTML content. |
[in] | box | The list item's main box. |
initial length of a list marker buffer
enough for 9,999,999,999,999,999,999 in decimal or five characters for 4-byte UTF-8.
Definition at line 4325 of file layout.c.
References box::length, box::list_marker, box::list_value, box::style, talloc_array, talloc_realloc, and box::text.
Referenced by layout_lists().
|
static |
Layout and position an absolutely positioned box.
box | absolute box to layout and position |
containing_block | containing block |
cx | position of box relative to containing_block |
cy | position of box relative to containing_block |
content | memory pool for any new boxes |
Definition at line 4558 of file layout.c.
References AUTO, box::border, BOTTOM, BOX_BLOCK, BOX_FLEX, BOX_INLINE_BLOCK, BOX_INLINE_FLEX, BOX_TABLE, BOX_TABLE_CELL, box::flags, box::float_container, box::height, height, IFRAME, layout_apply_minmax_height(), layout_block_context(), layout_compute_offsets(), layout_find_dimensions(), layout_flex(), layout_solve_width(), layout_table(), LEFT, box::margin, max, box::max_width, min, box::min_width, NSLOG, box::object, box::padding, box::parent, RIGHT, box::style, TOP, box::type, box_border::width, box::width, border::width, width, box::x, and box::y.
Referenced by layout_position_absolute().
|
static |
Manimpulate box height according to CSS min-height and max-height properties.
unit_len_ctx | CSS length conversion context for document. |
box | block to modify with any min-height or max-height |
container | containing block for absolutely positioned elements, or NULL for non absolutely positioned elements. |
Definition at line 2158 of file layout.c.
References AUTO, BOX_INLINE_CONTAINER, box::float_container, box::height, height, ns_computed_min_height(), box::parent, box::style, and box::type.
Referenced by layout_absolute(), and layout_block_context().
|
static |
Manipulate a block's [RB]padding/height/width to accommodate scrollbars.
box | Box to apply scrollbar space too. Must be BOX_BLOCK. |
which | Which scrollbar to make space for. Must be RIGHT or BOTTOM. |
Definition at line 1526 of file layout.c.
References AUTO, BOTTOM, BOX_BLOCK, box_hscrollbar_present(), box_vscrollbar_present(), content_get_type(), CONTENT_HTML, box::height, height, box::object, box::padding, RIGHT, SCROLLBAR_WIDTH, box::style, box::type, and box::width.
Referenced by layout_block_context().
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().
|
static |
Compute dimensions of box, margins, paddings, and borders for a block-level element.
unit_len_ctx | Length conversion context |
available_width | Max width available in pixels |
viewport_height | Height of viewport in pixels or -ve if unknown |
lm | min left margin required to avoid floats in px. zero if not applicable |
rm | min right margin required to avoid floats in px. zero if not applicable |
box | box to find dimensions of. updated with new width, height, margins, borders and paddings |
See CSS 2.1 10.3.3, 10.3.4, 10.6.2, and 10.6.3.
Definition at line 1484 of file layout.c.
References AUTO, box::border, BOTTOM, content_get_type(), CONTENT_HTML, box::flags, box::height, height, layout_find_dimensions(), layout_get_object_dimensions(), layout_solve_width(), box::margin, box::max_width, box::min_width, box::object, box::padding, REPLACE_DIM, box_border::style, box::style, TOP, box::width, and width.
Referenced by layout_block_context(), and layout_document().
|
static |
Layout a block which contains an object.
block | box of type BLOCK, INLINE_BLOCK, TABLE, or TABLE_CELL |
Definition at line 2271 of file layout.c.
References BOX_BLOCK, BOX_FLEX, BOX_INLINE_BLOCK, BOX_INLINE_FLEX, BOX_TABLE, BOX_TABLE_CELL, content_can_reformat(), content_reformat(), hlcache_handle_get_url(), NSLOG, box::object, box::type, and box::width.
Referenced by layout_block_context().
|
static |
Recursively calculate the descendant_[xy][01] values for a laid-out box tree and inform iframe browser windows of their size and position.
unit_len_ctx | Length conversion context |
box | tree of boxes to update |
Definition at line 5303 of file layout.c.
References AUTO, box_coords(), BOX_FLOAT_LEFT, BOX_FLOAT_RIGHT, BOX_INLINE, BOX_INLINE_END, BOX_TEXT, browser_window_reformat(), browser_window_set_dimensions(), browser_window_set_position(), box::children, content_get_height(), content_get_type(), content_get_width(), CONTENT_HTML, box::descendant_x0, box::descendant_x1, box::descendant_y0, box::descendant_y1, box::flags, box::float_children, box::height, box::iframe, box::inline_end, layout_calculate_descendant_bboxes(), layout_get_box_bbox(), layout_update_descendant_bbox(), box::list_marker, box::next, box::next_float, box::object, REPLACE_DIM, box::style, box::type, UNKNOWN_WIDTH, box::width, box::x, and box::y.
Referenced by layout_calculate_descendant_bboxes(), and layout_document().
|
static |
Find y coordinate which clears all floats on left and/or right.
fl | first float in float list |
clear | type of clear |
Definition at line 1256 of file layout.c.
References BOX_FLOAT_LEFT, BOX_FLOAT_RIGHT, box::height, box::next_float, box::type, and box::y.
Referenced by layout_block_context(), and layout_line().
|
static |
Compute box offsets for a relatively or absolutely positioned box with respect to a box.
unit_len_ctx | Length conversion context |
box | box to compute offsets for |
containing_block | box to compute percentages with respect to |
top | updated to top offset, or AUTO |
right | updated to right offset, or AUTO |
bottom | updated to bottom offset, or AUTO |
left | updated to left offset, or AUTO |
See CSS 2.1 9.3.2. containing_block must have width and height.
Definition at line 4469 of file layout.c.
References AUTO, box::height, box::style, type, UNKNOWN_WIDTH, and box::width.
Referenced by layout_absolute(), and layout_compute_relative_offset().
|
static |
Compute a box's relative offset as per CSS 2.1 9.4.3.
unit_len_ctx | Length conversion context |
box | Box to compute relative offsets for. |
x | Receives relative offset in x. |
y | Receives relative offset in y. |
Definition at line 5011 of file layout.c.
References AUTO, box::float_container, layout_compute_offsets(), NSLOG, box::parent, box::style, box::x, and box::y.
Referenced by layout_position_relative().
bool layout_document | ( | struct html_content * | content, |
int | width, | ||
int | height | ||
) |
Calculate positions of boxes in a document.
content | content of type CONTENT_HTML |
width | available width |
height | available height |
Definition at line 5396 of file layout.c.
References box::border, BOTTOM, box::children, content_get_url(), box::height, height, layout_block_context(), layout_block_find_dimensions(), layout_calculate_descendant_bboxes(), layout_lists(), layout_minmax_block(), layout_position_absolute(), layout_position_relative(), LEFT, box::margin, NSLOG, nsurl_access(), box::padding, RIGHT, TOP, box_border::width, box::width, width, box::x, and box::y.
Referenced by html_reformat().
|
static |
Layout the contents of a float or inline block.
b | float or inline block box |
width | available width |
content | memory pool for any new boxes |
Definition at line 2569 of file layout.c.
References AUTO, BOTTOM, BOX_BLOCK, BOX_FLEX, BOX_INLINE_BLOCK, BOX_INLINE_FLEX, BOX_TABLE, layout_block_context(), layout_flex(), layout_float_find_dimensions(), layout_table(), LEFT, box::margin, RIGHT, box::style, TOP, box::type, and width.
Referenced by layout_line().
|
static |
Compute dimensions of box, margins, paddings, and borders for a floating element using shrink-to-fit.
Also used for inline-blocks.
unit_len_ctx | CSS length conversion context for document. |
available_width | Max width available in pixels |
style | Box's style |
box | Box for which to find dimensions Box margins, borders, paddings, width and height are updated. |
Definition at line 2431 of file layout.c.
References AUTO, box::border, BOTTOM, calculate_mbp_width(), content_get_type(), CONTENT_HTML, box::flags, box::gadget, GADGET_FILE, GADGET_PASSWORD, GADGET_TEXTAREA, GADGET_TEXTBOX, box::height, height, layout_find_dimensions(), layout_get_object_dimensions(), LEFT, box::margin, max, box::max_width, min, box::min_width, box::object, box::padding, REPLACE_DIM, RIGHT, SCROLLBAR_WIDTH, box_border::style, box::style, TOP, form_control::type, box_border::width, box::width, and width.
Referenced by layout_float().
|
static |
Find a box's bounding box relative to itself, i.e.
the box's border edge box
unit_len_ctx | Length conversion context |
box | box find bounding box of |
desc_x0 | updated to left of box's bbox |
desc_y0 | updated to top of box's bbox |
desc_x1 | updated to right of box's bbox |
desc_y1 | updated to bottom of box's bbox |
Definition at line 5195 of file layout.c.
References box::border, BOTTOM, BOX_BLOCK, box::height, LEFT, box::object, box::padding, RIGHT, box::style, TOP, box::type, box_border::width, and box::width.
Referenced by layout_calculate_descendant_bboxes(), and layout_update_descendant_bbox().
|
static |
Compute the size of replaced boxes with auto dimensions, according to content.
box | Box with object |
width | Width value in px or AUTO. If AUTO, updated to value in px. |
height | Height value in px or AUTO. If AUTO, updated to value in px. |
min_width | Box's min width, as given by layout_find_dimensions. |
max_width | Box's max width, as given by layout_find_dimensions. |
min_height | Box's min height, as given by layout_find_dimensions. |
max_height | Box's max height, as given by layout_find_dimensions. |
See CSS 2.1 sections 10.3 and 10.6.
Definition at line 134 of file layout.c.
References AUTO, content_get_height(), content_get_width(), height, box::object, and width.
Referenced by layout_block_context(), layout_block_find_dimensions(), layout_float_find_dimensions(), layout_line(), and layout_minmax_line().
|
static |
Layout lines of text or inline boxes with floats.
box | inline container box |
width | horizontal space available |
cont | ancestor box which defines horizontal space, for floats |
cx | box position relative to cont |
cy | box position relative to cont |
content | memory pool for any new boxes |
Definition at line 3443 of file layout.c.
References BOX_BR, BOX_INLINE_CONTAINER, box::children, box::height, layout_line(), box::length, lh__box_is_object(), max, box::next, NSLOG, box::style, box::text, box::type, box::width, width, and box::y.
Referenced by layout_block_context().
|
static |
Position a line of boxes in inline formatting context.
first | box at start of line |
width | available width on input, updated with actual width on output (may be incorrect if the line gets split?) |
y | coordinate of top of line, updated on exit to bottom |
cx | coordinate of left of line relative to cont |
cy | coordinate of top of line relative to cont |
cont | ancestor box which defines horizontal space, for floats |
indent | apply any first-line indent |
has_text_children | at least one TEXT in the inline_container |
next_box | updated to first box for next line, or 0 at end |
content | memory pool for any new boxes |
Definition at line 2707 of file layout.c.
References add_float_to_container(), AUTO, box::border, BOTTOM, BOX_BR, BOX_FLOAT_LEFT, BOX_INLINE, BOX_INLINE_BLOCK, BOX_INLINE_END, BOX_INLINE_FLEX, BOX_TEXT, box::cached_place_below_level, box::children, box::clear_level, content_can_reformat(), content_get_available_width(), content_get_height(), content_reformat(), find_sides(), box::flags, box::float_children, box::float_container, font_plot_style_from_css(), box::gadget, GADGET_SELECT, box::height, height, IFRAME, box::inline_end, form_control::items, layout_clear(), layout_find_dimensions(), layout_float(), layout_get_object_dimensions(), layout_text_box_split(), layout_text_indent(), LEFT, box::length, lh__box_is_float_box(), lh__box_is_inline_content(), lh__box_is_inline_flow(), lh__box_is_replace(), line_height(), box::margin, box::max_width, MEASURED, NEW_LINE, box::next, form_option::next, NSLOG, nsoption_bool, box::object, box::padding, box::parent, place_float_below(), PRIsizet, REPLACE_DIM, RIGHT, SCROLLBAR_WIDTH, form_control::select, box::space, gui_layout_table::split, box::style, box::text, form_option::text, TOP, box::type, form_control::type, UNKNOWN_WIDTH, form_option::value, box_border::width, box::width, width, gui_layout_table::width, box::x, and box::y.
Referenced by layout_inline_container().
|
static |
Layout list markers.
Definition at line 4396 of file layout.c.
References box::children, content_get_height(), content_get_width(), box::flags, font_plot_style_from_css(), box::height, layout__list_item_is_numerical(), layout__ordered_list_count(), layout__set_numerical_marker_text(), layout_lists(), box::length, line_height(), box::list_marker, MEASURED, box::next, box::object, box::style, box::text, UNKNOWN_WIDTH, content::width, box::width, box::x, and box::y.
Referenced by layout_document(), and layout_lists().
|
static |
Calculate minimum and maximum width of a block.
block | box of type BLOCK, INLINE_BLOCK, or TABLE_CELL |
font_func | font functions |
content | The HTML content being layed out. |
Definition at line 859 of file layout.c.
References BOX_BLOCK, box_dump(), BOX_FLEX, BOX_INLINE_BLOCK, BOX_INLINE_CONTAINER, BOX_INLINE_FLEX, BOX_TABLE, BOX_TABLE_CELL, calculate_mbp_width(), box::children, content_get_type(), content_get_width(), CONTENT_HTML, box::flags, box::gadget, GADGET_CHECKBOX, GADGET_FILE, GADGET_PASSWORD, GADGET_RADIO, GADGET_TEXTAREA, GADGET_TEXTBOX, HAS_HEIGHT, height, html_get_box_tree(), IFRAME, layout_minmax_block(), layout_minmax_inline_container(), layout_minmax_table(), LEFT, lh__box_is_flex_container(), lh__box_is_flex_item(), lh__box_is_float_box(), lh__flex_main_is_horizontal(), MAKE_HEIGHT, max, box::max_width, min, box::min_width, NEED_MIN, box::next, box::object, box::parent, RIGHT, box::style, box::type, form_control::type, UNKNOWN_MAX_WIDTH, and width.
Referenced by layout_document(), layout_minmax_block(), layout_minmax_line(), and layout_minmax_table().
|
static |
Calculate minimum and maximum width of an inline container.
inline_container | box of type INLINE_CONTAINER | |
[out] | has_height | set to true if container has height |
font_func | Font functions. |
Definition at line 811 of file layout.c.
References BOX_INLINE_CONTAINER, box::children, layout_minmax_line(), max, box::max_width, min, box::min_width, box::type, and UNKNOWN_MAX_WIDTH.
Referenced by layout_minmax_block().
|
static |
Calculate minimum and maximum width of a line.
first | a box in an inline container |
line_min | updated to minimum width of line starting at first |
line_max | updated to maximum width of line starting at first |
first_line | true iff this is the first line in the inline container |
line_has_height | updated to true or false, depending on line |
font_func | Font functions. |
Definition at line 463 of file layout.c.
References AUTO, BOX_BR, box_has_percentage_max_width(), BOX_INLINE, BOX_INLINE_BLOCK, BOX_INLINE_END, BOX_INLINE_FLEX, BOX_TABLE, calculate_mbp_width(), box::children, box::flags, font_plot_style_from_css(), box::gadget, GADGET_SELECT, HAS_HEIGHT, height, IFRAME, box::inline_end, form_control::items, layout_get_object_dimensions(), layout_minmax_block(), layout_minmax_table(), layout_text_indent(), LEFT, box::length, lh__box_is_float_box(), lh__box_is_inline_content(), lh__box_is_replace(), max, box::max_width, MEASURED, min, box::min_width, NEED_MIN, box::next, form_option::next, NSLOG, nsoption_bool, box::object, box::parent, REPLACE_DIM, RIGHT, SCROLLBAR_WIDTH, form_control::select, box::space, box::style, box::text, form_option::text, box::type, form_control::type, UNKNOWN_WIDTH, form_option::value, box::width, width, and gui_layout_table::width.
Referenced by layout_minmax_inline_container().
|
static |
Calculate minimum and maximum width of a table.
table | box of type TABLE |
font_func | Font functions |
content | The HTML content we are laying out. |
TODO: Handle colspan="0" correctly. It's currently converted to 1 in box normaisation
Definition at line 257 of file layout.c.
References box_dump(), BOX_TABLE_CELL, calculate_mbp_width(), box::children, box::col, box::columns, layout_minmax_block(), LEFT, column::max, max, box::max_width, column::min, min, box::min_width, box::next, NSLOG, RIGHT, box::start_column, box::style, table_calculate_column_types(), box::type, type, UNKNOWN_MAX_WIDTH, column::width, and width.
Referenced by layout_minmax_block(), and layout_minmax_line().
|
static |
Moves the children of a box by a specified amount.
box | top of tree of boxes |
x | the amount to move children by horizontally |
y | the amount to move children by vertically |
Definition at line 1579 of file layout.c.
References box::children, box::next, box::x, and box::y.
Referenced by layout_table().
|
static |
Find next block that current margin collapses to.
unit_len_ctx | Length conversion context |
box | box to start tree-order search from (top margin is included) |
block | box responsible for current block fromatting context |
viewport_height | height of viewport in px |
max_pos_margin | updated to to maximum positive margin encountered |
max_neg_margin | updated to to maximum negative margin encountered |
Definition at line 1139 of file layout.c.
References box::border, BOTTOM, BOX_BLOCK, BOX_INLINE_CONTAINER, box_is_first_child(), box::children, box::flags, layout_find_dimensions(), MAKE_HEIGHT, box::margin, box::next, box::object, box::padding, box::parent, box::style, TOP, box::type, box_border::width, and box::width.
Referenced by layout_block_context().
|
static |
Recursively layout and position absolutely positioned boxes.
box | tree of boxes to layout |
containing_block | current containing block |
cx | position of box relative to containing_block |
cy | position of box relative to containing_block |
content | memory pool for any new boxes |
Definition at line 4944 of file layout.c.
References BOX_BLOCK, BOX_FLEX, BOX_INLINE_BLOCK, BOX_INLINE_FLEX, BOX_TABLE, box::children, box::float_children, layout_absolute(), layout_position_absolute(), box::next, box::parent, box::style, box::type, box::x, and box::y.
Referenced by layout_document(), and layout_position_absolute().
|
static |
Adjust positions of relatively positioned boxes.
unit_len_ctx | Length conversion context |
root | box to adjust the position of |
fp | box which forms the block formatting context for children of "root" which are floats |
fx | x offset due to intervening relatively positioned boxes between current box, "root", and the block formatting context box, "fp", for float children of "root" |
fy | y offset due to intervening relatively positioned boxes between current box, "root", and the block formatting context box, "fp", for float children of "root" |
Definition at line 5092 of file layout.c.
References BOX_INLINE, BOX_TEXT, box::children, box::float_children, box::inline_end, layout_compute_relative_offset(), layout_position_relative(), box::next, box::next_float, root, box::style, box::type, box::x, and box::y.
Referenced by layout_document(), and layout_position_relative().
|
static |
Solve the width constraint as given in CSS 2.1 section 10.3.3.
box | Box to solve constraint for |
available_width | Max width available in pixels |
width | Current box width |
lm | Min left margin required to avoid floats in px. zero if not applicable |
rm | Min right margin required to avoid floats in px. zero if not applicable |
max_width | Box max-width ( -ve means no max-width to apply) |
min_width | Box min-width ( <=0 means no min-width to apply) |
Definition at line 1346 of file layout.c.
References AUTO, box::border, LEFT, box::margin, box::max_width, box::min_width, box::padding, box::parent, RIGHT, box::style, box_border::width, and width.
Referenced by layout_absolute(), layout_block_context(), and layout_block_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().
|
static |
Split a text box.
content | memory pool for any new boxes |
fstyle | style for text in text box |
split_box | box with text to split |
new_length | new length for text in split_box, after splitting |
new_width | new width for text in split_box, after splitting |
A new box is created and inserted into the box tree after split_box, containing the text after new_length excluding the initial space character.
Definition at line 2349 of file layout.c.
References CLONE, box::flags, box::last, box::length, MEASURED, box::next, NSLOG, box::parent, box::prev, PRIsizet, box::space, talloc_memdup, box::text, UNKNOWN_WIDTH, box::width, and gui_layout_table::width.
Referenced by layout_line().
|
static |
Calculate the text-indent length.
style | style of block |
width | width of containing block |
Definition at line 230 of file layout.c.
References width.
Referenced by layout_line(), and layout_minmax_line().
|
static |
Apply changes to box descendant_[xy][01] values due to given child.
unit_len_ctx | Length conversion context |
box | box to update |
child | a box, which may affect box's descendant bbox |
off_x | offset to apply to child->x coord to treat as child of box |
off_y | offset to apply to child->y coord to treat as child of box |
Definition at line 5237 of file layout.c.
References content_get_type(), CONTENT_HTML, box::descendant_x0, box::descendant_x1, box::descendant_y0, box::descendant_y1, layout_get_box_bbox(), box::object, box::style, box::x, and box::y.
Referenced by layout_calculate_descendant_bboxes().
|
static |
Calculate line height from a style.
Definition at line 2654 of file layout.c.
References line_height(), and box::style.
Referenced by form_redraw_select_menu(), form_select_menu_clicked(), layout_line(), layout_lists(), line_height(), ro_gui_wimp_event_process_window_menu_click(), textarea_redraw(), textplain_coords_from_range(), textplain_offset_from_coords(), and textplain_redraw().
|
static |
Position a float in the first available space.
c | float box to position |
width | available width |
cx | x coordinate relative to cont to place float right of |
y | y coordinate relative to cont to place float below |
cont | ancestor box which defines horizontal space, for floats |
Definition at line 2610 of file layout.c.
References BOX_FLOAT_LEFT, box::cached_place_below_level, find_sides(), box::float_children, box::height, NSLOG, box::type, box::width, width, box::x, and box::y.
Referenced by layout_line().
const css_border_color_func border_color_funcs[4] |
Array of per-side access functions for computed style border colors.
Definition at line 106 of file layout.c.
Referenced by layout_find_dimensions().
const css_border_style_func border_style_funcs[4] |
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().
const css_len_func border_width_funcs[4] |
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().
const css_len_func margin_funcs[4] |
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().
const css_len_func padding_funcs[4] |
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().