Skip to content

Commit 644c932

Browse files
committed
Remove dedicated HashSet<Element*> for DocumentTimeline::runningAnimationsForElementAreAllAccelerated()
https://bugs.webkit.org/show_bug.cgi?id=216775 Reviewed by Antti Koivisto. * animation/AnimationTimeline.h: * animation/DocumentTimeline.cpp: (WebCore::DocumentTimeline::detachFromDocument): (WebCore::DocumentTimeline::animationAcceleratedRunningStateDidChange): (WebCore::DocumentTimeline::runningAnimationsForElementAreAllAccelerated const): (WebCore::DocumentTimeline::animationWasAddedToElement): Deleted. (WebCore::DocumentTimeline::animationWasRemovedFromElement): Deleted. (WebCore::DocumentTimeline::updateListOfElementsWithRunningAcceleratedAnimationsForElement): Deleted. * animation/DocumentTimeline.h: Canonical link: https://commits.webkit.org/229566@main git-svn-id: https://svn.webkit.org/repository/webkit/trunk@267347 268f45cc-cd09-0410-ab3c-d52691b4dbfc
1 parent 9792b5a commit 644c932

4 files changed

Lines changed: 29 additions & 43 deletions

File tree

Source/WebCore/ChangeLog

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,20 @@
1+
2020-09-21 Antoine Quint <graouts@webkit.org>
2+
3+
Remove dedicated HashSet<Element*> for DocumentTimeline::runningAnimationsForElementAreAllAccelerated()
4+
https://bugs.webkit.org/show_bug.cgi?id=216775
5+
6+
Reviewed by Antti Koivisto.
7+
8+
* animation/AnimationTimeline.h:
9+
* animation/DocumentTimeline.cpp:
10+
(WebCore::DocumentTimeline::detachFromDocument):
11+
(WebCore::DocumentTimeline::animationAcceleratedRunningStateDidChange):
12+
(WebCore::DocumentTimeline::runningAnimationsForElementAreAllAccelerated const):
13+
(WebCore::DocumentTimeline::animationWasAddedToElement): Deleted.
14+
(WebCore::DocumentTimeline::animationWasRemovedFromElement): Deleted.
15+
(WebCore::DocumentTimeline::updateListOfElementsWithRunningAcceleratedAnimationsForElement): Deleted.
16+
* animation/DocumentTimeline.h:
17+
118
2020-09-21 Chris Dumez <cdumez@apple.com>
219

320
AnalyserNode should downmix input audio to mono

Source/WebCore/animation/AnimationTimeline.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -66,8 +66,8 @@ class AnimationTimeline : public RefCounted<AnimationTimeline>, public CanMakeWe
6666
void willChangeRendererForElement(Element&);
6767
void cancelDeclarativeAnimationsForElement(Element&, WebAnimation::Silently);
6868

69-
virtual void animationWasAddedToElement(WebAnimation&, Element&);
70-
virtual void animationWasRemovedFromElement(WebAnimation&, Element&);
69+
void animationWasAddedToElement(WebAnimation&, Element&);
70+
void animationWasRemovedFromElement(WebAnimation&, Element&);
7171

7272
void removeDeclarativeAnimationFromListsForOwningElement(WebAnimation&, Element&);
7373

Source/WebCore/animation/DocumentTimeline.cpp

Lines changed: 10 additions & 37 deletions
Original file line numberDiff line numberDiff line change
@@ -83,7 +83,6 @@ void DocumentTimeline::detachFromDocument()
8383
controller->removeTimeline(*this);
8484

8585
m_pendingAnimationEvents.clear();
86-
m_elementsWithRunningAcceleratedAnimations.clear();
8786

8887
auto& animationsToRemove = m_animations;
8988
while (!animationsToRemove.isEmpty())
@@ -421,51 +420,16 @@ std::unique_ptr<RenderStyle> DocumentTimeline::animatedStyleForRenderer(RenderEl
421420
return result;
422421
}
423422

