Coverage Report

Created: 2018-09-25 14:53

/work/obj-fuzz/dist/include/mozilla/InternalMutationEvent.h
Line
Count
Source (jump to first uncovered line)
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 "nsAtom.h"
13
#include "nsINode.h"
14
15
namespace mozilla {
16
17
class InternalMutationEvent : public WidgetEvent
18
{
19
public:
20
0
  virtual InternalMutationEvent* AsMutationEvent() override { return this; }
21
22
  InternalMutationEvent(bool aIsTrusted, EventMessage aMessage)
23
    : WidgetEvent(aIsTrusted, aMessage, eMutationEventClass)
24
    , mAttrChange(0)
25
0
  {
26
0
    mFlags.mCancelable = false;
27
0
  }
28
29
  virtual WidgetEvent* Duplicate() const override
30
0
  {
31
0
    MOZ_ASSERT(mClass == eMutationEventClass,
32
0
               "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
0
  }
38
39
  nsCOMPtr<nsINode> mRelatedNode;
40
  RefPtr<nsAtom>    mAttrName;
41
  RefPtr<nsAtom>    mPrevAttrValue;
42
  RefPtr<nsAtom>    mNewAttrValue;
43
  unsigned short       mAttrChange;
44
45
  void AssignMutationEventData(const InternalMutationEvent& aEvent,
46
                               bool aCopyTargets)
47
0
  {
48
0
    AssignEventData(aEvent, aCopyTargets);
49
0
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
0
#define NS_EVENT_BITS_MUTATION_SUBTREEMODIFIED                0x01
62
0
#define NS_EVENT_BITS_MUTATION_NODEINSERTED                   0x02
63
0
#define NS_EVENT_BITS_MUTATION_NODEREMOVED                    0x04
64
0
#define NS_EVENT_BITS_MUTATION_NODEREMOVEDFROMDOCUMENT        0x08
65
0
#define NS_EVENT_BITS_MUTATION_NODEINSERTEDINTODOCUMENT       0x10
66
0
#define NS_EVENT_BITS_MUTATION_ATTRMODIFIED                   0x20
67
0
#define NS_EVENT_BITS_MUTATION_CHARACTERDATAMODIFIED          0x40
68
69
} // namespace mozilla
70
71
#endif // mozilla_MutationEvent_h__