0

Update animation docs with OnAborted caveat

Bug: None
Change-Id: Id14b44aa0abb060a9aa1c21a12fc7f18612a0c5c
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/3795742
Commit-Queue: Elaine Chien <elainechien@chromium.org>
Reviewed-by: Allen Bauer <kylixrd@chromium.org>
Cr-Commit-Position: refs/heads/main@{#1030332}
This commit is contained in:
Elaine Chien
2022-08-02 00:15:54 +00:00
committed by Chromium LUCI CQ
parent a885f0fbfd
commit eb7088a657
2 changed files with 4 additions and 2 deletions
docs/ui/animation_builder
ui/views/animation

@ -108,7 +108,7 @@ Calls on AnimationBuilder affect the whole animations and calls on AnimationSequ
#### Setting callbacks
When setting callbacks for the animations note that the AnimationBuilders observer that calls these callbacks may outlive the callback's parameters.
The OnEnded callback runs when all animations created on the AnimationBuilder have finished. The OnAborted callback runs when any one animation created on the AnimationBuilder has been aborted. Therefore, these callbacks and every object the callback accesses needs to outlive all the Layers/LayerOwners being animated on since the Layers ultimately own the objects that run the animation. Otherwise developers may need to use weak pointers or force animations to be cancelled in the objects destructor to prevent accessing destroyed objects.
The OnEnded callback runs when all animations created on the AnimationBuilder have finished. The OnAborted callback runs when any one animation created on the AnimationBuilder has been aborted. Therefore, these callbacks and every object the callback accesses needs to outlive all the Layers/LayerOwners being animated on since the Layers ultimately own the objects that run the animation. Otherwise developers may need to use weak pointers or force animations to be cancelled in the objects destructor to prevent accessing destroyed objects. Note that aborted notifications can be sent during the destruction process. Therefore subclasses that own the Layers may actually be destroyed before the OnAborted callback is run.
#### API
``` cpp

@ -42,7 +42,9 @@ class AnimationAbortHandle;
// being animated on since the Layers ultimately own the objects that run the
// animation. Otherwise, developers may need to use weak pointers or force
// animations to be cancelled in the objects destructor to prevent accessing
// destroyed objects.
// destroyed objects. Note that aborted notifications can be sent during the
// destruction process. Therefore subclasses that own the Layers may actually be
// destroyed before the OnAborted callback is run.
class VIEWS_EXPORT AnimationBuilder {
public: