NetSurf
utils.h
Go to the documentation of this file.
1/*
2 * Copyright 2009 John-Mark Bell <jmb@netsurf-browser.org>
3 *
4 * This file is part of NetSurf, http://www.netsurf-browser.org/
5 *
6 * NetSurf is free software; you can redistribute it and/or modify
7 * it under the terms of the GNU General Public License as published by
8 * the Free Software Foundation; version 2 of the License.
9 *
10 * NetSurf is distributed in the hope that it will be useful,
11 * but WITHOUT ANY WARRANTY; without even the implied warranty of
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 * GNU General Public License for more details.
14 *
15 * You should have received a copy of the GNU General Public License
16 * along with this program. If not, see <http://www.gnu.org/licenses/>.
17 */
18
19#ifndef NETSURF_CSS_UTILS_H_
20#define NETSURF_CSS_UTILS_H_
21
22#include <libcss/libcss.h>
23
24#include "netsurf/css.h"
25
26/** DPI of the screen, in fixed point units */
27extern css_fixed nscss_screen_dpi;
28
29/**
30 * Temporary helper wrappers for for libcss computed style getter, while
31 * we don't support all values of display.
32 */
33static inline uint8_t ns_computed_display(
34 const css_computed_style *style, bool root)
35{
36 uint8_t value = css_computed_display(style, root);
37
38 switch (value) {
39 case CSS_DISPLAY_GRID:
40 return CSS_DISPLAY_BLOCK;
41
42 case CSS_DISPLAY_INLINE_GRID:
43 return CSS_DISPLAY_INLINE_BLOCK;
44
45 default:
46 break;
47 }
48
49 return value;
50}
51
52/**
53 * Temporary helper wrappers for for libcss computed style getter, while
54 * we don't support all values of display.
55 */
56static inline uint8_t ns_computed_display_static(
57 const css_computed_style *style)
58{
59 uint8_t value = css_computed_display_static(style);
60
61 switch (value) {
62 case CSS_DISPLAY_GRID:
63 return CSS_DISPLAY_BLOCK;
64
65 case CSS_DISPLAY_INLINE_GRID:
66 return CSS_DISPLAY_INLINE_BLOCK;
67
68 default:
69 break;
70 }
71
72 return value;
73}
74
75static inline uint8_t ns_computed_min_height(
76 const css_computed_style *style,
77 css_fixed *length, css_unit *unit)
78{
79 uint8_t value = css_computed_min_height(style, length, unit);
80
81 if (value == CSS_MIN_HEIGHT_AUTO) {
82 value = CSS_MIN_HEIGHT_SET;
83 *length = 0;
84 *unit = CSS_UNIT_PX;
85 }
86
87 return value;
88}
89
90
91static inline uint8_t ns_computed_min_width(
92 const css_computed_style *style,
93 css_fixed *length, css_unit *unit)
94{
95 uint8_t value = css_computed_min_width(style, length, unit);
96
97 if (value == CSS_MIN_WIDTH_AUTO) {
98 value = CSS_MIN_WIDTH_SET;
99 *length = 0;
100 *unit = CSS_UNIT_PX;
101 }
102
103 return value;
104}
105
106#endif
static uint8_t ns_computed_display(const css_computed_style *style, bool root)
Temporary helper wrappers for for libcss computed style getter, while we don't support all values of ...
Definition: utils.h:33
css_fixed nscss_screen_dpi
DPI of the screen, in fixed point units.
Definition: css.c:44
static uint8_t ns_computed_min_height(const css_computed_style *style, css_fixed *length, css_unit *unit)
Definition: utils.h:75
static uint8_t ns_computed_min_width(const css_computed_style *style, css_fixed *length, css_unit *unit)
Definition: utils.h:91
static uint8_t ns_computed_display_static(const css_computed_style *style)
Temporary helper wrappers for for libcss computed style getter, while we don't support all values of ...
Definition: utils.h:56
static struct directory * root
Definition: filename.c:55
Netsurf core css API.