Commit 3e0c1b5f authored by Hitoshi Yoshida's avatar Hitoshi Yoshida Committed by Commit Bot

bindings: Do not get if timeline is missing (1/N)

Bindings is going to update IDL dictionaries to be strict about their
members' existence.  After the update, accessing a getter on a missing
dictionary member will crash.

This CL fixes the potential bug in Animatable.animate().


Bug: 839389
Change-Id: I305daff7130a2a26b5a7142f67fe7920910cead3
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2226483Reviewed-by: default avatarYuki Shiino <yukishiino@chromium.org>
Reviewed-by: default avatarKentaro Hara <haraken@chromium.org>
Auto-Submit: Hitoshi Yoshida <peria@chromium.org>
Commit-Queue: Kentaro Hara <haraken@chromium.org>
Cr-Commit-Position: refs/heads/master@{#774571}
parent d766e5db
...@@ -77,24 +77,18 @@ Animation* Animatable::animate( ...@@ -77,24 +77,18 @@ Animation* Animatable::animate(
return element->GetDocument().Timeline().Play(effect); return element->GetDocument().Timeline().Play(effect);
Animation* animation; Animation* animation;
AnimationTimeline* timeline = const KeyframeAnimationOptions* options_dict =
options.GetAsKeyframeAnimationOptions()->timeline(); options.GetAsKeyframeAnimationOptions();
if (!options_dict->hasTimeline()) {
bool timeline_is_undefined =
!options.GetAsKeyframeAnimationOptions()->hasTimeline();
bool timeline_is_null = !timeline_is_undefined && !timeline;
if (timeline_is_undefined) {
animation = element->GetDocument().Timeline().Play(effect); animation = element->GetDocument().Timeline().Play(effect);
} else if (timeline_is_null) { } else if (AnimationTimeline* timeline = options_dict->timeline()) {
animation = Animation::Create(element->GetExecutionContext(), effect,
timeline, exception_state);
} else {
DCHECK(timeline);
animation = timeline->Play(effect); animation = timeline->Play(effect);
} else {
animation = Animation::Create(element->GetExecutionContext(), effect,
nullptr, exception_state);
} }
animation->setId(options.GetAsKeyframeAnimationOptions()->id()); animation->setId(options_dict->id());
return animation; return animation;
} }
......
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