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 const WidgetEventTime
* aTime
= nullptr)
23 : WidgetEvent(aIsTrusted
, aMessage
, eMutationEventClass
, aTime
),
25 mFlags
.mCancelable
= false;
28 virtual WidgetEvent
* Duplicate() const override
{
29 MOZ_ASSERT(mClass
== eMutationEventClass
,
30 "Duplicate() must be overridden by sub class");
31 InternalMutationEvent
* result
=
32 new InternalMutationEvent(false, mMessage
, this);
33 result
->AssignMutationEventData(*this, true);
34 result
->mFlags
= mFlags
;
38 nsCOMPtr
<nsINode
> mRelatedNode
;
39 RefPtr
<nsAtom
> mAttrName
;
40 RefPtr
<nsAtom
> mPrevAttrValue
;
41 RefPtr
<nsAtom
> mNewAttrValue
;
42 unsigned short mAttrChange
;
44 void AssignMutationEventData(const InternalMutationEvent
& aEvent
,
46 AssignEventData(aEvent
, aCopyTargets
);
48 mRelatedNode
= aEvent
.mRelatedNode
;
49 mAttrName
= aEvent
.mAttrName
;
50 mPrevAttrValue
= aEvent
.mPrevAttrValue
;
51 mNewAttrValue
= aEvent
.mNewAttrValue
;
52 mAttrChange
= aEvent
.mAttrChange
;
56 // Bits are actually checked to optimize mutation event firing.
57 // That's why I don't number from 0x00. The first event should
59 #define NS_EVENT_BITS_MUTATION_SUBTREEMODIFIED 0x01
60 #define NS_EVENT_BITS_MUTATION_NODEINSERTED 0x02
61 #define NS_EVENT_BITS_MUTATION_NODEREMOVED 0x04
62 #define NS_EVENT_BITS_MUTATION_NODEREMOVEDFROMDOCUMENT 0x08
63 #define NS_EVENT_BITS_MUTATION_NODEINSERTEDINTODOCUMENT 0x10
64 #define NS_EVENT_BITS_MUTATION_ATTRMODIFIED 0x20
65 #define NS_EVENT_BITS_MUTATION_CHARACTERDATAMODIFIED 0x40
67 #define NS_EVENT_BITS_MUTATION_ALL \
68 (NS_EVENT_BITS_MUTATION_SUBTREEMODIFIED | \
69 NS_EVENT_BITS_MUTATION_NODEINSERTED | NS_EVENT_BITS_MUTATION_NODEREMOVED | \
70 NS_EVENT_BITS_MUTATION_NODEREMOVEDFROMDOCUMENT | \
71 NS_EVENT_BITS_MUTATION_NODEINSERTEDINTODOCUMENT | \
72 NS_EVENT_BITS_MUTATION_ATTRMODIFIED | \
73 NS_EVENT_BITS_MUTATION_CHARACTERDATAMODIFIED)
75 } // namespace mozilla
77 #endif // mozilla_MutationEvent_h__