tor-browser

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

nsDOMStringMap.h (2134B)


      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 nsDOMStringMap_h
      8 #define nsDOMStringMap_h
      9 
     10 #include "js/RootingAPI.h"       // JS::Handle
     11 #include "js/friend/DOMProxy.h"  // JS::ExpandoAndGeneration
     12 #include "nsCycleCollectionParticipant.h"
     13 #include "nsString.h"
     14 #include "nsStubMutationObserver.h"
     15 #include "nsTArray.h"
     16 #include "nsWrapperCache.h"
     17 
     18 // XXX Avoid including this here by moving function bodies to the cpp file
     19 #include "mozilla/dom/Element.h"
     20 
     21 namespace mozilla {
     22 class ErrorResult;
     23 namespace dom {
     24 class DOMString;
     25 class DocGroup;
     26 }  // namespace dom
     27 }  // namespace mozilla
     28 
     29 class nsDOMStringMap : public nsStubMutationObserver, public nsWrapperCache {
     30 public:
     31  NS_DECL_CYCLE_COLLECTING_ISUPPORTS
     32  NS_DECL_CYCLE_COLLECTION_WRAPPERCACHE_CLASS(nsDOMStringMap)
     33 
     34  NS_DECL_NSIMUTATIONOBSERVER_ATTRIBUTECHANGED
     35 
     36  nsINode* GetParentObject() { return mElement; }
     37 
     38  mozilla::dom::DocGroup* GetDocGroup() const;
     39 
     40  explicit nsDOMStringMap(mozilla::dom::Element* aElement);
     41 
     42  // WebIDL API
     43  virtual JSObject* WrapObject(JSContext* cx,
     44                               JS::Handle<JSObject*> aGivenProto) override;
     45  void NamedGetter(const nsAString& aProp, bool& found,
     46                   mozilla::dom::DOMString& aResult) const;
     47  void NamedSetter(const nsAString& aProp, const nsAString& aValue,
     48                   mozilla::ErrorResult& rv);
     49  void NamedDeleter(const nsAString& aProp, bool& found);
     50  void GetSupportedNames(nsTArray<nsString>& aNames);
     51 
     52  JS::ExpandoAndGeneration mExpandoAndGeneration;
     53 
     54 private:
     55  virtual ~nsDOMStringMap();
     56 
     57 protected:
     58  RefPtr<mozilla::dom::Element> mElement;
     59  // Flag to guard against infinite recursion.
     60  bool mRemovingProp;
     61  static bool DataPropToAttr(const nsAString& aProp, nsAutoString& aResult);
     62  static bool AttrToDataProp(const nsAString& aAttr, nsAutoString& aResult);
     63 };
     64 
     65 #endif