1 /* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
2 /* vim: set ts=8 sts=2 et sw=2 tw=80: */
3 /* This Source Code Form is subject to the terms of the Mozilla Public
4 * License, v. 2.0. If a copy of the MPL was not distributed with this
5 * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
7 #ifndef mozilla_MutationEvent_h__
8 #define mozilla_MutationEvent_h__
10 #include "mozilla/BasicEvents.h"
17 class InternalMutationEvent
: public WidgetEvent
{
19 virtual InternalMutationEvent
* AsMutationEvent() override
{ return this; }
21 InternalMutationEvent(bool aIsTrusted
, EventMessage aMessage
)
22 : WidgetEvent(aIsTrusted
, aMessage
, eMutationEventClass
), mAttrChange(0) {
23 mFlags
.mCancelable
= false;
26 virtual WidgetEvent
* Duplicate() const override
{
27 MOZ_ASSERT(mClass
== eMutationEventClass
,
28 "Duplicate() must be overridden by sub class");
29 InternalMutationEvent
* result
= new InternalMutationEvent(false, mMessage
);
30 result
->AssignMutationEventData(*this, true);
31 result
->mFlags
= mFlags
;
35 nsCOMPtr
<nsINode
> mRelatedNode
;
36 RefPtr
<nsAtom
> mAttrName
;
37 RefPtr
<nsAtom
> mPrevAttrValue
;
38 RefPtr
<nsAtom
> mNewAttrValue
;
39 unsigned short mAttrChange
;
41 void AssignMutationEventData(const InternalMutationEvent
& aEvent
,
43 AssignEventData(aEvent
, aCopyTargets
);
45 mRelatedNode
= aEvent
.mRelatedNode
;
46 mAttrName
= aEvent
.mAttrName
;
47 mPrevAttrValue
= aEvent
.mPrevAttrValue
;
48 mNewAttrValue
= aEvent
.mNewAttrValue
;
49 mAttrChange
= aEvent
.mAttrChange
;
53 // Bits are actually checked to optimize mutation event firing.
54 // That's why I don't number from 0x00. The first event should
56 #define NS_EVENT_BITS_MUTATION_SUBTREEMODIFIED 0x01
57 #define NS_EVENT_BITS_MUTATION_NODEINSERTED 0x02
58 #define NS_EVENT_BITS_MUTATION_NODEREMOVED 0x04
59 #define NS_EVENT_BITS_MUTATION_NODEREMOVEDFROMDOCUMENT 0x08
60 #define NS_EVENT_BITS_MUTATION_NODEINSERTEDINTODOCUMENT 0x10
61 #define NS_EVENT_BITS_MUTATION_ATTRMODIFIED 0x20
62 #define NS_EVENT_BITS_MUTATION_CHARACTERDATAMODIFIED 0x40
64 } // namespace mozilla
66 #endif // mozilla_MutationEvent_h__