49 if (css_computed_writing_mode(ctx->
root_style) ==
50 CSS_WRITING_MODE_HORIZONTAL_TB) {
58 if (css_computed_writing_mode(ctx->
root_style) ==
59 CSS_WRITING_MODE_HORIZONTAL_TB) {
66 if (ctx->
vh < ctx->
vw) {
73 if (ctx->
vh > ctx->
vw) {
92 assert(unit != CSS_UNIT_EM &&
93 unit != CSS_UNIT_EX &&
94 unit != CSS_UNIT_CAP &&
95 unit != CSS_UNIT_CH &&
96 unit != CSS_UNIT_IC &&
97 unit != CSS_UNIT_REM &&
98 unit != CSS_UNIT_RLH);
105 case CSS_UNIT_PX:
return FDIV(FMUL(length, F_72), F_96);
107 case CSS_UNIT_IN:
return FMUL(length, F_72);
109 case CSS_UNIT_CM:
return FMUL(length,
110 FDIV(F_72, FLTTOFIX(2.54)));
112 case CSS_UNIT_MM:
return FMUL(length,
113 FDIV(F_72, FLTTOFIX(25.4)));
115 case CSS_UNIT_Q:
return FMUL(length,
116 FDIV(F_72, FLTTOFIX(101.6)));
117 case CSS_UNIT_PT:
return length;
119 case CSS_UNIT_PC:
return FMUL(length, INTTOFIX(12));
120 case CSS_UNIT_VH:
return FDIV(FMUL(FDIV(FMUL(length, ctx->
vh), F_100), F_72), F_96);
121 case CSS_UNIT_VW:
return FDIV(FMUL(FDIV(FMUL(length,ctx->
vw), F_100), F_72), F_96);
133 const css_computed_style *style)
136 css_fixed px_per_unit;
147 css_fixed font_size = 0;
148 css_unit font_unit = CSS_UNIT_PT;
150 assert(style != NULL);
152 css_computed_font_size(style, &font_size, &font_unit);
158 if (font_size < FDIV(INTTOFIX(
nsoption_int(font_min_size)), F_10)) {
159 font_size = FDIV(INTTOFIX(
nsoption_int(font_min_size)), F_10);
164 px_per_unit = FDIV(FMUL(font_size, F_96), F_72);
169 px_per_unit = FMUL(px_per_unit, FLTTOFIX(0.6));
172 px_per_unit = FMUL(px_per_unit, FLTTOFIX(0.9));
175 px_per_unit = FMUL(px_per_unit, FLTTOFIX(0.4));
178 px_per_unit = FMUL(px_per_unit, FLTTOFIX(1.1));
193 px_per_unit = FDIV(F_96, FLTTOFIX(2.54));
197 px_per_unit = FDIV(F_96, FLTTOFIX(25.4));
201 px_per_unit = FDIV(F_96, FLTTOFIX(101.6));
205 px_per_unit = FDIV(F_96, F_72);
209 px_per_unit = FDIV(F_96, INTTOFIX(6));
213 css_fixed font_size = 0;
214 css_unit font_unit = CSS_UNIT_PT;
219 &font_size, &font_unit);
225 if (font_size < FDIV(INTTOFIX(
nsoption_int(font_min_size)), F_10)) {
226 font_size = FDIV(INTTOFIX(
nsoption_int(font_min_size)), F_10);
231 px_per_unit = FDIV(FMUL(font_size, F_96), F_72);
236 px_per_unit = FDIV(F_96, FDIV(
241 px_per_unit = FDIV(ctx->
vh, F_100);
244 px_per_unit = FDIV(ctx->
vw, F_100);
255 px_per_unit += F_0_5;
258 return FMUL(length, TRUNCATEFIX(px_per_unit));
css_fixed nscss_len2pt(const nscss_len_ctx *ctx, css_fixed length, css_unit unit)
Convert an absolute CSS length to points.
Length conversion context data.
#define nsoption_int(OPTION)
Get the value of an integer option.
Option reading and saving interface.
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.
const css_computed_style * root_style
Computed style for the document root element.
css_fixed nscss_screen_dpi
Screen DPI in fixed point units: defaults to 90, which RISC OS uses.
int vh
Viewport height in px.
static css_fixed nscss_pixels_css_to_physical(css_fixed css_pixels)
Convert css pixels to physical pixels.
int vw
Viewport width in px.
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.
css_fixed nscss_baseline_pixel_density
Medium screen density for device viewing distance.