Coverage Report

Created: 2018-09-25 14:53

/src/mozilla-central/dom/events/StorageEvent.cpp
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
#include "mozilla/dom/StorageEvent.h"
8
#include "mozilla/dom/Storage.h"
9
10
namespace mozilla {
11
namespace dom {
12
13
NS_IMPL_CYCLE_COLLECTION_CLASS(StorageEvent)
14
15
NS_IMPL_ADDREF_INHERITED(StorageEvent, Event)
16
NS_IMPL_RELEASE_INHERITED(StorageEvent, Event)
17
18
0
NS_IMPL_CYCLE_COLLECTION_TRAVERSE_BEGIN_INHERITED(StorageEvent, Event)
19
0
  NS_IMPL_CYCLE_COLLECTION_TRAVERSE(mStorageArea)
20
0
NS_IMPL_CYCLE_COLLECTION_TRAVERSE_END
21
22
0
NS_IMPL_CYCLE_COLLECTION_TRACE_BEGIN_INHERITED(StorageEvent, Event)
23
0
NS_IMPL_CYCLE_COLLECTION_TRACE_END
24
25
0
NS_IMPL_CYCLE_COLLECTION_UNLINK_BEGIN_INHERITED(StorageEvent, Event)
26
0
  NS_IMPL_CYCLE_COLLECTION_UNLINK(mStorageArea)
27
0
NS_IMPL_CYCLE_COLLECTION_UNLINK_END
28
29
0
NS_INTERFACE_MAP_BEGIN_CYCLE_COLLECTION(StorageEvent)
30
0
NS_INTERFACE_MAP_END_INHERITING(Event)
31
32
StorageEvent::StorageEvent(EventTarget* aOwner)
33
  : Event(aOwner, nullptr, nullptr)
34
0
{
35
0
}
36
37
StorageEvent::~StorageEvent()
38
0
{
39
0
}
40
41
StorageEvent*
42
StorageEvent::AsStorageEvent()
43
0
{
44
0
  return this;
45
0
}
46
47
JSObject*
48
StorageEvent::WrapObjectInternal(JSContext* aCx, JS::Handle<JSObject*> aGivenProto)
49
0
{
50
0
  return StorageEvent_Binding::Wrap(aCx, this, aGivenProto);
51
0
}
52
53
already_AddRefed<StorageEvent>
54
StorageEvent::Constructor(EventTarget* aOwner,
55
                          const nsAString& aType,
56
                          const StorageEventInit& aEventInitDict)
57
0
{
58
0
  RefPtr<StorageEvent> e = new StorageEvent(aOwner);
59
0
60
0
  bool trusted = e->Init(aOwner);
61
0
  e->InitEvent(aType, aEventInitDict.mBubbles, aEventInitDict.mCancelable);
62
0
  e->mKey = aEventInitDict.mKey;
63
0
  e->mOldValue = aEventInitDict.mOldValue;
64
0
  e->mNewValue = aEventInitDict.mNewValue;
65
0
  e->mUrl = aEventInitDict.mUrl;
66
0
  e->mStorageArea = aEventInitDict.mStorageArea;
67
0
  e->SetTrusted(trusted);
68
0
  e->SetComposed(aEventInitDict.mComposed);
69
0
  return e.forget();
70
0
}
71
72
already_AddRefed<StorageEvent>
73
StorageEvent::Constructor(const GlobalObject& aGlobal,
74
                          const nsAString& aType,
75
                          const StorageEventInit& aEventInitDict,
76
                          ErrorResult& aRv)
77
0
{
78
0
  nsCOMPtr<EventTarget> owner = do_QueryInterface(aGlobal.GetAsSupports());
79
0
  return Constructor(owner, aType, aEventInitDict);
80
0
}
81
82
void
83
StorageEvent::InitStorageEvent(const nsAString& aType, bool aCanBubble,
84
                               bool aCancelable, const nsAString& aKey,
85
                               const nsAString& aOldValue,
86
                               const nsAString& aNewValue,
87
                               const nsAString& aURL,
88
                               Storage* aStorageArea)
89
0
{
90
0
  NS_ENSURE_TRUE_VOID(!mEvent->mFlags.mIsBeingDispatched);
91
0
92
0
  InitEvent(aType, aCanBubble, aCancelable);
93
0
  mKey = aKey;
94
0
  mOldValue = aOldValue;
95
0
  mNewValue = aNewValue;
96
0
  mUrl = aURL;
97
0
  mStorageArea = aStorageArea;
98
0
}
99
100
} // namespace dom
101
} // namespace mozilla