summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJohn-Mark Bell <jmb@netsurf-browser.org>2017-02-04 17:57:47 (GMT)
committer John-Mark Bell <jmb@netsurf-browser.org>2017-02-04 17:57:47 (GMT)
commit40936ea51e4a3d6b0ac0a3a679519275e91544d7 (patch)
treec968f1d0736e58b398dbea91a9f2463e457c186e
parent7c57ceadc3a6076914242783582581095283b63b (diff)
downloadlibcss-40936ea51e4a3d6b0ac0a3a679519275e91544d7.tar.gz
libcss-40936ea51e4a3d6b0ac0a3a679519275e91544d7.tar.bz2
Units: parse new unit names
-rw-r--r--src/bytecode/bytecode.h20
-rw-r--r--src/parse/properties/utils.c32
2 files changed, 51 insertions, 1 deletions
diff --git a/src/bytecode/bytecode.h b/src/bytecode/bytecode.h
index 4ac3dfb..cd93eb2 100644
--- a/src/bytecode/bytecode.h
+++ b/src/bytecode/bytecode.h
@@ -32,6 +32,18 @@ typedef enum unit {
UNIT_MM = 5,
UNIT_PT = 6,
UNIT_PC = 7,
+ UNIT_Q = 8,
+ UNIT_CH = 9,
+ UNIT_IC = 10,
+ UNIT_REM = 11,
+ UNIT_LH = 12,
+ UNIT_RLH = 13,
+ UNIT_VW = 14,
+ UNIT_VH = 15,
+ UNIT_VI = 16,
+ UNIT_VB = 17,
+ UNIT_VMIN = 18,
+ UNIT_VMAX = 19,
UNIT_PCT = (1 << 8),
@@ -39,6 +51,7 @@ typedef enum unit {
UNIT_DEG = (1 << 9) + 0,
UNIT_GRAD = (1 << 9) + 1,
UNIT_RAD = (1 << 9) + 2,
+ UNIT_TURN = (1 << 9) + 3,
UNIT_TIME = (1 << 10),
UNIT_MS = (1 << 10) + 0,
@@ -46,7 +59,12 @@ typedef enum unit {
UNIT_FREQ = (1 << 11),
UNIT_HZ = (1 << 11) + 0,
- UNIT_KHZ = (1 << 11) + 1
+ UNIT_KHZ = (1 << 11) + 1,
+
+ UNIT_RESOLUTION = (1 << 12),
+ UNIT_DPI = (1 << 12) + 0,
+ UNIT_DPCM = (1 << 12) + 1,
+ UNIT_DPPX = (1 << 12) + 2,
} unit;
typedef uint32_t colour;
diff --git a/src/parse/properties/utils.c b/src/parse/properties/utils.c
index 82dacf8..97583c6 100644
--- a/src/parse/properties/utils.c
+++ b/src/parse/properties/utils.c
@@ -1007,6 +1007,16 @@ css_error css__parse_unit_keyword(const char *ptr, size_t len, uint32_t *unit)
if (len == 4) {
if (strncasecmp(ptr, "grad", 4) == 0)
*unit = UNIT_GRAD;
+ else if (strncasecmp(ptr, "turn", 4) == 0)
+ *unit = UNIT_TURN;
+ else if (strncasecmp(ptr, "dppx", 4) == 0)
+ *unit = UNIT_DPPX;
+ else if (strncasecmp(ptr, "dpcm", 4) == 0)
+ *unit = UNIT_DPCM;
+ else if (strncasecmp(ptr, "vmin", 4) == 0)
+ *unit = UNIT_VMIN;
+ else if (strncasecmp(ptr, "vmax", 4) == 0)
+ *unit = UNIT_VMAX;
else
return CSS_INVALID;
} else if (len == 3) {
@@ -1016,6 +1026,12 @@ 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, "dpi", 3) == 0)
+ *unit = UNIT_DPI;
+ else if (strncasecmp(ptr, "rlh", 3) == 0)
+ *unit = UNIT_RLH;
+ else if (strncasecmp(ptr, "rem", 3) == 0)
+ *unit = UNIT_REM;
else
return CSS_INVALID;
} else if (len == 2) {
@@ -1039,11 +1055,27 @@ css_error css__parse_unit_keyword(const char *ptr, size_t len, uint32_t *unit)
*unit = UNIT_PT;
else if (strncasecmp(ptr, "pc", 2) == 0)
*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, "vw", 2) == 0)
+ *unit = UNIT_VW;
+ else if (strncasecmp(ptr, "vh", 2) == 0)
+ *unit = UNIT_VH;
+ else if (strncasecmp(ptr, "vi", 2) == 0)
+ *unit = UNIT_VI;
+ else if (strncasecmp(ptr, "vb", 2) == 0)
+ *unit = UNIT_VB;
else
return CSS_INVALID;
} else if (len == 1) {
if (strncasecmp(ptr, "s", 1) == 0)
*unit = UNIT_S;
+ else if (strncasecmp(ptr, "Q", 1) == 0)
+ *unit = UNIT_Q;
else
return CSS_INVALID;
} else