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