Bug 1852740: add tests for the `fetchpriority` attribute in Link headers. r=necko...
[gecko.git] / dom / events / StorageEvent.cpp
blob6854400293ae28d8d6607cdce7a344314a3759f8
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/. */
7 #include "mozilla/dom/StorageEvent.h"
8 #include "mozilla/dom/Storage.h"
9 #include "mozilla/dom/StorageEventBinding.h"
11 namespace mozilla::dom {
13 NS_IMPL_CYCLE_COLLECTION_CLASS(StorageEvent)
15 NS_IMPL_ADDREF_INHERITED(StorageEvent, Event)
16 NS_IMPL_RELEASE_INHERITED(StorageEvent, Event)
18 NS_IMPL_CYCLE_COLLECTION_TRAVERSE_BEGIN_INHERITED(StorageEvent, Event)
19 NS_IMPL_CYCLE_COLLECTION_TRAVERSE(mStorageArea)
20 NS_IMPL_CYCLE_COLLECTION_TRAVERSE_END
22 NS_IMPL_CYCLE_COLLECTION_TRACE_BEGIN_INHERITED(StorageEvent, Event)
23 NS_IMPL_CYCLE_COLLECTION_TRACE_END
25 NS_IMPL_CYCLE_COLLECTION_UNLINK_BEGIN_INHERITED(StorageEvent, Event)
26 NS_IMPL_CYCLE_COLLECTION_UNLINK(mStorageArea)
27 NS_IMPL_CYCLE_COLLECTION_UNLINK_END
29 NS_INTERFACE_MAP_BEGIN_CYCLE_COLLECTION(StorageEvent)
30 NS_INTERFACE_MAP_END_INHERITING(Event)
32 StorageEvent::StorageEvent(EventTarget* aOwner)
33 : Event(aOwner, nullptr, nullptr) {}
35 StorageEvent::~StorageEvent() = default;
37 StorageEvent* StorageEvent::AsStorageEvent() { return this; }
39 JSObject* StorageEvent::WrapObjectInternal(JSContext* aCx,
40 JS::Handle<JSObject*> aGivenProto) {
41 return StorageEvent_Binding::Wrap(aCx, this, aGivenProto);
44 already_AddRefed<StorageEvent> StorageEvent::Constructor(
45 EventTarget* aOwner, const nsAString& aType,
46 const StorageEventInit& aEventInitDict) {
47 RefPtr<StorageEvent> e = new StorageEvent(aOwner);
49 bool trusted = e->Init(aOwner);
50 e->InitEvent(aType, aEventInitDict.mBubbles, aEventInitDict.mCancelable);
51 e->mKey = aEventInitDict.mKey;
52 e->mOldValue = aEventInitDict.mOldValue;
53 e->mNewValue = aEventInitDict.mNewValue;
54 e->mUrl = aEventInitDict.mUrl;
55 e->mStorageArea = aEventInitDict.mStorageArea;
56 e->SetTrusted(trusted);
57 e->SetComposed(aEventInitDict.mComposed);
58 return e.forget();
61 already_AddRefed<StorageEvent> StorageEvent::Constructor(
62 const GlobalObject& aGlobal, const nsAString& aType,
63 const StorageEventInit& aEventInitDict) {
64 nsCOMPtr<EventTarget> owner = do_QueryInterface(aGlobal.GetAsSupports());
65 return Constructor(owner, aType, aEventInitDict);
68 void StorageEvent::InitStorageEvent(const nsAString& aType, bool aCanBubble,
69 bool aCancelable, const nsAString& aKey,
70 const nsAString& aOldValue,
71 const nsAString& aNewValue,
72 const nsAString& aURL,
73 Storage* aStorageArea) {
74 NS_ENSURE_TRUE_VOID(!mEvent->mFlags.mIsBeingDispatched);
76 InitEvent(aType, aCanBubble, aCancelable);
77 mKey = aKey;
78 mOldValue = aOldValue;
79 mNewValue = aNewValue;
80 mUrl = aURL;
81 mStorageArea = aStorageArea;
84 } // namespace mozilla::dom