Backed out 2 changesets (bug 1539720) for causing caret related failures. CLOSED...
[gecko.git] / dom / animation / AnimationPerformanceWarning.cpp
blobe57beff51f5b96d12f4eb712174a0d78f95a2030
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::TransformBackfaceVisibilityHidden:
45 key = "CompositorAnimationWarningTransformBackfaceVisibilityHidden";
46 break;
47 case Type::TransformSVG:
48 key = "CompositorAnimationWarningTransformSVG";
49 break;
50 case Type::TransformWithGeometricProperties:
51 key = "CompositorAnimationWarningTransformWithGeometricProperties";
52 break;
53 case Type::TransformWithSyncGeometricAnimations:
54 key = "CompositorAnimationWarningTransformWithSyncGeometricAnimations";
55 break;
56 case Type::TransformFrameInactive:
57 key = "CompositorAnimationWarningTransformFrameInactive";
58 break;
59 case Type::TransformIsBlockedByImportantRules:
60 key = "CompositorAnimationWarningTransformIsBlockedByImportantRules";
61 break;
62 case Type::OpacityFrameInactive:
63 key = "CompositorAnimationWarningOpacityFrameInactive";
64 break;
65 case Type::HasRenderingObserver:
66 key = "CompositorAnimationWarningHasRenderingObserver";
67 break;
68 case Type::HasCurrentColor:
69 key = "CompositorAnimationWarningHasCurrentColor";
70 break;
71 case Type::None:
72 MOZ_ASSERT_UNREACHABLE("Uninitialized type shouldn't be used");
73 return false;
76 nsresult rv = nsContentUtils::GetLocalizedString(
77 nsContentUtils::eLAYOUT_PROPERTIES, key, aLocalizedString);
78 return NS_SUCCEEDED(rv);
81 } // namespace mozilla