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 #include "AnimationPerformanceWarning.h"
9 #include "nsContentUtils.h"
14 nsresult
AnimationPerformanceWarning::ToLocalizedStringWithIntParams(
15 const char* aKey
, nsAString
& aLocalizedString
) const {
16 AutoTArray
<nsString
, N
> strings
;
18 MOZ_DIAGNOSTIC_ASSERT(mParams
->Length() == N
);
19 for (size_t i
= 0, n
= mParams
->Length(); i
< n
; i
++) {
20 strings
.AppendElement()->AppendInt((*mParams
)[i
]);
23 return nsContentUtils::FormatLocalizedString(
24 nsContentUtils::eLAYOUT_PROPERTIES
, aKey
, strings
, aLocalizedString
);
27 bool AnimationPerformanceWarning::ToLocalizedString(
28 nsAString
& aLocalizedString
) const {
29 const char* key
= nullptr;
32 case Type::ContentTooLarge
:
33 MOZ_ASSERT(mParams
&& mParams
->Length() == 6,
34 "Parameter's length should be 6 for ContentTooLarge2");
36 return NS_SUCCEEDED(ToLocalizedStringWithIntParams
<6>(
37 "CompositorAnimationWarningContentTooLarge2", aLocalizedString
));
38 case Type::ContentTooLargeArea
:
39 MOZ_ASSERT(mParams
&& mParams
->Length() == 2,
40 "Parameter's length should be 2 for ContentTooLargeArea");
42 return NS_SUCCEEDED(ToLocalizedStringWithIntParams
<2>(
43 "CompositorAnimationWarningContentTooLargeArea", aLocalizedString
));
44 case Type::TransformBackfaceVisibilityHidden
:
45 key
= "CompositorAnimationWarningTransformBackfaceVisibilityHidden";
47 case Type::TransformSVG
:
48 key
= "CompositorAnimationWarningTransformSVG";
50 case Type::TransformWithGeometricProperties
:
51 key
= "CompositorAnimationWarningTransformWithGeometricProperties";
53 case Type::TransformWithSyncGeometricAnimations
:
54 key
= "CompositorAnimationWarningTransformWithSyncGeometricAnimations";
56 case Type::TransformFrameInactive
:
57 key
= "CompositorAnimationWarningTransformFrameInactive";
59 case Type::TransformIsBlockedByImportantRules
:
60 key
= "CompositorAnimationWarningTransformIsBlockedByImportantRules";
62 case Type::OpacityFrameInactive
:
63 key
= "CompositorAnimationWarningOpacityFrameInactive";
65 case Type::HasRenderingObserver
:
66 key
= "CompositorAnimationWarningHasRenderingObserver";
68 case Type::HasCurrentColor
:
69 key
= "CompositorAnimationWarningHasCurrentColor";
72 MOZ_ASSERT_UNREACHABLE("Uninitialized type shouldn't be used");
76 nsresult rv
= nsContentUtils::GetLocalizedString(
77 nsContentUtils::eLAYOUT_PROPERTIES
, key
, aLocalizedString
);
78 return NS_SUCCEEDED(rv
);
81 } // namespace mozilla