NetSurf
Functions | Variables
utils.c File Reference
#include <assert.h>
#include "utils/nsoption.h"
#include "utils/log.h"
#include "css/utils.h"
Include dependency graph for utils.c:

Go to the source code of this file.

Functions

static css_unit css_utils__fudge_viewport_units (const nscss_len_ctx *ctx, css_unit unit)
 Map viewport-relative length units to either vh or vw. More...
 
css_fixed nscss_len2pt (const nscss_len_ctx *ctx, css_fixed length, css_unit unit)
 Convert an absolute CSS length to points. More...
 
css_fixed nscss_len2px (const nscss_len_ctx *ctx, css_fixed length, css_unit unit, const css_computed_style *style)
 Convert a CSS length to pixels. More...
 

Variables

css_fixed nscss_screen_dpi = F_90
 Screen DPI in fixed point units: defaults to 90, which RISC OS uses. More...
 
css_fixed nscss_baseline_pixel_density = F_96
 Medium screen density for device viewing distance. More...
 

Function Documentation

◆ css_utils__fudge_viewport_units()

static css_unit css_utils__fudge_viewport_units ( const nscss_len_ctx ctx,
css_unit  unit 
)
inlinestatic

Map viewport-relative length units to either vh or vw.

Non-viewport-relative units are unchanged.

Parameters
[in]ctxLength conversion context.
[in]unitUnit to map.
Returns
the mapped unit.

Definition at line 42 of file utils.c.

References nscss_len_ctx::root_style, nscss_len_ctx::vh, and nscss_len_ctx::vw.

Referenced by nscss_len2pt(), and nscss_len2px().

Here is the caller graph for this function:

◆ nscss_len2pt()

css_fixed nscss_len2pt ( const nscss_len_ctx ctx,
css_fixed  length,
css_unit  unit 
)

Convert an absolute CSS length to points.

Parameters
[in]ctxLength conversion context.
[in]lengthAbsolute CSS length.
[in]unitUnit of the length.
Returns
length in points

Definition at line 86 of file utils.c.

References css_utils__fudge_viewport_units(), nscss_len_ctx::vh, and nscss_len_ctx::vw.

Referenced by font_plot_style_from_css(), and nscss_len2px().

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

◆ nscss_len2px()

css_fixed nscss_len2px ( const nscss_len_ctx ctx,
css_fixed  length,
css_unit  unit,
const css_computed_style *  style 
)

Convert a CSS length to pixels.

Parameters
[in]ctxLength conversion context.
[in]lengthLength to convert.
[in]unitCorresponding unit.
[in]styleComputed style applying to length. May be NULL if unit is not em, ex, cap, ch, or ic.
Returns
length in pixels

Definition at line 129 of file utils.c.

References css_utils__fudge_viewport_units(), nscss_len2pt(), nscss_pixels_css_to_physical(), nsoption_int, nscss_len_ctx::root_style, nscss_len_ctx::vh, and nscss_len_ctx::vw.

Referenced by box_contains_point(), calculate_mbp_width(), html_get_dimensions(), html_object_callback(), html_redraw_background(), html_redraw_box(), html_redraw_inline_background(), layout_apply_minmax_height(), layout_block_context(), layout_compute_offsets(), layout_find_dimensions(), layout_float_find_dimensions(), layout_get_box_bbox(), layout_line(), layout_minmax_block(), layout_minmax_line(), layout_minmax_table(), layout_table(), layout_text_indent(), line_height(), print_make_settings(), table_border_is_more_eyecatching(), table_calculate_column_types(), table_cell_top_process_group(), table_cell_top_process_row(), table_cell_top_process_table(), table_used_border_for_cell(), 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 call graph for this function:
Here is the caller graph for this function:

Variable Documentation

◆ nscss_baseline_pixel_density

css_fixed nscss_baseline_pixel_density = F_96

Medium screen density for device viewing distance.

Definition at line 31 of file utils.c.

Referenced by nscss_pixels_css_to_physical(), and nscss_pixels_physical_to_css().

◆ nscss_screen_dpi

css_fixed nscss_screen_dpi = F_90

Screen DPI in fixed point units: defaults to 90, which RISC OS uses.

DPI of the screen, in fixed point units.

Definition at line 28 of file utils.c.

Referenced by browser_get_dpi(), browser_set_dpi(), form_open_select_menu(), nscss_pixels_css_to_physical(), nscss_pixels_physical_to_css(), page_info__measure_text_entry(), textarea_create(), textarea_setup_text_offsets(), textplain_line_height(), and treeview_init().