summaryrefslogtreecommitdiff
path: root/src/select/unit.h
blob: e4d21dab2b82ffaf796f5a2f8e151401c3bd0803 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
/*
 * This file is part of LibCSS
 * Licensed under the MIT License,
 *                http://www.opensource.org/licenses/mit-license.php
 *
 * Copyright 2021 Michael Drake <tlsa@netsurf-browser.org>
 */

#ifndef css_select_unit_h_
#define css_select_unit_h_

#include <libcss/unit.h>

/**
 * Convert a length to CSS pixels for a media query context.
 *
 * \param[in]  media   Client media specification.
 * \param[in]  length  Length to convert.
 * \param[in]  unit    Current unit of length.
 * \return A length in CSS pixels.
 */
css_fixed css_unit_len2px_mq(
		const css_media *media,
		const css_fixed length,
		const css_unit unit);

/**
 * Convert relative font size units to absolute units.
 *
 * \param[in] ref_length         Reference font-size length or NULL.
 * \param[in] root_style         Root element style or NULL.
 * \param[in] font_size_default  Client default font size in CSS pixels.
 * \param[in,out] size           The length to convert.
 * \return CSS_OK on success, or appropriate error otherwise.
 */
css_error css_unit_compute_absolute_font_size(
		const css_hint_length *ref_length,
		const css_computed_style *root_style,
		css_fixed font_size_default,
		css_hint *size);

#endif