haikuwebkit/Source/WebCore/animation/ElementAnimationRareData.cpp

58 lines
2.0 KiB
C++
Raw Permalink Normal View History

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: Canonical link: https://commits.webkit.org/221886@main git-svn-id: https://svn.webkit.org/repository/webkit/trunk@258316 268f45cc-cd09-0410-ab3c-d52691b4dbfc
2020-03-12 07:48:06 +00:00
/*
* 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"
DocumentTimeline / CSSTransition objects are leaking on CNN.com https://bugs.webkit.org/show_bug.cgi?id=208069 <rdar://problem/59680143> Reviewed by Simon Fraser, Geoffrey Garen and Darin Adler. Source/WebCore: Test: webanimations/leak-css-animation.html We add a test feature that lets use query the availability of a given WebAnimation by its "id" property in the WebAnimation::instances list. We also fix some build issues that appeared with a change in UnifiedSources order. * animation/ElementAnimationRareData.cpp: (WebCore::ElementAnimationRareData::setAnimationsCreatedByMarkup): * animation/ElementAnimationRareData.h: (WebCore::ElementAnimationRareData::setAnimationsCreatedByMarkup): Deleted. * animation/WebAnimation.h: * testing/Internals.cpp: (WebCore::Internals::animationWithIdExists const): * testing/Internals.h: * testing/Internals.idl: Source/WTF: If a CSSAnimation is set on an element using the `animation-name` CSS property, and later removed, it will leak due to the ListHashSet<RefPtr<CSSAnimation>> (aka CSSAnimationCollection) member on ElementAnimationRareData being replaced to the new list, but the old list not being cleared from its members. We fix the ListHashSet assignment operator to use swap ensuring previously held items are cleared. * wtf/ListHashSet.h: (WTF::=): Tools: Add a test that checks that a ListHashSet containing RefPtr<> types correctly calls the destructor for those items when the assignment operator is used. * TestWebKitAPI/Tests/WTF/ListHashSet.cpp: (TestWebKitAPI::ListHashSetReferencedItem::create): (TestWebKitAPI::ListHashSetReferencedItem::ListHashSetReferencedItem): (TestWebKitAPI::ListHashSetReferencedItem::~ListHashSetReferencedItem): (TestWebKitAPI::FakeElementAnimationRareData::FakeElementAnimationRareData): (TestWebKitAPI::FakeElementAnimationRareData::~FakeElementAnimationRareData): (TestWebKitAPI::FakeElementAnimationRareData::collection): (TestWebKitAPI::FakeElementAnimationRareData::setCollection): (TestWebKitAPI::TEST): LayoutTests: Add a test that checks that setting a CSSAnimation on an element, waiting a frame, and removing it will not leak that CSSAnimation. * webanimations/leak-css-animation-expected.txt: Added. * webanimations/leak-css-animation.html: Added. * webanimations/resources/css-animation-leak-iframe.html: Added. Canonical link: https://commits.webkit.org/222331@main git-svn-id: https://svn.webkit.org/repository/webkit/trunk@258826 268f45cc-cd09-0410-ab3c-d52691b4dbfc
2020-03-23 08:17:26 +00:00
#include "CSSAnimation.h"
#include "CSSTransition.h"
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: Canonical link: https://commits.webkit.org/221886@main git-svn-id: https://svn.webkit.org/repository/webkit/trunk@258316 268f45cc-cd09-0410-ab3c-d52691b4dbfc
2020-03-12 07:48:06 +00:00
#include "KeyframeEffectStack.h"
#include "RenderStyle.h"
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: Canonical link: https://commits.webkit.org/221886@main git-svn-id: https://svn.webkit.org/repository/webkit/trunk@258316 268f45cc-cd09-0410-ab3c-d52691b4dbfc
2020-03-12 07:48:06 +00:00
namespace WebCore {
Reduce the reliance on PseudoElement in the animation code https://bugs.webkit.org/show_bug.cgi?id=216931 LayoutTests/imported/w3c: Reviewed by Antti Koivisto. Mark a WPT test progression. * web-platform-tests/css/css-transitions/non-rendered-element-002-expected.txt: Source/WebCore: <rdar://problem/69511682> Reviewed by Antti Koivisto. We have so far relied on PseudoElement as a foundation for supporting animations of pseudo-elements. This is not a great choice since PseudoElement is currently limited to ::before and ::after pseudo-elements only. This patch refactors animation-related code to rely on PseudoElement as little as possible without making changes outside of the animation code, as a first step towards supporting animation of more pseudo-elements. This patch introduces a new struct Styleable which combines an Element& and PseudoId. We use this struct instead of Element objects wherever necessary in the animation code. On top of that, we add a PseudoId parameter to all the Element methods wrapping access to ElementAnimationRareData and use a HashMap<PseudoId, std::unique_ptr<ElementAnimationRareData>> to be able to separate animation data per pseudo-element. * Headers.cmake: * WebCore.xcodeproj/project.pbxproj: * animation/AnimationTimeline.cpp: (WebCore::AnimationTimeline::removeAnimation): (WebCore::AnimationTimeline::animationWasAddedToStyleable): (WebCore::AnimationTimeline::animationWasRemovedFromStyleable): (WebCore::AnimationTimeline::removeDeclarativeAnimationFromListsForOwningElement): (WebCore::AnimationTimeline::removeCSSAnimationCreatedByMarkup): (WebCore::AnimationTimeline::elementWasRemoved): (WebCore::AnimationTimeline::willChangeRendererForStyleable): (WebCore::AnimationTimeline::cancelDeclarativeAnimationsForStyleable): (WebCore::shouldConsiderAnimation): (WebCore::AnimationTimeline::updateCSSAnimationsForStyleable): (WebCore::keyframeEffectForElementAndProperty): (WebCore::AnimationTimeline::updateCSSTransitionsForStyleableAndProperty): (WebCore::AnimationTimeline::updateCSSTransitionsForStyleable): (WebCore::AnimationTimeline::animationWasAddedToElement): Deleted. (WebCore::AnimationTimeline::animationWasRemovedFromElement): Deleted. (WebCore::AnimationTimeline::willChangeRendererForElement): Deleted. (WebCore::AnimationTimeline::cancelDeclarativeAnimationsForElement): Deleted. (WebCore::AnimationTimeline::updateCSSAnimationsForElement): Deleted. (WebCore::AnimationTimeline::updateCSSTransitionsForElementAndProperty): Deleted. (WebCore::AnimationTimeline::updateCSSTransitionsForElement): Deleted. * animation/AnimationTimeline.h: * animation/CSSAnimation.cpp: (WebCore::CSSAnimation::create): (WebCore::CSSAnimation::CSSAnimation): * animation/CSSAnimation.h: * animation/CSSTransition.cpp: (WebCore::CSSTransition::create): (WebCore::CSSTransition::CSSTransition): * animation/CSSTransition.h: * animation/DeclarativeAnimation.cpp: (WebCore::DeclarativeAnimation::DeclarativeAnimation): (WebCore::DeclarativeAnimation::owningElement const): (WebCore::DeclarativeAnimation::disassociateFromOwningElement): (WebCore::DeclarativeAnimation::initialize): (WebCore::DeclarativeAnimation::enqueueDOMEvent): * animation/DeclarativeAnimation.h: * animation/DocumentTimeline.cpp: (WebCore::DocumentTimeline::animationCanBeRemoved): (WebCore::DocumentTimeline::transitionDidComplete): (WebCore::DocumentTimeline::computeExtentOfAnimation const): (WebCore::DocumentTimeline::isRunningAnimationOnRenderer const): (WebCore::DocumentTimeline::isRunningAcceleratedAnimationOnRenderer const): (WebCore::DocumentTimeline::animatedStyleForRenderer): (WebCore::DocumentTimeline::runningAnimationsForRendererAreAllAccelerated const): (WebCore::DocumentTimeline::runningAnimationsForElementAreAllAccelerated const): Deleted. * animation/DocumentTimeline.h: * animation/ElementAnimationRareData.cpp: (WebCore::ElementAnimationRareData::ElementAnimationRareData): * animation/ElementAnimationRareData.h: (WebCore::ElementAnimationRareData::pseudoId const): * animation/KeyframeEffect.cpp: (WebCore::elementOrPseudoElementForStyleable): (WebCore::invalidateElement): (WebCore::KeyframeEffect::animationTimelineDidChange): (WebCore::KeyframeEffect::updateEffectStackMembership): (WebCore::KeyframeEffect::targetStyleable const): (WebCore::KeyframeEffect::setTarget): (WebCore::KeyframeEffect::setPseudoElement): (WebCore::KeyframeEffect::didChangeTargetStyleable): (WebCore::KeyframeEffect::invalidate): (WebCore::KeyframeEffect::applyPendingAcceleratedActions): (WebCore::KeyframeEffect::didChangeTargetElementOrPseudoElement): Deleted. * animation/KeyframeEffect.h: * animation/KeyframeEffectStack.cpp: (WebCore::KeyframeEffectStack::addEffect): * animation/WebAnimation.cpp: (WebCore::WebAnimation::setEffectInternal): (WebCore::WebAnimation::setTimeline): (WebCore::WebAnimation::effectTargetDidChange): (WebCore::WebAnimation::persist): (WebCore::WebAnimation::commitStyles): * animation/WebAnimation.h: * animation/WebAnimationUtilities.cpp: (WebCore::compareDeclarativeAnimationOwningElementPositionsInDocumentTreeOrder): (WebCore::compareCSSTransitions): (WebCore::compareCSSAnimations): * dom/Element.cpp: (WebCore::Element::removedFromAncestor): (WebCore::Element::animationRareData const): (WebCore::Element::ensureAnimationRareData): (WebCore::Element::keyframeEffectStack const): (WebCore::Element::ensureKeyframeEffectStack): (WebCore::Element::hasKeyframeEffects const): (WebCore::Element::applyKeyframeEffects): (WebCore::Element::animations const): (WebCore::Element::hasCompletedTransitionsForProperty const): (WebCore::Element::hasRunningTransitionsForProperty const): (WebCore::Element::hasRunningTransitions const): (WebCore::Element::ensureAnimations): (WebCore::Element::animationsCreatedByMarkup): (WebCore::Element::setAnimationsCreatedByMarkup): (WebCore::Element::ensureCompletedTransitionsByProperty): (WebCore::Element::ensureRunningTransitionsByProperty): (WebCore::Element::lastStyleChangeEventStyle const): (WebCore::Element::setLastStyleChangeEventStyle): (WebCore::Element::getAnimations): * dom/Element.h: * dom/ElementRareData.cpp: * dom/ElementRareData.h: (WebCore::ElementRareData::useTypes const): (WebCore::ElementRareData::animationRareData const): (WebCore::ElementRareData::ensureAnimationRareData): (WebCore::ElementRareData::elementAnimationRareData): Deleted. * dom/PseudoElement.cpp: (WebCore::PseudoElement::clearHostElement): (WebCore::PseudoElement::isTargetedByKeyframeEffectRequiringPseudoElement): * rendering/RenderBoxModelObject.cpp: (WebCore::RenderBoxModelObject::hasRunningAcceleratedAnimations const): * rendering/RenderLayerCompositor.cpp: (WebCore::RenderLayerCompositor::requiresCompositingForAnimation const): (WebCore::RenderLayerCompositor::isRunningTransformAnimation const): * rendering/style/RenderStyleConstants.cpp: (WebCore::operator<<): * rendering/updating/RenderTreeUpdater.cpp: (WebCore::RenderTreeUpdater::tearDownRenderers): * style/StyleTreeResolver.cpp: (WebCore::Style::TreeResolver::resolveElement): (WebCore::Style::TreeResolver::resolvePseudoStyle): (WebCore::Style::TreeResolver::createAnimatedElementUpdate): * style/StyleTreeResolver.h: * style/Styleable.h: Added. (WebCore::Styleable::Styleable): (WebCore::Styleable::fromElement): (WebCore::Styleable::fromRenderer): (WebCore::Styleable::operator== const): (WebCore::Styleable::operator!= const): (WebCore::Styleable::keyframeEffectStack const): (WebCore::Styleable::ensureKeyframeEffectStack const): (WebCore::Styleable::hasKeyframeEffects const): (WebCore::Styleable::applyKeyframeEffects const): (WebCore::Styleable::animations const): (WebCore::Styleable::hasCompletedTransitionsForProperty const): (WebCore::Styleable::hasRunningTransitionsForProperty const): (WebCore::Styleable::hasRunningTransitions const): (WebCore::Styleable::ensureAnimations const): (WebCore::Styleable::ensureCompletedTransitionsByProperty const): (WebCore::Styleable::ensureRunningTransitionsByProperty const): (WebCore::Styleable::animationsCreatedByMarkup const): (WebCore::Styleable::setAnimationsCreatedByMarkup const): (WebCore::Styleable::lastStyleChangeEventStyle const): (WebCore::Styleable::setLastStyleChangeEventStyle const): LayoutTests: <rdar://problem/69511682> Reviewed by Antti Koivisto. Update a couple of tests which relied on an internals method to get a pseudo element and instead use the Web Animations API to determine whether a given animation targets a pseudo-element. This has the added benefit of having the same code run in a testing environment as in a regular browser. * fast/css-generated-content/pseudo-animation.html: * fast/css-generated-content/pseudo-transition.html: Canonical link: https://commits.webkit.org/229750@main git-svn-id: https://svn.webkit.org/repository/webkit/trunk@267571 268f45cc-cd09-0410-ab3c-d52691b4dbfc
2020-09-25 15:22:00 +00:00
ElementAnimationRareData::ElementAnimationRareData(PseudoId pseudoId)
: m_pseudoId(pseudoId)
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: Canonical link: https://commits.webkit.org/221886@main git-svn-id: https://svn.webkit.org/repository/webkit/trunk@258316 268f45cc-cd09-0410-ab3c-d52691b4dbfc
2020-03-12 07:48:06 +00:00
{
}
ElementAnimationRareData::~ElementAnimationRareData()
{
}
KeyframeEffectStack& ElementAnimationRareData::ensureKeyframeEffectStack()
{
if (!m_keyframeEffectStack)
m_keyframeEffectStack = makeUnique<KeyframeEffectStack>();
return *m_keyframeEffectStack.get();
}
DocumentTimeline / CSSTransition objects are leaking on CNN.com https://bugs.webkit.org/show_bug.cgi?id=208069 <rdar://problem/59680143> Reviewed by Simon Fraser, Geoffrey Garen and Darin Adler. Source/WebCore: Test: webanimations/leak-css-animation.html We add a test feature that lets use query the availability of a given WebAnimation by its "id" property in the WebAnimation::instances list. We also fix some build issues that appeared with a change in UnifiedSources order. * animation/ElementAnimationRareData.cpp: (WebCore::ElementAnimationRareData::setAnimationsCreatedByMarkup): * animation/ElementAnimationRareData.h: (WebCore::ElementAnimationRareData::setAnimationsCreatedByMarkup): Deleted. * animation/WebAnimation.h: * testing/Internals.cpp: (WebCore::Internals::animationWithIdExists const): * testing/Internals.h: * testing/Internals.idl: Source/WTF: If a CSSAnimation is set on an element using the `animation-name` CSS property, and later removed, it will leak due to the ListHashSet<RefPtr<CSSAnimation>> (aka CSSAnimationCollection) member on ElementAnimationRareData being replaced to the new list, but the old list not being cleared from its members. We fix the ListHashSet assignment operator to use swap ensuring previously held items are cleared. * wtf/ListHashSet.h: (WTF::=): Tools: Add a test that checks that a ListHashSet containing RefPtr<> types correctly calls the destructor for those items when the assignment operator is used. * TestWebKitAPI/Tests/WTF/ListHashSet.cpp: (TestWebKitAPI::ListHashSetReferencedItem::create): (TestWebKitAPI::ListHashSetReferencedItem::ListHashSetReferencedItem): (TestWebKitAPI::ListHashSetReferencedItem::~ListHashSetReferencedItem): (TestWebKitAPI::FakeElementAnimationRareData::FakeElementAnimationRareData): (TestWebKitAPI::FakeElementAnimationRareData::~FakeElementAnimationRareData): (TestWebKitAPI::FakeElementAnimationRareData::collection): (TestWebKitAPI::FakeElementAnimationRareData::setCollection): (TestWebKitAPI::TEST): LayoutTests: Add a test that checks that setting a CSSAnimation on an element, waiting a frame, and removing it will not leak that CSSAnimation. * webanimations/leak-css-animation-expected.txt: Added. * webanimations/leak-css-animation.html: Added. * webanimations/resources/css-animation-leak-iframe.html: Added. Canonical link: https://commits.webkit.org/222331@main git-svn-id: https://svn.webkit.org/repository/webkit/trunk@258826 268f45cc-cd09-0410-ab3c-d52691b4dbfc
2020-03-23 08:17:26 +00:00
void ElementAnimationRareData::setAnimationsCreatedByMarkup(CSSAnimationCollection&& animations)
{
m_animationsCreatedByMarkup = WTFMove(animations);
}
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: Canonical link: https://commits.webkit.org/221886@main git-svn-id: https://svn.webkit.org/repository/webkit/trunk@258316 268f45cc-cd09-0410-ab3c-d52691b4dbfc
2020-03-12 07:48:06 +00:00
} // namespace WebCore