Changeset 149694 in webkit


Ignore:
Timestamp:
May 7, 2013 3:04:01 PM (11 years ago)
Author:
andersca@apple.com
Message:

Clean up KeyframeValueList and related classes
https://bugs.webkit.org/show_bug.cgi?id=115738

Reviewed by Simon Fraser.

Source/WebCore:

Add static create() functions to the AnimationValue subclasses, and change a bunch of parameters
and return values that can never be null from pointer types to reference types to better indicate this.

  • platform/graphics/GraphicsLayer.cpp:

(WebCore::filterOperationsAt):
(WebCore::GraphicsLayer::validateFilterOperations):
(WebCore::operationsAt):
(WebCore::GraphicsLayer::validateTransformOperations):

  • platform/graphics/GraphicsLayer.h:

(AnimationValue):
(WebCore::AnimationValue::AnimationValue):
(WebCore::FloatAnimationValue::create):
(FloatAnimationValue):
(WebCore::FloatAnimationValue::FloatAnimationValue):
(WebCore::TransformAnimationValue::create):
(TransformAnimationValue):
(WebCore::TransformAnimationValue::value):
(WebCore::TransformAnimationValue::TransformAnimationValue):
(WebCore::FilterAnimationValue::create):
(WebCore::FilterAnimationValue::value):
(WebCore::FilterAnimationValue::FilterAnimationValue):
(FilterAnimationValue):
(WebCore::KeyframeValueList::~KeyframeValueList):
(KeyframeValueList):
(WebCore::KeyframeValueList::at):

  • platform/graphics/ca/GraphicsLayerCA.cpp:

(WebCore::animationHasStepsTimingFunction):
(WebCore::GraphicsLayerCA::createTransformAnimationsFromKeyframes):
(WebCore::GraphicsLayerCA::createFilterAnimationsFromKeyframes):
(WebCore::GraphicsLayerCA::timingFunctionForAnimationValue):
(WebCore::GraphicsLayerCA::setAnimationEndpoints):
(WebCore::GraphicsLayerCA::setAnimationKeyframes):
(WebCore::GraphicsLayerCA::setTransformAnimationEndpoints):
(WebCore::GraphicsLayerCA::setTransformAnimationKeyframes):
(WebCore::GraphicsLayerCA::setFilterAnimationEndpoints):
(WebCore::GraphicsLayerCA::setFilterAnimationKeyframes):

  • platform/graphics/ca/GraphicsLayerCA.h:

(GraphicsLayerCA):

  • rendering/RenderLayerBacking.cpp:

(WebCore::RenderLayerBacking::startAnimation):
(WebCore::RenderLayerBacking::startTransition):

Source/WebKit2:

Update for WebCore changes.

  • Shared/CoordinatedGraphics/CoordinatedGraphicsArgumentCoders.cpp:

(CoreIPC::::decode):

Location:
trunk/Source
Files:
12 edited

Legend:

