tor-browser

The Tor Browser
git clone https://git.dasho.dev/tor-browser.git
Log | Files | Refs | README | LICENSE

TestInterfaceSetlikeNode.cpp (1832B)


      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/. */
      6 
      7 #include "mozilla/dom/TestInterfaceSetlikeNode.h"
      8 
      9 #include "mozilla/dom/BindingUtils.h"
     10 #include "mozilla/dom/TestInterfaceJSMaplikeSetlikeIterableBinding.h"
     11 #include "nsPIDOMWindow.h"
     12 
     13 namespace mozilla::dom {
     14 
     15 NS_IMPL_CYCLE_COLLECTION_WRAPPERCACHE(TestInterfaceSetlikeNode, mParent)
     16 
     17 NS_IMPL_CYCLE_COLLECTING_ADDREF(TestInterfaceSetlikeNode)
     18 NS_IMPL_CYCLE_COLLECTING_RELEASE(TestInterfaceSetlikeNode)
     19 
     20 NS_INTERFACE_MAP_BEGIN_CYCLE_COLLECTION(TestInterfaceSetlikeNode)
     21  NS_WRAPPERCACHE_INTERFACE_MAP_ENTRY
     22  NS_INTERFACE_MAP_ENTRY(nsISupports)
     23 NS_INTERFACE_MAP_END
     24 
     25 TestInterfaceSetlikeNode::TestInterfaceSetlikeNode(JSContext* aCx,
     26                                                   nsPIDOMWindowInner* aParent)
     27    : mParent(aParent) {}
     28 
     29 // static
     30 already_AddRefed<TestInterfaceSetlikeNode>
     31 TestInterfaceSetlikeNode::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;
     38  }
     39 
     40  RefPtr<TestInterfaceSetlikeNode> r =
     41      new TestInterfaceSetlikeNode(nullptr, window);
     42  return r.forget();
     43 }
     44 
     45 JSObject* TestInterfaceSetlikeNode::WrapObject(
     46    JSContext* aCx, JS::Handle<JSObject*> aGivenProto) {
     47  return TestInterfaceSetlikeNode_Binding::Wrap(aCx, this, aGivenProto);
     48 }
     49 
     50 nsPIDOMWindowInner* TestInterfaceSetlikeNode::GetParentObject() const {
     51  return mParent;
     52 }
     53 
     54 }  // namespace mozilla::dom