Skip to content

Commit

Permalink
chore: cherry-pick e3805f29fed7 from chromium (#32900)
Browse files Browse the repository at this point in the history
Co-authored-by: PatchUp <73610968+patchup[bot]@users.noreply.github.com>
Co-authored-by: Electron Bot <electron@github.com>
  • Loading branch information
3 people committed Feb 17, 2022
1 parent fc1c566 commit def17fe
Show file tree
Hide file tree
Showing 2 changed files with 73 additions and 0 deletions.
1 change: 1 addition & 0 deletions patches/chromium/.patches
Original file line number Diff line number Diff line change
Expand Up @@ -117,6 +117,7 @@ fix_crash_when_saving_edited_pdf_files.patch
use_axnodeid_rather_than_axnode_in_axeventgenerator_tree_events.patch
fire_iframe_onload_for_cross-origin-initiated_same-document.patch
do_not_select_vulkan_device_based_on_the_passed_in_gpu_info_on_linux.patch
cherry-pick-e3805f29fed7.patch
cherry-pick-be50c60b4225.patch
cherry-pick-0081bb347e67.patch
m98_fs_fix_fileutil_lifetime_issue.patch
Expand Down
72 changes: 72 additions & 0 deletions patches/chromium/cherry-pick-e3805f29fed7.patch
Original file line number Diff line number Diff line change
@@ -0,0 +1,72 @@
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
From: Kevin Ellis <kevers@google.com>
Date: Fri, 11 Feb 2022 01:36:04 +0000
Subject: Code health cleanup: replacing animations.

Animation::Update performed a synchronous processing of the finish
microtask to ensure that finished events where dispatched ahead of
replace events. This step does not align with the spec. Instead we
should be queuing the replace event. Microtasks will be processed in
the correct order.

Spec link: https://www.w3.org/TR/web-animations-1/#timelines

Change-Id: Ibe7753e792fb6cf905bbe6815a080a8cc51c2803

(cherry picked from commit d4fb69ff0fe343fe8a171014785a88eabfe2b1c2)

Bug: 1290858
Change-Id: Ibe7753e792fb6cf905bbe6815a080a8cc51c2803
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/3414765
Reviewed-by: Mustaq Ahmed <mustaq@chromium.org>
Commit-Queue: Kevin Ellis <kevers@chromium.org>
Cr-Original-Commit-Position: refs/heads/main@{#964223}
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/3453925
Reviewed-by: Adrian Taylor <adetaylor@google.com>
Commit-Queue: Krishna Govind <govind@chromium.org>
Cr-Commit-Position: refs/branch-heads/4758@{#1134}
Cr-Branched-From: 4a2cf4baf90326df19c3ee70ff987960d59a386e-refs/heads/main@{#950365}

diff --git a/third_party/blink/renderer/core/animation/animation.cc b/third_party/blink/renderer/core/animation/animation.cc
index 943d0594b9c2fdcb10f90e3b4e951b8a809e74f3..734e10902292d7d81884af34b562d18a7802135a 100644
--- a/third_party/blink/renderer/core/animation/animation.cc
+++ b/third_party/blink/renderer/core/animation/animation.cc
@@ -2275,10 +2275,6 @@ bool Animation::Update(TimingUpdateReason reason) {

if (reason == kTimingUpdateForAnimationFrame) {
if (idle || CalculateAnimationPlayState() == kFinished) {
- // TODO(crbug.com/1029348): Per spec, we should have a microtask
- // checkpoint right after the update cycle. Once this is fixed we should
- // no longer need to force a synchronous resolution here.
- AsyncFinishMicrotask();
finished_ = true;
}
}
diff --git a/third_party/blink/renderer/core/animation/document_animations.cc b/third_party/blink/renderer/core/animation/document_animations.cc
index 29217ecb96dbdd342e75145c337c189d85c9bca5..681b30bfdcc30db0d1b8904d327f36582c47a197 100644
--- a/third_party/blink/renderer/core/animation/document_animations.cc
+++ b/third_party/blink/renderer/core/animation/document_animations.cc
@@ -47,6 +47,7 @@
#include "third_party/blink/renderer/core/page/page_animator.h"
#include "third_party/blink/renderer/core/style/computed_style.h"
#include "third_party/blink/renderer/platform/bindings/microtask.h"
+#include "third_party/blink/renderer/platform/heap/persistent.h"

namespace blink {

@@ -258,10 +259,13 @@ void DocumentAnimations::RemoveReplacedAnimations(

// The list of animations for removal is constructed in reverse composite
// ordering for efficiency. Flip the ordering to ensure that events are
- // dispatched in composite order.
+ // dispatched in composite order. Queue as a microtask so that the finished
+ // event is dispatched ahead of the remove event.
for (auto it = animations_to_remove.rbegin();
it != animations_to_remove.rend(); it++) {
- (*it)->RemoveReplacedAnimation();
+ Animation* animation = *it;
+ Microtask::EnqueueMicrotask(WTF::Bind(&Animation::RemoveReplacedAnimation,
+ WrapWeakPersistent(animation)));
}
}

0 comments on commit def17fe

Please sign in to comment.