aboutsummaryrefslogtreecommitdiffstats
path: root/components/script/dom/mutationobserver.rs
diff options
context:
space:
mode:
authorbors-servo <lbergstrom+bors@mozilla.com>2017-05-20 15:04:43 -0500
committerGitHub <noreply@github.com>2017-05-20 15:04:43 -0500
commit323760f47e79b49ef8db4484cca1969bc26b5413 (patch)
tree922ea79e79299ff090177517a62f359589d12020 /components/script/dom/mutationobserver.rs
parent05a26a29967b4cb70cac0055d0a177881e047efd (diff)
parent0290e405ce2e090f8b9c581acd9df585aebb0672 (diff)
downloadservo-323760f47e79b49ef8db4484cca1969bc26b5413.tar.gz
servo-323760f47e79b49ef8db4484cca1969bc26b5413.zip
Auto merge of #16933 - MortimerGoro:mutation_children, r=jdm
Implement MutationObserver childList mutations. <!-- Please describe your changes on the following line: --> Implement MutationObserver childList mutations --- <!-- Thank you for contributing to Servo! Please replace each `[ ]` by `[X]` when the step is complete, and replace `__` with appropriate data: --> - [x] `./mach build -d` does not report any errors - [x] `./mach test-tidy` does not report any errors - [ ] These changes fix #__ (github issue number if applicable). <!-- Either: --> - [x] There are tests for these changes OR - [ ] These changes do not require tests because _____ <!-- Also, please make sure that "Allow edits from maintainers" checkbox is checked, so that we can help you if you get stuck somewhere along the way.--> <!-- Pull requests that do not address these steps are welcome, but they will require additional verification as part of the review process. --> <!-- Reviewable:start --> --- This change is [<img src="https://reviewable.io/review_button.svg" height="34" align="absmiddle" alt="Reviewable"/>](https://reviewable.io/reviews/servo/servo/16933) <!-- Reviewable:end -->
Diffstat (limited to 'components/script/dom/mutationobserver.rs')
-rw-r--r--components/script/dom/mutationobserver.rs16
1 files changed, 13 insertions, 3 deletions
diff --git a/components/script/dom/mutationobserver.rs b/components/script/dom/mutationobserver.rs
index 48c8fe24b87..84d34af0149 100644
--- a/components/script/dom/mutationobserver.rs
+++ b/components/script/dom/mutationobserver.rs
@@ -29,9 +29,10 @@ pub struct MutationObserver {
record_queue: DOMRefCell<Vec<Root<MutationRecord>>>,
}
-#[derive(Clone)]
-pub enum Mutation {
- Attribute { name: LocalName, namespace: Namespace, old_value: DOMString }
+pub enum Mutation<'a> {
+ Attribute { name: LocalName, namespace: Namespace, old_value: DOMString },
+ ChildList { added: Option<&'a [&'a Node]>, removed: Option<&'a [&'a Node]>,
+ prev: Option<&'a Node>, next: Option<&'a Node> },
}
#[derive(HeapSizeOf, JSTraceable)]
@@ -143,6 +144,12 @@ impl MutationObserver {
interestedObservers.push((Root::from_ref(&*registered.observer),
paired_string));
}
+ },
+ Mutation::ChildList { .. } => {
+ if !registered.options.child_list {
+ continue;
+ }
+ interestedObservers.push((Root::from_ref(&*registered.observer), None));
}
}
}
@@ -159,6 +166,9 @@ impl MutationObserver {
None
};
MutationRecord::attribute_mutated(target, name, namespace, paired_string.clone())
+ },
+ Mutation::ChildList { ref added, ref removed, ref next, ref prev } => {
+ MutationRecord::child_list_mutated(target, *added, *removed, *next, *prev)
}
};
// Step 4.8