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/. */
7 #ifndef mozilla_dom_CustomStateSet_h
8 #define mozilla_dom_CustomStateSet_h
10 #include "js/TypeDecls.h"
11 #include "mozilla/ErrorResult.h"
13 #include "nsCycleCollectionParticipant.h"
14 #include "nsWrapperCache.h"
17 namespace mozilla::dom
{
22 class CustomStateSet final
: public nsISupports
, public nsWrapperCache
{
24 NS_DECL_CYCLE_COLLECTING_ISUPPORTS
25 NS_DECL_CYCLE_COLLECTION_WRAPPERCACHE_CLASS(CustomStateSet
)
27 explicit CustomStateSet(HTMLElement
* aTarget
);
30 nsISupports
* GetParentObject() const;
32 JSObject
* WrapObject(JSContext
* aCx
,
33 JS::Handle
<JSObject
*> aGivenProto
) override
;
35 static MOZ_CAN_RUN_SCRIPT_BOUNDARY already_AddRefed
<CustomStateSet
>
36 Constructor(const GlobalObject
& aGlobal
, ErrorResult
& aRv
);
38 void InvalidateStyleFromCustomStateSetChange() const;
40 MOZ_CAN_RUN_SCRIPT
void Clear(ErrorResult
& aRv
);
43 * @brief Removes a given string from the state set.
45 MOZ_CAN_RUN_SCRIPT
bool Delete(const nsAString
& aState
, ErrorResult
& aRv
);
48 * @brief Adds a string to this state set.
50 MOZ_CAN_RUN_SCRIPT
void Add(const nsAString
& aState
, ErrorResult
& aRv
);
53 virtual ~CustomStateSet() = default;
55 RefPtr
<HTMLElement
> mTarget
;
58 } // namespace mozilla::dom
60 #endif // mozilla_dom_CustomStateSet_h