Repository navigation
Introduce VirtualMethods::children_changed() - #6660
Conversation
|
Critic review: https://critic.hoppipolla.co.uk/r/5593 This is an external review system which you may optionally use for the code review of your pull request. In order to help critic track your changes, please do not make in-place history rewrites (e.g. via |
|
@pcwalton I don't see how we can afford to not bring it back if we ever support mutation observers. Maybe an enum |
|
Seems like I forgot to fix Node.replaceChild(). |
|
I think we are better off passing around an enumeration representing each kind of changes that can happen to children of a node, instead of 2 vectors and 2 nodes. With the 2 vectors and 2 nodes, implementors have to handle cases that don't exist, like removing n out of m children of a node, while the only removal cases that exist are removing a single node or all of them. |
|
Maybe use a |
|
@pcwalton So I should make a RootedSmallVec I guess? |
|
☔ The latest upstream changes (presumably #6694) made this pull request unmergeable. Please resolve the merge conflicts. |
|
There is a problem on insertion, children_changed() isn't called when the nodes are removed from their original parents. |
|
Misunderstood the problem, children_changed() was called too many times because remove() didn't check whether the suppress observers flag was set or not. |
|
I've looked through node.rs and cross-checked the various node manipulation algorithms in the spec against our implementation. It appears as though in the cases in which we execute an algorithm with observers suppressed (and therefore don't call children_changed), we later explicitly call children_changed for the same set of affected nodes. Accordingly, these changes look good to me with a couple small considerations. -S-awaiting-review +S-needs-code-changes Reviewed 4 of 4 files at r1, 7 of 7 files at r2. components/script/dom/node.rs, line 2605 [r2] (raw file): components/script/dom/node.rs, line 2622 [r2] (raw file): Why is removed_node &&? Comments from the review on Reviewable.io |
This virtual method mimics the behaviour of mutation observers and make it more viable than the older child_inserted(), which didn't cover removed nodes and was called as many times as there were inserted nodes. A few other shortcomings where remove_child() was called directly instead of Node::remove() were also fixed while at it.
|
Review status: 10 of 11 files reviewed at latest revision, 1 unresolved discussion, all commit checks successful. components/script/dom/node.rs, line 2622 [r2] (raw file): Comments from the review on Reviewable.io |
|
@bors-servo: r+ Reviewed 1 of 1 files at r3. Comments from the review on Reviewable.io |
|
📌 Commit 7b40cc9 has been approved by |
|
⌛ Testing commit 7b40cc9 with merge 705c95d... |
Introduce VirtualMethods::children_changed() This virtual method mimics the behaviour of mutation observers and make it more viable than the older child_inserted(), which didn't cover removed nodes and was called as many times as there were inserted nodes. A few other shortcomings where remove_child() was called directly instead of Node::remove() were also fixed while at it. <!-- Reviewable:start --> [<img src="https://reviewable.io/review_button.png" height=40 alt="Review on Reviewable"/>](https://reviewable.io/reviews/servo/servo/6660) <!-- Reviewable:end -->
This virtual method mimics the behaviour of mutation observers and make it more viable than the older child_inserted(), which didn't cover removed nodes and was called as many times as there were inserted nodes.
A few other shortcomings where remove_child() was called directly instead of Node::remove() were also fixed while at it.