Line data Source code
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 "nsCycleCollectionParticipant.h"
11 : #include "nsTArray.h"
12 : #include "nsString.h"
13 : #include "nsWrapperCache.h"
14 : #include "mozilla/dom/Element.h"
15 : #include "jsfriendapi.h" // For js::ExpandoAndGeneration
16 :
17 : namespace mozilla {
18 : class ErrorResult;
19 : } // namespace mozilla
20 :
21 : class nsDOMStringMap : public nsStubMutationObserver,
22 : public nsWrapperCache
23 : {
24 : public:
25 : NS_DECL_CYCLE_COLLECTING_ISUPPORTS
26 0 : NS_DECL_CYCLE_COLLECTION_SCRIPT_HOLDER_CLASS(nsDOMStringMap)
27 :
28 : NS_DECL_NSIMUTATIONOBSERVER_ATTRIBUTECHANGED
29 :
30 0 : nsINode* GetParentObject()
31 : {
32 0 : return mElement;
33 : }
34 :
35 : explicit nsDOMStringMap(mozilla::dom::Element* aElement);
36 :
37 : // WebIDL API
38 : virtual JSObject* WrapObject(JSContext *cx, JS::Handle<JSObject*> aGivenProto) override;
39 : void NamedGetter(const nsAString& aProp, bool& found,
40 : mozilla::dom::DOMString& aResult) const;
41 : void NamedSetter(const nsAString& aProp, const nsAString& aValue,
42 : mozilla::ErrorResult& rv);
43 : void NamedDeleter(const nsAString& aProp, bool &found);
44 : void GetSupportedNames(nsTArray<nsString>& aNames);
45 :
46 : js::ExpandoAndGeneration mExpandoAndGeneration;
47 :
48 : private:
49 : virtual ~nsDOMStringMap();
50 :
51 : protected:
52 : RefPtr<mozilla::dom::Element> mElement;
53 : // Flag to guard against infinite recursion.
54 : bool mRemovingProp;
55 : static bool DataPropToAttr(const nsAString& aProp, nsAutoString& aResult);
56 : static bool AttrToDataProp(const nsAString& aAttr, nsAutoString& aResult);
57 : };
58 :
59 : #endif
|