dom/events/InternalMutationEvent.h

changeset 0
6474c204b198
equal deleted inserted replaced
-1:000000000000 0:eeb435dd2c9f
1 /* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
2 /* This Source Code Form is subject to the terms of the Mozilla Public
3 * License, v. 2.0. If a copy of the MPL was not distributed with this
4 * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
5
6 #ifndef mozilla_MutationEvent_h__
7 #define mozilla_MutationEvent_h__
8
9 #include "mozilla/BasicEvents.h"
10 #include "nsCOMPtr.h"
11 #include "nsIAtom.h"
12 #include "nsIDOMNode.h"
13
14 namespace mozilla {
15
16 class InternalMutationEvent : public WidgetEvent
17 {
18 public:
19 virtual InternalMutationEvent* AsMutationEvent() MOZ_OVERRIDE { return this; }
20
21 InternalMutationEvent(bool aIsTrusted, uint32_t aMessage) :
22 WidgetEvent(aIsTrusted, aMessage, NS_MUTATION_EVENT),
23 mAttrChange(0)
24 {
25 mFlags.mCancelable = false;
26 }
27
28 virtual WidgetEvent* Duplicate() const MOZ_OVERRIDE
29 {
30 MOZ_ASSERT(eventStructType == NS_MUTATION_EVENT,
31 "Duplicate() must be overridden by sub class");
32 InternalMutationEvent* result = new InternalMutationEvent(false, message);
33 result->AssignMutationEventData(*this, true);
34 result->mFlags = mFlags;
35 return result;
36 }
37
38 nsCOMPtr<nsIDOMNode> mRelatedNode;
39 nsCOMPtr<nsIAtom> mAttrName;
40 nsCOMPtr<nsIAtom> mPrevAttrValue;
41 nsCOMPtr<nsIAtom> mNewAttrValue;
42 unsigned short mAttrChange;
43
44 void AssignMutationEventData(const InternalMutationEvent& aEvent,
45 bool aCopyTargets)
46 {
47 AssignEventData(aEvent, aCopyTargets);
48
49 mRelatedNode = aEvent.mRelatedNode;
50 mAttrName = aEvent.mAttrName;
51 mPrevAttrValue = aEvent.mPrevAttrValue;
52 mNewAttrValue = aEvent.mNewAttrValue;
53 mAttrChange = aEvent.mAttrChange;
54 }
55 };
56
57 // Bits are actually checked to optimize mutation event firing.
58 // That's why I don't number from 0x00. The first event should
59 // always be 0x01.
60 #define NS_EVENT_BITS_MUTATION_SUBTREEMODIFIED 0x01
61 #define NS_EVENT_BITS_MUTATION_NODEINSERTED 0x02
62 #define NS_EVENT_BITS_MUTATION_NODEREMOVED 0x04
63 #define NS_EVENT_BITS_MUTATION_NODEREMOVEDFROMDOCUMENT 0x08
64 #define NS_EVENT_BITS_MUTATION_NODEINSERTEDINTODOCUMENT 0x10
65 #define NS_EVENT_BITS_MUTATION_ATTRMODIFIED 0x20
66 #define NS_EVENT_BITS_MUTATION_CHARACTERDATAMODIFIED 0x40
67
68 } // namespace mozilla
69
70 #endif // mozilla_MutationEvent_h__

mercurial