2015-05-03 22:32:37 +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: */
|
2014-08-30 10:11:57 +04:00
|
|
|
/* 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/. */
|
|
|
|
|
2014-09-25 18:11:43 +04:00
|
|
|
#ifndef mozilla_dom_AnimationUtils_h
|
|
|
|
#define mozilla_dom_AnimationUtils_h
|
|
|
|
|
2014-08-30 10:11:57 +04:00
|
|
|
#include "mozilla/TimeStamp.h"
|
2016-12-07 12:47:23 +03:00
|
|
|
#include "mozilla/dom/BindingDeclarations.h"
|
2014-08-30 10:11:57 +04:00
|
|
|
#include "mozilla/dom/Nullable.h"
|
2015-12-04 02:32:53 +03:00
|
|
|
#include "nsStringFwd.h"
|
|
|
|
|
|
|
|
class nsIContent;
|
2016-03-11 11:20:17 +03:00
|
|
|
class nsIDocument;
|
|
|
|
struct JSContext;
|
2014-08-30 10:11:57 +04:00
|
|
|
|
|
|
|
namespace mozilla {
|
|
|
|
|
2016-01-27 04:08:00 +03:00
|
|
|
class ComputedTimingFunction;
|
|
|
|
|
2014-08-30 10:11:57 +04:00
|
|
|
class AnimationUtils
|
|
|
|
{
|
|
|
|
public:
|
2015-12-04 02:32:53 +03:00
|
|
|
static dom::Nullable<double>
|
2016-03-11 11:15:23 +03:00
|
|
|
TimeDurationToDouble(const dom::Nullable<TimeDuration>& aTime)
|
2014-08-30 10:11:57 +04:00
|
|
|
{
|
2015-12-04 02:32:53 +03:00
|
|
|
dom::Nullable<double> result;
|
2014-08-30 10:11:57 +04:00
|
|
|
|
|
|
|
if (!aTime.IsNull()) {
|
|
|
|
result.SetValue(aTime.Value().ToMilliseconds());
|
|
|
|
}
|
|
|
|
|
|
|
|
return result;
|
|
|
|
}
|
2015-02-09 13:25:51 +03:00
|
|
|
|
2015-12-04 02:32:53 +03:00
|
|
|
static dom::Nullable<TimeDuration>
|
2016-03-11 11:15:23 +03:00
|
|
|
DoubleToTimeDuration(const dom::Nullable<double>& aTime)
|
2015-02-09 13:25:51 +03:00
|
|
|
{
|
2015-12-04 02:32:53 +03:00
|
|
|
dom::Nullable<TimeDuration> result;
|
2015-02-09 13:25:51 +03:00
|
|
|
|
|
|
|
if (!aTime.IsNull()) {
|
|
|
|
result.SetValue(TimeDuration::FromMilliseconds(aTime.Value()));
|
|
|
|
}
|
|
|
|
|
|
|
|
return result;
|
|
|
|
}
|
2015-12-04 02:32:53 +03:00
|
|
|
|
|
|
|
static void LogAsyncAnimationFailure(nsCString& aMessage,
|
|
|
|
const nsIContent* aContent = nullptr);
|
2016-01-27 04:08:00 +03:00
|
|
|
|
2016-03-11 11:20:17 +03:00
|
|
|
/**
|
|
|
|
* Get the document from the JS context to use when parsing CSS properties.
|
|
|
|
*/
|
|
|
|
static nsIDocument*
|
|
|
|
GetCurrentRealmDocument(JSContext* aCx);
|
2016-05-24 06:57:43 +03:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Checks if offscreen animation throttling is enabled.
|
|
|
|
*/
|
|
|
|
static bool
|
|
|
|
IsOffscreenThrottlingEnabled();
|
2016-08-10 12:58:49 +03:00
|
|
|
|
2016-12-04 02:07:40 +03:00
|
|
|
/**
|
|
|
|
* Returns true if the preference to enable the core Web Animations API is
|
|
|
|
* true.
|
|
|
|
*/
|
|
|
|
static bool IsCoreAPIEnabled();
|
|
|
|
|
2016-08-10 12:58:49 +03:00
|
|
|
/**
|
|
|
|
* Returns true if the preference to enable the core Web Animations API is
|
2016-09-23 09:31:34 +03:00
|
|
|
* true or the caller is chrome.
|
2016-08-10 12:58:49 +03:00
|
|
|
*/
|
2016-12-07 12:47:23 +03:00
|
|
|
static bool IsCoreAPIEnabledForCaller(dom::CallerType aCallerType);
|
2014-08-30 10:11:57 +04:00
|
|
|
};
|
|
|
|
|
|
|
|
} // namespace mozilla
|
2014-09-25 18:11:43 +04:00
|
|
|
|
|
|
|
#endif
|