24#ifndef NETSURF_HTML_LAYOUT_INTERNAL_H
25#define NETSURF_HTML_LAYOUT_INTERNAL_H
72 const css_computed_style *style,
73 css_fixed *length, css_unit *unit);
75 const css_computed_style *style);
77 const css_computed_style *style,
156 const css_computed_style *style)
163 return css_computed_position(b->
style) == CSS_POSITION_ABSOLUTE ||
164 css_computed_position(b->
style) == CSS_POSITION_FIXED;
169 const css_computed_style *style = flex->
style;
171 assert(style != NULL);
173 switch (css_computed_flex_direction(style)) {
175 case CSS_FLEX_DIRECTION_ROW:
176 case CSS_FLEX_DIRECTION_ROW_REVERSE:
178 case CSS_FLEX_DIRECTION_COLUMN:
179 case CSS_FLEX_DIRECTION_COLUMN_REVERSE:
186 switch (css_computed_flex_direction(flex->
style)) {
188 case CSS_FLEX_DIRECTION_ROW_REVERSE:
189 case CSS_FLEX_DIRECTION_COLUMN_REVERSE:
191 case CSS_FLEX_DIRECTION_ROW:
192 case CSS_FLEX_DIRECTION_COLUMN:
223 const struct box *flex,
234 const struct box *flex,
280 return css_computed_height(b->
style,
281 &length, &unit) == CSS_HEIGHT_AUTO;
283 return css_computed_width(b->
style,
284 &length, &unit) == CSS_WIDTH_AUTO;
289 const struct box *flex,
290 const struct box *item)
292 enum css_align_self_e align_self = css_computed_align_self(item->
style);
294 if (align_self == CSS_ALIGN_SELF_AUTO) {
295 align_self = css_computed_align_items(flex->
style);
314 const css_unit_ctx *unit_len_ctx,
315 const css_computed_style *style,
324 css_unit unit = CSS_UNIT_PX;
330 enum css_margin_e
type;
333 if (
type == CSS_MARGIN_SET) {
334 if (unit == CSS_UNIT_PCT) {
335 *frac += FIXTOFLT(FDIV(value, F_100));
337 *fixed += FIXTOINT(css_unit_len2device_px(
349 *fixed += FIXTOINT(css_unit_len2device_px(
358 if (unit == CSS_UNIT_PCT) {
359 *frac += FIXTOFLT(FDIV(value, F_100));
361 *fixed += FIXTOINT(css_unit_len2device_px(
383 const css_unit_ctx *unit_len_ctx,
389 enum css_box_sizing_e bs;
393 bs = css_computed_box_sizing(
box->
style);
395 if (bs == CSS_BOX_SIZING_BORDER_BOX) {
396 int orig = *dimension;
402 false,
true,
true, &fixed, &frac);
405 false,
true,
true, &fixed, &frac);
406 orig -= frac * available_width + fixed;
407 *dimension = orig > 0 ? orig : 0;
431 const css_unit_ctx *unit_len_ctx,
435 const css_computed_style *style,
446 struct box *containing_block = NULL;
450 if (css_computed_width_px(
style, unit_len_ctx,
451 available_width,
width) == CSS_WIDTH_SET) {
453 available_width,
true,
width);
460 enum css_height_e htype;
462 css_unit unit = CSS_UNIT_PX;
464 htype = css_computed_height(
style, &value, &unit);
466 if (htype == CSS_HEIGHT_SET) {
467 if (unit == CSS_UNIT_PCT) {
468 enum css_height_e cbhtype;
470 if (css_computed_position(
box->
style) ==
471 CSS_POSITION_ABSOLUTE &&
477 css_computed_position(
box->
style) !=
478 CSS_POSITION_ABSOLUTE &&
501 if (containing_block) {
503 css_unit u = CSS_UNIT_PX;
505 cbhtype = css_computed_height(
506 containing_block->
style,
510 if (containing_block &&
512 (css_computed_position(
box->
style) ==
513 CSS_POSITION_ABSOLUTE ||
514 cbhtype == CSS_HEIGHT_SET)) {
519 *
height = FPCT_OF_INT_TOINT(value,
520 containing_block->
height);
523 viewport_height >= 0) {
526 *
height = FPCT_OF_INT_TOINT(value,
534 *
height = FIXTOINT(css_unit_len2device_px(
544 available_width,
false,
height);
549 enum css_max_width_e
type;
551 css_unit unit = CSS_UNIT_PX;
553 type = css_computed_max_width(
style, &value, &unit);
555 if (
type == CSS_MAX_WIDTH_SET) {
556 if (unit == CSS_UNIT_PCT) {
560 *
max_width = FIXTOINT(css_unit_len2device_px(
576 enum css_min_width_e
type;
578 css_unit unit = CSS_UNIT_PX;
582 if (
type == CSS_MIN_WIDTH_SET) {
583 if (unit == CSS_UNIT_PCT) {
587 *
min_width = FIXTOINT(css_unit_len2device_px(
603 enum css_max_height_e
type;
605 css_unit unit = CSS_UNIT_PX;
607 type = css_computed_max_height(
style, &value, &unit);
609 if (
type == CSS_MAX_HEIGHT_SET) {
610 if (unit == CSS_UNIT_PCT) {
614 *max_height = FIXTOINT(css_unit_len2device_px(
625 enum css_min_height_e
type;
627 css_unit unit = CSS_UNIT_PX;
631 if (
type == CSS_MIN_HEIGHT_SET) {
632 if (unit == CSS_UNIT_PCT) {
636 *min_height = FIXTOINT(css_unit_len2device_px(
646 for (i = 0; i != 4; i++) {
648 enum css_margin_e
type = CSS_MARGIN_AUTO;
650 css_unit unit = CSS_UNIT_PX;
654 if (
type == CSS_MARGIN_SET) {
655 if (unit == CSS_UNIT_PCT) {
656 margin[i] = FPCT_OF_INT_TOINT(value,
659 margin[i] = FIXTOINT(css_unit_len2device_px(
670 css_unit unit = CSS_UNIT_PX;
674 if (unit == CSS_UNIT_PCT) {
675 padding[i] = FPCT_OF_INT_TOINT(value,
678 padding[i] = FIXTOINT(css_unit_len2device_px(
686 enum css_border_style_e bstyle = CSS_BORDER_STYLE_NONE;
689 css_unit unit = CSS_UNIT_PX;
698 if (bstyle == CSS_BORDER_STYLE_HIDDEN ||
699 bstyle == CSS_BORDER_STYLE_NONE)
709 if (css_computed_border_collapse(
style) ==
710 CSS_BORDER_COLLAPSE_COLLAPSE &&
static uint8_t ns_computed_min_height(const css_computed_style *style, css_fixed *length, css_unit *unit)
static uint8_t ns_computed_min_width(const css_computed_style *style, css_fixed *length, css_unit *unit)
static bool lh__flex_direction_reversed(const struct box *flex)
static bool lh__flex_main_is_horizontal(const struct box *flex)
static bool lh__box_is_object(const struct box *b)
Layout helper: Check whether box is an object.
static int lh__delta_outer_main(const struct box *flex, const struct box *b)
uint8_t(* css_border_style_func)(const css_computed_style *style)
static bool lh__box_is_flex_container(const struct box *b)
Layout helper: Check whether box takes part in inline flow.
static bool lh__box_is_replace(const struct box *b)
Layout helper: Check whether box is replaced.
bool layout_block_context(struct box *block, int viewport_height, html_content *content)
Layout a block formatting context.
const css_border_style_func border_style_funcs[4]
Array of per-side access functions for computed style border styles.
static int * lh__box_size_cross_ptr(bool horizontal, struct box *b)
static int * lh__box_size_main_ptr(bool horizontal, struct box *b)
bool layout_flex(struct box *flex, int available_width, html_content *content)
Layout a flex container.
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.
static bool lh__box_is_absolute(const struct box *b)
bool layout_table(struct box *table, int available_width, html_content *content)
Layout a table.
static bool lh__have_border(enum box_side side, const css_computed_style *style)
Layout helper: Check for CSS border on given side.
static int lh__box_size_main(bool horizontal, const struct box *b)
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.
const css_border_color_func border_color_funcs[4]
Array of per-side access functions for computed style border colors.
uint8_t(* css_len_func)(const css_computed_style *style, css_fixed *length, css_unit *unit)
const css_len_func border_width_funcs[4]
Array of per-side access functions for computed style border_widths.
static int lh__delta_outer_height(const struct box *b)
static int lh__box_size_cross(bool horizontal, const struct box *b)
static bool lh__box_is_inline_content(const struct box *b)
Layout helper: Check whether box is inline level.
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.
static enum css_align_self_e lh__box_align_self(const struct box *flex, const struct box *item)
static bool lh__box_is_flex_item(const struct box *b)
Layout helper: Check whether box takes part in inline flow.
static int lh__delta_outer_width(const struct box *b)
static bool lh__box_is_inline_level(const struct box *b)
Layout helper: Check whether box is inline level.
static int lh__delta_outer_cross(const struct box *flex, const struct box *b)
static int lh__non_auto_margin(const struct box *b, enum box_side side)
static bool lh__box_is_inline_flow(const struct box *b)
Layout helper: Check whether box takes part in inline flow.
uint8_t(* css_border_color_func)(const css_computed_style *style, css_color *color)
const css_len_func padding_funcs[4]
Array of per-side access functions for computed style paddings.
static bool lh__box_is_float_box(const struct box *b)
Layout helper: Check whether box is a float.
const css_len_func margin_funcs[4]
Array of per-side access functions for computed style margins.
static bool lh__box_size_cross_is_auto(bool horizontal, struct box *b)
Container for border values during table border calculations.
enum css_border_style_e style
border-style
css_fixed width
border-width length
css_color c
border-color value
Container for box border details.
int width
border-width (pixels)
struct box_border border[4]
Border: TOP, RIGHT, BOTTOM, LEFT.
int min_width
Width of box taking all line breaks (including margins etc).
int width
Width of content box (excluding padding etc.).
struct box * parent
Parent box, or NULL.
int height
Height of content box (excluding padding etc.).
struct box * float_container
If box is a float, points to box's containing block.
int margin[4]
Margin: TOP, RIGHT, BOTTOM, LEFT.
int max_width
Width that would be taken with no line breaks.
box_type type
Type of box.
css_computed_style * style
Style for this box.
struct hlcache_handle * object
Object in this box (usually an image), or NULL if none.
int padding[4]
Padding: TOP, RIGHT, BOTTOM, LEFT.
box_flags flags
Box flags.
struct form_control * gadget
Form control data, or NULL if not a form control.
Content which corresponds to a single URL.
Data specific to CONTENT_HTML.