1.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000 1.2 +++ b/dom/events/InternalMutationEvent.h Wed Dec 31 06:09:35 2014 +0100 1.3 @@ -0,0 +1,70 @@ 1.4 +/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ 1.5 +/* This Source Code Form is subject to the terms of the Mozilla Public 1.6 + * License, v. 2.0. If a copy of the MPL was not distributed with this 1.7 + * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ 1.8 + 1.9 +#ifndef mozilla_MutationEvent_h__ 1.10 +#define mozilla_MutationEvent_h__ 1.11 + 1.12 +#include "mozilla/BasicEvents.h" 1.13 +#include "nsCOMPtr.h" 1.14 +#include "nsIAtom.h" 1.15 +#include "nsIDOMNode.h" 1.16 + 1.17 +namespace mozilla { 1.18 + 1.19 +class InternalMutationEvent : public WidgetEvent 1.20 +{ 1.21 +public: 1.22 + virtual InternalMutationEvent* AsMutationEvent() MOZ_OVERRIDE { return this; } 1.23 + 1.24 + InternalMutationEvent(bool aIsTrusted, uint32_t aMessage) : 1.25 + WidgetEvent(aIsTrusted, aMessage, NS_MUTATION_EVENT), 1.26 + mAttrChange(0) 1.27 + { 1.28 + mFlags.mCancelable = false; 1.29 + } 1.30 + 1.31 + virtual WidgetEvent* Duplicate() const MOZ_OVERRIDE 1.32 + { 1.33 + MOZ_ASSERT(eventStructType == NS_MUTATION_EVENT, 1.34 + "Duplicate() must be overridden by sub class"); 1.35 + InternalMutationEvent* result = new InternalMutationEvent(false, message); 1.36 + result->AssignMutationEventData(*this, true); 1.37 + result->mFlags = mFlags; 1.38 + return result; 1.39 + } 1.40 + 1.41 + nsCOMPtr<nsIDOMNode> mRelatedNode; 1.42 + nsCOMPtr<nsIAtom> mAttrName; 1.43 + nsCOMPtr<nsIAtom> mPrevAttrValue; 1.44 + nsCOMPtr<nsIAtom> mNewAttrValue; 1.45 + unsigned short mAttrChange; 1.46 + 1.47 + void AssignMutationEventData(const InternalMutationEvent& aEvent, 1.48 + bool aCopyTargets) 1.49 + { 1.50 + AssignEventData(aEvent, aCopyTargets); 1.51 + 1.52 + mRelatedNode = aEvent.mRelatedNode; 1.53 + mAttrName = aEvent.mAttrName; 1.54 + mPrevAttrValue = aEvent.mPrevAttrValue; 1.55 + mNewAttrValue = aEvent.mNewAttrValue; 1.56 + mAttrChange = aEvent.mAttrChange; 1.57 + } 1.58 +}; 1.59 + 1.60 +// Bits are actually checked to optimize mutation event firing. 1.61 +// That's why I don't number from 0x00. The first event should 1.62 +// always be 0x01. 1.63 +#define NS_EVENT_BITS_MUTATION_SUBTREEMODIFIED 0x01 1.64 +#define NS_EVENT_BITS_MUTATION_NODEINSERTED 0x02 1.65 +#define NS_EVENT_BITS_MUTATION_NODEREMOVED 0x04 1.66 +#define NS_EVENT_BITS_MUTATION_NODEREMOVEDFROMDOCUMENT 0x08 1.67 +#define NS_EVENT_BITS_MUTATION_NODEINSERTEDINTODOCUMENT 0x10 1.68 +#define NS_EVENT_BITS_MUTATION_ATTRMODIFIED 0x20 1.69 +#define NS_EVENT_BITS_MUTATION_CHARACTERDATAMODIFIED 0x40 1.70 + 1.71 +} // namespace mozilla 1.72 + 1.73 +#endif // mozilla_MutationEvent_h__