CustomStateSet.h (1640B)
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_CustomStateSet_h 8 #define mozilla_dom_CustomStateSet_h 9 10 #include "js/TypeDecls.h" 11 #include "mozilla/ErrorResult.h" 12 #include "nsCOMPtr.h" 13 #include "nsCycleCollectionParticipant.h" 14 #include "nsWrapperCache.h" 15 16 namespace mozilla::dom { 17 18 class HTMLElement; 19 class GlobalObject; 20 21 class CustomStateSet final : public nsISupports, public nsWrapperCache { 22 public: 23 NS_DECL_CYCLE_COLLECTING_ISUPPORTS 24 NS_DECL_CYCLE_COLLECTION_WRAPPERCACHE_CLASS(CustomStateSet) 25 26 explicit CustomStateSet(HTMLElement* aTarget); 27 28 // WebIDL interface 29 nsISupports* GetParentObject() const; 30 31 JSObject* WrapObject(JSContext* aCx, 32 JS::Handle<JSObject*> aGivenProto) override; 33 34 static MOZ_CAN_RUN_SCRIPT_BOUNDARY already_AddRefed<CustomStateSet> 35 Constructor(const GlobalObject& aGlobal, ErrorResult& aRv); 36 37 MOZ_CAN_RUN_SCRIPT void Clear(ErrorResult& aRv); 38 39 /** 40 * @brief Removes a given string from the state set. 41 */ 42 MOZ_CAN_RUN_SCRIPT bool Delete(const nsAString& aState, ErrorResult& aRv); 43 44 /** 45 * @brief Adds a string to this state set. 46 */ 47 MOZ_CAN_RUN_SCRIPT void Add(const nsAString& aState, ErrorResult& aRv); 48 49 private: 50 virtual ~CustomStateSet() = default; 51 52 RefPtr<HTMLElement> mTarget; 53 }; 54 55 } // namespace mozilla::dom 56 57 #endif // mozilla_dom_CustomStateSet_h