424-
void DocumentTimeline::animationWasAddedToElement(WebAnimation& animation, Element& element)
425-
{
426-
AnimationTimeline::animationWasAddedToElement(animation, element);
427-
updateListOfElementsWithRunningAcceleratedAnimationsForElement(element);
428-
}
429-
430-
void DocumentTimeline::animationWasRemovedFromElement(WebAnimation& animation, Element& element)
431-
{
432-
AnimationTimeline::animationWasRemovedFromElement(animation, element);
433-
updateListOfElementsWithRunningAcceleratedAnimationsForElement(element);
434-
}
435-
436423
void DocumentTimeline::animationAcceleratedRunningStateDidChange(WebAnimation& animation)
437424
{
438425
m_acceleratedAnimationsPendingRunningStateChange.add(&animation);
439426

440-
if (is<KeyframeEffect>(animation.effect())) {
441-
if (auto* target = downcast<KeyframeEffect>(animation.effect())->targetElementOrPseudoElement())
442-
updateListOfElementsWithRunningAcceleratedAnimationsForElement(*target);
443-
}
444-
445427
if (shouldRunUpdateAnimationsAndSendEventsIgnoringSuspensionState())
446428
scheduleAnimationResolution();
447429
else
448430
clearTickScheduleTimer();
449431
}
450432

451-
void DocumentTimeline::updateListOfElementsWithRunningAcceleratedAnimationsForElement(Element& element)
452-
{
453-
auto* animations = element.animations();
454-
if (!animations || animations->isEmpty()) {
455-
m_elementsWithRunningAcceleratedAnimations.remove(&element);
456-
return;
457-
}
458-
459-
for (const auto& animation : *animations) {
460-
if (!animation->isRunningAccelerated()) {
461-
m_elementsWithRunningAcceleratedAnimations.remove(&element);
462-
return;
463-
}
464-
}
465-
466-
m_elementsWithRunningAcceleratedAnimations.add(&element);
467-
}
468-
469433
void DocumentTimeline::applyPendingAcceleratedAnimations()
470434
{
471435
auto acceleratedAnimationsPendingRunningStateChange = m_acceleratedAnimationsPendingRunningStateChange;
@@ -484,7 +448,16 @@ void DocumentTimeline::applyPendingAcceleratedAnimations()
484448

485449
bool DocumentTimeline::runningAnimationsForElementAreAllAccelerated(Element& element) const
486450
{
487-
return m_elementsWithRunningAcceleratedAnimations.contains(&element);
451+
auto* animations = element.animations();
452+
if (!animations || animations->isEmpty())
453+
return false;
454+
455+
for (const auto& animation : *animations) {
456+
if (!animation->isRunningAccelerated())
457+
return false;
458+
}
459+
460+
return true;
488461
}
489462

490463
void DocumentTimeline::enqueueAnimationEvent(AnimationEventBase& event)

Source/WebCore/animation/DocumentTimeline.h

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -52,8 +52,6 @@ class DocumentTimeline final : public AnimationTimeline
5252

5353
void animationTimingDidChange(WebAnimation&) override;
5454
void removeAnimation(WebAnimation&) override;
55-
void animationWasAddedToElement(WebAnimation&, Element&) final;
56-
void animationWasRemovedFromElement(WebAnimation&, Element&) final;
5755
void transitionDidComplete(RefPtr<CSSTransition>);
5856

5957
// If possible, compute the visual extent of any transform animation on the given renderer
@@ -92,14 +90,12 @@ class DocumentTimeline final : public AnimationTimeline
9290
void scheduleAnimationResolution();
9391
void clearTickScheduleTimer();
9492
void internalUpdateAnimationsAndSendEvents();
95-
void updateListOfElementsWithRunningAcceleratedAnimationsForElement(Element&);
9693
void scheduleNextTick();
9794
bool animationCanBeRemoved(WebAnimation&);
9895
bool shouldRunUpdateAnimationsAndSendEventsIgnoringSuspensionState() const;
9996

10097
Timer m_tickScheduleTimer;
10198
HashSet<RefPtr<WebAnimation>> m_acceleratedAnimationsPendingRunningStateChange;
102-
HashSet<Element*> m_elementsWithRunningAcceleratedAnimations;
10399
AnimationEvents m_pendingAnimationEvents;
104100
WeakPtr<Document> m_document;
105101
Seconds m_originTime;

0 commit comments

Comments
 (0)