Bug 1910248 - Remove nsIFrame::LayerIsPrerenderedDataKey r=layout-reviewers,TYLin
[gecko.git] / dom / animation / AnimationPerformanceWarning.cpp
blob25ee1b529cc755c2b45df54bcafee975fd314dd0
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"
11 namespace mozilla {
13 template <uint32_t N>
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;
31 switch (mType) {
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::TransformSVG:
45 key = "CompositorAnimationWarningTransformSVG";
46 break;
47 case Type::TransformFrameInactive:
48 key = "CompositorAnimationWarningTransformFrameInactive";
49 break;
50 case Type::TransformIsBlockedByImportantRules:
51 key = "CompositorAnimationWarningTransformIsBlockedByImportantRules";
52 break;
53 case Type::OpacityFrameInactive:
54 key = "CompositorAnimationWarningOpacityFrameInactive";
55 break;
56 case Type::HasRenderingObserver:
57 key = "CompositorAnimationWarningHasRenderingObserver";
58 break;
59 case Type::HasCurrentColor:
60 key = "CompositorAnimationWarningHasCurrentColor";
61 break;
62 case Type::None:
63 MOZ_ASSERT_UNREACHABLE("Uninitialized type shouldn't be used");
64 return false;
67 nsresult rv = nsContentUtils::GetLocalizedString(
68 nsContentUtils::eLAYOUT_PROPERTIES, key, aLocalizedString);
69 return NS_SUCCEEDED(rv);
72 } // namespace mozilla