MutationObserver.h [plain text]
#ifndef MutationObserver_h
#define MutationObserver_h
#include <wtf/HashMap.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>
namespace WebCore {
class Dictionary;
class MutationCallback;
class MutationObserverRegistration;
class MutationRecord;
class Node;
typedef int ExceptionCode;
typedef unsigned char MutationObserverOptions;
typedef unsigned char MutationRecordDeliveryOptions;
class MutationObserver : public RefCounted<MutationObserver> {
public:
enum MutationType {
ChildList = 1 << 0,
Attributes = 1 << 1,
CharacterData = 1 << 2,
AllMutationTypes = ChildList | Attributes | CharacterData
};
enum ObservationFlags {
Subtree = 1 << 3,
AttributeFilter = 1 << 4
};
enum DeliveryFlags {
AttributeOldValue = 1 << 5,
CharacterDataOldValue = 1 << 6,
};
static PassRefPtr<MutationObserver> create(PassRefPtr<MutationCallback>);
static void deliverAllMutations();
~MutationObserver();
void observe(Node*, const Dictionary&, ExceptionCode&);
Vector<RefPtr<MutationRecord>> takeRecords();
void disconnect();
void observationStarted(MutationObserverRegistration*);
void observationEnded(MutationObserverRegistration*);
void enqueueMutationRecord(PassRefPtr<MutationRecord>);
void setHasTransientRegistration();
bool canDeliver();
HashSet<Node*> getObservedNodes() const;
private:
struct ObserverLessThan;
explicit MutationObserver(PassRefPtr<MutationCallback>);
void deliver();
static bool validateOptions(MutationObserverOptions);
RefPtr<MutationCallback> m_callback;
Vector<RefPtr<MutationRecord>> m_records;
HashSet<MutationObserverRegistration*> m_registrations;
unsigned m_priority;
};
}
#endif // MutationObserver_h