Commit 59edcc08 authored by Kevin Ellis's avatar Kevin Ellis Committed by Commit Bot

Support setKeyframes for CSS transitions

CSS transtions use transition keyframe models instead of string
keyframe models.  With this patch, the model is replaced with a string
keyframe model when setKeyframes is called if required.

Bug: 835818
Change-Id: Ie77a1b38e6ac4392b4b29b22af8d78cb504ce8fc
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2134613Reviewed-by: default avatarRobert Flack <flackr@chromium.org>
Commit-Queue: Kevin Ellis <kevers@chromium.org>
Cr-Commit-Position: refs/heads/master@{#755975}
parent bcb78251
......@@ -260,22 +260,17 @@ HeapVector<ScriptValue> KeyframeEffect::getKeyframes(
void KeyframeEffect::setKeyframes(ScriptState* script_state,
const ScriptValue& keyframes,
ExceptionState& exception_state) {
// TODO(crbug.com/799061): Support TransitionKeyframeEffectModel. This will
// require a lot of work as the setKeyframes API can mutate a transition
// Animation into a 'normal' one with multiple properties.
if (!Model()->IsStringKeyframeEffectModel()) {
exception_state.ThrowDOMException(
DOMExceptionCode::kNotSupportedError,
"Calling setKeyframes on CSS Transitions is not yet supported");
return;
}
StringKeyframeVector new_keyframes = EffectInput::ParseKeyframesArgument(
target(), keyframes, script_state, exception_state);
if (exception_state.HadException())
return;
ignore_css_keyframes_ = true;
if (auto* model = DynamicTo<TransitionKeyframeEffectModel>(Model()))
SetModel(model->CloneAsEmptyStringKeyframeModel());
DCHECK(Model()->IsStringKeyframeEffectModel());
SetKeyframes(new_keyframes);
}
......
......@@ -234,6 +234,12 @@ class KeyframeEffectModel final : public KeyframeEffectModelBase {
keyframes, composite_, default_keyframe_easing_);
}
KeyframeEffectModel<StringKeyframe>* CloneAsEmptyStringKeyframeModel() {
HeapVector<Member<StringKeyframe>> empty_keyframes;
return MakeGarbageCollected<KeyframeEffectModel<StringKeyframe>>(
empty_keyframes, composite_, default_keyframe_easing_);
}
private:
bool IsStringKeyframeEffectModel() const override { return false; }
bool IsTransitionKeyframeEffectModel() const override { return false; }
......
This is a testharness.js-based test.
FAIL Keyframes set using setKeyframes() are reflected in computed style for a running transition Failed to execute 'setKeyframes' on 'KeyframeEffect': Calling setKeyframes on CSS Transitions is not yet supported
FAIL A transition with replaced keyframes still returns the original transitionProperty Failed to execute 'setKeyframes' on 'KeyframeEffect': Calling setKeyframes on CSS Transitions is not yet supported
FAIL A transition with no keyframes still returns the original transitionProperty Failed to execute 'setKeyframes' on 'KeyframeEffect': Calling setKeyframes on CSS Transitions is not yet supported
FAIL A transition with replaced keyframes still exhibits the regular transition reversing behavior Failed to execute 'setKeyframes' on 'KeyframeEffect': Calling setKeyframes on CSS Transitions is not yet supported
FAIL A transition with no keyframes still exhibits the regular transition reversing behavior Failed to execute 'setKeyframes' on 'KeyframeEffect': Calling setKeyframes on CSS Transitions is not yet supported
PASS Keyframes set using setKeyframes() are reflected in computed style for a running transition
PASS A transition with replaced keyframes still returns the original transitionProperty
PASS A transition with no keyframes still returns the original transitionProperty
FAIL A transition with replaced keyframes still exhibits the regular transition reversing behavior Cannot read property 'effect' of undefined
FAIL A transition with no keyframes still exhibits the regular transition reversing behavior Cannot read property 'effect' of undefined
Harness: the test ran to completion.
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment