Backed out 8 changesets (bug 1873776) for causing vendor failures. CLOSED TREE
[gecko.git] / dom / animation / AnimationPerformanceWarning.h
blobe59eade9e64c15821954388c1e1fc1478d500ca9
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_AnimationPerformanceWarning_h
8 #define mozilla_dom_AnimationPerformanceWarning_h
10 #include <initializer_list>
12 #include "mozilla/Maybe.h"
13 #include "nsStringFwd.h"
14 #include "nsTArray.h"
16 namespace mozilla {
18 // Represents the reason why we can't run the CSS property on the compositor.
19 struct AnimationPerformanceWarning {
20 enum class Type : uint8_t {
21 None,
22 ContentTooLarge,
23 ContentTooLargeArea,
24 TransformBackfaceVisibilityHidden,
25 TransformSVG,
26 TransformWithGeometricProperties,
27 TransformWithSyncGeometricAnimations,
28 TransformFrameInactive,
29 TransformIsBlockedByImportantRules,
30 OpacityFrameInactive,
31 HasRenderingObserver,
32 HasCurrentColor,
35 explicit AnimationPerformanceWarning(Type aType) : mType(aType) {
36 MOZ_ASSERT(mType != Type::None);
39 AnimationPerformanceWarning(Type aType,
40 std::initializer_list<int32_t> aParams)
41 : mType(aType) {
42 MOZ_ASSERT(mType != Type::None);
43 // FIXME: Once std::initializer_list::size() become a constexpr function,
44 // we should use static_assert here.
45 MOZ_ASSERT(aParams.size() <= kMaxParamsForLocalization,
46 "The length of parameters should be less than "
47 "kMaxParamsForLocalization");
48 mParams.emplace(aParams);
51 // Maximum number of parameters passed to
52 // nsContentUtils::FormatLocalizedString to localize warning messages.
54 // NOTE: This constexpr can't be forward declared, so if you want to use
55 // this variable, please include this header file directly.
56 // This value is the same as the limit of nsStringBundle::FormatString.
57 // See the implementation of nsStringBundle::FormatString.
58 static constexpr uint8_t kMaxParamsForLocalization = 10;
60 // Indicates why this property could not be animated on the compositor.
61 Type mType;
63 // Optional parameters that may be used for localization.
64 Maybe<CopyableTArray<int32_t>> mParams;
66 bool ToLocalizedString(nsAString& aLocalizedString) const;
67 template <uint32_t N>
68 nsresult ToLocalizedStringWithIntParams(const char* aKey,
69 nsAString& aLocalizedString) const;
71 bool operator==(const AnimationPerformanceWarning& aOther) const {
72 return mType == aOther.mType && mParams == aOther.mParams;
74 bool operator!=(const AnimationPerformanceWarning& aOther) const {
75 return !(*this == aOther);
79 } // namespace mozilla
81 #endif // mozilla_dom_AnimationPerformanceWarning_h