Skip to content
This repository has been archived by the owner on Aug 4, 2022. It is now read-only.

Commit

Permalink
Bug 1536688 - Allow animating the 'all' property from Web Animations;…
Browse files Browse the repository at this point in the history
… r=emilio

Differential Revision: https://phabricator.services.mozilla.com/D28763
  • Loading branch information
birtles committed Apr 26, 2019
1 parent f904761 commit 8894214
Show file tree
Hide file tree
Showing 5 changed files with 81 additions and 2 deletions.
1 change: 1 addition & 0 deletions dom/animation/test/chrome.ini
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ support-files =
[chrome/test_animation_observers_sync.html]
[chrome/test_animation_performance_warning.html]
[chrome/test_animation_properties.html]
[chrome/test_animation_properties_display.html]
[chrome/test_cssanimation_missing_keyframes.html]
[chrome/test_generated_content_getAnimations.html]
[chrome/test_running_on_compositor.html]
Expand Down
43 changes: 43 additions & 0 deletions dom/animation/test/chrome/test_animation_properties_display.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
<!doctype html>
<head>
<meta charset=utf-8>
<title>Bug 1536688 - Test that 'display' is not included in
KeyframeEffect.getProperties() when using shorthand 'all'</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>
</head>
<body>
<a href="https://bugzilla.mozilla.org/show_bug.cgi?id=1536688"
target="_blank">Mozilla Bug 1536688</a>
<div id="log"></div>
<script>
'use strict';

SpecialPowers.pushPrefEnv(
{
set: [['dom.animations-api.core.enabled', true]],
},
function() {
test(t => {
const div = addDiv(t);
const animation = div.animate(
{ all: ['unset', 'unset'] },
100 * MS_PER_SEC
);
// Flush styles since getProperties does not.
getComputedStyle(div).opacity;

const properties = animation.effect.getProperties();
assert_false(
properties.some(property => property.property === 'display'),
'Should not have a property for display'
);
});

done();
}
);

</script>
</body>
2 changes: 0 additions & 2 deletions servo/components/style/properties/data.py
Original file line number Diff line number Diff line change
Expand Up @@ -400,8 +400,6 @@ def __init__(self, name, sub_properties, spec=None, servo_pref=None, gecko_pref=
and allowed_in_keyframe_block != "False"

def get_animatable(self):
if self.ident == "all":
return False
for sub in self.sub_properties:
if sub.animatable:
return True
Expand Down
7 changes: 7 additions & 0 deletions servo/ports/geckolib/glue.rs
Original file line number Diff line number Diff line change
Expand Up @@ -5104,6 +5104,13 @@ pub extern "C" fn Servo_GetComputedKeyframeValues(
let mut maybe_append_animation_value =
|property: LonghandId, value: Option<AnimationValue>| {
debug_assert!(!property.is_logical());
debug_assert!(property.is_animatable());

// 'display' is only animatable from SMIL
if property == LonghandId::Display {
return;
}

if seen.contains(property) {
return;
}
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
<!doctype html>
<meta charset=utf-8>
<title>Calculating computed keyframes: Shorthand properties</title>
<link rel="help" href="https://drafts.csswg.org/web-animations-1/#calculating-computed-keyframes">
<script src="/resources/testharness.js"></script>
<script src="/resources/testharnessreport.js"></script>
<script src="../../testcommon.js"></script>
<body>
<div id="log"></div>
<div id="target"></div>
<script>
'use strict';

test(t => {
const div = createDiv(t);
div.style.opacity = '0';

const animation = div.animate({ all: 'initial' }, 100 * MS_PER_SEC);
animation.currentTime = 50 * MS_PER_SEC;

assert_approx_equals(
parseFloat(getComputedStyle(div).opacity),
0.5,
0.0001,
'Should be half way through an opacity animation'
);
}, 'It should be possible to animate the all shorthand');

</script>
</body>

0 comments on commit 8894214

Please sign in to comment.