summaryrefslogtreecommitdiff
path: root/Source/WebCore/dom/MutationObserver.h
diff options
context:
space:
mode:
Diffstat (limited to 'Source/WebCore/dom/MutationObserver.h')
-rw-r--r--Source/WebCore/dom/MutationObserver.h62
1 files changed, 33 insertions, 29 deletions
diff --git a/Source/WebCore/dom/MutationObserver.h b/Source/WebCore/dom/MutationObserver.h
index d35294a92..b7c71bd51 100644
--- a/Source/WebCore/dom/MutationObserver.h
+++ b/Source/WebCore/dom/MutationObserver.h
@@ -28,31 +28,26 @@
* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
-#ifndef MutationObserver_h
-#define MutationObserver_h
+#pragma once
-#include <wtf/HashMap.h>
+#include "ExceptionOr.h"
+#include <wtf/Forward.h>
#include <wtf/HashSet.h>
-#include <wtf/PassRefPtr.h>
-#include <wtf/RefCounted.h>
-#include <wtf/RefPtr.h>
-#include <wtf/text/AtomicString.h>
-#include <wtf/text/AtomicStringHash.h>
+#include <wtf/Vector.h>
namespace WebCore {
-class Dictionary;
+class HTMLSlotElement;
class MutationCallback;
class MutationObserverRegistration;
class MutationRecord;
class Node;
-typedef int ExceptionCode;
-
-typedef unsigned char MutationObserverOptions;
-typedef unsigned char MutationRecordDeliveryOptions;
+using MutationObserverOptions = unsigned char;
+using MutationRecordDeliveryOptions = unsigned char;
class MutationObserver : public RefCounted<MutationObserver> {
+ friend class MutationObserverMicrotask;
public:
enum MutationType {
ChildList = 1 << 0,
@@ -72,36 +67,45 @@ public:
CharacterDataOldValue = 1 << 6,
};
- static PassRefPtr<MutationObserver> create(PassRefPtr<MutationCallback>);
- static void deliverAllMutations();
+ static Ref<MutationObserver> create(Ref<MutationCallback>&&);
~MutationObserver();
- void observe(Node*, const Dictionary&, ExceptionCode&);
- Vector<RefPtr<MutationRecord>> takeRecords();
+ struct Init {
+ bool childList;
+ std::optional<bool> attributes;
+ std::optional<bool> characterData;
+ bool subtree;
+ std::optional<bool> attributeOldValue;
+ std::optional<bool> characterDataOldValue;
+ std::optional<Vector<String>> attributeFilter;
+ };
+
+ ExceptionOr<void> observe(Node&, const Init&);
+ Vector<Ref<MutationRecord>> takeRecords();
void disconnect();
- void observationStarted(MutationObserverRegistration*);
- void observationEnded(MutationObserverRegistration*);
- void enqueueMutationRecord(PassRefPtr<MutationRecord>);
+
+ void observationStarted(MutationObserverRegistration&);
+ void observationEnded(MutationObserverRegistration&);
+ void enqueueMutationRecord(Ref<MutationRecord>&&);
void setHasTransientRegistration();
bool canDeliver();
- HashSet<Node*> getObservedNodes() const;
+ HashSet<Node*> observedNodes() const;
-private:
- struct ObserverLessThan;
+ static void enqueueSlotChangeEvent(HTMLSlotElement&);
- explicit MutationObserver(PassRefPtr<MutationCallback>);
+private:
+ explicit MutationObserver(Ref<MutationCallback>&&);
void deliver();
+ static void notifyMutationObservers();
static bool validateOptions(MutationObserverOptions);
- RefPtr<MutationCallback> m_callback;
- Vector<RefPtr<MutationRecord>> m_records;
+ Ref<MutationCallback> m_callback;
+ Vector<Ref<MutationRecord>> m_records;
HashSet<MutationObserverRegistration*> m_registrations;
unsigned m_priority;
};
-}
-
-#endif // MutationObserver_h
+} // namespace WebCore