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