mirror of
https://github.com/mozilla/gecko-dev.git
synced 2025-02-26 12:20:56 +00:00

Deletion of mutation observers from a list resulted in O(n^2) behavior and could lead to massive freezes. This is resolved by using a LinkedList instead, reducing complexity to O(n). A safely iterable doubly linked list was implemented based on `mozilla::DoublyLinkedList`, allowing to insert and remove elements while iterating the list. Due to the nature of `mozilla::DoublyLinkedList`, every Mutation Observer now inherits `mozilla::DoublyLinkedListElement<T>`. This implies that a Mutation Observer can only be part of one DoublyLinkedList. This conflicts with some Mutation Observers, which are being added to multiple `nsINode`s. To continue supporting this, new MutationObserver base classes `nsMultiMutationObserver` and `nsStubMultiMutationObserver` are introduced, which create `MutationObserverWrapper` objects each time they are added to a `nsINode`. The wrapper objects forward every call to the actual observer. Differential Revision: https://phabricator.services.mozilla.com/D157031