2007-03-22 10:30:00 -07:00
|
|
|
/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
|
2012-05-21 04:12:37 -07:00
|
|
|
/* This Source Code Form is subject to the terms of the Mozilla Public
|
|
|
|
* License, v. 2.0. If a copy of the MPL was not distributed with this
|
|
|
|
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
|
2007-03-22 10:30:00 -07:00
|
|
|
|
2013-09-24 03:04:16 -07:00
|
|
|
#ifndef mozilla_MutationEvent_h__
|
|
|
|
#define mozilla_MutationEvent_h__
|
2007-03-22 10:30:00 -07:00
|
|
|
|
2013-09-24 03:04:16 -07:00
|
|
|
#include "mozilla/BasicEvents.h"
|
|
|
|
#include "nsCOMPtr.h"
|
2007-03-22 10:30:00 -07:00
|
|
|
#include "nsIAtom.h"
|
2013-09-24 03:04:16 -07:00
|
|
|
#include "nsIDOMNode.h"
|
|
|
|
|
|
|
|
namespace mozilla {
|
2007-03-22 10:30:00 -07:00
|
|
|
|
2013-09-24 03:04:16 -07:00
|
|
|
class InternalMutationEvent : public WidgetEvent
|
2007-03-22 10:30:00 -07:00
|
|
|
{
|
|
|
|
public:
|
2013-10-17 23:10:20 -07:00
|
|
|
virtual InternalMutationEvent* AsMutationEvent() MOZ_OVERRIDE { return this; }
|
|
|
|
|
2014-08-03 22:28:57 -07:00
|
|
|
InternalMutationEvent(bool aIsTrusted, uint32_t aMessage)
|
|
|
|
: WidgetEvent(aIsTrusted, aMessage, eMutationEventClass)
|
|
|
|
, mAttrChange(0)
|
2007-03-22 10:30:00 -07:00
|
|
|
{
|
2012-12-15 17:26:03 -08:00
|
|
|
mFlags.mCancelable = false;
|
2007-03-22 10:30:00 -07:00
|
|
|
}
|
|
|
|
|
2014-01-26 22:10:44 -08:00
|
|
|
virtual WidgetEvent* Duplicate() const MOZ_OVERRIDE
|
|
|
|
{
|
2014-08-03 22:28:57 -07:00
|
|
|
MOZ_ASSERT(mClass == eMutationEventClass,
|
2014-01-26 22:10:44 -08:00
|
|
|
"Duplicate() must be overridden by sub class");
|
|
|
|
InternalMutationEvent* result = new InternalMutationEvent(false, message);
|
|
|
|
result->AssignMutationEventData(*this, true);
|
|
|
|
result->mFlags = mFlags;
|
|
|
|
return result;
|
|
|
|
}
|
|
|
|
|
2007-03-22 10:30:00 -07:00
|
|
|
nsCOMPtr<nsIDOMNode> mRelatedNode;
|
|
|
|
nsCOMPtr<nsIAtom> mAttrName;
|
|
|
|
nsCOMPtr<nsIAtom> mPrevAttrValue;
|
|
|
|
nsCOMPtr<nsIAtom> mNewAttrValue;
|
|
|
|
unsigned short mAttrChange;
|
2013-09-03 04:45:30 -07:00
|
|
|
|
2013-09-24 03:04:16 -07:00
|
|
|
void AssignMutationEventData(const InternalMutationEvent& aEvent,
|
|
|
|
bool aCopyTargets)
|
2013-09-03 04:45:30 -07:00
|
|
|
{
|
|
|
|
AssignEventData(aEvent, aCopyTargets);
|
|
|
|
|
|
|
|
mRelatedNode = aEvent.mRelatedNode;
|
|
|
|
mAttrName = aEvent.mAttrName;
|
|
|
|
mPrevAttrValue = aEvent.mPrevAttrValue;
|
|
|
|
mNewAttrValue = aEvent.mNewAttrValue;
|
|
|
|
mAttrChange = aEvent.mAttrChange;
|
|
|
|
}
|
2007-03-22 10:30:00 -07:00
|
|
|
};
|
|
|
|
|
|
|
|
// Bits are actually checked to optimize mutation event firing.
|
|
|
|
// That's why I don't number from 0x00. The first event should
|
|
|
|
// always be 0x01.
|
|
|
|
#define NS_EVENT_BITS_MUTATION_SUBTREEMODIFIED 0x01
|
|
|
|
#define NS_EVENT_BITS_MUTATION_NODEINSERTED 0x02
|
|
|
|
#define NS_EVENT_BITS_MUTATION_NODEREMOVED 0x04
|
|
|
|
#define NS_EVENT_BITS_MUTATION_NODEREMOVEDFROMDOCUMENT 0x08
|
|
|
|
#define NS_EVENT_BITS_MUTATION_NODEINSERTEDINTODOCUMENT 0x10
|
|
|
|
#define NS_EVENT_BITS_MUTATION_ATTRMODIFIED 0x20
|
|
|
|
#define NS_EVENT_BITS_MUTATION_CHARACTERDATAMODIFIED 0x40
|
|
|
|
|
2013-09-24 03:04:16 -07:00
|
|
|
} // namespace mozilla
|
|
|
|
|
|
|
|
#endif // mozilla_MutationEvent_h__
|