Hello,
I want to add support for document.getELementById with minimal effort
and minimal slowdown. My idea is:
In parse_element instead of returning attr, alloc and return struct node2:
struct node2 {
        LIST_HEAD(struct node2);
//      unsigned char *start; /* start of HTML element at char '<' */
        unsigned char *a; /* start of attributes, the value of attr */
        struct list_head attrs;
} 

struct attrs {
        LIST_HEAD(struct attrs);
        unsigned char *name;
        unsigned char *value;
}

get_attr_val_node(struct node2 *node, unsigned char *name, ...)
{
        struct attrs *at;
        int found = 0;
        foreach (at, node->attrs) {
                if (!strcasecmp(name, at->name)) {
                        found = 1;
                        break;
                }
        }
        if (found) return stracpy(at->value);
        return get_attr_val(node->a, name, ...);
}

Unfortunately for consistency nodes cannot be allocated every time.
Instead, they should be lookup in the hastable 1. Big slowdown.
Which struct should contain this hashtable?

In start_element in ELEMENT_RENDER_PROLOGUE nodes will be stored
in the hashtable 2, which will be used by getElementById.
Which struct should contain this hashtable?

innerHTML:
struct innerHTML {
        unsigned char *html; /* start of new html */
        unsigned char *eof; /* end of new html */
        unsigned char *end; /* end of original element 
        (first char after closing tag '</...>') */
}
Places where the html is changed mark using special char, eg.
(char)0x05. Pointers to those chars will be keys in the hastable 3.
parse_html should parse them somehow. I don't know how yet.
Which struct should contain this hashtable?

After any change of attribute or innerHTML the whole document should be 
reparsed.
Big slowdown.

Have you got any idea how to make it better?
_______________________________________________
elinks-dev mailing list
elinks-dev@linuxfromscratch.org
http://linuxfromscratch.org/mailman/listinfo/elinks-dev

Reply via email to