MutationObserverInterestGroup.h [plain text]
#ifndef MutationObserverInterestGroup_h
#define MutationObserverInterestGroup_h
#if ENABLE(MUTATION_OBSERVERS)
#include "Document.h"
#include "Node.h"
#include "QualifiedName.h"
#include "WebKitMutationObserver.h"
#include <wtf/HashMap.h>
#include <wtf/PassOwnPtr.h>
namespace WebCore {
class MutationObserverInterestGroup {
public:
static PassOwnPtr<MutationObserverInterestGroup> createForChildListMutation(Node* target)
{
if (!target->document()->hasMutationObserversOfType(WebKitMutationObserver::ChildList))
return nullptr;
MutationRecordDeliveryOptions oldValueFlag = 0;
return createIfNeeded(target, WebKitMutationObserver::ChildList, oldValueFlag);
}
static PassOwnPtr<MutationObserverInterestGroup> createForCharacterDataMutation(Node* target)
{
if (!target->document()->hasMutationObserversOfType(WebKitMutationObserver::CharacterData))
return nullptr;
return createIfNeeded(target, WebKitMutationObserver::CharacterData, WebKitMutationObserver::CharacterDataOldValue);
}
static PassOwnPtr<MutationObserverInterestGroup> createForAttributesMutation(Node* target, const QualifiedName& attributeName)
{
if (!target->document()->hasMutationObserversOfType(WebKitMutationObserver::Attributes))
return nullptr;
return createIfNeeded(target, WebKitMutationObserver::Attributes, WebKitMutationObserver::AttributeOldValue, &attributeName);
}
bool isOldValueRequested();
void enqueueMutationRecord(PassRefPtr<MutationRecord>);
private:
static PassOwnPtr<MutationObserverInterestGroup> createIfNeeded(Node* target, WebKitMutationObserver::MutationType, MutationRecordDeliveryOptions oldValueFlag, const QualifiedName* attributeName = 0);
MutationObserverInterestGroup(HashMap<WebKitMutationObserver*, MutationRecordDeliveryOptions>& observers, MutationRecordDeliveryOptions oldValueFlag);
bool hasOldValue(MutationRecordDeliveryOptions options) { return options & m_oldValueFlag; }
HashMap<WebKitMutationObserver*, MutationRecordDeliveryOptions> m_observers;
MutationRecordDeliveryOptions m_oldValueFlag;
};
}
#endif // ENABLE(MUTATION_OBSERVERS)
#endif // MutationObserverInterestGroup_h