mirror of
https://github.com/netsurf-browser/netsurf
synced 2024-11-27 16:59:36 +03:00
It probably helps to reflect API changes
svn path=/trunk/netsurf/; revision=7090
This commit is contained in:
parent
33619d7003
commit
23cb08ad01
@ -73,26 +73,32 @@ static struct {
|
||||
static inline char *c_string_from_hubbub_string(hubbub_ctx *ctx,
|
||||
const hubbub_string *str);
|
||||
static void create_namespaces(hubbub_ctx *ctx, xmlNode *root);
|
||||
static int create_comment(void *ctx, const hubbub_string *data, void **result);
|
||||
static int create_doctype(void *ctx, const hubbub_doctype *doctype,
|
||||
static hubbub_error create_comment(void *ctx, const hubbub_string *data,
|
||||
void **result);
|
||||
static int create_element(void *ctx, const hubbub_tag *tag, void **result);
|
||||
static int create_text(void *ctx, const hubbub_string *data, void **result);
|
||||
static int ref_node(void *ctx, void *node);
|
||||
static int unref_node(void *ctx, void *node);
|
||||
static int append_child(void *ctx, void *parent, void *child, void **result);
|
||||
static int insert_before(void *ctx, void *parent, void *child, void *ref_child,
|
||||
static hubbub_error create_doctype(void *ctx, const hubbub_doctype *doctype,
|
||||
void **result);
|
||||
static int remove_child(void *ctx, void *parent, void *child, void **result);
|
||||
static int clone_node(void *ctx, void *node, bool deep, void **result);
|
||||
static int reparent_children(void *ctx, void *node, void *new_parent);
|
||||
static int get_parent(void *ctx, void *node, bool element_only, void **result);
|
||||
static int has_children(void *ctx, void *node, bool *result);
|
||||
static int form_associate(void *ctx, void *form, void *node);
|
||||
static int add_attributes(void *ctx, void *node,
|
||||
static hubbub_error create_element(void *ctx, const hubbub_tag *tag,
|
||||
void **result);
|
||||
static hubbub_error create_text(void *ctx, const hubbub_string *data,
|
||||
void **result);
|
||||
static hubbub_error ref_node(void *ctx, void *node);
|
||||
static hubbub_error unref_node(void *ctx, void *node);
|
||||
static hubbub_error append_child(void *ctx, void *parent, void *child,
|
||||
void **result);
|
||||
static hubbub_error insert_before(void *ctx, void *parent, void *child,
|
||||
void *ref_child, void **result);
|
||||
static hubbub_error remove_child(void *ctx, void *parent, void *child,
|
||||
void **result);
|
||||
static hubbub_error clone_node(void *ctx, void *node, bool deep, void **result);
|
||||
static hubbub_error reparent_children(void *ctx, void *node, void *new_parent);
|
||||
static hubbub_error get_parent(void *ctx, void *node, bool element_only,
|
||||
void **result);
|
||||
static hubbub_error has_children(void *ctx, void *node, bool *result);
|
||||
static hubbub_error form_associate(void *ctx, void *form, void *node);
|
||||
static hubbub_error add_attributes(void *ctx, void *node,
|
||||
const hubbub_attribute *attributes, uint32_t n_attributes);
|
||||
static int set_quirks_mode(void *ctx, hubbub_quirks_mode mode);
|
||||
static int change_encoding(void *ctx, const char *charset);
|
||||
static hubbub_error set_quirks_mode(void *ctx, hubbub_quirks_mode mode);
|
||||
static hubbub_error change_encoding(void *ctx, const char *charset);
|
||||
|
||||
static struct form *parse_form_element(xmlNode *node, const char *docenc);
|
||||
static struct form_control *parse_input_element(xmlNode *node);
|
||||
@ -304,7 +310,7 @@ void create_namespaces(hubbub_ctx *ctx, xmlNode *root)
|
||||
}
|
||||
}
|
||||
|
||||
int create_comment(void *ctx, const hubbub_string *data, void **result)
|
||||
hubbub_error create_comment(void *ctx, const hubbub_string *data, void **result)
|
||||
{
|
||||
hubbub_ctx *c = (hubbub_ctx *) ctx;
|
||||
char *content;
|
||||
@ -312,12 +318,12 @@ int create_comment(void *ctx, const hubbub_string *data, void **result)
|
||||
|
||||
content = c_string_from_hubbub_string(c, data);
|
||||
if (content == NULL)
|
||||
return 1;
|
||||
return HUBBUB_NOMEM;
|
||||
|
||||
n = xmlNewDocComment(c->document, BAD_CAST content);
|
||||
if (n == NULL) {
|
||||
free(content);
|
||||
return 1;
|
||||
return HUBBUB_NOMEM;
|
||||
}
|
||||
n->_private = (void *) (uintptr_t) 1;
|
||||
|
||||
@ -325,10 +331,11 @@ int create_comment(void *ctx, const hubbub_string *data, void **result)
|
||||
|
||||
*result = (void *) n;
|
||||
|
||||
return 0;
|
||||
return HUBBUB_OK;
|
||||
}
|
||||
|
||||
int create_doctype(void *ctx, const hubbub_doctype *doctype, void **result)
|
||||
hubbub_error create_doctype(void *ctx, const hubbub_doctype *doctype,
|
||||
void **result)
|
||||
{
|
||||
hubbub_ctx *c = (hubbub_ctx *) ctx;
|
||||
char *name, *public = NULL, *system = NULL;
|
||||
@ -336,13 +343,13 @@ int create_doctype(void *ctx, const hubbub_doctype *doctype, void **result)
|
||||
|
||||
name = c_string_from_hubbub_string(c, &doctype->name);
|
||||
if (name == NULL)
|
||||
return 1;
|
||||
return HUBBUB_NOMEM;
|
||||
|
||||
if (!doctype->public_missing) {
|
||||
public = c_string_from_hubbub_string(c, &doctype->public_id);
|
||||
if (public == NULL) {
|
||||
free(name);
|
||||
return 1;
|
||||
return HUBBUB_NOMEM;
|
||||
}
|
||||
}
|
||||
|
||||
@ -351,7 +358,7 @@ int create_doctype(void *ctx, const hubbub_doctype *doctype, void **result)
|
||||
if (system == NULL) {
|
||||
free(public);
|
||||
free(name);
|
||||
return 1;
|
||||
return HUBBUB_NOMEM;
|
||||
}
|
||||
}
|
||||
|
||||
@ -362,7 +369,7 @@ int create_doctype(void *ctx, const hubbub_doctype *doctype, void **result)
|
||||
free(system);
|
||||
free(public);
|
||||
free(name);
|
||||
return 1;
|
||||
return HUBBUB_NOMEM;
|
||||
}
|
||||
n->_private = (void *) (uintptr_t) 1;
|
||||
|
||||
@ -372,10 +379,10 @@ int create_doctype(void *ctx, const hubbub_doctype *doctype, void **result)
|
||||
free(public);
|
||||
free(name);
|
||||
|
||||
return 0;
|
||||
return HUBBUB_OK;
|
||||
}
|
||||
|
||||
int create_element(void *ctx, const hubbub_tag *tag, void **result)
|
||||
hubbub_error create_element(void *ctx, const hubbub_tag *tag, void **result)
|
||||
{
|
||||
hubbub_ctx *c = (hubbub_ctx *) ctx;
|
||||
char *name;
|
||||
@ -383,7 +390,7 @@ int create_element(void *ctx, const hubbub_tag *tag, void **result)
|
||||
|
||||
name = c_string_from_hubbub_string(c, &tag->name);
|
||||
if (name == NULL)
|
||||
return 1;
|
||||
return HUBBUB_NOMEM;
|
||||
|
||||
if (c->namespaces[0] != NULL) {
|
||||
n = xmlNewDocNode(c->document, c->namespaces[tag->ns - 1],
|
||||
@ -401,15 +408,15 @@ int create_element(void *ctx, const hubbub_tag *tag, void **result)
|
||||
}
|
||||
if (n == NULL) {
|
||||
free(name);
|
||||
return 1;
|
||||
return HUBBUB_NOMEM;
|
||||
}
|
||||
n->_private = (void *) (uintptr_t) 1;
|
||||
|
||||
if (tag->n_attributes > 0 && add_attributes(ctx, (void *) n,
|
||||
tag->attributes, tag->n_attributes) != 0) {
|
||||
tag->attributes, tag->n_attributes) != HUBBUB_OK) {
|
||||
xmlFreeNode(n);
|
||||
free(name);
|
||||
return 1;
|
||||
return HUBBUB_NOMEM;
|
||||
}
|
||||
|
||||
if (strcasecmp(name, "form") == 0) {
|
||||
@ -419,7 +426,7 @@ int create_element(void *ctx, const hubbub_tag *tag, void **result)
|
||||
if (form == NULL) {
|
||||
xmlFreeNode(n);
|
||||
free(name);
|
||||
return 1;
|
||||
return HUBBUB_NOMEM;
|
||||
}
|
||||
|
||||
/* Insert into list */
|
||||
@ -431,26 +438,26 @@ int create_element(void *ctx, const hubbub_tag *tag, void **result)
|
||||
|
||||
free(name);
|
||||
|
||||
return 0;
|
||||
return HUBBUB_OK;
|
||||
}
|
||||
|
||||
int create_text(void *ctx, const hubbub_string *data, void **result)
|
||||
hubbub_error create_text(void *ctx, const hubbub_string *data, void **result)
|
||||
{
|
||||
hubbub_ctx *c = (hubbub_ctx *) ctx;
|
||||
xmlNodePtr n;
|
||||
|
||||
n = xmlNewDocTextLen(c->document, BAD_CAST data->ptr, (int) data->len);
|
||||
if (n == NULL) {
|
||||
return 1;
|
||||
return HUBBUB_NOMEM;
|
||||
}
|
||||
n->_private = (void *) (uintptr_t) 1;
|
||||
|
||||
*result = (void *) n;
|
||||
|
||||
return 0;
|
||||
return HUBBUB_OK;
|
||||
}
|
||||
|
||||
int ref_node(void *ctx, void *node)
|
||||
hubbub_error ref_node(void *ctx, void *node)
|
||||
{
|
||||
hubbub_ctx *c = (hubbub_ctx *) ctx;
|
||||
|
||||
@ -466,10 +473,10 @@ int ref_node(void *ctx, void *node)
|
||||
n->_private = (void *) ++count;
|
||||
}
|
||||
|
||||
return 0;
|
||||
return HUBBUB_OK;
|
||||
}
|
||||
|
||||
int unref_node(void *ctx, void *node)
|
||||
hubbub_error unref_node(void *ctx, void *node)
|
||||
{
|
||||
hubbub_ctx *c = (hubbub_ctx *) ctx;
|
||||
|
||||
@ -493,10 +500,10 @@ int unref_node(void *ctx, void *node)
|
||||
}
|
||||
}
|
||||
|
||||
return 0;
|
||||
return HUBBUB_OK;
|
||||
}
|
||||
|
||||
int append_child(void *ctx, void *parent, void *child, void **result)
|
||||
hubbub_error append_child(void *ctx, void *parent, void *child, void **result)
|
||||
{
|
||||
xmlNode *chld = (xmlNode *) child;
|
||||
xmlNode *p = (xmlNode *) parent;
|
||||
@ -514,7 +521,7 @@ int append_child(void *ctx, void *parent, void *child, void **result)
|
||||
* merges the content with a pre-existing text node. */
|
||||
chld = xmlCopyNode(chld, 0);
|
||||
if (chld == NULL)
|
||||
return 1;
|
||||
return HUBBUB_NOMEM;
|
||||
|
||||
*result = xmlAddChild(p, chld);
|
||||
|
||||
@ -524,15 +531,15 @@ int append_child(void *ctx, void *parent, void *child, void **result)
|
||||
}
|
||||
|
||||
if (*result == NULL)
|
||||
return 1;
|
||||
return HUBBUB_NOMEM;
|
||||
|
||||
ref_node(ctx, *result);
|
||||
|
||||
return 0;
|
||||
return HUBBUB_OK;
|
||||
}
|
||||
|
||||
int insert_before(void *ctx, void *parent, void *child, void *ref_child,
|
||||
void **result)
|
||||
hubbub_error insert_before(void *ctx, void *parent, void *child,
|
||||
void *ref_child, void **result)
|
||||
{
|
||||
xmlNode *chld = (xmlNode *) child;
|
||||
xmlNode *ref = (xmlNode *) ref_child;
|
||||
@ -542,7 +549,7 @@ int insert_before(void *ctx, void *parent, void *child, void *ref_child,
|
||||
/* Clone text node, as it'll be freed by libxml */
|
||||
chld = xmlCopyNode(chld, 0);
|
||||
if (chld == NULL)
|
||||
return 1;
|
||||
return HUBBUB_NOMEM;
|
||||
|
||||
*result = xmlAddNextSibling(ref->prev, chld);
|
||||
|
||||
@ -552,14 +559,14 @@ int insert_before(void *ctx, void *parent, void *child, void *ref_child,
|
||||
}
|
||||
|
||||
if (*result == NULL)
|
||||
return 1;
|
||||
return HUBBUB_NOMEM;
|
||||
|
||||
ref_node(ctx, *result);
|
||||
|
||||
return 0;
|
||||
return HUBBUB_OK;
|
||||
}
|
||||
|
||||
int remove_child(void *ctx, void *parent, void *child, void **result)
|
||||
hubbub_error remove_child(void *ctx, void *parent, void *child, void **result)
|
||||
{
|
||||
xmlNode *chld = (xmlNode *) child;
|
||||
|
||||
@ -569,24 +576,24 @@ int remove_child(void *ctx, void *parent, void *child, void **result)
|
||||
|
||||
ref_node(ctx, *result);
|
||||
|
||||
return 0;
|
||||
return HUBBUB_OK;
|
||||
}
|
||||
|
||||
int clone_node(void *ctx, void *node, bool deep, void **result)
|
||||
hubbub_error clone_node(void *ctx, void *node, bool deep, void **result)
|
||||
{
|
||||
xmlNode *n = (xmlNode *) node;
|
||||
|
||||
*result = xmlCopyNode(n, deep ? 1 : 2);
|
||||
|
||||
if (*result == NULL)
|
||||
return 1;
|
||||
return HUBBUB_NOMEM;
|
||||
|
||||
((xmlNode *)(*result))->_private = (void *) (uintptr_t) 1;
|
||||
|
||||
return 0;
|
||||
return HUBBUB_OK;
|
||||
}
|
||||
|
||||
int reparent_children(void *ctx, void *node, void *new_parent)
|
||||
hubbub_error reparent_children(void *ctx, void *node, void *new_parent)
|
||||
{
|
||||
xmlNode *n = (xmlNode *) node;
|
||||
xmlNode *p = (xmlNode *) new_parent;
|
||||
@ -598,15 +605,15 @@ int reparent_children(void *ctx, void *node, void *new_parent)
|
||||
xmlUnlinkNode(child);
|
||||
|
||||
if (xmlAddChild(p, child) == NULL)
|
||||
return 1;
|
||||
return HUBBUB_NOMEM;
|
||||
|
||||
child = next;
|
||||
}
|
||||
|
||||
return 0;
|
||||
return HUBBUB_OK;
|
||||
}
|
||||
|
||||
int get_parent(void *ctx, void *node, bool element_only, void **result)
|
||||
hubbub_error get_parent(void *ctx, void *node, bool element_only, void **result)
|
||||
{
|
||||
xmlNode *n = (xmlNode *) node;
|
||||
|
||||
@ -620,19 +627,19 @@ int get_parent(void *ctx, void *node, bool element_only, void **result)
|
||||
if (*result != NULL)
|
||||
ref_node(ctx, *result);
|
||||
|
||||
return 0;
|
||||
return HUBBUB_OK;
|
||||
}
|
||||
|
||||
int has_children(void *ctx, void *node, bool *result)
|
||||
hubbub_error has_children(void *ctx, void *node, bool *result)
|
||||
{
|
||||
xmlNode *n = (xmlNode *) node;
|
||||
|
||||
*result = n->children != NULL;
|
||||
|
||||
return 0;
|
||||
return HUBBUB_OK;
|
||||
}
|
||||
|
||||
int form_associate(void *ctx, void *form, void *node)
|
||||
hubbub_error form_associate(void *ctx, void *form, void *node)
|
||||
{
|
||||
hubbub_ctx *c = (hubbub_ctx *) ctx;
|
||||
xmlNode *n = (xmlNode *) node;
|
||||
@ -667,7 +674,7 @@ int form_associate(void *ctx, void *form, void *node)
|
||||
|
||||
/* None found -- give up */
|
||||
if (f == NULL)
|
||||
return 0;
|
||||
return HUBBUB_OK;
|
||||
|
||||
/* Will be one of: button, fieldset, input, label,
|
||||
* output, select, textarea.
|
||||
@ -683,19 +690,19 @@ int form_associate(void *ctx, void *form, void *node)
|
||||
} else if (strcasecmp((const char *) n->name, "textarea") == 0) {
|
||||
control = parse_textarea_element(n);
|
||||
} else
|
||||
return 0;
|
||||
return HUBBUB_OK;
|
||||
|
||||
/* Memory exhaustion */
|
||||
if (control == NULL)
|
||||
return 1;
|
||||
return HUBBUB_NOMEM;
|
||||
|
||||
/* Add the control to the form */
|
||||
form_add_control(f, control);
|
||||
|
||||
return 0;
|
||||
return HUBBUB_OK;
|
||||
}
|
||||
|
||||
int add_attributes(void *ctx, void *node,
|
||||
hubbub_error add_attributes(void *ctx, void *node,
|
||||
const hubbub_attribute *attributes, uint32_t n_attributes)
|
||||
{
|
||||
hubbub_ctx *c = (hubbub_ctx *) ctx;
|
||||
@ -708,12 +715,12 @@ int add_attributes(void *ctx, void *node,
|
||||
|
||||
name = c_string_from_hubbub_string(c, &attributes[attr].name);
|
||||
if (name == NULL)
|
||||
return 1;
|
||||
return HUBBUB_NOMEM;
|
||||
|
||||
value = c_string_from_hubbub_string(c, &attributes[attr].value);
|
||||
if (value == NULL) {
|
||||
free(name);
|
||||
return 1;
|
||||
return HUBBUB_NOMEM;
|
||||
}
|
||||
|
||||
if (attributes[attr].ns != HUBBUB_NS_NULL &&
|
||||
@ -727,22 +734,22 @@ int add_attributes(void *ctx, void *node,
|
||||
if (prop == NULL) {
|
||||
free(value);
|
||||
free(name);
|
||||
return 1;
|
||||
return HUBBUB_NOMEM;
|
||||
}
|
||||
|
||||
free(value);
|
||||
free(name);
|
||||
}
|
||||
|
||||
return 0;
|
||||
return HUBBUB_OK;
|
||||
}
|
||||
|
||||
int set_quirks_mode(void *ctx, hubbub_quirks_mode mode)
|
||||
hubbub_error set_quirks_mode(void *ctx, hubbub_quirks_mode mode)
|
||||
{
|
||||
return 0;
|
||||
return HUBBUB_OK;
|
||||
}
|
||||
|
||||
int change_encoding(void *ctx, const char *charset)
|
||||
hubbub_error change_encoding(void *ctx, const char *charset)
|
||||
{
|
||||
hubbub_ctx *c = (hubbub_ctx *) ctx;
|
||||
uint32_t source;
|
||||
@ -750,7 +757,7 @@ int change_encoding(void *ctx, const char *charset)
|
||||
|
||||
/* If we have an encoding here, it means we are *certain* */
|
||||
if (c->encoding != NULL) {
|
||||
return 0;
|
||||
return HUBBUB_OK;
|
||||
}
|
||||
|
||||
/* Find the confidence otherwise (can only be from a BOM) */
|
||||
@ -759,7 +766,7 @@ int change_encoding(void *ctx, const char *charset)
|
||||
if (source == HUBBUB_CHARSET_CONFIDENT) {
|
||||
c->encoding_source = ENCODING_SOURCE_DETECTED;
|
||||
c->encoding = (char *) charset;
|
||||
return 0;
|
||||
return HUBBUB_OK;
|
||||
}
|
||||
|
||||
/* So here we have something of confidence tentative... */
|
||||
@ -776,7 +783,7 @@ int change_encoding(void *ctx, const char *charset)
|
||||
c->encoding_source = ENCODING_SOURCE_META;
|
||||
|
||||
/* Equal encodings will have the same string pointers */
|
||||
return (charset == name) ? 0 : 1;
|
||||
return (charset == name) ? HUBBUB_OK : HUBBUB_ENCODINGCHANGE;
|
||||
}
|
||||
|
||||
struct form *parse_form_element(xmlNode *node, const char *docenc)
|
||||
|
Loading…
Reference in New Issue
Block a user