Re:Modernizing the DOM Tree in Microsoft Edge
by smitherfield on Wednesday April 19, 2017 @04:47PM
(#14151621)
That does seem like it makes more sense; you could then implement `node_index` as a fast, stateless inline method like so:
[ Parent
| on HN ]
Re:Modernizing the DOM Tree in Microsoft Edge
by c-smile on Wednesday April 19, 2017 @05:20PM
(#14151895)
This does not work, element/node shall have stable address so to be O(1) addressable.
Elements/nodes can participate in multiple lists at the same time. Rendering lists (a.k.a. rendering tree) and things like Document.querySelectorAll() that returns NodeList.
Re:Modernizing the DOM Tree in Microsoft Edge
by Someone on Thursday April 20, 2017 @03:17AM
(#14154598)
Can I conclude that your earlier statement "yet the structure ensures that there are no loops in the tree." isn't correct? I could easily create a loop like this:
this.children[0] = this;
Re:Modernizing the DOM Tree in Microsoft Edge
by c-smile on Thursday April 20, 2017 @07:10PM
(#14161721)
That case is easily manageable: you cannot insert/appendNode that has non-null parent. So you need to remove that node from its former parent first.
Problem is that their solution by design contains loops.
So on each tree traversal iteration you will need to access parent:
Node* get_next_node(Node* that) {
that = that->next;
return that == that->parent->first_child ? nullptr : that;
}
Re:Modernizing the DOM Tree in Microsoft Edge
by wtetzner on Thursday April 20, 2017 @04:09PM
(#14160367)
How could that happen, given that children isn't a pointer?
vector<node*> children;
Re:Modernizing the DOM Tree in Microsoft Edge
by Someone on Friday April 21, 2017 @01:03PM
(#14167306)
It is C++, and std::vector has an operator[] that makes a vector behave like a convention C 'pointer to data' for array accesses (in fact, the compiler likely will optimize the access to exactly what you would get if the declaration were of a C array of pointers to node)