/work/obj-fuzz/dist/include/mozilla/AnimationPerformanceWarning.h
Line | Count | Source (jump to first uncovered line) |
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_AnimationPerformanceWarning_h |
8 | | #define mozilla_dom_AnimationPerformanceWarning_h |
9 | | |
10 | | #include <initializer_list> |
11 | | |
12 | | #include "mozilla/Maybe.h" |
13 | | #include "nsStringFwd.h" |
14 | | #include "nsTArray.h" |
15 | | |
16 | | namespace mozilla { |
17 | | |
18 | | // Represents the reason why we can't run the CSS property on the compositor. |
19 | | struct AnimationPerformanceWarning |
20 | | { |
21 | | enum class Type : uint8_t { |
22 | | ContentTooLarge, |
23 | | ContentTooLargeArea, |
24 | | TransformBackfaceVisibilityHidden, |
25 | | TransformPreserve3D, |
26 | | TransformSVG, |
27 | | TransformWithGeometricProperties, |
28 | | TransformWithSyncGeometricAnimations, |
29 | | TransformFrameInactive, |
30 | | OpacityFrameInactive, |
31 | | HasRenderingObserver, |
32 | | }; |
33 | | |
34 | | explicit AnimationPerformanceWarning(Type aType) |
35 | | : mType(aType) { } |
36 | | |
37 | | AnimationPerformanceWarning(Type aType, |
38 | | std::initializer_list<int32_t> aParams) |
39 | | : mType(aType) |
40 | 0 | { |
41 | 0 | // FIXME: Once std::initializer_list::size() become a constexpr function, |
42 | 0 | // we should use static_assert here. |
43 | 0 | MOZ_ASSERT(aParams.size() <= kMaxParamsForLocalization, |
44 | 0 | "The length of parameters should be less than " |
45 | 0 | "kMaxParamsForLocalization"); |
46 | 0 | mParams.emplace(aParams); |
47 | 0 | } |
48 | | |
49 | | // Maximum number of parameters passed to |
50 | | // nsContentUtils::FormatLocalizedString to localize warning messages. |
51 | | // |
52 | | // NOTE: This constexpr can't be forward declared, so if you want to use |
53 | | // this variable, please include this header file directly. |
54 | | // This value is the same as the limit of nsStringBundle::FormatString. |
55 | | // See the implementation of nsStringBundle::FormatString. |
56 | | static constexpr uint8_t kMaxParamsForLocalization = 10; |
57 | | |
58 | | // Indicates why this property could not be animated on the compositor. |
59 | | Type mType; |
60 | | |
61 | | // Optional parameters that may be used for localization. |
62 | | Maybe<nsTArray<int32_t>> mParams; |
63 | | |
64 | | bool ToLocalizedString(nsAString& aLocalizedString) const; |
65 | | template<uint32_t N> |
66 | | nsresult ToLocalizedStringWithIntParams( |
67 | | const char* aKey, nsAString& aLocalizedString) const; |
68 | | |
69 | | bool operator==(const AnimationPerformanceWarning& aOther) const |
70 | | { |
71 | | return mType == aOther.mType && |
72 | | mParams == aOther.mParams; |
73 | | } |
74 | | bool operator!=(const AnimationPerformanceWarning& aOther) const |
75 | | { |
76 | | return !(*this == aOther); |
77 | | } |
78 | | }; |
79 | | |
80 | | } // namespace mozilla |
81 | | |
82 | | #endif // mozilla_dom_AnimationPerformanceWarning_h |