diff options
Diffstat (limited to 'src')
-rw-r--r-- | src/select/calc.c | 2 | ||||
-rw-r--r-- | src/select/computed.c | 14 | ||||
-rw-r--r-- | src/select/unit.c | 2 |
3 files changed, 11 insertions, 7 deletions
diff --git a/src/select/calc.c b/src/select/calc.c index 7e7fd1e..387188e 100644 --- a/src/select/calc.c +++ b/src/select/calc.c @@ -179,7 +179,7 @@ static css_error css__normalise_unit(const css_unit_ctx *unit_ctx, return CSS_INVALID; } *v = css_multiply_fixed(*v, pct100); - *v = css_divide_fixed(*v, INTTOFIX(100)); + *v = css_divide_fixed(*v, F_100); *u = UNIT_PX; return CSS_OK; } else if (*u == UNIT_CALC_NUMBER) { diff --git a/src/select/computed.c b/src/select/computed.c index 14e108d..3f5b8a7 100644 --- a/src/select/computed.c +++ b/src/select/computed.c @@ -702,7 +702,7 @@ uint8_t css_computed_max_width(const css_computed_style *style, return get_max_width(style, length, unit); } -uint8_t css_computed_width( +uint8_t css_computed_width_px( const css_computed_style *style, const css_unit_ctx *unit_ctx, int available_px, @@ -721,8 +721,10 @@ uint8_t css_computed_width( case CSS_WIDTH_SET: switch (unit) { case CSS_UNIT_CALC: - if (css_calculator_calculate(style->calc, unit_ctx, available_px, - value.calc, style, &unit, &value.value) == CSS_OK) { + if (css_calculator_calculate( + style->calc, unit_ctx, + available_px, value.calc, + style, &unit, &value.value) == CSS_OK) { type = CSS_WIDTH_SET; *px_out = FIXTOINT(value.value); } else { @@ -751,13 +753,15 @@ uint8_t css_computed_width( return type; } -uint8_t css_computed_width_static(const css_computed_style *style, +uint8_t css_computed_width(const css_computed_style *style, css_fixed *length, css_unit *unit) { css_fixed_or_calc length_ = {.value = 0}; uint8_t ret = get_width(style, &length_, unit); if (ret == CSS_WIDTH_SET) { - assert(*unit != CSS_UNIT_CALC); + if (*unit == CSS_UNIT_CALC) { + return CSS_WIDTH_AUTO; + } *length = length_.value; } return ret; diff --git a/src/select/unit.c b/src/select/unit.c index 5f0f179..75c33db 100644 --- a/src/select/unit.c +++ b/src/select/unit.c @@ -518,7 +518,7 @@ css_fixed css_unit_angle2deg(const css_unit unit, const css_fixed angle) if (unit == CSS_UNIT_GRAD) { return FMUL(angle, FLTTOFIX(0.9)); } else if (unit == CSS_UNIT_RAD) { - return FDIV(FMUL(angle, INTTOFIX(180)), F_PI); + return FDIV(FMUL(angle, F_180), F_PI); } else { /* Must be degrees as DEG/RAD/GRAD are all angle kinds */ return angle; |