Diff
Modified: trunk/Source/WebCore/ChangeLog (258315 => 258316)
--- trunk/Source/WebCore/ChangeLog 2020-03-12 07:08:21 UTC (rev 258315)
+++ trunk/Source/WebCore/ChangeLog 2020-03-12 07:48:06 UTC (rev 258316)
@@ -1,3 +1,95 @@
+2020-03-11 Antoine Quint <grao...@webkit.org>
+
+ AnimationTimeline should not have multiple HashMaps with raw Element* keys
+ https://bugs.webkit.org/show_bug.cgi?id=208079
+ <rdar://problem/59687906>
+
+ Reviewed by Ryosuke Niwa.
+
+ We introduce a new ElementAnimationRareData class that holds the KeyframeEffectStack previously owned by ElementRareData as well as a few maps and lists
+ owned by AnimationTimeline which would use raw Element pointers as keys. Specifically, this is what changed:
+
+ - AnimationTimeline::m_elementToRunningCSSTransitionByCSSPropertyID → ElementAnimationRareData::runningTransitionByProperty()
+ - AnimationTimeline::m_elementToCompletedCSSTransitionByCSSPropertyID → ElementAnimationRareData::completedTransitionByProperty()
+ - AnimationTimeline::m_elementToCSSAnimationsCreatedByMarkupMap → ElementAnimationRareData::animationsCreatedByMarkup()
+ - AnimationTimeline::m_elementToCSSTransitionsMap → ElementAnimationRareData::transitions()
+ - AnimationTimeline::m_elementToCSSAnimationsMap → ElementAnimationRareData::cssAnimations()
+ - AnimationTimeline::m_elementToAnimationsMap → ElementAnimationRareData::webAnimations()
+
+ For convenience, these new members are exposed via Element directly.
+
+ No change in behavior, so no new tests.
+
+ * Headers.cmake:
+ * Sources.txt:
+ * WebCore.xcodeproj/project.pbxproj:
+ * animation/AnimationPlaybackEventInit.h:
+ * animation/AnimationTimeline.cpp:
+ (WebCore::AnimationTimeline::animationWasAddedToElement):
+ (WebCore::removeCSSTransitionFromMap):
+ (WebCore::AnimationTimeline::animationWasRemovedFromElement):
+ (WebCore::AnimationTimeline::removeDeclarativeAnimationFromListsForOwningElement):
+ (WebCore::AnimationTimeline::animationsForElement const):
+ (WebCore::AnimationTimeline::removeCSSAnimationCreatedByMarkup):
+ (WebCore::AnimationTimeline::willDestroyRendererForElement):
+ (WebCore::AnimationTimeline::elementWasRemoved):
+ (WebCore::AnimationTimeline::cancelDeclarativeAnimationsForElement):
+ (WebCore::AnimationTimeline::updateCSSAnimationsForElement):
+ (WebCore::propertyInStyleMatchesValueForTransitionInMap):
+ (WebCore::AnimationTimeline::updateCSSTransitionsForElementAndProperty):
+ (WebCore::AnimationTimeline::updateCSSTransitionsForElement):
+ (WebCore::removeAnimationFromMapForElement): Deleted.
+ (WebCore::AnimationTimeline::ensureRunningTransitionsByProperty): Deleted.
+ * animation/AnimationTimeline.h:
+ * animation/ComputedEffectTiming.h:
+ * animation/DocumentTimeline.cpp:
+ (WebCore::DocumentTimeline::transitionDidComplete):
+ * animation/ElementAnimationRareData.cpp: Copied from Source/WebCore/animation/ComputedEffectTiming.h.
+ (WebCore::ElementAnimationRareData::ElementAnimationRareData):
+ (WebCore::ElementAnimationRareData::~ElementAnimationRareData):
+ (WebCore::ElementAnimationRareData::ensureKeyframeEffectStack):
+ * animation/ElementAnimationRareData.h: Added.
+ (WebCore::ElementAnimationRareData::keyframeEffectStack):
+ (WebCore::ElementAnimationRareData::webAnimations):
+ (WebCore::ElementAnimationRareData::cssAnimations):
+ (WebCore::ElementAnimationRareData::transitions):
+ (WebCore::ElementAnimationRareData::animationsCreatedByMarkup):
+ (WebCore::ElementAnimationRareData::setAnimationsCreatedByMarkup):
+ (WebCore::ElementAnimationRareData::completedTransitionByProperty):
+ (WebCore::ElementAnimationRareData::runningTransitionsByProperty):
+ * animation/KeyframeEffect.h:
+ * animation/OptionalEffectTiming.h:
+ * animation/WebAnimation.h:
+ * animation/WebAnimationTypes.h: Copied from Source/WebCore/animation/WebAnimationUtilities.h.
+ (WebCore::WebAnimationsMarkableDoubleTraits::isEmptyValue):
+ (WebCore::WebAnimationsMarkableDoubleTraits::emptyValue):
+ * animation/WebAnimationUtilities.h:
+ (WebCore::WebAnimationsMarkableDoubleTraits::isEmptyValue): Deleted.
+ (WebCore::WebAnimationsMarkableDoubleTraits::emptyValue): Deleted.
+ * dom/Element.cpp:
+ (WebCore::Element::animationRareData const):
+ (WebCore::Element::ensureAnimationRareData):
+ (WebCore::Element::keyframeEffectStack const):
+ (WebCore::Element::ensureKeyframeEffectStack):
+ (WebCore::Element::hasKeyframeEffects const):
+ (WebCore::Element::webAnimations):
+ (WebCore::Element::cssAnimations):
+ (WebCore::Element::transitions):
+ (WebCore::Element::animationsCreatedByMarkup):
+ (WebCore::Element::setAnimationsCreatedByMarkup):
+ (WebCore::Element::completedTransitionByProperty):
+ (WebCore::Element::runningTransitionsByProperty):
+ * dom/Element.h:
+ * dom/ElementRareData.h:
+ (WebCore::ElementRareData::elementAnimationRareData):
+ (WebCore::ElementRareData::useTypes const):
+ (WebCore::ElementRareData::ensureAnimationRareData):
+ (WebCore::ElementRareData::keyframeEffectStack): Deleted.
+ (WebCore::ElementRareData::setKeyframeEffectStack): Deleted.
+ * dom/Node.cpp:
+ (WebCore::stringForRareDataUseType):
+ * dom/NodeRareData.h:
+
2020-03-11 Jer Noble <jer.no...@apple.com>
Adopt AVSampleBufferVideoOutput
Modified: trunk/Source/WebCore/Headers.cmake (258315 => 258316)
--- trunk/Source/WebCore/Headers.cmake 2020-03-12 07:08:21 UTC (rev 258315)
+++ trunk/Source/WebCore/Headers.cmake 2020-03-12 07:48:06 UTC (rev 258316)
@@ -185,6 +185,7 @@
animation/KeyframeAnimationOptions.h
animation/KeyframeEffectOptions.h
animation/PlaybackDirection.h
+ animation/WebAnimationTypes.h
bindings/IDLTypes.h
Modified: trunk/Source/WebCore/Sources.txt (258315 => 258316)
--- trunk/Source/WebCore/Sources.txt 2020-03-12 07:08:21 UTC (rev 258315)
+++ trunk/Source/WebCore/Sources.txt 2020-03-12 07:48:06 UTC (rev 258316)
@@ -455,6 +455,7 @@
animation/CSSTransition.cpp
animation/DeclarativeAnimation.cpp
animation/DocumentTimeline.cpp
+animation/ElementAnimationRareData.cpp
animation/KeyframeEffect.cpp
animation/KeyframeEffectStack.cpp
animation/WebAnimation.cpp
Modified: trunk/Source/WebCore/WebCore.xcodeproj/project.pbxproj (258315 => 258316)
--- trunk/Source/WebCore/WebCore.xcodeproj/project.pbxproj 2020-03-12 07:08:21 UTC (rev 258315)
+++ trunk/Source/WebCore/WebCore.xcodeproj/project.pbxproj 2020-03-12 07:48:06 UTC (rev 258316)
@@ -2084,6 +2084,7 @@
71025EDE1F99F1EC004A250C /* JSAnimationTimeline.h in Headers */ = {isa = PBXBuildFile; fileRef = 71025ED91F99F1A7004A250C /* JSAnimationTimeline.h */; };
71025EE01F99F1EC004A250C /* JSDocumentTimeline.h in Headers */ = {isa = PBXBuildFile; fileRef = 71025EDC1F99F1A8004A250C /* JSDocumentTimeline.h */; };
71025EE21F99F1EC004A250C /* JSWebAnimation.h in Headers */ = {isa = PBXBuildFile; fileRef = 71025ED81F99F1A6004A250C /* JSWebAnimation.h */; };
+ 7108EEE62418ED5A005C3DA7 /* WebAnimationTypes.h in Headers */ = {isa = PBXBuildFile; fileRef = 7108EEE42418ED53005C3DA7 /* WebAnimationTypes.h */; settings = {ATTRIBUTES = (Private, ); }; };
7111243E216FA71100EB7B67 /* CompositeOperationOrAuto.h in Headers */ = {isa = PBXBuildFile; fileRef = 7111243B216FA6E000EB7B67 /* CompositeOperationOrAuto.h */; settings = {ATTRIBUTES = (Private, ); }; };
71112441216FA7CD00EB7B67 /* JSCompositeOperationOrAuto.h in Headers */ = {isa = PBXBuildFile; fileRef = 71112440216FA7BE00EB7B67 /* JSCompositeOperationOrAuto.h */; settings = {ATTRIBUTES = (Private, ); }; };
7116E2CC1FED75DC00C06FDE /* ComputedEffectTiming.h in Headers */ = {isa = PBXBuildFile; fileRef = 7116E2CB1FED75D100C06FDE /* ComputedEffectTiming.h */; settings = {ATTRIBUTES = (Private, ); }; };
@@ -2090,6 +2091,7 @@
7116E2CF1FED765B00C06FDE /* JSComputedEffectTiming.h in Headers */ = {isa = PBXBuildFile; fileRef = 7116E2CE1FED765200C06FDE /* JSComputedEffectTiming.h */; settings = {ATTRIBUTES = (Private, ); }; };
7117445914BC34EC00EE5FC8 /* SVGTextMetricsBuilder.h in Headers */ = {isa = PBXBuildFile; fileRef = 7117445714BC34E200EE5FC8 /* SVGTextMetricsBuilder.h */; };
7118FED515685CC60030B79A /* JSSVGViewSpec.h in Headers */ = {isa = PBXBuildFile; fileRef = 7118FED315685CC60030B79A /* JSSVGViewSpec.h */; };
+ 7119465624181EA100466C11 /* ElementAnimationRareData.h in Headers */ = {isa = PBXBuildFile; fileRef = 7119465324181E8300466C11 /* ElementAnimationRareData.h */; settings = {ATTRIBUTES = (Private, ); }; };
711AD126236D86E5006FF37C /* AnimationEventBase.h in Headers */ = {isa = PBXBuildFile; fileRef = 711AD123236D86D3006FF37C /* AnimationEventBase.h */; settings = {ATTRIBUTES = (Private, ); }; };
71207340216DFB0000C78329 /* OptionalEffectTiming.h in Headers */ = {isa = PBXBuildFile; fileRef = 7120733D216DFAF100C78329 /* OptionalEffectTiming.h */; settings = {ATTRIBUTES = (Private, ); }; };
71207343216DFB4100C78329 /* JSOptionalEffectTiming.h in Headers */ = {isa = PBXBuildFile; fileRef = 71207341216DFB3100C78329 /* JSOptionalEffectTiming.h */; settings = {ATTRIBUTES = (Private, ); }; };
@@ -9419,6 +9421,7 @@
71025EDA1F99F1A7004A250C /* JSAnimationTimeline.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = JSAnimationTimeline.cpp; sourceTree = "<group>"; };
71025EDB1F99F1A8004A250C /* JSDocumentTimeline.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = JSDocumentTimeline.cpp; sourceTree = "<group>"; };
71025EDC1F99F1A8004A250C /* JSDocumentTimeline.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = JSDocumentTimeline.h; sourceTree = "<group>"; };
+ 7108EEE42418ED53005C3DA7 /* WebAnimationTypes.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = WebAnimationTypes.h; sourceTree = "<group>"; };
710FA74B1DEE576D004C715E /* controls-bar.js */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode._javascript_; path = "controls-bar.js"; sourceTree = "<group>"; };
710FA74C1DEE577E004C715E /* controls-visibility-support.js */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode._javascript_; path = "controls-visibility-support.js"; sourceTree = "<group>"; };
7111243B216FA6E000EB7B67 /* CompositeOperationOrAuto.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = CompositeOperationOrAuto.h; sourceTree = "<group>"; };
@@ -9433,6 +9436,8 @@
7117445714BC34E200EE5FC8 /* SVGTextMetricsBuilder.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = SVGTextMetricsBuilder.h; sourceTree = "<group>"; };
7118FED215685CC60030B79A /* JSSVGViewSpec.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = JSSVGViewSpec.cpp; sourceTree = "<group>"; };
7118FED315685CC60030B79A /* JSSVGViewSpec.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = JSSVGViewSpec.h; sourceTree = "<group>"; };
+ 7119465324181E8300466C11 /* ElementAnimationRareData.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = ElementAnimationRareData.h; sourceTree = "<group>"; };
+ 7119465524181E8400466C11 /* ElementAnimationRareData.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = ElementAnimationRareData.cpp; sourceTree = "<group>"; };
711AD123236D86D3006FF37C /* AnimationEventBase.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = AnimationEventBase.h; sourceTree = "<group>"; };
711AD125236D86D4006FF37C /* AnimationEventBase.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = AnimationEventBase.cpp; sourceTree = "<group>"; };
711FB0751DC7688F00C4C708 /* placard-support.js */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode._javascript_; path = "placard-support.js"; sourceTree = "<group>"; };
@@ -21046,6 +21051,8 @@
71729F7920F3BA3900801CE6 /* DocumentTimelineOptions.idl */,
712BE47C1FE86448002031CC /* EffectTiming.h */,
712BE47A1FE86447002031CC /* EffectTiming.idl */,
+ 7119465524181E8400466C11 /* ElementAnimationRareData.cpp */,
+ 7119465324181E8300466C11 /* ElementAnimationRareData.h */,
712BE4811FE865D4002031CC /* FillMode.h */,
712BE4821FE865D5002031CC /* FillMode.idl */,
713F1D5923DF1D7D003F5EFA /* GetAnimationsOptions.h */,
@@ -21068,6 +21075,7 @@
71025EC31F99F096004A250C /* WebAnimation.cpp */,
71025EC21F99F096004A250C /* WebAnimation.h */,
71025EC81F99F096004A250C /* WebAnimation.idl */,
+ 7108EEE42418ED53005C3DA7 /* WebAnimationTypes.h */,
71C25AF52392BF3C00D5C098 /* WebAnimationUtilities.cpp */,
7132444F20109D9B00AE7FB2 /* WebAnimationUtilities.h */,
);
@@ -26370,6 +26378,8 @@
CD9D375A215163E40049657B /* CDMInstanceSession.h */,
CD94A5D41F71CB6C00F525C5 /* CDMKeyStatus.h */,
CD94A5CD1F71CB6900F525C5 /* CDMKeySystemConfiguration.h */,
+ CD8D306E23AD4FA8006C3975 /* CDMLogging.cpp */,
+ CD8D306D23AD4FA8006C3975 /* CDMLogging.h */,
CD94A5D31F71CB6C00F525C5 /* CDMMediaCapability.h */,
CD94A5D61F71CB6D00F525C5 /* CDMMessageType.h */,
CD3CE11C240451AF004BA01D /* CDMPrivate.cpp */,
@@ -26379,8 +26389,6 @@
CD94A5CC1F71CB6900F525C5 /* CDMRequirement.h */,
CD94A5D01F71CB6B00F525C5 /* CDMRestrictions.h */,
CD94A5D51F71CB6D00F525C5 /* CDMSessionType.h */,
- CD8D306D23AD4FA8006C3975 /* CDMLogging.h */,
- CD8D306E23AD4FA8006C3975 /* CDMLogging.cpp */,
);
path = encryptedmedia;
sourceTree = "<group>";
@@ -29362,6 +29370,7 @@
CD3CE0FB2401AAD9004BA01D /* CDMInstanceSession.h in Headers */,
CD3CE0FC2401AAD9004BA01D /* CDMKeyStatus.h in Headers */,
CD3CE0FD2401AAD9004BA01D /* CDMKeySystemConfiguration.h in Headers */,
+ CD8D306F23AD4FA8006C3975 /* CDMLogging.h in Headers */,
CD3CE0FE2401AAD9004BA01D /* CDMMediaCapability.h in Headers */,
CD3CE0FF2401AADA004BA01D /* CDMMessageType.h in Headers */,
CD3CE1002401AADA004BA01D /* CDMPrivate.h in Headers */,
@@ -29904,6 +29913,7 @@
A8C4A80709D563270003AC8D /* Element.h in Headers */,
E4AE7C1A17D232350009FB31 /* ElementAncestorIterator.h in Headers */,
E440AA961C68420800A265CC /* ElementAndTextDescendantIterator.h in Headers */,
+ 7119465624181EA100466C11 /* ElementAnimationRareData.h in Headers */,
E46A2B1E17CA76B1000DBCD8 /* ElementChildIterator.h in Headers */,
313BCE1C235E3BE500FC39E5 /* ElementContext.h in Headers */,
B5B7A17117C10AC000E4AA0A /* ElementData.h in Headers */,
@@ -30431,7 +30441,6 @@
07E9E12E18F5E2760011A3A4 /* InbandMetadataTextTrackPrivateAVF.h in Headers */,
07941792166E855F009416C2 /* InbandTextTrack.h in Headers */,
07941794166EA04E009416C2 /* InbandTextTrackPrivate.h in Headers */,
- CD8D306F23AD4FA8006C3975 /* CDMLogging.h in Headers */,
07B442D7166C70B000556CAD /* InbandTextTrackPrivateAVF.h in Headers */,
07AA6B6C166D2C1300D45671 /* InbandTextTrackPrivateAVFObjC.h in Headers */,
07CE77D516712A6A00C55A47 /* InbandTextTrackPrivateClient.h in Headers */,
@@ -33027,6 +33036,7 @@
AA478A7F16CD70C3007D1BB4 /* WebAccessibilityObjectWrapperMac.h in Headers */,
2D3EF4481917915C00034184 /* WebActionDisablingCALayerDelegate.h in Headers */,
71025ED31F99F0CE004A250C /* WebAnimation.h in Headers */,
+ 7108EEE62418ED5A005C3DA7 /* WebAnimationTypes.h in Headers */,
7132445120109DA500AE7FB2 /* WebAnimationUtilities.h in Headers */,
E18536841F4E481400FE091B /* WebArchiveResourceFromNSAttributedString.h in Headers */,
E18C35441F71970C00FF632D /* WebArchiveResourceWebResourceHandler.h in Headers */,
Modified: trunk/Source/WebCore/animation/AnimationPlaybackEventInit.h (258315 => 258316)
--- trunk/Source/WebCore/animation/AnimationPlaybackEventInit.h 2020-03-12 07:08:21 UTC (rev 258315)
+++ trunk/Source/WebCore/animation/AnimationPlaybackEventInit.h 2020-03-12 07:48:06 UTC (rev 258316)
@@ -26,7 +26,7 @@
#pragma once
#include "EventInit.h"
-#include "WebAnimationUtilities.h"
+#include "WebAnimationTypes.h"
namespace WebCore {
Modified: trunk/Source/WebCore/animation/AnimationTimeline.cpp (258315 => 258316)
--- trunk/Source/WebCore/animation/AnimationTimeline.cpp 2020-03-12 07:08:21 UTC (rev 258315)
+++ trunk/Source/WebCore/animation/AnimationTimeline.cpp 2020-03-12 07:48:06 UTC (rev 258316)
@@ -101,53 +101,29 @@
void AnimationTimeline::animationWasAddedToElement(WebAnimation& animation, Element& element)
{
- [&] () -> ElementToAnimationsMap& {
- if (is<CSSTransition>(animation) && downcast<CSSTransition>(animation).owningElement())
- return m_elementToCSSTransitionsMap;
- if (is<CSSAnimation>(animation) && downcast<CSSAnimation>(animation).owningElement())
- return m_elementToCSSAnimationsMap;
- return m_elementToAnimationsMap;
- }().ensure(&element, [] {
- return AnimationCollection { };
- }).iterator->value.add(&animation);
+ if (is<CSSTransition>(animation) && downcast<CSSTransition>(animation).owningElement() == &element)
+ element.transitions().add(&animation);
+ else if (is<CSSAnimation>(animation) && downcast<CSSAnimation>(animation).owningElement() == &element)
+ element.cssAnimations().add(&animation);
+ else
+ element.webAnimations().add(&animation);
}
-static inline bool removeCSSTransitionFromMap(CSSTransition& transition, Element& element, HashMap<Element*, AnimationTimeline::PropertyToTransitionMap>& map)
+static inline bool removeCSSTransitionFromMap(CSSTransition& transition, PropertyToTransitionMap& cssTransitionsByProperty)
{
- auto iterator = map.find(&element);
- if (iterator == map.end())
- return false;
-
- auto& cssTransitionsByProperty = iterator->value;
-
auto transitionIterator = cssTransitionsByProperty.find(transition.property());
if (transitionIterator == cssTransitionsByProperty.end() || transitionIterator->value != &transition)
return false;
cssTransitionsByProperty.remove(transitionIterator);
-
- if (cssTransitionsByProperty.isEmpty())
- map.remove(&element);
return true;
}
-static inline void removeAnimationFromMapForElement(WebAnimation& animation, AnimationTimeline::ElementToAnimationsMap& map, Element& element)
-{
- auto iterator = map.find(&element);
- if (iterator == map.end())
- return;
-
- auto& animations = iterator->value;
- animations.remove(&animation);
- if (!animations.size())
- map.remove(iterator);
-}
-
void AnimationTimeline::animationWasRemovedFromElement(WebAnimation& animation, Element& element)
{
- removeAnimationFromMapForElement(animation, m_elementToCSSTransitionsMap, element);
- removeAnimationFromMapForElement(animation, m_elementToCSSAnimationsMap, element);
- removeAnimationFromMapForElement(animation, m_elementToAnimationsMap, element);
+ element.transitions().remove(&animation);
+ element.cssAnimations().remove(&animation);
+ element.webAnimations().remove(&animation);
// Now, if we're dealing with a CSS Transition, we remove it from the m_elementToRunningCSSTransitionByCSSPropertyID map.
// We don't need to do this for CSS Animations because their timing can be set via CSS to end, which would cause this
@@ -163,8 +139,8 @@
if (is<CSSTransition>(animation)) {
auto& transition = downcast<CSSTransition>(animation);
- if (!removeCSSTransitionFromMap(transition, element, m_elementToRunningCSSTransitionByCSSPropertyID))
- removeCSSTransitionFromMap(transition, element, m_elementToCompletedCSSTransitionByCSSPropertyID);
+ if (!removeCSSTransitionFromMap(transition, element.runningTransitionsByProperty()))
+ removeCSSTransitionFromMap(transition, element.completedTransitionByProperty());
}
}
@@ -178,18 +154,12 @@
animations.append(effect->animation());
}
} else {
- if (m_elementToCSSTransitionsMap.contains(&element)) {
- const auto& cssTransitions = m_elementToCSSTransitionsMap.get(&element);
- animations.appendRange(cssTransitions.begin(), cssTransitions.end());
- }
- if (m_elementToCSSAnimationsMap.contains(&element)) {
- const auto& cssAnimations = m_elementToCSSAnimationsMap.get(&element);
- animations.appendRange(cssAnimations.begin(), cssAnimations.end());
- }
- if (m_elementToAnimationsMap.contains(&element)) {
- const auto& webAnimations = m_elementToAnimationsMap.get(&element);
- animations.appendRange(webAnimations.begin(), webAnimations.end());
- }
+ const auto& cssTransitions = element.transitions();
+ animations.appendRange(cssTransitions.begin(), cssTransitions.end());
+ const auto& cssAnimations = element.cssAnimations();
+ animations.appendRange(cssAnimations.begin(), cssAnimations.end());
+ const auto& webAnimations = element.webAnimations();
+ animations.appendRange(webAnimations.begin(), webAnimations.end());
}
return animations;
@@ -197,13 +167,7 @@
void AnimationTimeline::removeCSSAnimationCreatedByMarkup(Element& element, CSSAnimation& cssAnimation)
{
- auto iterator = m_elementToCSSAnimationsCreatedByMarkupMap.find(&element);
- if (iterator != m_elementToCSSAnimationsCreatedByMarkupMap.end()) {
- auto& cssAnimations = iterator->value;
- cssAnimations.remove(&cssAnimation);
- if (!cssAnimations.size())
- m_elementToCSSAnimationsCreatedByMarkupMap.remove(iterator);
- }
+ element.animationsCreatedByMarkup().remove(&cssAnimation);
if (!element.hasKeyframeEffects())
return;
@@ -226,10 +190,10 @@
void AnimationTimeline::willDestroyRendererForElement(Element& element)
{
- for (auto& cssTransition : m_elementToCSSTransitionsMap.get(&element))
+ for (auto& cssTransition : element.transitions())
cssTransition->cancel(WebAnimation::Silently::Yes);
- for (auto& cssAnimation : m_elementToCSSAnimationsMap.get(&element)) {
+ for (auto& cssAnimation : element.cssAnimations()) {
if (is<CSSAnimation>(cssAnimation))
removeCSSAnimationCreatedByMarkup(element, downcast<CSSAnimation>(*cssAnimation));
cssAnimation->cancel(WebAnimation::Silently::Yes);
@@ -239,12 +203,6 @@
void AnimationTimeline::elementWasRemoved(Element& element)
{
willDestroyRendererForElement(element);
-
- m_elementToAnimationsMap.remove(&element);
- m_elementToCSSAnimationsMap.remove(&element);
- m_elementToCSSTransitionsMap.remove(&element);
- m_elementToRunningCSSTransitionByCSSPropertyID.remove(&element);
- m_elementToCSSAnimationsCreatedByMarkupMap.remove(&element);
}
void AnimationTimeline::removeAnimationsForElement(Element& element)
@@ -261,9 +219,9 @@
void AnimationTimeline::cancelDeclarativeAnimationsForElement(Element& element)
{
- for (auto& cssTransition : m_elementToCSSTransitionsMap.get(&element))
+ for (auto& cssTransition : element.transitions())
cssTransition->cancel();
- for (auto& cssAnimation : m_elementToCSSAnimationsMap.get(&element)) {
+ for (auto& cssAnimation : element.cssAnimations()) {
if (is<CSSAnimation>(cssAnimation))
removeCSSAnimationCreatedByMarkup(element, downcast<CSSAnimation>(*cssAnimation));
cssAnimation->cancel();
@@ -293,13 +251,8 @@
// In case this element is newly getting a "display: none" we need to cancel all of its animations and disregard new ones.
if (currentStyle && currentStyle->display() != DisplayType::None && afterChangeStyle.display() == DisplayType::None) {
- auto iterator = m_elementToCSSAnimationsCreatedByMarkupMap.find(&element);
- if (iterator != m_elementToCSSAnimationsCreatedByMarkupMap.end()) {
- auto& cssAnimations = iterator->value;
- for (auto& cssAnimation : cssAnimations)
- cssAnimation->cancelFromStyle();
- m_elementToCSSAnimationsCreatedByMarkupMap.remove(iterator);
- }
+ for (auto& cssAnimation : element.animationsCreatedByMarkup())
+ cssAnimation->cancelFromStyle();
keyframeEffectStack.setCSSAnimationList(nullptr);
return;
}
@@ -310,9 +263,7 @@
return;
CSSAnimationCollection newAnimations;
- auto& previousAnimations = m_elementToCSSAnimationsCreatedByMarkupMap.ensure(&element, [] {
- return CSSAnimationCollection { };
- }).iterator->value;
+ auto& previousAnimations = element.animationsCreatedByMarkup();
// https://www.w3.org/TR/css-animations-1/#animations
// The same @keyframes rule name may be repeated within an animation-name. Changes to the animation-name update existing
@@ -356,10 +307,7 @@
}
}
- if (newAnimations.isEmpty())
- m_elementToCSSAnimationsCreatedByMarkupMap.remove(&element);
- else
- m_elementToCSSAnimationsCreatedByMarkupMap.set(&element, WTFMove(newAnimations));
+ element.setAnimationsCreatedByMarkup(WTFMove(newAnimations));
keyframeEffectStack.setCSSAnimationList(currentAnimationList);
}
@@ -377,7 +325,7 @@
return nullptr;
}
-static bool propertyInStyleMatchesValueForTransitionInMap(CSSPropertyID property, const RenderStyle& style, AnimationTimeline::PropertyToTransitionMap& transitions)
+static bool propertyInStyleMatchesValueForTransitionInMap(CSSPropertyID property, const RenderStyle& style, PropertyToTransitionMap& transitions)
{
if (auto* transition = transitions.get(property)) {
if (CSSPropertyAnimation::propertiesEqual(property, &style, &transition->targetStyle()))
@@ -410,13 +358,6 @@
return true;
}
-AnimationTimeline::PropertyToTransitionMap& AnimationTimeline::ensureRunningTransitionsByProperty(Element& element)
-{
- return m_elementToRunningCSSTransitionByCSSPropertyID.ensure(&element, [] {
- return PropertyToTransitionMap { };
- }).iterator->value;
-}
-
static void compileTransitionPropertiesInStyle(const RenderStyle& style, HashSet<CSSPropertyID>& transitionProperties, bool& transitionPropertiesContainAll)
{
if (transitionPropertiesContainAll)
@@ -444,7 +385,7 @@
}
}
-void AnimationTimeline::updateCSSTransitionsForElementAndProperty(Element& element, CSSPropertyID property, const RenderStyle& currentStyle, const RenderStyle& afterChangeStyle, AnimationTimeline::PropertyToTransitionMap& runningTransitionsByProperty, PropertyToTransitionMap& completedTransitionsByProperty, const MonotonicTime generationTime)
+void AnimationTimeline::updateCSSTransitionsForElementAndProperty(Element& element, CSSPropertyID property, const RenderStyle& currentStyle, const RenderStyle& afterChangeStyle, PropertyToTransitionMap& runningTransitionsByProperty, PropertyToTransitionMap& completedTransitionsByProperty, const MonotonicTime generationTime)
{
const Animation* matchingBackingAnimation = nullptr;
if (auto* transitions = afterChangeStyle.transitions()) {
@@ -574,7 +515,7 @@
auto delay = matchingBackingAnimation->delay() < 0 ? Seconds(matchingBackingAnimation->delay()) * reversingShorteningFactor : Seconds(matchingBackingAnimation->delay());
auto duration = Seconds(matchingBackingAnimation->duration()) * reversingShorteningFactor;
- ensureRunningTransitionsByProperty(element).set(property, CSSTransition::create(element, property, generationTime, *matchingBackingAnimation, &previouslyRunningTransitionCurrentStyle, afterChangeStyle, delay, duration, reversingAdjustedStartStyle, reversingShorteningFactor));
+ element.runningTransitionsByProperty().set(property, CSSTransition::create(element, property, generationTime, *matchingBackingAnimation, &previouslyRunningTransitionCurrentStyle, afterChangeStyle, delay, duration, reversingAdjustedStartStyle, reversingShorteningFactor));
} else {
// 4. Otherwise, implementations must cancel the running transition
previouslyRunningTransition->cancelFromStyle();
@@ -590,7 +531,7 @@
auto duration = Seconds(matchingBackingAnimation->duration());
auto& reversingAdjustedStartStyle = currentStyle;
auto reversingShorteningFactor = 1;
- ensureRunningTransitionsByProperty(element).set(property, CSSTransition::create(element, property, generationTime, *matchingBackingAnimation, &previouslyRunningTransitionCurrentStyle, afterChangeStyle, delay, duration, reversingAdjustedStartStyle, reversingShorteningFactor));
+ element.runningTransitionsByProperty().set(property, CSSTransition::create(element, property, generationTime, *matchingBackingAnimation, &previouslyRunningTransitionCurrentStyle, afterChangeStyle, delay, duration, reversingAdjustedStartStyle, reversingShorteningFactor));
}
}
}
@@ -599,10 +540,9 @@
{
// In case this element is newly getting a "display: none" we need to cancel all of its transitions and disregard new ones.
if (currentStyle.hasTransitions() && currentStyle.display() != DisplayType::None && afterChangeStyle.display() == DisplayType::None) {
- if (m_elementToRunningCSSTransitionByCSSPropertyID.contains(&element)) {
- for (const auto& cssTransitionsByCSSPropertyIDMapItem : m_elementToRunningCSSTransitionByCSSPropertyID.take(&element))
- cssTransitionsByCSSPropertyIDMapItem.value->cancelFromStyle();
- }
+ auto runningTransitions = element.runningTransitionsByProperty();
+ for (const auto& cssTransitionsByCSSPropertyIDMapItem : runningTransitions)
+ cssTransitionsByCSSPropertyIDMapItem.value->cancelFromStyle();
return;
}
@@ -609,12 +549,9 @@
// Section 3 "Starting of transitions" from the CSS Transitions Level 1 specification.
// https://drafts.csswg.org/css-transitions-1/#starting
- auto& runningTransitionsByProperty = ensureRunningTransitionsByProperty(element);
+ auto& runningTransitionsByProperty = element.runningTransitionsByProperty();
+ auto& completedTransitionsByProperty = element.completedTransitionByProperty();
- auto& completedTransitionsByProperty = m_elementToCompletedCSSTransitionByCSSPropertyID.ensure(&element, [] {
- return PropertyToTransitionMap { };
- }).iterator->value;
-
auto generationTime = MonotonicTime::now();
// First, let's compile the list of all CSS properties found in the current style and the after-change style.
Modified: trunk/Source/WebCore/animation/AnimationTimeline.h (258315 => 258316)
--- trunk/Source/WebCore/animation/AnimationTimeline.h 2020-03-12 07:08:21 UTC (rev 258315)
+++ trunk/Source/WebCore/animation/AnimationTimeline.h 2020-03-12 07:48:06 UTC (rev 258316)
@@ -75,10 +75,6 @@
void updateCSSAnimationsForElement(Element&, const RenderStyle* currentStyle, const RenderStyle& afterChangeStyle);
void updateCSSTransitionsForElement(Element&, const RenderStyle& currentStyle, const RenderStyle& afterChangeStyle);
- using AnimationCollection = ListHashSet<RefPtr<WebAnimation>>;
- using ElementToAnimationsMap = HashMap<Element*, AnimationCollection>;
- using PropertyToTransitionMap = HashMap<CSSPropertyID, RefPtr<CSSTransition>>;
-
virtual ~AnimationTimeline();
protected:
@@ -86,23 +82,12 @@
Vector<WeakPtr<WebAnimation>> m_allAnimations;
AnimationCollection m_animations;
- HashMap<Element*, PropertyToTransitionMap> m_elementToCompletedCSSTransitionByCSSPropertyID;
private:
- using CSSAnimationCollection = ListHashSet<RefPtr<CSSAnimation>>;
- using ElementToCSSAnimationsMap = HashMap<Element*, CSSAnimationCollection>;
-
void updateGlobalPosition(WebAnimation&);
- PropertyToTransitionMap& ensureRunningTransitionsByProperty(Element&);
void updateCSSTransitionsForElementAndProperty(Element&, CSSPropertyID, const RenderStyle& currentStyle, const RenderStyle& afterChangeStyle, PropertyToTransitionMap&, PropertyToTransitionMap&, const MonotonicTime);
void removeCSSAnimationCreatedByMarkup(Element&, CSSAnimation&);
- ElementToAnimationsMap m_elementToAnimationsMap;
- ElementToAnimationsMap m_elementToCSSAnimationsMap;
- ElementToAnimationsMap m_elementToCSSTransitionsMap;
- ElementToCSSAnimationsMap m_elementToCSSAnimationsCreatedByMarkupMap;
- HashMap<Element*, PropertyToTransitionMap> m_elementToRunningCSSTransitionByCSSPropertyID;
-
Markable<Seconds, Seconds::MarkableTraits> m_currentTime;
};
Modified: trunk/Source/WebCore/animation/ComputedEffectTiming.h (258315 => 258316)
--- trunk/Source/WebCore/animation/ComputedEffectTiming.h 2020-03-12 07:08:21 UTC (rev 258315)
+++ trunk/Source/WebCore/animation/ComputedEffectTiming.h 2020-03-12 07:48:06 UTC (rev 258316)
@@ -27,7 +27,7 @@
#include "AnimationEffectPhase.h"
#include "EffectTiming.h"
-#include "WebAnimationUtilities.h"
+#include "WebAnimationTypes.h"
namespace WebCore {
Modified: trunk/Source/WebCore/animation/DocumentTimeline.cpp (258315 => 258316)
--- trunk/Source/WebCore/animation/DocumentTimeline.cpp 2020-03-12 07:08:21 UTC (rev 258315)
+++ trunk/Source/WebCore/animation/DocumentTimeline.cpp 2020-03-12 07:48:06 UTC (rev 258316)
@@ -546,11 +546,8 @@
ASSERT(transition);
removeAnimation(*transition);
if (is<KeyframeEffect>(transition->effect())) {
- if (auto* target = downcast<KeyframeEffect>(transition->effect())->target()) {
- m_elementToCompletedCSSTransitionByCSSPropertyID.ensure(target, [] {
- return HashMap<CSSPropertyID, RefPtr<CSSTransition>> { };
- }).iterator->value.set(transition->property(), transition);
- }
+ if (auto* target = downcast<KeyframeEffect>(transition->effect())->target())
+ target->completedTransitionByProperty().set(transition->property(), transition);
}
}
Copied: trunk/Source/WebCore/animation/ElementAnimationRareData.cpp (from rev 258315, trunk/Source/WebCore/animation/ComputedEffectTiming.h) (0 => 258316)
--- trunk/Source/WebCore/animation/ElementAnimationRareData.cpp (rev 0)
+++ trunk/Source/WebCore/animation/ElementAnimationRareData.cpp 2020-03-12 07:48:06 UTC (rev 258316)
@@ -0,0 +1,48 @@
+/*
+ * Copyright (C) 2020 Apple Inc. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY APPLE INC. ``AS IS'' AND ANY
+ * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR
+ * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
+ * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
+ * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
+ * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
+ * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+ * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#include "config.h"
+#include "ElementAnimationRareData.h"
+
+#include "KeyframeEffectStack.h"
+
+namespace WebCore {
+
+ElementAnimationRareData::ElementAnimationRareData()
+{
+}
+
+ElementAnimationRareData::~ElementAnimationRareData()
+{
+}
+
+KeyframeEffectStack& ElementAnimationRareData::ensureKeyframeEffectStack()
+{
+ if (!m_keyframeEffectStack)
+ m_keyframeEffectStack = makeUnique<KeyframeEffectStack>();
+ return *m_keyframeEffectStack.get();
+}
+
+} // namespace WebCore
Added: trunk/Source/WebCore/animation/ElementAnimationRareData.h (0 => 258316)
--- trunk/Source/WebCore/animation/ElementAnimationRareData.h (rev 0)
+++ trunk/Source/WebCore/animation/ElementAnimationRareData.h 2020-03-12 07:48:06 UTC (rev 258316)
@@ -0,0 +1,67 @@
+/*
+ * Copyright (C) 2020 Apple Inc. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY APPLE INC. ``AS IS'' AND ANY
+ * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR
+ * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
+ * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
+ * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
+ * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
+ * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+ * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#pragma once
+
+#include "KeyframeEffectStack.h"
+#include "WebAnimationTypes.h"
+
+namespace WebCore {
+
+class CSSAnimation;
+class CSSTransition;
+class WebAnimation;
+
+class ElementAnimationRareData {
+ WTF_MAKE_NONCOPYABLE(ElementAnimationRareData);
+ WTF_MAKE_FAST_ALLOCATED;
+public:
+ explicit ElementAnimationRareData();
+ ~ElementAnimationRareData();
+
+ KeyframeEffectStack* keyframeEffectStack() { return m_keyframeEffectStack.get(); }
+ KeyframeEffectStack& ensureKeyframeEffectStack();
+
+ AnimationCollection& webAnimations() { return m_webAnimations; }
+ AnimationCollection& cssAnimations() { return m_cssAnimations; }
+ AnimationCollection& transitions() { return m_transitions; }
+ CSSAnimationCollection& animationsCreatedByMarkup() { return m_animationsCreatedByMarkup; }
+ void setAnimationsCreatedByMarkup(CSSAnimationCollection&& animations) { m_animationsCreatedByMarkup = WTFMove(animations); }
+ PropertyToTransitionMap& completedTransitionByProperty() { return m_completedTransitionByProperty; }
+ PropertyToTransitionMap& runningTransitionsByProperty() { return m_runningTransitionsByProperty; }
+
+private:
+
+ std::unique_ptr<KeyframeEffectStack> m_keyframeEffectStack;
+ AnimationCollection m_webAnimations;
+ AnimationCollection m_cssAnimations;
+ AnimationCollection m_transitions;
+ CSSAnimationCollection m_animationsCreatedByMarkup;
+ PropertyToTransitionMap m_completedTransitionByProperty;
+ PropertyToTransitionMap m_runningTransitionsByProperty;
+};
+
+} // namespace WebCore
+
Modified: trunk/Source/WebCore/animation/KeyframeEffect.h (258315 => 258316)
--- trunk/Source/WebCore/animation/KeyframeEffect.h 2020-03-12 07:08:21 UTC (rev 258315)
+++ trunk/Source/WebCore/animation/KeyframeEffect.h 2020-03-12 07:48:06 UTC (rev 258316)
@@ -37,7 +37,7 @@
#include "KeyframeList.h"
#include "RenderStyle.h"
#include "StyleProperties.h"
-#include "WebAnimationUtilities.h"
+#include "WebAnimationTypes.h"
#include <wtf/Ref.h>
namespace WebCore {
Modified: trunk/Source/WebCore/animation/OptionalEffectTiming.h (258315 => 258316)
--- trunk/Source/WebCore/animation/OptionalEffectTiming.h 2020-03-12 07:08:21 UTC (rev 258315)
+++ trunk/Source/WebCore/animation/OptionalEffectTiming.h 2020-03-12 07:48:06 UTC (rev 258316)
@@ -27,7 +27,7 @@
#include "FillMode.h"
#include "PlaybackDirection.h"
-#include "WebAnimationUtilities.h"
+#include "WebAnimationTypes.h"
#include <wtf/Variant.h>
#include <wtf/text/WTFString.h>
Modified: trunk/Source/WebCore/animation/WebAnimation.h (258315 => 258316)
--- trunk/Source/WebCore/animation/WebAnimation.h 2020-03-12 07:08:21 UTC (rev 258315)
+++ trunk/Source/WebCore/animation/WebAnimation.h 2020-03-12 07:48:06 UTC (rev 258316)
@@ -30,7 +30,7 @@
#include "EventTarget.h"
#include "ExceptionOr.h"
#include "IDLTypes.h"
-#include "WebAnimationUtilities.h"
+#include "WebAnimationTypes.h"
#include <wtf/Forward.h>
#include <wtf/Markable.h>
#include <wtf/Optional.h>
Copied: trunk/Source/WebCore/animation/WebAnimationTypes.h (from rev 258315, trunk/Source/WebCore/animation/WebAnimationUtilities.h) (0 => 258316)
--- trunk/Source/WebCore/animation/WebAnimationTypes.h (rev 0)
+++ trunk/Source/WebCore/animation/WebAnimationTypes.h 2020-03-12 07:48:06 UTC (rev 258316)
@@ -0,0 +1,60 @@
+/*
+ * Copyright (C) 2020 Apple Inc. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY APPLE INC. ``AS IS'' AND ANY
+ * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR
+ * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
+ * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
+ * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
+ * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
+ * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+ * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#pragma once
+
+#include "CSSValue.h"
+#include <wtf/HashMap.h>
+#include <wtf/ListHashSet.h>
+#include <wtf/Markable.h>
+
+namespace WebCore {
+
+class AnimationList;
+class CSSAnimation;
+class CSSTransition;
+class WebAnimation;
+
+struct WebAnimationsMarkableDoubleTraits {
+ static bool isEmptyValue(double value)
+ {
+ return std::isnan(value);
+ }
+
+ static constexpr double emptyValue()
+ {
+ return std::numeric_limits<double>::quiet_NaN();
+ }
+};
+
+using MarkableDouble = Markable<double, WebAnimationsMarkableDoubleTraits>;
+
+using AnimationCollection = ListHashSet<RefPtr<WebAnimation>>;
+using PropertyToTransitionMap = HashMap<CSSPropertyID, RefPtr<CSSTransition>>;
+using CSSAnimationCollection = ListHashSet<RefPtr<CSSAnimation>>;
+
+} // namespace WebCore
+
+
Modified: trunk/Source/WebCore/animation/WebAnimationUtilities.h (258315 => 258316)
--- trunk/Source/WebCore/animation/WebAnimationUtilities.h 2020-03-12 07:08:21 UTC (rev 258315)
+++ trunk/Source/WebCore/animation/WebAnimationUtilities.h 2020-03-12 07:48:06 UTC (rev 258316)
@@ -50,20 +50,6 @@
const auto timeEpsilon = Seconds::fromMilliseconds(0.001);
-struct WebAnimationsMarkableDoubleTraits {
- static bool isEmptyValue(double value)
- {
- return std::isnan(value);
- }
-
- static constexpr double emptyValue()
- {
- return std::numeric_limits<double>::quiet_NaN();
- }
-};
-
-using MarkableDouble = Markable<double, WebAnimationsMarkableDoubleTraits>;
-
bool compareAnimationsByCompositeOrder(WebAnimation&, WebAnimation&, const AnimationList*);
} // namespace WebCore
Modified: trunk/Source/WebCore/dom/Element.cpp (258315 => 258316)
--- trunk/Source/WebCore/dom/Element.cpp 2020-03-12 07:08:21 UTC (rev 258315)
+++ trunk/Source/WebCore/dom/Element.cpp 2020-03-12 07:48:06 UTC (rev 258316)
@@ -46,6 +46,7 @@
#include "DocumentSharedObjectPool.h"
#include "DocumentTimeline.h"
#include "Editing.h"
+#include "ElementAnimationRareData.h"
#include "ElementIterator.h"
#include "ElementRareData.h"
#include "EventDispatcher.h"
@@ -3738,26 +3739,35 @@
#endif
+ElementAnimationRareData* Element::animationRareData() const
+{
+ return hasRareData() ? elementRareData()->elementAnimationRareData() : nullptr;
+}
+
+ElementAnimationRareData& Element::ensureAnimationRareData()
+{
+ return ensureElementRareData().ensureAnimationRareData();
+}
+
KeyframeEffectStack* Element::keyframeEffectStack() const
{
- return hasRareData() ? elementRareData()->keyframeEffectStack() : nullptr;
+ if (auto* animationData = animationRareData())
+ return animationData->keyframeEffectStack();
+ return nullptr;
}
KeyframeEffectStack& Element::ensureKeyframeEffectStack()
{
- auto& rareData = ensureElementRareData();
- if (!rareData.keyframeEffectStack())
- rareData.setKeyframeEffectStack(makeUnique<KeyframeEffectStack>());
- return *rareData.keyframeEffectStack();
+ return ensureAnimationRareData().ensureKeyframeEffectStack();
}
bool Element::hasKeyframeEffects() const
{
- if (!hasRareData())
- return false;
-
- auto* keyframeEffectStack = elementRareData()->keyframeEffectStack();
- return keyframeEffectStack && keyframeEffectStack->hasEffects();
+ if (auto* animationData = animationRareData()) {
+ if (auto* keyframeEffectStack = animationData->keyframeEffectStack())
+ return keyframeEffectStack->hasEffects();
+ }
+ return false;
}
OptionSet<AnimationImpact> Element::applyKeyframeEffects(RenderStyle& targetStyle)
@@ -3778,6 +3788,41 @@
return impact;
}
+AnimationCollection& Element::webAnimations()
+{
+ return ensureAnimationRareData().webAnimations();
+}
+
+AnimationCollection& Element::cssAnimations()
+{
+ return ensureAnimationRareData().cssAnimations();
+}
+
+AnimationCollection& Element::transitions()
+{
+ return ensureAnimationRareData().transitions();
+}
+
+CSSAnimationCollection& Element::animationsCreatedByMarkup()
+{
+ return ensureAnimationRareData().animationsCreatedByMarkup();
+}
+
+void Element::setAnimationsCreatedByMarkup(CSSAnimationCollection&& animations)
+{
+ ensureAnimationRareData().setAnimationsCreatedByMarkup(WTFMove(animations));
+}
+
+PropertyToTransitionMap& Element::completedTransitionByProperty()
+{
+ return ensureAnimationRareData().completedTransitionByProperty();
+}
+
+PropertyToTransitionMap& Element::runningTransitionsByProperty()
+{
+ return ensureAnimationRareData().runningTransitionsByProperty();
+}
+
#if ENABLE(RESIZE_OBSERVER)
void Element::disconnectFromResizeObservers()
Modified: trunk/Source/WebCore/dom/Element.h (258315 => 258316)
--- trunk/Source/WebCore/dom/Element.h 2020-03-12 07:08:21 UTC (rev 258315)
+++ trunk/Source/WebCore/dom/Element.h 2020-03-12 07:48:06 UTC (rev 258316)
@@ -32,6 +32,7 @@
#include "ShadowRootMode.h"
#include "SimulatedClickOptions.h"
#include "StyleChange.h"
+#include "WebAnimationTypes.h"
#include <_javascript_Core/Strong.h>
namespace WebCore {
@@ -41,6 +42,7 @@
class DOMRect;
class DOMRectList;
class DOMTokenList;
+class ElementAnimationRareData;
class ElementRareData;
class Frame;
class HTMLDocument;
@@ -491,6 +493,14 @@
bool hasKeyframeEffects() const;
OptionSet<AnimationImpact> applyKeyframeEffects(RenderStyle&);
+ AnimationCollection& webAnimations();
+ AnimationCollection& cssAnimations();
+ AnimationCollection& transitions();
+ CSSAnimationCollection& animationsCreatedByMarkup();
+ void setAnimationsCreatedByMarkup(CSSAnimationCollection&&);
+ PropertyToTransitionMap& completedTransitionByProperty();
+ PropertyToTransitionMap& runningTransitionsByProperty();
+
#if ENABLE(FULLSCREEN_API)
WEBCORE_EXPORT bool containsFullScreenElement() const;
void setContainsFullScreenElement(bool);
@@ -705,6 +715,9 @@
ElementRareData* elementRareData() const;
ElementRareData& ensureElementRareData();
+ ElementAnimationRareData* animationRareData() const;
+ ElementAnimationRareData& ensureAnimationRareData();
+
virtual int defaultTabIndex() const;
void detachAllAttrNodesFromElement();
Modified: trunk/Source/WebCore/dom/ElementRareData.h (258315 => 258316)
--- trunk/Source/WebCore/dom/ElementRareData.h 2020-03-12 07:08:21 UTC (rev 258315)
+++ trunk/Source/WebCore/dom/ElementRareData.h 2020-03-12 07:48:06 UTC (rev 258316)
@@ -24,6 +24,7 @@
#include "CustomElementReactionQueue.h"
#include "DOMTokenList.h"
#include "DatasetDOMStringMap.h"
+#include "ElementAnimationRareData.h"
#include "IntersectionObserver.h"
#include "KeyframeEffectStack.h"
#include "NamedNodeMap.h"
@@ -101,8 +102,8 @@
bool hasCSSAnimation() const { return m_hasCSSAnimation; }
void setHasCSSAnimation(bool value) { m_hasCSSAnimation = value; }
- KeyframeEffectStack* keyframeEffectStack() { return m_keyframeEffectStack.get(); }
- void setKeyframeEffectStack(std::unique_ptr<KeyframeEffectStack>&& keyframeEffectStack) { m_keyframeEffectStack = WTFMove(keyframeEffectStack); }
+ ElementAnimationRareData* elementAnimationRareData() { return m_animationRareData.get(); }
+ ElementAnimationRareData& ensureAnimationRareData();
bool hasElementIdentifier() const { return m_hasElementIdentifier; }
void setHasElementIdentifier(bool value) { m_hasElementIdentifier = value; }
@@ -158,6 +159,8 @@
#endif
if (m_beforePseudoElement || m_afterPseudoElement)
result.add(UseType::PseudoElements);
+ if (m_animationRareData)
+ result.add(UseType::Animations);
return result;
}
#endif
@@ -190,7 +193,7 @@
std::unique_ptr<ResizeObserverData> m_resizeObserverData;
#endif
- std::unique_ptr<KeyframeEffectStack> m_keyframeEffectStack;
+ std::unique_ptr<ElementAnimationRareData> m_animationRareData;
RefPtr<PseudoElement> m_beforePseudoElement;
RefPtr<PseudoElement> m_afterPseudoElement;
@@ -249,4 +252,11 @@
setChildIndex(0);
}
+inline ElementAnimationRareData& ElementRareData::ensureAnimationRareData()
+{
+ if (!m_animationRareData)
+ m_animationRareData = makeUnique<ElementAnimationRareData>();
+ return *m_animationRareData.get();
+}
+
} // namespace WebCore
Modified: trunk/Source/WebCore/dom/Node.cpp (258315 => 258316)
--- trunk/Source/WebCore/dom/Node.cpp 2020-03-12 07:08:21 UTC (rev 258315)
+++ trunk/Source/WebCore/dom/Node.cpp 2020-03-12 07:48:06 UTC (rev 258316)
@@ -128,6 +128,8 @@
return "InteractionObserver";
case NodeRareData::UseType::PseudoElements:
return "PseudoElements";
+ case NodeRareData::UseType::Animations:
+ return "Animations";
}
return nullptr;
}
Modified: trunk/Source/WebCore/dom/NodeRareData.h (258315 => 258316)
--- trunk/Source/WebCore/dom/NodeRareData.h 2020-03-12 07:08:21 UTC (rev 258315)
+++ trunk/Source/WebCore/dom/NodeRareData.h 2020-03-12 07:48:06 UTC (rev 258316)
@@ -248,7 +248,6 @@
ConnectedFrameCount = 1 << 0,
NodeList = 1 << 1,
MutationObserver = 1 << 2,
-
TabIndex = 1 << 3,
MinimumSize = 1 << 4,
ScrollingPosition = 1 << 5,
@@ -260,6 +259,7 @@
AttributeMap = 1 << 11,
InteractionObserver = 1 << 12,
PseudoElements = 1 << 13,
+ Animations = 1 << 14,
};
#endif