#ifndef MutationObserver_h
#define MutationObserver_h
#include "bindings/v8/ScriptWrappable.h"
#include "wtf/HashSet.h"
#include "wtf/PassOwnPtr.h"
#include "wtf/PassRefPtr.h"
#include "wtf/RefCounted.h"
#include "wtf/RefPtr.h"
#include "wtf/Vector.h"
namespace WebCore {
class Dictionary;
class ExceptionState;
class MutationCallback;
class MutationObserverRegistration;
class MutationRecord;
class Node;
typedef unsigned char MutationObserverOptions;
typedef unsigned char MutationRecordDeliveryOptions;
class MutationObserver : public RefCounted<MutationObserver>, public ScriptWrappable {
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(PassOwnPtr<MutationCallback>);
static void resumeSuspendedObservers();
static void deliverMutations();
~MutationObserver();
void observe(Node*, const Dictionary&, ExceptionState&);
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(PassOwnPtr<MutationCallback>);
void deliver();
OwnPtr<MutationCallback> m_callback;
Vector<RefPtr<MutationRecord> > m_records;
HashSet<MutationObserverRegistration*> m_registrations;
unsigned m_priority;
};
}
#endif