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/. */
|
|
|
|
|
|
|
|
#ifndef mozilla_dom_AnimationPerformanceWarning_h
|
|
|
|
#define mozilla_dom_AnimationPerformanceWarning_h
|
|
|
|
|
2016-10-19 07:33:14 +03:00
|
|
|
#include <initializer_list>
|
2016-03-04 11:54:25 +03:00
|
|
|
|
2016-12-02 04:13:06 +03:00
|
|
|
#include "mozilla/Maybe.h"
|
2017-08-17 02:48:52 +03:00
|
|
|
#include "nsStringFwd.h"
|
2016-12-02 04:13:06 +03:00
|
|
|
#include "nsTArray.h"
|
|
|
|
|
2016-03-04 11:54:25 +03:00
|
|
|
namespace mozilla {
|
|
|
|
|
|
|
|
// Represents the reason why we can't run the CSS property on the compositor.
|
|
|
|
struct AnimationPerformanceWarning
|
|
|
|
{
|
|
|
|
enum class Type : uint8_t {
|
|
|
|
ContentTooLarge,
|
2017-06-06 00:01:19 +03:00
|
|
|
ContentTooLargeArea,
|
2016-03-04 11:54:25 +03:00
|
|
|
TransformBackfaceVisibilityHidden,
|
|
|
|
TransformPreserve3D,
|
|
|
|
TransformSVG,
|
2016-03-14 03:07:48 +03:00
|
|
|
TransformWithGeometricProperties,
|
2016-12-02 04:00:51 +03:00
|
|
|
TransformWithSyncGeometricAnimations,
|
2016-03-04 11:54:25 +03:00
|
|
|
TransformFrameInactive,
|
|
|
|
OpacityFrameInactive,
|
2016-07-29 08:58:32 +03:00
|
|
|
HasRenderingObserver,
|
2016-03-04 11:54:25 +03:00
|
|
|
};
|
|
|
|
|
|
|
|
explicit AnimationPerformanceWarning(Type aType)
|
|
|
|
: mType(aType) { }
|
|
|
|
|
|
|
|
AnimationPerformanceWarning(Type aType,
|
|
|
|
std::initializer_list<int32_t> aParams)
|
|
|
|
: mType(aType)
|
|
|
|
{
|
|
|
|
// FIXME: Once std::initializer_list::size() become a constexpr function,
|
|
|
|
// we should use static_assert here.
|
|
|
|
MOZ_ASSERT(aParams.size() <= kMaxParamsForLocalization,
|
|
|
|
"The length of parameters should be less than "
|
|
|
|
"kMaxParamsForLocalization");
|
|
|
|
mParams.emplace(aParams);
|
|
|
|
}
|
|
|
|
|
|
|
|
// Maximum number of parameters passed to
|
|
|
|
// nsContentUtils::FormatLocalizedString to localize warning messages.
|
|
|
|
//
|
|
|
|
// NOTE: This constexpr can't be forward declared, so if you want to use
|
|
|
|
// this variable, please include this header file directly.
|
|
|
|
// This value is the same as the limit of nsStringBundle::FormatString.
|
|
|
|
// See the implementation of nsStringBundle::FormatString.
|
2016-07-09 00:39:53 +03:00
|
|
|
static constexpr uint8_t kMaxParamsForLocalization = 10;
|
2016-03-04 11:54:25 +03:00
|
|
|
|
|
|
|
// Indicates why this property could not be animated on the compositor.
|
|
|
|
Type mType;
|
|
|
|
|
|
|
|
// Optional parameters that may be used for localization.
|
|
|
|
Maybe<nsTArray<int32_t>> mParams;
|
|
|
|
|
2017-08-04 07:40:52 +03:00
|
|
|
bool ToLocalizedString(nsAString& aLocalizedString) const;
|
2016-05-07 11:37:57 +03:00
|
|
|
template<uint32_t N>
|
|
|
|
nsresult ToLocalizedStringWithIntParams(
|
2017-08-04 07:40:52 +03:00
|
|
|
const char* aKey, nsAString& aLocalizedString) const;
|
2016-03-04 11:54:25 +03:00
|
|
|
|
|
|
|
bool operator==(const AnimationPerformanceWarning& aOther) const
|
|
|
|
{
|
|
|
|
return mType == aOther.mType &&
|
|
|
|
mParams == aOther.mParams;
|
|
|
|
}
|
|
|
|
bool operator!=(const AnimationPerformanceWarning& aOther) const
|
|
|
|
{
|
|
|
|
return !(*this == aOther);
|
|
|
|
}
|
|
|
|
};
|
|
|
|
|
|
|
|
} // namespace mozilla
|
|
|
|
|
|
|
|
#endif // mozilla_dom_AnimationPerformanceWarning_h
|