netsurf: branch master updated. release/3.10-98-g55fadc8
by NetSurf Browser Project
Gitweb links:
...log http://git.netsurf-browser.org/netsurf.git/shortlog/55fadc802ac80286e4f72...
...commit http://git.netsurf-browser.org/netsurf.git/commit/55fadc802ac80286e4f7266...
...tree http://git.netsurf-browser.org/netsurf.git/tree/55fadc802ac80286e4f726686...
The branch, master has been updated
via 55fadc802ac80286e4f7266866ad789c78f57483 (commit)
from 3b57deb046a35a8e88fb0db672adf9aac6899aea (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/netsurf.git/commit/?id=55fadc802ac80286e4f...
commit 55fadc802ac80286e4f7266866ad789c78f57483
Author: Michael Drake <michael.drake(a)codethink.co.uk>
Commit: Michael Drake <michael.drake(a)codethink.co.uk>
html: list counter style: Revert to string for {pre|post}fix.
diff --git a/content/handlers/html/list_counter_style.c b/content/handlers/html/list_counter_style.c
index e864c9b..81d9aa3 100644
--- a/content/handlers/html/list_counter_style.c
+++ b/content/handlers/html/list_counter_style.c
@@ -41,8 +41,8 @@ struct list_counter_style {
const unsigned int length;
const symbol_t value;
} pad;
- const symbol_t prefix;
- const symbol_t postfix;
+ const char *prefix;
+ const char *postfix;
const symbol_t *symbols; /**< array of symbols which represent this style */
const int *weights; /**< symbol weights for additive schemes */
const size_t items; /**< items in symbol and weight table */
@@ -50,6 +50,32 @@ struct list_counter_style {
};
/**
+ * Copy a null-terminated UTF-8 string to buffer at offset, if there is space
+ *
+ * \param[in] buf The output buffer
+ * \param[in] buflen The length of \a buf
+ * \param[in] pos Current position in \a buf
+ * \param[in] str The string to copy into \a buf
+ * \return The number of bytes needed in the output buffer which may be
+ * larger than \a buflen but the buffer will not be overrun
+ */
+static inline size_t
+copy_string(char *buf, const size_t buflen, size_t pos, const char *str)
+{
+ size_t sidx = 0; /* current string index */
+
+ while (str[sidx] != '\0') {
+ if (pos < buflen) {
+ buf[pos] = str[sidx];
+ }
+ pos++;
+ sidx++;
+ }
+
+ return sidx;
+}
+
+/**
* Copy a UTF-8 symbol to buffer at offset, if there is space
*
* \param[in] buf The output buffer
@@ -115,8 +141,8 @@ map_aval_to_symbols(char *buf, const size_t buflen,
}
/* postfix */
- oidx += copy_symbol(buf, buflen, oidx,
- (cstyle->postfix[0] != '\0') ?
+ oidx += copy_string(buf, buflen, oidx,
+ (cstyle->postfix != NULL) ?
cstyle->postfix : postfix);
return oidx;
-----------------------------------------------------------------------
Summary of changes:
content/handlers/html/list_counter_style.c | 34 ++++++++++++++++++++++++----
1 file changed, 30 insertions(+), 4 deletions(-)
diff --git a/content/handlers/html/list_counter_style.c b/content/handlers/html/list_counter_style.c
index e864c9b..81d9aa3 100644
--- a/content/handlers/html/list_counter_style.c
+++ b/content/handlers/html/list_counter_style.c
@@ -41,8 +41,8 @@ struct list_counter_style {
const unsigned int length;
const symbol_t value;
} pad;
- const symbol_t prefix;
- const symbol_t postfix;
+ const char *prefix;
+ const char *postfix;
const symbol_t *symbols; /**< array of symbols which represent this style */
const int *weights; /**< symbol weights for additive schemes */
const size_t items; /**< items in symbol and weight table */
@@ -50,6 +50,32 @@ struct list_counter_style {
};
/**
+ * Copy a null-terminated UTF-8 string to buffer at offset, if there is space
+ *
+ * \param[in] buf The output buffer
+ * \param[in] buflen The length of \a buf
+ * \param[in] pos Current position in \a buf
+ * \param[in] str The string to copy into \a buf
+ * \return The number of bytes needed in the output buffer which may be
+ * larger than \a buflen but the buffer will not be overrun
+ */
+static inline size_t
+copy_string(char *buf, const size_t buflen, size_t pos, const char *str)
+{
+ size_t sidx = 0; /* current string index */
+
+ while (str[sidx] != '\0') {
+ if (pos < buflen) {
+ buf[pos] = str[sidx];
+ }
+ pos++;
+ sidx++;
+ }
+
+ return sidx;
+}
+
+/**
* Copy a UTF-8 symbol to buffer at offset, if there is space
*
* \param[in] buf The output buffer
@@ -115,8 +141,8 @@ map_aval_to_symbols(char *buf, const size_t buflen,
}
/* postfix */
- oidx += copy_symbol(buf, buflen, oidx,
- (cstyle->postfix[0] != '\0') ?
+ oidx += copy_string(buf, buflen, oidx,
+ (cstyle->postfix != NULL) ?
cstyle->postfix : postfix);
return oidx;
--
NetSurf Browser
1 year, 12 months
netsurf: branch master updated. release/3.10-97-g3b57deb
by NetSurf Browser Project
Gitweb links:
...log http://git.netsurf-browser.org/netsurf.git/shortlog/3b57deb046a35a8e88fb0...
...commit http://git.netsurf-browser.org/netsurf.git/commit/3b57deb046a35a8e88fb0db...
...tree http://git.netsurf-browser.org/netsurf.git/tree/3b57deb046a35a8e88fb0db67...
The branch, master has been updated
via 3b57deb046a35a8e88fb0db672adf9aac6899aea (commit)
from 87b5fd1bccc28132405fe34e129e1eb1e4b63f5b (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/netsurf.git/commit/?id=3b57deb046a35a8e88f...
commit 3b57deb046a35a8e88fb0db672adf9aac6899aea
Author: Michael Drake <michael.drake(a)codethink.co.uk>
Commit: Michael Drake <michael.drake(a)codethink.co.uk>
html: list counter style: Constify {pre|post}fix memebers.
diff --git a/content/handlers/html/list_counter_style.c b/content/handlers/html/list_counter_style.c
index fc54c6c..e864c9b 100644
--- a/content/handlers/html/list_counter_style.c
+++ b/content/handlers/html/list_counter_style.c
@@ -41,8 +41,8 @@ struct list_counter_style {
const unsigned int length;
const symbol_t value;
} pad;
- symbol_t prefix;
- symbol_t postfix;
+ const symbol_t prefix;
+ const symbol_t postfix;
const symbol_t *symbols; /**< array of symbols which represent this style */
const int *weights; /**< symbol weights for additive schemes */
const size_t items; /**< items in symbol and weight table */
-----------------------------------------------------------------------
Summary of changes:
content/handlers/html/list_counter_style.c | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)
diff --git a/content/handlers/html/list_counter_style.c b/content/handlers/html/list_counter_style.c
index fc54c6c..e864c9b 100644
--- a/content/handlers/html/list_counter_style.c
+++ b/content/handlers/html/list_counter_style.c
@@ -41,8 +41,8 @@ struct list_counter_style {
const unsigned int length;
const symbol_t value;
} pad;
- symbol_t prefix;
- symbol_t postfix;
+ const symbol_t prefix;
+ const symbol_t postfix;
const symbol_t *symbols; /**< array of symbols which represent this style */
const int *weights; /**< symbol weights for additive schemes */
const size_t items; /**< items in symbol and weight table */
--
NetSurf Browser
1 year, 12 months
netsurf: branch master updated. release/3.10-96-g87b5fd1
by NetSurf Browser Project
Gitweb links:
...log http://git.netsurf-browser.org/netsurf.git/shortlog/87b5fd1bccc28132405fe...
...commit http://git.netsurf-browser.org/netsurf.git/commit/87b5fd1bccc28132405fe34...
...tree http://git.netsurf-browser.org/netsurf.git/tree/87b5fd1bccc28132405fe34e1...
The branch, master has been updated
via 87b5fd1bccc28132405fe34e129e1eb1e4b63f5b (commit)
from 60d9dbe390f95fc85b414005ef4b91a7aec0a2fc (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/netsurf.git/commit/?id=87b5fd1bccc28132405...
commit 87b5fd1bccc28132405fe34e129e1eb1e4b63f5b
Author: Michael Drake <michael.drake(a)codethink.co.uk>
Commit: Michael Drake <michael.drake(a)codethink.co.uk>
html: list counter style: Split out symbol copy.
diff --git a/content/handlers/html/list_counter_style.c b/content/handlers/html/list_counter_style.c
index ae9fb8c..fc54c6c 100644
--- a/content/handlers/html/list_counter_style.c
+++ b/content/handlers/html/list_counter_style.c
@@ -41,14 +41,39 @@ struct list_counter_style {
const unsigned int length;
const symbol_t value;
} pad;
- const char *prefix;
- const char *postfix;
+ symbol_t prefix;
+ symbol_t postfix;
const symbol_t *symbols; /**< array of symbols which represent this style */
const int *weights; /**< symbol weights for additive schemes */
const size_t items; /**< items in symbol and weight table */
size_t (*calc)(uint8_t *ares, const size_t alen, int value, const struct list_counter_style *cstyle); /**< function to calculate the system */
};
+/**
+ * Copy a UTF-8 symbol to buffer at offset, if there is space
+ *
+ * \param[in] buf The output buffer
+ * \param[in] buflen The length of \a buf
+ * \param[in] pos Current position in \a buf
+ * \param[in] symbol The symbol to copy into \a buf
+ * \return The number of bytes needed in the output buffer which may be
+ * larger than \a buflen but the buffer will not be overrun
+ */
+static inline size_t
+copy_symbol(char *buf, const size_t buflen, size_t pos, const symbol_t symbol)
+{
+ size_t sidx = 0; /* current symbol index */
+
+ while ((sidx < sizeof(symbol_t)) && (symbol[sidx] != '\0')) {
+ if (pos < buflen) {
+ buf[pos] = symbol[sidx];
+ }
+ pos++;
+ sidx++;
+ }
+
+ return sidx;
+}
/**
* maps alphabet values to output values with a symbol table
@@ -71,53 +96,28 @@ map_aval_to_symbols(char *buf, const size_t buflen,
const struct list_counter_style *cstyle)
{
size_t oidx = 0;
- size_t pidx; /* padding index */
size_t aidx; /* numeral index */
- size_t sidx; /* current symbol index */
- const char *postfix = "."; /* default postfix string */
+ const symbol_t postfix = "."; /* default postfix string */
/* add padding if required */
if (alen < cstyle->pad.length) {
+ size_t pidx; /* padding index */
for (pidx=cstyle->pad.length - alen; pidx > 0; pidx--) {
- sidx=0;
- while ((sidx < 4) &&
- (cstyle->pad.value[sidx] != 0)) {
- if (oidx < buflen) {
- buf[oidx] = cstyle->pad.value[sidx];
- }
- oidx++;
- sidx++;
- }
+ oidx += copy_symbol(buf, buflen, oidx,
+ cstyle->pad.value);
}
}
/* map symbols */
for (aidx=0; aidx < alen; aidx++) {
- sidx=0;
- while ((sidx < 4) &&
- (cstyle->symbols[aval[aidx]][sidx] != 0)) {
- if (oidx < buflen) {
- buf[oidx] = cstyle->symbols[aval[aidx]][sidx];
- }
- oidx++;
- sidx++;
- }
+ oidx += copy_symbol(buf, buflen, oidx,
+ cstyle->symbols[aval[aidx]]);
}
-
/* postfix */
- if (cstyle->postfix != NULL) {
- postfix = cstyle->postfix;
- }
- sidx=0;
- while ((sidx < 4) &&
- (postfix[sidx] != 0)) {
- if (oidx < buflen) {
- buf[oidx] = postfix[sidx];
- }
- oidx++;
- sidx++;
- }
+ oidx += copy_symbol(buf, buflen, oidx,
+ (cstyle->postfix[0] != '\0') ?
+ cstyle->postfix : postfix);
return oidx;
}
-----------------------------------------------------------------------
Summary of changes:
content/handlers/html/list_counter_style.c | 72 ++++++++++++++--------------
1 file changed, 36 insertions(+), 36 deletions(-)
diff --git a/content/handlers/html/list_counter_style.c b/content/handlers/html/list_counter_style.c
index ae9fb8c..fc54c6c 100644
--- a/content/handlers/html/list_counter_style.c
+++ b/content/handlers/html/list_counter_style.c
@@ -41,14 +41,39 @@ struct list_counter_style {
const unsigned int length;
const symbol_t value;
} pad;
- const char *prefix;
- const char *postfix;
+ symbol_t prefix;
+ symbol_t postfix;
const symbol_t *symbols; /**< array of symbols which represent this style */
const int *weights; /**< symbol weights for additive schemes */
const size_t items; /**< items in symbol and weight table */
size_t (*calc)(uint8_t *ares, const size_t alen, int value, const struct list_counter_style *cstyle); /**< function to calculate the system */
};
+/**
+ * Copy a UTF-8 symbol to buffer at offset, if there is space
+ *
+ * \param[in] buf The output buffer
+ * \param[in] buflen The length of \a buf
+ * \param[in] pos Current position in \a buf
+ * \param[in] symbol The symbol to copy into \a buf
+ * \return The number of bytes needed in the output buffer which may be
+ * larger than \a buflen but the buffer will not be overrun
+ */
+static inline size_t
+copy_symbol(char *buf, const size_t buflen, size_t pos, const symbol_t symbol)
+{
+ size_t sidx = 0; /* current symbol index */
+
+ while ((sidx < sizeof(symbol_t)) && (symbol[sidx] != '\0')) {
+ if (pos < buflen) {
+ buf[pos] = symbol[sidx];
+ }
+ pos++;
+ sidx++;
+ }
+
+ return sidx;
+}
/**
* maps alphabet values to output values with a symbol table
@@ -71,53 +96,28 @@ map_aval_to_symbols(char *buf, const size_t buflen,
const struct list_counter_style *cstyle)
{
size_t oidx = 0;
- size_t pidx; /* padding index */
size_t aidx; /* numeral index */
- size_t sidx; /* current symbol index */
- const char *postfix = "."; /* default postfix string */
+ const symbol_t postfix = "."; /* default postfix string */
/* add padding if required */
if (alen < cstyle->pad.length) {
+ size_t pidx; /* padding index */
for (pidx=cstyle->pad.length - alen; pidx > 0; pidx--) {
- sidx=0;
- while ((sidx < 4) &&
- (cstyle->pad.value[sidx] != 0)) {
- if (oidx < buflen) {
- buf[oidx] = cstyle->pad.value[sidx];
- }
- oidx++;
- sidx++;
- }
+ oidx += copy_symbol(buf, buflen, oidx,
+ cstyle->pad.value);
}
}
/* map symbols */
for (aidx=0; aidx < alen; aidx++) {
- sidx=0;
- while ((sidx < 4) &&
- (cstyle->symbols[aval[aidx]][sidx] != 0)) {
- if (oidx < buflen) {
- buf[oidx] = cstyle->symbols[aval[aidx]][sidx];
- }
- oidx++;
- sidx++;
- }
+ oidx += copy_symbol(buf, buflen, oidx,
+ cstyle->symbols[aval[aidx]]);
}
-
/* postfix */
- if (cstyle->postfix != NULL) {
- postfix = cstyle->postfix;
- }
- sidx=0;
- while ((sidx < 4) &&
- (postfix[sidx] != 0)) {
- if (oidx < buflen) {
- buf[oidx] = postfix[sidx];
- }
- oidx++;
- sidx++;
- }
+ oidx += copy_symbol(buf, buflen, oidx,
+ (cstyle->postfix[0] != '\0') ?
+ cstyle->postfix : postfix);
return oidx;
}
--
NetSurf Browser
1 year, 12 months
netsurf: branch master updated. release/3.10-95-g60d9dbe
by NetSurf Browser Project
Gitweb links:
...log http://git.netsurf-browser.org/netsurf.git/shortlog/60d9dbe390f95fc85b414...
...commit http://git.netsurf-browser.org/netsurf.git/commit/60d9dbe390f95fc85b41400...
...tree http://git.netsurf-browser.org/netsurf.git/tree/60d9dbe390f95fc85b414005e...
The branch, master has been updated
via 60d9dbe390f95fc85b414005ef4b91a7aec0a2fc (commit)
from 29f7931ea41fc06f5d4d69a41484456d94e64ec5 (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/netsurf.git/commit/?id=60d9dbe390f95fc85b4...
commit 60d9dbe390f95fc85b414005ef4b91a7aec0a2fc
Author: Vincent Sanders <vince(a)kyllikki.org>
Commit: Vincent Sanders <vince(a)kyllikki.org>
change list counter style formatting to be table driven
diff --git a/content/handlers/html/box_construct.c b/content/handlers/html/box_construct.c
index 9204090..6c6fc24 100644
--- a/content/handlers/html/box_construct.c
+++ b/content/handlers/html/box_construct.c
@@ -398,10 +398,10 @@ static unsigned int compute_list_marker_index(struct box *last)
}
/**
- * maximum length of a list marker
+ * initial length of a list marker buffer
*
* enough for 9,999,999,999,999,999,999 in decimal
- * or six characters for 3byte utf8
+ * or five characters for 4byte utf8
*/
#define LIST_MARKER_SIZE 20
@@ -423,6 +423,7 @@ box_construct_marker(struct box *box,
lwc_string *image_uri;
struct box *marker;
enum css_list_style_type_e list_style_type;
+ size_t counter_len;
marker = box_create(NULL, box->style, false, NULL, NULL, title,
NULL, ctx->bctx);
@@ -454,7 +455,7 @@ box_construct_marker(struct box *box,
break;
case CSS_LIST_STYLE_TYPE_NONE:
- marker->text = 0;
+ marker->text = NULL;
marker->length = 0;
break;
@@ -462,13 +463,29 @@ box_construct_marker(struct box *box,
marker->rows = compute_list_marker_index(parent->last);
marker->text = talloc_array(ctx->bctx, char, LIST_MARKER_SIZE);
- if (marker->text == NULL)
+ if (marker->text == NULL) {
return false;
+ }
- marker->length = list_counter_style_value(marker->text,
- LIST_MARKER_SIZE,
- list_style_type,
- marker->rows);
+ counter_len = list_counter_style_value(marker->text,
+ LIST_MARKER_SIZE,
+ list_style_type,
+ marker->rows);
+ if (counter_len > LIST_MARKER_SIZE) {
+ /* use computed size as marker did not fit allocation */
+ marker->text = talloc_realloc(ctx->bctx,
+ marker->text,
+ char,
+ counter_len);
+ if (marker->text == NULL) {
+ return false;
+ }
+ counter_len = list_counter_style_value(marker->text,
+ counter_len,
+ list_style_type,
+ marker->rows);
+ }
+ marker->length = counter_len;
break;
}
diff --git a/content/handlers/html/list_counter_style.c b/content/handlers/html/list_counter_style.c
index af643df..ae9fb8c 100644
--- a/content/handlers/html/list_counter_style.c
+++ b/content/handlers/html/list_counter_style.c
@@ -22,13 +22,34 @@
*/
#include <stddef.h>
-#include <stdio.h>
#include "css/select.h"
#include "html/list_counter_style.h"
+#define SYMBOL_SIZE 4
+typedef char symbol_t[SYMBOL_SIZE];
+
+struct list_counter_style {
+ const char *name; /**< style name for debug purposes */
+ struct {
+ const int start; /**< first acceptable value for this style */
+ const int end; /**< last acceptable value for this style */
+ } range;
+ struct {
+ const unsigned int length;
+ const symbol_t value;
+ } pad;
+ const char *prefix;
+ const char *postfix;
+ const symbol_t *symbols; /**< array of symbols which represent this style */
+ const int *weights; /**< symbol weights for additive schemes */
+ const size_t items; /**< items in symbol and weight table */
+ size_t (*calc)(uint8_t *ares, const size_t alen, int value, const struct list_counter_style *cstyle); /**< function to calculate the system */
+};
+
+
/**
* maps alphabet values to output values with a symbol table
*
@@ -44,27 +65,60 @@
* \return The number of bytes needed in the output buffer whichmay be
* larger than \a buflen but the buffer will not be overrun
*/
-static int
+static size_t
map_aval_to_symbols(char *buf, const size_t buflen,
const uint8_t *aval, const size_t alen,
- const char symtab[][4], const size_t symtablen)
+ const struct list_counter_style *cstyle)
{
- size_t oidx;
- size_t aidx;
- int sidx;
+ size_t oidx = 0;
+ size_t pidx; /* padding index */
+ size_t aidx; /* numeral index */
+ size_t sidx; /* current symbol index */
+ const char *postfix = "."; /* default postfix string */
+
+ /* add padding if required */
+ if (alen < cstyle->pad.length) {
+ for (pidx=cstyle->pad.length - alen; pidx > 0; pidx--) {
+ sidx=0;
+ while ((sidx < 4) &&
+ (cstyle->pad.value[sidx] != 0)) {
+ if (oidx < buflen) {
+ buf[oidx] = cstyle->pad.value[sidx];
+ }
+ oidx++;
+ sidx++;
+ }
+ }
+ }
- oidx = 0;
+ /* map symbols */
for (aidx=0; aidx < alen; aidx++) {
sidx=0;
while ((sidx < 4) &&
- (symtab[aval[aidx]][sidx] != 0)) {
+ (cstyle->symbols[aval[aidx]][sidx] != 0)) {
if (oidx < buflen) {
- buf[oidx] = symtab[aval[aidx]][sidx];
+ buf[oidx] = cstyle->symbols[aval[aidx]][sidx];
}
oidx++;
sidx++;
}
}
+
+
+ /* postfix */
+ if (cstyle->postfix != NULL) {
+ postfix = cstyle->postfix;
+ }
+ sidx=0;
+ while ((sidx < 4) &&
+ (postfix[sidx] != 0)) {
+ if (oidx < buflen) {
+ buf[oidx] = postfix[sidx];
+ }
+ oidx++;
+ sidx++;
+ }
+
return oidx;
}
@@ -84,7 +138,7 @@ static size_t
calc_numeric_system(uint8_t *ares,
const size_t alen,
int value,
- unsigned char slen)
+ const struct list_counter_style *cstyle)
{
size_t idx = 0;
uint8_t *first;
@@ -92,9 +146,11 @@ calc_numeric_system(uint8_t *ares,
/* generate alphabet values in ascending order */
while (value > 0) {
- if (idx < alen) ares[idx] = value % slen;
+ if (idx < alen) {
+ ares[idx] = value % cstyle->items;
+ }
idx++;
- value = value / slen;
+ value = value / cstyle->items;
}
/* put the values in decending order */
@@ -129,10 +185,9 @@ calc_numeric_system(uint8_t *ares,
*/
static size_t
calc_additive_system(uint8_t *ares,
- const size_t alen,
- int value,
- const int weights[],
- unsigned char wlen)
+ const size_t alen,
+ int value,
+ const struct list_counter_style *cstyle)
{
size_t widx; /* weight index */
size_t aidx = 0;
@@ -140,15 +195,17 @@ calc_additive_system(uint8_t *ares,
size_t times; /* number of times a weight occours */
/* iterate over the available weights */
- for (widx = 0; widx < wlen;widx++) {
- times = value / weights[widx];
+ for (widx = 0; widx < cstyle->items;widx++) {
+ times = value / cstyle->weights[widx];
if (times > 0) {
for (idx=0;idx < times;idx++) {
- if (aidx < alen) ares[aidx] = widx;
+ if (aidx < alen) {
+ ares[aidx] = widx;
+ }
aidx++;
}
- value -= times * weights[widx];
+ value -= times * cstyle->weights[widx];
}
}
@@ -169,9 +226,9 @@ calc_additive_system(uint8_t *ares,
*/
static size_t
calc_alphabet_system(uint8_t *ares,
- const size_t alen,
- int value,
- unsigned char slen)
+ const size_t alen,
+ int value,
+ const struct list_counter_style *cstyle)
{
size_t idx = 0;
uint8_t *first;
@@ -180,9 +237,11 @@ calc_alphabet_system(uint8_t *ares,
/* generate alphabet values in ascending order */
while (value > 0) {
--value;
- if (idx < alen) ares[idx] = value % slen;
+ if (idx < alen) {
+ ares[idx] = value % cstyle->items;
+ }
idx++;
- value = value / slen;
+ value = value / cstyle->items;
}
/* put the values in decending order */
@@ -209,11 +268,11 @@ calc_alphabet_system(uint8_t *ares,
*
* \return The number of numerals that are nesesary for full output
*/
-static int
+static size_t
calc_roman_system(uint8_t *buf,
const size_t maxlen,
int value,
- unsigned char slen)
+ const struct list_counter_style *cstyle)
{
const int S[] = { 0, 2, 4, 2, 4, 2, 4 };
const int D[] = { 1000, 500, 100, 50, 10, 5, 1 };
@@ -222,7 +281,7 @@ calc_roman_system(uint8_t *buf,
unsigned int i = 0; /* index into maps */
int r, r2;
- assert(slen == 7);
+ assert(cstyle->items == 7);
while (value > 0) {
if (D[i] <= value) {
@@ -256,274 +315,215 @@ calc_roman_system(uint8_t *buf,
}
-/**
- * lower case roman numeral
- */
-static int ntolcromannumeral(char *buf, const size_t buflen, int value)
-{
- size_t alen;
- uint8_t aval[20];
- const char symtab[][4] = {
- "m", "d", "c", "l", "x", "v", "i"
- };
- const size_t symtablen = sizeof(symtab) / 4;
-
- alen = calc_roman_system(aval, sizeof(aval), value, symtablen);
- if (alen >= sizeof(aval)) {
- *buf = '?';
- return 1;
- }
-
- return map_aval_to_symbols(buf, buflen, aval, alen, symtab, symtablen);
-}
-
-/**
- * upper case roman numeral
- */
-static int ntoucromannumeral(char *buf, const size_t buflen, int value)
-{
- size_t alen;
- uint8_t aval[20];
- const char symtab[][4] = {
- "M", "D", "C", "L", "X", "V", "I"
- };
- const size_t symtablen = sizeof(symtab) / 4;
-
- alen = calc_roman_system(aval, sizeof(aval), value, symtablen);
- if (alen >= sizeof(aval)) {
- *buf = '?';
- return 1;
- }
-
- return map_aval_to_symbols(buf, buflen, aval, alen, symtab, symtablen);
-}
-
-
-
-
-static int ntolcalpha(char *buf, const size_t buflen, int value)
-{
- size_t alen;
- uint8_t aval[20];
- const char symtab[][4] = {
- "a", "b", "c", "d", "e", "f", "g", "h", "i", "j",
- "k", "l", "m", "n", "o", "p", "q", "r", "s", "t",
- "u", "v", "w", "x", "y", "z"
- };
- const size_t symtablen = sizeof(symtab) / 4;
-
- alen = calc_alphabet_system(aval, sizeof(aval), value, symtablen);
- if (alen >= sizeof(aval)) {
- *buf = '?';
- return 1;
- }
-
- return map_aval_to_symbols(buf, buflen, aval, alen, symtab, symtablen);
-}
-
-static int ntoucalpha(char *buf, const size_t buflen, int value)
-{
- size_t alen;
- uint8_t aval[20];
- const char symtab[][4] = {
- "A", "B", "C", "D", "E", "F", "G", "H", "I", "J",
- "K", "L", "M", "N", "O", "P", "Q", "R", "S", "T",
- "U", "V", "W", "X", "Y", "Z"
- };
- const size_t symtablen = sizeof(symtab) / 4;
-
- alen = calc_alphabet_system(aval, sizeof(aval), value, symtablen);
- if (alen >= sizeof(aval)) {
- *buf = '?';
- return 1;
- }
-
- return map_aval_to_symbols(buf, buflen, aval, alen, symtab, symtablen);
-}
-
-static int ntolcgreek(char *buf, const size_t buflen, int value)
-{
- size_t alen;
- uint8_t aval[20];
- const char symtab[][4] = {
- "��", "��", "��", "��", "��", "��", "��", "��", "��", "��",
- "��", "��", "��", "��", "��", "��", "��", "��", "��", "��",
- "��", "��", "��", "��"
- };
- const size_t symtablen = sizeof(symtab) / 4;
-
- alen = calc_alphabet_system(aval, sizeof(aval), value, symtablen);
- if (alen >= sizeof(aval)) {
- *buf = '?';
- return 1;
- }
-
- return map_aval_to_symbols(buf, buflen, aval, alen, symtab, symtablen);
-}
+/* tables for all the counter styles */
+
+
+static const symbol_t georgian_symbols[] = {
+ "���",
+ "���", "���", "���", "���", "���", "���", "���", "���", "���",
+ "���", "���", "���", "���", "���", "���", "���", "���", "���",
+ "���", "���", "���", "���", "���", "���", "���", "���", "���",
+ "���", "���", "���", "���", "���", "���", "���", "���", "���",
+};
+static const int georgian_weights[] = {
+ 10000,
+ 9000, 8000, 7000, 6000, 5000, 4000, 3000, 2000, 1000,
+ 900, 800, 700, 600, 500, 400, 300, 200, 100,
+ 90, 80, 70, 60, 50, 40, 30, 20, 10,
+ 9, 8, 7, 6, 5, 4, 3, 2, 1
+};
+static struct list_counter_style lcs_georgian = {
+ .name="georgian",
+ .range.start = 1,
+ .range.end = 19999,
+ .symbols = georgian_symbols,
+ .weights = georgian_weights,
+ .items = (sizeof(georgian_symbols) / SYMBOL_SIZE),
+ .calc = calc_additive_system,
+};
+
+
+static const symbol_t armenian_symbols[] = {
+ "��", "��", "��", "��", "��", "��", "��", "��", "��",
+ "��", "��", "��", "��", "��", "��", "��", "��", "��",
+ "��", "��", "��", "��", "��", "��", "��", "��", "��",
+ "��", "��", "��", "��", "��", "��", "��", "��", "��"
+};
+static const int armenian_weights[] = {
+ 9000, 8000, 7000, 6000, 5000, 4000, 3000, 2000, 1000,
+ 900, 800, 700, 600, 500, 400, 300, 200, 100,
+ 90, 80, 70, 60, 50, 40, 30, 20, 10,
+ 9, 8, 7, 6, 5, 4, 3, 2, 1
+};
+static struct list_counter_style lcs_armenian = {
+ .name = "armenian",
+ .range.start = 1,
+ .range.end = 9999,
+ .symbols = armenian_symbols,
+ .weights = armenian_weights,
+ .items = (sizeof(armenian_symbols) / SYMBOL_SIZE),
+ .calc = calc_additive_system,
+};
+
+
+static const symbol_t decimal_symbols[] = {
+ "0", "1", "2", "3", "4", "5", "6", "7", "8", "9"
+};
+static struct list_counter_style lcs_decimal = {
+ .name = "decimal",
+ .symbols = decimal_symbols,
+ .items = (sizeof(decimal_symbols) / SYMBOL_SIZE),
+ .calc = calc_numeric_system,
+};
+
+
+static struct list_counter_style lcs_decimal_leading_zero = {
+ .name = "decimal-leading-zero",
+ .pad.length = 2,
+ .pad.value = "0",
+ .symbols = decimal_symbols,
+ .items = (sizeof(decimal_symbols) / SYMBOL_SIZE),
+ .calc = calc_numeric_system,
+};
+
+
+static const symbol_t lower_greek_symbols[] = {
+ "��", "��", "��", "��", "��", "��", "��", "��", "��", "��",
+ "��", "��", "��", "��", "��", "��", "��", "��", "��", "��",
+ "��", "��", "��", "��"
+};
+static struct list_counter_style lcs_lower_greek = {
+ .name="lower-greek",
+ .symbols = lower_greek_symbols,
+ .items = (sizeof(lower_greek_symbols) / SYMBOL_SIZE),
+ .calc = calc_alphabet_system,
+};
+
+
+static const symbol_t upper_alpha_symbols[] = {
+ "A", "B", "C", "D", "E", "F", "G", "H", "I", "J",
+ "K", "L", "M", "N", "O", "P", "Q", "R", "S", "T",
+ "U", "V", "W", "X", "Y", "Z"
+};
+static struct list_counter_style lcs_upper_alpha = {
+ .name="upper-alpha",
+ .symbols = upper_alpha_symbols,
+ .items = (sizeof(upper_alpha_symbols) / SYMBOL_SIZE),
+ .calc = calc_alphabet_system,
+};
+
+
+static const symbol_t lower_alpha_symbols[] = {
+ "a", "b", "c", "d", "e", "f", "g", "h", "i", "j",
+ "k", "l", "m", "n", "o", "p", "q", "r", "s", "t",
+ "u", "v", "w", "x", "y", "z"
+};
+static struct list_counter_style lcs_lower_alpha = {
+ .name="lower-alpha",
+ .symbols = lower_alpha_symbols,
+ .items = (sizeof(lower_alpha_symbols) / SYMBOL_SIZE),
+ .calc = calc_alphabet_system,
+};
+
+
+static const symbol_t upper_roman_symbols[] = {
+ "M", "D", "C", "L", "X", "V", "I"
+};
+static struct list_counter_style lcs_upper_roman = {
+ .name="upper-roman",
+ .symbols = upper_roman_symbols,
+ .items = (sizeof(upper_roman_symbols) / SYMBOL_SIZE),
+ .calc = calc_roman_system,
+};
+
+
+static const symbol_t lower_roman_symbols[] = {
+ "m", "d", "c", "l", "x", "v", "i"
+};
+static struct list_counter_style lcs_lower_roman = {
+ .name="lower-roman",
+ .symbols = lower_roman_symbols,
+ .items = (sizeof(lower_roman_symbols) / SYMBOL_SIZE),
+ .calc = calc_roman_system,
+};
#if 0
-static int ntolchex(char *buf, const size_t buflen, int value)
-{
- size_t alen;
- uint8_t aval[20];
- const char symtab[][4] = {
- "0", "1", "2", "3", "4", "5", "6", "7", "8", "9",
- "a", "b", "c", "d", "e", "f"
- };
- const size_t symtablen = sizeof(symtab) / 4;
-
- alen = calc_numeric_system(aval, sizeof(aval), value, symtablen);
- if (alen >= sizeof(aval)) {
- *buf = '?';
- return 1;
- }
-
- return map_aval_to_symbols(buf, buflen, aval, alen, symtab, symtablen);
-}
+static const symbol_t lower_hexidecimal_symbols[] = {
+ "0", "1", "2", "3", "4", "5", "6", "7", "8", "9",
+ "a", "b", "c", "d", "e", "f"
+};
+static struct list_counter_style lcs_lower_hexidecimal = {
+ .name="lower_hexidecimal",
+ .symbols = lower_hexidecimal_symbols,
+ .items = (sizeof(lower_hexidecimal_symbols) / SYMBOL_SIZE),
+ .calc = calc_numeric_system,
+};
#endif
-static int ntodecimal(char *buf, const size_t buflen, int value)
-{
- size_t alen;
- uint8_t aval[20];
- const char symtab[][4] = {
- "0", "1", "2", "3", "4", "5", "6", "7", "8", "9"
- };
- const size_t symtablen = sizeof(symtab) / 4;
-
- alen = calc_numeric_system(aval, sizeof(aval), value, symtablen);
- if (alen >= sizeof(aval)) {
- *buf = '?';
- return 1;
- }
- return map_aval_to_symbols(buf, buflen, aval, alen, symtab, symtablen);
-}
-
-static int ntoarmenian(char *buf, const size_t buflen, int value)
-{
- size_t alen;
- uint8_t aval[20];
- const char symtab[][4] = {
- "��", "��", "��", "��", "��", "��", "��", "��", "��",
- "��", "��", "��", "��", "��", "��", "��", "��", "��",
- "��", "��", "��", "��", "��", "��", "��", "��", "��",
- "��", "��", "��", "��", "��", "��", "��", "��", "��"
- };
- const int weighttab[] = {
- 9000, 8000, 7000, 6000, 5000, 4000, 3000, 2000, 1000,
- 900, 800, 700, 600, 500, 400, 300, 200, 100,
- 90, 80, 70, 60, 50, 40, 30, 20, 10,
- 9, 8, 7, 6, 5, 4, 3, 2, 1
- };
- const size_t symtablen = sizeof(symtab) / 4;
-
- alen = calc_additive_system(aval, sizeof(aval), value, weighttab, symtablen);
- if (alen >= sizeof(aval)) {
- *buf = '?';
- return 1;
- }
-
- return map_aval_to_symbols(buf, buflen, aval, alen, symtab, symtablen);
-}
-
-
-static int ntogeorgian(char *buf, const size_t buflen, int value)
-{
- size_t alen;
- uint8_t aval[20];
- const char symtab[][4] = {
- "���",
- "���", "���", "���", "���", "���", "���", "���", "���", "���",
- "���", "���", "���", "���", "���", "���", "���", "���", "���",
- "���", "���", "���", "���", "���", "���", "���", "���", "���",
- "���", "���", "���", "���", "���", "���", "���", "���", "���",
- };
- const int weighttab[] = {
- 10000,
- 9000, 8000, 7000, 6000, 5000, 4000, 3000, 2000, 1000,
- 900, 800, 700, 600, 500, 400, 300, 200, 100,
- 90, 80, 70, 60, 50, 40, 30, 20, 10,
- 9, 8, 7, 6, 5, 4, 3, 2, 1
- };
- const size_t symtablen = sizeof(symtab) / 4;
-
- alen = calc_additive_system(aval, sizeof(aval), value, weighttab, symtablen);
- if (alen >= sizeof(aval)) {
- *buf = '?';
- return 1;
- }
-
- return map_aval_to_symbols(buf, buflen, aval, alen, symtab, symtablen);
-}
-
-/**
- * format value into a list marker with a style
- *
- * The value is a one based index into the list. This means for
- * numeric printing the value must be incremented by one.
- */
+/* exported interface defined in html/list_counter_style.h */
size_t
list_counter_style_value(char *text,
size_t text_len,
enum css_list_style_type_e list_style_type,
- unsigned int value)
+ int value)
{
- int res = -1;
+ size_t alen;
+ uint8_t aval[20];
+ struct list_counter_style *cstyle;
switch (list_style_type) {
case CSS_LIST_STYLE_TYPE_DECIMAL_LEADING_ZERO:
- res = snprintf(text, text_len, "%02u", value);
+ cstyle = &lcs_decimal_leading_zero;
break;
case CSS_LIST_STYLE_TYPE_LOWER_ROMAN:
- res = ntolcromannumeral(text, text_len, value);
+ cstyle = &lcs_lower_roman;
break;
case CSS_LIST_STYLE_TYPE_UPPER_ROMAN:
- res = ntoucromannumeral(text, text_len, value);
+ cstyle = &lcs_upper_roman;
break;
case CSS_LIST_STYLE_TYPE_LOWER_ALPHA:
case CSS_LIST_STYLE_TYPE_LOWER_LATIN:
- res = ntolcalpha(text, text_len, value);
+ cstyle = &lcs_lower_alpha;
break;
case CSS_LIST_STYLE_TYPE_UPPER_ALPHA:
case CSS_LIST_STYLE_TYPE_UPPER_LATIN:
- res = ntoucalpha(text, text_len, value);
+ cstyle = &lcs_upper_alpha;
break;
case CSS_LIST_STYLE_TYPE_LOWER_GREEK:
- res = ntolcgreek(text, text_len, value);
+ cstyle = &lcs_lower_greek;
break;
case CSS_LIST_STYLE_TYPE_ARMENIAN:
- res = ntoarmenian(text, text_len, value);
+ cstyle = &lcs_armenian;
break;
case CSS_LIST_STYLE_TYPE_GEORGIAN:
- res = ntogeorgian(text, text_len, value);
+ cstyle = &lcs_georgian;
break;
case CSS_LIST_STYLE_TYPE_DECIMAL:
default:
- res = ntodecimal(text, text_len, value);
+ cstyle = &lcs_decimal;
break;
}
- /* deal with error */
- if (res < 0) {
- text[0] = 0;
- return 0;
- }
+ alen = cstyle->calc(aval, sizeof(aval), value, cstyle);
- /* deal with overflow */
- if ((size_t)res >= (text_len-2)) {
- res = text_len-2;
+ /* ensure it is possible to calculate with the selected system */
+ if ((alen == 0) || (alen >= sizeof(aval))) {
+ /* retry in decimal */
+ alen = lcs_decimal.calc(aval, sizeof(aval), value, &lcs_decimal);
+ if ((alen == 0) || (alen >= sizeof(aval))) {
+ /* failed in decimal, give up */
+ return 0;
+ }
}
- text[res++] = '.';
- text[res] = 0;
- return res;
+ return map_aval_to_symbols(text, text_len, aval, alen, cstyle);
}
diff --git a/content/handlers/html/list_counter_style.h b/content/handlers/html/list_counter_style.h
index 6446b93..2b1e79a 100644
--- a/content/handlers/html/list_counter_style.h
+++ b/content/handlers/html/list_counter_style.h
@@ -30,16 +30,16 @@
/**
* format value into a list marker with a style
*
- * \param text The buffer to recive the output
- * \param text_len The length available in \a text
- * \param list_style_type The css list style type
- * \param value The value to style
- * \return The size of data placed in \a text
+ * \param text buffer to recive the result
+ * \param text_len The length of the \a text buffer
+ * \param list_style_type the css list style.
+ * \param value The value to format.
+ * \return The length of the complete output which may exceed \a text_len
*/
size_t
list_counter_style_value(char *text,
size_t text_len,
enum css_list_style_type_e list_style_type,
- unsigned int value);
+ int value);
#endif
-----------------------------------------------------------------------
Summary of changes:
content/handlers/html/box_construct.c | 33 +-
content/handlers/html/list_counter_style.c | 504 ++++++++++++++--------------
content/handlers/html/list_counter_style.h | 12 +-
3 files changed, 283 insertions(+), 266 deletions(-)
diff --git a/content/handlers/html/box_construct.c b/content/handlers/html/box_construct.c
index 9204090..6c6fc24 100644
--- a/content/handlers/html/box_construct.c
+++ b/content/handlers/html/box_construct.c
@@ -398,10 +398,10 @@ static unsigned int compute_list_marker_index(struct box *last)
}
/**
- * maximum length of a list marker
+ * initial length of a list marker buffer
*
* enough for 9,999,999,999,999,999,999 in decimal
- * or six characters for 3byte utf8
+ * or five characters for 4byte utf8
*/
#define LIST_MARKER_SIZE 20
@@ -423,6 +423,7 @@ box_construct_marker(struct box *box,
lwc_string *image_uri;
struct box *marker;
enum css_list_style_type_e list_style_type;
+ size_t counter_len;
marker = box_create(NULL, box->style, false, NULL, NULL, title,
NULL, ctx->bctx);
@@ -454,7 +455,7 @@ box_construct_marker(struct box *box,
break;
case CSS_LIST_STYLE_TYPE_NONE:
- marker->text = 0;
+ marker->text = NULL;
marker->length = 0;
break;
@@ -462,13 +463,29 @@ box_construct_marker(struct box *box,
marker->rows = compute_list_marker_index(parent->last);
marker->text = talloc_array(ctx->bctx, char, LIST_MARKER_SIZE);
- if (marker->text == NULL)
+ if (marker->text == NULL) {
return false;
+ }
- marker->length = list_counter_style_value(marker->text,
- LIST_MARKER_SIZE,
- list_style_type,
- marker->rows);
+ counter_len = list_counter_style_value(marker->text,
+ LIST_MARKER_SIZE,
+ list_style_type,
+ marker->rows);
+ if (counter_len > LIST_MARKER_SIZE) {
+ /* use computed size as marker did not fit allocation */
+ marker->text = talloc_realloc(ctx->bctx,
+ marker->text,
+ char,
+ counter_len);
+ if (marker->text == NULL) {
+ return false;
+ }
+ counter_len = list_counter_style_value(marker->text,
+ counter_len,
+ list_style_type,
+ marker->rows);
+ }
+ marker->length = counter_len;
break;
}
diff --git a/content/handlers/html/list_counter_style.c b/content/handlers/html/list_counter_style.c
index af643df..ae9fb8c 100644
--- a/content/handlers/html/list_counter_style.c
+++ b/content/handlers/html/list_counter_style.c
@@ -22,13 +22,34 @@
*/
#include <stddef.h>
-#include <stdio.h>
#include "css/select.h"
#include "html/list_counter_style.h"
+#define SYMBOL_SIZE 4
+typedef char symbol_t[SYMBOL_SIZE];
+
+struct list_counter_style {
+ const char *name; /**< style name for debug purposes */
+ struct {
+ const int start; /**< first acceptable value for this style */
+ const int end; /**< last acceptable value for this style */
+ } range;
+ struct {
+ const unsigned int length;
+ const symbol_t value;
+ } pad;
+ const char *prefix;
+ const char *postfix;
+ const symbol_t *symbols; /**< array of symbols which represent this style */
+ const int *weights; /**< symbol weights for additive schemes */
+ const size_t items; /**< items in symbol and weight table */
+ size_t (*calc)(uint8_t *ares, const size_t alen, int value, const struct list_counter_style *cstyle); /**< function to calculate the system */
+};
+
+
/**
* maps alphabet values to output values with a symbol table
*
@@ -44,27 +65,60 @@
* \return The number of bytes needed in the output buffer whichmay be
* larger than \a buflen but the buffer will not be overrun
*/
-static int
+static size_t
map_aval_to_symbols(char *buf, const size_t buflen,
const uint8_t *aval, const size_t alen,
- const char symtab[][4], const size_t symtablen)
+ const struct list_counter_style *cstyle)
{
- size_t oidx;
- size_t aidx;
- int sidx;
+ size_t oidx = 0;
+ size_t pidx; /* padding index */
+ size_t aidx; /* numeral index */
+ size_t sidx; /* current symbol index */
+ const char *postfix = "."; /* default postfix string */
+
+ /* add padding if required */
+ if (alen < cstyle->pad.length) {
+ for (pidx=cstyle->pad.length - alen; pidx > 0; pidx--) {
+ sidx=0;
+ while ((sidx < 4) &&
+ (cstyle->pad.value[sidx] != 0)) {
+ if (oidx < buflen) {
+ buf[oidx] = cstyle->pad.value[sidx];
+ }
+ oidx++;
+ sidx++;
+ }
+ }
+ }
- oidx = 0;
+ /* map symbols */
for (aidx=0; aidx < alen; aidx++) {
sidx=0;
while ((sidx < 4) &&
- (symtab[aval[aidx]][sidx] != 0)) {
+ (cstyle->symbols[aval[aidx]][sidx] != 0)) {
if (oidx < buflen) {
- buf[oidx] = symtab[aval[aidx]][sidx];
+ buf[oidx] = cstyle->symbols[aval[aidx]][sidx];
}
oidx++;
sidx++;
}
}
+
+
+ /* postfix */
+ if (cstyle->postfix != NULL) {
+ postfix = cstyle->postfix;
+ }
+ sidx=0;
+ while ((sidx < 4) &&
+ (postfix[sidx] != 0)) {
+ if (oidx < buflen) {
+ buf[oidx] = postfix[sidx];
+ }
+ oidx++;
+ sidx++;
+ }
+
return oidx;
}
@@ -84,7 +138,7 @@ static size_t
calc_numeric_system(uint8_t *ares,
const size_t alen,
int value,
- unsigned char slen)
+ const struct list_counter_style *cstyle)
{
size_t idx = 0;
uint8_t *first;
@@ -92,9 +146,11 @@ calc_numeric_system(uint8_t *ares,
/* generate alphabet values in ascending order */
while (value > 0) {
- if (idx < alen) ares[idx] = value % slen;
+ if (idx < alen) {
+ ares[idx] = value % cstyle->items;
+ }
idx++;
- value = value / slen;
+ value = value / cstyle->items;
}
/* put the values in decending order */
@@ -129,10 +185,9 @@ calc_numeric_system(uint8_t *ares,
*/
static size_t
calc_additive_system(uint8_t *ares,
- const size_t alen,
- int value,
- const int weights[],
- unsigned char wlen)
+ const size_t alen,
+ int value,
+ const struct list_counter_style *cstyle)
{
size_t widx; /* weight index */
size_t aidx = 0;
@@ -140,15 +195,17 @@ calc_additive_system(uint8_t *ares,
size_t times; /* number of times a weight occours */
/* iterate over the available weights */
- for (widx = 0; widx < wlen;widx++) {
- times = value / weights[widx];
+ for (widx = 0; widx < cstyle->items;widx++) {
+ times = value / cstyle->weights[widx];
if (times > 0) {
for (idx=0;idx < times;idx++) {
- if (aidx < alen) ares[aidx] = widx;
+ if (aidx < alen) {
+ ares[aidx] = widx;
+ }
aidx++;
}
- value -= times * weights[widx];
+ value -= times * cstyle->weights[widx];
}
}
@@ -169,9 +226,9 @@ calc_additive_system(uint8_t *ares,
*/
static size_t
calc_alphabet_system(uint8_t *ares,
- const size_t alen,
- int value,
- unsigned char slen)
+ const size_t alen,
+ int value,
+ const struct list_counter_style *cstyle)
{
size_t idx = 0;
uint8_t *first;
@@ -180,9 +237,11 @@ calc_alphabet_system(uint8_t *ares,
/* generate alphabet values in ascending order */
while (value > 0) {
--value;
- if (idx < alen) ares[idx] = value % slen;
+ if (idx < alen) {
+ ares[idx] = value % cstyle->items;
+ }
idx++;
- value = value / slen;
+ value = value / cstyle->items;
}
/* put the values in decending order */
@@ -209,11 +268,11 @@ calc_alphabet_system(uint8_t *ares,
*
* \return The number of numerals that are nesesary for full output
*/
-static int
+static size_t
calc_roman_system(uint8_t *buf,
const size_t maxlen,
int value,
- unsigned char slen)
+ const struct list_counter_style *cstyle)
{
const int S[] = { 0, 2, 4, 2, 4, 2, 4 };
const int D[] = { 1000, 500, 100, 50, 10, 5, 1 };
@@ -222,7 +281,7 @@ calc_roman_system(uint8_t *buf,
unsigned int i = 0; /* index into maps */
int r, r2;
- assert(slen == 7);
+ assert(cstyle->items == 7);
while (value > 0) {
if (D[i] <= value) {
@@ -256,274 +315,215 @@ calc_roman_system(uint8_t *buf,
}
-/**
- * lower case roman numeral
- */
-static int ntolcromannumeral(char *buf, const size_t buflen, int value)
-{
- size_t alen;
- uint8_t aval[20];
- const char symtab[][4] = {
- "m", "d", "c", "l", "x", "v", "i"
- };
- const size_t symtablen = sizeof(symtab) / 4;
-
- alen = calc_roman_system(aval, sizeof(aval), value, symtablen);
- if (alen >= sizeof(aval)) {
- *buf = '?';
- return 1;
- }
-
- return map_aval_to_symbols(buf, buflen, aval, alen, symtab, symtablen);
-}
-
-/**
- * upper case roman numeral
- */
-static int ntoucromannumeral(char *buf, const size_t buflen, int value)
-{
- size_t alen;
- uint8_t aval[20];
- const char symtab[][4] = {
- "M", "D", "C", "L", "X", "V", "I"
- };
- const size_t symtablen = sizeof(symtab) / 4;
-
- alen = calc_roman_system(aval, sizeof(aval), value, symtablen);
- if (alen >= sizeof(aval)) {
- *buf = '?';
- return 1;
- }
-
- return map_aval_to_symbols(buf, buflen, aval, alen, symtab, symtablen);
-}
-
-
-
-
-static int ntolcalpha(char *buf, const size_t buflen, int value)
-{
- size_t alen;
- uint8_t aval[20];
- const char symtab[][4] = {
- "a", "b", "c", "d", "e", "f", "g", "h", "i", "j",
- "k", "l", "m", "n", "o", "p", "q", "r", "s", "t",
- "u", "v", "w", "x", "y", "z"
- };
- const size_t symtablen = sizeof(symtab) / 4;
-
- alen = calc_alphabet_system(aval, sizeof(aval), value, symtablen);
- if (alen >= sizeof(aval)) {
- *buf = '?';
- return 1;
- }
-
- return map_aval_to_symbols(buf, buflen, aval, alen, symtab, symtablen);
-}
-
-static int ntoucalpha(char *buf, const size_t buflen, int value)
-{
- size_t alen;
- uint8_t aval[20];
- const char symtab[][4] = {
- "A", "B", "C", "D", "E", "F", "G", "H", "I", "J",
- "K", "L", "M", "N", "O", "P", "Q", "R", "S", "T",
- "U", "V", "W", "X", "Y", "Z"
- };
- const size_t symtablen = sizeof(symtab) / 4;
-
- alen = calc_alphabet_system(aval, sizeof(aval), value, symtablen);
- if (alen >= sizeof(aval)) {
- *buf = '?';
- return 1;
- }
-
- return map_aval_to_symbols(buf, buflen, aval, alen, symtab, symtablen);
-}
-
-static int ntolcgreek(char *buf, const size_t buflen, int value)
-{
- size_t alen;
- uint8_t aval[20];
- const char symtab[][4] = {
- "��", "��", "��", "��", "��", "��", "��", "��", "��", "��",
- "��", "��", "��", "��", "��", "��", "��", "��", "��", "��",
- "��", "��", "��", "��"
- };
- const size_t symtablen = sizeof(symtab) / 4;
-
- alen = calc_alphabet_system(aval, sizeof(aval), value, symtablen);
- if (alen >= sizeof(aval)) {
- *buf = '?';
- return 1;
- }
-
- return map_aval_to_symbols(buf, buflen, aval, alen, symtab, symtablen);
-}
+/* tables for all the counter styles */
+
+
+static const symbol_t georgian_symbols[] = {
+ "���",
+ "���", "���", "���", "���", "���", "���", "���", "���", "���",
+ "���", "���", "���", "���", "���", "���", "���", "���", "���",
+ "���", "���", "���", "���", "���", "���", "���", "���", "���",
+ "���", "���", "���", "���", "���", "���", "���", "���", "���",
+};
+static const int georgian_weights[] = {
+ 10000,
+ 9000, 8000, 7000, 6000, 5000, 4000, 3000, 2000, 1000,
+ 900, 800, 700, 600, 500, 400, 300, 200, 100,
+ 90, 80, 70, 60, 50, 40, 30, 20, 10,
+ 9, 8, 7, 6, 5, 4, 3, 2, 1
+};
+static struct list_counter_style lcs_georgian = {
+ .name="georgian",
+ .range.start = 1,
+ .range.end = 19999,
+ .symbols = georgian_symbols,
+ .weights = georgian_weights,
+ .items = (sizeof(georgian_symbols) / SYMBOL_SIZE),
+ .calc = calc_additive_system,
+};
+
+
+static const symbol_t armenian_symbols[] = {
+ "��", "��", "��", "��", "��", "��", "��", "��", "��",
+ "��", "��", "��", "��", "��", "��", "��", "��", "��",
+ "��", "��", "��", "��", "��", "��", "��", "��", "��",
+ "��", "��", "��", "��", "��", "��", "��", "��", "��"
+};
+static const int armenian_weights[] = {
+ 9000, 8000, 7000, 6000, 5000, 4000, 3000, 2000, 1000,
+ 900, 800, 700, 600, 500, 400, 300, 200, 100,
+ 90, 80, 70, 60, 50, 40, 30, 20, 10,
+ 9, 8, 7, 6, 5, 4, 3, 2, 1
+};
+static struct list_counter_style lcs_armenian = {
+ .name = "armenian",
+ .range.start = 1,
+ .range.end = 9999,
+ .symbols = armenian_symbols,
+ .weights = armenian_weights,
+ .items = (sizeof(armenian_symbols) / SYMBOL_SIZE),
+ .calc = calc_additive_system,
+};
+
+
+static const symbol_t decimal_symbols[] = {
+ "0", "1", "2", "3", "4", "5", "6", "7", "8", "9"
+};
+static struct list_counter_style lcs_decimal = {
+ .name = "decimal",
+ .symbols = decimal_symbols,
+ .items = (sizeof(decimal_symbols) / SYMBOL_SIZE),
+ .calc = calc_numeric_system,
+};
+
+
+static struct list_counter_style lcs_decimal_leading_zero = {
+ .name = "decimal-leading-zero",
+ .pad.length = 2,
+ .pad.value = "0",
+ .symbols = decimal_symbols,
+ .items = (sizeof(decimal_symbols) / SYMBOL_SIZE),
+ .calc = calc_numeric_system,
+};
+
+
+static const symbol_t lower_greek_symbols[] = {
+ "��", "��", "��", "��", "��", "��", "��", "��", "��", "��",
+ "��", "��", "��", "��", "��", "��", "��", "��", "��", "��",
+ "��", "��", "��", "��"
+};
+static struct list_counter_style lcs_lower_greek = {
+ .name="lower-greek",
+ .symbols = lower_greek_symbols,
+ .items = (sizeof(lower_greek_symbols) / SYMBOL_SIZE),
+ .calc = calc_alphabet_system,
+};
+
+
+static const symbol_t upper_alpha_symbols[] = {
+ "A", "B", "C", "D", "E", "F", "G", "H", "I", "J",
+ "K", "L", "M", "N", "O", "P", "Q", "R", "S", "T",
+ "U", "V", "W", "X", "Y", "Z"
+};
+static struct list_counter_style lcs_upper_alpha = {
+ .name="upper-alpha",
+ .symbols = upper_alpha_symbols,
+ .items = (sizeof(upper_alpha_symbols) / SYMBOL_SIZE),
+ .calc = calc_alphabet_system,
+};
+
+
+static const symbol_t lower_alpha_symbols[] = {
+ "a", "b", "c", "d", "e", "f", "g", "h", "i", "j",
+ "k", "l", "m", "n", "o", "p", "q", "r", "s", "t",
+ "u", "v", "w", "x", "y", "z"
+};
+static struct list_counter_style lcs_lower_alpha = {
+ .name="lower-alpha",
+ .symbols = lower_alpha_symbols,
+ .items = (sizeof(lower_alpha_symbols) / SYMBOL_SIZE),
+ .calc = calc_alphabet_system,
+};
+
+
+static const symbol_t upper_roman_symbols[] = {
+ "M", "D", "C", "L", "X", "V", "I"
+};
+static struct list_counter_style lcs_upper_roman = {
+ .name="upper-roman",
+ .symbols = upper_roman_symbols,
+ .items = (sizeof(upper_roman_symbols) / SYMBOL_SIZE),
+ .calc = calc_roman_system,
+};
+
+
+static const symbol_t lower_roman_symbols[] = {
+ "m", "d", "c", "l", "x", "v", "i"
+};
+static struct list_counter_style lcs_lower_roman = {
+ .name="lower-roman",
+ .symbols = lower_roman_symbols,
+ .items = (sizeof(lower_roman_symbols) / SYMBOL_SIZE),
+ .calc = calc_roman_system,
+};
#if 0
-static int ntolchex(char *buf, const size_t buflen, int value)
-{
- size_t alen;
- uint8_t aval[20];
- const char symtab[][4] = {
- "0", "1", "2", "3", "4", "5", "6", "7", "8", "9",
- "a", "b", "c", "d", "e", "f"
- };
- const size_t symtablen = sizeof(symtab) / 4;
-
- alen = calc_numeric_system(aval, sizeof(aval), value, symtablen);
- if (alen >= sizeof(aval)) {
- *buf = '?';
- return 1;
- }
-
- return map_aval_to_symbols(buf, buflen, aval, alen, symtab, symtablen);
-}
+static const symbol_t lower_hexidecimal_symbols[] = {
+ "0", "1", "2", "3", "4", "5", "6", "7", "8", "9",
+ "a", "b", "c", "d", "e", "f"
+};
+static struct list_counter_style lcs_lower_hexidecimal = {
+ .name="lower_hexidecimal",
+ .symbols = lower_hexidecimal_symbols,
+ .items = (sizeof(lower_hexidecimal_symbols) / SYMBOL_SIZE),
+ .calc = calc_numeric_system,
+};
#endif
-static int ntodecimal(char *buf, const size_t buflen, int value)
-{
- size_t alen;
- uint8_t aval[20];
- const char symtab[][4] = {
- "0", "1", "2", "3", "4", "5", "6", "7", "8", "9"
- };
- const size_t symtablen = sizeof(symtab) / 4;
-
- alen = calc_numeric_system(aval, sizeof(aval), value, symtablen);
- if (alen >= sizeof(aval)) {
- *buf = '?';
- return 1;
- }
- return map_aval_to_symbols(buf, buflen, aval, alen, symtab, symtablen);
-}
-
-static int ntoarmenian(char *buf, const size_t buflen, int value)
-{
- size_t alen;
- uint8_t aval[20];
- const char symtab[][4] = {
- "��", "��", "��", "��", "��", "��", "��", "��", "��",
- "��", "��", "��", "��", "��", "��", "��", "��", "��",
- "��", "��", "��", "��", "��", "��", "��", "��", "��",
- "��", "��", "��", "��", "��", "��", "��", "��", "��"
- };
- const int weighttab[] = {
- 9000, 8000, 7000, 6000, 5000, 4000, 3000, 2000, 1000,
- 900, 800, 700, 600, 500, 400, 300, 200, 100,
- 90, 80, 70, 60, 50, 40, 30, 20, 10,
- 9, 8, 7, 6, 5, 4, 3, 2, 1
- };
- const size_t symtablen = sizeof(symtab) / 4;
-
- alen = calc_additive_system(aval, sizeof(aval), value, weighttab, symtablen);
- if (alen >= sizeof(aval)) {
- *buf = '?';
- return 1;
- }
-
- return map_aval_to_symbols(buf, buflen, aval, alen, symtab, symtablen);
-}
-
-
-static int ntogeorgian(char *buf, const size_t buflen, int value)
-{
- size_t alen;
- uint8_t aval[20];
- const char symtab[][4] = {
- "���",
- "���", "���", "���", "���", "���", "���", "���", "���", "���",
- "���", "���", "���", "���", "���", "���", "���", "���", "���",
- "���", "���", "���", "���", "���", "���", "���", "���", "���",
- "���", "���", "���", "���", "���", "���", "���", "���", "���",
- };
- const int weighttab[] = {
- 10000,
- 9000, 8000, 7000, 6000, 5000, 4000, 3000, 2000, 1000,
- 900, 800, 700, 600, 500, 400, 300, 200, 100,
- 90, 80, 70, 60, 50, 40, 30, 20, 10,
- 9, 8, 7, 6, 5, 4, 3, 2, 1
- };
- const size_t symtablen = sizeof(symtab) / 4;
-
- alen = calc_additive_system(aval, sizeof(aval), value, weighttab, symtablen);
- if (alen >= sizeof(aval)) {
- *buf = '?';
- return 1;
- }
-
- return map_aval_to_symbols(buf, buflen, aval, alen, symtab, symtablen);
-}
-
-/**
- * format value into a list marker with a style
- *
- * The value is a one based index into the list. This means for
- * numeric printing the value must be incremented by one.
- */
+/* exported interface defined in html/list_counter_style.h */
size_t
list_counter_style_value(char *text,
size_t text_len,
enum css_list_style_type_e list_style_type,
- unsigned int value)
+ int value)
{
- int res = -1;
+ size_t alen;
+ uint8_t aval[20];
+ struct list_counter_style *cstyle;
switch (list_style_type) {
case CSS_LIST_STYLE_TYPE_DECIMAL_LEADING_ZERO:
- res = snprintf(text, text_len, "%02u", value);
+ cstyle = &lcs_decimal_leading_zero;
break;
case CSS_LIST_STYLE_TYPE_LOWER_ROMAN:
- res = ntolcromannumeral(text, text_len, value);
+ cstyle = &lcs_lower_roman;
break;
case CSS_LIST_STYLE_TYPE_UPPER_ROMAN:
- res = ntoucromannumeral(text, text_len, value);
+ cstyle = &lcs_upper_roman;
break;
case CSS_LIST_STYLE_TYPE_LOWER_ALPHA:
case CSS_LIST_STYLE_TYPE_LOWER_LATIN:
- res = ntolcalpha(text, text_len, value);
+ cstyle = &lcs_lower_alpha;
break;
case CSS_LIST_STYLE_TYPE_UPPER_ALPHA:
case CSS_LIST_STYLE_TYPE_UPPER_LATIN:
- res = ntoucalpha(text, text_len, value);
+ cstyle = &lcs_upper_alpha;
break;
case CSS_LIST_STYLE_TYPE_LOWER_GREEK:
- res = ntolcgreek(text, text_len, value);
+ cstyle = &lcs_lower_greek;
break;
case CSS_LIST_STYLE_TYPE_ARMENIAN:
- res = ntoarmenian(text, text_len, value);
+ cstyle = &lcs_armenian;
break;
case CSS_LIST_STYLE_TYPE_GEORGIAN:
- res = ntogeorgian(text, text_len, value);
+ cstyle = &lcs_georgian;
break;
case CSS_LIST_STYLE_TYPE_DECIMAL:
default:
- res = ntodecimal(text, text_len, value);
+ cstyle = &lcs_decimal;
break;
}
- /* deal with error */
- if (res < 0) {
- text[0] = 0;
- return 0;
- }
+ alen = cstyle->calc(aval, sizeof(aval), value, cstyle);
- /* deal with overflow */
- if ((size_t)res >= (text_len-2)) {
- res = text_len-2;
+ /* ensure it is possible to calculate with the selected system */
+ if ((alen == 0) || (alen >= sizeof(aval))) {
+ /* retry in decimal */
+ alen = lcs_decimal.calc(aval, sizeof(aval), value, &lcs_decimal);
+ if ((alen == 0) || (alen >= sizeof(aval))) {
+ /* failed in decimal, give up */
+ return 0;
+ }
}
- text[res++] = '.';
- text[res] = 0;
- return res;
+ return map_aval_to_symbols(text, text_len, aval, alen, cstyle);
}
diff --git a/content/handlers/html/list_counter_style.h b/content/handlers/html/list_counter_style.h
index 6446b93..2b1e79a 100644
--- a/content/handlers/html/list_counter_style.h
+++ b/content/handlers/html/list_counter_style.h
@@ -30,16 +30,16 @@
/**
* format value into a list marker with a style
*
- * \param text The buffer to recive the output
- * \param text_len The length available in \a text
- * \param list_style_type The css list style type
- * \param value The value to style
- * \return The size of data placed in \a text
+ * \param text buffer to recive the result
+ * \param text_len The length of the \a text buffer
+ * \param list_style_type the css list style.
+ * \param value The value to format.
+ * \return The length of the complete output which may exceed \a text_len
*/
size_t
list_counter_style_value(char *text,
size_t text_len,
enum css_list_style_type_e list_style_type,
- unsigned int value);
+ int value);
#endif
--
NetSurf Browser
1 year, 12 months
libdom: branch master updated. release/0.4.1-6-ga2ffae6
by NetSurf Browser Project
Gitweb links:
...log http://git.netsurf-browser.org/libdom.git/shortlog/a2ffae698d4c12d9457c62...
...commit http://git.netsurf-browser.org/libdom.git/commit/a2ffae698d4c12d9457c62b7...
...tree http://git.netsurf-browser.org/libdom.git/tree/a2ffae698d4c12d9457c62b79e...
The branch, master has been updated
via a2ffae698d4c12d9457c62b79eddd4342e2e213c (commit)
from c90f98b7d5bdaecb1c497b155af5347aedb1d617 (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/libdom.git/commit/?id=a2ffae698d4c12d9457c...
commit a2ffae698d4c12d9457c62b79eddd4342e2e213c
Author: Michael Drake <michael.drake(a)codethink.co.uk>
Commit: Michael Drake <michael.drake(a)codethink.co.uk>
Constify vtables.
diff --git a/include/dom/core/node.h b/include/dom/core/node.h
index 9600e6d..5058c78 100644
--- a/include/dom/core/node.h
+++ b/include/dom/core/node.h
@@ -77,7 +77,7 @@ typedef struct dom_node_internal dom_node_internal;
* DOM node type
*/
typedef struct dom_node {
- void *vtable;
+ const void *vtable;
uint32_t refcnt;
} dom_node;
diff --git a/src/core/attr.c b/src/core/attr.c
index e18e2a7..8fcaac3 100644
--- a/src/core/attr.c
+++ b/src/core/attr.c
@@ -49,7 +49,7 @@ struct dom_attr {
};
/* The vtable for dom_attr node */
-static struct dom_attr_vtable attr_vtable = {
+static const struct dom_attr_vtable attr_vtable = {
{
{
DOM_NODE_EVENT_TARGET_VTABLE,
@@ -60,7 +60,7 @@ static struct dom_attr_vtable attr_vtable = {
};
/* The protected vtable for dom_attr */
-static struct dom_node_protect_vtable attr_protect_vtable = {
+static const struct dom_node_protect_vtable attr_protect_vtable = {
DOM_ATTR_PROTECT_VTABLE
};
diff --git a/src/core/cdatasection.c b/src/core/cdatasection.c
index c6812e3..efba237 100644
--- a/src/core/cdatasection.c
+++ b/src/core/cdatasection.c
@@ -20,7 +20,7 @@ struct dom_cdata_section {
dom_text base; /**< Base node */
};
-static struct dom_node_protect_vtable cdata_section_protect_vtable = {
+static const struct dom_node_protect_vtable cdata_section_protect_vtable = {
DOM_CDATA_SECTION_PROTECT_VTABLE
};
diff --git a/src/core/characterdata.c b/src/core/characterdata.c
index ea665b3..e6f5dbe 100644
--- a/src/core/characterdata.c
+++ b/src/core/characterdata.c
@@ -21,7 +21,7 @@
/* The virtual functions for dom_characterdata, we make this vtable
* public to each child class */
-struct dom_characterdata_vtable characterdata_vtable = {
+const struct dom_characterdata_vtable characterdata_vtable = {
{
{
DOM_NODE_EVENT_TARGET_VTABLE
diff --git a/src/core/characterdata.h b/src/core/characterdata.h
index 0b0889c..c8f4db3 100644
--- a/src/core/characterdata.h
+++ b/src/core/characterdata.h
@@ -116,7 +116,7 @@ dom_exception _dom_characterdata_copy(dom_node_internal *old,
_dom_characterdata_destroy, \
_dom_characterdata_copy
-extern struct dom_characterdata_vtable characterdata_vtable;
+extern const struct dom_characterdata_vtable characterdata_vtable;
dom_exception _dom_characterdata_copy_internal(dom_characterdata *old,
dom_characterdata *new);
diff --git a/src/core/comment.c b/src/core/comment.c
index 0697826..b36a1be 100644
--- a/src/core/comment.c
+++ b/src/core/comment.c
@@ -21,7 +21,7 @@ struct dom_comment {
dom_characterdata base; /**< Base node */
};
-static struct dom_node_protect_vtable comment_protect_vtable = {
+static const struct dom_node_protect_vtable comment_protect_vtable = {
DOM_COMMENT_PROTECT_VTABLE
};
diff --git a/src/core/doc_fragment.c b/src/core/doc_fragment.c
index 96cc707..9e10a1a 100644
--- a/src/core/doc_fragment.c
+++ b/src/core/doc_fragment.c
@@ -22,14 +22,14 @@ struct dom_document_fragment {
dom_node_internal base; /**< Base node */
};
-static struct dom_node_vtable df_vtable = {
+static const struct dom_node_vtable df_vtable = {
{
DOM_NODE_EVENT_TARGET_VTABLE
},
DOM_NODE_VTABLE
};
-static struct dom_node_protect_vtable df_protect_vtable = {
+static const struct dom_node_protect_vtable df_protect_vtable = {
DOM_DF_PROTECT_VTABLE
};
diff --git a/src/core/document.c b/src/core/document.c
index 7c0bcdc..40d4cd9 100644
--- a/src/core/document.c
+++ b/src/core/document.c
@@ -42,7 +42,7 @@ struct dom_doc_nl {
};
/* The virtual functions of this dom_document */
-static struct dom_document_vtable document_vtable = {
+static const struct dom_document_vtable document_vtable = {
{
{
DOM_NODE_EVENT_TARGET_VTABLE
@@ -52,7 +52,7 @@ static struct dom_document_vtable document_vtable = {
DOM_DOCUMENT_VTABLE
};
-static struct dom_node_protect_vtable document_protect_vtable = {
+static const struct dom_node_protect_vtable document_protect_vtable = {
DOM_DOCUMENT_PROTECT_VTABLE
};
diff --git a/src/core/document_type.c b/src/core/document_type.c
index d7b1b99..a0fafdd 100644
--- a/src/core/document_type.c
+++ b/src/core/document_type.c
@@ -27,7 +27,7 @@ struct dom_document_type {
dom_string *system_id; /**< Doctype system ID */
};
-static struct dom_document_type_vtable document_type_vtable = {
+static const struct dom_document_type_vtable document_type_vtable = {
{
{
DOM_NODE_EVENT_TARGET_VTABLE
@@ -37,7 +37,7 @@ static struct dom_document_type_vtable document_type_vtable = {
DOM_DOCUMENT_TYPE_VTABLE
};
-static struct dom_node_protect_vtable dt_protect_vtable = {
+static const struct dom_node_protect_vtable dt_protect_vtable = {
DOM_DT_PROTECT_VTABLE
};
diff --git a/src/core/element.c b/src/core/element.c
index dbdd56b..3b031a0 100644
--- a/src/core/element.c
+++ b/src/core/element.c
@@ -32,7 +32,7 @@
#include "utils/list.h"
#include "events/mutation_event.h"
-struct dom_element_vtable _dom_element_vtable = {
+const struct dom_element_vtable _dom_element_vtable = {
{
{
DOM_NODE_EVENT_TARGET_VTABLE
@@ -42,7 +42,7 @@ struct dom_element_vtable _dom_element_vtable = {
DOM_ELEMENT_VTABLE
};
-static struct dom_element_protected_vtable element_protect_vtable = {
+static const struct dom_element_protected_vtable element_protect_vtable = {
{
DOM_NODE_PROTECT_VTABLE_ELEMENT
},
diff --git a/src/core/element.h b/src/core/element.h
index c89ddc0..fb946b7 100644
--- a/src/core/element.h
+++ b/src/core/element.h
@@ -238,6 +238,6 @@ dom_exception _dom_element_copy_internal(dom_element *old,
dom_exception _dom_element_get_id(struct dom_element *ele, dom_string **id);
-extern struct dom_element_vtable _dom_element_vtable;
+extern const struct dom_element_vtable _dom_element_vtable;
#endif
diff --git a/src/core/entity_ref.c b/src/core/entity_ref.c
index aa32111..bc6fbab 100644
--- a/src/core/entity_ref.c
+++ b/src/core/entity_ref.c
@@ -20,14 +20,14 @@ struct dom_entity_reference {
dom_node_internal base; /**< Base node */
};
-static struct dom_node_vtable er_vtable = {
+static const struct dom_node_vtable er_vtable = {
{
DOM_NODE_EVENT_TARGET_VTABLE
},
DOM_NODE_VTABLE
};
-static struct dom_node_protect_vtable er_protect_vtable = {
+static const struct dom_node_protect_vtable er_protect_vtable = {
DOM_ER_PROTECT_VTABLE
};
diff --git a/src/core/node.c b/src/core/node.c
index b471725..f8b8def 100644
--- a/src/core/node.c
+++ b/src/core/node.c
@@ -55,14 +55,14 @@ static inline dom_exception _dom_node_detach_range(dom_node_internal *first,
static inline void _dom_node_replace(dom_node_internal *old,
dom_node_internal *replacement);
-static struct dom_node_vtable node_vtable = {
+static const struct dom_node_vtable node_vtable = {
{
DOM_NODE_EVENT_TARGET_VTABLE
},
DOM_NODE_VTABLE
};
-static struct dom_node_protect_vtable node_protect_vtable = {
+static const struct dom_node_protect_vtable node_protect_vtable = {
DOM_NODE_PROTECT_VTABLE
};
diff --git a/src/core/node.h b/src/core/node.h
index 87f3cb3..36d0ec1 100644
--- a/src/core/node.h
+++ b/src/core/node.h
@@ -53,7 +53,7 @@ typedef struct dom_node_protect_vtable {
*/
struct dom_node_internal {
struct dom_node base; /**< The vtable base */
- void *vtable; /**< The protected vtable */
+ const void *vtable; /**< The protected vtable */
dom_string *name; /**< Node name (this is the local part
* of a QName in the cases where a
diff --git a/src/core/pi.c b/src/core/pi.c
index d12f109..3e69841 100644
--- a/src/core/pi.c
+++ b/src/core/pi.c
@@ -20,14 +20,14 @@ struct dom_processing_instruction {
dom_node_internal base; /**< Base node */
};
-static struct dom_node_vtable pi_vtable = {
+static const struct dom_node_vtable pi_vtable = {
{
DOM_NODE_EVENT_TARGET_VTABLE
},
DOM_NODE_VTABLE
};
-static struct dom_node_protect_vtable pi_protect_vtable = {
+static const struct dom_node_protect_vtable pi_protect_vtable = {
DOM_PI_PROTECT_VTABLE
};
/**
diff --git a/src/core/text.c b/src/core/text.c
index b73e86d..f63fabe 100644
--- a/src/core/text.c
+++ b/src/core/text.c
@@ -20,7 +20,7 @@
#include "utils/utils.h"
/* The virtual table for dom_text */
-struct dom_text_vtable text_vtable = {
+const struct dom_text_vtable text_vtable = {
{
{
{
@@ -33,7 +33,7 @@ struct dom_text_vtable text_vtable = {
DOM_TEXT_VTABLE
};
-static struct dom_node_protect_vtable text_protect_vtable = {
+static const struct dom_node_protect_vtable text_protect_vtable = {
DOM_TEXT_PROTECT_VTABLE
};
diff --git a/src/core/text.h b/src/core/text.h
index 26424ce..3f5739b 100644
--- a/src/core/text.h
+++ b/src/core/text.h
@@ -66,7 +66,7 @@ dom_exception _dom_text_copy(dom_node_internal *old, dom_node_internal **copy);
__dom_text_destroy, \
_dom_text_copy
-extern struct dom_text_vtable text_vtable;
+extern const struct dom_text_vtable text_vtable;
dom_exception _dom_text_copy_internal(dom_text *old, dom_text *new);
#define dom_text_copy_internal(o, n) \
diff --git a/src/events/event.c b/src/events/event.c
index 3fe9978..26b245e 100644
--- a/src/events/event.c
+++ b/src/events/event.c
@@ -18,7 +18,7 @@
static void _virtual_dom_event_destroy(dom_event *evt);
-static struct dom_event_private_vtable _event_vtable = {
+static const struct dom_event_private_vtable _event_vtable = {
_virtual_dom_event_destroy
};
diff --git a/src/events/event.h b/src/events/event.h
index 857f20a..7cada7b 100644
--- a/src/events/event.h
+++ b/src/events/event.h
@@ -45,7 +45,7 @@ struct dom_event {
uint32_t refcnt; /**< The reference count of this object */
- struct dom_event_private_vtable *vtable;
+ const struct dom_event_private_vtable *vtable;
/**< The private virtual function table of Event */
bool in_dispatch; /**< Whether this event is in dispatch */
bool is_initialised; /**< Whether this event is initialised */
diff --git a/src/events/keyboard_event.c b/src/events/keyboard_event.c
index d349355..d1fa1ca 100644
--- a/src/events/keyboard_event.c
+++ b/src/events/keyboard_event.c
@@ -15,7 +15,7 @@
static void _virtual_dom_keyboard_event_destroy(struct dom_event *evt);
-static struct dom_event_private_vtable _event_vtable = {
+static const struct dom_event_private_vtable _event_vtable = {
_virtual_dom_keyboard_event_destroy
};
diff --git a/src/events/mouse_event.c b/src/events/mouse_event.c
index b3b2154..ac1d142 100644
--- a/src/events/mouse_event.c
+++ b/src/events/mouse_event.c
@@ -15,7 +15,7 @@
static void _virtual_dom_mouse_event_destroy(struct dom_event *evt);
-static struct dom_event_private_vtable _event_vtable = {
+static const struct dom_event_private_vtable _event_vtable = {
_virtual_dom_mouse_event_destroy
};
diff --git a/src/events/mouse_multi_wheel_event.c b/src/events/mouse_multi_wheel_event.c
index bcbe8d5..a42085a 100644
--- a/src/events/mouse_multi_wheel_event.c
+++ b/src/events/mouse_multi_wheel_event.c
@@ -16,7 +16,7 @@
static void _virtual_dom_mouse_multi_wheel_event_destroy(
struct dom_event *evt);
-static struct dom_event_private_vtable _event_vtable = {
+static const struct dom_event_private_vtable _event_vtable = {
_virtual_dom_mouse_multi_wheel_event_destroy
};
diff --git a/src/events/mouse_wheel_event.c b/src/events/mouse_wheel_event.c
index d59eab1..5d6bdd6 100644
--- a/src/events/mouse_wheel_event.c
+++ b/src/events/mouse_wheel_event.c
@@ -15,7 +15,7 @@
static void _virtual_dom_mouse_wheel_event_destroy(struct dom_event *evt);
-static struct dom_event_private_vtable _event_vtable = {
+static const struct dom_event_private_vtable _event_vtable = {
_virtual_dom_mouse_wheel_event_destroy
};
diff --git a/src/events/mutation_event.c b/src/events/mutation_event.c
index df92c5f..2c5ffdc 100644
--- a/src/events/mutation_event.c
+++ b/src/events/mutation_event.c
@@ -11,7 +11,7 @@
static void _virtual_dom_mutation_event_destroy(struct dom_event *evt);
-static struct dom_event_private_vtable _event_vtable = {
+static const struct dom_event_private_vtable _event_vtable = {
_virtual_dom_mutation_event_destroy
};
diff --git a/src/events/mutation_name_event.c b/src/events/mutation_name_event.c
index e0ba82e..13a51b5 100644
--- a/src/events/mutation_name_event.c
+++ b/src/events/mutation_name_event.c
@@ -14,7 +14,7 @@
static void _virtual_dom_mutation_name_event_destroy(struct dom_event *evt);
-static struct dom_event_private_vtable _event_vtable = {
+static const struct dom_event_private_vtable _event_vtable = {
_virtual_dom_mutation_name_event_destroy
};
diff --git a/src/events/text_event.c b/src/events/text_event.c
index 3437716..d0d2706 100644
--- a/src/events/text_event.c
+++ b/src/events/text_event.c
@@ -12,7 +12,7 @@
static void _virtual_dom_text_event_destroy(struct dom_event *evt);
-static struct dom_event_private_vtable _event_vtable = {
+static const struct dom_event_private_vtable _event_vtable = {
_virtual_dom_text_event_destroy
};
diff --git a/src/events/ui_event.c b/src/events/ui_event.c
index 34ec84d..672f999 100644
--- a/src/events/ui_event.c
+++ b/src/events/ui_event.c
@@ -11,7 +11,7 @@
static void _virtual_dom_ui_event_destroy(struct dom_event *evt);
-static struct dom_event_private_vtable _event_vtable = {
+static const struct dom_event_private_vtable _event_vtable = {
_virtual_dom_ui_event_destroy
};
diff --git a/src/html/html_anchor_element.c b/src/html/html_anchor_element.c
index 8d64c2b..88fd2ac 100644
--- a/src/html/html_anchor_element.c
+++ b/src/html/html_anchor_element.c
@@ -18,7 +18,7 @@
#include "core/attr.h"
#include "utils/utils.h"
-static struct dom_element_protected_vtable _protect_vtable = {
+static const struct dom_element_protected_vtable _protect_vtable = {
{
DOM_NODE_PROTECT_VTABLE_HTML_ANCHOR_ELEMENT
},
diff --git a/src/html/html_applet_element.c b/src/html/html_applet_element.c
index 93ea1b5..f7f1afc 100644
--- a/src/html/html_applet_element.c
+++ b/src/html/html_applet_element.c
@@ -18,7 +18,7 @@
#include "core/attr.h"
#include "utils/utils.h"
-static struct dom_element_protected_vtable _protect_vtable = {
+static const struct dom_element_protected_vtable _protect_vtable = {
{
DOM_NODE_PROTECT_VTABLE_HTML_APPLET_ELEMENT
},
diff --git a/src/html/html_area_element.c b/src/html/html_area_element.c
index 828b073..3da59d7 100644
--- a/src/html/html_area_element.c
+++ b/src/html/html_area_element.c
@@ -17,7 +17,7 @@
#include "core/attr.h"
#include "utils/utils.h"
-static struct dom_element_protected_vtable _protect_vtable = {
+static const struct dom_element_protected_vtable _protect_vtable = {
{
DOM_NODE_PROTECT_VTABLE_HTML_AREA_ELEMENT
},
diff --git a/src/html/html_base_element.c b/src/html/html_base_element.c
index 0034f7c..f322f5b 100644
--- a/src/html/html_base_element.c
+++ b/src/html/html_base_element.c
@@ -13,7 +13,7 @@
#include "core/node.h"
#include "utils/utils.h"
-static struct dom_element_protected_vtable _protect_vtable = {
+static const struct dom_element_protected_vtable _protect_vtable = {
{
DOM_NODE_PROTECT_VTABLE_HTML_BASE_ELEMENT
},
diff --git a/src/html/html_basefont_element.c b/src/html/html_basefont_element.c
index ac1183d..b68ae03 100644
--- a/src/html/html_basefont_element.c
+++ b/src/html/html_basefont_element.c
@@ -17,7 +17,7 @@
#include "core/attr.h"
#include "utils/utils.h"
-static struct dom_element_protected_vtable _protect_vtable = {
+static const struct dom_element_protected_vtable _protect_vtable = {
{
DOM_NODE_PROTECT_VTABLE_HTML_BASE_FONT_ELEMENT
},
diff --git a/src/html/html_body_element.c b/src/html/html_body_element.c
index 0fc4b13..4f52152 100644
--- a/src/html/html_body_element.c
+++ b/src/html/html_body_element.c
@@ -15,7 +15,7 @@
#include "core/node.h"
#include "utils/utils.h"
-static struct dom_element_protected_vtable _protect_vtable = {
+static const struct dom_element_protected_vtable _protect_vtable = {
{
DOM_NODE_PROTECT_VTABLE_HTML_BODY_ELEMENT
},
diff --git a/src/html/html_br_element.c b/src/html/html_br_element.c
index 74e3ea8..71778f6 100644
--- a/src/html/html_br_element.c
+++ b/src/html/html_br_element.c
@@ -17,7 +17,7 @@
#include "core/attr.h"
#include "utils/utils.h"
-static struct dom_element_protected_vtable _protect_vtable = {
+static const struct dom_element_protected_vtable _protect_vtable = {
{
DOM_NODE_PROTECT_VTABLE_HTML_BR_ELEMENT
},
diff --git a/src/html/html_button_element.c b/src/html/html_button_element.c
index 04a17dd..52a3607 100644
--- a/src/html/html_button_element.c
+++ b/src/html/html_button_element.c
@@ -17,7 +17,7 @@
#include "core/attr.h"
#include "utils/utils.h"
-static struct dom_element_protected_vtable _protect_vtable = {
+static const struct dom_element_protected_vtable _protect_vtable = {
{
DOM_NODE_PROTECT_VTABLE_HTML_BUTTON_ELEMENT
},
diff --git a/src/html/html_canvas_element.c b/src/html/html_canvas_element.c
index 8e5d3fc..71d4a53 100644
--- a/src/html/html_canvas_element.c
+++ b/src/html/html_canvas_element.c
@@ -17,7 +17,7 @@
#include "core/attr.h"
#include "utils/utils.h"
-static struct dom_element_protected_vtable _protect_vtable = {
+static const struct dom_element_protected_vtable _protect_vtable = {
{
DOM_NODE_PROTECT_VTABLE_HTML_CANVAS_ELEMENT
},
diff --git a/src/html/html_directory_element.c b/src/html/html_directory_element.c
index 585af1c..19db7cd 100644
--- a/src/html/html_directory_element.c
+++ b/src/html/html_directory_element.c
@@ -17,7 +17,7 @@
#include "core/attr.h"
#include "utils/utils.h"
-static struct dom_element_protected_vtable _protect_vtable = {
+static const struct dom_element_protected_vtable _protect_vtable = {
{
DOM_NODE_PROTECT_VTABLE_HTML_DIRECTORY_ELEMENT
},
diff --git a/src/html/html_div_element.c b/src/html/html_div_element.c
index b061246..c39af74 100644
--- a/src/html/html_div_element.c
+++ b/src/html/html_div_element.c
@@ -17,7 +17,7 @@
#include "core/attr.h"
#include "utils/utils.h"
-static struct dom_element_protected_vtable _protect_vtable = {
+static const struct dom_element_protected_vtable _protect_vtable = {
{
DOM_NODE_PROTECT_VTABLE_HTML_DIV_ELEMENT
},
diff --git a/src/html/html_dlist_element.c b/src/html/html_dlist_element.c
index ab9d4c3..fb0ad56 100644
--- a/src/html/html_dlist_element.c
+++ b/src/html/html_dlist_element.c
@@ -17,7 +17,7 @@
#include "core/attr.h"
#include "utils/utils.h"
-static struct dom_element_protected_vtable _protect_vtable = {
+static const struct dom_element_protected_vtable _protect_vtable = {
{
DOM_NODE_PROTECT_VTABLE_HTML_DL_ELEMENT
},
diff --git a/src/html/html_document.c b/src/html/html_document.c
index 5d06e80..5471f4f 100644
--- a/src/html/html_document.c
+++ b/src/html/html_document.c
@@ -72,7 +72,7 @@
#include "utils/namespace.h"
#include "utils/utils.h"
-static struct dom_html_document_vtable html_document_vtable = {
+static const struct dom_html_document_vtable html_document_vtable = {
{
{
{
@@ -85,7 +85,7 @@ static struct dom_html_document_vtable html_document_vtable = {
DOM_HTML_DOCUMENT_VTABLE
};
-static struct dom_node_protect_vtable html_document_protect_vtable = {
+static const struct dom_node_protect_vtable html_document_protect_vtable = {
DOM_HTML_DOCUMENT_PROTECT_VTABLE
};
diff --git a/src/html/html_element.c b/src/html/html_element.c
index 5d3df37..df0fa6a 100644
--- a/src/html/html_element.c
+++ b/src/html/html_element.c
@@ -18,7 +18,7 @@
#include "core/document.h"
#include "utils/utils.h"
-struct dom_html_element_vtable _dom_html_element_vtable = {
+const struct dom_html_element_vtable _dom_html_element_vtable = {
{
{
{
@@ -31,7 +31,7 @@ struct dom_html_element_vtable _dom_html_element_vtable = {
DOM_HTML_ELEMENT_VTABLE
};
-static struct dom_element_protected_vtable _dom_html_element_protect_vtable = {
+static const struct dom_element_protected_vtable _dom_html_element_protect_vtable = {
{
DOM_HTML_ELEMENT_PROTECT_VTABLE
},
diff --git a/src/html/html_element.h b/src/html/html_element.h
index 0290569..87e1bbb 100644
--- a/src/html/html_element.h
+++ b/src/html/html_element.h
@@ -162,7 +162,7 @@ dom_exception _dom_html_element_copy_internal(dom_html_element *old,
#define dom_html_element_copy_internal(o, n) _dom_html_element_copy_internal( \
(dom_html_element *) (o), (dom_html_element *) (n))
-extern struct dom_html_element_vtable _dom_html_element_vtable;
+extern const struct dom_html_element_vtable _dom_html_element_vtable;
#endif
diff --git a/src/html/html_fieldset_element.c b/src/html/html_fieldset_element.c
index fe44e74..2ab8dd0 100644
--- a/src/html/html_fieldset_element.c
+++ b/src/html/html_fieldset_element.c
@@ -17,7 +17,7 @@
#include "core/node.h"
#include "utils/utils.h"
-static struct dom_element_protected_vtable _protect_vtable = {
+static const struct dom_element_protected_vtable _protect_vtable = {
{
DOM_NODE_PROTECT_VTABLE_HTML_FIELDSET_ELEMENT
},
diff --git a/src/html/html_font_element.c b/src/html/html_font_element.c
index ecedfb0..38f8869 100644
--- a/src/html/html_font_element.c
+++ b/src/html/html_font_element.c
@@ -17,7 +17,7 @@
#include "core/attr.h"
#include "utils/utils.h"
-static struct dom_element_protected_vtable _protect_vtable = {
+static const struct dom_element_protected_vtable _protect_vtable = {
{
DOM_NODE_PROTECT_VTABLE_HTML_FONT_ELEMENT
},
diff --git a/src/html/html_form_element.c b/src/html/html_form_element.c
index 1dd1992..5ba8365 100644
--- a/src/html/html_form_element.c
+++ b/src/html/html_form_element.c
@@ -22,7 +22,7 @@
#include "core/node.h"
#include "utils/utils.h"
-static struct dom_element_protected_vtable _protect_vtable = {
+static const struct dom_element_protected_vtable _protect_vtable = {
{
DOM_NODE_PROTECT_VTABLE_HTML_FORM_ELEMENT
},
diff --git a/src/html/html_frame_element.c b/src/html/html_frame_element.c
index fe6859c..321cff9 100644
--- a/src/html/html_frame_element.c
+++ b/src/html/html_frame_element.c
@@ -17,7 +17,7 @@
#include "core/attr.h"
#include "utils/utils.h"
-static struct dom_element_protected_vtable _protect_vtable = {
+static const struct dom_element_protected_vtable _protect_vtable = {
{
DOM_NODE_PROTECT_VTABLE_HTML_FRAME_ELEMENT
},
diff --git a/src/html/html_frameset_element.c b/src/html/html_frameset_element.c
index be44d5d..84a52b0 100644
--- a/src/html/html_frameset_element.c
+++ b/src/html/html_frameset_element.c
@@ -17,7 +17,7 @@
#include "core/attr.h"
#include "utils/utils.h"
-static struct dom_element_protected_vtable _protect_vtable = {
+static const struct dom_element_protected_vtable _protect_vtable = {
{
DOM_NODE_PROTECT_VTABLE_HTML_FRAME_SET_ELEMENT
},
diff --git a/src/html/html_head_element.c b/src/html/html_head_element.c
index ff02b1f..20f6aa8 100644
--- a/src/html/html_head_element.c
+++ b/src/html/html_head_element.c
@@ -13,7 +13,7 @@
#include "core/node.h"
#include "utils/utils.h"
-static struct dom_element_protected_vtable _protect_vtable = {
+static const struct dom_element_protected_vtable _protect_vtable = {
{
DOM_NODE_PROTECT_VTABLE_HTML_HEAD_ELEMENT
},
diff --git a/src/html/html_heading_element.c b/src/html/html_heading_element.c
index 8ab2c5a..21e36c6 100644
--- a/src/html/html_heading_element.c
+++ b/src/html/html_heading_element.c
@@ -17,7 +17,7 @@
#include "core/attr.h"
#include "utils/utils.h"
-static struct dom_element_protected_vtable _protect_vtable = {
+static const struct dom_element_protected_vtable _protect_vtable = {
{
DOM_NODE_PROTECT_VTABLE_HTML_HEADING_ELEMENT
},
diff --git a/src/html/html_hr_element.c b/src/html/html_hr_element.c
index e6086f5..8ca9743 100644
--- a/src/html/html_hr_element.c
+++ b/src/html/html_hr_element.c
@@ -17,7 +17,7 @@
#include "core/attr.h"
#include "utils/utils.h"
-static struct dom_element_protected_vtable _protect_vtable = {
+static const struct dom_element_protected_vtable _protect_vtable = {
{
DOM_NODE_PROTECT_VTABLE_HTML_HR_ELEMENT
},
diff --git a/src/html/html_html_element.c b/src/html/html_html_element.c
index 9cdcd5e..24f35e4 100644
--- a/src/html/html_html_element.c
+++ b/src/html/html_html_element.c
@@ -13,7 +13,7 @@
#include "core/node.h"
#include "utils/utils.h"
-static struct dom_element_protected_vtable _protect_vtable = {
+static const struct dom_element_protected_vtable _protect_vtable = {
{
DOM_NODE_PROTECT_VTABLE_HTML_HTML_ELEMENT
},
diff --git a/src/html/html_iframe_element.c b/src/html/html_iframe_element.c
index 4d7272b..96397d0 100644
--- a/src/html/html_iframe_element.c
+++ b/src/html/html_iframe_element.c
@@ -17,7 +17,7 @@
#include "core/attr.h"
#include "utils/utils.h"
-static struct dom_element_protected_vtable _protect_vtable = {
+static const struct dom_element_protected_vtable _protect_vtable = {
{
DOM_NODE_PROTECT_VTABLE_HTML_IFRAME_ELEMENT
},
diff --git a/src/html/html_image_element.c b/src/html/html_image_element.c
index 3cdd15f..e5b9c7b 100644
--- a/src/html/html_image_element.c
+++ b/src/html/html_image_element.c
@@ -18,7 +18,7 @@
#include "core/attr.h"
#include "utils/utils.h"
-static struct dom_element_protected_vtable _protect_vtable = {
+static const struct dom_element_protected_vtable _protect_vtable = {
{
DOM_NODE_PROTECT_VTABLE_HTML_IMAGE_ELEMENT
},
diff --git a/src/html/html_input_element.c b/src/html/html_input_element.c
index 079b55e..025ef5d 100644
--- a/src/html/html_input_element.c
+++ b/src/html/html_input_element.c
@@ -17,7 +17,7 @@
#include "core/attr.h"
#include "utils/utils.h"
-static struct dom_element_protected_vtable _protect_vtable = {
+static const struct dom_element_protected_vtable _protect_vtable = {
{
DOM_NODE_PROTECT_VTABLE_HTML_INPUT_ELEMENT
},
diff --git a/src/html/html_isindex_element.c b/src/html/html_isindex_element.c
index 40cb99c..e793fae 100644
--- a/src/html/html_isindex_element.c
+++ b/src/html/html_isindex_element.c
@@ -16,7 +16,7 @@
#include "core/attr.h"
#include "utils/utils.h"
-static struct dom_element_protected_vtable _protect_vtable = {
+static const struct dom_element_protected_vtable _protect_vtable = {
{
DOM_NODE_PROTECT_VTABLE_HTML_ISINDEX_ELEMENT
},
diff --git a/src/html/html_label_element.c b/src/html/html_label_element.c
index 777144a..c62adca 100644
--- a/src/html/html_label_element.c
+++ b/src/html/html_label_element.c
@@ -15,7 +15,7 @@
#include "core/node.h"
#include "utils/utils.h"
-static struct dom_element_protected_vtable _protect_vtable = {
+static const struct dom_element_protected_vtable _protect_vtable = {
{
DOM_NODE_PROTECT_VTABLE_HTML_LABEL_ELEMENT
},
diff --git a/src/html/html_legend_element.c b/src/html/html_legend_element.c
index efb712b..f4200c8 100644
--- a/src/html/html_legend_element.c
+++ b/src/html/html_legend_element.c
@@ -19,7 +19,7 @@
#include "core/attr.h"
#include "utils/utils.h"
-static struct dom_element_protected_vtable _protect_vtable = {
+static const struct dom_element_protected_vtable _protect_vtable = {
{
DOM_NODE_PROTECT_VTABLE_HTML_LEGEND_ELEMENT
},
diff --git a/src/html/html_li_element.c b/src/html/html_li_element.c
index 84becf9..6856046 100644
--- a/src/html/html_li_element.c
+++ b/src/html/html_li_element.c
@@ -17,7 +17,7 @@
#include "core/attr.h"
#include "utils/utils.h"
-static struct dom_element_protected_vtable _protect_vtable = {
+static const struct dom_element_protected_vtable _protect_vtable = {
{
DOM_NODE_PROTECT_VTABLE_HTML_LI_ELEMENT
},
diff --git a/src/html/html_link_element.c b/src/html/html_link_element.c
index 87fe980..4916883 100644
--- a/src/html/html_link_element.c
+++ b/src/html/html_link_element.c
@@ -15,7 +15,7 @@
#include "core/attr.h"
#include "utils/utils.h"
-static struct dom_element_protected_vtable _protect_vtable = {
+static const struct dom_element_protected_vtable _protect_vtable = {
{
DOM_NODE_PROTECT_VTABLE_HTML_LINK_ELEMENT
},
diff --git a/src/html/html_map_element.c b/src/html/html_map_element.c
index 3b10222..865d9b6 100644
--- a/src/html/html_map_element.c
+++ b/src/html/html_map_element.c
@@ -19,7 +19,7 @@
#include "core/attr.h"
#include "utils/utils.h"
-static struct dom_element_protected_vtable _protect_vtable = {
+static const struct dom_element_protected_vtable _protect_vtable = {
{
DOM_NODE_PROTECT_VTABLE_HTML_MAP_ELEMENT
},
diff --git a/src/html/html_menu_element.c b/src/html/html_menu_element.c
index 09eadb6..882f1f2 100644
--- a/src/html/html_menu_element.c
+++ b/src/html/html_menu_element.c
@@ -17,7 +17,7 @@
#include "core/attr.h"
#include "utils/utils.h"
-static struct dom_element_protected_vtable _protect_vtable = {
+static const struct dom_element_protected_vtable _protect_vtable = {
{
DOM_NODE_PROTECT_VTABLE_HTML_MENU_ELEMENT
},
diff --git a/src/html/html_meta_element.c b/src/html/html_meta_element.c
index 4098daf..39fd9e1 100644
--- a/src/html/html_meta_element.c
+++ b/src/html/html_meta_element.c
@@ -13,7 +13,7 @@
#include "core/node.h"
#include "utils/utils.h"
-static struct dom_element_protected_vtable _protect_vtable = {
+static const struct dom_element_protected_vtable _protect_vtable = {
{
DOM_NODE_PROTECT_VTABLE_HTML_META_ELEMENT
},
diff --git a/src/html/html_mod_element.c b/src/html/html_mod_element.c
index 20cb042..4f3331c 100644
--- a/src/html/html_mod_element.c
+++ b/src/html/html_mod_element.c
@@ -17,7 +17,7 @@
#include "core/attr.h"
#include "utils/utils.h"
-static struct dom_element_protected_vtable _protect_vtable = {
+static const struct dom_element_protected_vtable _protect_vtable = {
{
DOM_NODE_PROTECT_VTABLE_HTML_MOD_ELEMENT
},
diff --git a/src/html/html_object_element.c b/src/html/html_object_element.c
index b51e3a0..1359ede 100644
--- a/src/html/html_object_element.c
+++ b/src/html/html_object_element.c
@@ -20,7 +20,7 @@
#include "core/attr.h"
#include "utils/utils.h"
-static struct dom_element_protected_vtable _protect_vtable = {
+static const struct dom_element_protected_vtable _protect_vtable = {
{
DOM_NODE_PROTECT_VTABLE_HTML_OBJECT_ELEMENT
},
diff --git a/src/html/html_olist_element.c b/src/html/html_olist_element.c
index c89d11f..415b656 100644
--- a/src/html/html_olist_element.c
+++ b/src/html/html_olist_element.c
@@ -17,7 +17,7 @@
#include "core/attr.h"
#include "utils/utils.h"
-static struct dom_element_protected_vtable _protect_vtable = {
+static const struct dom_element_protected_vtable _protect_vtable = {
{
DOM_NODE_PROTECT_VTABLE_HTML_OLIST_ELEMENT
},
diff --git a/src/html/html_opt_group_element.c b/src/html/html_opt_group_element.c
index 6af0a29..a50e3de 100644
--- a/src/html/html_opt_group_element.c
+++ b/src/html/html_opt_group_element.c
@@ -17,7 +17,7 @@
#include "core/attr.h"
#include "utils/utils.h"
-static struct dom_element_protected_vtable _protect_vtable = {
+static const struct dom_element_protected_vtable _protect_vtable = {
{
DOM_NODE_PROTECT_VTABLE_HTML_OPT_GROUP_ELEMENT
},
diff --git a/src/html/html_paragraph_element.c b/src/html/html_paragraph_element.c
index 2b2f420..3c8f384 100644
--- a/src/html/html_paragraph_element.c
+++ b/src/html/html_paragraph_element.c
@@ -17,7 +17,7 @@
#include "core/attr.h"
#include "utils/utils.h"
-static struct dom_element_protected_vtable _protect_vtable = {
+static const struct dom_element_protected_vtable _protect_vtable = {
{
DOM_NODE_PROTECT_VTABLE_HTML_P_ELEMENT
},
diff --git a/src/html/html_param_element.c b/src/html/html_param_element.c
index c75e1ce..2c991ac 100644
--- a/src/html/html_param_element.c
+++ b/src/html/html_param_element.c
@@ -17,7 +17,7 @@
#include "core/attr.h"
#include "utils/utils.h"
-static struct dom_element_protected_vtable _protect_vtable = {
+static const struct dom_element_protected_vtable _protect_vtable = {
{
DOM_NODE_PROTECT_VTABLE_HTML_PARAM_ELEMENT
},
diff --git a/src/html/html_pre_element.c b/src/html/html_pre_element.c
index 64c8c3d..7582fde 100644
--- a/src/html/html_pre_element.c
+++ b/src/html/html_pre_element.c
@@ -17,7 +17,7 @@
#include "core/attr.h"
#include "utils/utils.h"
-static struct dom_element_protected_vtable _protect_vtable = {
+static const struct dom_element_protected_vtable _protect_vtable = {
{
DOM_NODE_PROTECT_VTABLE_HTML_PRE_ELEMENT
},
diff --git a/src/html/html_quote_element.c b/src/html/html_quote_element.c
index cf3e0c5..f1bc06f 100644
--- a/src/html/html_quote_element.c
+++ b/src/html/html_quote_element.c
@@ -17,7 +17,7 @@
#include "core/attr.h"
#include "utils/utils.h"
-static struct dom_element_protected_vtable _protect_vtable = {
+static const struct dom_element_protected_vtable _protect_vtable = {
{
DOM_NODE_PROTECT_VTABLE_HTML_QUOTE_ELEMENT
},
diff --git a/src/html/html_script_element.c b/src/html/html_script_element.c
index e8dfb1d..9acbf29 100644
--- a/src/html/html_script_element.c
+++ b/src/html/html_script_element.c
@@ -17,7 +17,7 @@
#include "core/attr.h"
#include "utils/utils.h"
-static struct dom_element_protected_vtable _protect_vtable = {
+static const struct dom_element_protected_vtable _protect_vtable = {
{
DOM_NODE_PROTECT_VTABLE_HTML_SCRIPT_ELEMENT
},
diff --git a/src/html/html_select_element.c b/src/html/html_select_element.c
index 0801d0a..8ba78f1 100644
--- a/src/html/html_select_element.c
+++ b/src/html/html_select_element.c
@@ -17,7 +17,7 @@
#include "core/node.h"
#include "utils/utils.h"
-static struct dom_element_protected_vtable _protect_vtable = {
+static const struct dom_element_protected_vtable _protect_vtable = {
{
DOM_NODE_PROTECT_VTABLE_HTML_SELECT_ELEMENT
},
diff --git a/src/html/html_style_element.c b/src/html/html_style_element.c
index ae845be..4e4974f 100644
--- a/src/html/html_style_element.c
+++ b/src/html/html_style_element.c
@@ -13,7 +13,7 @@
#include "core/node.h"
#include "utils/utils.h"
-static struct dom_element_protected_vtable _protect_vtable = {
+static const struct dom_element_protected_vtable _protect_vtable = {
{
DOM_NODE_PROTECT_VTABLE_HTML_STYLE_ELEMENT
},
diff --git a/src/html/html_table_element.c b/src/html/html_table_element.c
index f197d07..010a6cd 100644
--- a/src/html/html_table_element.c
+++ b/src/html/html_table_element.c
@@ -21,7 +21,7 @@
#include "core/attr.h"
#include "utils/utils.h"
-static struct dom_element_protected_vtable _protect_vtable = {
+static const struct dom_element_protected_vtable _protect_vtable = {
{
DOM_NODE_PROTECT_VTABLE_HTML_TABLE_ELEMENT
},
diff --git a/src/html/html_tablecaption_element.c b/src/html/html_tablecaption_element.c
index cae229c..0e55e3a 100644
--- a/src/html/html_tablecaption_element.c
+++ b/src/html/html_tablecaption_element.c
@@ -17,7 +17,7 @@
#include "core/attr.h"
#include "utils/utils.h"
-static struct dom_element_protected_vtable _protect_vtable = {
+static const struct dom_element_protected_vtable _protect_vtable = {
{
DOM_NODE_PROTECT_VTABLE_HTML_TABLE_CAPTION_ELEMENT
},
diff --git a/src/html/html_tablecell_element.c b/src/html/html_tablecell_element.c
index 7a1f968..2fc31c8 100644
--- a/src/html/html_tablecell_element.c
+++ b/src/html/html_tablecell_element.c
@@ -18,7 +18,7 @@
#include "core/attr.h"
#include "utils/utils.h"
-static struct dom_element_protected_vtable _protect_vtable = {
+static const struct dom_element_protected_vtable _protect_vtable = {
{
DOM_NODE_PROTECT_VTABLE_HTML_TABLE_CELL_ELEMENT
},
diff --git a/src/html/html_tablecol_element.c b/src/html/html_tablecol_element.c
index 74169be..56bcd64 100644
--- a/src/html/html_tablecol_element.c
+++ b/src/html/html_tablecol_element.c
@@ -17,7 +17,7 @@
#include "core/attr.h"
#include "utils/utils.h"
-static struct dom_element_protected_vtable _protect_vtable = {
+static const struct dom_element_protected_vtable _protect_vtable = {
{
DOM_NODE_PROTECT_VTABLE_HTML_TABLE_COL_ELEMENT
},
diff --git a/src/html/html_tablerow_element.c b/src/html/html_tablerow_element.c
index 569e70f..1a6069b 100644
--- a/src/html/html_tablerow_element.c
+++ b/src/html/html_tablerow_element.c
@@ -20,7 +20,7 @@
#include "core/attr.h"
#include "utils/utils.h"
-static struct dom_element_protected_vtable _protect_vtable = {
+static const struct dom_element_protected_vtable _protect_vtable = {
{
DOM_NODE_PROTECT_VTABLE_HTML_TABLE_ROW_ELEMENT
},
diff --git a/src/html/html_tablesection_element.c b/src/html/html_tablesection_element.c
index f839758..dee5ae5 100644
--- a/src/html/html_tablesection_element.c
+++ b/src/html/html_tablesection_element.c
@@ -21,7 +21,7 @@
#include "core/attr.h"
#include "utils/utils.h"
-static struct dom_element_protected_vtable _protect_vtable = {
+static const struct dom_element_protected_vtable _protect_vtable = {
{
DOM_NODE_PROTECT_VTABLE_HTML_TABLE_SECTION_ELEMENT
},
diff --git a/src/html/html_text_area_element.c b/src/html/html_text_area_element.c
index 5c63c3c..db351bc 100644
--- a/src/html/html_text_area_element.c
+++ b/src/html/html_text_area_element.c
@@ -17,7 +17,7 @@
#include "core/attr.h"
#include "utils/utils.h"
-static struct dom_element_protected_vtable _protect_vtable = {
+static const struct dom_element_protected_vtable _protect_vtable = {
{
DOM_NODE_PROTECT_VTABLE_HTML_TEXT_AREA_ELEMENT
},
diff --git a/src/html/html_title_element.c b/src/html/html_title_element.c
index 440b9d5..f727dfa 100644
--- a/src/html/html_title_element.c
+++ b/src/html/html_title_element.c
@@ -17,7 +17,7 @@
#include "core/node.h"
#include "utils/utils.h"
-static struct dom_element_protected_vtable _protect_vtable = {
+static const struct dom_element_protected_vtable _protect_vtable = {
{
DOM_NODE_PROTECT_VTABLE_HTML_TITLE_ELEMENT
},
diff --git a/src/html/html_ulist_element.c b/src/html/html_ulist_element.c
index f2b87fb..48cb0c2 100644
--- a/src/html/html_ulist_element.c
+++ b/src/html/html_ulist_element.c
@@ -17,7 +17,7 @@
#include "core/attr.h"
#include "utils/utils.h"
-static struct dom_element_protected_vtable _protect_vtable = {
+static const struct dom_element_protected_vtable _protect_vtable = {
{
DOM_NODE_PROTECT_VTABLE_HTML_U_LIST_ELEMENT
},
-----------------------------------------------------------------------
Summary of changes:
include/dom/core/node.h | 2 +-
src/core/attr.c | 4 ++--
src/core/cdatasection.c | 2 +-
src/core/characterdata.c | 2 +-
src/core/characterdata.h | 2 +-
src/core/comment.c | 2 +-
src/core/doc_fragment.c | 4 ++--
src/core/document.c | 4 ++--
src/core/document_type.c | 4 ++--
src/core/element.c | 4 ++--
src/core/element.h | 2 +-
src/core/entity_ref.c | 4 ++--
src/core/node.c | 4 ++--
src/core/node.h | 2 +-
src/core/pi.c | 4 ++--
src/core/text.c | 4 ++--
src/core/text.h | 2 +-
src/events/event.c | 2 +-
src/events/event.h | 2 +-
src/events/keyboard_event.c | 2 +-
src/events/mouse_event.c | 2 +-
src/events/mouse_multi_wheel_event.c | 2 +-
src/events/mouse_wheel_event.c | 2 +-
src/events/mutation_event.c | 2 +-
src/events/mutation_name_event.c | 2 +-
src/events/text_event.c | 2 +-
src/events/ui_event.c | 2 +-
src/html/html_anchor_element.c | 2 +-
src/html/html_applet_element.c | 2 +-
src/html/html_area_element.c | 2 +-
src/html/html_base_element.c | 2 +-
src/html/html_basefont_element.c | 2 +-
src/html/html_body_element.c | 2 +-
src/html/html_br_element.c | 2 +-
src/html/html_button_element.c | 2 +-
src/html/html_canvas_element.c | 2 +-
src/html/html_directory_element.c | 2 +-
src/html/html_div_element.c | 2 +-
src/html/html_dlist_element.c | 2 +-
src/html/html_document.c | 4 ++--
src/html/html_element.c | 4 ++--
src/html/html_element.h | 2 +-
src/html/html_fieldset_element.c | 2 +-
src/html/html_font_element.c | 2 +-
src/html/html_form_element.c | 2 +-
src/html/html_frame_element.c | 2 +-
src/html/html_frameset_element.c | 2 +-
src/html/html_head_element.c | 2 +-
src/html/html_heading_element.c | 2 +-
src/html/html_hr_element.c | 2 +-
src/html/html_html_element.c | 2 +-
src/html/html_iframe_element.c | 2 +-
src/html/html_image_element.c | 2 +-
src/html/html_input_element.c | 2 +-
src/html/html_isindex_element.c | 2 +-
src/html/html_label_element.c | 2 +-
src/html/html_legend_element.c | 2 +-
src/html/html_li_element.c | 2 +-
src/html/html_link_element.c | 2 +-
src/html/html_map_element.c | 2 +-
src/html/html_menu_element.c | 2 +-
src/html/html_meta_element.c | 2 +-
src/html/html_mod_element.c | 2 +-
src/html/html_object_element.c | 2 +-
src/html/html_olist_element.c | 2 +-
src/html/html_opt_group_element.c | 2 +-
src/html/html_paragraph_element.c | 2 +-
src/html/html_param_element.c | 2 +-
src/html/html_pre_element.c | 2 +-
src/html/html_quote_element.c | 2 +-
src/html/html_script_element.c | 2 +-
src/html/html_select_element.c | 2 +-
src/html/html_style_element.c | 2 +-
src/html/html_table_element.c | 2 +-
src/html/html_tablecaption_element.c | 2 +-
src/html/html_tablecell_element.c | 2 +-
src/html/html_tablecol_element.c | 2 +-
src/html/html_tablerow_element.c | 2 +-
src/html/html_tablesection_element.c | 2 +-
src/html/html_text_area_element.c | 2 +-
src/html/html_title_element.c | 2 +-
src/html/html_ulist_element.c | 2 +-
82 files changed, 93 insertions(+), 93 deletions(-)
diff --git a/include/dom/core/node.h b/include/dom/core/node.h
index 9600e6d..5058c78 100644
--- a/include/dom/core/node.h
+++ b/include/dom/core/node.h
@@ -77,7 +77,7 @@ typedef struct dom_node_internal dom_node_internal;
* DOM node type
*/
typedef struct dom_node {
- void *vtable;
+ const void *vtable;
uint32_t refcnt;
} dom_node;
diff --git a/src/core/attr.c b/src/core/attr.c
index e18e2a7..8fcaac3 100644
--- a/src/core/attr.c
+++ b/src/core/attr.c
@@ -49,7 +49,7 @@ struct dom_attr {
};
/* The vtable for dom_attr node */
-static struct dom_attr_vtable attr_vtable = {
+static const struct dom_attr_vtable attr_vtable = {
{
{
DOM_NODE_EVENT_TARGET_VTABLE,
@@ -60,7 +60,7 @@ static struct dom_attr_vtable attr_vtable = {
};
/* The protected vtable for dom_attr */
-static struct dom_node_protect_vtable attr_protect_vtable = {
+static const struct dom_node_protect_vtable attr_protect_vtable = {
DOM_ATTR_PROTECT_VTABLE
};
diff --git a/src/core/cdatasection.c b/src/core/cdatasection.c
index c6812e3..efba237 100644
--- a/src/core/cdatasection.c
+++ b/src/core/cdatasection.c
@@ -20,7 +20,7 @@ struct dom_cdata_section {
dom_text base; /**< Base node */
};
-static struct dom_node_protect_vtable cdata_section_protect_vtable = {
+static const struct dom_node_protect_vtable cdata_section_protect_vtable = {
DOM_CDATA_SECTION_PROTECT_VTABLE
};
diff --git a/src/core/characterdata.c b/src/core/characterdata.c
index ea665b3..e6f5dbe 100644
--- a/src/core/characterdata.c
+++ b/src/core/characterdata.c
@@ -21,7 +21,7 @@
/* The virtual functions for dom_characterdata, we make this vtable
* public to each child class */
-struct dom_characterdata_vtable characterdata_vtable = {
+const struct dom_characterdata_vtable characterdata_vtable = {
{
{
DOM_NODE_EVENT_TARGET_VTABLE
diff --git a/src/core/characterdata.h b/src/core/characterdata.h
index 0b0889c..c8f4db3 100644
--- a/src/core/characterdata.h
+++ b/src/core/characterdata.h
@@ -116,7 +116,7 @@ dom_exception _dom_characterdata_copy(dom_node_internal *old,
_dom_characterdata_destroy, \
_dom_characterdata_copy
-extern struct dom_characterdata_vtable characterdata_vtable;
+extern const struct dom_characterdata_vtable characterdata_vtable;
dom_exception _dom_characterdata_copy_internal(dom_characterdata *old,
dom_characterdata *new);
diff --git a/src/core/comment.c b/src/core/comment.c
index 0697826..b36a1be 100644
--- a/src/core/comment.c
+++ b/src/core/comment.c
@@ -21,7 +21,7 @@ struct dom_comment {
dom_characterdata base; /**< Base node */
};
-static struct dom_node_protect_vtable comment_protect_vtable = {
+static const struct dom_node_protect_vtable comment_protect_vtable = {
DOM_COMMENT_PROTECT_VTABLE
};
diff --git a/src/core/doc_fragment.c b/src/core/doc_fragment.c
index 96cc707..9e10a1a 100644
--- a/src/core/doc_fragment.c
+++ b/src/core/doc_fragment.c
@@ -22,14 +22,14 @@ struct dom_document_fragment {
dom_node_internal base; /**< Base node */
};
-static struct dom_node_vtable df_vtable = {
+static const struct dom_node_vtable df_vtable = {
{
DOM_NODE_EVENT_TARGET_VTABLE
},
DOM_NODE_VTABLE
};
-static struct dom_node_protect_vtable df_protect_vtable = {
+static const struct dom_node_protect_vtable df_protect_vtable = {
DOM_DF_PROTECT_VTABLE
};
diff --git a/src/core/document.c b/src/core/document.c
index 7c0bcdc..40d4cd9 100644
--- a/src/core/document.c
+++ b/src/core/document.c
@@ -42,7 +42,7 @@ struct dom_doc_nl {
};
/* The virtual functions of this dom_document */
-static struct dom_document_vtable document_vtable = {
+static const struct dom_document_vtable document_vtable = {
{
{
DOM_NODE_EVENT_TARGET_VTABLE
@@ -52,7 +52,7 @@ static struct dom_document_vtable document_vtable = {
DOM_DOCUMENT_VTABLE
};
-static struct dom_node_protect_vtable document_protect_vtable = {
+static const struct dom_node_protect_vtable document_protect_vtable = {
DOM_DOCUMENT_PROTECT_VTABLE
};
diff --git a/src/core/document_type.c b/src/core/document_type.c
index d7b1b99..a0fafdd 100644
--- a/src/core/document_type.c
+++ b/src/core/document_type.c
@@ -27,7 +27,7 @@ struct dom_document_type {
dom_string *system_id; /**< Doctype system ID */
};
-static struct dom_document_type_vtable document_type_vtable = {
+static const struct dom_document_type_vtable document_type_vtable = {
{
{
DOM_NODE_EVENT_TARGET_VTABLE
@@ -37,7 +37,7 @@ static struct dom_document_type_vtable document_type_vtable = {
DOM_DOCUMENT_TYPE_VTABLE
};
-static struct dom_node_protect_vtable dt_protect_vtable = {
+static const struct dom_node_protect_vtable dt_protect_vtable = {
DOM_DT_PROTECT_VTABLE
};
diff --git a/src/core/element.c b/src/core/element.c
index dbdd56b..3b031a0 100644
--- a/src/core/element.c
+++ b/src/core/element.c
@@ -32,7 +32,7 @@
#include "utils/list.h"
#include "events/mutation_event.h"
-struct dom_element_vtable _dom_element_vtable = {
+const struct dom_element_vtable _dom_element_vtable = {
{
{
DOM_NODE_EVENT_TARGET_VTABLE
@@ -42,7 +42,7 @@ struct dom_element_vtable _dom_element_vtable = {
DOM_ELEMENT_VTABLE
};
-static struct dom_element_protected_vtable element_protect_vtable = {
+static const struct dom_element_protected_vtable element_protect_vtable = {
{
DOM_NODE_PROTECT_VTABLE_ELEMENT
},
diff --git a/src/core/element.h b/src/core/element.h
index c89ddc0..fb946b7 100644
--- a/src/core/element.h
+++ b/src/core/element.h
@@ -238,6 +238,6 @@ dom_exception _dom_element_copy_internal(dom_element *old,
dom_exception _dom_element_get_id(struct dom_element *ele, dom_string **id);
-extern struct dom_element_vtable _dom_element_vtable;
+extern const struct dom_element_vtable _dom_element_vtable;
#endif
diff --git a/src/core/entity_ref.c b/src/core/entity_ref.c
index aa32111..bc6fbab 100644
--- a/src/core/entity_ref.c
+++ b/src/core/entity_ref.c
@@ -20,14 +20,14 @@ struct dom_entity_reference {
dom_node_internal base; /**< Base node */
};
-static struct dom_node_vtable er_vtable = {
+static const struct dom_node_vtable er_vtable = {
{
DOM_NODE_EVENT_TARGET_VTABLE
},
DOM_NODE_VTABLE
};
-static struct dom_node_protect_vtable er_protect_vtable = {
+static const struct dom_node_protect_vtable er_protect_vtable = {
DOM_ER_PROTECT_VTABLE
};
diff --git a/src/core/node.c b/src/core/node.c
index b471725..f8b8def 100644
--- a/src/core/node.c
+++ b/src/core/node.c
@@ -55,14 +55,14 @@ static inline dom_exception _dom_node_detach_range(dom_node_internal *first,
static inline void _dom_node_replace(dom_node_internal *old,
dom_node_internal *replacement);
-static struct dom_node_vtable node_vtable = {
+static const struct dom_node_vtable node_vtable = {
{
DOM_NODE_EVENT_TARGET_VTABLE
},
DOM_NODE_VTABLE
};
-static struct dom_node_protect_vtable node_protect_vtable = {
+static const struct dom_node_protect_vtable node_protect_vtable = {
DOM_NODE_PROTECT_VTABLE
};
diff --git a/src/core/node.h b/src/core/node.h
index 87f3cb3..36d0ec1 100644
--- a/src/core/node.h
+++ b/src/core/node.h
@@ -53,7 +53,7 @@ typedef struct dom_node_protect_vtable {
*/
struct dom_node_internal {
struct dom_node base; /**< The vtable base */
- void *vtable; /**< The protected vtable */
+ const void *vtable; /**< The protected vtable */
dom_string *name; /**< Node name (this is the local part
* of a QName in the cases where a
diff --git a/src/core/pi.c b/src/core/pi.c
index d12f109..3e69841 100644
--- a/src/core/pi.c
+++ b/src/core/pi.c
@@ -20,14 +20,14 @@ struct dom_processing_instruction {
dom_node_internal base; /**< Base node */
};
-static struct dom_node_vtable pi_vtable = {
+static const struct dom_node_vtable pi_vtable = {
{
DOM_NODE_EVENT_TARGET_VTABLE
},
DOM_NODE_VTABLE
};
-static struct dom_node_protect_vtable pi_protect_vtable = {
+static const struct dom_node_protect_vtable pi_protect_vtable = {
DOM_PI_PROTECT_VTABLE
};
/**
diff --git a/src/core/text.c b/src/core/text.c
index b73e86d..f63fabe 100644
--- a/src/core/text.c
+++ b/src/core/text.c
@@ -20,7 +20,7 @@
#include "utils/utils.h"
/* The virtual table for dom_text */
-struct dom_text_vtable text_vtable = {
+const struct dom_text_vtable text_vtable = {
{
{
{
@@ -33,7 +33,7 @@ struct dom_text_vtable text_vtable = {
DOM_TEXT_VTABLE
};
-static struct dom_node_protect_vtable text_protect_vtable = {
+static const struct dom_node_protect_vtable text_protect_vtable = {
DOM_TEXT_PROTECT_VTABLE
};
diff --git a/src/core/text.h b/src/core/text.h
index 26424ce..3f5739b 100644
--- a/src/core/text.h
+++ b/src/core/text.h
@@ -66,7 +66,7 @@ dom_exception _dom_text_copy(dom_node_internal *old, dom_node_internal **copy);
__dom_text_destroy, \
_dom_text_copy
-extern struct dom_text_vtable text_vtable;
+extern const struct dom_text_vtable text_vtable;
dom_exception _dom_text_copy_internal(dom_text *old, dom_text *new);
#define dom_text_copy_internal(o, n) \
diff --git a/src/events/event.c b/src/events/event.c
index 3fe9978..26b245e 100644
--- a/src/events/event.c
+++ b/src/events/event.c
@@ -18,7 +18,7 @@
static void _virtual_dom_event_destroy(dom_event *evt);
-static struct dom_event_private_vtable _event_vtable = {
+static const struct dom_event_private_vtable _event_vtable = {
_virtual_dom_event_destroy
};
diff --git a/src/events/event.h b/src/events/event.h
index 857f20a..7cada7b 100644
--- a/src/events/event.h
+++ b/src/events/event.h
@@ -45,7 +45,7 @@ struct dom_event {
uint32_t refcnt; /**< The reference count of this object */
- struct dom_event_private_vtable *vtable;
+ const struct dom_event_private_vtable *vtable;
/**< The private virtual function table of Event */
bool in_dispatch; /**< Whether this event is in dispatch */
bool is_initialised; /**< Whether this event is initialised */
diff --git a/src/events/keyboard_event.c b/src/events/keyboard_event.c
index d349355..d1fa1ca 100644
--- a/src/events/keyboard_event.c
+++ b/src/events/keyboard_event.c
@@ -15,7 +15,7 @@
static void _virtual_dom_keyboard_event_destroy(struct dom_event *evt);
-static struct dom_event_private_vtable _event_vtable = {
+static const struct dom_event_private_vtable _event_vtable = {
_virtual_dom_keyboard_event_destroy
};
diff --git a/src/events/mouse_event.c b/src/events/mouse_event.c
index b3b2154..ac1d142 100644
--- a/src/events/mouse_event.c
+++ b/src/events/mouse_event.c
@@ -15,7 +15,7 @@
static void _virtual_dom_mouse_event_destroy(struct dom_event *evt);
-static struct dom_event_private_vtable _event_vtable = {
+static const struct dom_event_private_vtable _event_vtable = {
_virtual_dom_mouse_event_destroy
};
diff --git a/src/events/mouse_multi_wheel_event.c b/src/events/mouse_multi_wheel_event.c
index bcbe8d5..a42085a 100644
--- a/src/events/mouse_multi_wheel_event.c
+++ b/src/events/mouse_multi_wheel_event.c
@@ -16,7 +16,7 @@
static void _virtual_dom_mouse_multi_wheel_event_destroy(
struct dom_event *evt);
-static struct dom_event_private_vtable _event_vtable = {
+static const struct dom_event_private_vtable _event_vtable = {
_virtual_dom_mouse_multi_wheel_event_destroy
};
diff --git a/src/events/mouse_wheel_event.c b/src/events/mouse_wheel_event.c
index d59eab1..5d6bdd6 100644
--- a/src/events/mouse_wheel_event.c
+++ b/src/events/mouse_wheel_event.c
@@ -15,7 +15,7 @@
static void _virtual_dom_mouse_wheel_event_destroy(struct dom_event *evt);
-static struct dom_event_private_vtable _event_vtable = {
+static const struct dom_event_private_vtable _event_vtable = {
_virtual_dom_mouse_wheel_event_destroy
};
diff --git a/src/events/mutation_event.c b/src/events/mutation_event.c
index df92c5f..2c5ffdc 100644
--- a/src/events/mutation_event.c
+++ b/src/events/mutation_event.c
@@ -11,7 +11,7 @@
static void _virtual_dom_mutation_event_destroy(struct dom_event *evt);
-static struct dom_event_private_vtable _event_vtable = {
+static const struct dom_event_private_vtable _event_vtable = {
_virtual_dom_mutation_event_destroy
};
diff --git a/src/events/mutation_name_event.c b/src/events/mutation_name_event.c
index e0ba82e..13a51b5 100644
--- a/src/events/mutation_name_event.c
+++ b/src/events/mutation_name_event.c
@@ -14,7 +14,7 @@
static void _virtual_dom_mutation_name_event_destroy(struct dom_event *evt);
-static struct dom_event_private_vtable _event_vtable = {
+static const struct dom_event_private_vtable _event_vtable = {
_virtual_dom_mutation_name_event_destroy
};
diff --git a/src/events/text_event.c b/src/events/text_event.c
index 3437716..d0d2706 100644
--- a/src/events/text_event.c
+++ b/src/events/text_event.c
@@ -12,7 +12,7 @@
static void _virtual_dom_text_event_destroy(struct dom_event *evt);
-static struct dom_event_private_vtable _event_vtable = {
+static const struct dom_event_private_vtable _event_vtable = {
_virtual_dom_text_event_destroy
};
diff --git a/src/events/ui_event.c b/src/events/ui_event.c
index 34ec84d..672f999 100644
--- a/src/events/ui_event.c
+++ b/src/events/ui_event.c
@@ -11,7 +11,7 @@
static void _virtual_dom_ui_event_destroy(struct dom_event *evt);
-static struct dom_event_private_vtable _event_vtable = {
+static const struct dom_event_private_vtable _event_vtable = {
_virtual_dom_ui_event_destroy
};
diff --git a/src/html/html_anchor_element.c b/src/html/html_anchor_element.c
index 8d64c2b..88fd2ac 100644
--- a/src/html/html_anchor_element.c
+++ b/src/html/html_anchor_element.c
@@ -18,7 +18,7 @@
#include "core/attr.h"
#include "utils/utils.h"
-static struct dom_element_protected_vtable _protect_vtable = {
+static const struct dom_element_protected_vtable _protect_vtable = {
{
DOM_NODE_PROTECT_VTABLE_HTML_ANCHOR_ELEMENT
},
diff --git a/src/html/html_applet_element.c b/src/html/html_applet_element.c
index 93ea1b5..f7f1afc 100644
--- a/src/html/html_applet_element.c
+++ b/src/html/html_applet_element.c
@@ -18,7 +18,7 @@
#include "core/attr.h"
#include "utils/utils.h"
-static struct dom_element_protected_vtable _protect_vtable = {
+static const struct dom_element_protected_vtable _protect_vtable = {
{
DOM_NODE_PROTECT_VTABLE_HTML_APPLET_ELEMENT
},
diff --git a/src/html/html_area_element.c b/src/html/html_area_element.c
index 828b073..3da59d7 100644
--- a/src/html/html_area_element.c
+++ b/src/html/html_area_element.c
@@ -17,7 +17,7 @@
#include "core/attr.h"
#include "utils/utils.h"
-static struct dom_element_protected_vtable _protect_vtable = {
+static const struct dom_element_protected_vtable _protect_vtable = {
{
DOM_NODE_PROTECT_VTABLE_HTML_AREA_ELEMENT
},
diff --git a/src/html/html_base_element.c b/src/html/html_base_element.c
index 0034f7c..f322f5b 100644
--- a/src/html/html_base_element.c
+++ b/src/html/html_base_element.c
@@ -13,7 +13,7 @@
#include "core/node.h"
#include "utils/utils.h"
-static struct dom_element_protected_vtable _protect_vtable = {
+static const struct dom_element_protected_vtable _protect_vtable = {
{
DOM_NODE_PROTECT_VTABLE_HTML_BASE_ELEMENT
},
diff --git a/src/html/html_basefont_element.c b/src/html/html_basefont_element.c
index ac1183d..b68ae03 100644
--- a/src/html/html_basefont_element.c
+++ b/src/html/html_basefont_element.c
@@ -17,7 +17,7 @@
#include "core/attr.h"
#include "utils/utils.h"
-static struct dom_element_protected_vtable _protect_vtable = {
+static const struct dom_element_protected_vtable _protect_vtable = {
{
DOM_NODE_PROTECT_VTABLE_HTML_BASE_FONT_ELEMENT
},
diff --git a/src/html/html_body_element.c b/src/html/html_body_element.c
index 0fc4b13..4f52152 100644
--- a/src/html/html_body_element.c
+++ b/src/html/html_body_element.c
@@ -15,7 +15,7 @@
#include "core/node.h"
#include "utils/utils.h"
-static struct dom_element_protected_vtable _protect_vtable = {
+static const struct dom_element_protected_vtable _protect_vtable = {
{
DOM_NODE_PROTECT_VTABLE_HTML_BODY_ELEMENT
},
diff --git a/src/html/html_br_element.c b/src/html/html_br_element.c
index 74e3ea8..71778f6 100644
--- a/src/html/html_br_element.c
+++ b/src/html/html_br_element.c
@@ -17,7 +17,7 @@
#include "core/attr.h"
#include "utils/utils.h"
-static struct dom_element_protected_vtable _protect_vtable = {
+static const struct dom_element_protected_vtable _protect_vtable = {
{
DOM_NODE_PROTECT_VTABLE_HTML_BR_ELEMENT
},
diff --git a/src/html/html_button_element.c b/src/html/html_button_element.c
index 04a17dd..52a3607 100644
--- a/src/html/html_button_element.c
+++ b/src/html/html_button_element.c
@@ -17,7 +17,7 @@
#include "core/attr.h"
#include "utils/utils.h"
-static struct dom_element_protected_vtable _protect_vtable = {
+static const struct dom_element_protected_vtable _protect_vtable = {
{
DOM_NODE_PROTECT_VTABLE_HTML_BUTTON_ELEMENT
},
diff --git a/src/html/html_canvas_element.c b/src/html/html_canvas_element.c
index 8e5d3fc..71d4a53 100644
--- a/src/html/html_canvas_element.c
+++ b/src/html/html_canvas_element.c
@@ -17,7 +17,7 @@
#include "core/attr.h"
#include "utils/utils.h"
-static struct dom_element_protected_vtable _protect_vtable = {
+static const struct dom_element_protected_vtable _protect_vtable = {
{
DOM_NODE_PROTECT_VTABLE_HTML_CANVAS_ELEMENT
},
diff --git a/src/html/html_directory_element.c b/src/html/html_directory_element.c
index 585af1c..19db7cd 100644
--- a/src/html/html_directory_element.c
+++ b/src/html/html_directory_element.c
@@ -17,7 +17,7 @@
#include "core/attr.h"
#include "utils/utils.h"
-static struct dom_element_protected_vtable _protect_vtable = {
+static const struct dom_element_protected_vtable _protect_vtable = {
{
DOM_NODE_PROTECT_VTABLE_HTML_DIRECTORY_ELEMENT
},
diff --git a/src/html/html_div_element.c b/src/html/html_div_element.c
index b061246..c39af74 100644
--- a/src/html/html_div_element.c
+++ b/src/html/html_div_element.c
@@ -17,7 +17,7 @@
#include "core/attr.h"
#include "utils/utils.h"
-static struct dom_element_protected_vtable _protect_vtable = {
+static const struct dom_element_protected_vtable _protect_vtable = {
{
DOM_NODE_PROTECT_VTABLE_HTML_DIV_ELEMENT
},
diff --git a/src/html/html_dlist_element.c b/src/html/html_dlist_element.c
index ab9d4c3..fb0ad56 100644
--- a/src/html/html_dlist_element.c
+++ b/src/html/html_dlist_element.c
@@ -17,7 +17,7 @@
#include "core/attr.h"
#include "utils/utils.h"
-static struct dom_element_protected_vtable _protect_vtable = {
+static const struct dom_element_protected_vtable _protect_vtable = {
{
DOM_NODE_PROTECT_VTABLE_HTML_DL_ELEMENT
},
diff --git a/src/html/html_document.c b/src/html/html_document.c
index 5d06e80..5471f4f 100644
--- a/src/html/html_document.c
+++ b/src/html/html_document.c
@@ -72,7 +72,7 @@
#include "utils/namespace.h"
#include "utils/utils.h"
-static struct dom_html_document_vtable html_document_vtable = {
+static const struct dom_html_document_vtable html_document_vtable = {
{
{
{
@@ -85,7 +85,7 @@ static struct dom_html_document_vtable html_document_vtable = {
DOM_HTML_DOCUMENT_VTABLE
};
-static struct dom_node_protect_vtable html_document_protect_vtable = {
+static const struct dom_node_protect_vtable html_document_protect_vtable = {
DOM_HTML_DOCUMENT_PROTECT_VTABLE
};
diff --git a/src/html/html_element.c b/src/html/html_element.c
index 5d3df37..df0fa6a 100644
--- a/src/html/html_element.c
+++ b/src/html/html_element.c
@@ -18,7 +18,7 @@
#include "core/document.h"
#include "utils/utils.h"
-struct dom_html_element_vtable _dom_html_element_vtable = {
+const struct dom_html_element_vtable _dom_html_element_vtable = {
{
{
{
@@ -31,7 +31,7 @@ struct dom_html_element_vtable _dom_html_element_vtable = {
DOM_HTML_ELEMENT_VTABLE
};
-static struct dom_element_protected_vtable _dom_html_element_protect_vtable = {
+static const struct dom_element_protected_vtable _dom_html_element_protect_vtable = {
{
DOM_HTML_ELEMENT_PROTECT_VTABLE
},
diff --git a/src/html/html_element.h b/src/html/html_element.h
index 0290569..87e1bbb 100644
--- a/src/html/html_element.h
+++ b/src/html/html_element.h
@@ -162,7 +162,7 @@ dom_exception _dom_html_element_copy_internal(dom_html_element *old,
#define dom_html_element_copy_internal(o, n) _dom_html_element_copy_internal( \
(dom_html_element *) (o), (dom_html_element *) (n))
-extern struct dom_html_element_vtable _dom_html_element_vtable;
+extern const struct dom_html_element_vtable _dom_html_element_vtable;
#endif
diff --git a/src/html/html_fieldset_element.c b/src/html/html_fieldset_element.c
index fe44e74..2ab8dd0 100644
--- a/src/html/html_fieldset_element.c
+++ b/src/html/html_fieldset_element.c
@@ -17,7 +17,7 @@
#include "core/node.h"
#include "utils/utils.h"
-static struct dom_element_protected_vtable _protect_vtable = {
+static const struct dom_element_protected_vtable _protect_vtable = {
{
DOM_NODE_PROTECT_VTABLE_HTML_FIELDSET_ELEMENT
},
diff --git a/src/html/html_font_element.c b/src/html/html_font_element.c
index ecedfb0..38f8869 100644
--- a/src/html/html_font_element.c
+++ b/src/html/html_font_element.c
@@ -17,7 +17,7 @@
#include "core/attr.h"
#include "utils/utils.h"
-static struct dom_element_protected_vtable _protect_vtable = {
+static const struct dom_element_protected_vtable _protect_vtable = {
{
DOM_NODE_PROTECT_VTABLE_HTML_FONT_ELEMENT
},
diff --git a/src/html/html_form_element.c b/src/html/html_form_element.c
index 1dd1992..5ba8365 100644
--- a/src/html/html_form_element.c
+++ b/src/html/html_form_element.c
@@ -22,7 +22,7 @@
#include "core/node.h"
#include "utils/utils.h"
-static struct dom_element_protected_vtable _protect_vtable = {
+static const struct dom_element_protected_vtable _protect_vtable = {
{
DOM_NODE_PROTECT_VTABLE_HTML_FORM_ELEMENT
},
diff --git a/src/html/html_frame_element.c b/src/html/html_frame_element.c
index fe6859c..321cff9 100644
--- a/src/html/html_frame_element.c
+++ b/src/html/html_frame_element.c
@@ -17,7 +17,7 @@
#include "core/attr.h"
#include "utils/utils.h"
-static struct dom_element_protected_vtable _protect_vtable = {
+static const struct dom_element_protected_vtable _protect_vtable = {
{
DOM_NODE_PROTECT_VTABLE_HTML_FRAME_ELEMENT
},
diff --git a/src/html/html_frameset_element.c b/src/html/html_frameset_element.c
index be44d5d..84a52b0 100644
--- a/src/html/html_frameset_element.c
+++ b/src/html/html_frameset_element.c
@@ -17,7 +17,7 @@
#include "core/attr.h"
#include "utils/utils.h"
-static struct dom_element_protected_vtable _protect_vtable = {
+static const struct dom_element_protected_vtable _protect_vtable = {
{
DOM_NODE_PROTECT_VTABLE_HTML_FRAME_SET_ELEMENT
},
diff --git a/src/html/html_head_element.c b/src/html/html_head_element.c
index ff02b1f..20f6aa8 100644
--- a/src/html/html_head_element.c
+++ b/src/html/html_head_element.c
@@ -13,7 +13,7 @@
#include "core/node.h"
#include "utils/utils.h"
-static struct dom_element_protected_vtable _protect_vtable = {
+static const struct dom_element_protected_vtable _protect_vtable = {
{
DOM_NODE_PROTECT_VTABLE_HTML_HEAD_ELEMENT
},
diff --git a/src/html/html_heading_element.c b/src/html/html_heading_element.c
index 8ab2c5a..21e36c6 100644
--- a/src/html/html_heading_element.c
+++ b/src/html/html_heading_element.c
@@ -17,7 +17,7 @@
#include "core/attr.h"
#include "utils/utils.h"
-static struct dom_element_protected_vtable _protect_vtable = {
+static const struct dom_element_protected_vtable _protect_vtable = {
{
DOM_NODE_PROTECT_VTABLE_HTML_HEADING_ELEMENT
},
diff --git a/src/html/html_hr_element.c b/src/html/html_hr_element.c
index e6086f5..8ca9743 100644
--- a/src/html/html_hr_element.c
+++ b/src/html/html_hr_element.c
@@ -17,7 +17,7 @@
#include "core/attr.h"
#include "utils/utils.h"
-static struct dom_element_protected_vtable _protect_vtable = {
+static const struct dom_element_protected_vtable _protect_vtable = {
{
DOM_NODE_PROTECT_VTABLE_HTML_HR_ELEMENT
},
diff --git a/src/html/html_html_element.c b/src/html/html_html_element.c
index 9cdcd5e..24f35e4 100644
--- a/src/html/html_html_element.c
+++ b/src/html/html_html_element.c
@@ -13,7 +13,7 @@
#include "core/node.h"
#include "utils/utils.h"
-static struct dom_element_protected_vtable _protect_vtable = {
+static const struct dom_element_protected_vtable _protect_vtable = {
{
DOM_NODE_PROTECT_VTABLE_HTML_HTML_ELEMENT
},
diff --git a/src/html/html_iframe_element.c b/src/html/html_iframe_element.c
index 4d7272b..96397d0 100644
--- a/src/html/html_iframe_element.c
+++ b/src/html/html_iframe_element.c
@@ -17,7 +17,7 @@
#include "core/attr.h"
#include "utils/utils.h"
-static struct dom_element_protected_vtable _protect_vtable = {
+static const struct dom_element_protected_vtable _protect_vtable = {
{
DOM_NODE_PROTECT_VTABLE_HTML_IFRAME_ELEMENT
},
diff --git a/src/html/html_image_element.c b/src/html/html_image_element.c
index 3cdd15f..e5b9c7b 100644
--- a/src/html/html_image_element.c
+++ b/src/html/html_image_element.c
@@ -18,7 +18,7 @@
#include "core/attr.h"
#include "utils/utils.h"
-static struct dom_element_protected_vtable _protect_vtable = {
+static const struct dom_element_protected_vtable _protect_vtable = {
{
DOM_NODE_PROTECT_VTABLE_HTML_IMAGE_ELEMENT
},
diff --git a/src/html/html_input_element.c b/src/html/html_input_element.c
index 079b55e..025ef5d 100644
--- a/src/html/html_input_element.c
+++ b/src/html/html_input_element.c
@@ -17,7 +17,7 @@
#include "core/attr.h"
#include "utils/utils.h"
-static struct dom_element_protected_vtable _protect_vtable = {
+static const struct dom_element_protected_vtable _protect_vtable = {
{
DOM_NODE_PROTECT_VTABLE_HTML_INPUT_ELEMENT
},
diff --git a/src/html/html_isindex_element.c b/src/html/html_isindex_element.c
index 40cb99c..e793fae 100644
--- a/src/html/html_isindex_element.c
+++ b/src/html/html_isindex_element.c
@@ -16,7 +16,7 @@
#include "core/attr.h"
#include "utils/utils.h"
-static struct dom_element_protected_vtable _protect_vtable = {
+static const struct dom_element_protected_vtable _protect_vtable = {
{
DOM_NODE_PROTECT_VTABLE_HTML_ISINDEX_ELEMENT
},
diff --git a/src/html/html_label_element.c b/src/html/html_label_element.c
index 777144a..c62adca 100644
--- a/src/html/html_label_element.c
+++ b/src/html/html_label_element.c
@@ -15,7 +15,7 @@
#include "core/node.h"
#include "utils/utils.h"
-static struct dom_element_protected_vtable _protect_vtable = {
+static const struct dom_element_protected_vtable _protect_vtable = {
{
DOM_NODE_PROTECT_VTABLE_HTML_LABEL_ELEMENT
},
diff --git a/src/html/html_legend_element.c b/src/html/html_legend_element.c
index efb712b..f4200c8 100644
--- a/src/html/html_legend_element.c
+++ b/src/html/html_legend_element.c
@@ -19,7 +19,7 @@
#include "core/attr.h"
#include "utils/utils.h"
-static struct dom_element_protected_vtable _protect_vtable = {
+static const struct dom_element_protected_vtable _protect_vtable = {
{
DOM_NODE_PROTECT_VTABLE_HTML_LEGEND_ELEMENT
},
diff --git a/src/html/html_li_element.c b/src/html/html_li_element.c
index 84becf9..6856046 100644
--- a/src/html/html_li_element.c
+++ b/src/html/html_li_element.c
@@ -17,7 +17,7 @@
#include "core/attr.h"
#include "utils/utils.h"
-static struct dom_element_protected_vtable _protect_vtable = {
+static const struct dom_element_protected_vtable _protect_vtable = {
{
DOM_NODE_PROTECT_VTABLE_HTML_LI_ELEMENT
},
diff --git a/src/html/html_link_element.c b/src/html/html_link_element.c
index 87fe980..4916883 100644
--- a/src/html/html_link_element.c
+++ b/src/html/html_link_element.c
@@ -15,7 +15,7 @@
#include "core/attr.h"
#include "utils/utils.h"
-static struct dom_element_protected_vtable _protect_vtable = {
+static const struct dom_element_protected_vtable _protect_vtable = {
{
DOM_NODE_PROTECT_VTABLE_HTML_LINK_ELEMENT
},
diff --git a/src/html/html_map_element.c b/src/html/html_map_element.c
index 3b10222..865d9b6 100644
--- a/src/html/html_map_element.c
+++ b/src/html/html_map_element.c
@@ -19,7 +19,7 @@
#include "core/attr.h"
#include "utils/utils.h"
-static struct dom_element_protected_vtable _protect_vtable = {
+static const struct dom_element_protected_vtable _protect_vtable = {
{
DOM_NODE_PROTECT_VTABLE_HTML_MAP_ELEMENT
},
diff --git a/src/html/html_menu_element.c b/src/html/html_menu_element.c
index 09eadb6..882f1f2 100644
--- a/src/html/html_menu_element.c
+++ b/src/html/html_menu_element.c
@@ -17,7 +17,7 @@
#include "core/attr.h"
#include "utils/utils.h"
-static struct dom_element_protected_vtable _protect_vtable = {
+static const struct dom_element_protected_vtable _protect_vtable = {
{
DOM_NODE_PROTECT_VTABLE_HTML_MENU_ELEMENT
},
diff --git a/src/html/html_meta_element.c b/src/html/html_meta_element.c
index 4098daf..39fd9e1 100644
--- a/src/html/html_meta_element.c
+++ b/src/html/html_meta_element.c
@@ -13,7 +13,7 @@
#include "core/node.h"
#include "utils/utils.h"
-static struct dom_element_protected_vtable _protect_vtable = {
+static const struct dom_element_protected_vtable _protect_vtable = {
{
DOM_NODE_PROTECT_VTABLE_HTML_META_ELEMENT
},
diff --git a/src/html/html_mod_element.c b/src/html/html_mod_element.c
index 20cb042..4f3331c 100644
--- a/src/html/html_mod_element.c
+++ b/src/html/html_mod_element.c
@@ -17,7 +17,7 @@
#include "core/attr.h"
#include "utils/utils.h"
-static struct dom_element_protected_vtable _protect_vtable = {
+static const struct dom_element_protected_vtable _protect_vtable = {
{
DOM_NODE_PROTECT_VTABLE_HTML_MOD_ELEMENT
},
diff --git a/src/html/html_object_element.c b/src/html/html_object_element.c
index b51e3a0..1359ede 100644
--- a/src/html/html_object_element.c
+++ b/src/html/html_object_element.c
@@ -20,7 +20,7 @@
#include "core/attr.h"
#include "utils/utils.h"
-static struct dom_element_protected_vtable _protect_vtable = {
+static const struct dom_element_protected_vtable _protect_vtable = {
{
DOM_NODE_PROTECT_VTABLE_HTML_OBJECT_ELEMENT
},
diff --git a/src/html/html_olist_element.c b/src/html/html_olist_element.c
index c89d11f..415b656 100644
--- a/src/html/html_olist_element.c
+++ b/src/html/html_olist_element.c
@@ -17,7 +17,7 @@
#include "core/attr.h"
#include "utils/utils.h"
-static struct dom_element_protected_vtable _protect_vtable = {
+static const struct dom_element_protected_vtable _protect_vtable = {
{
DOM_NODE_PROTECT_VTABLE_HTML_OLIST_ELEMENT
},
diff --git a/src/html/html_opt_group_element.c b/src/html/html_opt_group_element.c
index 6af0a29..a50e3de 100644
--- a/src/html/html_opt_group_element.c
+++ b/src/html/html_opt_group_element.c
@@ -17,7 +17,7 @@
#include "core/attr.h"
#include "utils/utils.h"
-static struct dom_element_protected_vtable _protect_vtable = {
+static const struct dom_element_protected_vtable _protect_vtable = {
{
DOM_NODE_PROTECT_VTABLE_HTML_OPT_GROUP_ELEMENT
},
diff --git a/src/html/html_paragraph_element.c b/src/html/html_paragraph_element.c
index 2b2f420..3c8f384 100644
--- a/src/html/html_paragraph_element.c
+++ b/src/html/html_paragraph_element.c
@@ -17,7 +17,7 @@
#include "core/attr.h"
#include "utils/utils.h"
-static struct dom_element_protected_vtable _protect_vtable = {
+static const struct dom_element_protected_vtable _protect_vtable = {
{
DOM_NODE_PROTECT_VTABLE_HTML_P_ELEMENT
},
diff --git a/src/html/html_param_element.c b/src/html/html_param_element.c
index c75e1ce..2c991ac 100644
--- a/src/html/html_param_element.c
+++ b/src/html/html_param_element.c
@@ -17,7 +17,7 @@
#include "core/attr.h"
#include "utils/utils.h"
-static struct dom_element_protected_vtable _protect_vtable = {
+static const struct dom_element_protected_vtable _protect_vtable = {
{
DOM_NODE_PROTECT_VTABLE_HTML_PARAM_ELEMENT
},
diff --git a/src/html/html_pre_element.c b/src/html/html_pre_element.c
index 64c8c3d..7582fde 100644
--- a/src/html/html_pre_element.c
+++ b/src/html/html_pre_element.c
@@ -17,7 +17,7 @@
#include "core/attr.h"
#include "utils/utils.h"
-static struct dom_element_protected_vtable _protect_vtable = {
+static const struct dom_element_protected_vtable _protect_vtable = {
{
DOM_NODE_PROTECT_VTABLE_HTML_PRE_ELEMENT
},
diff --git a/src/html/html_quote_element.c b/src/html/html_quote_element.c
index cf3e0c5..f1bc06f 100644
--- a/src/html/html_quote_element.c
+++ b/src/html/html_quote_element.c
@@ -17,7 +17,7 @@
#include "core/attr.h"
#include "utils/utils.h"
-static struct dom_element_protected_vtable _protect_vtable = {
+static const struct dom_element_protected_vtable _protect_vtable = {
{
DOM_NODE_PROTECT_VTABLE_HTML_QUOTE_ELEMENT
},
diff --git a/src/html/html_script_element.c b/src/html/html_script_element.c
index e8dfb1d..9acbf29 100644
--- a/src/html/html_script_element.c
+++ b/src/html/html_script_element.c
@@ -17,7 +17,7 @@
#include "core/attr.h"
#include "utils/utils.h"
-static struct dom_element_protected_vtable _protect_vtable = {
+static const struct dom_element_protected_vtable _protect_vtable = {
{
DOM_NODE_PROTECT_VTABLE_HTML_SCRIPT_ELEMENT
},
diff --git a/src/html/html_select_element.c b/src/html/html_select_element.c
index 0801d0a..8ba78f1 100644
--- a/src/html/html_select_element.c
+++ b/src/html/html_select_element.c
@@ -17,7 +17,7 @@
#include "core/node.h"
#include "utils/utils.h"
-static struct dom_element_protected_vtable _protect_vtable = {
+static const struct dom_element_protected_vtable _protect_vtable = {
{
DOM_NODE_PROTECT_VTABLE_HTML_SELECT_ELEMENT
},
diff --git a/src/html/html_style_element.c b/src/html/html_style_element.c
index ae845be..4e4974f 100644
--- a/src/html/html_style_element.c
+++ b/src/html/html_style_element.c
@@ -13,7 +13,7 @@
#include "core/node.h"
#include "utils/utils.h"
-static struct dom_element_protected_vtable _protect_vtable = {
+static const struct dom_element_protected_vtable _protect_vtable = {
{
DOM_NODE_PROTECT_VTABLE_HTML_STYLE_ELEMENT
},
diff --git a/src/html/html_table_element.c b/src/html/html_table_element.c
index f197d07..010a6cd 100644
--- a/src/html/html_table_element.c
+++ b/src/html/html_table_element.c
@@ -21,7 +21,7 @@
#include "core/attr.h"
#include "utils/utils.h"
-static struct dom_element_protected_vtable _protect_vtable = {
+static const struct dom_element_protected_vtable _protect_vtable = {
{
DOM_NODE_PROTECT_VTABLE_HTML_TABLE_ELEMENT
},
diff --git a/src/html/html_tablecaption_element.c b/src/html/html_tablecaption_element.c
index cae229c..0e55e3a 100644
--- a/src/html/html_tablecaption_element.c
+++ b/src/html/html_tablecaption_element.c
@@ -17,7 +17,7 @@
#include "core/attr.h"
#include "utils/utils.h"
-static struct dom_element_protected_vtable _protect_vtable = {
+static const struct dom_element_protected_vtable _protect_vtable = {
{
DOM_NODE_PROTECT_VTABLE_HTML_TABLE_CAPTION_ELEMENT
},
diff --git a/src/html/html_tablecell_element.c b/src/html/html_tablecell_element.c
index 7a1f968..2fc31c8 100644
--- a/src/html/html_tablecell_element.c
+++ b/src/html/html_tablecell_element.c
@@ -18,7 +18,7 @@
#include "core/attr.h"
#include "utils/utils.h"
-static struct dom_element_protected_vtable _protect_vtable = {
+static const struct dom_element_protected_vtable _protect_vtable = {
{
DOM_NODE_PROTECT_VTABLE_HTML_TABLE_CELL_ELEMENT
},
diff --git a/src/html/html_tablecol_element.c b/src/html/html_tablecol_element.c
index 74169be..56bcd64 100644
--- a/src/html/html_tablecol_element.c
+++ b/src/html/html_tablecol_element.c
@@ -17,7 +17,7 @@
#include "core/attr.h"
#include "utils/utils.h"
-static struct dom_element_protected_vtable _protect_vtable = {
+static const struct dom_element_protected_vtable _protect_vtable = {
{
DOM_NODE_PROTECT_VTABLE_HTML_TABLE_COL_ELEMENT
},
diff --git a/src/html/html_tablerow_element.c b/src/html/html_tablerow_element.c
index 569e70f..1a6069b 100644
--- a/src/html/html_tablerow_element.c
+++ b/src/html/html_tablerow_element.c
@@ -20,7 +20,7 @@
#include "core/attr.h"
#include "utils/utils.h"
-static struct dom_element_protected_vtable _protect_vtable = {
+static const struct dom_element_protected_vtable _protect_vtable = {
{
DOM_NODE_PROTECT_VTABLE_HTML_TABLE_ROW_ELEMENT
},
diff --git a/src/html/html_tablesection_element.c b/src/html/html_tablesection_element.c
index f839758..dee5ae5 100644
--- a/src/html/html_tablesection_element.c
+++ b/src/html/html_tablesection_element.c
@@ -21,7 +21,7 @@
#include "core/attr.h"
#include "utils/utils.h"
-static struct dom_element_protected_vtable _protect_vtable = {
+static const struct dom_element_protected_vtable _protect_vtable = {
{
DOM_NODE_PROTECT_VTABLE_HTML_TABLE_SECTION_ELEMENT
},
diff --git a/src/html/html_text_area_element.c b/src/html/html_text_area_element.c
index 5c63c3c..db351bc 100644
--- a/src/html/html_text_area_element.c
+++ b/src/html/html_text_area_element.c
@@ -17,7 +17,7 @@
#include "core/attr.h"
#include "utils/utils.h"
-static struct dom_element_protected_vtable _protect_vtable = {
+static const struct dom_element_protected_vtable _protect_vtable = {
{
DOM_NODE_PROTECT_VTABLE_HTML_TEXT_AREA_ELEMENT
},
diff --git a/src/html/html_title_element.c b/src/html/html_title_element.c
index 440b9d5..f727dfa 100644
--- a/src/html/html_title_element.c
+++ b/src/html/html_title_element.c
@@ -17,7 +17,7 @@
#include "core/node.h"
#include "utils/utils.h"
-static struct dom_element_protected_vtable _protect_vtable = {
+static const struct dom_element_protected_vtable _protect_vtable = {
{
DOM_NODE_PROTECT_VTABLE_HTML_TITLE_ELEMENT
},
diff --git a/src/html/html_ulist_element.c b/src/html/html_ulist_element.c
index f2b87fb..48cb0c2 100644
--- a/src/html/html_ulist_element.c
+++ b/src/html/html_ulist_element.c
@@ -17,7 +17,7 @@
#include "core/attr.h"
#include "utils/utils.h"
-static struct dom_element_protected_vtable _protect_vtable = {
+static const struct dom_element_protected_vtable _protect_vtable = {
{
DOM_NODE_PROTECT_VTABLE_HTML_U_LIST_ELEMENT
},
--
Document Object Model library
1 year, 12 months
netsurf: branch master updated. release/3.10-94-g29f7931
by NetSurf Browser Project
Gitweb links:
...log http://git.netsurf-browser.org/netsurf.git/shortlog/29f7931ea41fc06f5d4d6...
...commit http://git.netsurf-browser.org/netsurf.git/commit/29f7931ea41fc06f5d4d69a...
...tree http://git.netsurf-browser.org/netsurf.git/tree/29f7931ea41fc06f5d4d69a41...
The branch, master has been updated
via 29f7931ea41fc06f5d4d69a41484456d94e64ec5 (commit)
from bca82dfe83530c9994259833214f1bc097c5a685 (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/netsurf.git/commit/?id=29f7931ea41fc06f5d4...
commit 29f7931ea41fc06f5d4d69a41484456d94e64ec5
Author: Michael Drake <michael.drake(a)codethink.co.uk>
Commit: Michael Drake <michael.drake(a)codethink.co.uk>
Default CSS: Use 40px for list padding.
diff --git a/resources/default.css b/resources/default.css
index 276bc15..fa47c76 100644
--- a/resources/default.css
+++ b/resources/default.css
@@ -50,9 +50,9 @@ pre { display: block; font-family: monospace; white-space: pre; margin-bottom: 1
ins { color: green; text-decoration: underline; }
del { color: red; text-decoration: line-through; }
-ul { display: block; padding-left: 1.5em; margin: 1.12em 0;
+ul { display: block; padding-left: 40px; margin: 1.12em 0;
list-style-type: disc; }
-ol { display: block; padding-left: 1.5em; margin: 1.12em 0;
+ol { display: block; padding-left: 40px; margin: 1.12em 0;
list-style-type: decimal; }
li { display: list-item; }
-----------------------------------------------------------------------
Summary of changes:
resources/default.css | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)
diff --git a/resources/default.css b/resources/default.css
index 276bc15..fa47c76 100644
--- a/resources/default.css
+++ b/resources/default.css
@@ -50,9 +50,9 @@ pre { display: block; font-family: monospace; white-space: pre; margin-bottom: 1
ins { color: green; text-decoration: underline; }
del { color: red; text-decoration: line-through; }
-ul { display: block; padding-left: 1.5em; margin: 1.12em 0;
+ul { display: block; padding-left: 40px; margin: 1.12em 0;
list-style-type: disc; }
-ol { display: block; padding-left: 1.5em; margin: 1.12em 0;
+ol { display: block; padding-left: 40px; margin: 1.12em 0;
list-style-type: decimal; }
li { display: list-item; }
--
NetSurf Browser
1 year, 12 months