Changeset 107162 in webkit


Ignore:
Timestamp:
Feb 8, 2012 6:07:11 PM (12 years ago)
Author:
igor.o@sisa.samsung.com
Message:

Source/WebCore: Implement reverse animation direction

Implement reverse animation direction
https://bugs.webkit.org/show_bug.cgi?id=60525

Implement reverse and alternate-reverse direction.

Reviewed by Dean Jackson.

Tests: animations/animation-direction-alternate-reverse.html

animations/animation-direction-reverse.html
animations/fill-mode-reverse.html

  • css/CSSParser.cpp:

(WebCore::CSSParser::parseAnimationDirection):

  • css/CSSStyleSelector.cpp:

(WebCore::CSSStyleSelector::mapAnimationDirection):

  • css/CSSValueKeywords.in:
  • page/WebKitAnimation.cpp:

(WebCore::WebKitAnimation::direction):

  • page/WebKitAnimation.h:
  • page/animation/AnimationBase.cpp:

(WebCore::AnimationBase::fractionalTime):

  • platform/animation/Animation.h:

(Animation):

  • platform/graphics/texmap/TextureMapperAnimation.cpp:

(WebCore):
(WebCore::shouldReverseAnimationValue):
(WebCore::normalizedAnimationValue):

LayoutTests: Implement reverse animation direction
https://bugs.webkit.org/show_bug.cgi?id=60525

Add test for the new animation-direction values.

Reviewed by Dean Jackson.

  • animations/animation-direction-alternate-reverse-expected.txt: Added.
  • animations/animation-direction-alternate-reverse.html: Added.
  • animations/animation-direction-reverse-expected.txt: Added.
  • animations/animation-direction-reverse.html: Added.
  • animations/fill-mode-reverse-expected.txt: Added.
  • animations/fill-mode-reverse.html: Added.
Location:
trunk
Files:
6 added
10 edited

Legend:

