You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Note that these aren't the DOM mutation observers, just an internal servo thing that lets ranges register a callback for when the document changes. It's similar to nsIMutationObserver in Gecko.
With a Vec on the document itself, children_changed() could still be used in the VirtualMethods implementation of Node to update any range associated to the context object, or actually the insert methods and friends could do it themselves too, couldn't they?
Why the indirection with this MutationObserver thing?
I can see children_changed being used for some of the notifications, but I'm not sure how you'd handle some other cases. For example, there are steps to run when calling CharacterData#replaceData, or Node#normalize.
But yes, I think it would be cleaner to just do the steps directly in insert and remove methods.
As for the MutationObserver thing...
In Gecko, other things than just range hook into nsIMutationObserver but perhaps we don't care about those for now.
Having played around with it some I think the MutationObserver abstraction isn't necessary yet and just makes things more complicated for now so I'm tempted to drop it.
Hi Josh,
I am trying to implement Step 4.2 of Queuing a mutation record (If name and namespace are given, set record’s attributeName to name, and record’s attributeNamespace to namespace.)
error[E0382]: use of partially moved value: `attr_type`
--> /home/kbalaji/Moz/servo/components/script/dom/mutationobserver.rs:103:19
|
103 | match attr_type {
| ^^^^^^^^^ value used here after move
104 | Mutation::Attribute {name,namespace,oldValue,newValue} => { let mut given_name = name;let mut given_namespace = namespace;
| ---- value moved here
|
= note: move occurs because `attr_type.name` has type `string_cache::atom::Atom<servo_atoms::AtomStaticSet>`, which does not implement the `Copy` trait
error[E0382]: use of moved value: `attr_type.name`
--> /home/kbalaji/Moz/servo/components/script/dom/mutationobserver.rs:104:37
|
104 | Mutation::Attribute {name,namespace,oldValue,newValue} => { let mut given_name = name;let mut given_namespace = namespace;
| ^^^^ value moved here in previous iteration of loop
|
= note: move occurs because `attr_type.name` has type `string_cache::atom::Atom<servo_atoms::AtomStaticSet>`, which does not implement the `Copy` trait
(similar errors for namespace,oldValue and newValue).
I tried including #[derive(Clone,Copy)] before my mutation and the following code
error[E0119]: conflicting implementations of trait `core::marker::Copy` for type `dom::mutationobserver::Mutation`:
--> /home/kbalaji/Moz/servo/components/script/dom/mutationobserver.rs:35:1
|
31 | #[derive(Clone,Copy)]
| ---- first implementation here
...
35 | impl Copy for Mutation {}
| ^^^^^^^^^^^^^^^^^^^^^^^^^ conflicting implementation for `dom::mutationobserver::Mutation`
error[E0204]: the trait `Copy` may not be implemented for this type
--> /home/kbalaji/Moz/servo/components/script/dom/mutationobserver.rs:31:16
|
31 | #[derive(Clone,Copy)]
| ^^^^
32 | pub enum Mutation {
33 | Attribute { name: Atom, namespace: Namespace, oldValue: DOMString, newValue: DOMString}
| ---------- this field does not implement `Copy`
error[E0204]: the trait `Copy` may not be implemented for this type
--> /home/kbalaji/Moz/servo/components/script/dom/mutationobserver.rs:35:6
|
33 | Attribute { name: Atom, namespace: Namespace, oldValue: DOMString, newValue: DOMString}
| ---------- this field does not implement `Copy`
34 | }
35 | impl Copy for Mutation {}
| ^^^^
error[E0119]: conflicting implementations of trait `core::clone::Clone` for type `dom::mutationobserver::Mutation`:
--> /home/kbalaji/Moz/servo/components/script/dom/mutationobserver.rs:36:1
|
31 | #[derive(Clone,Copy)]
| ----- first implementation here
...
36 | impl Clone for Mutation { fn clone(&self) -> Self { *self } }
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ conflicting implementation for `dom::mutationobserver::Mutation`
Please let us know on how to reference name and namespace of attr_type ( function argument).
Thank you.
Hi,
Separately, I am not clear on what "type" means in "To queue a mutation record of type for target with one or more of (depends on type) ....." .
In Step 3 of Queuing a mutation record , type is supposed to be compared with "attributes", "characterData" and "childList".
Does type refer to record_type of a mutation record object ?. If so , should I pass a mutation record object as well as an argument to my function queue_a_mutation_record along with target and enum. This would enable me to access the type of mutation record through that object.
Please let us know. Thank you.
The "type" in the spec is equivalent to matching against the enum that we're using. To avoid the errors about partially moved values, you will want to use ref binding in the matches, and clone those values like let mut given_name = name.clone().
As for the question about MutationObserverInit, my mistake. I guess you will want sensible defaults for the new members in the constructor, and then set them to the real values in MutationObserver::Observe.
Reacted by Sumit Srivastava, gosavipooja and krishnakarthick1993
@Xanewok Signal slots are part of a standard that we don't implement, so those can be ignored. We're also missing character data notifications, and all of the failing tests that are named MutationObserver.
Activity
jdm commentedon Jul 15, 2015
cc @nox
nox commentedon Jul 15, 2015
Colour me interested. Why do you think mutation observers are the way to go for DOM ranges?
dzbarsky commentedon Jul 15, 2015
Note that these aren't the DOM mutation observers, just an internal servo thing that lets ranges register a callback for when the document changes. It's similar to nsIMutationObserver in Gecko.
jdm commentedon Jul 15, 2015
That sounds confusingly named, in that case :)
dzbarsky commentedon Jul 15, 2015
True it could use a different name. MutationWatcher or something.
nox commentedon Jul 18, 2015
@dzbarsky Would #6660 help?
dzbarsky commentedon Jul 18, 2015
I'm not sure how that PR helps here. There's not really a great way for nodes to know that they're the start or end of some range.
nox commentedon Jul 18, 2015
I made
Rc<RangeInner>in Range because I intended to store aVec<Weak<RangeInner>>in each node. I guess that's the wrong way to go at it?dzbarsky commentedon Jul 18, 2015
That's a lot of storage. I think it's better to store that Vec on the document itself, that's basically what I'm doing in #6639
nox commentedon Jul 18, 2015
With a Vec on the document itself, children_changed() could still be used in the VirtualMethods implementation of Node to update any range associated to the context object, or actually the insert methods and friends could do it themselves too, couldn't they?
Why the indirection with this MutationObserver thing?
dzbarsky commentedon Jul 19, 2015
I can see children_changed being used for some of the notifications, but I'm not sure how you'd handle some other cases. For example, there are steps to run when calling CharacterData#replaceData, or Node#normalize.
But yes, I think it would be cleaner to just do the steps directly in insert and remove methods.
As for the MutationObserver thing...
In Gecko, other things than just range hook into nsIMutationObserver but perhaps we don't care about those for now.
One thing to keep in mind is that NodeIterator also defines "removing steps" (https://dom.spec.whatwg.org/#nodeiterator).
So we would also need to store a Vec of NodeIterators. I was hoping to combine those but it looks like they need different notifications so it doesn't really make things any cleaner.
Having played around with it some I think the MutationObserver abstraction isn't necessary yet and just makes things more complicated for now so I'm tempted to drop it.
nox commentedon Oct 28, 2015
I'm on the Range part.
[-]Implement mutation observers (and hook up DOM Range)[/-][+]Implement mutation observers[/+]39 remaining items
jdm commentedon Apr 30, 2017
(they will need to be wrapped in Cell or DOMRefCell types to allow mutating them later)
gosavipooja commentedon Apr 30, 2017
Hi,
There is no MutationObserverInit argument in the constructor currently and if we add it, it shoots an error in the Bindings file:
Should we create another overridden constructor which also has MutationObserverInit argument? Or what way should we follow?
Thanks!
krishnakarthick1993 commentedon Apr 30, 2017
Hi Josh,
I am trying to implement Step 4.2 of Queuing a mutation record (If name and namespace are given, set record’s attributeName to name, and record’s attributeNamespace to namespace.)
My enum is
Since I need name and namespace of Attribute of Mutation enum which is passed as an argument to my function , I tried using the match function like (http://rustbyexample.com/custom_types/enum.html)
My function is
On compilation I get
(similar errors for namespace,oldValue and newValue).
I tried including #[derive(Clone,Copy)] before my mutation and the following code
Compiler still throws
Please let us know on how to reference name and namespace of attr_type ( function argument).
Thank you.
KiChjang commentedon Apr 30, 2017
I'm very confused why you have
Can
Attributenot be a struct of its own?krishnakarthick1993 commentedon Apr 30, 2017
Hi,
Separately, I am not clear on what "type" means in "To queue a mutation record of type for target with one or more of (depends on type) ....." .
In Step 3 of Queuing a mutation record , type is supposed to be compared with "attributes", "characterData" and "childList".
Does type refer to record_type of a mutation record object ?. If so , should I pass a mutation record object as well as an argument to my function queue_a_mutation_record along with target and enum. This would enable me to access the type of mutation record through that object.
Please let us know. Thank you.
jdm commentedon Apr 30, 2017
The "type" in the spec is equivalent to matching against the enum that we're using. To avoid the errors about partially moved values, you will want to use
refbinding in the matches, and clone those values likelet mut given_name = name.clone().jdm commentedon Apr 30, 2017
As for the question about MutationObserverInit, my mistake. I guess you will want sensible defaults for the new members in the constructor, and then set them to the real values in MutationObserver::Observe.
Auto merge of #16668 - srivassumit:MutationObserver, r=<try>
Auto merge of #16883 - jdm:mutationobserver, r=jdm
Xanewok commentedon Oct 24, 2017
@jdm just want to make sure what's the status of this issue - it seems that effectively almost all of the listed work in https://github.com/servo/servo/wiki/Mutation-observer-project is done (I tried to go over them and mark done items, excuse the crude format), mostly by #16883?
It seems that what's left is:
void disconnect(),sequence<MutationRecord> takeRecords()Asking because we planned to take this on as a team as a part of our university thesis project
cc @mrowqa @marmistrz
marmistrz commentedon Oct 24, 2017
cc @taki-jaro
jdm commentedon Oct 24, 2017
@Xanewok Signal slots are part of a standard that we don't implement, so those can be ignored. We're also missing character data notifications, and all of the failing tests that are named MutationObserver.
jdm commentedon Jan 23, 2020
We have implemented mutation observers. If anything is missing or not working, we should open new issues for those items.