1
0
mirror of https://github.com/rkd77/elinks.git synced 2024-12-04 14:46:47 -05:00

get_dom_node_type_name(): return struct dom_string *

This commit is contained in:
Jonas Fonseca 2005-12-10 19:28:37 +01:00 committed by Jonas Fonseca
parent 5f69255cbc
commit 2aedeb0a67
3 changed files with 20 additions and 20 deletions

View File

@ -460,26 +460,26 @@ get_dom_node_value(struct dom_node *node, int codepage)
return compress_string(value, valuelen); return compress_string(value, valuelen);
} }
unsigned char * struct dom_string *
get_dom_node_type_name(enum dom_node_type type) get_dom_node_type_name(enum dom_node_type type)
{ {
static unsigned char *dom_node_type_names[DOM_NODES] = { static struct dom_string dom_node_type_names[DOM_NODES] = {
NULL, INIT_DOM_STRING(NULL, 0),
/* DOM_NODE_ELEMENT */ "element", /* DOM_NODE_ELEMENT */ INIT_DOM_STRING("element", -1),
/* DOM_NODE_ATTRIBUTE */ "attribute", /* DOM_NODE_ATTRIBUTE */ INIT_DOM_STRING("attribute", -1),
/* DOM_NODE_TEXT */ "text", /* DOM_NODE_TEXT */ INIT_DOM_STRING("text", -1),
/* DOM_NODE_CDATA_SECTION */ "cdata-section", /* DOM_NODE_CDATA_SECTION */ INIT_DOM_STRING("cdata-section", -1),
/* DOM_NODE_ENTITY_REFERENCE */ "entity-reference", /* DOM_NODE_ENTITY_REFERENCE */ INIT_DOM_STRING("entity-reference", -1),
/* DOM_NODE_ENTITY */ "entity", /* DOM_NODE_ENTITY */ INIT_DOM_STRING("entity", -1),
/* DOM_NODE_PROCESSING_INSTRUCTION */ "proc-instruction", /* DOM_NODE_PROCESSING_INSTRUCTION */ INIT_DOM_STRING("proc-instruction", -1),
/* DOM_NODE_COMMENT */ "comment", /* DOM_NODE_COMMENT */ INIT_DOM_STRING("comment", -1),
/* DOM_NODE_DOCUMENT */ "document", /* DOM_NODE_DOCUMENT */ INIT_DOM_STRING("document", -1),
/* DOM_NODE_DOCUMENT_TYPE */ "document-type", /* DOM_NODE_DOCUMENT_TYPE */ INIT_DOM_STRING("document-type", -1),
/* DOM_NODE_DOCUMENT_FRAGMENT */ "document-fragment", /* DOM_NODE_DOCUMENT_FRAGMENT */ INIT_DOM_STRING("document-fragment", -1),
/* DOM_NODE_NOTATION */ "notation", /* DOM_NODE_NOTATION */ INIT_DOM_STRING("notation", -1),
}; };
assert(type < DOM_NODES); assert(type < DOM_NODES);
return dom_node_type_names[type]; return &dom_node_type_names[type];
} }

View File

@ -292,7 +292,7 @@ unsigned char *get_dom_node_name(struct dom_node *node);
unsigned char *get_dom_node_value(struct dom_node *node, int codepage); unsigned char *get_dom_node_value(struct dom_node *node, int codepage);
/* Returns the name used for identifying the node type. */ /* Returns the name used for identifying the node type. */
unsigned char *get_dom_node_type_name(enum dom_node_type type); struct dom_string *get_dom_node_type_name(enum dom_node_type type);
/* Returns a pointer to a node list containing attributes. */ /* Returns a pointer to a node list containing attributes. */
#define get_dom_node_attributes(node) \ #define get_dom_node_attributes(node) \

View File

@ -97,8 +97,7 @@ init_dom_renderer(struct dom_renderer *renderer, struct document *document,
color_T foreground = document->options.default_fg; color_T foreground = document->options.default_fg;
static int i_want_struct_module_for_dom; static int i_want_struct_module_for_dom;
unsigned char *name = get_dom_node_type_name(type); struct dom_string *name = get_dom_node_type_name(type);
int namelen = name ? strlen(name) : 0;
struct css_selector *selector = NULL; struct css_selector *selector = NULL;
if (!i_want_struct_module_for_dom) { if (!i_want_struct_module_for_dom) {
@ -119,9 +118,10 @@ init_dom_renderer(struct dom_renderer *renderer, struct document *document,
} }
if (name) if (name)
if (is_dom_string_set(name))
selector = find_css_selector(&css->selectors, selector = find_css_selector(&css->selectors,
CST_ELEMENT, CSR_ROOT, CST_ELEMENT, CSR_ROOT,
name, namelen); name->string, name->length);
if (selector) { if (selector) {
struct list_head *properties = &selector->properties; struct list_head *properties = &selector->properties;