summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMichael Drake <Michael Drake tlsa@netsurf-browser.org>2020-12-04 13:39:28 +0000
committerMichael Drake <Michael Drake tlsa@netsurf-browser.org>2020-12-04 13:41:33 +0000
commite8238ac2dab2a9c8cd31e7f66504218cf90c4d23 (patch)
tree4e5c33647da6f2334eece2b2cf6858d4be100b1e
parent03ab48a3171d358d50d0d97331a64a79c084521b (diff)
downloadlibcss-master.tar.gz
libcss-master.tar.bz2
select: Split out bytecode to unit conversion helper.HEADmaster
-rw-r--r--src/select/helpers.h51
-rw-r--r--src/select/mq.h3
-rw-r--r--src/select/properties/helpers.c39
-rw-r--r--src/select/properties/helpers.h4
4 files changed, 54 insertions, 43 deletions
diff --git a/src/select/helpers.h b/src/select/helpers.h
new file mode 100644
index 0000000..ba2e3be
--- /dev/null
+++ b/src/select/helpers.h
@@ -0,0 +1,51 @@
+/*
+ * This file is part of LibCSS
+ * Licensed under the MIT License,
+ * http://www.opensource.org/licenses/mit-license.php
+ * Copyright 2009 John-Mark Bell <jmb@netsurf-browser.org>
+ */
+
+#ifndef css_select_helpers_h_
+#define css_select_helpers_h_
+
+/**
+ * Convert unit bytecode to a css_unit.
+ */
+static inline css_unit css__to_css_unit(uint32_t u)
+{
+ switch (u) {
+ case UNIT_PX: return CSS_UNIT_PX;
+ case UNIT_EX: return CSS_UNIT_EX;
+ case UNIT_EM: return CSS_UNIT_EM;
+ case UNIT_IN: return CSS_UNIT_IN;
+ case UNIT_CM: return CSS_UNIT_CM;
+ 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;
+ case UNIT_VB: return CSS_UNIT_VB;
+ case UNIT_VMIN: return CSS_UNIT_VMIN;
+ case UNIT_VMAX: return CSS_UNIT_VMAX;
+ case UNIT_Q: return CSS_UNIT_Q;
+ case UNIT_PCT: return CSS_UNIT_PCT;
+ case UNIT_DEG: return CSS_UNIT_DEG;
+ case UNIT_GRAD: return CSS_UNIT_GRAD;
+ case UNIT_RAD: return CSS_UNIT_RAD;
+ case UNIT_MS: return CSS_UNIT_MS;
+ case UNIT_S: return CSS_UNIT_S;
+ case UNIT_HZ: return CSS_UNIT_HZ;
+ case UNIT_KHZ: return CSS_UNIT_KHZ;
+ }
+
+ return 0;
+}
+
+#endif
diff --git a/src/select/mq.h b/src/select/mq.h
index 9a97b7d..79303e9 100644
--- a/src/select/mq.h
+++ b/src/select/mq.h
@@ -9,8 +9,7 @@
#ifndef css_select_mq_h_
#define css_select_mq_h_
-#include "select/properties/properties.h"
-#include "select/properties/helpers.h"
+#include "select/helpers.h"
static inline css_fixed css_len2px(
css_fixed length,
diff --git a/src/select/properties/helpers.c b/src/select/properties/helpers.c
index 5893919..40936dd 100644
--- a/src/select/properties/helpers.c
+++ b/src/select/properties/helpers.c
@@ -16,45 +16,6 @@
#include "select/properties/helpers.h"
-/* Useful helpers */
-
-css_unit css__to_css_unit(uint32_t u)
-{
- switch (u) {
- case UNIT_PX: return CSS_UNIT_PX;
- case UNIT_EX: return CSS_UNIT_EX;
- case UNIT_EM: return CSS_UNIT_EM;
- case UNIT_IN: return CSS_UNIT_IN;
- case UNIT_CM: return CSS_UNIT_CM;
- 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;
- case UNIT_VB: return CSS_UNIT_VB;
- case UNIT_VMIN: return CSS_UNIT_VMIN;
- case UNIT_VMAX: return CSS_UNIT_VMAX;
- case UNIT_Q: return CSS_UNIT_Q;
- case UNIT_PCT: return CSS_UNIT_PCT;
- case UNIT_DEG: return CSS_UNIT_DEG;
- case UNIT_GRAD: return CSS_UNIT_GRAD;
- case UNIT_RAD: return CSS_UNIT_RAD;
- case UNIT_MS: return CSS_UNIT_MS;
- case UNIT_S: return CSS_UNIT_S;
- case UNIT_HZ: return CSS_UNIT_HZ;
- case UNIT_KHZ: return CSS_UNIT_KHZ;
- }
-
- return 0;
-}
-
/******************************************************************************
* Utilities below here *
******************************************************************************/
diff --git a/src/select/properties/helpers.h b/src/select/properties/helpers.h
index 901bcf0..60e5b4c 100644
--- a/src/select/properties/helpers.h
+++ b/src/select/properties/helpers.h
@@ -8,13 +8,13 @@
#ifndef css_select_properties_helpers_h_
#define css_select_properties_helpers_h_
+#include "select/helpers.h"
+
uint32_t generic_destroy_color(void *bytecode);
uint32_t generic_destroy_uri(void *bytecode);
uint32_t generic_destroy_length(void *bytecode);
uint32_t generic_destroy_number(void *bytecode);
-css_unit css__to_css_unit(uint32_t u);
-
css_error css__cascade_bg_border_color(uint32_t opv, css_style *style,
css_select_state *state,
css_error (*fun)(css_computed_style *, uint8_t, css_color));