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 mozilla_AnimValuesStyleRule_h
8 : #define mozilla_AnimValuesStyleRule_h
9 :
10 : #include "mozilla/StyleAnimationValue.h"
11 : #include "nsCSSPropertyID.h"
12 : #include "nsCSSPropertyIDSet.h"
13 : #include "nsDataHashtable.h"
14 : #include "nsHashKeys.h" // For nsUint32HashKey
15 : #include "nsIStyleRule.h"
16 : #include "nsISupportsImpl.h" // For NS_DECL_ISUPPORTS
17 : #include "nsRuleNode.h" // For nsCachedStyleData
18 : #include "nsTArray.h" // For nsTArray
19 :
20 : namespace mozilla {
21 :
22 : /**
23 : * A style rule that maps property-StyleAnimationValue pairs.
24 : */
25 : class AnimValuesStyleRule final : public nsIStyleRule
26 : {
27 : public:
28 8 : AnimValuesStyleRule()
29 8 : : mStyleBits(0) {}
30 :
31 : // nsISupports implementation
32 : NS_DECL_ISUPPORTS
33 :
34 : // nsIStyleRule implementation
35 : void MapRuleInfoInto(nsRuleData* aRuleData) override;
36 : bool MightMapInheritedStyleData() override;
37 : bool GetDiscretelyAnimatedCSSValue(nsCSSPropertyID aProperty,
38 : nsCSSValue* aValue) override;
39 : #ifdef DEBUG
40 : void List(FILE* out = stdout, int32_t aIndent = 0) const override;
41 : #endif
42 :
43 : // For the following functions, it there is already a value for |aProperty| it
44 : // will be replaced with |aValue|.
45 : void AddValue(nsCSSPropertyID aProperty, const StyleAnimationValue &aValue);
46 : void AddValue(nsCSSPropertyID aProperty, StyleAnimationValue&& aValue);
47 :
48 0 : bool HasValue(nsCSSPropertyID aProperty) const {
49 0 : return mAnimationValues.Contains(aProperty);
50 : }
51 : bool GetValue(nsCSSPropertyID aProperty, StyleAnimationValue& aValue) const;
52 :
53 : private:
54 4 : ~AnimValuesStyleRule() {}
55 :
56 : nsDataHashtable<nsUint32HashKey, StyleAnimationValue> mAnimationValues;
57 :
58 : uint32_t mStyleBits;
59 : };
60 :
61 : } // namespace mozilla
62 :
63 : #endif // mozilla_AnimValuesStyleRule_h
|