[Web Animations] Audit Web Animations classes for memory reduction
authorgraouts@webkit.org <graouts@webkit.org@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Thu, 10 Jan 2019 08:19:39 +0000 (08:19 +0000)
committergraouts@webkit.org <graouts@webkit.org@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Thu, 10 Jan 2019 08:19:39 +0000 (08:19 +0000)
commit273af2d7fc1a555c2d0d8b08fcbb198941331d43
treec82241e4124bbf6ca8b7e9231d0f573b4514b732
parent4bd86179d5c9aca34b87f8d92ebba55a27f91cdd
[Web Animations] Audit Web Animations classes for memory reduction
https://bugs.webkit.org/show_bug.cgi?id=193195

Reviewed by Simon Fraser and Yusuke Suzuki.

The classes, enums and structs added to support Web Animations were not as memory-efficient as they could be. We now order
members in a way that reduces padding, use Markable<T, Traits> instead of Optional<T> where applicable, declare enums as uint8_t
and removed unnecessary members.

As a result, classes and structs have shrunk as follows:

WebAnimation: 256 > 216
DeclarativeAnimation: 392 > 344
CSSAnimation: 416 > 368
CSSTransition: 440 > 392
AnimationEffect: 88 > 72
KeyframeEffect: 208 > 184
AnimationPlaybackEvent: 104 > 88
EffectTiming: 72 > 64
ComputedEffectTiming: 136 > 112
AnimationTimeline: 264 > 248
DocumentTimeline: 496 > 464
OptionalEffectTiming: 112 > 80
BaseKeyframe: 32 > 24
ParsedKeyframe: 80 > 72
BaseComputedKeyframe: 40 > 32

* animation/AnimationEffect.h: Order members in decreasing size, except for m_fill and m_direction, which we put at the top to
save 8 bytes (2 bytes of padding instead of 4 before m_animation and saving 6 bytes of padding at the end).
* animation/AnimationPlaybackEvent.cpp:
(WebCore::AnimationPlaybackEvent::AnimationPlaybackEvent):
* animation/AnimationPlaybackEvent.h:
* animation/AnimationPlaybackEventInit.h:
* animation/AnimationTimeline.cpp:
(WebCore::AnimationTimeline::AnimationTimeline):
(WebCore::AnimationTimeline::updateCSSTransitionsForElement):
* animation/AnimationTimeline.h: We remove the m_classType member and instead make isDocumentTimeline() virtual.
(WebCore::AnimationTimeline::isDocumentTimeline const):
(): Deleted.
(WebCore::AnimationTimeline::classType const): Deleted.
* animation/CompositeOperation.h:
* animation/CompositeOperationOrAuto.h:
* animation/ComputedEffectTiming.h:
* animation/DeclarativeAnimation.cpp:
(WebCore::DeclarativeAnimation::DeclarativeAnimation):
(WebCore::DeclarativeAnimation::invalidateDOMEvents):
* animation/DeclarativeAnimation.h: We keep m_wasPending and m_previousPhase at the top to save some padding at the end.
* animation/DocumentTimeline.cpp:
(WebCore::DocumentTimeline::DocumentTimeline):
* animation/DocumentTimeline.h:
* animation/EffectTiming.h:
* animation/FillMode.h:
* animation/IterationCompositeOperation.h:
* animation/KeyframeEffect.cpp:
(WebCore::computeMissingKeyframeOffsets):
(WebCore::KeyframeEffect::create):
(WebCore::KeyframeEffect::KeyframeEffect):
* animation/KeyframeEffect.h:
* animation/OptionalEffectTiming.h:
* animation/PlaybackDirection.h:
* animation/WebAnimation.h:
* animation/WebAnimationUtilities.h:
(WebCore::WebAnimationsMarkableDoubleTraits::isEmptyValue):
(WebCore::WebAnimationsMarkableDoubleTraits::emptyValue):

git-svn-id: https://svn.webkit.org/repository/webkit/trunk@239820 268f45cc-cd09-0410-ab3c-d52691b4dbfc
23 files changed:
Source/WebCore/ChangeLog
Source/WebCore/animation/AnimationEffect.h
Source/WebCore/animation/AnimationPlaybackEvent.cpp
Source/WebCore/animation/AnimationPlaybackEvent.h
Source/WebCore/animation/AnimationPlaybackEventInit.h
Source/WebCore/animation/AnimationTimeline.cpp
Source/WebCore/animation/AnimationTimeline.h
Source/WebCore/animation/CompositeOperation.h
Source/WebCore/animation/CompositeOperationOrAuto.h
Source/WebCore/animation/ComputedEffectTiming.h
Source/WebCore/animation/DeclarativeAnimation.cpp
Source/WebCore/animation/DeclarativeAnimation.h
Source/WebCore/animation/DocumentTimeline.cpp
Source/WebCore/animation/DocumentTimeline.h
Source/WebCore/animation/EffectTiming.h
Source/WebCore/animation/FillMode.h
Source/WebCore/animation/IterationCompositeOperation.h
Source/WebCore/animation/KeyframeEffect.cpp
Source/WebCore/animation/KeyframeEffect.h
Source/WebCore/animation/OptionalEffectTiming.h
Source/WebCore/animation/PlaybackDirection.h
Source/WebCore/animation/WebAnimation.h
Source/WebCore/animation/WebAnimationUtilities.h