-
Notifications
You must be signed in to change notification settings - Fork 1.3k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[web-animations]
KeyframeValue
and AcceleratedEffectKeyframe
shou…
…ld derive from a shared base class https://bugs.webkit.org/show_bug.cgi?id=264747 Reviewed by Dean Jackson. As part of the work on threaded animation resolution (see bug 250970), we will need to have the keyframe interpolation logic currently contained in `KeyframeEffect` also apply to `AcceleratedEffect`. This will require a fair amount of refactoring to move all the relevant code in a shared base class for both `KeyframeEffect` and `AcceleratedEffect`. The first step towards this goal is to have the keyframe class backing those animation effect classes, `KeyframeValue` and `AcceleratedEffectKeyframe`, use a shared base class. In this patch we introduce a new `KeyframeInterpolation` class, which is currently empty except for the nested `KeyframeInterpolation::Keyframe`. It exposes a simple set of methods that `KeyframeValue` and `AcceleratedEffectKeyframe` now override: double offset() const; std::optional<CompositeOperation> compositeOperation() const; bool animatesProperty(Property) const; We also add a new abstract `AnimatedProperty` which can be either `AnimatableCSSProperty` or `AcceleratedEffectProperty`. * Source/WebCore/Headers.cmake: * Source/WebCore/WebCore.xcodeproj/project.pbxproj: * Source/WebCore/animation/KeyframeEffect.cpp: (WebCore::KeyframeEffect::getKeyframes): (WebCore::KeyframeEffect::setAnimatedPropertiesInStyle): (WebCore::KeyframeEffect::computeExtentOfTransformAnimation const): (WebCore::KeyframeEffect::progressUntilNextStep const): (WebCore::KeyframeEffect::computeHasImplicitKeyframeForAcceleratedProperty): * Source/WebCore/animation/KeyframeInterpolation.h: Added. (WebCore::KeyframeInterpolation::Keyframe::isAcceleratedEffectKeyframe const): (WebCore::KeyframeInterpolation::Keyframe::isKeyframeValue const): * Source/WebCore/animation/WebAnimationTypes.h: * Source/WebCore/inspector/agents/InspectorAnimationAgent.cpp: (WebCore::buildObjectForKeyframes): * Source/WebCore/platform/animation/AcceleratedEffect.cpp: (WebCore::AcceleratedEffect::Keyframe::Keyframe): (WebCore::AcceleratedEffect::Keyframe::animatesProperty const): (WebCore::AcceleratedEffect::Keyframe::clone const): (WebCore::AcceleratedEffect::create): (WebCore::AcceleratedEffect::AcceleratedEffect): (WebCore::AcceleratedEffectKeyframe::clone const): Deleted. * Source/WebCore/platform/animation/AcceleratedEffect.h: (WebCore::AcceleratedEffect::keyframes const): * Source/WebCore/rendering/RenderLayerBacking.cpp: (WebCore::RenderLayerBacking::startAnimation): * Source/WebCore/rendering/style/KeyframeList.cpp: (WebCore::KeyframeList::operator== const): (WebCore::KeyframeList::insert): (WebCore::KeyframeList::hasImplicitKeyframes const): (WebCore::KeyframeList::copyKeyframes): (WebCore::KeyframeList::fillImplicitKeyframes): (WebCore::KeyframeValue::animatesProperty const): (WebCore::KeyframeValue::containsProperty const): Deleted. * Source/WebCore/rendering/style/KeyframeList.h: (WebCore::KeyframeValue::KeyframeValue): Deleted. (WebCore::KeyframeValue::properties const): Deleted. (WebCore::KeyframeValue::key const): Deleted. (WebCore::KeyframeValue::setKey): Deleted. (WebCore::KeyframeValue::style const): Deleted. (WebCore::KeyframeValue::setStyle): Deleted. (WebCore::KeyframeValue::timingFunction const): Deleted. (WebCore::KeyframeValue::setTimingFunction): Deleted. (WebCore::KeyframeValue::compositeOperation const): Deleted. (WebCore::KeyframeValue::setCompositeOperation): Deleted. (WebCore::KeyframeValue::containsDirectionAwareProperty const): Deleted. (WebCore::KeyframeValue::setContainsDirectionAwareProperty): Deleted. * Source/WebCore/style/StyleResolver.cpp: (WebCore::Style::Resolver::keyframeStylesForAnimation): * Source/WebKit/Shared/WebCoreArgumentCoders.serialization.in: Canonical link: https://commits.webkit.org/270648@main
- Loading branch information
Showing
13 changed files
with
231 additions
and
119 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,57 @@ | ||
/* | ||
* Copyright (C) 2023 Apple Inc. All rights reserved. | ||
* | ||
* Redistribution and use in source and binary forms, with or without | ||
* modification, are permitted provided that the following conditions | ||
* are met: | ||
* 1. Redistributions of source code must retain the above copyright | ||
* notice, this list of conditions and the following disclaimer. | ||
* 2. Redistributions in binary form must reproduce the above copyright | ||
* notice, this list of conditions and the following disclaimer in the | ||
* documentation and/or other materials provided with the distribution. | ||
* | ||
* THIS SOFTWARE IS PROVIDED BY APPLE INC. ``AS IS'' AND ANY | ||
* EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE | ||
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR | ||
* PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR | ||
* CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, | ||
* EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, | ||
* PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR | ||
* PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY | ||
* OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT | ||
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE | ||
* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. | ||
*/ | ||
|
||
#pragma once | ||
|
||
#include "CompositeOperation.h" | ||
#include "WebAnimationTypes.h" | ||
#include <optional> | ||
#include <wtf/Seconds.h> | ||
|
||
namespace WebCore { | ||
|
||
class KeyframeInterpolation { | ||
public: | ||
using Property = std::variant<AnimatableCSSProperty, AcceleratedEffectProperty>; | ||
|
||
class Keyframe { | ||
public: | ||
virtual double offset() const = 0; | ||
virtual std::optional<CompositeOperation> compositeOperation() const = 0; | ||
virtual bool animatesProperty(Property) const = 0; | ||
|
||
virtual bool isAcceleratedEffectKeyframe() const { return false; } | ||
virtual bool isKeyframeValue() const { return false; } | ||
|
||
virtual ~Keyframe() = default; | ||
}; | ||
}; | ||
|
||
} // namespace WebCore | ||
|
||
#define SPECIALIZE_TYPE_TRAITS_KEYFRAME_INTERPOLATION_KEYFRAME(ToValueTypeName, predicate) \ | ||
SPECIALIZE_TYPE_TRAITS_BEGIN(WebCore::ToValueTypeName) \ | ||
static bool isType(const WebCore::KeyframeInterpolation::Keyframe& value) { return value.predicate; } \ | ||
SPECIALIZE_TYPE_TRAITS_END() |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.