tor-browser

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

TestInterfaceIterableDouble.h (1719B)


      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 #ifndef mozilla_dom_TestInterfaceIterableDouble_h
      8 #define mozilla_dom_TestInterfaceIterableDouble_h
      9 
     10 #include "nsCOMPtr.h"
     11 #include "nsString.h"
     12 #include "nsTArray.h"
     13 #include "nsWrapperCache.h"
     14 
     15 class nsPIDOMWindowInner;
     16 
     17 namespace mozilla {
     18 
     19 class ErrorResult;
     20 
     21 namespace dom {
     22 
     23 class GlobalObject;
     24 
     25 // Implementation of test binding for webidl iterable interfaces, using
     26 // primitives for value type
     27 class TestInterfaceIterableDouble final : public nsISupports,
     28                                          public nsWrapperCache {
     29 public:
     30  NS_DECL_CYCLE_COLLECTING_ISUPPORTS
     31  NS_DECL_CYCLE_COLLECTION_WRAPPERCACHE_CLASS(TestInterfaceIterableDouble)
     32 
     33  explicit TestInterfaceIterableDouble(nsPIDOMWindowInner* aParent);
     34  nsPIDOMWindowInner* GetParentObject() const;
     35  virtual JSObject* WrapObject(JSContext* aCx,
     36                               JS::Handle<JSObject*> aGivenProto) override;
     37  static already_AddRefed<TestInterfaceIterableDouble> Constructor(
     38      const GlobalObject& aGlobal, ErrorResult& rv);
     39 
     40  size_t GetIterableLength();
     41  nsAString& GetKeyAtIndex(uint32_t aIndex);
     42  nsAString& GetValueAtIndex(uint32_t aIndex);
     43 
     44 private:
     45  virtual ~TestInterfaceIterableDouble() = default;
     46  nsCOMPtr<nsPIDOMWindowInner> mParent;
     47  nsTArray<std::pair<nsString, nsString>> mValues;
     48 };
     49 
     50 }  // namespace dom
     51 }  // namespace mozilla
     52 
     53 #endif  // mozilla_dom_TestInterfaceIterableDouble_h