Unmodified
Added
Removed
  • trunk/Source/WebCore/ChangeLog

    r149693 r149694  
     12013-05-07  Anders Carlsson  <andersca@apple.com>
     2
     3        Clean up KeyframeValueList and related classes
     4        https://bugs.webkit.org/show_bug.cgi?id=115738
     5
     6        Reviewed by Simon Fraser.
     7
     8        Add static create() functions to the AnimationValue subclasses, and change a bunch of parameters
     9        and return values that can never be null from pointer types to reference types to better indicate this.
     10
     11        * platform/graphics/GraphicsLayer.cpp:
     12        (WebCore::filterOperationsAt):
     13        (WebCore::GraphicsLayer::validateFilterOperations):
     14        (WebCore::operationsAt):
     15        (WebCore::GraphicsLayer::validateTransformOperations):
     16        * platform/graphics/GraphicsLayer.h:
     17        (AnimationValue):
     18        (WebCore::AnimationValue::AnimationValue):
     19        (WebCore::FloatAnimationValue::create):
     20        (FloatAnimationValue):
     21        (WebCore::FloatAnimationValue::FloatAnimationValue):
     22        (WebCore::TransformAnimationValue::create):
     23        (TransformAnimationValue):
     24        (WebCore::TransformAnimationValue::value):
     25        (WebCore::TransformAnimationValue::TransformAnimationValue):
     26        (WebCore::FilterAnimationValue::create):
     27        (WebCore::FilterAnimationValue::value):
     28        (WebCore::FilterAnimationValue::FilterAnimationValue):
     29        (FilterAnimationValue):
     30        (WebCore::KeyframeValueList::~KeyframeValueList):
     31        (KeyframeValueList):
     32        (WebCore::KeyframeValueList::at):
     33        * platform/graphics/ca/GraphicsLayerCA.cpp:
     34        (WebCore::animationHasStepsTimingFunction):
     35        (WebCore::GraphicsLayerCA::createTransformAnimationsFromKeyframes):
     36        (WebCore::GraphicsLayerCA::createFilterAnimationsFromKeyframes):
     37        (WebCore::GraphicsLayerCA::timingFunctionForAnimationValue):
     38        (WebCore::GraphicsLayerCA::setAnimationEndpoints):
     39        (WebCore::GraphicsLayerCA::setAnimationKeyframes):
     40        (WebCore::GraphicsLayerCA::setTransformAnimationEndpoints):
     41        (WebCore::GraphicsLayerCA::setTransformAnimationKeyframes):
     42        (WebCore::GraphicsLayerCA::setFilterAnimationEndpoints):
     43        (WebCore::GraphicsLayerCA::setFilterAnimationKeyframes):
     44        * platform/graphics/ca/GraphicsLayerCA.h:
     45        (GraphicsLayerCA):
     46        * rendering/RenderLayerBacking.cpp:
     47        (WebCore::RenderLayerBacking::startAnimation):
     48        (WebCore::RenderLayerBacking::startTransition):
     49
    1502013-05-07  Anders Carlsson  <andersca@apple.com>
    251
  • trunk/Source/WebCore/platform/graphics/GraphicsLayer.cpp

    r149661 r149694  
    410410
    411411#if ENABLE(CSS_FILTERS)
    412 static inline const FilterOperations* filterOperationsAt(const KeyframeValueList& valueList, size_t index)
    413 {
    414     return static_cast<const FilterAnimationValue*>(valueList.at(index))->value();
     412static inline const FilterOperations& filterOperationsAt(const KeyframeValueList& valueList, size_t index)
     413{
     414    return static_cast<const FilterAnimationValue&>(valueList.at(index)).value();
    415415}
    416416
     
    425425    size_t firstIndex = 0;
    426426    for ( ; firstIndex < valueList.size(); ++firstIndex) {
    427         if (filterOperationsAt(valueList, firstIndex)->operations().size() > 0)
     427        if (!filterOperationsAt(valueList, firstIndex).operations().isEmpty())
    428428            break;
    429429    }
     
    432432        return -1;
    433433
    434     const FilterOperations* firstVal = filterOperationsAt(valueList, firstIndex);
     434    const FilterOperations& firstVal = filterOperationsAt(valueList, firstIndex);
    435435   
    436436    for (size_t i = firstIndex + 1; i < valueList.size(); ++i) {
    437         const FilterOperations* val = filterOperationsAt(valueList, i);
     437        const FilterOperations& val = filterOperationsAt(valueList, i);
    438438       
    439439        // An emtpy filter list matches anything.
    440         if (val->operations().isEmpty())
     440        if (val.operations().isEmpty())
    441441            continue;
    442442       
    443         if (!firstVal->operationsMatch(*val))
     443        if (!firstVal.operationsMatch(val))
    444444            return -1;
    445445    }
     
    453453// true if the rotation between any two keyframes is >= 180 degrees.
    454454
    455 static inline const TransformOperations* operationsAt(const KeyframeValueList& valueList, size_t index)
    456 {
    457     return static_cast<const TransformAnimationValue*>(valueList.at(index))->value();
     455static inline const TransformOperations& operationsAt(const KeyframeValueList& valueList, size_t index)
     456{
     457    return static_cast<const TransformAnimationValue&>(valueList.at(index)).value();
    458458}
    459459
     
    470470    size_t firstIndex = 0;
    471471    for ( ; firstIndex < valueList.size(); ++firstIndex) {
    472         if (operationsAt(valueList, firstIndex)->operations().size() > 0)
     472        if (!operationsAt(valueList, firstIndex).operations().isEmpty())
    473473            break;
    474474    }
     
    477477        return -1;
    478478       
    479     const TransformOperations* firstVal = operationsAt(valueList, firstIndex);
     479    const TransformOperations& firstVal = operationsAt(valueList, firstIndex);
    480480   
    481481    // See if the keyframes are valid.
    482482    for (size_t i = firstIndex + 1; i < valueList.size(); ++i) {
    483         const TransformOperations* val = operationsAt(valueList, i);
    484        
    485         // An emtpy transform list matches anything.
    486         if (val->operations().isEmpty())
     483        const TransformOperations& val = operationsAt(valueList, i);
     484       
     485        // An empty transform list matches anything.
     486        if (val.operations().isEmpty())
    487487            continue;
    488488           
    489         if (!firstVal->operationsMatch(*val))
     489        if (!firstVal.operationsMatch(val))
    490490            return -1;
    491491    }
     
    495495    double maxRotAngle = -1.0;
    496496       
    497     for (size_t j = 0; j < firstVal->operations().size(); ++j) {
    498         TransformOperation::OperationType type = firstVal->operations().at(j)->getOperationType();
     497    for (size_t j = 0; j < firstVal.operations().size(); ++j) {
     498        TransformOperation::OperationType type = firstVal.operations().at(j)->getOperationType();
    499499       
    500500        // if this is a rotation entry, we need to see if any angle differences are >= 180 deg
     
    503503            type == TransformOperation::ROTATE_Z ||
    504504            type == TransformOperation::ROTATE_3D) {
    505             lastRotAngle = static_cast<RotateTransformOperation*>(firstVal->operations().at(j).get())->angle();
     505            lastRotAngle = static_cast<RotateTransformOperation*>(firstVal.operations().at(j).get())->angle();
    506506           
    507507            if (maxRotAngle < 0)
     
    509509           
    510510            for (size_t i = firstIndex + 1; i < valueList.size(); ++i) {
    511                 const TransformOperations* val = operationsAt(valueList, i);
    512                 double rotAngle = val->operations().isEmpty() ? 0 : (static_cast<RotateTransformOperation*>(val->operations().at(j).get())->angle());
     511                const TransformOperations& val = operationsAt(valueList, i);
     512                double rotAngle = val.operations().isEmpty() ? 0 : (static_cast<RotateTransformOperation*>(val.operations().at(j).get())->angle());
    513513                double diffAngle = fabs(rotAngle - lastRotAngle);
    514514                if (diffAngle > maxRotAngle)
  • trunk/Source/WebCore/platform/graphics/GraphicsLayer.h

    r149661 r149694  
    7373    WTF_MAKE_FAST_ALLOCATED;
    7474public:
    75     explicit AnimationValue(float keyTime, PassRefPtr<TimingFunction> timingFunction = 0)
    76         : m_keyTime(keyTime)
    77         , m_timingFunction(timingFunction)
    78     {
    79     }
    80    
    8175    virtual ~AnimationValue() { }
    8276
     
    8478    const TimingFunction* timingFunction() const { return m_timingFunction.get(); }
    8579    virtual PassOwnPtr<AnimationValue> clone() const = 0;
     80
     81protected:
     82    AnimationValue(float keyTime, PassRefPtr<TimingFunction> timingFunction = 0)
     83        : m_keyTime(keyTime)
     84        , m_timingFunction(timingFunction)
     85    {
     86    }
    8687
    8788private:
     
    9495class FloatAnimationValue : public AnimationValue {
    9596public:
    96     FloatAnimationValue(float keyTime, float value, PassRefPtr<TimingFunction> timingFunction = 0)
     97    static PassOwnPtr<FloatAnimationValue> create(float keyTime, float value, PassRefPtr<TimingFunction> timingFunction = 0)
     98    {
     99        return adoptPtr(new FloatAnimationValue(keyTime, value, timingFunction));
     100    }
     101
     102    virtual PassOwnPtr<AnimationValue> clone() const OVERRIDE
     103    {
     104        return adoptPtr(new FloatAnimationValue(*this));
     105    }
     106
     107    float value() const { return m_value; }
     108
     109private:
     110    FloatAnimationValue(float keyTime, float value, PassRefPtr<TimingFunction> timingFunction)
    97111        : AnimationValue(keyTime, timingFunction)
    98112        , m_value(value)
    99113    {
    100114    }
    101     virtual PassOwnPtr<AnimationValue> clone() const OVERRIDE { return adoptPtr(new FloatAnimationValue(*this)); }
    102 
    103     float value() const { return m_value; }
    104 
    105 private:
     115
    106116    float m_value;
    107117};
     
    111121class TransformAnimationValue : public AnimationValue {
    112122public:
    113     explicit TransformAnimationValue(float keyTime, const TransformOperations* value = 0, PassRefPtr<TimingFunction> timingFunction = 0)
     123    static PassOwnPtr<TransformAnimationValue> create(float keyTime, const TransformOperations& value, PassRefPtr<TimingFunction> timingFunction = 0)
     124    {
     125        return adoptPtr(new TransformAnimationValue(keyTime, value, timingFunction));
     126    }
     127
     128    virtual PassOwnPtr<AnimationValue> clone() const OVERRIDE
     129    {
     130        return adoptPtr(new TransformAnimationValue(*this));
     131    }
     132
     133    const TransformOperations& value() const { return m_value; }
     134
     135private:
     136    TransformAnimationValue(float keyTime, const TransformOperations& value, PassRefPtr<TimingFunction> timingFunction)
    114137        : AnimationValue(keyTime, timingFunction)
    115     {
    116         if (value)
    117             m_value = *value;
    118     }
    119     virtual PassOwnPtr<AnimationValue> clone() const OVERRIDE { return adoptPtr(new TransformAnimationValue(*this)); }
    120 
    121     const TransformOperations* value() const { return &m_value; }
    122 
    123 private:
     138        , m_value(value)
     139    {
     140    }
     141
    124142    TransformOperations m_value;
    125143};
     
    130148class FilterAnimationValue : public AnimationValue {
    131149public:
    132     explicit FilterAnimationValue(float keyTime, const FilterOperations* value = 0, PassRefPtr<TimingFunction> timingFunction = 0)
     150    static PassOwnPtr<FilterAnimationValue> create(float keyTime, const FilterOperations& value, PassRefPtr<TimingFunction> timingFunction = 0)
     151    {
     152        return adoptPtr(new FilterAnimationValue(keyTime, value, timingFunction));
     153    }
     154
     155    virtual PassOwnPtr<AnimationValue> clone() const OVERRIDE
     156    {
     157        return adoptPtr(new FilterAnimationValue(*this));
     158    }
     159
     160    const FilterOperations& value() const { return m_value; }
     161
     162private:
     163    FilterAnimationValue(float keyTime, const FilterOperations& value, PassRefPtr<TimingFunction> timingFunction)
    133164        : AnimationValue(keyTime, timingFunction)
    134     {
    135         if (value)
    136             m_value = *value;
    137     }
    138     virtual PassOwnPtr<AnimationValue> clone() const OVERRIDE { return adoptPtr(new FilterAnimationValue(*this)); }
    139 
    140     const FilterOperations* value() const { return &m_value; }
    141 
    142 private:
     165        , m_value(value)
     166    {
     167    }
     168
    143169    FilterOperations m_value;
    144170};
     
    162188    }
    163189
     190    ~KeyframeValueList()
     191    {
     192    }
     193
    164194    KeyframeValueList& operator=(const KeyframeValueList& other)
    165195    {
     
    178208
    179209    size_t size() const { return m_values.size(); }
    180     const AnimationValue* at(size_t i) const { return m_values.at(i).get(); }
     210    const AnimationValue& at(size_t i) const { return *m_values.at(i); }
    181211   
    182212    // Insert, sorted by keyTime.
  • trunk/Source/WebCore/platform/graphics/GraphicsLayerAnimation.cpp

    r147746 r149694  
    4040
    4141
    42 static FilterOperations applyFilterAnimation(const FilterOperations* from, const FilterOperations* to, double progress, const IntSize& boxSize)
     42static FilterOperations applyFilterAnimation(const FilterOperations& from, const FilterOperations& to, double progress, const IntSize& boxSize)
    4343{
    4444    // First frame of an animation.
    4545    if (!progress)
    46         return *from;
     46        return from;
    4747
    4848    // Last frame of an animation.
    4949    if (progress == 1)
    50         return *to;
    51 
    52     if (!from->isEmpty() && !to->isEmpty() && !from->operationsMatch(*to))
    53         return *to;
     50        return to;
     51
     52    if (!from.isEmpty() && !to.isEmpty() && !from.operationsMatch(to))
     53        return to;
    5454
    5555    FilterOperations result;
    5656
    57     size_t fromSize = from->operations().size();
    58     size_t toSize = to->operations().size();
     57    size_t fromSize = from.operations().size();
     58    size_t toSize = to.operations().size();
    5959    size_t size = std::max(fromSize, toSize);
    6060    for (size_t i = 0; i < size; i++) {
    61         RefPtr<FilterOperation> fromOp = (i < fromSize) ? from->operations()[i].get() : 0;
    62         RefPtr<FilterOperation> toOp = (i < toSize) ? to->operations()[i].get() : 0;
     61        RefPtr<FilterOperation> fromOp = (i < fromSize) ? from.operations()[i].get() : 0;
     62        RefPtr<FilterOperation> toOp = (i < toSize) ? to.operations()[i].get() : 0;
    6363        RefPtr<FilterOperation> blendedOp = toOp ? blendFunc(fromOp.get(), toOp.get(), progress, boxSize) : (fromOp ? blendFunc(0, fromOp.get(), progress, boxSize, true) : 0);
    6464        if (blendedOp)
     
    156156}
    157157
    158 static TransformationMatrix applyTransformAnimation(const TransformOperations* from, const TransformOperations* to, double progress, const IntSize& boxSize, bool listsMatch)
     158static TransformationMatrix applyTransformAnimation(const TransformOperations& from, const TransformOperations& to, double progress, const IntSize& boxSize, bool listsMatch)
    159159{
    160160    TransformationMatrix matrix;
     
    162162    // First frame of an animation.
    163163    if (!progress) {
    164         from->apply(boxSize, matrix);
     164        from.apply(boxSize, matrix);
    165165        return matrix;
    166166    }
     
    168168    // Last frame of an animation.
    169169    if (progress == 1) {
    170         to->apply(boxSize, matrix);
     170        to.apply(boxSize, matrix);
    171171        return matrix;
    172172    }
     
    175175    if (!listsMatch) {
    176176        TransformationMatrix fromMatrix;
    177         to->apply(boxSize, matrix);
    178         from->apply(boxSize, fromMatrix);
     177        to.apply(boxSize, matrix);
     178        from.apply(boxSize, fromMatrix);
    179179        matrix.blend(fromMatrix, progress);
    180180        return matrix;
     
    182182
    183183    // Animation to "-webkit-transform: none".
    184     if (!to->size()) {
    185         TransformOperations blended(*from);
     184    if (!to.size()) {
     185        TransformOperations blended(from);
    186186        for (size_t i = 0; i < blended.operations().size(); ++i)
    187187            blended.operations()[i]->blend(0, progress, true)->apply(matrix, boxSize);
     
    190190
    191191    // Animation from "-webkit-transform: none".
    192     if (!from->size()) {
    193         TransformOperations blended(*to);
     192    if (!from.size()) {
     193        TransformOperations blended(to);
    194194        for (size_t i = 0; i < blended.operations().size(); ++i)
    195195            blended.operations()[i]->blend(0, 1. - progress, true)->apply(matrix, boxSize);
     
    198198
    199199    // Normal animation with a matching operation list.
    200     TransformOperations blended(*to);
     200    TransformOperations blended(to);
    201201    for (size_t i = 0; i < blended.operations().size(); ++i)
    202         blended.operations()[i]->blend(from->at(i), progress, !from->at(i))->apply(matrix, boxSize);
     202        blended.operations()[i]->blend(from.at(i), progress, !from.at(i))->apply(matrix, boxSize);
    203203    return matrix;
    204204}
    205205
    206 static const TimingFunction* timingFunctionForAnimationValue(const AnimationValue* animValue, const Animation* anim)
    207 {
    208     if (animValue->timingFunction())
    209         return animValue->timingFunction();
     206static const TimingFunction* timingFunctionForAnimationValue(const AnimationValue& animValue, const Animation* anim)
     207{
     208    if (animValue.timingFunction())
     209        return animValue.timingFunction();
    210210    if (anim->timingFunction())
    211211        return anim->timingFunction().get();
     
    228228}
    229229
    230 void GraphicsLayerAnimation::applyInternal(Client* client, const AnimationValue* from, const AnimationValue* to, float progress)
     230void GraphicsLayerAnimation::applyInternal(Client* client, const AnimationValue& from, const AnimationValue& to, float progress)
    231231{
    232232    switch (m_keyframes.property()) {
    233233    case AnimatedPropertyOpacity:
    234         client->setAnimatedOpacity(applyOpacityAnimation((static_cast<const FloatAnimationValue*>(from)->value()), (static_cast<const FloatAnimationValue*>(to)->value()), progress));
     234        client->setAnimatedOpacity(applyOpacityAnimation((static_cast<const FloatAnimationValue&>(from).value()), (static_cast<const FloatAnimationValue&>(to).value()), progress));
    235235        return;
    236236    case AnimatedPropertyWebkitTransform:
    237         client->setAnimatedTransform(applyTransformAnimation(static_cast<const TransformAnimationValue*>(from)->value(), static_cast<const TransformAnimationValue*>(to)->value(), progress, m_boxSize, m_listsMatch));
     237        client->setAnimatedTransform(applyTransformAnimation(static_cast<const TransformAnimationValue&>(from).value(), static_cast<const TransformAnimationValue&>(to).value(), progress, m_boxSize, m_listsMatch));
    238238        return;
    239239#if ENABLE(CSS_FILTERS)
    240240    case AnimatedPropertyWebkitFilter:
    241         client->setAnimatedFilters(applyFilterAnimation(static_cast<const FilterAnimationValue*>(from)->value(), static_cast<const FilterAnimationValue*>(to)->value(), progress, m_boxSize));
     241        client->setAnimatedFilters(applyFilterAnimation(static_cast<const FilterAnimationValue&>(from).value(), static_cast<const FilterAnimationValue&>(to).value(), progress, m_boxSize));
    242242        return;
    243243#endif
     
    305305
    306306    for (size_t i = 0; i < m_keyframes.size() - 1; ++i) {
    307         const AnimationValue* from = m_keyframes.at(i);
    308         const AnimationValue* to = m_keyframes.at(i + 1);
    309         if (from->keyTime() > normalizedValue || to->keyTime() < normalizedValue)
     307        const AnimationValue& from = m_keyframes.at(i);
     308        const AnimationValue& to = m_keyframes.at(i + 1);
     309        if (from.keyTime() > normalizedValue || to.keyTime() < normalizedValue)
    310310            continue;
    311311
    312         normalizedValue = (normalizedValue - from->keyTime()) / (to->keyTime() - from->keyTime());
     312        normalizedValue = (normalizedValue - from.keyTime()) / (to.keyTime() - from.keyTime());
    313313        const TimingFunction* timingFunction = timingFunctionForAnimationValue(from, m_animation.get());
    314314        normalizedValue = applyTimingFunction(timingFunction, normalizedValue, m_animation->duration());
  • trunk/Source/WebCore/platform/graphics/GraphicsLayerAnimation.h

    r136953 r149694  
    6767
    6868private:
    69     void applyInternal(Client*, const AnimationValue* from, const AnimationValue* to, float progress);
     69    void applyInternal(Client*, const AnimationValue& from, const AnimationValue& to, float progress);
    7070    KeyframeValueList m_keyframes;
    7171    IntSize m_boxSize;
  • trunk/Source/WebCore/platform/graphics/ca/GraphicsLayerCA.cpp

    r149665 r149694  
    243243   
    244244    for (unsigned i = 0; i < valueList.size(); ++i) {
    245         const TimingFunction* timingFunction = valueList.at(i)->timingFunction();
    246         if (timingFunction && timingFunction->isStepsTimingFunction())
    247             return true;
     245        if (const TimingFunction* timingFunction = valueList.at(i).timingFunction()) {
     246            if (timingFunction->isStepsTimingFunction())
     247                return true;
     248        }
    248249    }
    249250
     
    20922093    bool hasBigRotation;
    20932094    int listIndex = validateTransformOperations(valueList, hasBigRotation);
    2094     const TransformOperations* operations = (listIndex >= 0) ? static_cast<const TransformAnimationValue*>(valueList.at(listIndex))->value() : 0;
     2095    const TransformOperations* operations = (listIndex >= 0) ? &static_cast<const TransformAnimationValue&>(valueList.at(listIndex)).value() : 0;
    20952096
    20962097    // We need to fall back to software animation if we don't have setValueFunction:, and
     
    21822183        return false;
    21832184       
    2184     const FilterOperations* operations = static_cast<const FilterAnimationValue*>(valueList.at(listIndex))->value();
     2185    const FilterOperations& operations = static_cast<const FilterAnimationValue&>(valueList.at(listIndex)).value();
    21852186    // Make sure the platform layer didn't fallback to using software filter compositing instead.
    2186     if (!PlatformCALayer::filtersCanBeComposited(*operations))
     2187    if (!PlatformCALayer::filtersCanBeComposited(operations))
    21872188        return false;
    21882189
    2189     int numAnimations = operations->size();
     2190    int numAnimations = operations.size();
    21902191
    21912192    // FIXME: We can't currently hardware animate shadows.
    21922193    for (int i = 0; i < numAnimations; ++i) {
    2193         if (operations->at(i)->getOperationType() == FilterOperation::DROP_SHADOW)
     2194        if (operations.at(i)->getOperationType() == FilterOperation::DROP_SHADOW)
    21942195            return false;
    21952196    }
    21962197
    21972198    for (int animationIndex = 0; animationIndex < numAnimations; ++animationIndex) {
    2198         if (!appendToUncommittedAnimations(valueList, operations->operations().at(animationIndex).get(), animation, animationName, animationIndex, timeOffset))
     2199        if (!appendToUncommittedAnimations(valueList, operations.operations().at(animationIndex).get(), animation, animationName, animationIndex, timeOffset))
    21992200            return false;
    22002201    }
     
    22542255}
    22552256
    2256 const TimingFunction* GraphicsLayerCA::timingFunctionForAnimationValue(const AnimationValue* animValue, const Animation* anim)
    2257 {
    2258     if (animValue->timingFunction())
    2259         return animValue->timingFunction();
    2260     if (anim->isTimingFunctionSet())
    2261         return anim->timingFunction().get();
     2257const TimingFunction* GraphicsLayerCA::timingFunctionForAnimationValue(const AnimationValue& animValue, const Animation& anim)
     2258{
     2259    if (animValue.timingFunction())
     2260        return animValue.timingFunction();
     2261    if (anim.isTimingFunctionSet())
     2262        return anim.timingFunction().get();
    22622263   
    22632264    return CubicBezierTimingFunction::defaultTimingFunction();
     
    22732274    switch (valueList.property()) {
    22742275    case AnimatedPropertyOpacity: {
    2275         basicAnim->setFromValue(static_cast<const FloatAnimationValue*>(valueList.at(fromIndex))->value());
    2276         basicAnim->setToValue(static_cast<const FloatAnimationValue*>(valueList.at(toIndex))->value());
     2276        basicAnim->setFromValue(static_cast<const FloatAnimationValue&>(valueList.at(fromIndex)).value());
     2277        basicAnim->setToValue(static_cast<const FloatAnimationValue&>(valueList.at(toIndex)).value());
    22772278        break;
    22782279    }
     
    22842285    // This codepath is used for 2-keyframe animations, so we still need to look in the start
    22852286    // for a timing function. Even in the reversing animation case, the first keyframe provides the timing function.
    2286     const TimingFunction* timingFunction = timingFunctionForAnimationValue(valueList.at(0), animation);
     2287    const TimingFunction* timingFunction = timingFunctionForAnimationValue(valueList.at(0), *animation);
    22872288    if (timingFunction)
    22882289        basicAnim->setTimingFunction(timingFunction, !forwards);
     
    23012302    for (unsigned i = 0; i < valueList.size(); ++i) {
    23022303        unsigned index = forwards ? i : (valueList.size() - i - 1);
    2303         const AnimationValue* curValue = valueList.at(index);
    2304         keyTimes.append(forwards ? curValue->keyTime() : (1 - curValue->keyTime()));
     2304        const AnimationValue& curValue = valueList.at(index);
     2305        keyTimes.append(forwards ? curValue.keyTime() : (1 - curValue.keyTime()));
    23052306
    23062307        switch (valueList.property()) {
    23072308        case AnimatedPropertyOpacity: {
    2308             const FloatAnimationValue* floatValue = static_cast<const FloatAnimationValue*>(curValue);
    2309             values.append(floatValue->value());
     2309            const FloatAnimationValue& floatValue = static_cast<const FloatAnimationValue&>(curValue);
     2310            values.append(floatValue.value());
    23102311            break;
    23112312        }
     
    23162317
    23172318        if (i < (valueList.size() - 1))
    2318             timingFunctions.append(timingFunctionForAnimationValue(forwards ? curValue : valueList.at(index - 1), animation));
     2319            timingFunctions.append(timingFunctionForAnimationValue(forwards ? curValue : valueList.at(index - 1), *animation));
    23192320    }
    23202321   
     
    23352336    unsigned toIndex = forwards;
    23362337   
    2337     const TransformAnimationValue* startValue = static_cast<const TransformAnimationValue*>(valueList.at(fromIndex));
    2338     const TransformAnimationValue* endValue = static_cast<const TransformAnimationValue*>(valueList.at(toIndex));
     2338    const TransformAnimationValue& startValue = static_cast<const TransformAnimationValue&>(valueList.at(fromIndex));
     2339    const TransformAnimationValue& endValue = static_cast<const TransformAnimationValue&>(valueList.at(toIndex));
    23392340   
    23402341    if (isMatrixAnimation) {
    23412342        TransformationMatrix fromTransform, toTransform;
    2342         startValue->value()->apply(boxSize, fromTransform);
    2343         endValue->value()->apply(boxSize, toTransform);
     2343        startValue.value().apply(boxSize, fromTransform);
     2344        endValue.value().apply(boxSize, toTransform);
    23442345
    23452346        // If any matrix is singular, CA won't animate it correctly. So fall back to software animation
     
    23522353        if (isTransformTypeNumber(transformOpType)) {
    23532354            float fromValue;
    2354             getTransformFunctionValue(startValue->value()->at(functionIndex), transformOpType, boxSize, fromValue);
     2355            getTransformFunctionValue(startValue.value().at(functionIndex), transformOpType, boxSize, fromValue);
    23552356            basicAnim->setFromValue(fromValue);
    23562357           
    23572358            float toValue;
    2358             getTransformFunctionValue(endValue->value()->at(functionIndex), transformOpType, boxSize, toValue);
     2359            getTransformFunctionValue(endValue.value().at(functionIndex), transformOpType, boxSize, toValue);
    23592360            basicAnim->setToValue(toValue);
    23602361        } else if (isTransformTypeFloatPoint3D(transformOpType)) {
    23612362            FloatPoint3D fromValue;
    2362             getTransformFunctionValue(startValue->value()->at(functionIndex), transformOpType, boxSize, fromValue);
     2363            getTransformFunctionValue(startValue.value().at(functionIndex), transformOpType, boxSize, fromValue);
    23632364            basicAnim->setFromValue(fromValue);
    23642365           
    23652366            FloatPoint3D toValue;
    2366             getTransformFunctionValue(endValue->value()->at(functionIndex), transformOpType, boxSize, toValue);
     2367            getTransformFunctionValue(endValue.value().at(functionIndex), transformOpType, boxSize, toValue);
    23672368            basicAnim->setToValue(toValue);
    23682369        } else {
    23692370            TransformationMatrix fromValue;
    2370             getTransformFunctionValue(startValue->value()->at(functionIndex), transformOpType, boxSize, fromValue);
     2371            getTransformFunctionValue(startValue.value().at(functionIndex), transformOpType, boxSize, fromValue);
    23712372            basicAnim->setFromValue(fromValue);
    23722373
    23732374            TransformationMatrix toValue;
    2374             getTransformFunctionValue(endValue->value()->at(functionIndex), transformOpType, boxSize, toValue);
     2375            getTransformFunctionValue(endValue.value().at(functionIndex), transformOpType, boxSize, toValue);
    23752376            basicAnim->setToValue(toValue);
    23762377        }
     
    23792380    // This codepath is used for 2-keyframe animations, so we still need to look in the start
    23802381    // for a timing function. Even in the reversing animation case, the first keyframe provides the timing function.
    2381     const TimingFunction* timingFunction = timingFunctionForAnimationValue(valueList.at(0), animation);
     2382    const TimingFunction* timingFunction = timingFunctionForAnimationValue(valueList.at(0), *animation);
    23822383    basicAnim->setTimingFunction(timingFunction, !forwards);
    23832384
     
    24012402    for (unsigned i = 0; i < valueList.size(); ++i) {
    24022403        unsigned index = forwards ? i : (valueList.size() - i - 1);
    2403         const TransformAnimationValue* curValue = static_cast<const TransformAnimationValue*>(valueList.at(index));
    2404         keyTimes.append(forwards ? curValue->keyTime() : (1 - curValue->keyTime()));
     2404        const TransformAnimationValue& curValue = static_cast<const TransformAnimationValue&>(valueList.at(index));
     2405        keyTimes.append(forwards ? curValue.keyTime() : (1 - curValue.keyTime()));
    24052406
    24062407        if (isMatrixAnimation) {
    24072408            TransformationMatrix transform;
    2408             curValue->value()->apply(boxSize, transform);
     2409            curValue.value().apply(boxSize, transform);
    24092410
    24102411            // If any matrix is singular, CA won't animate it correctly. So fall back to software animation
     
    24142415            transformationMatrixValues.append(transform);
    24152416        } else {
    2416             const TransformOperation* transformOp = curValue->value()->at(functionIndex);
     2417            const TransformOperation* transformOp = curValue.value().at(functionIndex);
    24172418            if (isTransformTypeNumber(transformOpType)) {
    24182419                float value;
     
    24312432
    24322433        if (i < (valueList.size() - 1))
    2433             timingFunctions.append(timingFunctionForAnimationValue(forwards ? curValue : valueList.at(index - 1), animation));
     2434            timingFunctions.append(timingFunctionForAnimationValue(forwards ? curValue : valueList.at(index - 1), *animation));
    24342435    }
    24352436   
     
    24622463    unsigned toIndex = forwards;
    24632464
    2464     const FilterAnimationValue* fromValue = static_cast<const FilterAnimationValue*>(valueList.at(fromIndex));
    2465     const FilterAnimationValue* toValue = static_cast<const FilterAnimationValue*>(valueList.at(toIndex));
    2466 
    2467     const FilterOperation* fromOperation = fromValue->value()->at(functionIndex);
    2468     const FilterOperation* toOperation = toValue->value()->at(functionIndex);
     2465    const FilterAnimationValue& fromValue = static_cast<const FilterAnimationValue&>(valueList.at(fromIndex));
     2466    const FilterAnimationValue& toValue = static_cast<const FilterAnimationValue&>(valueList.at(toIndex));
     2467
     2468    const FilterOperation* fromOperation = fromValue.value().at(functionIndex);
     2469    const FilterOperation* toOperation = toValue.value().at(functionIndex);
    24692470
    24702471    RefPtr<DefaultFilterOperation> defaultFromOperation;
     
    24882489    // This codepath is used for 2-keyframe animations, so we still need to look in the start
    24892490    // for a timing function. Even in the reversing animation case, the first keyframe provides the timing function.
    2490     basicAnim->setTimingFunction(timingFunctionForAnimationValue(valueList.at(0), animation), !forwards);
     2491    basicAnim->setTimingFunction(timingFunctionForAnimationValue(valueList.at(0), *animation), !forwards);
    24912492
    24922493    return true;
     
    25042505    for (unsigned i = 0; i < valueList.size(); ++i) {
    25052506        unsigned index = forwards ? i : (valueList.size() - i - 1);
    2506         const FilterAnimationValue* curValue = static_cast<const FilterAnimationValue*>(valueList.at(index));
    2507         keyTimes.append(forwards ? curValue->keyTime() : (1 - curValue->keyTime()));
    2508 
    2509         if (curValue->value()->operations().size() > static_cast<size_t>(functionIndex))
    2510             values.append(curValue->value()->operations()[functionIndex]);
     2507        const FilterAnimationValue& curValue = static_cast<const FilterAnimationValue&>(valueList.at(index));
     2508        keyTimes.append(forwards ? curValue.keyTime() : (1 - curValue.keyTime()));
     2509
     2510        if (curValue.value().operations().size() > static_cast<size_t>(functionIndex))
     2511            values.append(curValue.value().operations()[functionIndex]);
    25112512        else {
    25122513            if (!defaultOperation)
     
    25162517
    25172518        if (i < (valueList.size() - 1))
    2518             timingFunctions.append(timingFunctionForAnimationValue(forwards ? curValue : valueList.at(index - 1), animation));
     2519            timingFunctions.append(timingFunctionForAnimationValue(forwards ? curValue : valueList.at(index - 1), *animation));
    25192520    }
    25202521   
  • trunk/Source/WebCore/platform/graphics/ca/GraphicsLayerCA.h

    r149388 r149694  
    206206    void setupAnimation(PlatformCAAnimation*, const Animation*, bool additive);
    207207   
    208     const TimingFunction* timingFunctionForAnimationValue(const AnimationValue*, const Animation*);
     208    const TimingFunction* timingFunctionForAnimationValue(const AnimationValue&, const Animation&);
    209209   
    210210    bool setAnimationEndpoints(const KeyframeValueList&, const Animation*, PlatformCAAnimation*);
  • trunk/Source/WebCore/platform/graphics/texmap/coordinated/CoordinatedGraphicsScene.cpp

    r149276 r149694  
    713713            continue;
    714714        for (size_t j = 0; j < keyframes.size(); ++j) {
    715             const FilterAnimationValue* filterValue = static_cast<const FilterAnimationValue*>(keyframes.at(i));
    716             injectCachedCustomFilterPrograms(*filterValue->value());
     715            const FilterAnimationValue& filterValue = static_cast<const FilterAnimationValue&>(keyframes.at(i));
     716            injectCachedCustomFilterPrograms(filterValue.value());
    717717        }
    718718    }
  • trunk/Source/WebCore/rendering/RenderLayerBacking.cpp

    r149661 r149694  
    21082108        bool isFirstOrLastKeyframe = key == 0 || key == 1;
    21092109        if ((hasTransform && isFirstOrLastKeyframe) || currentKeyframe.containsProperty(CSSPropertyWebkitTransform))
    2110             transformVector.insert(adoptPtr(new TransformAnimationValue(key, &(keyframeStyle->transform()), tf)));
    2111        
     2110            transformVector.insert(TransformAnimationValue::create(key, keyframeStyle->transform(), tf));
     2111
    21122112        if ((hasOpacity && isFirstOrLastKeyframe) || currentKeyframe.containsProperty(CSSPropertyOpacity))
    2113             opacityVector.insert(adoptPtr(new FloatAnimationValue(key, keyframeStyle->opacity(), tf)));
     2113            opacityVector.insert(FloatAnimationValue::create(key, keyframeStyle->opacity(), tf));
    21142114
    21152115#if ENABLE(CSS_FILTERS)
    21162116        if ((hasFilter && isFirstOrLastKeyframe) || currentKeyframe.containsProperty(CSSPropertyWebkitFilter))
    2117             filterVector.insert(adoptPtr(new FilterAnimationValue(key, &(keyframeStyle->filter()), tf)));
     2117            filterVector.insert(FilterAnimationValue::create(key, keyframeStyle->filter(), tf));
    21182118#endif
    21192119    }
     
    21552155        if (opacityAnim && !opacityAnim->isEmptyOrZeroDuration()) {
    21562156            KeyframeValueList opacityVector(AnimatedPropertyOpacity);
    2157             opacityVector.insert(adoptPtr(new FloatAnimationValue(0, compositingOpacity(fromStyle->opacity()))));
    2158             opacityVector.insert(adoptPtr(new FloatAnimationValue(1, compositingOpacity(toStyle->opacity()))));
     2157            opacityVector.insert(FloatAnimationValue::create(0, compositingOpacity(fromStyle->opacity())));
     2158            opacityVector.insert(FloatAnimationValue::create(1, compositingOpacity(toStyle->opacity())));
    21592159            // The boxSize param is only used for transform animations (which can only run on RenderBoxes), so we pass an empty size here.
    21602160            if (m_graphicsLayer->addAnimation(opacityVector, IntSize(), opacityAnim, GraphicsLayer::animationNameForTransition(AnimatedPropertyOpacity), timeOffset)) {
     
    21702170        if (transformAnim && !transformAnim->isEmptyOrZeroDuration()) {
    21712171            KeyframeValueList transformVector(AnimatedPropertyWebkitTransform);
    2172             transformVector.insert(adoptPtr(new TransformAnimationValue(0, &fromStyle->transform())));
    2173             transformVector.insert(adoptPtr(new TransformAnimationValue(1, &toStyle->transform())));
     2172            transformVector.insert(TransformAnimationValue::create(0, fromStyle->transform()));
     2173            transformVector.insert(TransformAnimationValue::create(1, toStyle->transform()));
    21742174            if (m_graphicsLayer->addAnimation(transformVector, toRenderBox(renderer())->pixelSnappedBorderBoxRect().size(), transformAnim, GraphicsLayer::animationNameForTransition(AnimatedPropertyWebkitTransform), timeOffset)) {
    21752175                // To ensure that the correct transform is visible when the animation ends, also set the final transform.
     
    21852185        if (filterAnim && !filterAnim->isEmptyOrZeroDuration()) {
    21862186            KeyframeValueList filterVector(AnimatedPropertyWebkitFilter);
    2187             filterVector.insert(adoptPtr(new FilterAnimationValue(0, &fromStyle->filter())));
    2188             filterVector.insert(adoptPtr(new FilterAnimationValue(1, &toStyle->filter())));
     2187            filterVector.insert(FilterAnimationValue::create(0, fromStyle->filter()));
     2188            filterVector.insert(FilterAnimationValue::create(1, toStyle->filter()));
    21892189            if (m_graphicsLayer->addAnimation(filterVector, IntSize(), filterAnim, GraphicsLayer::animationNameForTransition(AnimatedPropertyWebkitFilter), timeOffset)) {
    21902190                // To ensure that the correct filter is visible when the animation ends, also set the final filter.
  • trunk/Source/WebKit2/ChangeLog

    r149693 r149694  
     12013-05-07  Anders Carlsson  <andersca@apple.com>
     2
     3        Clean up KeyframeValueList and related classes
     4        https://bugs.webkit.org/show_bug.cgi?id=115738
     5
     6        Reviewed by Simon Fraser.
     7
     8        Update for WebCore changes.
     9
     10        * Shared/CoordinatedGraphics/CoordinatedGraphicsArgumentCoders.cpp:
     11        (CoreIPC::::decode):
     12
    1132013-05-07  Anders Carlsson  <andersca@apple.com>
    214
  • trunk/Source/WebKit2/Shared/CoordinatedGraphics/CoordinatedGraphicsArgumentCoders.cpp

    r149661 r149694  
    646646    encoder << static_cast<uint32_t>(keyframes.size());
    647647    for (size_t i = 0; i < keyframes.size(); ++i) {
    648         const AnimationValue* value = keyframes.at(i);
    649         encoder << value->keyTime();
    650         encodeTimingFunction(encoder, value->timingFunction());
     648        const AnimationValue& value = keyframes.at(i);
     649        encoder << value.keyTime();
     650        encodeTimingFunction(encoder, value.timingFunction());
    651651        switch (keyframes.property()) {
    652652        case AnimatedPropertyOpacity:
    653             encoder << static_cast<const FloatAnimationValue*>(value)->value();
     653            encoder << static_cast<const FloatAnimationValue&>(value).value();
    654654            break;
    655655        case AnimatedPropertyWebkitTransform:
    656             encoder << *static_cast<const TransformAnimationValue*>(value)->value();
     656            encoder << static_cast<const TransformAnimationValue&>(value).value();
    657657            break;
    658658#if ENABLE(CSS_FILTERS)
    659659        case AnimatedPropertyWebkitFilter:
    660             encoder << *static_cast<const FilterAnimationValue*>(value)->value();
     660            encoder << static_cast<const FilterAnimationValue&>(value).value();
    661661            break;
    662662#endif
     
    734734            if (!decoder.decode(value))
    735735                return false;
    736             keyframes.insert(adoptPtr(new FloatAnimationValue(keyTime, value, timingFunction)));
     736            keyframes.insert(FloatAnimationValue::create(keyTime, value, timingFunction));
    737737            break;
    738738        }
     
    741741            if (!decoder.decode(transform))
    742742                return false;
    743             keyframes.insert(adoptPtr(new TransformAnimationValue(keyTime, &transform, timingFunction)));
     743            keyframes.insert(TransformAnimationValue::create(keyTime, transform, timingFunction));
    744744            break;
    745745        }
     
    749749            if (!decoder.decode(filter))
    750750                return false;
    751             keyframes.insert(adoptPtr(new FilterAnimationValue(keyTime, &filter, timingFunction)));
     751            keyframes.insert(FilterAnimationValue::create(keyTime, filter, timingFunction));
    752752            break;
    753753        }
  • trunk/Source/WebKit2/WebProcess/WebPage/CoordinatedGraphics/CoordinatedLayerTreeHost.cpp

    r149292 r149694  
    343343                continue;
    344344            for (size_t j = 0; j < keyframes.size(); ++j) {
    345                 const FilterAnimationValue* filterValue = static_cast<const FilterAnimationValue*>(keyframes.at(i));
    346                 checkCustomFilterProgramProxies(*filterValue->value());
     345                const FilterAnimationValue& filterValue = static_cast<const FilterAnimationValue&>(keyframes.at(i));
     346                checkCustomFilterProgramProxies(filterValue.value());
    347347            }
    348348        }
Note: See TracChangeset for help on using the changeset viewer.