Bug 1885602 - Part 5: Implement navigating to the SUMO help topic from the menu heade...
[gecko.git] / dom / bindings / test / TestInterfaceMaplikeJSObject.cpp
blobe9fb50e4b60df7d9503db89e999cbd44cdb6bd64
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 file,
5 * You can obtain one at http://mozilla.org/MPL/2.0/. */
7 #include "mozilla/dom/TestInterfaceMaplikeJSObject.h"
8 #include "mozilla/dom/TestInterfaceMaplike.h"
9 #include "mozilla/dom/TestInterfaceJSMaplikeSetlikeIterableBinding.h"
10 #include "nsPIDOMWindow.h"
11 #include "mozilla/dom/BindingUtils.h"
13 namespace mozilla::dom {
15 NS_IMPL_CYCLE_COLLECTION_WRAPPERCACHE(TestInterfaceMaplikeJSObject, mParent)
17 NS_IMPL_CYCLE_COLLECTING_ADDREF(TestInterfaceMaplikeJSObject)
18 NS_IMPL_CYCLE_COLLECTING_RELEASE(TestInterfaceMaplikeJSObject)
20 NS_INTERFACE_MAP_BEGIN_CYCLE_COLLECTION(TestInterfaceMaplikeJSObject)
21 NS_WRAPPERCACHE_INTERFACE_MAP_ENTRY
22 NS_INTERFACE_MAP_ENTRY(nsISupports)
23 NS_INTERFACE_MAP_END
25 TestInterfaceMaplikeJSObject::TestInterfaceMaplikeJSObject(
26 nsPIDOMWindowInner* aParent)
27 : mParent(aParent) {}
29 // static
30 already_AddRefed<TestInterfaceMaplikeJSObject>
31 TestInterfaceMaplikeJSObject::Constructor(const GlobalObject& aGlobal,
32 ErrorResult& aRv) {
33 nsCOMPtr<nsPIDOMWindowInner> window =
34 do_QueryInterface(aGlobal.GetAsSupports());
35 if (!window) {
36 aRv.Throw(NS_ERROR_FAILURE);
37 return nullptr;
40 RefPtr<TestInterfaceMaplikeJSObject> r =
41 new TestInterfaceMaplikeJSObject(window);
42 return r.forget();
45 JSObject* TestInterfaceMaplikeJSObject::WrapObject(
46 JSContext* aCx, JS::Handle<JSObject*> aGivenProto) {
47 return TestInterfaceMaplikeJSObject_Binding::Wrap(aCx, this, aGivenProto);
50 nsPIDOMWindowInner* TestInterfaceMaplikeJSObject::GetParentObject() const {
51 return mParent;
54 void TestInterfaceMaplikeJSObject::SetInternal(JSContext* aCx,
55 const nsAString& aKey,
56 JS::Handle<JSObject*> aObject) {
57 ErrorResult rv;
58 TestInterfaceMaplikeJSObject_Binding::MaplikeHelpers::Set(this, aKey, aObject,
59 rv);
62 void TestInterfaceMaplikeJSObject::ClearInternal() {
63 ErrorResult rv;
64 TestInterfaceMaplikeJSObject_Binding::MaplikeHelpers::Clear(this, rv);
67 bool TestInterfaceMaplikeJSObject::DeleteInternal(const nsAString& aKey) {
68 ErrorResult rv;
69 return TestInterfaceMaplikeJSObject_Binding::MaplikeHelpers::Delete(this,
70 aKey, rv);
73 bool TestInterfaceMaplikeJSObject::HasInternal(const nsAString& aKey) {
74 ErrorResult rv;
75 return TestInterfaceMaplikeJSObject_Binding::MaplikeHelpers::Has(this, aKey,
76 rv);
79 void TestInterfaceMaplikeJSObject::GetInternal(
80 JSContext* aCx, const nsAString& aKey, JS::MutableHandle<JSObject*> aRetVal,
81 ErrorResult& aRv) {
82 TestInterfaceMaplikeJSObject_Binding::MaplikeHelpers::Get(this, aCx, aKey,
83 aRetVal, aRv);
85 } // namespace mozilla::dom