Branch: refs/heads/main
Home: https://github.com/WebKit/WebKit
Commit: de4af743e2716edf699f7a1af80d2449c7a0f3f1
https://github.com/WebKit/WebKit/commit/de4af743e2716edf699f7a1af80d2449c7a0f3f1
Author: Antoine Quint <[email protected]>
Date: 2026-09-17 (Thu, 17 Sep 2026)
Changed paths:
M Source/WebCore/animation/ScrollTimeline.h
M Source/WebCore/animation/StyleOriginatedTimelinesController.cpp
M Source/WebCore/animation/ViewTimeline.h
M Source/WebCore/style/Styleable.h
Log Message:
-----------
[scroll-animations] reduce use of `Styleable` when managing style-originated
timelines
https://bugs.webkit.org/show_bug.cgi?id=324263
rdar://187483823
Reviewed by Anne van Kesteren.
We dramatically improved performance of style-originated timelines matching and
updating in 320902@main.
Further investigation of our performance in this area indicates that ~20% of
the newly-added test's time
was spent in `WeakStyleable::WeakStyleable(const Styleable&)` and a further 30%
in the two accessors that
call it. Those accessors run once per timeline registered under a name for
every animation attached to
that name, and each of those calls created and destroyed weak references only
to hand back an element that
the caller compares by pointer and then discards.
We reduce our use of `Styleable` by making `originatingElement()`, the new
`originatingElementIncludingTimelineScope()`
and `originatingElementExcludingTimelineScope()` return a `const Element*`
directly. Meanwhile, the callers
that genuinely need a `Styleable` use the new `originatingStyleable()`, which
now hand back a reference
rather than a copy.
To that end, we make `ViewTimeline::subjectStyleable()` return a reference just
like `ScrollTimeline::sourceStyleable()`.
Additionally, `ScrollTimeline::timelineScopeDeclaredElement()` returns an
`Element*` instead of a `WeakPtr`
and `WeakStyleable::element()` returns a reference to its `WeakPtr` member
instead of a copy.
This improves the performance of
`PerformanceTests/Animation/scroll-timeline-shared-name.html` by about 30%.
This patch was created using LLM code assistance.
* Source/WebCore/animation/ScrollTimeline.h:
(WebCore::ScrollTimeline::timelineScopeDeclaredElement const):
* Source/WebCore/animation/StyleOriginatedTimelinesController.cpp:
(WebCore::originatingStyleable):
(WebCore::originatingElement):
(WebCore::originatingElementIncludingTimelineScope):
(WebCore::originatingElementExcludingTimelineScope):
(WebCore::StyleOriginatedTimelinesController::determineTreeOrder):
(WebCore::StyleOriginatedTimelinesController::determineTimelineForElement):
(WebCore::StyleOriginatedTimelinesController::updateTimelineForTimelineScope):
(WebCore::StyleOriginatedTimelinesController::unregisterNamedTimeline):
(WebCore::StyleOriginatedTimelinesController::attachAnimation):
(WebCore::StyleOriginatedTimelinesController::updateTimelinesForTimelineScope):
(WebCore::StyleOriginatedTimelinesController::unregisterNamedTimelinesAssociatedWithElement):
(WebCore::StyleOriginatedTimelinesController::styleableWasRemoved):
(WebCore::originatingStyleableIncludingTimelineScope): Deleted.
* Source/WebCore/animation/ViewTimeline.h:
* Source/WebCore/style/Styleable.h:
(WebCore::WeakStyleable::element const): Deleted.
Canonical link: https://commits.webkit.org/321320@main
To unsubscribe from these emails, change your notification settings at
https://github.com/WebKit/WebKit/settings/notifications