CSS: Update to latest libcss: Remove weird units.

The 'rlh', 'ic' and 'cap' units were never implemented by anyone.
This commit is contained in:
Michael Drake 2021-03-15 17:03:37 +00:00 committed by Michael Drake
parent a6e825833d
commit 638a408dde
3 changed files with 2 additions and 46 deletions

View File

@ -113,24 +113,15 @@ static void dump_css_unit(FILE *stream, css_fixed val, css_unit unit)
case CSS_UNIT_KHZ: case CSS_UNIT_KHZ:
fprintf(stream, "kHz"); fprintf(stream, "kHz");
break; break;
case CSS_UNIT_CAP:
fprintf(stream, "cap");
break;
case CSS_UNIT_CH: case CSS_UNIT_CH:
fprintf(stream, "ch"); fprintf(stream, "ch");
break; break;
case CSS_UNIT_IC:
fprintf(stream, "ic");
break;
case CSS_UNIT_REM: case CSS_UNIT_REM:
fprintf(stream, "rem"); fprintf(stream, "rem");
break; break;
case CSS_UNIT_LH: case CSS_UNIT_LH:
fprintf(stream, "lh"); fprintf(stream, "lh");
break; break;
case CSS_UNIT_RLH:
fprintf(stream, "rlh");
break;
case CSS_UNIT_VH: case CSS_UNIT_VH:
fprintf(stream, "vh"); fprintf(stream, "vh");
break; break;

View File

@ -423,9 +423,7 @@ css_error nscss_compute_font_size(void *pw, const css_hint *parent,
size->data.length.unit = parent_size.unit; size->data.length.unit = parent_size.unit;
} else if (size->data.length.unit == CSS_UNIT_EM || } else if (size->data.length.unit == CSS_UNIT_EM ||
size->data.length.unit == CSS_UNIT_EX || size->data.length.unit == CSS_UNIT_EX ||
size->data.length.unit == CSS_UNIT_CAP || size->data.length.unit == CSS_UNIT_CH) {
size->data.length.unit == CSS_UNIT_CH ||
size->data.length.unit == CSS_UNIT_IC) {
size->data.length.value = size->data.length.value =
FMUL(size->data.length.value, parent_size.value); FMUL(size->data.length.value, parent_size.value);
@ -435,21 +433,11 @@ css_error nscss_compute_font_size(void *pw, const css_hint *parent,
size->data.length.value = FMUL(size->data.length.value, size->data.length.value = FMUL(size->data.length.value,
FLTTOFIX(0.6)); FLTTOFIX(0.6));
break; break;
case CSS_UNIT_CAP:
/* Height of captals. 1cap = 0.9em in NetSurf. */
size->data.length.value = FMUL(size->data.length.value,
FLTTOFIX(0.9));
break;
case CSS_UNIT_CH: case CSS_UNIT_CH:
/* Width of '0'. 1ch = 0.4em in NetSurf. */ /* Width of '0'. 1ch = 0.4em in NetSurf. */
size->data.length.value = FMUL(size->data.length.value, size->data.length.value = FMUL(size->data.length.value,
FLTTOFIX(0.4)); FLTTOFIX(0.4));
break; break;
case CSS_UNIT_IC:
/* Width of U+6C43. 1ic = 1.1em in NetSurf. */
size->data.length.value = FMUL(size->data.length.value,
FLTTOFIX(1.1));
break;
default: default:
/* No scaling required for EM. */ /* No scaling required for EM. */
break; break;
@ -473,12 +461,6 @@ css_error nscss_compute_font_size(void *pw, const css_hint *parent,
size->data.length.value, size->data.length.value,
parent_size.value); parent_size.value);
} }
} else if (size->data.length.unit == CSS_UNIT_RLH) {
/** TODO: Convert root element line-height to absolute value. */
size->data.length.value = FMUL(size->data.length.value, FDIV(
INTTOFIX(nsoption_int(font_size)),
INTTOFIX(10)));
size->data.length.unit = CSS_UNIT_PT;
} }
size->status = CSS_FONT_SIZE_DIMENSION; size->status = CSS_FONT_SIZE_DIMENSION;

View File

@ -91,11 +91,8 @@ css_fixed nscss_len2pt(
/* Length must not be relative */ /* Length must not be relative */
assert(unit != CSS_UNIT_EM && assert(unit != CSS_UNIT_EM &&
unit != CSS_UNIT_EX && unit != CSS_UNIT_EX &&
unit != CSS_UNIT_CAP &&
unit != CSS_UNIT_CH && unit != CSS_UNIT_CH &&
unit != CSS_UNIT_IC && unit != CSS_UNIT_REM);
unit != CSS_UNIT_REM &&
unit != CSS_UNIT_RLH);
unit = css_utils__fudge_viewport_units(ctx, unit); unit = css_utils__fudge_viewport_units(ctx, unit);
@ -140,9 +137,7 @@ css_fixed nscss_len2px(
switch (unit) { switch (unit) {
case CSS_UNIT_EM: case CSS_UNIT_EM:
case CSS_UNIT_EX: case CSS_UNIT_EX:
case CSS_UNIT_CAP:
case CSS_UNIT_CH: case CSS_UNIT_CH:
case CSS_UNIT_IC:
{ {
css_fixed font_size = 0; css_fixed font_size = 0;
css_unit font_unit = CSS_UNIT_PT; css_unit font_unit = CSS_UNIT_PT;
@ -168,15 +163,9 @@ css_fixed nscss_len2px(
case CSS_UNIT_EX: case CSS_UNIT_EX:
px_per_unit = FMUL(px_per_unit, FLTTOFIX(0.6)); px_per_unit = FMUL(px_per_unit, FLTTOFIX(0.6));
break; break;
case CSS_UNIT_CAP:
px_per_unit = FMUL(px_per_unit, FLTTOFIX(0.9));
break;
case CSS_UNIT_CH: case CSS_UNIT_CH:
px_per_unit = FMUL(px_per_unit, FLTTOFIX(0.4)); px_per_unit = FMUL(px_per_unit, FLTTOFIX(0.4));
break; break;
case CSS_UNIT_IC:
px_per_unit = FMUL(px_per_unit, FLTTOFIX(1.1));
break;
default: break; default: break;
} }
} }
@ -231,12 +220,6 @@ css_fixed nscss_len2px(
px_per_unit = FDIV(FMUL(font_size, F_96), F_72); px_per_unit = FDIV(FMUL(font_size, F_96), F_72);
break; break;
} }
/* 1rlh = <user_font_size>pt => 1rlh = (DPI/user_font_size)px */
case CSS_UNIT_RLH:
px_per_unit = FDIV(F_96, FDIV(
INTTOFIX(nsoption_int(font_size)),
INTTOFIX(10)));
break;
case CSS_UNIT_VH: case CSS_UNIT_VH:
px_per_unit = FDIV(ctx->vh, F_100); px_per_unit = FDIV(ctx->vh, F_100);
break; break;