Changeset 267571 in webkit
- Timestamp:
- Sep 25, 2020, 8:22:00 AM (6 years ago)
- Location:
- trunk
- Files:
-
- 1 added
- 37 edited
-
LayoutTests/ChangeLog (modified) (1 diff)
-
LayoutTests/fast/css-generated-content/pseudo-animation.html (modified) (2 diffs)
-
LayoutTests/fast/css-generated-content/pseudo-transition.html (modified) (3 diffs)
-
LayoutTests/imported/w3c/ChangeLog (modified) (1 diff)
-
LayoutTests/imported/w3c/web-platform-tests/css/css-transitions/non-rendered-element-002-expected.txt (modified) (1 diff)
-
Source/WebCore/ChangeLog (modified) (1 diff)
-
Source/WebCore/Headers.cmake (modified) (1 diff)
-
Source/WebCore/WebCore.xcodeproj/project.pbxproj (modified) (7 diffs)
-
Source/WebCore/animation/AnimationTimeline.cpp (modified) (25 diffs)
-
Source/WebCore/animation/AnimationTimeline.h (modified) (4 diffs)
-
Source/WebCore/animation/CSSAnimation.cpp (modified) (3 diffs)
-
Source/WebCore/animation/CSSAnimation.h (modified) (4 diffs)
-
Source/WebCore/animation/CSSTransition.cpp (modified) (3 diffs)
-
Source/WebCore/animation/CSSTransition.h (modified) (4 diffs)
-
Source/WebCore/animation/DeclarativeAnimation.cpp (modified) (5 diffs)
-
Source/WebCore/animation/DeclarativeAnimation.h (modified) (4 diffs)
-
Source/WebCore/animation/DocumentTimeline.cpp (modified) (8 diffs)
-
Source/WebCore/animation/DocumentTimeline.h (modified) (2 diffs)
-
Source/WebCore/animation/ElementAnimationRareData.cpp (modified) (1 diff)
-
Source/WebCore/animation/ElementAnimationRareData.h (modified) (2 diffs)
-
Source/WebCore/animation/KeyframeEffect.cpp (modified) (10 diffs)
-
Source/WebCore/animation/KeyframeEffect.h (modified) (3 diffs)
-
Source/WebCore/animation/KeyframeEffectStack.cpp (modified) (1 diff)
-
Source/WebCore/animation/WebAnimation.cpp (modified) (7 diffs)
-
Source/WebCore/animation/WebAnimation.h (modified) (3 diffs)
-
Source/WebCore/animation/WebAnimationUtilities.cpp (modified) (3 diffs)
-
Source/WebCore/dom/Element.cpp (modified) (5 diffs)
-
Source/WebCore/dom/Element.h (modified) (2 diffs)
-
Source/WebCore/dom/ElementRareData.cpp (modified) (1 diff)
-
Source/WebCore/dom/ElementRareData.h (modified) (4 diffs)
-
Source/WebCore/dom/PseudoElement.cpp (modified) (2 diffs)
-
Source/WebCore/rendering/RenderBoxModelObject.cpp (modified) (1 diff)
-
Source/WebCore/rendering/RenderLayerCompositor.cpp (modified) (2 diffs)
-
Source/WebCore/rendering/style/RenderStyleConstants.cpp (modified) (1 diff)
-
Source/WebCore/rendering/updating/RenderTreeUpdater.cpp (modified) (1 diff)
-
Source/WebCore/style/StyleTreeResolver.cpp (modified) (6 diffs)
-
Source/WebCore/style/StyleTreeResolver.h (modified) (2 diffs)
-
Source/WebCore/style/Styleable.h (added)
Legend:
- Unmodified
- Added
- Removed
-
trunk/LayoutTests/ChangeLog
r267564 r267571 1 2020-09-25 Antoine Quint <graouts@webkit.org> 2 3 Reduce the reliance on PseudoElement in the animation code 4 https://bugs.webkit.org/show_bug.cgi?id=216931 5 <rdar://problem/69511682> 6 7 Reviewed by Antti Koivisto. 8 9 Update a couple of tests which relied on an internals method to get a pseudo element and instead use 10 the Web Animations API to determine whether a given animation targets a pseudo-element. This has the 11 added benefit of having the same code run in a testing environment as in a regular browser. 12 13 * fast/css-generated-content/pseudo-animation.html: 14 * fast/css-generated-content/pseudo-transition.html: 15 1 16 2020-09-25 Alexey Shvayka <shvaikalesh@gmail.com> 2 17 -
trunk/LayoutTests/fast/css-generated-content/pseudo-animation.html
r236541 r267571 79 79 // below and it no longer needs shouldBeCloseTo. 80 80 81 function pauseAnimationAtTimeOnPseudoElement(animationName, time, element, pseudo Id)81 function pauseAnimationAtTimeOnPseudoElement(animationName, time, element, pseudoElement) 82 82 { 83 const pseudoElement = internals.pseudoElement(element, pseudoId); 84 if (!pseudoElement) { 85 console.log("Failed to find pseudo element"); 86 return; 87 } 88 89 const animations = pseudoElement.getAnimations(); 90 for (let animation of animations) { 91 if (animation instanceof CSSAnimation && animation.animationName == animationName && animation.effect.getKeyframes().length) { 83 for (let animation of element.getAnimations({ subtree: true })) { 84 if (animation instanceof CSSAnimation && animation.animationName == animationName && animation.effect.target == element && animation.effect.pseudoElement == pseudoElement) { 92 85 animation.currentTime = time * 1000; 93 86 animation.pause(); … … 100 93 function testAnimation(id) 101 94 { 95 const pseudoElement = `::${id}`; 102 96 var div = document.getElementById(id); 103 97 div.className = 'animate'; 104 98 window.div = div; 105 99 shouldBe('div.offsetWidth', '52'); 106 if (window.internals) { 107 pauseAnimationAtTimeOnPseudoElement('example', 1.0, div, id); 108 shouldBeCloseTo('div.offsetWidth', 20, 1); 109 computedTop = getPseudoComputedTop(id); 110 shouldBeCloseTo('computedTop', 170, 1); 111 pauseAnimationAtTimeOnPseudoElement('example', 2.0, div, id); 112 shouldBeCloseTo('div.offsetWidth', 12, 1); 113 computedTop = getPseudoComputedTop(id); 114 shouldBeCloseTo('computedTop', 200, 1); 115 } else { 116 // This will be flaky, but it's a reasonable approximation for testing 117 // in a browser instead of DRT. 118 setTimeout(function() { 119 window.div = div; 120 shouldBeCloseTo('div.offsetWidth', 20, 1); 121 computedTop = getPseudoComputedTop(id); 122 shouldBeCloseTo('computedTop', 170, 1); 123 }, 1000); 124 setTimeout(function() { 125 window.div = div; 126 shouldBeCloseTo('div.offsetWidth', 12, 1); 127 computedTop = getPseudoComputedTop(id); 128 shouldBeCloseTo('computedTop', 200, 1); 129 }, 2000); 130 } 100 101 pauseAnimationAtTimeOnPseudoElement('example', 1.0, div, pseudoElement); 102 shouldBeCloseTo('div.offsetWidth', 20, 1); 103 computedTop = getPseudoComputedTop(id); 104 shouldBeCloseTo('computedTop', 170, 1); 105 pauseAnimationAtTimeOnPseudoElement('example', 2.0, div, pseudoElement); 106 shouldBeCloseTo('div.offsetWidth', 12, 1); 107 computedTop = getPseudoComputedTop(id); 108 shouldBeCloseTo('computedTop', 200, 1); 131 109 } 132 110 -
trunk/LayoutTests/fast/css-generated-content/pseudo-transition.html
r236541 r267571 57 57 const propertiesRequiringPrefix = ["-webkit-text-stroke-color", "-webkit-text-fill-color"]; 58 58 59 function pauseTransitionAtTimeOnPseudoElement(transitionProperty, time, element, pseudo Id)59 function pauseTransitionAtTimeOnPseudoElement(transitionProperty, time, element, pseudoElement) 60 60 { 61 const pseudoElement = internals.pseudoElement(element, pseudoId);62 if (!pseudoElement) {63 console.log("Failed to find pseudo element");64 return;65 }66 67 61 if (transitionProperty.startsWith(prefix) && !propertiesRequiringPrefix.includes(transitionProperty)) 68 62 transitionProperty = transitionProperty.substr(prefix.length); 69 63 70 // Otherwise, use the Web Animations API. 71 const animations = pseudoElement.getAnimations(); 72 for (let animation of animations) { 73 if (animation instanceof CSSTransition && animation.transitionProperty == transitionProperty) { 64 for (let animation of element.getAnimations({ subtree: true })) { 65 if (animation instanceof CSSTransition && animation.transitionProperty == transitionProperty && animation.effect.target == element && animation.effect.pseudoElement == pseudoElement) { 74 66 animation.currentTime = time * 1000; 75 67 animation.pause(); … … 77 69 } 78 70 } 71 79 72 console.log(`A transition for property ${transitionProperty} could not be found`); 80 73 return false; … … 83 76 function testTransition(id) 84 77 { 78 const pseudoElement = `::${id}`; 85 79 var div = document.getElementById(id); 86 80 div.className = 'transition'; 87 81 window.div = div; 88 82 shouldBe('div.offsetWidth', '52'); 89 if (window.internals) { 90 pauseTransitionAtTimeOnPseudoElement('width', 1.0, div, id); 91 shouldBeCloseTo('div.offsetWidth', 20, 1); 92 pauseTransitionAtTimeOnPseudoElement('top', 1.0, div, id); 93 computedTop = getPseudoComputedTop(id); 94 shouldBeCloseTo('computedTop', 170, 1); 95 pauseTransitionAtTimeOnPseudoElement('width', 2.0, div, id); 96 shouldBeCloseTo('div.offsetWidth', 12, 1); 97 pauseTransitionAtTimeOnPseudoElement('top', 2.0, div, id); 98 computedTop = getPseudoComputedTop(id); 99 shouldBeCloseTo('computedTop', 200, 1); 100 } else { 101 // This will be flaky, but it's a reasonable approximation for testing 102 // in a browser instead of DRT. 103 setTimeout(function() { 104 window.div = div; 105 shouldBeCloseTo('div.offsetWidth', 20, 1); 106 computedTop = getPseudoComputedTop(id); 107 shouldBeCloseTo('computedTop', 170, 1); 108 }, 1000); 109 setTimeout(function() { 110 window.div = div; 111 shouldBeCloseTo('div.offsetWidth', 12, 1); 112 computedTop = getPseudoComputedTop(id); 113 shouldBeCloseTo('computedTop', 200, 1); 114 }, 2000); 115 } 83 84 pauseTransitionAtTimeOnPseudoElement('width', 1.0, div, pseudoElement); 85 shouldBeCloseTo('div.offsetWidth', 20, 1); 86 pauseTransitionAtTimeOnPseudoElement('top', 1.0, div, pseudoElement); 87 computedTop = getPseudoComputedTop(id); 88 shouldBeCloseTo('computedTop', 170, 1); 89 pauseTransitionAtTimeOnPseudoElement('width', 2.0, div, pseudoElement); 90 shouldBeCloseTo('div.offsetWidth', 12, 1); 91 pauseTransitionAtTimeOnPseudoElement('top', 2.0, div, pseudoElement); 92 computedTop = getPseudoComputedTop(id); 93 shouldBeCloseTo('computedTop', 200, 1); 116 94 } 117 95 -
trunk/LayoutTests/imported/w3c/ChangeLog
r267570 r267571 1 2020-09-25 Antoine Quint <graouts@webkit.org> 2 3 Reduce the reliance on PseudoElement in the animation code 4 https://bugs.webkit.org/show_bug.cgi?id=216931 5 6 Reviewed by Antti Koivisto. 7 8 Mark a WPT test progression. 9 10 * web-platform-tests/css/css-transitions/non-rendered-element-002-expected.txt: 11 1 12 2020-09-25 Antoine Quint <graouts@webkit.org> 2 13 -
trunk/LayoutTests/imported/w3c/web-platform-tests/css/css-transitions/non-rendered-element-002-expected.txt
r264522 r267571 1 1 2 Harness Error (TIMEOUT), message = null 2 PASS Transitions on ::before/::after pseudo-elements are canceled when the content property is cleared 3 3 4 TIMEOUT Transitions on ::before/::after pseudo-elements are canceled when the content property is cleared Test timed out5 -
trunk/Source/WebCore/ChangeLog
r267566 r267571 1 2020-09-25 Antoine Quint <graouts@webkit.org> 2 3 Reduce the reliance on PseudoElement in the animation code 4 https://bugs.webkit.org/show_bug.cgi?id=216931 5 <rdar://problem/69511682> 6 7 Reviewed by Antti Koivisto. 8 9 We have so far relied on PseudoElement as a foundation for supporting animations of pseudo-elements. This is not a 10 great choice since PseudoElement is currently limited to ::before and ::after pseudo-elements only. This patch 11 refactors animation-related code to rely on PseudoElement as little as possible without making changes outside 12 of the animation code, as a first step towards supporting animation of more pseudo-elements. 13 14 This patch introduces a new struct Styleable which combines an Element& and PseudoId. We use this struct instead 15 of Element objects wherever necessary in the animation code. On top of that, we add a PseudoId parameter to all the 16 Element methods wrapping access to ElementAnimationRareData and use a HashMap<PseudoId, std::unique_ptr<ElementAnimationRareData>> 17 to be able to separate animation data per pseudo-element. 18 19 * Headers.cmake: 20 * WebCore.xcodeproj/project.pbxproj: 21 * animation/AnimationTimeline.cpp: 22 (WebCore::AnimationTimeline::removeAnimation): 23 (WebCore::AnimationTimeline::animationWasAddedToStyleable): 24 (WebCore::AnimationTimeline::animationWasRemovedFromStyleable): 25 (WebCore::AnimationTimeline::removeDeclarativeAnimationFromListsForOwningElement): 26 (WebCore::AnimationTimeline::removeCSSAnimationCreatedByMarkup): 27 (WebCore::AnimationTimeline::elementWasRemoved): 28 (WebCore::AnimationTimeline::willChangeRendererForStyleable): 29 (WebCore::AnimationTimeline::cancelDeclarativeAnimationsForStyleable): 30 (WebCore::shouldConsiderAnimation): 31 (WebCore::AnimationTimeline::updateCSSAnimationsForStyleable): 32 (WebCore::keyframeEffectForElementAndProperty): 33 (WebCore::AnimationTimeline::updateCSSTransitionsForStyleableAndProperty): 34 (WebCore::AnimationTimeline::updateCSSTransitionsForStyleable): 35 (WebCore::AnimationTimeline::animationWasAddedToElement): Deleted. 36 (WebCore::AnimationTimeline::animationWasRemovedFromElement): Deleted. 37 (WebCore::AnimationTimeline::willChangeRendererForElement): Deleted. 38 (WebCore::AnimationTimeline::cancelDeclarativeAnimationsForElement): Deleted. 39 (WebCore::AnimationTimeline::updateCSSAnimationsForElement): Deleted. 40 (WebCore::AnimationTimeline::updateCSSTransitionsForElementAndProperty): Deleted. 41 (WebCore::AnimationTimeline::updateCSSTransitionsForElement): Deleted. 42 * animation/AnimationTimeline.h: 43 * animation/CSSAnimation.cpp: 44 (WebCore::CSSAnimation::create): 45 (WebCore::CSSAnimation::CSSAnimation): 46 * animation/CSSAnimation.h: 47 * animation/CSSTransition.cpp: 48 (WebCore::CSSTransition::create): 49 (WebCore::CSSTransition::CSSTransition): 50 * animation/CSSTransition.h: 51 * animation/DeclarativeAnimation.cpp: 52 (WebCore::DeclarativeAnimation::DeclarativeAnimation): 53 (WebCore::DeclarativeAnimation::owningElement const): 54 (WebCore::DeclarativeAnimation::disassociateFromOwningElement): 55 (WebCore::DeclarativeAnimation::initialize): 56 (WebCore::DeclarativeAnimation::enqueueDOMEvent): 57 * animation/DeclarativeAnimation.h: 58 * animation/DocumentTimeline.cpp: 59 (WebCore::DocumentTimeline::animationCanBeRemoved): 60 (WebCore::DocumentTimeline::transitionDidComplete): 61 (WebCore::DocumentTimeline::computeExtentOfAnimation const): 62 (WebCore::DocumentTimeline::isRunningAnimationOnRenderer const): 63 (WebCore::DocumentTimeline::isRunningAcceleratedAnimationOnRenderer const): 64 (WebCore::DocumentTimeline::animatedStyleForRenderer): 65 (WebCore::DocumentTimeline::runningAnimationsForRendererAreAllAccelerated const): 66 (WebCore::DocumentTimeline::runningAnimationsForElementAreAllAccelerated const): Deleted. 67 * animation/DocumentTimeline.h: 68 * animation/ElementAnimationRareData.cpp: 69 (WebCore::ElementAnimationRareData::ElementAnimationRareData): 70 * animation/ElementAnimationRareData.h: 71 (WebCore::ElementAnimationRareData::pseudoId const): 72 * animation/KeyframeEffect.cpp: 73 (WebCore::elementOrPseudoElementForStyleable): 74 (WebCore::invalidateElement): 75 (WebCore::KeyframeEffect::animationTimelineDidChange): 76 (WebCore::KeyframeEffect::updateEffectStackMembership): 77 (WebCore::KeyframeEffect::targetStyleable const): 78 (WebCore::KeyframeEffect::setTarget): 79 (WebCore::KeyframeEffect::setPseudoElement): 80 (WebCore::KeyframeEffect::didChangeTargetStyleable): 81 (WebCore::KeyframeEffect::invalidate): 82 (WebCore::KeyframeEffect::applyPendingAcceleratedActions): 83 (WebCore::KeyframeEffect::didChangeTargetElementOrPseudoElement): Deleted. 84 * animation/KeyframeEffect.h: 85 * animation/KeyframeEffectStack.cpp: 86 (WebCore::KeyframeEffectStack::addEffect): 87 * animation/WebAnimation.cpp: 88 (WebCore::WebAnimation::setEffectInternal): 89 (WebCore::WebAnimation::setTimeline): 90 (WebCore::WebAnimation::effectTargetDidChange): 91 (WebCore::WebAnimation::persist): 92 (WebCore::WebAnimation::commitStyles): 93 * animation/WebAnimation.h: 94 * animation/WebAnimationUtilities.cpp: 95 (WebCore::compareDeclarativeAnimationOwningElementPositionsInDocumentTreeOrder): 96 (WebCore::compareCSSTransitions): 97 (WebCore::compareCSSAnimations): 98 * dom/Element.cpp: 99 (WebCore::Element::removedFromAncestor): 100 (WebCore::Element::animationRareData const): 101 (WebCore::Element::ensureAnimationRareData): 102 (WebCore::Element::keyframeEffectStack const): 103 (WebCore::Element::ensureKeyframeEffectStack): 104 (WebCore::Element::hasKeyframeEffects const): 105 (WebCore::Element::applyKeyframeEffects): 106 (WebCore::Element::animations const): 107 (WebCore::Element::hasCompletedTransitionsForProperty const): 108 (WebCore::Element::hasRunningTransitionsForProperty const): 109 (WebCore::Element::hasRunningTransitions const): 110 (WebCore::Element::ensureAnimations): 111 (WebCore::Element::animationsCreatedByMarkup): 112 (WebCore::Element::setAnimationsCreatedByMarkup): 113 (WebCore::Element::ensureCompletedTransitionsByProperty): 114 (WebCore::Element::ensureRunningTransitionsByProperty): 115 (WebCore::Element::lastStyleChangeEventStyle const): 116 (WebCore::Element::setLastStyleChangeEventStyle): 117 (WebCore::Element::getAnimations): 118 * dom/Element.h: 119 * dom/ElementRareData.cpp: 120 * dom/ElementRareData.h: 121 (WebCore::ElementRareData::useTypes const): 122 (WebCore::ElementRareData::animationRareData const): 123 (WebCore::ElementRareData::ensureAnimationRareData): 124 (WebCore::ElementRareData::elementAnimationRareData): Deleted. 125 * dom/PseudoElement.cpp: 126 (WebCore::PseudoElement::clearHostElement): 127 (WebCore::PseudoElement::isTargetedByKeyframeEffectRequiringPseudoElement): 128 * rendering/RenderBoxModelObject.cpp: 129 (WebCore::RenderBoxModelObject::hasRunningAcceleratedAnimations const): 130 * rendering/RenderLayerCompositor.cpp: 131 (WebCore::RenderLayerCompositor::requiresCompositingForAnimation const): 132 (WebCore::RenderLayerCompositor::isRunningTransformAnimation const): 133 * rendering/style/RenderStyleConstants.cpp: 134 (WebCore::operator<<): 135 * rendering/updating/RenderTreeUpdater.cpp: 136 (WebCore::RenderTreeUpdater::tearDownRenderers): 137 * style/StyleTreeResolver.cpp: 138 (WebCore::Style::TreeResolver::resolveElement): 139 (WebCore::Style::TreeResolver::resolvePseudoStyle): 140 (WebCore::Style::TreeResolver::createAnimatedElementUpdate): 141 * style/StyleTreeResolver.h: 142 * style/Styleable.h: Added. 143 (WebCore::Styleable::Styleable): 144 (WebCore::Styleable::fromElement): 145 (WebCore::Styleable::fromRenderer): 146 (WebCore::Styleable::operator== const): 147 (WebCore::Styleable::operator!= const): 148 (WebCore::Styleable::keyframeEffectStack const): 149 (WebCore::Styleable::ensureKeyframeEffectStack const): 150 (WebCore::Styleable::hasKeyframeEffects const): 151 (WebCore::Styleable::applyKeyframeEffects const): 152 (WebCore::Styleable::animations const): 153 (WebCore::Styleable::hasCompletedTransitionsForProperty const): 154 (WebCore::Styleable::hasRunningTransitionsForProperty const): 155 (WebCore::Styleable::hasRunningTransitions const): 156 (WebCore::Styleable::ensureAnimations const): 157 (WebCore::Styleable::ensureCompletedTransitionsByProperty const): 158 (WebCore::Styleable::ensureRunningTransitionsByProperty const): 159 (WebCore::Styleable::animationsCreatedByMarkup const): 160 (WebCore::Styleable::setAnimationsCreatedByMarkup const): 161 (WebCore::Styleable::lastStyleChangeEventStyle const): 162 (WebCore::Styleable::setLastStyleChangeEventStyle const): 163 1 164 2020-09-25 Youenn Fablet <youenn@apple.com> 2 165 -
trunk/Source/WebCore/Headers.cmake
r267565 r267571 1495 1495 style/StyleUpdate.h 1496 1496 style/StyleValidity.h 1497 style/Styleable.h 1497 1498 1498 1499 svg/SVGLengthContext.h -
trunk/Source/WebCore/WebCore.xcodeproj/project.pbxproj
r267565 r267571 2124 2124 7132445120109DA500AE7FB2 /* WebAnimationUtilities.h in Headers */ = {isa = PBXBuildFile; fileRef = 7132444F20109D9B00AE7FB2 /* WebAnimationUtilities.h */; settings = {ATTRIBUTES = (Private, ); }; }; 2125 2125 7134496E146941B300720312 /* SVGLengthContext.h in Headers */ = {isa = PBXBuildFile; fileRef = 7134496C146941B300720312 /* SVGLengthContext.h */; settings = {ATTRIBUTES = (Private, ); }; }; 2126 713922BE2518AB77005DB3C2 /* Styleable.h in Headers */ = {isa = PBXBuildFile; fileRef = 713922BC2518AB70005DB3C2 /* Styleable.h */; settings = {ATTRIBUTES = (Private, ); }; }; 2126 2127 713F1D5A23DF1D8D003F5EFA /* GetAnimationsOptions.h in Headers */ = {isa = PBXBuildFile; fileRef = 713F1D5923DF1D7D003F5EFA /* GetAnimationsOptions.h */; settings = {ATTRIBUTES = (Private, ); }; }; 2127 2128 713F1D5D23DF2582003F5EFA /* JSGetAnimationsOptions.h in Headers */ = {isa = PBXBuildFile; fileRef = 713F1D5B23DF2560003F5EFA /* JSGetAnimationsOptions.h */; }; … … 9739 9740 7134496B146941B300720312 /* SVGLengthContext.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = SVGLengthContext.cpp; sourceTree = "<group>"; }; 9740 9741 7134496C146941B300720312 /* SVGLengthContext.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = SVGLengthContext.h; sourceTree = "<group>"; }; 9742 713922BC2518AB70005DB3C2 /* Styleable.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = Styleable.h; sourceTree = "<group>"; }; 9741 9743 713E70AF1733E8B300A22D00 /* plugIns.js */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.javascript; path = plugIns.js; sourceTree = "<group>"; }; 9742 9744 713F1D5723DF1D7D003F5EFA /* GetAnimationsOptions.idl */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text; path = GetAnimationsOptions.idl; sourceTree = "<group>"; }; … … 28380 28382 A79BAD9F161E7F3F00C2E652 /* RuleSet.cpp */, 28381 28383 A79BADA0161E7F3F00C2E652 /* RuleSet.h */, 28384 713922BC2518AB70005DB3C2 /* Styleable.h */, 28382 28385 E45BA6B22376227E004DFC07 /* StyleAdjuster.cpp */, 28383 28386 E45BA6B52376229F004DFC07 /* StyleAdjuster.h */, … … 32746 32749 6F0B98B523F268EC00EEC2F2 /* LayoutInlineTextBox.h in Headers */, 32747 32750 E418025523D4549B00FFB071 /* LayoutIntegrationBoxTree.h in Headers */, 32751 E403B7A2251B11930019E800 /* LayoutIntegrationCoverage.h in Headers */, 32748 32752 E4ABABDD236088FE00FA4345 /* LayoutIntegrationLineLayout.h in Headers */, 32753 E403B7A3251B11C10019E800 /* LayoutIntegrationPagination.h in Headers */, 32749 32754 11310CF420BA4A3D0065A8D0 /* LayoutIterator.h in Headers */, 32750 32755 6FFA4C0123F2FED9007E4EBC /* LayoutLineBreakBox.h in Headers */, … … 32791 32796 AB31C91E10AE1B8E000C7B92 /* LineClampValue.h in Headers */, 32792 32797 FFEFAB2A18380DA000514534 /* LineLayoutState.h in Headers */, 32793 E403B7A2251B11930019E800 /* LayoutIntegrationCoverage.h in Headers */,32794 32798 E484A33E23055325009ADE6A /* LineLayoutTraversal.h in Headers */, 32795 32799 E4343D252392779000EBBB66 /* LineLayoutTraversalComplexPath.h in Headers */, … … 33659 33663 1400D7A817136EA70077CE05 /* ScriptWrappableInlines.h in Headers */, 33660 33664 BC8AE34F12EA096A00EB3AE6 /* ScrollableArea.h in Headers */, 33661 E403B7A3251B11C10019E800 /* LayoutIntegrationPagination.h in Headers */,33662 33665 5D925B680F64D4DD00B847F0 /* ScrollAlignment.h in Headers */, 33663 33666 CA3BF67E10D99BAE00E6CE53 /* ScrollAnimator.h in Headers */, … … 33892 33895 849F77760EFEC6200090849D /* StrokeStyleApplier.h in Headers */, 33893 33896 414B82051D6DF0E50077EBE3 /* StructuredClone.h in Headers */, 33897 713922BE2518AB77005DB3C2 /* Styleable.h in Headers */, 33894 33898 E45BA6B6237622A3004DFC07 /* StyleAdjuster.h in Headers */, 33895 33899 BC5EB6A30E81DC4F00B25965 /* StyleBackgroundData.h in Headers */, -
trunk/Source/WebCore/animation/AnimationTimeline.cpp
r267204 r267571 43 43 #include "StylePropertyShorthand.h" 44 44 #include "StyleResolver.h" 45 #include "Styleable.h" 45 46 #include "WebAnimationUtilities.h" 46 47 #include <wtf/text/TextStream.h> … … 81 82 m_animations.remove(&animation); 82 83 if (is<KeyframeEffect>(animation.effect())) { 83 if (auto * target = downcast<KeyframeEffect>(animation.effect())->targetElementOrPseudoElement()) {84 animationWasRemovedFrom Element(animation, *target);85 target->ensureKeyframeEffectStack().removeEffect(*downcast<KeyframeEffect>(animation.effect()));84 if (auto styleable = downcast<KeyframeEffect>(animation.effect())->targetStyleable()) { 85 animationWasRemovedFromStyleable(animation, *styleable); 86 styleable->ensureKeyframeEffectStack().removeEffect(*downcast<KeyframeEffect>(animation.effect())); 86 87 } 87 88 } … … 96 97 } 97 98 98 void AnimationTimeline::animationWasAddedTo Element(WebAnimation& animation, Element& element)99 { 100 element.ensureAnimations().add(&animation);99 void AnimationTimeline::animationWasAddedToStyleable(WebAnimation& animation, const Styleable& styleable) 100 { 101 styleable.ensureAnimations().add(&animation); 101 102 } 102 103 … … 111 112 } 112 113 113 void AnimationTimeline::animationWasRemovedFrom Element(WebAnimation& animation, Element& element)114 { 115 element.ensureAnimations().remove(&animation);114 void AnimationTimeline::animationWasRemovedFromStyleable(WebAnimation& animation, const Styleable& styleable) 115 { 116 styleable.ensureAnimations().remove(&animation); 116 117 117 118 // Now, if we're dealing with a CSS Transition, we remove it from the m_elementToRunningCSSTransitionByCSSPropertyID map. … … 120 121 // to the JS API or changing the target element's animation-name property. 121 122 if (is<CSSTransition>(animation)) 122 removeDeclarativeAnimationFromListsForOwningElement(animation, element);123 } 124 125 void AnimationTimeline::removeDeclarativeAnimationFromListsForOwningElement(WebAnimation& animation, Element& element)123 removeDeclarativeAnimationFromListsForOwningElement(animation, styleable); 124 } 125 126 void AnimationTimeline::removeDeclarativeAnimationFromListsForOwningElement(WebAnimation& animation, const Styleable& styleable) 126 127 { 127 128 ASSERT(is<DeclarativeAnimation>(animation)); … … 129 130 if (is<CSSTransition>(animation)) { 130 131 auto& transition = downcast<CSSTransition>(animation); 131 if (!removeCSSTransitionFromMap(transition, element.ensureRunningTransitionsByProperty()))132 removeCSSTransitionFromMap(transition, element.ensureCompletedTransitionsByProperty());133 } 134 } 135 136 void AnimationTimeline::removeCSSAnimationCreatedByMarkup( Element& element, CSSAnimation& cssAnimation)137 { 138 element.animationsCreatedByMarkup().remove(&cssAnimation);139 140 if (! element.hasKeyframeEffects())141 return; 142 143 auto& keyframeEffectStack = element.ensureKeyframeEffectStack();132 if (!removeCSSTransitionFromMap(transition, styleable.ensureRunningTransitionsByProperty())) 133 removeCSSTransitionFromMap(transition, styleable.ensureCompletedTransitionsByProperty()); 134 } 135 } 136 137 void AnimationTimeline::removeCSSAnimationCreatedByMarkup(const Styleable& styleable, CSSAnimation& cssAnimation) 138 { 139 styleable.animationsCreatedByMarkup().remove(&cssAnimation); 140 141 if (!styleable.hasKeyframeEffects()) 142 return; 143 144 auto& keyframeEffectStack = styleable.ensureKeyframeEffectStack(); 144 145 auto* cssAnimationList = keyframeEffectStack.cssAnimationList(); 145 146 if (!cssAnimationList || cssAnimationList->isEmpty()) … … 157 158 } 158 159 159 void AnimationTimeline::elementWasRemoved( Element& element)160 { 161 cancelDeclarativeAnimationsFor Element(element, WebAnimation::Silently::Yes);162 } 163 164 void AnimationTimeline::willChangeRendererFor Element(Element& element)165 { 166 if (auto* animations = element.animations()) {160 void AnimationTimeline::elementWasRemoved(const Styleable& styleable) 161 { 162 cancelDeclarativeAnimationsForStyleable(styleable, WebAnimation::Silently::Yes); 163 } 164 165 void AnimationTimeline::willChangeRendererForStyleable(const Styleable& styleable) 166 { 167 if (auto* animations = styleable.animations()) { 167 168 for (const auto& animation : *animations) 168 169 animation->willChangeRenderer(); … … 170 171 } 171 172 172 void AnimationTimeline::cancelDeclarativeAnimationsFor Element(Element& element, WebAnimation::Silently silently)173 { 174 if (auto* animations = element.animations()) {173 void AnimationTimeline::cancelDeclarativeAnimationsForStyleable(const Styleable& styleable, WebAnimation::Silently silently) 174 { 175 if (auto* animations = styleable.animations()) { 175 176 for (auto& animation : *animations) { 176 177 if (is<DeclarativeAnimation>(animation)) { 177 178 if (is<CSSAnimation>(animation)) 178 removeCSSAnimationCreatedByMarkup( element, downcast<CSSAnimation>(*animation));179 removeCSSAnimationCreatedByMarkup(styleable, downcast<CSSAnimation>(*animation)); 179 180 animation->cancel(silently); 180 181 } … … 183 184 } 184 185 185 static bool shouldConsiderAnimation(Element& element OrPseudoElement, const Animation& animation)186 static bool shouldConsiderAnimation(Element& element, const Animation& animation) 186 187 { 187 188 if (!animation.isValidAnimation()) … … 194 195 return false; 195 196 196 auto& element = is<PseudoElement>(elementOrPseudoElement) ? *downcast<PseudoElement>(elementOrPseudoElement).hostElement() : elementOrPseudoElement;197 198 197 if (auto* styleScope = Style::Scope::forOrdinal(element, animation.nameStyleScopeOrdinal())) 199 198 return styleScope->resolver().isAnimationNameValid(name); … … 202 201 } 203 202 204 void AnimationTimeline::updateCSSAnimationsFor Element(Element& element, const RenderStyle* currentStyle, const RenderStyle& newStyle)205 { 206 auto& keyframeEffectStack = element.ensureKeyframeEffectStack();203 void AnimationTimeline::updateCSSAnimationsForStyleable(const Styleable& styleable, const RenderStyle* currentStyle, const RenderStyle& newStyle) 204 { 205 auto& keyframeEffectStack = styleable.ensureKeyframeEffectStack(); 207 206 208 207 // In case this element is newly getting a "display: none" we need to cancel all of its animations and disregard new ones. 209 208 if (currentStyle && currentStyle->display() != DisplayType::None && newStyle.display() == DisplayType::None) { 210 for (auto& cssAnimation : element.animationsCreatedByMarkup())209 for (auto& cssAnimation : styleable.animationsCreatedByMarkup()) 211 210 cssAnimation->cancelFromStyle(); 212 211 keyframeEffectStack.setCSSAnimationList(nullptr); … … 220 219 221 220 CSSAnimationCollection newAnimations; 222 auto& previousAnimations = element.animationsCreatedByMarkup();221 auto& previousAnimations = styleable.animationsCreatedByMarkup(); 223 222 224 223 // https://www.w3.org/TR/css-animations-1/#animations … … 234 233 for (size_t i = currentAnimationList->size(); i > 0; --i) { 235 234 auto& currentAnimation = currentAnimationList->animation(i - 1); 236 if (!shouldConsiderAnimation( element, currentAnimation))235 if (!shouldConsiderAnimation(styleable.element, currentAnimation)) 237 236 continue; 238 237 … … 252 251 253 252 if (!foundMatchingAnimation) 254 newAnimations.add(CSSAnimation::create( element, currentAnimation, currentStyle, newStyle));253 newAnimations.add(CSSAnimation::create(styleable, currentAnimation, currentStyle, newStyle)); 255 254 } 256 255 } … … 264 263 } 265 264 266 element.setAnimationsCreatedByMarkup(WTFMove(newAnimations));265 styleable.setAnimationsCreatedByMarkup(WTFMove(newAnimations)); 267 266 268 267 keyframeEffectStack.setCSSAnimationList(currentAnimationList); 269 268 } 270 269 271 static KeyframeEffect* keyframeEffectForElementAndProperty( Element& element, CSSPropertyID property)272 { 273 if (auto* keyframeEffectStack = element.keyframeEffectStack()) {270 static KeyframeEffect* keyframeEffectForElementAndProperty(const Styleable& styleable, CSSPropertyID property) 271 { 272 if (auto* keyframeEffectStack = styleable.keyframeEffectStack()) { 274 273 auto effects = keyframeEffectStack->sortedEffects(); 275 274 for (const auto& effect : makeReversedRange(effects)) { … … 340 339 } 341 340 342 void AnimationTimeline::updateCSSTransitionsFor ElementAndProperty(Element& element, CSSPropertyID property, const RenderStyle& currentStyle, const RenderStyle& newStyle, const MonotonicTime generationTime)343 { 344 auto* keyframeEffect = keyframeEffectForElementAndProperty( element, property);341 void AnimationTimeline::updateCSSTransitionsForStyleableAndProperty(const Styleable& styleable, CSSPropertyID property, const RenderStyle& currentStyle, const RenderStyle& newStyle, const MonotonicTime generationTime) 342 { 343 auto* keyframeEffect = keyframeEffectForElementAndProperty(styleable, property); 345 344 auto* animation = keyframeEffect ? keyframeEffect->animation() : nullptr; 346 bool isDeclarative = animation && is<DeclarativeAnimation>(animation) && downcast<DeclarativeAnimation>(*animation).owningElement() == &element; 345 346 bool isDeclarative = false; 347 if (is<DeclarativeAnimation>(animation)) { 348 if (auto owningElement = downcast<DeclarativeAnimation>(*animation).owningElement()) 349 isDeclarative = *owningElement == styleable; 350 } 351 347 352 if (animation && !isDeclarative) 348 353 return; … … 359 364 // A CSS Transition might have completed since the last time animations were updated so we must 360 365 // update the running and completed transitions membership in that case. 361 if (is<CSSTransition>(animation) && matchingBackingAnimation && element.hasRunningTransitionsForProperty(property) && animation->playState() == WebAnimation::PlayState::Finished) {362 element.ensureCompletedTransitionsByProperty().set(property, element.ensureRunningTransitionsByProperty().take(property));366 if (is<CSSTransition>(animation) && matchingBackingAnimation && styleable.hasRunningTransitionsForProperty(property) && animation->playState() == WebAnimation::PlayState::Finished) { 367 styleable.ensureCompletedTransitionsByProperty().set(property, styleable.ensureRunningTransitionsByProperty().take(property)); 363 368 animation = nullptr; 364 369 } … … 378 383 379 384 // If it exists, use the recorded RenderStyle for this element during a previous call to Style::TreeResolver::createAnimatedElementUpdate(). 380 if (auto* lastStyleChangeEventStyle = element.lastStyleChangeEventStyle())385 if (auto* lastStyleChangeEventStyle = styleable.lastStyleChangeEventStyle()) 381 386 return RenderStyle::clone(*lastStyleChangeEventStyle); 382 387 … … 400 405 }(); 401 406 402 if (! element.hasRunningTransitionsForProperty(property)407 if (!styleable.hasRunningTransitionsForProperty(property) 403 408 && !CSSPropertyAnimation::propertiesEqual(property, &beforeChangeStyle, &afterChangeStyle) 404 409 && CSSPropertyAnimation::canPropertyBeInterpolated(property, &beforeChangeStyle, &afterChangeStyle) 405 && !propertyInStyleMatchesValueForTransitionInMap(property, afterChangeStyle, element.ensureCompletedTransitionsByProperty())410 && !propertyInStyleMatchesValueForTransitionInMap(property, afterChangeStyle, styleable.ensureCompletedTransitionsByProperty()) 406 411 && matchingBackingAnimation && transitionCombinedDuration(matchingBackingAnimation) > 0) { 407 412 // 1. If all of the following are true: … … 413 418 414 419 // then implementations must remove the completed transition (if present) from the set of completed transitions 415 element.ensureCompletedTransitionsByProperty().remove(property);420 styleable.ensureCompletedTransitionsByProperty().remove(property); 416 421 417 422 // and start a transition whose: … … 426 431 auto& reversingAdjustedStartStyle = beforeChangeStyle; 427 432 auto reversingShorteningFactor = 1; 428 element.ensureRunningTransitionsByProperty().set(property, CSSTransition::create(element, property, generationTime, *matchingBackingAnimation, &beforeChangeStyle, afterChangeStyle, delay, duration, reversingAdjustedStartStyle, reversingShorteningFactor));429 } else if ( element.hasCompletedTransitionsForProperty(property) && !propertyInStyleMatchesValueForTransitionInMap(property, afterChangeStyle, element.ensureCompletedTransitionsByProperty())) {433 styleable.ensureRunningTransitionsByProperty().set(property, CSSTransition::create(styleable, property, generationTime, *matchingBackingAnimation, &beforeChangeStyle, afterChangeStyle, delay, duration, reversingAdjustedStartStyle, reversingShorteningFactor)); 434 } else if (styleable.hasCompletedTransitionsForProperty(property) && !propertyInStyleMatchesValueForTransitionInMap(property, afterChangeStyle, styleable.ensureCompletedTransitionsByProperty())) { 430 435 // 2. Otherwise, if the element has a completed transition for the property and the end value of the completed transition is different from 431 436 // the after-change style for the property, then implementations must remove the completed transition from the set of completed transitions. 432 element.ensureCompletedTransitionsByProperty().remove(property);433 } 434 435 bool hasRunningTransition = element.hasRunningTransitionsForProperty(property);436 if ((hasRunningTransition || element.hasCompletedTransitionsForProperty(property)) && !matchingBackingAnimation) {437 styleable.ensureCompletedTransitionsByProperty().remove(property); 438 } 439 440 bool hasRunningTransition = styleable.hasRunningTransitionsForProperty(property); 441 if ((hasRunningTransition || styleable.hasCompletedTransitionsForProperty(property)) && !matchingBackingAnimation) { 437 442 // 3. If the element has a running transition or completed transition for the property, and there is not a matching transition-property 438 443 // value, then implementations must cancel the running transition or remove the completed transition from the set of completed transitions. 439 444 if (hasRunningTransition) 440 element.ensureRunningTransitionsByProperty().take(property)->cancel();445 styleable.ensureRunningTransitionsByProperty().take(property)->cancel(); 441 446 else 442 element.ensureCompletedTransitionsByProperty().remove(property);443 } 444 445 if (matchingBackingAnimation && element.hasRunningTransitionsForProperty(property) && !propertyInStyleMatchesValueForTransitionInMap(property, afterChangeStyle, element.ensureRunningTransitionsByProperty())) {446 auto previouslyRunningTransition = element.ensureRunningTransitionsByProperty().take(property);447 styleable.ensureCompletedTransitionsByProperty().remove(property); 448 } 449 450 if (matchingBackingAnimation && styleable.hasRunningTransitionsForProperty(property) && !propertyInStyleMatchesValueForTransitionInMap(property, afterChangeStyle, styleable.ensureRunningTransitionsByProperty())) { 451 auto previouslyRunningTransition = styleable.ensureRunningTransitionsByProperty().take(property); 447 452 auto& previouslyRunningTransitionCurrentStyle = previouslyRunningTransition->currentStyle(); 448 453 // 4. If the element has a running transition for the property, there is a matching transition-property value, and the end value of the running … … 482 487 auto duration = Seconds(matchingBackingAnimation->duration()) * reversingShorteningFactor; 483 488 484 element.ensureRunningTransitionsByProperty().set(property, CSSTransition::create(element, property, generationTime, *matchingBackingAnimation, &previouslyRunningTransitionCurrentStyle, afterChangeStyle, delay, duration, reversingAdjustedStartStyle, reversingShorteningFactor));489 styleable.ensureRunningTransitionsByProperty().set(property, CSSTransition::create(styleable, property, generationTime, *matchingBackingAnimation, &previouslyRunningTransitionCurrentStyle, afterChangeStyle, delay, duration, reversingAdjustedStartStyle, reversingShorteningFactor)); 485 490 } else { 486 491 // 4. Otherwise, implementations must cancel the running transition … … 498 503 auto& reversingAdjustedStartStyle = currentStyle; 499 504 auto reversingShorteningFactor = 1; 500 element.ensureRunningTransitionsByProperty().set(property, CSSTransition::create(element, property, generationTime, *matchingBackingAnimation, &previouslyRunningTransitionCurrentStyle, afterChangeStyle, delay, duration, reversingAdjustedStartStyle, reversingShorteningFactor));501 } 502 } 503 } 504 505 void AnimationTimeline::updateCSSTransitionsFor Element(Element& element, const RenderStyle& currentStyle, const RenderStyle& newStyle)505 styleable.ensureRunningTransitionsByProperty().set(property, CSSTransition::create(styleable, property, generationTime, *matchingBackingAnimation, &previouslyRunningTransitionCurrentStyle, afterChangeStyle, delay, duration, reversingAdjustedStartStyle, reversingShorteningFactor)); 506 } 507 } 508 } 509 510 void AnimationTimeline::updateCSSTransitionsForStyleable(const Styleable& styleable, const RenderStyle& currentStyle, const RenderStyle& newStyle) 506 511 { 507 512 // In case this element is newly getting a "display: none" we need to cancel all of its transitions and disregard new ones. 508 513 if (currentStyle.hasTransitions() && currentStyle.display() != DisplayType::None && newStyle.display() == DisplayType::None) { 509 if ( element.hasRunningTransitions()) {510 auto runningTransitions = element.ensureRunningTransitionsByProperty();514 if (styleable.hasRunningTransitions()) { 515 auto runningTransitions = styleable.ensureRunningTransitionsByProperty(); 511 516 for (const auto& cssTransitionsByCSSPropertyIDMapItem : runningTransitions) 512 517 cssTransitionsByCSSPropertyIDMapItem.value->cancelFromStyle(); … … 533 538 if (isShorthand && *isShorthand) 534 539 continue; 535 updateCSSTransitionsFor ElementAndProperty(element, property, currentStyle, newStyle, generationTime);540 updateCSSTransitionsForStyleableAndProperty(styleable, property, currentStyle, newStyle, generationTime); 536 541 } 537 542 return; … … 539 544 540 545 for (auto property : transitionProperties) 541 updateCSSTransitionsFor ElementAndProperty(element, property, currentStyle, newStyle, generationTime);546 updateCSSTransitionsForStyleableAndProperty(styleable, property, currentStyle, newStyle, generationTime); 542 547 } 543 548 -
trunk/Source/WebCore/animation/AnimationTimeline.h
r267347 r267571 30 30 #include "ComputedEffectTiming.h" 31 31 #include "RenderStyle.h" 32 #include "Styleable.h" 32 33 #include "WebAnimation.h" 33 34 #include <wtf/Forward.h> … … 45 46 class CSSTransition; 46 47 class DeclarativeAnimation; 47 class Element;48 48 49 49 class AnimationTimeline : public RefCounted<AnimationTimeline>, public CanMakeWeakPtr<AnimationTimeline> { … … 62 62 virtual Optional<Seconds> currentTime() { return m_currentTime; } 63 63 64 void elementWasRemoved( Element&);64 void elementWasRemoved(const Styleable&); 65 65 66 void willChangeRendererFor Element(Element&);67 void cancelDeclarativeAnimationsFor Element(Element&, WebAnimation::Silently);66 void willChangeRendererForStyleable(const Styleable&); 67 void cancelDeclarativeAnimationsForStyleable(const Styleable&, WebAnimation::Silently); 68 68 69 void animationWasAddedTo Element(WebAnimation&, Element&);70 void animationWasRemovedFrom Element(WebAnimation&, Element&);69 void animationWasAddedToStyleable(WebAnimation&, const Styleable&); 70 void animationWasRemovedFromStyleable(WebAnimation&, const Styleable&); 71 71 72 void removeDeclarativeAnimationFromListsForOwningElement(WebAnimation&, Element&);72 void removeDeclarativeAnimationFromListsForOwningElement(WebAnimation&, const Styleable&); 73 73 74 void updateCSSAnimationsFor Element(Element&, const RenderStyle* currentStyle, const RenderStyle& afterChangeStyle);75 void updateCSSTransitionsFor Element(Element&, const RenderStyle& currentStyle, const RenderStyle& newStyle);74 void updateCSSAnimationsForStyleable(const Styleable&, const RenderStyle* currentStyle, const RenderStyle& afterChangeStyle); 75 void updateCSSTransitionsForStyleable(const Styleable&, const RenderStyle& currentStyle, const RenderStyle& newStyle); 76 76 77 77 protected: … … 83 83 private: 84 84 void updateGlobalPosition(WebAnimation&); 85 void updateCSSTransitionsFor ElementAndProperty(Element&, CSSPropertyID, const RenderStyle& currentStyle, const RenderStyle& afterChangeStyle, const MonotonicTime);86 void removeCSSAnimationCreatedByMarkup( Element&, CSSAnimation&);85 void updateCSSTransitionsForStyleableAndProperty(const Styleable&, CSSPropertyID, const RenderStyle& currentStyle, const RenderStyle& afterChangeStyle, const MonotonicTime); 86 void removeCSSAnimationCreatedByMarkup(const Styleable&, CSSAnimation&); 87 87 88 88 Markable<Seconds, Seconds::MarkableTraits> m_currentTime; -
trunk/Source/WebCore/animation/CSSAnimation.cpp
r261637 r267571 29 29 #include "Animation.h" 30 30 #include "AnimationEvent.h" 31 #include "Element.h"32 31 #include "InspectorInstrumentation.h" 33 32 #include "RenderStyle.h" … … 38 37 WTF_MAKE_ISO_ALLOCATED_IMPL(CSSAnimation); 39 38 40 Ref<CSSAnimation> CSSAnimation::create( Element& owningElement, const Animation& backingAnimation, const RenderStyle* oldStyle, const RenderStyle& newStyle)39 Ref<CSSAnimation> CSSAnimation::create(const Styleable& owningElement, const Animation& backingAnimation, const RenderStyle* oldStyle, const RenderStyle& newStyle) 41 40 { 42 41 auto result = adoptRef(*new CSSAnimation(owningElement, backingAnimation)); … … 48 47 } 49 48 50 CSSAnimation::CSSAnimation( Element& element, const Animation& backingAnimation)49 CSSAnimation::CSSAnimation(const Styleable& element, const Animation& backingAnimation) 51 50 : DeclarativeAnimation(element, backingAnimation) 52 51 , m_animationName(backingAnimation.name()) -
trunk/Source/WebCore/animation/CSSAnimation.h
r260671 r267571 27 27 28 28 #include "DeclarativeAnimation.h" 29 #include "Styleable.h" 29 30 #include <wtf/OptionSet.h> 30 31 #include <wtf/Ref.h> … … 33 34 34 35 class Animation; 35 class Element;36 36 class RenderStyle; 37 37 … … 39 39 WTF_MAKE_ISO_ALLOCATED(CSSAnimation); 40 40 public: 41 static Ref<CSSAnimation> create( Element&, const Animation&, const RenderStyle* oldStyle, const RenderStyle& newStyle);41 static Ref<CSSAnimation> create(const Styleable&, const Animation&, const RenderStyle* oldStyle, const RenderStyle& newStyle); 42 42 ~CSSAnimation() = default; 43 43 … … 49 49 50 50 private: 51 CSSAnimation( Element&, const Animation&);51 CSSAnimation(const Styleable&, const Animation&); 52 52 53 53 void syncPropertiesWithBackingAnimation() final; -
trunk/Source/WebCore/animation/CSSTransition.cpp
r264332 r267571 29 29 #include "Animation.h" 30 30 #include "DocumentTimeline.h" 31 #include "Element.h"32 31 #include "InspectorInstrumentation.h" 33 32 #include "KeyframeEffect.h" … … 39 38 WTF_MAKE_ISO_ALLOCATED_IMPL(CSSTransition); 40 39 41 Ref<CSSTransition> CSSTransition::create( Element& owningElement, CSSPropertyID property, MonotonicTime generationTime, const Animation& backingAnimation, const RenderStyle* oldStyle, const RenderStyle& newStyle, Seconds delay, Seconds duration, const RenderStyle& reversingAdjustedStartStyle, double reversingShorteningFactor)40 Ref<CSSTransition> CSSTransition::create(const Styleable& owningElement, CSSPropertyID property, MonotonicTime generationTime, const Animation& backingAnimation, const RenderStyle* oldStyle, const RenderStyle& newStyle, Seconds delay, Seconds duration, const RenderStyle& reversingAdjustedStartStyle, double reversingShorteningFactor) 42 41 { 43 42 ASSERT(oldStyle); … … 51 50 } 52 51 53 CSSTransition::CSSTransition( Element& element, CSSPropertyID property, MonotonicTime generationTime, const Animation& backingAnimation, const RenderStyle& oldStyle, const RenderStyle& targetStyle, const RenderStyle& reversingAdjustedStartStyle, double reversingShorteningFactor)54 : DeclarativeAnimation( element, backingAnimation)52 CSSTransition::CSSTransition(const Styleable& styleable, CSSPropertyID property, MonotonicTime generationTime, const Animation& backingAnimation, const RenderStyle& oldStyle, const RenderStyle& targetStyle, const RenderStyle& reversingAdjustedStartStyle, double reversingShorteningFactor) 53 : DeclarativeAnimation(styleable, backingAnimation) 55 54 , m_property(property) 56 55 , m_generationTime(generationTime) 57 , m_timelineTimeAtCreation( element.document().timeline().currentTime())56 , m_timelineTimeAtCreation(styleable.element.document().timeline().currentTime()) 58 57 , m_targetStyle(RenderStyle::clonePtr(targetStyle)) 59 58 , m_currentStyle(RenderStyle::clonePtr(oldStyle)) -
trunk/Source/WebCore/animation/CSSTransition.h
r263464 r267571 28 28 #include "CSSPropertyNames.h" 29 29 #include "DeclarativeAnimation.h" 30 #include "Styleable.h" 30 31 #include <wtf/Markable.h> 31 32 #include <wtf/MonotonicTime.h> … … 37 38 38 39 class Animation; 39 class Element;40 40 class RenderStyle; 41 41 … … 43 43 WTF_MAKE_ISO_ALLOCATED(CSSTransition); 44 44 public: 45 static Ref<CSSTransition> create( Element&, CSSPropertyID, MonotonicTime generationTime, const Animation&, const RenderStyle* oldStyle, const RenderStyle& newStyle, Seconds delay, Seconds duration, const RenderStyle& reversingAdjustedStartStyle, double);45 static Ref<CSSTransition> create(const Styleable&, CSSPropertyID, MonotonicTime generationTime, const Animation&, const RenderStyle* oldStyle, const RenderStyle& newStyle, Seconds delay, Seconds duration, const RenderStyle& reversingAdjustedStartStyle, double); 46 46 ~CSSTransition() = default; 47 47 … … 57 57 58 58 private: 59 CSSTransition( Element&, CSSPropertyID, MonotonicTime generationTime, const Animation&, const RenderStyle& oldStyle, const RenderStyle& targetStyle, const RenderStyle& reversingAdjustedStartStyle, double);59 CSSTransition(const Styleable&, CSSPropertyID, MonotonicTime generationTime, const Animation&, const RenderStyle& oldStyle, const RenderStyle& targetStyle, const RenderStyle& reversingAdjustedStartStyle, double); 60 60 void setTimingProperties(Seconds delay, Seconds duration); 61 61 Ref<AnimationEventBase> createEvent(const AtomString& eventType, double elapsedTime, const String& pseudoId, Optional<Seconds> timelineTime) final; -
trunk/Source/WebCore/animation/DeclarativeAnimation.cpp
r265319 r267571 44 44 WTF_MAKE_ISO_ALLOCATED_IMPL(DeclarativeAnimation); 45 45 46 DeclarativeAnimation::DeclarativeAnimation(Element& owningElement, const Animation& backingAnimation) 47 : WebAnimation(owningElement.document()) 48 , m_owningElement(makeWeakPtr(owningElement)) 46 DeclarativeAnimation::DeclarativeAnimation(const Styleable& styleable, const Animation& backingAnimation) 47 : WebAnimation(styleable.element.document()) 48 , m_owningElement(makeWeakPtr(styleable.element)) 49 , m_owningPseudoId(styleable.pseudoId) 49 50 , m_backingAnimation(const_cast<Animation&>(backingAnimation)) 50 51 { … … 55 56 } 56 57 57 Element* DeclarativeAnimation::owningElement() const 58 { 59 return m_owningElement.get(); 58 const Optional<const Styleable> DeclarativeAnimation::owningElement() const 59 { 60 if (m_owningElement) 61 return Styleable(*m_owningElement.get(), m_owningPseudoId); 62 return WTF::nullopt; 60 63 } 61 64 … … 94 97 95 98 if (auto* animationTimeline = timeline()) 96 animationTimeline->removeDeclarativeAnimationFromListsForOwningElement(*this, * m_owningElement);99 animationTimeline->removeDeclarativeAnimationFromListsForOwningElement(*this, *owningElement()); 97 100 m_owningElement = nullptr; 98 101 } … … 113 116 ASSERT(m_owningElement); 114 117 115 if (is<PseudoElement>(m_owningElement.get())) { 116 auto& pseudoOwningElement = downcast<PseudoElement>(*m_owningElement); 117 ASSERT(pseudoOwningElement.hostElement()); 118 setEffect(KeyframeEffect::create(*pseudoOwningElement.hostElement(), pseudoOwningElement.pseudoId())); 119 } else 120 setEffect(KeyframeEffect::create(*m_owningElement, m_owningElement->pseudoId())); 118 setEffect(KeyframeEffect::create(*m_owningElement, m_owningPseudoId)); 121 119 setTimeline(&m_owningElement->document().timeline()); 122 120 downcast<KeyframeEffect>(effect())->computeDeclarativeAnimationBlendingKeyframes(oldStyle, newStyle); … … 353 351 354 352 auto time = secondsToWebAnimationsAPITime(elapsedTime) / 1000; 355 const auto& pseudoId = PseudoElement::pseudoElementNameForEvents(m_owning Element->pseudoId());353 const auto& pseudoId = PseudoElement::pseudoElementNameForEvents(m_owningPseudoId); 356 354 auto timelineTime = timeline() ? timeline()->currentTime() : WTF::nullopt; 357 355 auto event = createEvent(eventType, time, pseudoId, timelineTime); -
trunk/Source/WebCore/animation/DeclarativeAnimation.h
r260671 r267571 28 28 #include "AnimationEffect.h" 29 29 #include "AnimationEffectPhase.h" 30 #include "Styleable.h" 30 31 #include "WebAnimation.h" 31 32 #include <wtf/Ref.h> … … 46 47 bool isDeclarativeAnimation() const final { return true; } 47 48 48 Element*owningElement() const;49 const Optional<const Styleable> owningElement() const; 49 50 const Animation& backingAnimation() const { return m_backingAnimation; } 50 51 void setBackingAnimation(const Animation&); … … 73 74 74 75 protected: 75 DeclarativeAnimation( Element&, const Animation&);76 DeclarativeAnimation(const Styleable&, const Animation&); 76 77 77 78 virtual void initialize(const RenderStyle* oldStyle, const RenderStyle& newStyle); … … 91 92 92 93 WeakPtr<Element> m_owningElement; 94 PseudoId m_owningPseudoId; 93 95 Ref<Animation> m_backingAnimation; 94 96 double m_previousIteration; -
trunk/Source/WebCore/animation/DocumentTimeline.cpp
r267347 r267571 38 38 #include "Node.h" 39 39 #include "Page.h" 40 #include "RenderBoxModelObject.h" 40 41 #include "RenderElement.h" 41 42 #include "RenderLayer.h" … … 227 228 228 229 auto* keyframeEffect = downcast<KeyframeEffect>(effect); 229 auto * target = keyframeEffect->target();230 if (!target || !target-> isDescendantOf(*m_document))230 auto target = keyframeEffect->targetStyleable(); 231 if (!target || !target->element.isDescendantOf(*m_document)) 231 232 return false; 232 233 … … 297 298 removeAnimation(*transition); 298 299 if (is<KeyframeEffect>(transition->effect())) { 299 if (auto * target = downcast<KeyframeEffect>(transition->effect())->targetElementOrPseudoElement())300 target->ensureCompletedTransitionsByProperty().set(transition->property(), transition);300 if (auto styleable = downcast<KeyframeEffect>(transition->effect())->targetStyleable()) 301 styleable->ensureCompletedTransitionsByProperty().set(transition->property(), transition); 301 302 } 302 303 } … … 331 332 bool DocumentTimeline::computeExtentOfAnimation(RenderElement& renderer, LayoutRect& bounds) const 332 333 { 333 if (!renderer.element()) 334 return true; 335 336 auto* animations = renderer.element()->animations(); 334 auto styleable = Styleable::fromRenderer(renderer); 335 if (!styleable) 336 return false; 337 338 auto* animations = styleable->animations(); 337 339 if (!animations) 338 340 return false; … … 356 358 bool DocumentTimeline::isRunningAnimationOnRenderer(RenderElement& renderer, CSSPropertyID property) const 357 359 { 358 if (!renderer.element()) 359 return false; 360 361 auto* animations = renderer.element()->animations(); 360 auto styleable = Styleable::fromRenderer(renderer); 361 if (!styleable) 362 return false; 363 364 auto* animations = styleable->animations(); 362 365 if (!animations) 363 366 return false; … … 377 380 bool DocumentTimeline::isRunningAcceleratedAnimationOnRenderer(RenderElement& renderer, CSSPropertyID property) const 378 381 { 379 if (!renderer.element()) 380 return false; 381 382 auto* animations = renderer.element()->animations(); 382 auto styleable = Styleable::fromRenderer(renderer); 383 if (!styleable) 384 return false; 385 386 auto* animations = styleable->animations(); 383 387 if (!animations) 384 388 return false; … … 401 405 std::unique_ptr<RenderStyle> DocumentTimeline::animatedStyleForRenderer(RenderElement& renderer) 402 406 { 403 auto * element = renderer.element();404 if (! element)407 auto styleable = Styleable::fromRenderer(renderer); 408 if (!styleable) 405 409 return RenderStyle::clonePtr(renderer.style()); 406 410 407 auto* animations = renderer.element()->animations();411 auto* animations = styleable->animations(); 408 412 if (!animations) 409 413 return RenderStyle::clonePtr(renderer.style()); … … 447 451 } 448 452 449 bool DocumentTimeline::runningAnimationsForElementAreAllAccelerated(Element& element) const 450 { 451 auto* animations = element.animations(); 453 bool DocumentTimeline::runningAnimationsForRendererAreAllAccelerated(const RenderBoxModelObject& renderer) const 454 { 455 auto styleable = Styleable::fromRenderer(renderer); 456 if (!styleable) 457 return false; 458 459 auto* animations = styleable->animations(); 452 460 if (!animations || animations->isEmpty()) 453 461 return false; -
trunk/Source/WebCore/animation/DocumentTimeline.h
r267347 r267571 36 36 class AnimationEventBase; 37 37 class DocumentTimelinesController; 38 class RenderBoxModelObject; 38 39 class RenderElement; 39 40 … … 63 64 bool isRunningAcceleratedAnimationOnRenderer(RenderElement&, CSSPropertyID) const; 64 65 void animationAcceleratedRunningStateDidChange(WebAnimation&); 65 bool runningAnimationsFor ElementAreAllAccelerated(Element&) const;66 bool runningAnimationsForRendererAreAllAccelerated(const RenderBoxModelObject&) const; 66 67 void detachFromDocument(); 67 68 -
trunk/Source/WebCore/animation/ElementAnimationRareData.cpp
r262621 r267571 34 34 namespace WebCore { 35 35 36 ElementAnimationRareData::ElementAnimationRareData() 36 ElementAnimationRareData::ElementAnimationRareData(PseudoId pseudoId) 37 : m_pseudoId(pseudoId) 37 38 { 38 39 } -
trunk/Source/WebCore/animation/ElementAnimationRareData.h
r267204 r267571 40 40 WTF_MAKE_FAST_ALLOCATED; 41 41 public: 42 explicit ElementAnimationRareData( );42 explicit ElementAnimationRareData(PseudoId); 43 43 ~ElementAnimationRareData(); 44 45 PseudoId pseudoId() const { return m_pseudoId; } 44 46 45 47 KeyframeEffectStack* keyframeEffectStack() { return m_keyframeEffectStack.get(); } … … 62 64 PropertyToTransitionMap m_completedTransitionsByProperty; 63 65 PropertyToTransitionMap m_runningTransitionsByProperty; 66 PseudoId m_pseudoId; 64 67 }; 65 68 -
trunk/Source/WebCore/animation/KeyframeEffect.cpp
r266789 r267571 67 67 using namespace JSC; 68 68 69 static inline void invalidateElement(Element* element) 70 { 71 if (element) 72 element->invalidateStyleInternal(); 69 static Element* elementOrPseudoElementForStyleable(const Optional<const Styleable>& styleable) 70 { 71 if (!styleable) 72 return nullptr; 73 74 switch (styleable->pseudoId) { 75 case PseudoId::None: 76 return &styleable->element; 77 case PseudoId::Before: 78 return styleable->element.beforePseudoElement(); 79 case PseudoId::After: 80 return styleable->element.afterPseudoElement(); 81 default: 82 return nullptr; 83 } 84 } 85 86 static inline void invalidateElement(const Optional<const Styleable>& styleable) 87 { 88 if (auto* elementOrPseudoElement = elementOrPseudoElementForStyleable(styleable)) 89 elementOrPseudoElement->invalidateStyleInternal(); 73 90 } 74 91 … … 1052 1069 void KeyframeEffect::animationTimelineDidChange(AnimationTimeline* timeline) 1053 1070 { 1054 if (!targetElementOrPseudoElement()) 1071 auto target = targetStyleable(); 1072 if (!target) 1055 1073 return; 1056 1074 1057 1075 if (timeline) 1058 m_inTargetEffectStack = target ElementOrPseudoElement()->ensureKeyframeEffectStack().addEffect(*this);1076 m_inTargetEffectStack = target->ensureKeyframeEffectStack().addEffect(*this); 1059 1077 else { 1060 target ElementOrPseudoElement()->ensureKeyframeEffectStack().removeEffect(*this);1078 target->ensureKeyframeEffectStack().removeEffect(*this); 1061 1079 m_inTargetEffectStack = false; 1062 1080 } … … 1070 1088 void KeyframeEffect::updateEffectStackMembership() 1071 1089 { 1072 if (!targetElementOrPseudoElement()) 1090 auto target = targetStyleable(); 1091 if (!target) 1073 1092 return; 1074 1093 1075 1094 bool isRelevant = animation() && animation()->isRelevant(); 1076 1095 if (isRelevant && !m_inTargetEffectStack) 1077 m_inTargetEffectStack = target ElementOrPseudoElement()->ensureKeyframeEffectStack().addEffect(*this);1096 m_inTargetEffectStack = target->ensureKeyframeEffectStack().addEffect(*this); 1078 1097 else if (!isRelevant && m_inTargetEffectStack) { 1079 target ElementOrPseudoElement()->ensureKeyframeEffectStack().removeEffect(*this);1098 target->ensureKeyframeEffectStack().removeEffect(*this); 1080 1099 m_inTargetEffectStack = false; 1081 1100 } … … 1095 1114 } 1096 1115 1116 const Optional<const Styleable> KeyframeEffect::targetStyleable() const 1117 { 1118 if (m_target) 1119 return Styleable(*m_target, m_pseudoId); 1120 return WTF::nullopt; 1121 } 1122 1097 1123 bool KeyframeEffect::targetsPseudoElement() const 1098 1124 { … … 1120 1146 return; 1121 1147 1122 auto * previousTargetElementOrPseudoElement = targetElementOrPseudoElement();1148 auto& previousTargetStyleable = targetStyleable(); 1123 1149 m_target = WTFMove(newTarget); 1124 didChangeTarget ElementOrPseudoElement(previousTargetElementOrPseudoElement);1150 didChangeTargetStyleable(previousTargetStyleable); 1125 1151 } 1126 1152 … … 1162 1188 return { }; 1163 1189 1164 auto * previousTargetElementOrPseudoElement = targetElementOrPseudoElement();1190 auto& previousTargetStyleable = targetStyleable(); 1165 1191 m_pseudoId = pseudoId; 1166 didChangeTarget ElementOrPseudoElement(previousTargetElementOrPseudoElement);1192 didChangeTargetStyleable(previousTargetStyleable); 1167 1193 1168 1194 return { }; 1169 1195 } 1170 1196 1171 void KeyframeEffect::didChangeTarget ElementOrPseudoElement(Element* previousTargetElementOrPseudoElement)1172 { 1173 auto * newTargetElementOrPseudoElement = targetElementOrPseudoElement();1197 void KeyframeEffect::didChangeTargetStyleable(const Optional<const Styleable>& previousTargetStyleable) 1198 { 1199 auto newTargetStyleable = targetStyleable(); 1174 1200 1175 1201 // We must ensure a PseudoElement exists for this m_target / m_pseudoId pair if both are specified. 1202 // FIXME: Ideally this wouldn't be necessary. 1203 auto* newTargetElementOrPseudoElement = elementOrPseudoElementForStyleable(newTargetStyleable); 1176 1204 if (!newTargetElementOrPseudoElement && m_target.get() && m_pseudoId != PseudoId::None) { 1177 // We only support targeting ::before and ::after pseudo-elements at the moment.1205 // FIXME: We only support targeting ::before and ::after pseudo-elements at the moment. 1178 1206 if (m_pseudoId == PseudoId::Before || m_pseudoId == PseudoId::After) 1179 1207 newTargetElementOrPseudoElement = &m_target->ensurePseudoElement(m_pseudoId); … … 1181 1209 1182 1210 if (auto* effectAnimation = animation()) 1183 effectAnimation->effectTargetDidChange(previousTarget ElementOrPseudoElement, newTargetElementOrPseudoElement);1211 effectAnimation->effectTargetDidChange(previousTargetStyleable, newTargetStyleable); 1184 1212 1185 1213 clearBlendingKeyframes(); … … 1191 1219 // Likewise, we need to invalidate styles on the previous target so that 1192 1220 // any animated styles are removed immediately. 1193 invalidateElement(previousTarget ElementOrPseudoElement);1194 1195 if (previousTarget ElementOrPseudoElement) {1196 previousTarget ElementOrPseudoElement->ensureKeyframeEffectStack().removeEffect(*this);1221 invalidateElement(previousTargetStyleable); 1222 1223 if (previousTargetStyleable) { 1224 previousTargetStyleable->ensureKeyframeEffectStack().removeEffect(*this); 1197 1225 m_inTargetEffectStack = false; 1198 1226 } 1199 if (newTargetElementOrPseudoElement) 1200 m_inTargetEffectStack = newTargetElementOrPseudoElement->ensureKeyframeEffectStack().addEffect(*this); 1227 1228 if (newTargetStyleable) 1229 m_inTargetEffectStack = newTargetStyleable->ensureKeyframeEffectStack().addEffect(*this); 1201 1230 } 1202 1231 … … 1239 1268 { 1240 1269 LOG_WITH_STREAM(Animations, stream << "KeyframeEffect::invalidate on element " << ValueOrNull(targetElementOrPseudoElement())); 1241 invalidateElement(target ElementOrPseudoElement());1270 invalidateElement(targetStyleable()); 1242 1271 } 1243 1272 … … 1624 1653 ASSERT(m_target); 1625 1654 1626 auto* lastStyleChangeEventStyle = m_target->lastStyleChangeEventStyle( );1655 auto* lastStyleChangeEventStyle = m_target->lastStyleChangeEventStyle(m_pseudoId); 1627 1656 ASSERT(lastStyleChangeEventStyle); 1628 1657 -
trunk/Source/WebCore/animation/KeyframeEffect.h
r266789 r267571 38 38 #include "RenderStyle.h" 39 39 #include "StyleProperties.h" 40 #include "Styleable.h" 40 41 #include "WebAnimationTypes.h" 41 42 #include <wtf/Ref.h> … … 109 110 const String pseudoElement() const; 110 111 ExceptionOr<void> setPseudoElement(const String&); 112 113 const Optional<const Styleable> targetStyleable() const; 111 114 112 115 Vector<JSC::Strong<JSC::JSObject>> getBindingsKeyframes(JSC::JSGlobalObject&); … … 179 182 void updateEffectStackMembership(); 180 183 void copyPropertiesFromSource(Ref<KeyframeEffect>&&); 181 void didChangeTarget ElementOrPseudoElement(Element*);184 void didChangeTargetStyleable(const Optional<const Styleable>&); 182 185 ExceptionOr<void> processKeyframes(JSC::JSGlobalObject&, JSC::Strong<JSC::JSObject>&&); 183 186 void addPendingAcceleratedAction(AcceleratedAction); -
trunk/Source/WebCore/animation/KeyframeEffectStack.cpp
r261470 r267571 47 47 // To qualify for membership in an effect stack, an effect must have a target, an animation, a timeline and be relevant. 48 48 // This method will be called in WebAnimation and KeyframeEffect as those properties change. 49 if (!effect.target ElementOrPseudoElement() || !effect.animation() || !effect.animation()->timeline() || !effect.animation()->isRelevant())49 if (!effect.targetStyleable() || !effect.animation() || !effect.animation()->timeline() || !effect.animation()->isRelevant()) 50 50 return false; 51 51 -
trunk/Source/WebCore/animation/WebAnimation.cpp
r263729 r267571 207 207 auto oldEffect = std::exchange(m_effect, WTFMove(newEffect)); 208 208 209 Element* previousTarget = nullptr; 210 if (is<KeyframeEffect>(oldEffect)) 211 previousTarget = downcast<KeyframeEffect>(oldEffect.get())->targetElementOrPseudoElement(); 212 213 Element* newTarget = nullptr; 214 if (is<KeyframeEffect>(m_effect)) 215 newTarget = downcast<KeyframeEffect>(m_effect.get())->targetElementOrPseudoElement(); 209 Optional<const Styleable> previousTarget = is<KeyframeEffect>(oldEffect) ? downcast<KeyframeEffect>(oldEffect.get())->targetStyleable() : WTF::nullopt; 210 Optional<const Styleable> newTarget = is<KeyframeEffect>(m_effect) ? downcast<KeyframeEffect>(m_effect.get())->targetStyleable() : WTF::nullopt; 216 211 217 212 // Update the effect-to-animation relationships and the timeline's animation map. … … 219 214 oldEffect->setAnimation(nullptr); 220 215 if (!doNotRemoveFromTimeline && m_timeline && previousTarget && previousTarget != newTarget) 221 m_timeline->animationWasRemovedFrom Element(*this, *previousTarget);216 m_timeline->animationWasRemovedFromStyleable(*this, *previousTarget); 222 217 updateRelevance(); 223 218 } … … 226 221 m_effect->setAnimation(this); 227 222 if (m_timeline && newTarget && previousTarget != newTarget) 228 m_timeline->animationWasAddedTo Element(*this, *newTarget);223 m_timeline->animationWasAddedToStyleable(*this, *newTarget); 229 224 } 230 225 … … 246 241 247 242 if (is<KeyframeEffect>(m_effect)) { 248 auto* keyframeEffect = downcast<KeyframeEffect>(m_effect.get()); 249 auto* target = keyframeEffect->targetElementOrPseudoElement(); 250 if (target) { 243 if (auto target = downcast<KeyframeEffect>(m_effect.get())->targetStyleable()) { 251 244 // In the case of a declarative animation, we don't want to remove the animation from the relevant maps because 252 245 // while the timeline was set via the API, the element still has a transition or animation set up and we must 253 246 // not break the relationship. 254 247 if (m_timeline && !isDeclarativeAnimation()) 255 m_timeline->animationWasRemovedFrom Element(*this, *target);248 m_timeline->animationWasRemovedFromStyleable(*this, *target); 256 249 if (timeline) 257 timeline->animationWasAddedTo Element(*this, *target);250 timeline->animationWasAddedToStyleable(*this, *target); 258 251 } 259 252 } … … 286 279 } 287 280 288 void WebAnimation::effectTargetDidChange( Element* previousTarget, Element*newTarget)281 void WebAnimation::effectTargetDidChange(const Optional<const Styleable>& previousTarget, const Optional<const Styleable>& newTarget) 289 282 { 290 283 if (m_timeline) { 291 284 if (previousTarget) 292 m_timeline->animationWasRemovedFrom Element(*this, *previousTarget);285 m_timeline->animationWasRemovedFromStyleable(*this, *previousTarget); 293 286 294 287 if (newTarget) 295 m_timeline->animationWasAddedTo Element(*this, *newTarget);288 m_timeline->animationWasAddedToStyleable(*this, *newTarget); 296 289 297 290 // This could have changed whether we have replaced animations, so we may need to schedule an update. … … 1383 1376 if (is<KeyframeEffect>(m_effect)) { 1384 1377 auto& keyframeEffect = downcast<KeyframeEffect>(*m_effect); 1385 auto & target = *keyframeEffect.targetElementOrPseudoElement();1386 m_timeline->animationWasAddedTo Element(*this, target);1387 target.ensureKeyframeEffectStack().addEffect(keyframeEffect);1378 auto styleable = keyframeEffect.targetStyleable(); 1379 m_timeline->animationWasAddedToStyleable(*this, *styleable); 1380 styleable->ensureKeyframeEffectStack().addEffect(keyframeEffect); 1388 1381 } 1389 1382 } … … 1424 1417 inlineStyle->setCssText(styledElement.getAttribute("style")); 1425 1418 1426 auto& keyframeStack = styledElement.ensureKeyframeEffectStack( );1419 auto& keyframeStack = styledElement.ensureKeyframeEffectStack(PseudoId::None); 1427 1420 1428 1421 // 2.5 For each property, property, in targeted properties: -
trunk/Source/WebCore/animation/WebAnimation.h
r263729 r267571 30 30 #include "ExceptionOr.h" 31 31 #include "IDLTypes.h" 32 #include "Styleable.h" 32 33 #include "WebAnimationTypes.h" 33 34 #include <wtf/Forward.h> … … 45 46 class AnimationTimeline; 46 47 class Document; 47 class Element;48 48 class RenderStyle; 49 49 … … 123 123 WEBCORE_EXPORT Seconds timeToNextTick() const; 124 124 virtual void resolve(RenderStyle&, Optional<Seconds> = WTF::nullopt); 125 void effectTargetDidChange( Element* previousTarget, Element*newTarget);125 void effectTargetDidChange(const Optional<const Styleable>& previousTarget, const Optional<const Styleable>& newTarget); 126 126 void acceleratedStateDidChange(); 127 127 void applyPendingAcceleratedActions(); -
trunk/Source/WebCore/animation/WebAnimationUtilities.cpp
r261470 r267571 39 39 namespace WebCore { 40 40 41 static bool compareDeclarativeAnimationOwningElementPositionsInDocumentTreeOrder( Element& a, Element& b)41 static bool compareDeclarativeAnimationOwningElementPositionsInDocumentTreeOrder(const Styleable& a, const Styleable& b) 42 42 { 43 43 // We should not ever be calling this function with two Elements that are the same. If that were the case, 44 44 // then comparing objects of this kind would yield inconsistent results when comparing A == B and B == A. 45 45 // As such, this function should be called with std::stable_sort(). 46 RELEASE_ASSERT_WITH_SECURITY_IMPLICATION( &a != &b);46 RELEASE_ASSERT_WITH_SECURITY_IMPLICATION(a != b); 47 47 48 48 // With regard to pseudo-elements, the sort order is as follows: 49 // 49 50 // - element 51 // - ::marker 50 52 // - ::before 53 // - any other pseudo-elements not mentioned specifically in this list, sorted in ascending order by the Unicode codepoints that make up each selector 51 54 // - ::after 52 55 // - element children 56 enum SortingIndex : uint8_t { NotPseudo, Marker, Before, FirstLetter, FirstLine, Highlight, Scrollbar, Selection, After, Other }; 57 auto sortingIndex = [](PseudoId pseudoId) -> SortingIndex { 58 switch (pseudoId) { 59 case PseudoId::None: 60 return NotPseudo; 61 case PseudoId::Marker: 62 return Marker; 63 case PseudoId::Before: 64 return Before; 65 case PseudoId::FirstLetter: 66 return FirstLetter; 67 case PseudoId::FirstLine: 68 return FirstLine; 69 case PseudoId::Highlight: 70 return Highlight; 71 case PseudoId::Scrollbar: 72 return Scrollbar; 73 case PseudoId::Selection: 74 return Selection; 75 case PseudoId::After: 76 return After; 77 default: 78 ASSERT_NOT_REACHED(); 79 return Other; 80 } 81 }; 53 82 54 enum SortingIndex : uint8_t { NotPseudo, Before, After }; 83 auto& aReferenceElement = a.element; 84 int aSortingIndex = sortingIndex(a.pseudoId); 55 85 56 int aSortingIndex = NotPseudo; 57 Element* aReferenceElement = &a; 58 if (is<PseudoElement>(a)) { 59 auto& aPseudo = downcast<PseudoElement>(a); 60 aSortingIndex = aPseudo.isBeforePseudoElement() ? Before : After; 61 aReferenceElement = aPseudo.hostElement(); 62 ASSERT(aReferenceElement); 86 auto& bReferenceElement = b.element; 87 int bSortingIndex = sortingIndex(b.pseudoId); 88 89 if (&aReferenceElement == &bReferenceElement) { 90 ASSERT(aSortingIndex != bSortingIndex); 91 return aSortingIndex < bSortingIndex; 63 92 } 64 65 int bSortingIndex = NotPseudo; 66 Element* bReferenceElement = &b; 67 if (is<PseudoElement>(b)) { 68 auto& bPseudo = downcast<PseudoElement>(b); 69 bSortingIndex = bPseudo.isBeforePseudoElement() ? Before : After; 70 bReferenceElement = bPseudo.hostElement(); 71 ASSERT(bReferenceElement); 72 } 73 74 if (aReferenceElement == bReferenceElement) 75 return aSortingIndex < bSortingIndex; 76 return aReferenceElement->compareDocumentPosition(*bReferenceElement) & Node::DOCUMENT_POSITION_FOLLOWING; 93 return aReferenceElement.compareDocumentPosition(bReferenceElement) & Node::DOCUMENT_POSITION_FOLLOWING; 77 94 } 78 95 … … 81 98 ASSERT(a.owningElement()); 82 99 ASSERT(b.owningElement()); 83 auto& aOwningElement = *a.owningElement();84 auto& bOwningElement = *b.owningElement();100 auto& aOwningElement = a.owningElement(); 101 auto& bOwningElement = b.owningElement(); 85 102 86 103 // If the owning element of A and B differs, sort A and B by tree order of their corresponding owning elements. 87 if ( &aOwningElement != &bOwningElement)88 return compareDeclarativeAnimationOwningElementPositionsInDocumentTreeOrder( aOwningElement,bOwningElement);104 if (*aOwningElement != *bOwningElement) 105 return compareDeclarativeAnimationOwningElementPositionsInDocumentTreeOrder(*aOwningElement, *bOwningElement); 89 106 90 107 // Otherwise, if A and B have different transition generation values, sort by their corresponding transition generation in ascending order. … … 102 119 ASSERT(a.owningElement()); 103 120 ASSERT(b.owningElement()); 104 auto& aOwningElement = *a.owningElement();105 auto& bOwningElement = *b.owningElement();121 auto& aOwningElement = a.owningElement(); 122 auto& bOwningElement = b.owningElement(); 106 123 107 124 // If the owning element of A and B differs, sort A and B by tree order of their corresponding owning elements. 108 if ( &aOwningElement != &bOwningElement)109 return compareDeclarativeAnimationOwningElementPositionsInDocumentTreeOrder( aOwningElement,bOwningElement);125 if (*aOwningElement != *bOwningElement) 126 return compareDeclarativeAnimationOwningElementPositionsInDocumentTreeOrder(*aOwningElement, *bOwningElement); 110 127 111 128 // Sort A and B based on their position in the computed value of the animation-name property of the (common) owning element. 112 auto* cssAnimationList = aOwningElement .ensureKeyframeEffectStack().cssAnimationList();129 auto* cssAnimationList = aOwningElement->ensureKeyframeEffectStack().cssAnimationList(); 113 130 ASSERT(cssAnimationList); 114 131 ASSERT(!cssAnimationList->isEmpty()); -
trunk/Source/WebCore/dom/Element.cpp
r267345 r267571 2284 2284 RefPtr<Frame> frame = document().frame(); 2285 2285 if (auto* timeline = document().existingTimeline()) 2286 timeline->elementWasRemoved( *this);2286 timeline->elementWasRemoved({ *this, pseudoId() }); 2287 2287 2288 2288 #if ENABLE(WHEEL_EVENT_LATCHING) … … 3804 3804 #endif 3805 3805 3806 ElementAnimationRareData* Element::animationRareData( ) const3807 { 3808 return hasRareData() ? elementRareData()-> elementAnimationRareData() : nullptr;3809 } 3810 3811 ElementAnimationRareData& Element::ensureAnimationRareData( )3812 { 3813 return ensureElementRareData().ensureAnimationRareData( );3814 } 3815 3816 KeyframeEffectStack* Element::keyframeEffectStack( ) const3817 { 3818 if (auto* animationData = animationRareData( ))3806 ElementAnimationRareData* Element::animationRareData(PseudoId pseudoId) const 3807 { 3808 return hasRareData() ? elementRareData()->animationRareData(pseudoId) : nullptr; 3809 } 3810 3811 ElementAnimationRareData& Element::ensureAnimationRareData(PseudoId pseudoId) 3812 { 3813 return ensureElementRareData().ensureAnimationRareData(pseudoId); 3814 } 3815 3816 KeyframeEffectStack* Element::keyframeEffectStack(PseudoId pseudoId) const 3817 { 3818 if (auto* animationData = animationRareData(pseudoId)) 3819 3819 return animationData->keyframeEffectStack(); 3820 3820 return nullptr; 3821 3821 } 3822 3822 3823 KeyframeEffectStack& Element::ensureKeyframeEffectStack( )3824 { 3825 return ensureAnimationRareData( ).ensureKeyframeEffectStack();3826 } 3827 3828 bool Element::hasKeyframeEffects( ) const3829 { 3830 if (auto* animationData = animationRareData( )) {3823 KeyframeEffectStack& Element::ensureKeyframeEffectStack(PseudoId pseudoId) 3824 { 3825 return ensureAnimationRareData(pseudoId).ensureKeyframeEffectStack(); 3826 } 3827 3828 bool Element::hasKeyframeEffects(PseudoId pseudoId) const 3829 { 3830 if (auto* animationData = animationRareData(pseudoId)) { 3831 3831 if (auto* keyframeEffectStack = animationData->keyframeEffectStack()) 3832 3832 return keyframeEffectStack->hasEffects(); … … 3835 3835 } 3836 3836 3837 OptionSet<AnimationImpact> Element::applyKeyframeEffects( RenderStyle& targetStyle)3837 OptionSet<AnimationImpact> Element::applyKeyframeEffects(PseudoId pseudoId, RenderStyle& targetStyle) 3838 3838 { 3839 3839 OptionSet<AnimationImpact> impact; 3840 3840 3841 for (const auto& effect : ensureKeyframeEffectStack( ).sortedEffects()) {3841 for (const auto& effect : ensureKeyframeEffectStack(pseudoId).sortedEffects()) { 3842 3842 ASSERT(effect->animation()); 3843 3843 effect->animation()->resolve(targetStyle); … … 3853 3853 } 3854 3854 3855 const AnimationCollection* Element::animations( ) const3856 { 3857 if (auto* animationData = animationRareData( ))3855 const AnimationCollection* Element::animations(PseudoId pseudoId) const 3856 { 3857 if (auto* animationData = animationRareData(pseudoId)) 3858 3858 return &animationData->animations(); 3859 3859 return nullptr; 3860 3860 } 3861 3861 3862 bool Element::hasCompletedTransitionsForProperty( CSSPropertyID property) const3863 { 3864 if (auto* animationData = animationRareData( ))3862 bool Element::hasCompletedTransitionsForProperty(PseudoId pseudoId, CSSPropertyID property) const 3863 { 3864 if (auto* animationData = animationRareData(pseudoId)) 3865 3865 return animationData->completedTransitionsByProperty().contains(property); 3866 3866 return false; 3867 3867 } 3868 3868 3869 bool Element::hasRunningTransitionsForProperty( CSSPropertyID property) const3870 { 3871 if (auto* animationData = animationRareData( ))3869 bool Element::hasRunningTransitionsForProperty(PseudoId pseudoId, CSSPropertyID property) const 3870 { 3871 if (auto* animationData = animationRareData(pseudoId)) 3872 3872 return animationData->runningTransitionsByProperty().contains(property); 3873 3873 return false; 3874 3874 } 3875 3875 3876 bool Element::hasRunningTransitions( ) const3877 { 3878 if (auto* animationData = animationRareData( ))3876 bool Element::hasRunningTransitions(PseudoId pseudoId) const 3877 { 3878 if (auto* animationData = animationRareData(pseudoId)) 3879 3879 return !animationData->runningTransitionsByProperty().isEmpty(); 3880 3880 return false; 3881 3881 } 3882 3882 3883 AnimationCollection& Element::ensureAnimations( )3884 { 3885 return ensureAnimationRareData( ).animations();3886 } 3887 3888 CSSAnimationCollection& Element::animationsCreatedByMarkup( )3889 { 3890 return ensureAnimationRareData( ).animationsCreatedByMarkup();3891 } 3892 3893 void Element::setAnimationsCreatedByMarkup( CSSAnimationCollection&& animations)3894 { 3895 ensureAnimationRareData( ).setAnimationsCreatedByMarkup(WTFMove(animations));3896 } 3897 3898 PropertyToTransitionMap& Element::ensureCompletedTransitionsByProperty( )3899 { 3900 return ensureAnimationRareData( ).completedTransitionsByProperty();3901 } 3902 3903 PropertyToTransitionMap& Element::ensureRunningTransitionsByProperty( )3904 { 3905 return ensureAnimationRareData( ).runningTransitionsByProperty();3906 } 3907 3908 const RenderStyle* Element::lastStyleChangeEventStyle( ) const3909 { 3910 if (auto* animationData = animationRareData( ))3883 AnimationCollection& Element::ensureAnimations(PseudoId pseudoId) 3884 { 3885 return ensureAnimationRareData(pseudoId).animations(); 3886 } 3887 3888 CSSAnimationCollection& Element::animationsCreatedByMarkup(PseudoId pseudoId) 3889 { 3890 return ensureAnimationRareData(pseudoId).animationsCreatedByMarkup(); 3891 } 3892 3893 void Element::setAnimationsCreatedByMarkup(PseudoId pseudoId, CSSAnimationCollection&& animations) 3894 { 3895 ensureAnimationRareData(pseudoId).setAnimationsCreatedByMarkup(WTFMove(animations)); 3896 } 3897 3898 PropertyToTransitionMap& Element::ensureCompletedTransitionsByProperty(PseudoId pseudoId) 3899 { 3900 return ensureAnimationRareData(pseudoId).completedTransitionsByProperty(); 3901 } 3902 3903 PropertyToTransitionMap& Element::ensureRunningTransitionsByProperty(PseudoId pseudoId) 3904 { 3905 return ensureAnimationRareData(pseudoId).runningTransitionsByProperty(); 3906 } 3907 3908 const RenderStyle* Element::lastStyleChangeEventStyle(PseudoId pseudoId) const 3909 { 3910 if (auto* animationData = animationRareData(pseudoId)) 3911 3911 return animationData->lastStyleChangeEventStyle(); 3912 3912 return nullptr; 3913 3913 } 3914 3914 3915 void Element::setLastStyleChangeEventStyle( std::unique_ptr<const RenderStyle>&& style)3916 { 3917 if (auto* animationData = animationRareData( ))3915 void Element::setLastStyleChangeEventStyle(PseudoId pseudoId, std::unique_ptr<const RenderStyle>&& style) 3916 { 3917 if (auto* animationData = animationRareData(pseudoId)) 3918 3918 animationData->setLastStyleChangeEventStyle(WTFMove(style)); 3919 3919 else if (style) 3920 ensureAnimationRareData( ).setLastStyleChangeEventStyle(WTFMove(style));3920 ensureAnimationRareData(pseudoId).setLastStyleChangeEventStyle(WTFMove(style)); 3921 3921 } 3922 3922 … … 4543 4543 4544 4544 Vector<RefPtr<WebAnimation>> animations; 4545 if ( keyframeEffectStack()) {4546 for (auto& effect : keyframeEffectStack()->sortedEffects()) {4545 if (auto* effectStack = keyframeEffectStack(PseudoId::None)) { 4546 for (auto& effect : effectStack->sortedEffects()) { 4547 4547 if (effect->animation()->isRelevant()) 4548 4548 animations.append(effect->animation()); -
trunk/Source/WebCore/dom/Element.h
r267377 r267571 487 487 virtual void buildPendingResource() { }; 488 488 489 KeyframeEffectStack* keyframeEffectStack() const; 490 KeyframeEffectStack& ensureKeyframeEffectStack(); 491 bool hasKeyframeEffects() const; 492 OptionSet<AnimationImpact> applyKeyframeEffects(RenderStyle&); 493 494 const AnimationCollection* animations() const; 495 bool hasCompletedTransitionsForProperty(CSSPropertyID) const; 496 bool hasRunningTransitionsForProperty(CSSPropertyID) const; 497 bool hasRunningTransitions() const; 498 AnimationCollection& ensureAnimations(); 499 PropertyToTransitionMap& ensureCompletedTransitionsByProperty(); 500 PropertyToTransitionMap& ensureRunningTransitionsByProperty(); 501 CSSAnimationCollection& animationsCreatedByMarkup(); 502 void setAnimationsCreatedByMarkup(CSSAnimationCollection&&); 503 504 const RenderStyle* lastStyleChangeEventStyle() const; 505 void setLastStyleChangeEventStyle(std::unique_ptr<const RenderStyle>&&); 489 KeyframeEffectStack* keyframeEffectStack(PseudoId) const; 490 KeyframeEffectStack& ensureKeyframeEffectStack(PseudoId); 491 bool hasKeyframeEffects(PseudoId) const; 492 OptionSet<AnimationImpact> applyKeyframeEffects(PseudoId, RenderStyle&); 493 494 const AnimationCollection* animations(PseudoId) const; 495 bool hasCompletedTransitionsForProperty(PseudoId, CSSPropertyID) const; 496 bool hasRunningTransitionsForProperty(PseudoId, CSSPropertyID) const; 497 bool hasRunningTransitions(PseudoId) const; 498 AnimationCollection& ensureAnimations(PseudoId); 499 500 PropertyToTransitionMap& ensureCompletedTransitionsByProperty(PseudoId); 501 PropertyToTransitionMap& ensureRunningTransitionsByProperty(PseudoId); 502 CSSAnimationCollection& animationsCreatedByMarkup(PseudoId); 503 void setAnimationsCreatedByMarkup(PseudoId, CSSAnimationCollection&&); 504 505 const RenderStyle* lastStyleChangeEventStyle(PseudoId) const; 506 void setLastStyleChangeEventStyle(PseudoId, std::unique_ptr<const RenderStyle>&&); 506 507 507 508 #if ENABLE(FULLSCREEN_API) … … 717 718 ElementRareData& ensureElementRareData(); 718 719 719 ElementAnimationRareData* animationRareData( ) const;720 ElementAnimationRareData& ensureAnimationRareData( );720 ElementAnimationRareData* animationRareData(PseudoId) const; 721 ElementAnimationRareData& ensureAnimationRareData(PseudoId); 721 722 722 723 virtual int defaultTabIndex() const; -
trunk/Source/WebCore/dom/ElementRareData.cpp
r266769 r267571 37 37 LayoutSize sizeForResizing; 38 38 IntPoint savedLayerScrollPosition; 39 void* pointers[11]; 39 Vector<std::unique_ptr<ElementAnimationRareData>> animationRareData; 40 void* pointers[10]; 40 41 #if ENABLE(INTERSECTION_OBSERVER) 41 42 void* intersectionObserverData; -
trunk/Source/WebCore/dom/ElementRareData.h
r266769 r267571 90 90 void setSavedLayerScrollPosition(IntPoint position) { m_savedLayerScrollPosition = position; } 91 91 92 ElementAnimationRareData* elementAnimationRareData() { return m_animationRareData.get(); }93 ElementAnimationRareData& ensureAnimationRareData( );92 ElementAnimationRareData* animationRareData(PseudoId) const; 93 ElementAnimationRareData& ensureAnimationRareData(PseudoId); 94 94 95 95 DOMTokenList* partList() const { return m_partList.get(); } … … 142 142 result.add(UseType::ResizeObserver); 143 143 #endif 144 if ( m_animationRareData)144 if (!m_animationRareData.isEmpty()) 145 145 result.add(UseType::Animations); 146 146 if (m_beforePseudoElement || m_afterPseudoElement) … … 176 176 #endif 177 177 178 std::unique_ptr<ElementAnimationRareData> m_animationRareData;178 Vector<std::unique_ptr<ElementAnimationRareData>> m_animationRareData; 179 179 180 180 RefPtr<PseudoElement> m_beforePseudoElement; … … 238 238 } 239 239 240 inline ElementAnimationRareData& ElementRareData::ensureAnimationRareData() 241 { 242 if (!m_animationRareData) 243 m_animationRareData = makeUnique<ElementAnimationRareData>(); 244 return *m_animationRareData.get(); 240 inline ElementAnimationRareData* ElementRareData::animationRareData(PseudoId pseudoId) const 241 { 242 for (auto& animationRareData : m_animationRareData) { 243 if (animationRareData->pseudoId() == pseudoId) 244 return animationRareData.get(); 245 } 246 return nullptr; 247 } 248 249 inline ElementAnimationRareData& ElementRareData::ensureAnimationRareData(PseudoId pseudoId) 250 { 251 if (auto* animationRareData = this->animationRareData(pseudoId)) 252 return *animationRareData; 253 254 m_animationRareData.append(makeUnique<ElementAnimationRareData>(pseudoId)); 255 return *m_animationRareData.last().get(); 245 256 } 246 257 -
trunk/Source/WebCore/dom/PseudoElement.cpp
r267188 r267571 91 91 92 92 if (auto* timeline = document().existingTimeline()) 93 timeline->elementWasRemoved( *this);93 timeline->elementWasRemoved(Styleable::fromElement(*this)); 94 94 95 95 m_hostElement = nullptr; … … 103 103 bool PseudoElement::isTargetedByKeyframeEffectRequiringPseudoElement() 104 104 { 105 if (auto* stack = keyframeEffectStack()) 106 return stack->requiresPseudoElement(); 105 if (m_hostElement) { 106 if (auto* stack = m_hostElement->keyframeEffectStack(pseudoId())) 107 return stack->requiresPseudoElement(); 108 } 107 109 return false; 108 110 } -
trunk/Source/WebCore/rendering/RenderBoxModelObject.cpp
r266716 r267571 2709 2709 if (auto* node = element()) { 2710 2710 if (auto* timeline = node->document().existingTimeline()) 2711 return timeline->runningAnimationsFor ElementAreAllAccelerated(*node);2711 return timeline->runningAnimationsForRendererAreAllAccelerated(*this); 2712 2712 } 2713 2713 return false; -
trunk/Source/WebCore/rendering/RenderLayerCompositor.cpp
r267188 r267571 2960 2960 return false; 2961 2961 2962 if (auto * element = renderer.element()) {2963 if (auto* effectsStack = element->keyframeEffectStack()) {2962 if (auto styleable = Styleable::fromRenderer(renderer)) { 2963 if (auto* effectsStack = styleable->keyframeEffectStack()) { 2964 2964 return (effectsStack->isCurrentlyAffectingProperty(CSSPropertyOpacity) 2965 2965 && (usesCompositing() || (m_compositingTriggers & ChromeClient::AnimatedOpacityTrigger))) … … 3495 3495 return false; 3496 3496 3497 if (auto * element = renderer.element()) {3498 if (auto* effectsStack = element->keyframeEffectStack())3497 if (auto styleable = Styleable::fromRenderer(renderer)) { 3498 if (auto* effectsStack = styleable->keyframeEffectStack()) 3499 3499 return effectsStack->isCurrentlyAffectingProperty(CSSPropertyTransform); 3500 3500 } -
trunk/Source/WebCore/rendering/style/RenderStyleConstants.cpp
r262620 r267571 944 944 case PseudoId::FirstLine: ts << "first-line"; break; 945 945 case PseudoId::FirstLetter: ts << "first-letter"; break; 946 case PseudoId::Highlight: ts << "highlight"; break; 946 947 case PseudoId::Marker: ts << "marker"; break; 947 948 case PseudoId::Before: ts << "before"; break; -
trunk/Source/WebCore/rendering/updating/RenderTreeUpdater.cpp
r267191 r267571 559 559 if (timeline) { 560 560 if (document.renderTreeBeingDestroyed()) 561 timeline->cancelDeclarativeAnimationsFor Element(element, WebAnimation::Silently::Yes);561 timeline->cancelDeclarativeAnimationsForStyleable(Styleable::fromElement(element), WebAnimation::Silently::Yes); 562 562 else if (teardownType == TeardownType::RendererUpdateCancelingAnimations) 563 timeline->cancelDeclarativeAnimationsFor Element(element, WebAnimation::Silently::No);563 timeline->cancelDeclarativeAnimationsForStyleable(Styleable::fromElement(element), WebAnimation::Silently::No); 564 564 } 565 565 break; 566 566 case TeardownType::RendererUpdate: 567 567 if (timeline) 568 timeline->willChangeRendererFor Element(element);568 timeline->willChangeRendererForStyleable(Styleable::fromElement(element)); 569 569 break; 570 570 } -
trunk/Source/WebCore/style/StyleTreeResolver.cpp
r267191 r267571 218 218 } 219 219 220 auto update = createAnimatedElementUpdate(WTFMove(newStyle), element, parent().change);220 auto update = createAnimatedElementUpdate(WTFMove(newStyle), { element, PseudoId::None }, parent().change); 221 221 auto descendantsToResolve = computeDescendantsToResolve(update.change, element.styleValidity(), parent().descendantsToResolve); 222 222 … … 278 278 return { }; 279 279 280 return createAnimatedElementUpdate(WTFMove(pseudoStyle), element.ensurePseudoElement(pseudoId), elementUpdate.change);280 return createAnimatedElementUpdate(WTFMove(pseudoStyle), { element, pseudoId }, elementUpdate.change); 281 281 } 282 282 … … 307 307 } 308 308 309 ElementUpdate TreeResolver::createAnimatedElementUpdate(std::unique_ptr<RenderStyle> newStyle, Element& element, Change parentChange) 310 { 311 auto* oldStyle = element.renderOrDisplayContentsStyle(); 309 ElementUpdate TreeResolver::createAnimatedElementUpdate(std::unique_ptr<RenderStyle> newStyle, const Styleable& styleable, Change parentChange) 310 { 311 auto& element = styleable.element; 312 313 // FIXME: Ideally we could just call Element::renderOrDisplayContentsStyle() with a PseudoId 314 // and get the style for any PseudoId, not just PseudoId::Before or PseudoId::After. 315 auto* pseudoElement = [styleable]() -> PseudoElement* { 316 switch (styleable.pseudoId) { 317 case PseudoId::Before: 318 return styleable.element.beforePseudoElement(); 319 case PseudoId::After: 320 return styleable.element.afterPseudoElement(); 321 default: 322 return nullptr; 323 } 324 }(); 325 auto* oldStyle = pseudoElement ? pseudoElement->renderOrDisplayContentsStyle() : element.renderOrDisplayContentsStyle(); 312 326 313 327 OptionSet<AnimationImpact> animationImpact; … … 318 332 if (element.document().backForwardCacheState() == Document::NotInBackForwardCache && !element.document().renderView()->printing()) { 319 333 if (oldStyle && (oldStyle->hasTransitions() || newStyle->hasTransitions())) 320 m_document.timeline().updateCSSTransitionsFor Element(element, *oldStyle, *newStyle);334 m_document.timeline().updateCSSTransitionsForStyleable(styleable, *oldStyle, *newStyle); 321 335 322 336 // The order in which CSS Transitions and CSS Animations are updated matters since CSS Transitions define the after-change style … … 324 338 // such that when CSS Transitions are updated the CSS Animations data is the same as during the previous style change event. 325 339 if ((oldStyle && oldStyle->hasAnimations()) || newStyle->hasAnimations()) { 326 // FIXME: Remove this hack and pass the parent style via updateCSSAnimationsFor Element.340 // FIXME: Remove this hack and pass the parent style via updateCSSAnimationsForStyleable. 327 341 scope().resolver.setParentElementStyleForKeyframes(&parent().style); 328 342 329 m_document.timeline().updateCSSAnimationsFor Element(element, oldStyle, *newStyle);343 m_document.timeline().updateCSSAnimationsForStyleable(styleable, oldStyle, *newStyle); 330 344 331 345 scope().resolver.setParentElementStyleForKeyframes(nullptr); … … 335 349 // Now we can update all Web animations, which will include CSS Animations as well 336 350 // as animations created via the JS API. 337 if ( element.hasKeyframeEffects()) {351 if (styleable.hasKeyframeEffects()) { 338 352 // Record the style prior to applying animations for this style change event. 339 element.setLastStyleChangeEventStyle(RenderStyle::clonePtr(*newStyle));353 styleable.setLastStyleChangeEventStyle(RenderStyle::clonePtr(*newStyle)); 340 354 // Apply all keyframe effects to the new style. 341 355 auto animatedStyle = RenderStyle::clonePtr(*newStyle); 342 animationImpact = element.applyKeyframeEffects(*animatedStyle);356 animationImpact = styleable.applyKeyframeEffects(*animatedStyle); 343 357 newStyle = WTFMove(animatedStyle); 344 358 } else 345 element.setLastStyleChangeEventStyle(nullptr);359 styleable.setLastStyleChangeEventStyle(nullptr); 346 360 347 361 if (animationImpact) -
trunk/Source/WebCore/style/StyleTreeResolver.h
r267191 r267571 31 31 #include "StyleSharingResolver.h" 32 32 #include "StyleUpdate.h" 33 #include "Styleable.h" 33 34 #include <wtf/Function.h> 34 35 #include <wtf/Ref.h> … … 61 62 ElementUpdates resolveElement(Element&); 62 63 63 ElementUpdate createAnimatedElementUpdate(std::unique_ptr<RenderStyle>, Element&, Change);64 ElementUpdate createAnimatedElementUpdate(std::unique_ptr<RenderStyle>, const Styleable&, Change); 64 65 ElementUpdate resolvePseudoStyle(Element&, const ElementUpdate&, PseudoId); 65 66
Note:
See TracChangeset
for help on using the changeset viewer.