1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
//! Changes to the document, recorded for a script's `MutationObserver`.
//!
//! Recording happens in [`crate::DocumentMutator`], because every change
//! reaches the tree through it: a script's `appendChild`, `innerHTML` and
//! `setAttribute`, the parser, and the embedder alike. Hooking the script
//! bindings instead would miss whichever path a binding does not own.
//!
//! Two rules keep the log honest and cheap:
//!
//! - It is recorded only while the embedder has switched it on
//! ([`crate::BaseDocument::set_recording_mutations`]), which a script runtime
//! does while at least one observer is registered. A page with no observers
//! pays one branch per change.
//! - Only changes to a node that is in the document are recorded. Building a
//! detached fragment and then inserting it therefore yields one record for
//! the insertion, which is what a browser reports, rather than one per node
//! the fragment was built from. The cost is that an observer watching a
//! detached node directly hears nothing, which no framework relies on.
use crateNodeId;
/// One change, in the shape a `MutationRecord` needs.
/// The most records held between deliveries. A page that rewrites a large
/// tree while observed without ever yielding to its job queue would otherwise
/// grow this without bound; past the cap, further changes in that turn are
/// dropped rather than stored.
pub const MUTATION_LOG_CAP: usize = 100_000;