From 0cf10a040aea028c7dc81cf353da7a7af5331076 Mon Sep 17 00:00:00 2001 From: Michael Drake Date: Mon, 15 Mar 2021 16:56:59 +0000 Subject: Units: Remove units that nobody supports. --- docs/Bytecode | 23 ++++++++++------------- include/libcss/types.h | 25 +++++++++++-------------- src/bytecode/bytecode.h | 23 ++++++++++------------- src/parse/properties/font.c | 3 --- src/parse/properties/utils.c | 6 ------ src/select/helpers.h | 3 --- src/select/mq.h | 11 ----------- test/data/parse2/units.dat | 24 ------------------------ test/data/select/tests1.dat | 12 ++++++------ test/dump.h | 9 --------- test/dump_computed.h | 9 --------- 11 files changed, 37 insertions(+), 111 deletions(-) diff --git a/docs/Bytecode b/docs/Bytecode index d691923..4914e65 100644 --- a/docs/Bytecode +++ b/docs/Bytecode @@ -44,19 +44,16 @@ Length is a 32bit numeric value (as described above) and unit is as follows: 00000101 => mm 00000110 => pt 00000111 => pc - 00001000 => cap - 00001001 => ch - 00001010 => ic - 00001011 => rem - 00001100 => lh - 00001101 => rlh - 00001110 => vh - 00001111 => vw - 00010000 => vi - 00010001 => vb - 00010010 => vmin - 00010011 => vmax - 00010100 => q + 00001000 => ch + 00001001 => rem + 00001010 => lh + 00001011 => vh + 00001100 => vw + 00001101 => vi + 00001110 => vb + 00001111 => vmin + 00010000 => vmax + 00010001 => q bit 9 set => percentage unit bits 9-31: MBZ diff --git a/include/libcss/types.h b/include/libcss/types.h index d8ac494..1186c6f 100644 --- a/include/libcss/types.h +++ b/include/libcss/types.h @@ -88,19 +88,16 @@ typedef enum css_unit { CSS_UNIT_MM = 0x05, CSS_UNIT_PT = 0x06, CSS_UNIT_PC = 0x07, - CSS_UNIT_CAP = 0x08, - CSS_UNIT_CH = 0x09, - CSS_UNIT_IC = 0x0a, - CSS_UNIT_REM = 0x0b, - CSS_UNIT_LH = 0x0c, - CSS_UNIT_RLH = 0x0d, - CSS_UNIT_VH = 0x0e, - CSS_UNIT_VW = 0x0f, - CSS_UNIT_VI = 0x10, - CSS_UNIT_VB = 0x11, - CSS_UNIT_VMIN = 0x12, - CSS_UNIT_VMAX = 0x13, - CSS_UNIT_Q = 0x14, + CSS_UNIT_CH = 0x08, + CSS_UNIT_REM = 0x09, + CSS_UNIT_LH = 0x0a, + CSS_UNIT_VH = 0x0b, + CSS_UNIT_VW = 0x0c, + CSS_UNIT_VI = 0x0d, + CSS_UNIT_VB = 0x0e, + CSS_UNIT_VMIN = 0x0f, + CSS_UNIT_VMAX = 0x10, + CSS_UNIT_Q = 0x11, CSS_UNIT_PCT = 0x15, /* Percentage */ @@ -116,7 +113,7 @@ typedef enum css_unit { } css_unit; /** - * Media orienations + * Media orientations */ typedef enum css_media_orientation { CSS_MEDIA_ORIENTATION_PORTRAIT = 0, diff --git a/src/bytecode/bytecode.h b/src/bytecode/bytecode.h index 7518281..7f5ea9d 100644 --- a/src/bytecode/bytecode.h +++ b/src/bytecode/bytecode.h @@ -34,19 +34,16 @@ typedef enum unit { UNIT_MM = (1u << 8) + 5, UNIT_PT = (1u << 8) + 6, UNIT_PC = (1u << 8) + 7, - UNIT_CAP = (1u << 8) + 8, - UNIT_CH = (1u << 8) + 9, - UNIT_IC = (1u << 8) + 10, - UNIT_REM = (1u << 8) + 11, - UNIT_LH = (1u << 8) + 12, - UNIT_RLH = (1u << 8) + 13, - UNIT_VH = (1u << 8) + 14, - UNIT_VW = (1u << 8) + 15, - UNIT_VI = (1u << 8) + 16, - UNIT_VB = (1u << 8) + 17, - UNIT_VMIN = (1u << 8) + 18, - UNIT_VMAX = (1u << 8) + 19, - UNIT_Q = (1u << 8) + 20, + UNIT_CH = (1u << 8) + 8, + UNIT_REM = (1u << 8) + 9, + UNIT_LH = (1u << 8) + 10, + UNIT_VH = (1u << 8) + 11, + UNIT_VW = (1u << 8) + 12, + UNIT_VI = (1u << 8) + 13, + UNIT_VB = (1u << 8) + 14, + UNIT_VMIN = (1u << 8) + 15, + UNIT_VMAX = (1u << 8) + 16, + UNIT_Q = (1u << 8) + 17, UNIT_PCT = (1 << 9), diff --git a/src/parse/properties/font.c b/src/parse/properties/font.c index 681c613..5010242 100644 --- a/src/parse/properties/font.c +++ b/src/parse/properties/font.c @@ -27,12 +27,9 @@ static inline uint32_t css__to_parse_unit(css_unit u) case CSS_UNIT_MM: return UNIT_MM; case CSS_UNIT_PT: return UNIT_PT; case CSS_UNIT_PC: return UNIT_PC; - case CSS_UNIT_CAP: return UNIT_CAP; case CSS_UNIT_CH: return UNIT_CH; - case CSS_UNIT_IC: return UNIT_IC; case CSS_UNIT_REM: return UNIT_REM; case CSS_UNIT_LH: return UNIT_LH; - case CSS_UNIT_RLH: return UNIT_RLH; case CSS_UNIT_VH: return UNIT_VH; case CSS_UNIT_VW: return UNIT_VW; case CSS_UNIT_VI: return UNIT_VI; diff --git a/src/parse/properties/utils.c b/src/parse/properties/utils.c index 707a22b..1e184f8 100644 --- a/src/parse/properties/utils.c +++ b/src/parse/properties/utils.c @@ -1032,12 +1032,8 @@ css_error css__parse_unit_keyword(const char *ptr, size_t len, uint32_t *unit) *unit = UNIT_DEG; else if (strncasecmp(ptr, "rad", 3) == 0) *unit = UNIT_RAD; - else if (strncasecmp(ptr, "cap", 3) == 0) - *unit = UNIT_CAP; else if (strncasecmp(ptr, "rem", 3) == 0) *unit = UNIT_REM; - else if (strncasecmp(ptr, "rlh", 3) == 0) - *unit = UNIT_RLH; else if (strncasecmp(ptr, "dpi", 3) == 0) *unit = UNIT_DPI; else @@ -1065,8 +1061,6 @@ css_error css__parse_unit_keyword(const char *ptr, size_t len, uint32_t *unit) *unit = UNIT_PC; else if (strncasecmp(ptr, "ch", 2) == 0) *unit = UNIT_CH; - else if (strncasecmp(ptr, "ic", 2) == 0) - *unit = UNIT_IC; else if (strncasecmp(ptr, "lh", 2) == 0) *unit = UNIT_LH; else if (strncasecmp(ptr, "vh", 2) == 0) diff --git a/src/select/helpers.h b/src/select/helpers.h index ba2e3be..19ff7de 100644 --- a/src/select/helpers.h +++ b/src/select/helpers.h @@ -22,12 +22,9 @@ static inline css_unit css__to_css_unit(uint32_t u) case UNIT_MM: return CSS_UNIT_MM; case UNIT_PT: return CSS_UNIT_PT; case UNIT_PC: return CSS_UNIT_PC; - case UNIT_CAP: return CSS_UNIT_CAP; case UNIT_CH: return CSS_UNIT_CH; - case UNIT_IC: return CSS_UNIT_IC; case UNIT_REM: return CSS_UNIT_REM; case UNIT_LH: return CSS_UNIT_LH; - case UNIT_RLH: return CSS_UNIT_RLH; case UNIT_VH: return CSS_UNIT_VH; case UNIT_VW: return CSS_UNIT_VW; case UNIT_VI: return CSS_UNIT_VI; diff --git a/src/select/mq.h b/src/select/mq.h index 79303e9..6f98387 100644 --- a/src/select/mq.h +++ b/src/select/mq.h @@ -42,9 +42,7 @@ static inline css_fixed css_len2px( switch (unit) { case CSS_UNIT_EM: case CSS_UNIT_EX: - case CSS_UNIT_CAP: case CSS_UNIT_CH: - case CSS_UNIT_IC: { px_per_unit = FDIV(FMUL(media->client_font_size, F_96), F_72); @@ -53,15 +51,9 @@ static inline css_fixed css_len2px( case CSS_UNIT_EX: px_per_unit = FMUL(px_per_unit, FLTTOFIX(0.6)); break; - case CSS_UNIT_CAP: - px_per_unit = FMUL(px_per_unit, FLTTOFIX(0.9)); - break; case CSS_UNIT_CH: px_per_unit = FMUL(px_per_unit, FLTTOFIX(0.4)); break; - case CSS_UNIT_IC: - px_per_unit = FMUL(px_per_unit, FLTTOFIX(1.1)); - break; default: break; } @@ -90,9 +82,6 @@ static inline css_fixed css_len2px( case CSS_UNIT_REM: px_per_unit = FDIV(FMUL(media->client_font_size, F_96), F_72); break; - case CSS_UNIT_RLH: - px_per_unit = media->client_line_height; - break; case CSS_UNIT_VH: px_per_unit = FDIV(media->height, F_100); break; diff --git a/test/data/parse2/units.dat b/test/data/parse2/units.dat index 1052dc5..800df75 100644 --- a/test/data/parse2/units.dat +++ b/test/data/parse2/units.dat @@ -69,14 +69,6 @@ | width: 10pc #reset -#data -* { width: 10cap; } -#errors -#expected -| * -| width: 10cap -#reset - #data * { width: 10ch; } #errors @@ -85,14 +77,6 @@ | width: 10ch #reset -#data -* { width: 10ic; } -#errors -#expected -| * -| width: 10ic -#reset - #data * { width: 10rem; } #errors @@ -109,14 +93,6 @@ | width: 10lh #reset -#data -* { width: 10rlh; } -#errors -#expected -| * -| width: 10rlh -#reset - #data * { width: 10vh; } #errors diff --git a/test/data/select/tests1.dat b/test/data/select/tests1.dat index 1a91e82..eaf37d7 100644 --- a/test/data/select/tests1.dat +++ b/test/data/select/tests1.dat @@ -12419,7 +12419,7 @@ z-index: auto #tree | div* #ua -div { width: 10cap; } +div { width: 10em; } #errors #expected align-content: stretch @@ -12519,7 +12519,7 @@ unicode-bidi: normal vertical-align: baseline visibility: visible white-space: normal -width: 10cap +width: 10em word-spacing: normal writing-mode: horizontal-tb z-index: auto @@ -12637,7 +12637,7 @@ z-index: auto #tree | div* #ua -div { width: 10ic; } +div { width: 10ch; } #errors #expected align-content: stretch @@ -12737,7 +12737,7 @@ unicode-bidi: normal vertical-align: baseline visibility: visible white-space: normal -width: 10ic +width: 10ch word-spacing: normal writing-mode: horizontal-tb z-index: auto @@ -12964,7 +12964,7 @@ z-index: auto #tree | div* #ua -div { width: 10rlh; } +div { width: 10rem; } #errors #expected align-content: stretch @@ -13064,7 +13064,7 @@ unicode-bidi: normal vertical-align: baseline visibility: visible white-space: normal -width: 10rlh +width: 10rem word-spacing: normal writing-mode: horizontal-tb z-index: auto diff --git a/test/dump.h b/test/dump.h index d67bb2a..79819e0 100644 --- a/test/dump.h +++ b/test/dump.h @@ -584,24 +584,15 @@ static void dump_unit(css_fixed val, uint32_t unit, char **ptr) case UNIT_PC: *ptr += sprintf(*ptr, "pc"); break; - case UNIT_CAP: - *ptr += sprintf(*ptr, "cap"); - break; case UNIT_CH: *ptr += sprintf(*ptr, "ch"); break; - case UNIT_IC: - *ptr += sprintf(*ptr, "ic"); - break; case UNIT_REM: *ptr += sprintf(*ptr, "rem"); break; case UNIT_LH: *ptr += sprintf(*ptr, "lh"); break; - case UNIT_RLH: - *ptr += sprintf(*ptr, "rlh"); - break; case UNIT_VH: *ptr += sprintf(*ptr, "vh"); break; diff --git a/test/dump_computed.h b/test/dump_computed.h index b0c8bda..8ac6424 100644 --- a/test/dump_computed.h +++ b/test/dump_computed.h @@ -105,24 +105,15 @@ static size_t dump_css_unit(css_fixed val, css_unit unit, char *ptr, size_t len) case CSS_UNIT_PC: ret += snprintf(ptr + ret, len - ret, "pc"); break; - case CSS_UNIT_CAP: - ret += snprintf(ptr + ret, len - ret, "cap"); - break; case CSS_UNIT_CH: ret += snprintf(ptr + ret, len - ret, "ch"); break; - case CSS_UNIT_IC: - ret += snprintf(ptr + ret, len - ret, "ic"); - break; case CSS_UNIT_REM: ret += snprintf(ptr + ret, len - ret, "rem"); break; case CSS_UNIT_LH: ret += snprintf(ptr + ret, len - ret, "lh"); break; - case CSS_UNIT_RLH: - ret += snprintf(ptr + ret, len - ret, "rlh"); - break; case CSS_UNIT_VH: ret += snprintf(ptr + ret, len - ret, "vh"); break; -- cgit v1.2.3