1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128
|
// Copyright 2016 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
#ifndef KeyframeEffectReadOnly_h
#define KeyframeEffectReadOnly_h
#include "core/CoreExport.h"
#include "core/animation/AnimationEffectReadOnly.h"
#include "core/animation/EffectModel.h"
namespace blink {
class DictionarySequenceOrDictionary;
class Element;
class ExceptionState;
class ExecutionContext;
class KeyframeEffectOptions;
class PropertyHandle;
class SampledEffect;
// Represents the effect of an Animation on an Element's properties.
// http://w3c.github.io/web-animations/#the-keyframeeffect-interfaces
class CORE_EXPORT KeyframeEffectReadOnly : public AnimationEffectReadOnly {
DEFINE_WRAPPERTYPEINFO();
public:
enum Priority { DefaultPriority, TransitionPriority };
static KeyframeEffectReadOnly* create(Element*,
EffectModel*,
const Timing&,
Priority = DefaultPriority,
EventDelegate* = nullptr);
// Web Animations API Bindings constructors.
static KeyframeEffectReadOnly* create(
ExecutionContext*,
Element*,
const DictionarySequenceOrDictionary& effectInput,
double duration,
ExceptionState&);
static KeyframeEffectReadOnly* create(
ExecutionContext*,
Element*,
const DictionarySequenceOrDictionary& effectInput,
const KeyframeEffectOptions& timingInput,
ExceptionState&);
static KeyframeEffectReadOnly* create(
ExecutionContext*,
Element*,
const DictionarySequenceOrDictionary& effectInput,
ExceptionState&);
~KeyframeEffectReadOnly() override {}
bool isKeyframeEffectReadOnly() const override { return true; }
bool affects(PropertyHandle) const;
const EffectModel* model() const { return m_model.get(); }
EffectModel* model() { return m_model.get(); }
void setModel(EffectModel* model) { m_model = model; }
Priority getPriority() const { return m_priority; }
Element* target() const { return m_target; }
void notifySampledEffectRemovedFromEffectStack();
bool isCandidateForAnimationOnCompositor(double animationPlaybackRate) const;
// Must only be called once.
bool maybeStartAnimationOnCompositor(int group,
double startTime,
double timeOffset,
double animationPlaybackRate);
bool hasActiveAnimationsOnCompositor() const;
bool hasActiveAnimationsOnCompositor(CSSPropertyID) const;
bool cancelAnimationOnCompositor();
void restartAnimationOnCompositor();
void cancelIncompatibleAnimationsOnCompositor();
void pauseAnimationForTestingOnCompositor(double pauseTime);
void attachCompositedLayers();
void setCompositorAnimationIdsForTesting(
const Vector<int>& compositorAnimationIds) {
m_compositorAnimationIds = compositorAnimationIds;
}
DECLARE_VIRTUAL_TRACE();
void downgradeToNormal() { m_priority = DefaultPriority; }
protected:
KeyframeEffectReadOnly(Element*,
EffectModel*,
const Timing&,
Priority,
EventDelegate*);
void applyEffects();
void clearEffects();
void updateChildrenAndEffects() const override;
void attach(Animation*) override;
void detach() override;
void specifiedTimingChanged() override;
double calculateTimeToEffectChange(bool forwards,
double inheritedTime,
double timeToNextIteration) const override;
virtual bool hasIncompatibleStyle();
bool hasMultipleTransformProperties() const;
private:
Member<Element> m_target;
Member<EffectModel> m_model;
Member<SampledEffect> m_sampledEffect;
Priority m_priority;
Vector<int> m_compositorAnimationIds;
};
DEFINE_TYPE_CASTS(KeyframeEffectReadOnly,
AnimationEffectReadOnly,
animationNode,
animationNode->isKeyframeEffectReadOnly(),
animationNode.isKeyframeEffectReadOnly());
} // namespace blink
#endif // KeyframeEffectReadOnly_h
|