/src/mozilla-central/dom/animation/AnimationUtils.h
Line | Count | Source (jump to first uncovered line) |
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/. */ |
6 | | |
7 | | #ifndef mozilla_dom_AnimationUtils_h |
8 | | #define mozilla_dom_AnimationUtils_h |
9 | | |
10 | | #include "mozilla/TimeStamp.h" |
11 | | #include "mozilla/dom/BindingDeclarations.h" |
12 | | #include "mozilla/dom/Nullable.h" |
13 | | #include "nsRFPService.h" |
14 | | #include "nsStringFwd.h" |
15 | | |
16 | | class nsIContent; |
17 | | class nsIDocument; |
18 | | class nsIFrame; |
19 | | struct JSContext; |
20 | | |
21 | | namespace mozilla { |
22 | | |
23 | | class ComputedTimingFunction; |
24 | | class EffectSet; |
25 | | |
26 | | class AnimationUtils |
27 | | { |
28 | | public: |
29 | | static dom::Nullable<double> |
30 | | TimeDurationToDouble(const dom::Nullable<TimeDuration>& aTime) |
31 | 0 | { |
32 | 0 | dom::Nullable<double> result; |
33 | 0 |
|
34 | 0 | if (!aTime.IsNull()) { |
35 | 0 | // 0 is an inappropriate mixin for this this area; however CSS Animations needs to |
36 | 0 | // have it's Time Reduction Logic refactored, so it's currently only clamping for |
37 | 0 | // RFP mode. RFP mode gives a much lower time precision, so we accept the security |
38 | 0 | // leak here for now |
39 | 0 | result.SetValue( |
40 | 0 | nsRFPService::ReduceTimePrecisionAsMSecs(aTime.Value().ToMilliseconds(), 0, TimerPrecisionType::RFPOnly) |
41 | 0 | ); |
42 | 0 | } |
43 | 0 |
|
44 | 0 | return result; |
45 | 0 | } |
46 | | |
47 | | static dom::Nullable<TimeDuration> |
48 | | DoubleToTimeDuration(const dom::Nullable<double>& aTime) |
49 | 0 | { |
50 | 0 | dom::Nullable<TimeDuration> result; |
51 | 0 |
|
52 | 0 | if (!aTime.IsNull()) { |
53 | 0 | result.SetValue(TimeDuration::FromMilliseconds(aTime.Value())); |
54 | 0 | } |
55 | 0 |
|
56 | 0 | return result; |
57 | 0 | } |
58 | | |
59 | | static void LogAsyncAnimationFailure(nsCString& aMessage, |
60 | | const nsIContent* aContent = nullptr); |
61 | | |
62 | | /** |
63 | | * Get the document from the JS context to use when parsing CSS properties. |
64 | | */ |
65 | | static nsIDocument* |
66 | | GetCurrentRealmDocument(JSContext* aCx); |
67 | | |
68 | | /** |
69 | | * Get the document from the global object, or nullptr if the document has |
70 | | * no window, to use when constructing DOM object without entering the |
71 | | * target window's compartment (see KeyframeEffect constructor). |
72 | | */ |
73 | | static nsIDocument* |
74 | | GetDocumentFromGlobal(JSObject* aGlobalObject); |
75 | | |
76 | | /** |
77 | | * Checks if offscreen animation throttling is enabled. |
78 | | */ |
79 | | static bool |
80 | | IsOffscreenThrottlingEnabled(); |
81 | | |
82 | | /** |
83 | | * Returns true if the given EffectSet contains a current effect that animates |
84 | | * scale. |aFrame| is used for calculation of scale values. |
85 | | */ |
86 | | static bool EffectSetContainsAnimatedScale(EffectSet& aEffects, |
87 | | const nsIFrame* aFrame); |
88 | | }; |
89 | | |
90 | | } // namespace mozilla |
91 | | |
92 | | #endif |