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