Unmodified
Added
Removed
  • trunk/LayoutTests/ChangeLog

    r107160 r107162  
     12012-02-08  Igor Oliveira  <igor.o@sisa.samsung.com>
     2
     3        Implement reverse animation direction
     4        https://bugs.webkit.org/show_bug.cgi?id=60525
     5
     6        Add test for the new animation-direction values.
     7
     8        Reviewed by Dean Jackson.
     9
     10        * animations/animation-direction-alternate-reverse-expected.txt: Added.
     11        * animations/animation-direction-alternate-reverse.html: Added.
     12        * animations/animation-direction-reverse-expected.txt: Added.
     13        * animations/animation-direction-reverse.html: Added.
     14        * animations/fill-mode-reverse-expected.txt: Added.
     15        * animations/fill-mode-reverse.html: Added.
     16
    1172012-02-08  David Hyatt  <hyatt@apple.com>
    218
  • trunk/Source/WebCore/ChangeLog

    r107161 r107162  
     12012-02-08  Igor Oliveira  <igor.o@sisa.samsung.com>
     2
     3        Implement reverse animation direction
     4
     5        Implement reverse animation direction
     6        https://bugs.webkit.org/show_bug.cgi?id=60525
     7
     8        Implement reverse and alternate-reverse direction.
     9
     10        Reviewed by Dean Jackson.
     11
     12        Tests: animations/animation-direction-alternate-reverse.html
     13               animations/animation-direction-reverse.html
     14               animations/fill-mode-reverse.html
     15
     16        * css/CSSParser.cpp:
     17        (WebCore::CSSParser::parseAnimationDirection):
     18        * css/CSSStyleSelector.cpp:
     19        (WebCore::CSSStyleSelector::mapAnimationDirection):
     20        * css/CSSValueKeywords.in:
     21        * page/WebKitAnimation.cpp:
     22        (WebCore::WebKitAnimation::direction):
     23        * page/WebKitAnimation.h:
     24        * page/animation/AnimationBase.cpp:
     25        (WebCore::AnimationBase::fractionalTime):
     26        * platform/animation/Animation.h:
     27        (Animation):
     28        * platform/graphics/texmap/TextureMapperAnimation.cpp:
     29        (WebCore):
     30        (WebCore::shouldReverseAnimationValue):
     31        (WebCore::normalizedAnimationValue):
     32
    1332012-02-08  James Robinson  <jamesr@chromium.org>
    234
  • trunk/Source/WebCore/css/CSSParser.cpp

    r107030 r107162  
    33773377{
    33783378    CSSParserValue* value = m_valueList->current();
    3379     if (value->id == CSSValueNormal || value->id == CSSValueAlternate)
     3379    if (value->id == CSSValueNormal || value->id == CSSValueAlternate || value->id == CSSValueReverse || value->id == CSSValueAlternateReverse)
    33803380        return cssValuePool()->createIdentifierValue(value->id);
    33813381    return 0;
  • trunk/Source/WebCore/css/CSSStyleSelector.cpp

    r107112 r107162  
    43194319
    43204320    CSSPrimitiveValue* primitiveValue = static_cast<CSSPrimitiveValue*>(value);
    4321     layer->setDirection(primitiveValue->getIdent() == CSSValueAlternate ? Animation::AnimationDirectionAlternate : Animation::AnimationDirectionNormal);
     4321    switch (primitiveValue->getIdent()) {
     4322    case CSSValueNormal:
     4323        layer->setDirection(Animation::AnimationDirectionNormal);
     4324        break;
     4325    case CSSValueAlternate:
     4326        layer->setDirection(Animation::AnimationDirectionAlternate);
     4327        break;
     4328    case CSSValueReverse:
     4329        layer->setDirection(Animation::AnimationDirectionReverse);
     4330        break;
     4331    case CSSValueAlternateReverse:
     4332        layer->setDirection(Animation::AnimationDirectionAlternateReverse);
     4333        break;
     4334    }
    43224335}
    43234336
  • trunk/Source/WebCore/css/CSSValueKeywords.in

    r106980 r107162  
    701701// alternate
    702702
     703alternate-reverse
     704
    703705//
    704706// CSS_PROP__WEBKIT_ANIMATION_FILL_MODE
  • trunk/Source/WebCore/page/WebKitAnimation.cpp

    r94823 r107162  
    8585WebKitAnimation::Direction WebKitAnimation::direction() const
    8686{
    87     if (m_keyframeAnimation->animation()->direction() == Animation::AnimationDirectionNormal)
     87    switch (m_keyframeAnimation->animation()->direction()) {
     88    case Animation::AnimationDirectionNormal:
    8889        return DIRECTION_NORMAL;
    89     return DIRECTION_ALTERNATE;
     90    case Animation::AnimationDirectionAlternate:
     91        return DIRECTION_ALTERNATE;
     92    case Animation::AnimationDirectionReverse:
     93        return DIRECTION_REVERSE;
     94    case Animation::AnimationDirectionAlternateReverse:
     95        return DIRECTION_ALTERNATE_REVERSE;
     96    }
     97    ASSERT_NOT_REACHED();
     98    return DIRECTION_NORMAL;
    9099}
    91100
  • trunk/Source/WebCore/page/WebKitAnimation.h

    r80846 r107162  
    6060
    6161    // direction
    62     enum Direction { DIRECTION_NORMAL, DIRECTION_ALTERNATE };
     62    enum Direction { DIRECTION_NORMAL, DIRECTION_ALTERNATE, DIRECTION_REVERSE, DIRECTION_ALTERNATE_REVERSE };
    6363    Direction direction() const;
    6464
  • trunk/Source/WebCore/page/animation/AnimationBase.cpp

    r105901 r107162  
    16741674    fractionalTime -= integralTime;
    16751675
    1676     if ((m_animation->direction() == Animation::AnimationDirectionAlternate) && (integralTime & 1))
     1676    if (((m_animation->direction() == Animation::AnimationDirectionAlternate) && (integralTime & 1))
     1677        || ((m_animation->direction() == Animation::AnimationDirectionAlternateReverse) && !(integralTime & 1))
     1678        || m_animation->direction() == Animation::AnimationDirectionReverse)
    16771679        fractionalTime = 1 - fractionalTime;
    16781680
  • trunk/Source/WebCore/platform/animation/Animation.h

    r95901 r107162  
    4343    static PassRefPtr<Animation> create() { return adoptRef(new Animation); }
    4444    static PassRefPtr<Animation> create(const Animation* o) { return adoptRef(new Animation(*o)); }
    45    
     45
    4646    bool isDelaySet() const { return m_delaySet; }
    4747    bool isDirectionSet() const { return m_directionSet; }
     
    9797    double delay() const { return m_delay; }
    9898
    99     enum AnimationDirection { AnimationDirectionNormal, AnimationDirectionAlternate };
     99    enum AnimationDirection {
     100        AnimationDirectionNormal,
     101        AnimationDirectionAlternate,
     102        AnimationDirectionReverse,
     103        AnimationDirectionAlternateReverse
     104    };
    100105    AnimationDirection direction() const { return static_cast<AnimationDirection>(m_direction); }
    101106
     
    145150    double m_duration;
    146151    RefPtr<TimingFunction> m_timingFunction;
    147     unsigned m_direction : 1; // AnimationDirection
     152    unsigned m_direction : 2; // AnimationDirection
    148153    unsigned m_fillMode : 2;
    149154
  • trunk/Source/WebCore/platform/graphics/texmap/TextureMapperAnimation.cpp

    r106190 r107162  
    2727namespace WebCore {
    2828
    29 static double normalizedAnimationValue(double runningTime, double duration, bool alternate)
     29
     30static bool shouldReverseAnimationValue(Animation::AnimationDirection direction, int loopCount)
     31{
     32    if (((direction == Animation::AnimationDirectionAlternate) && (loopCount & 1))
     33        || ((direction == Animation::AnimationDirectionAlternateReverse) && !(loopCount & 1))
     34        || direction == Animation::AnimationDirectionReverse)
     35        return true;
     36    return false;
     37}
     38
     39static double normalizedAnimationValue(double runningTime, double duration, Animation::AnimationDirection direction)
    3040{
    3141    if (!duration)
     
    3646    const double remainder = runningTime - lastFullLoop;
    3747    const double normalized = remainder / duration;
    38     return (loopCount % 2 && alternate) ? (1 - normalized) : normalized;
     48
     49    return shouldReverseAnimationValue(direction, loopCount) ? 1 - normalized : normalized;
    3950}
    4051
Note: See TracChangeset for help on using the changeset viewer.