Line data Source code
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/. */
6 :
7 : #ifndef mozilla_MutationEvent_h__
8 : #define mozilla_MutationEvent_h__
9 :
10 : #include "mozilla/BasicEvents.h"
11 : #include "nsCOMPtr.h"
12 : #include "nsIAtom.h"
13 : #include "nsIDOMNode.h"
14 :
15 : namespace mozilla {
16 :
17 0 : class InternalMutationEvent : public WidgetEvent
18 : {
19 : public:
20 0 : virtual InternalMutationEvent* AsMutationEvent() override { return this; }
21 :
22 0 : InternalMutationEvent(bool aIsTrusted, EventMessage aMessage)
23 0 : : WidgetEvent(aIsTrusted, aMessage, eMutationEventClass)
24 0 : , mAttrChange(0)
25 : {
26 0 : mFlags.mCancelable = false;
27 0 : }
28 :
29 0 : virtual WidgetEvent* Duplicate() const override
30 : {
31 0 : MOZ_ASSERT(mClass == eMutationEventClass,
32 : "Duplicate() must be overridden by sub class");
33 0 : InternalMutationEvent* result = new InternalMutationEvent(false, mMessage);
34 0 : result->AssignMutationEventData(*this, true);
35 0 : result->mFlags = mFlags;
36 0 : return result;
37 : }
38 :
39 : nsCOMPtr<nsIDOMNode> mRelatedNode;
40 : nsCOMPtr<nsIAtom> mAttrName;
41 : nsCOMPtr<nsIAtom> mPrevAttrValue;
42 : nsCOMPtr<nsIAtom> mNewAttrValue;
43 : unsigned short mAttrChange;
44 :
45 0 : void AssignMutationEventData(const InternalMutationEvent& aEvent,
46 : bool aCopyTargets)
47 : {
48 0 : AssignEventData(aEvent, aCopyTargets);
49 :
50 0 : mRelatedNode = aEvent.mRelatedNode;
51 0 : mAttrName = aEvent.mAttrName;
52 0 : mPrevAttrValue = aEvent.mPrevAttrValue;
53 0 : mNewAttrValue = aEvent.mNewAttrValue;
54 0 : mAttrChange = aEvent.mAttrChange;
55 0 : }
56 : };
57 :
58 : // Bits are actually checked to optimize mutation event firing.
59 : // That's why I don't number from 0x00. The first event should
60 : // always be 0x01.
61 : #define NS_EVENT_BITS_MUTATION_SUBTREEMODIFIED 0x01
62 : #define NS_EVENT_BITS_MUTATION_NODEINSERTED 0x02
63 : #define NS_EVENT_BITS_MUTATION_NODEREMOVED 0x04
64 : #define NS_EVENT_BITS_MUTATION_NODEREMOVEDFROMDOCUMENT 0x08
65 : #define NS_EVENT_BITS_MUTATION_NODEINSERTEDINTODOCUMENT 0x10
66 : #define NS_EVENT_BITS_MUTATION_ATTRMODIFIED 0x20
67 : #define NS_EVENT_BITS_MUTATION_CHARACTERDATAMODIFIED 0x40
68 :
69 : } // namespace mozilla
70 :
71 : #endif // mozilla_MutationEvent_h__
|