Gitweb links:
...log
http://git.netsurf-browser.org/libcss.git/shortlog/35f499b333d1f97c47ac5581143ce9806d1c3536
...commit
http://git.netsurf-browser.org/libcss.git/commit/35f499b333d1f97c47ac5581143ce9806d1c3536
...tree
http://git.netsurf-browser.org/libcss.git/tree/35f499b333d1f97c47ac5581143ce9806d1c3536
The branch, master has been updated
via 35f499b333d1f97c47ac5581143ce9806d1c3536 (commit)
from 1c76ee6efeab2e9307d0a8aafa6666ca9db83128 (commit)
Those revisions listed above that are new to this repository have
not appeared on any other notification email; so we list those
revisions in full, below.
- Log -----------------------------------------------------------------
commitdiff
http://git.netsurf-browser.org/libcss.git/commit/?id=35f499b333d1f97c47ac5581143ce9806d1c3536
commit 35f499b333d1f97c47ac5581143ce9806d1c3536
Author: Vincent Sanders <[email protected]>
Commit: Vincent Sanders <[email protected]>
add cyclic system to list style formatting
diff --git a/src/select/format_list_style.c b/src/select/format_list_style.c
index 07d028b..4a2fee5 100644
--- a/src/select/format_list_style.c
+++ b/src/select/format_list_style.c
@@ -137,7 +137,7 @@ map_aval_to_symbols(char *buf, const size_t buflen,
* \param ares Buffer to recive the converted values
* \param alen the length of \a ares buffer
* \param value The value to convert
- * \param slen The number of symbols in the alphabet
+ * \param cstyle The counter style in use
* \return The length a complete conversion which may be larger than \a alen
*/
static size_t
@@ -179,6 +179,36 @@ calc_numeric_system(uint8_t *ares,
/**
+ * generate cyclic symbol values
+ *
+ * fills array with cyclic values that represent the input value
+ *
+ * \param ares Buffer to recive the converted values
+ * \param alen the length of \a ares buffer
+ * \param value The value to convert
+ * \param cstyle The counter style in use
+ * \return The length a complete conversion which may be larger than \a alen
+ */
+static size_t
+calc_cyclic_system(uint8_t *ares,
+ const size_t alen,
+ int value,
+ const struct list_counter_style *cstyle)
+{
+ if (alen == 0) {
+ return 0;
+ }
+ if (cstyle->items == 1) {
+ /* there is only one symbol so select it */
+ ares[0] = 0;
+ } else {
+ ares[0] = (value - 1) % cstyle->items;
+ }
+ return 1;
+}
+
+
+/**
* generate addative symbol values
*
* fills array with numeric values that represent the input value
@@ -472,13 +502,40 @@ static const struct list_counter_style lcs_lower_roman = {
.calc = calc_roman_system,
};
+static const symbol_t disc_symbols[] = { "\xE2\x80\xA2"}; /* 2022 BULLET */
+static const struct list_counter_style lcs_disc = {
+ .name = "disc",
+ .symbols = disc_symbols,
+ .items = (sizeof(disc_symbols) / SYMBOL_SIZE),
+ .postfix = " ",
+ .calc = calc_cyclic_system,
+};
+
+static const symbol_t circle_symbols[] = { "\342\227\213"}; /* 25CB WHITE
CIRCLE */
+static const struct list_counter_style lcs_circle = {
+ .name = "circle",
+ .symbols = circle_symbols,
+ .items = (sizeof(circle_symbols) / SYMBOL_SIZE),
+ .postfix = " ",
+ .calc = calc_cyclic_system,
+};
+
+static const symbol_t square_symbols[] = { "\342\226\252"}; /* 25AA BLACK
SMALL SQUARE */
+static const struct list_counter_style lcs_square = {
+ .name = "square",
+ .symbols = square_symbols,
+ .items = (sizeof(square_symbols) / SYMBOL_SIZE),
+ .postfix = " ",
+ .calc = calc_cyclic_system,
+};
+
#if 0
static const symbol_t lower_hexidecimal_symbols[] = {
"0", "1", "2", "3", "4", "5", "6", "7", "8", "9",
"a", "b", "c", "d", "e", "f"
};
static const struct list_counter_style lcs_lower_hexidecimal = {
- .name = "lower_hexidecimal",
+ .name = "lower-hexidecimal",
.symbols = lower_hexidecimal_symbols,
.items = (sizeof(lower_hexidecimal_symbols) / SYMBOL_SIZE),
.calc = calc_numeric_system,
@@ -535,6 +592,22 @@ css_error css_computed_format_list_style(
cstyle = &lcs_georgian;
break;
+ case CSS_LIST_STYLE_TYPE_DISC:
+ cstyle = &lcs_disc;
+ break;
+
+ case CSS_LIST_STYLE_TYPE_CIRCLE:
+ cstyle = &lcs_circle;
+ break;
+
+ case CSS_LIST_STYLE_TYPE_SQUARE:
+ cstyle = &lcs_square;
+ break;
+
+ case CSS_LIST_STYLE_TYPE_NONE:
+ *format_length = 0;
+ return CSS_OK;
+
case CSS_LIST_STYLE_TYPE_DECIMAL:
default:
cstyle = &lcs_decimal;
-----------------------------------------------------------------------
Summary of changes:
src/select/format_list_style.c | 77 ++++++++++++++++++++++++++++++++++++++--
1 file changed, 75 insertions(+), 2 deletions(-)
diff --git a/src/select/format_list_style.c b/src/select/format_list_style.c
index 07d028b..4a2fee5 100644
--- a/src/select/format_list_style.c
+++ b/src/select/format_list_style.c
@@ -137,7 +137,7 @@ map_aval_to_symbols(char *buf, const size_t buflen,
* \param ares Buffer to recive the converted values
* \param alen the length of \a ares buffer
* \param value The value to convert
- * \param slen The number of symbols in the alphabet
+ * \param cstyle The counter style in use
* \return The length a complete conversion which may be larger than \a alen
*/
static size_t
@@ -179,6 +179,36 @@ calc_numeric_system(uint8_t *ares,
/**
+ * generate cyclic symbol values
+ *
+ * fills array with cyclic values that represent the input value
+ *
+ * \param ares Buffer to recive the converted values
+ * \param alen the length of \a ares buffer
+ * \param value The value to convert
+ * \param cstyle The counter style in use
+ * \return The length a complete conversion which may be larger than \a alen
+ */
+static size_t
+calc_cyclic_system(uint8_t *ares,
+ const size_t alen,
+ int value,
+ const struct list_counter_style *cstyle)
+{
+ if (alen == 0) {
+ return 0;
+ }
+ if (cstyle->items == 1) {
+ /* there is only one symbol so select it */
+ ares[0] = 0;
+ } else {
+ ares[0] = (value - 1) % cstyle->items;
+ }
+ return 1;
+}
+
+
+/**
* generate addative symbol values
*
* fills array with numeric values that represent the input value
@@ -472,13 +502,40 @@ static const struct list_counter_style lcs_lower_roman = {
.calc = calc_roman_system,
};
+static const symbol_t disc_symbols[] = { "\xE2\x80\xA2"}; /* 2022 BULLET */
+static const struct list_counter_style lcs_disc = {
+ .name = "disc",
+ .symbols = disc_symbols,
+ .items = (sizeof(disc_symbols) / SYMBOL_SIZE),
+ .postfix = " ",
+ .calc = calc_cyclic_system,
+};
+
+static const symbol_t circle_symbols[] = { "\342\227\213"}; /* 25CB WHITE
CIRCLE */
+static const struct list_counter_style lcs_circle = {
+ .name = "circle",
+ .symbols = circle_symbols,
+ .items = (sizeof(circle_symbols) / SYMBOL_SIZE),
+ .postfix = " ",
+ .calc = calc_cyclic_system,
+};
+
+static const symbol_t square_symbols[] = { "\342\226\252"}; /* 25AA BLACK
SMALL SQUARE */
+static const struct list_counter_style lcs_square = {
+ .name = "square",
+ .symbols = square_symbols,
+ .items = (sizeof(square_symbols) / SYMBOL_SIZE),
+ .postfix = " ",
+ .calc = calc_cyclic_system,
+};
+
#if 0
static const symbol_t lower_hexidecimal_symbols[] = {
"0", "1", "2", "3", "4", "5", "6", "7", "8", "9",
"a", "b", "c", "d", "e", "f"
};
static const struct list_counter_style lcs_lower_hexidecimal = {
- .name = "lower_hexidecimal",
+ .name = "lower-hexidecimal",
.symbols = lower_hexidecimal_symbols,
.items = (sizeof(lower_hexidecimal_symbols) / SYMBOL_SIZE),
.calc = calc_numeric_system,
@@ -535,6 +592,22 @@ css_error css_computed_format_list_style(
cstyle = &lcs_georgian;
break;
+ case CSS_LIST_STYLE_TYPE_DISC:
+ cstyle = &lcs_disc;
+ break;
+
+ case CSS_LIST_STYLE_TYPE_CIRCLE:
+ cstyle = &lcs_circle;
+ break;
+
+ case CSS_LIST_STYLE_TYPE_SQUARE:
+ cstyle = &lcs_square;
+ break;
+
+ case CSS_LIST_STYLE_TYPE_NONE:
+ *format_length = 0;
+ return CSS_OK;
+
case CSS_LIST_STYLE_TYPE_DECIMAL:
default:
cstyle = &lcs_decimal;
--
Cascading Style Sheets library
_______________________________________________
netsurf-commits mailing list -- [email protected]
To unsubscribe send an email to [email protected]