Bug 1885602 - Part 5: Implement navigating to the SUMO help topic from the menu heade...
[gecko.git] / dom / bindings / test / TestInterfaceMaplike.cpp
blobba8ccf7279b82201ef05e7da2d2f64cb325dfa6a
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/TestInterfaceMaplike.h"
8 #include "mozilla/dom/TestInterfaceJSMaplikeSetlikeIterableBinding.h"
9 #include "nsPIDOMWindow.h"
10 #include "mozilla/dom/BindingUtils.h"
12 namespace mozilla::dom {
14 NS_IMPL_CYCLE_COLLECTION_WRAPPERCACHE(TestInterfaceMaplike, mParent)
16 NS_IMPL_CYCLE_COLLECTING_ADDREF(TestInterfaceMaplike)
17 NS_IMPL_CYCLE_COLLECTING_RELEASE(TestInterfaceMaplike)
19 NS_INTERFACE_MAP_BEGIN_CYCLE_COLLECTION(TestInterfaceMaplike)
20 NS_WRAPPERCACHE_INTERFACE_MAP_ENTRY
21 NS_INTERFACE_MAP_ENTRY(nsISupports)
22 NS_INTERFACE_MAP_END
24 TestInterfaceMaplike::TestInterfaceMaplike(nsPIDOMWindowInner* aParent)
25 : mParent(aParent) {}
27 // static
28 already_AddRefed<TestInterfaceMaplike> TestInterfaceMaplike::Constructor(
29 const GlobalObject& aGlobal, ErrorResult& aRv) {
30 nsCOMPtr<nsPIDOMWindowInner> window =
31 do_QueryInterface(aGlobal.GetAsSupports());
32 if (!window) {
33 aRv.Throw(NS_ERROR_FAILURE);
34 return nullptr;
37 RefPtr<TestInterfaceMaplike> r = new TestInterfaceMaplike(window);
38 return r.forget();
41 JSObject* TestInterfaceMaplike::WrapObject(JSContext* aCx,
42 JS::Handle<JSObject*> aGivenProto) {
43 return TestInterfaceMaplike_Binding::Wrap(aCx, this, aGivenProto);
46 nsPIDOMWindowInner* TestInterfaceMaplike::GetParentObject() const {
47 return mParent;
50 void TestInterfaceMaplike::SetInternal(const nsAString& aKey, int32_t aValue) {
51 ErrorResult rv;
52 TestInterfaceMaplike_Binding::MaplikeHelpers::Set(this, aKey, aValue, rv);
55 void TestInterfaceMaplike::ClearInternal() {
56 ErrorResult rv;
57 TestInterfaceMaplike_Binding::MaplikeHelpers::Clear(this, rv);
60 bool TestInterfaceMaplike::DeleteInternal(const nsAString& aKey) {
61 ErrorResult rv;
62 return TestInterfaceMaplike_Binding::MaplikeHelpers::Delete(this, aKey, rv);
65 bool TestInterfaceMaplike::HasInternal(const nsAString& aKey) {
66 ErrorResult rv;
67 return TestInterfaceMaplike_Binding::MaplikeHelpers::Has(this, aKey, rv);
70 int32_t TestInterfaceMaplike::GetInternal(const nsAString& aKey,
71 ErrorResult& aRv) {
72 return TestInterfaceMaplike_Binding::MaplikeHelpers::Get(this, aKey, aRv);
74 } // namespace mozilla::dom