2016-03-04 11:54:25 +03:00
|
|
|
/* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
|
|
|
|
/* vim: set ts=8 sts=2 et sw=2 tw=80: */
|
|
|
|
/* This Source Code Form is subject to the terms of the Mozilla Public
|
|
|
|
* License, v. 2.0. If a copy of the MPL was not distributed with this
|
|
|
|
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
|
|
|
|
|
|
|
|
#include "AnimationPerformanceWarning.h"
|
|
|
|
|
|
|
|
#include "nsContentUtils.h"
|
|
|
|
|
|
|
|
namespace mozilla {
|
|
|
|
|
2016-05-07 11:37:57 +03:00
|
|
|
template <uint32_t N>
|
|
|
|
nsresult AnimationPerformanceWarning::ToLocalizedStringWithIntParams(
|
2017-08-04 07:40:52 +03:00
|
|
|
const char* aKey, nsAString& aLocalizedString) const {
|
2016-05-07 11:37:57 +03:00
|
|
|
nsAutoString strings[N];
|
|
|
|
const char16_t* charParams[N];
|
|
|
|
|
|
|
|
for (size_t i = 0, n = mParams->Length(); i < n; i++) {
|
|
|
|
strings[i].AppendInt((*mParams)[i]);
|
|
|
|
charParams[i] = strings[i].get();
|
|
|
|
}
|
|
|
|
|
|
|
|
return nsContentUtils::FormatLocalizedString(
|
|
|
|
nsContentUtils::eLAYOUT_PROPERTIES, aKey, charParams, aLocalizedString);
|
|
|
|
}
|
|
|
|
|
2016-03-04 11:54:25 +03:00
|
|
|
bool AnimationPerformanceWarning::ToLocalizedString(
|
2017-08-04 07:40:52 +03:00
|
|
|
nsAString& aLocalizedString) const {
|
2016-03-04 11:54:25 +03:00
|
|
|
const char* key = nullptr;
|
|
|
|
|
|
|
|
switch (mType) {
|
|
|
|
case Type::ContentTooLarge:
|
2016-12-10 04:23:42 +03:00
|
|
|
MOZ_ASSERT(mParams && mParams->Length() == 6,
|
2017-06-06 00:01:19 +03:00
|
|
|
"Parameter's length should be 6 for ContentTooLarge2");
|
2016-03-04 11:54:25 +03:00
|
|
|
|
2016-05-19 07:06:27 +03:00
|
|
|
return NS_SUCCEEDED(ToLocalizedStringWithIntParams<7>(
|
2017-05-20 00:01:47 +03:00
|
|
|
"CompositorAnimationWarningContentTooLarge2", aLocalizedString));
|
2017-06-06 00:01:19 +03:00
|
|
|
case Type::ContentTooLargeArea:
|
|
|
|
MOZ_ASSERT(mParams && mParams->Length() == 2,
|
|
|
|
"Parameter's length should be 2 for ContentTooLargeArea");
|
|
|
|
|
|
|
|
return NS_SUCCEEDED(ToLocalizedStringWithIntParams<3>(
|
|
|
|
"CompositorAnimationWarningContentTooLargeArea", aLocalizedString));
|
2016-03-04 11:54:25 +03:00
|
|
|
case Type::TransformBackfaceVisibilityHidden:
|
2016-05-19 07:06:27 +03:00
|
|
|
key = "CompositorAnimationWarningTransformBackfaceVisibilityHidden";
|
2016-03-04 11:54:25 +03:00
|
|
|
break;
|
|
|
|
case Type::TransformPreserve3D:
|
2016-05-19 07:06:27 +03:00
|
|
|
key = "CompositorAnimationWarningTransformPreserve3D";
|
2016-03-04 11:54:25 +03:00
|
|
|
break;
|
|
|
|
case Type::TransformSVG:
|
2016-05-19 07:06:27 +03:00
|
|
|
key = "CompositorAnimationWarningTransformSVG";
|
2016-03-04 11:54:25 +03:00
|
|
|
break;
|
2016-03-14 03:07:48 +03:00
|
|
|
case Type::TransformWithGeometricProperties:
|
2016-05-19 07:06:27 +03:00
|
|
|
key = "CompositorAnimationWarningTransformWithGeometricProperties";
|
2016-03-14 03:07:48 +03:00
|
|
|
break;
|
2016-12-02 04:00:51 +03:00
|
|
|
case Type::TransformWithSyncGeometricAnimations:
|
|
|
|
key = "CompositorAnimationWarningTransformWithSyncGeometricAnimations";
|
|
|
|
break;
|
2016-03-04 11:54:25 +03:00
|
|
|
case Type::TransformFrameInactive:
|
2016-05-19 07:06:27 +03:00
|
|
|
key = "CompositorAnimationWarningTransformFrameInactive";
|
2016-03-04 11:54:25 +03:00
|
|
|
break;
|
|
|
|
case Type::OpacityFrameInactive:
|
2016-05-19 07:06:27 +03:00
|
|
|
key = "CompositorAnimationWarningOpacityFrameInactive";
|
2016-03-04 11:54:25 +03:00
|
|
|
break;
|
2016-07-29 08:58:32 +03:00
|
|
|
case Type::HasRenderingObserver:
|
|
|
|
key = "CompositorAnimationWarningHasRenderingObserver";
|
|
|
|
break;
|
2018-11-22 07:00:42 +03:00
|
|
|
case Type::None:
|
|
|
|
MOZ_ASSERT_UNREACHABLE("Uninitialized type shouldn't be used");
|
|
|
|
return false;
|
2016-03-04 11:54:25 +03:00
|
|
|
}
|
|
|
|
|
|
|
|
nsresult rv = nsContentUtils::GetLocalizedString(
|
|
|
|
nsContentUtils::eLAYOUT_PROPERTIES, key, aLocalizedString);
|
|
|
|
return NS_SUCCEEDED(rv);
|
|
|
|
}
|
|
|
|
|
|
|
|
} // namespace mozilla
|