News for hackers. Stuff that matters.
Re:Ladybird: A new cross-platform browser project by ameixaseca on Monday September 12, 2022 @03:52PM (#32815927)
Unless sibling is sideways (same level of the tree) and children is downward (one level closer to the leaves).

I haven't looked at the code but that's my first impression given the nomenclature.

Re:Ladybird: A new cross-platform browser project by c-smile on Monday September 12, 2022 @04:38PM (#32816578)
No, you didn't get it.

You may have children accounted as DL list and so each Node should have m_next / m_previous node references. + Parent node to have m_first_child reference (if list is circular). + m_parent (Node) reference.

So you need 4 pointers per each non-terminal node. Or 3 pointers for terminals.

Otherwise (vector of children):

You need only m_parent (Node) reference in terminals. And in container nodes additional vector<NodePtr> m_children; to store child references.

Re:Ladybird: A new cross-platform browser project by eb2 on Monday September 12, 2022 @09:37PM (#32819767)
You don’t need parent because you can use a breadcrumb stack to track parents.

You want sibling nodes otherwise you will have to traverse back to the root node sometimes to find a sibling.

Re:Ladybird: A new cross-platform browser project by c-smile on Monday September 12, 2022 @10:28PM (#32820079)
> You don’t need parent

You do need parent, check this: https://developer.mozilla.org/en-US/docs/Web/API/Node/parent...

> You want sibling nodes otherwise you will have to traverse back to the root node sometimes to find a sibling.

The only need for this is in Node.nextSibling implementation: https://developer.mozilla.org/en-US/docs/Web/API/Node/nextSi...

Where vector<>::find is pretty sufficient.

But in reality (at least in my Sciter) node stores its index in parent's m_children so it is O(1) operation.

Re:Ladybird: A new cross-platform browser project by lenkite on Friday September 16, 2022 @02:50AM (#32862932)
Is there source code available online illustrating your more-efficient DOM data-structure ?
Re:Ladybird: A new cross-platform browser project by xigoi on Tuesday September 13, 2022 @04:56AM (#32822013)
How about the + operator in CSS?
Re:Ladybird: A new cross-platform browser project by c-smile on Tuesday September 13, 2022 @09:30AM (#32824019)
And what is wrong with it?

and ~ combinator and :nth-child(n) selector for that matter too.

Re:Ladybird: A new cross-platform browser project by xigoi on Tuesday September 13, 2022 @09:46AM (#32824223)
I'm responding to the claim that you only need the ability to find a sibling for the nextSibling method.