mirror of
https://github.com/mozilla/gecko-dev.git
synced 2024-11-24 21:31:04 +00:00
Bug 1196114 - Part 2: Add AnimationPropertyStatus interface and KeyframeEffectReadOnly.runningStatus(). r=birtles,smaug
MozReview-Commit-ID: CPz3DtWxKll --HG-- extra : rebase_source : 5a210456997789ace942e60c3688f9600df3281c
This commit is contained in:
parent
3534158709
commit
e3df4388fc
@ -1877,6 +1877,30 @@ KeyframeEffectReadOnly::GetFrames(JSContext*& aCx,
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
void
|
||||
KeyframeEffectReadOnly::GetPropertyState(
|
||||
nsTArray<AnimationPropertyState>& aStates) const
|
||||
{
|
||||
for (const AnimationProperty& property : mProperties) {
|
||||
// Bug 1252730: We should also expose this winsInCascade as well.
|
||||
if (!property.mWinsInCascade) {
|
||||
continue;
|
||||
}
|
||||
|
||||
AnimationPropertyState state;
|
||||
state.mProperty.Construct(
|
||||
NS_ConvertASCIItoUTF16(nsCSSProps::GetStringValue(property.mProperty)));
|
||||
state.mRunningOnCompositor.Construct(property.mIsRunningOnCompositor);
|
||||
|
||||
if (property.mPerformanceWarning.isSome()) {
|
||||
state.mWarning.Construct(property.mPerformanceWarning.value());
|
||||
}
|
||||
|
||||
aStates.AppendElement(state);
|
||||
}
|
||||
}
|
||||
|
||||
/* static */ const TimeDuration
|
||||
KeyframeEffectReadOnly::OverflowRegionRefreshInterval()
|
||||
{
|
||||
|
@ -43,6 +43,7 @@ class OwningElementOrCSSPseudoElement;
|
||||
class UnrestrictedDoubleOrKeyframeEffectOptions;
|
||||
enum class IterationCompositeOperation : uint32_t;
|
||||
enum class CompositeOperation : uint32_t;
|
||||
struct AnimationPropertyState;
|
||||
}
|
||||
|
||||
/**
|
||||
@ -307,6 +308,8 @@ public:
|
||||
bool IsRunningOnCompositor() const;
|
||||
void SetIsRunningOnCompositor(nsCSSProperty aProperty, bool aIsRunning);
|
||||
|
||||
void GetPropertyState(nsTArray<AnimationPropertyState>& aStates) const;
|
||||
|
||||
// Returns true if this effect, applied to |aFrame|, contains
|
||||
// properties that mean we shouldn't run *any* compositor animations on this
|
||||
// element.
|
||||
|
@ -7,6 +7,7 @@ support-files =
|
||||
# file_animate_xrays.html needs to go in mochitest.ini since it is served
|
||||
# over HTTP
|
||||
[chrome/test_animation_observers.html]
|
||||
[chrome/test_animation_property_state.html]
|
||||
[chrome/test_restyles.html]
|
||||
[chrome/test_running_on_compositor.html]
|
||||
skip-if = buildapp == 'b2g'
|
||||
|
127
dom/animation/test/chrome/test_animation_property_state.html
Normal file
127
dom/animation/test/chrome/test_animation_property_state.html
Normal file
@ -0,0 +1,127 @@
|
||||
<!doctype html>
|
||||
<head>
|
||||
<meta charset=utf-8>
|
||||
<title>Bug 1196114 - Animation property which indicates
|
||||
running on the compositor or not</title>
|
||||
<script type="application/javascript" src="../testharness.js"></script>
|
||||
<script type="application/javascript" src="../testharnessreport.js"></script>
|
||||
<script type="application/javascript" src="../testcommon.js"></script>
|
||||
<style>
|
||||
div {
|
||||
/* Element needs geometry to be eligible for layerization */
|
||||
width: 100px;
|
||||
height: 100px;
|
||||
background-color: white;
|
||||
}
|
||||
</style>
|
||||
</head>
|
||||
<body>
|
||||
<a href="https://bugzilla.mozilla.org/show_bug.cgi?id=1196114"
|
||||
target="_blank">Mozilla Bug 1196114</a>
|
||||
<div id="log"></div>
|
||||
<script>
|
||||
'use strict';
|
||||
|
||||
function compare_property_state(a, b) {
|
||||
if (a.property > b.property) {
|
||||
return -1;
|
||||
} else if (a.property < b.property) {
|
||||
return 1;
|
||||
}
|
||||
if (a.runningOnCompositor != b.runningOnCompositor) {
|
||||
return a.runningOnCompositor ? 1 : -1;
|
||||
}
|
||||
return a.warning > b.warning ? -1 : 1;
|
||||
}
|
||||
|
||||
function assert_animation_property_state_equals(actual, expected) {
|
||||
assert_equals(actual.length, expected.length);
|
||||
|
||||
var sortedActual = actual.sort(compare_property_state);
|
||||
var sortedExpected = expected.sort(compare_property_state);
|
||||
|
||||
for (var i = 0; i < sortedActual.length; i++) {
|
||||
assert_equals(sortedActual[i].property,
|
||||
sortedExpected[i].property,
|
||||
'CSS property name should match');
|
||||
assert_equals(sortedActual[i].runningOnCompositor,
|
||||
sortedExpected[i].runningOnCompositor,
|
||||
'runningOnCompositor property should match');
|
||||
}
|
||||
}
|
||||
|
||||
var gAnimationsTests = [
|
||||
{
|
||||
desc: 'animations on compositor',
|
||||
frames: {
|
||||
opacity: [0, 1]
|
||||
},
|
||||
expected: [
|
||||
{
|
||||
property: 'opacity',
|
||||
runningOnCompositor: true
|
||||
}
|
||||
]
|
||||
},
|
||||
{
|
||||
desc: 'animations on main thread',
|
||||
frames: {
|
||||
backgroundColor: ['white', 'red']
|
||||
},
|
||||
expected: [
|
||||
{
|
||||
property: 'background-color',
|
||||
runningOnCompositor: false
|
||||
}
|
||||
]
|
||||
},
|
||||
{
|
||||
desc: 'animations on both threads',
|
||||
frames: {
|
||||
backgroundColor: ['white', 'red'],
|
||||
transform: ['translate(0px)', 'translate(100px)']
|
||||
},
|
||||
expected: [
|
||||
{
|
||||
property: 'background-color',
|
||||
runningOnCompositor: false
|
||||
},
|
||||
{
|
||||
property: 'transform',
|
||||
runningOnCompositor: true
|
||||
}
|
||||
]
|
||||
},
|
||||
{
|
||||
desc: 'two animation properties on compositor thread',
|
||||
frames: {
|
||||
opacity: [0, 1],
|
||||
transform: ['translate(0px)', 'translate(100px)']
|
||||
},
|
||||
expected: [
|
||||
{
|
||||
property: 'opacity',
|
||||
runningOnCompositor: true
|
||||
},
|
||||
{
|
||||
property: 'transform',
|
||||
runningOnCompositor: true
|
||||
}
|
||||
]
|
||||
}
|
||||
];
|
||||
|
||||
gAnimationsTests.forEach(function(subtest) {
|
||||
promise_test(function(t) {
|
||||
var div = addDiv(t);
|
||||
var animation = div.animate(subtest.frames, 100000);
|
||||
return animation.ready.then(t.step_func(function() {
|
||||
assert_animation_property_state_equals(
|
||||
animation.effect.getPropertyState(),
|
||||
subtest.expected);
|
||||
}));
|
||||
}, subtest.desc);
|
||||
});
|
||||
|
||||
</script>
|
||||
</body>
|
@ -45,6 +45,16 @@ interface KeyframeEffectReadOnly : AnimationEffectReadOnly {
|
||||
[Throws] sequence<object> getFrames();
|
||||
};
|
||||
|
||||
// Non-standard extensions
|
||||
dictionary AnimationPropertyState {
|
||||
DOMString property;
|
||||
boolean runningOnCompositor;
|
||||
DOMString? warning;
|
||||
};
|
||||
|
||||
partial interface KeyframeEffectReadOnly {
|
||||
[ChromeOnly] sequence<AnimationPropertyState> getPropertyState();
|
||||
};
|
||||
|
||||
[Func="nsDocument::IsWebAnimationsEnabled",
|
||||
Constructor ((Element or CSSPseudoElement)? target,
|
||||
|
Loading…
Reference in New Issue
Block a user