Changeset 35568 in webkit


Ignore:
Timestamp:
Aug 5, 2008 12:08:45 PM (16 years ago)
Author:
dino@apple.com
Message:

Reviewed by Dave Hyatt

Add support for CSS Animation properties to RenderStyle
https://bugs.webkit.org/show_bug.cgi?id=20068

(also fix some minor whitespace issues and remove debugging code)

  • css/CSSComputedStyleDeclaration.cpp:
  • css/CSSStyleSelector.cpp:
  • page/AnimationController.cpp:
  • rendering/style/RenderStyle.cpp:
  • rendering/style/RenderStyle.h:
Location:
trunk/WebCore
Files:
6 edited

Legend:

Unmodified
Added
Removed
  • trunk/WebCore/ChangeLog

    r35567 r35568  
     12008-08-05  Dean Jackson  <dino@apple.com>
     2
     3        Reviewed by Dave Hyatt
     4
     5        Add support for CSS Animation properties to RenderStyle
     6        https://bugs.webkit.org/show_bug.cgi?id=20068
     7
     8        (also fix some minor whitespace issues and remove debugging code)
     9
     10        * css/CSSComputedStyleDeclaration.cpp:
     11        * css/CSSStyleSelector.cpp:
     12        * page/AnimationController.cpp:
     13        * rendering/style/RenderStyle.cpp:
     14        * rendering/style/RenderStyle.h:
     15
    1162008-08-05  Kevin McCullough  <kmccullough@apple.com>
    217
  • trunk/WebCore/css/CSSComputedStyleDeclaration.cpp

    r35545 r35568  
    10691069            }
    10701070            else
    1071                 list->append(CSSPrimitiveValue::create(RenderStyle::initialDelay(), CSSPrimitiveValue::CSS_S));
     1071                list->append(CSSPrimitiveValue::create(RenderStyle::initialAnimationDelay(), CSSPrimitiveValue::CSS_S));
    10721072            return list.release();
    10731073        }
     
    10801080            }
    10811081            else
    1082                 list->append(CSSPrimitiveValue::create(RenderStyle::initialDuration(), CSSPrimitiveValue::CSS_S));
     1082                list->append(CSSPrimitiveValue::create(RenderStyle::initialAnimationDuration(), CSSPrimitiveValue::CSS_S));
    10831083            return list.release();
    10841084        }
     
    10931093            }
    10941094            else {
    1095                 const TimingFunction& tf = RenderStyle::initialTimingFunction();
     1095                const TimingFunction& tf = RenderStyle::initialAnimationTimingFunction();
    10961096                list->append(CSSTimingFunctionValue::create(tf.x1(), tf.y1(), tf.x2(), tf.y2()));
    10971097            }
  • trunk/WebCore/css/CSSStyleSelector.cpp

    r35545 r35568  
    200200if (isInitial) { \
    201201    AnimationList* list = m_style->accessTransitions(); \
    202     (*list)[0]->set##Prop(RenderStyle::initial##Prop()); \
     202    (*list)[0]->set##Prop(RenderStyle::initialAnimation##Prop()); \
    203203    for (size_t i = 1; i < list->size(); ++i) \
    204204        (*list)[0]->clear##Prop(); \
     
    50055005{
    50065006    if (value->cssValueType() == CSSValue::CSS_INITIAL) {
    5007         transition->setDuration(RenderStyle::initialDuration());
     5007        transition->setDuration(RenderStyle::initialAnimationDuration());
    50085008        return;
    50095009    }
     
    50225022{
    50235023    if (value->cssValueType() == CSSValue::CSS_INITIAL) {
    5024         transition->setDelay(RenderStyle::initialDelay());
     5024        transition->setDelay(RenderStyle::initialAnimationDelay());
    50255025        return;
    50265026    }
     
    50405040{
    50415041    if (value->cssValueType() == CSSValue::CSS_INITIAL) {
    5042         transition->setTimingFunction(RenderStyle::initialTimingFunction());
     5042        transition->setTimingFunction(RenderStyle::initialAnimationTimingFunction());
    50435043        return;
    50445044    }
     
    50755075{
    50765076    if (value->cssValueType() == CSSValue::CSS_INITIAL) {
    5077         transition->setProperty(RenderStyle::initialProperty());
     5077        transition->setProperty(RenderStyle::initialAnimationProperty());
    50785078        return;
    50795079    }
  • trunk/WebCore/page/AnimationController.cpp

    r35545 r35568  
    112112    }
    113113   
    114     void startTimer(Element* element, const AtomicString& name, int property, bool reset, 
     114    void startTimer(Element* element, const AtomicString& name, int property, bool reset,
    115115                    const AtomicString& eventType, double elapsedTime)
    116116    {
     
    192192    void suspendAnimations();
    193193    void resumeAnimations();
    194     bool suspended() const      { return m_suspended; }
     194    bool suspended() const { return m_suspended; }
    195195   
    196196    void overrideImplicitAnimations(int property);
     
    216216class AnimationBase : public Noncopyable {
    217217public:
    218     AnimationBase(const Animation* transition, RenderObject* renderer, CompositeAnimation* compAnim);   
     218    AnimationBase(const Animation* transition, RenderObject* renderer, CompositeAnimation* compAnim);
    219219    virtual ~AnimationBase()
    220220    {
     
    309309   
    310310    void animationTimerCallbackFired(const AtomicString& eventType, double elapsedTime);
    311     void animationEventDispatcherFired(Element* element, const AtomicString& name, int property, bool reset, 
     311    void animationEventDispatcherFired(Element* element, const AtomicString& name, int property, bool reset,
    312312                                       const AtomicString& eventType, double elapsedTime);
    313313   
     
    699699}
    700700
    701 void AnimationBase::animationEventDispatcherFired(Element* element, const AtomicString& name, int property, 
     701void AnimationBase::animationEventDispatcherFired(Element* element, const AtomicString& name, int property,
    702702                                                  bool reset, const AtomicString& eventType, double elapsedTime)
    703703{
     
    17411741void AnimationController::suspendAnimations(Document* document)
    17421742{
    1743 #ifdef DEBUG_STATE_MACHINE
    1744     fprintf(stderr, "AnimationController %p suspendAnimations for document %p\n", this, document);
    1745 #endif
    17461743    m_data->suspendAnimations(document);
    17471744}
     
    17491746void AnimationController::resumeAnimations(Document* document)
    17501747{
    1751 #ifdef DEBUG_STATE_MACHINE
    1752     fprintf(stderr, "AnimationController %p resumeAnimations for document %p\n", this, document);
    1753 #endif
    17541748    m_data->resumeAnimations(document);
    17551749}
  • trunk/WebCore/rendering/style/RenderStyle.cpp

    r35545 r35568  
    665665}
    666666
     667bool KeyframeList::operator==(const KeyframeList& o) const
     668{
     669    if (m_keyframes.size() != o.m_keyframes.size())
     670        return false;
     671
     672    Vector<KeyframeValue>::const_iterator it2 = o.m_keyframes.begin();
     673    for (Vector<KeyframeValue>::const_iterator it1 = m_keyframes.begin(); it1 != m_keyframes.end(); ++it1) {
     674        if (it1->key != it2->key)
     675            return false;
     676        const RenderStyle& style1 = it1->style;
     677        const RenderStyle& style2 = it2->style;
     678        if (!(style1 == style2))
     679            return false;
     680        ++it2;
     681    }
     682
     683    return true;
     684}
     685
     686void
     687KeyframeList::insert(float inKey, const RenderStyle& inStyle)
     688{
     689    if (inKey < 0 || inKey > 1)
     690        return;
     691
     692    for (size_t i = 0; i < m_keyframes.size(); ++i) {
     693        if (m_keyframes[i].key == inKey) {
     694            m_keyframes[i].style = inStyle;
     695            return;
     696        }
     697        if (m_keyframes[i].key > inKey) {
     698            // insert before
     699            m_keyframes.insert(i, KeyframeValue());
     700            m_keyframes[i].key = inKey;
     701            m_keyframes[i].style = inStyle;
     702            return;
     703        }
     704    }
     705   
     706    // append
     707    m_keyframes.append(KeyframeValue());
     708    m_keyframes[m_keyframes.size()-1].key = inKey;
     709    m_keyframes[m_keyframes.size()-1].style = inStyle;
     710}
     711
    667712Animation::Animation()
    668     : m_duration(RenderStyle::initialDuration())
    669     , m_timingFunction(RenderStyle::initialTimingFunction())
    670     , m_delay(RenderStyle::initialDelay())
    671     , m_property(RenderStyle::initialProperty())
     713    : m_delay(RenderStyle::initialAnimationDelay())
     714    , m_direction(RenderStyle::initialAnimationDirection())
     715    , m_duration(RenderStyle::initialAnimationDuration())
     716    , m_iterationCount(RenderStyle::initialAnimationIterationCount())
     717    , m_name(RenderStyle::initialAnimationName())
     718    , m_property(RenderStyle::initialAnimationProperty())
     719    , m_timingFunction(RenderStyle::initialAnimationTimingFunction())
     720    , m_playState(RenderStyle::initialAnimationPlayState())
     721    , m_delaySet(false)
     722    , m_directionSet(false)
    672723    , m_durationSet(false)
     724    , m_iterationCountSet(false)
     725    , m_nameSet(false)
     726    , m_playStateSet(false)
     727    , m_propertySet(false)
    673728    , m_timingFunctionSet(false)
    674     , m_delaySet(false)
    675     , m_propertySet(false)
     729    , m_isNone(false)
    676730{
    677731}
     
    679733Animation::Animation(const Animation& o)
    680734    : RefCounted<Animation>()
     735    , m_delay(o.m_delay)
     736    , m_direction(o.m_direction)
    681737    , m_duration(o.m_duration)
     738    , m_iterationCount(o.m_iterationCount)
     739    , m_name(o.m_name)
     740    , m_property(o.m_property)
    682741    , m_timingFunction(o.m_timingFunction)
    683     , m_delay(o.m_delay)
    684     , m_property(o.m_property)
     742    , m_playState(o.m_playState)
     743    , m_delaySet(o.m_delaySet)
     744    , m_directionSet(o.m_directionSet)
    685745    , m_durationSet(o.m_durationSet)
     746    , m_iterationCountSet(o.m_iterationCountSet)
     747    , m_nameSet(o.m_nameSet)
     748    , m_playStateSet(o.m_playStateSet)
     749    , m_propertySet(o.m_propertySet)
    686750    , m_timingFunctionSet(o.m_timingFunctionSet)
    687     , m_delaySet(o.m_delaySet)
    688     , m_propertySet(o.m_propertySet)
     751    , m_isNone(o.m_isNone)
    689752{
    690753}
     
    693756{
    694757    m_delay = o.m_delay;
     758    m_direction = o.m_direction;
    695759    m_duration = o.m_duration;
     760    m_iterationCount = o.m_iterationCount;
     761    m_name = o.m_name;
     762    m_playState = o.m_playState;
     763    m_property = o.m_property;
    696764    m_timingFunction = o.m_timingFunction;
    697     m_property = o.m_property;
    698765
    699766    m_delaySet = o.m_delaySet;
     767    m_directionSet = o.m_directionSet;
    700768    m_durationSet = o.m_durationSet;
     769    m_iterationCountSet = o.m_iterationCountSet;
     770    m_nameSet = o.m_nameSet;
     771    m_playStateSet = o.m_playStateSet;
     772    m_propertySet = o.m_propertySet;
    701773    m_timingFunctionSet = o.m_timingFunctionSet;
    702     m_propertySet = o.m_propertySet;
     774
     775    m_isNone = o.m_isNone;
    703776
    704777    return *this;
    705778}
    706779
    707 bool Animation::animationsMatch(const Animation* o) const
     780bool Animation::animationsMatch(const Animation* o, bool matchPlayStates /* = true */) const
    708781{
    709782    if (!o)
    710783        return false;
    711784   
    712     bool result = m_duration == o->m_duration &&
     785    bool result = m_delay == o->m_delay &&
     786                  m_direction == o->m_direction &&
     787                  m_duration == o->m_duration &&
     788                  m_iterationCount == o->m_iterationCount &&
     789                  m_name == o->m_name &&
     790                  m_property == o->m_property &&
    713791                  m_timingFunction == o->m_timingFunction &&
    714                   m_delay == o->m_delay &&
    715                   m_property == o->m_property &&
    716                   m_durationSet == o->m_durationSet &&
    717                   m_timingFunctionSet == o->m_timingFunctionSet &&
    718792                  m_delaySet == o->m_delaySet &&
    719                   m_propertySet == o->m_propertySet;
    720    
    721     return result;
     793                  m_directionSet == o->m_directionSet &&
     794                  m_durationSet == o->m_durationSet &&
     795                  m_iterationCountSet == o->m_iterationCountSet &&
     796                  m_nameSet == o->m_nameSet &&
     797                  m_propertySet == o->m_propertySet &&
     798                  m_timingFunctionSet == o->m_timingFunctionSet &&
     799                  m_isNone == o->m_isNone;
     800
     801    if (!result)
     802        return false;
     803
     804    if (matchPlayStates && (m_playState != o->m_playState || m_playStateSet != o->m_playStateSet))
     805        return false;
     806
     807    // now check keyframes
     808    if ((m_keyframeList.get() && !o->m_keyframeList.get()) || (!m_keyframeList.get() && o->m_keyframeList.get()))
     809        return false;
     810    if (!(m_keyframeList.get()))
     811        return true;
     812    return *m_keyframeList == *o->m_keyframeList;
    722813}
    723814
     
    733824    size_t i;
    734825    FILL_UNSET_PROPERTY(isDelaySet, delay, setDelay);
     826    FILL_UNSET_PROPERTY(isDirectionSet, direction, setDirection);
    735827    FILL_UNSET_PROPERTY(isDurationSet, duration, setDuration);
     828    FILL_UNSET_PROPERTY(isIterationCountSet, iterationCount, setIterationCount);
     829    FILL_UNSET_PROPERTY(isPlayStateSet, playState, setPlayState);
     830    FILL_UNSET_PROPERTY(isNameSet, name, setName);
    736831    FILL_UNSET_PROPERTY(isTimingFunctionSet, timingFunction, setTimingFunction);
    737832    FILL_UNSET_PROPERTY(isPropertySet, property, setProperty);
     
    761856    , m_borderFit(RenderStyle::initialBorderFit())
    762857    , m_boxShadow(0)
     858    , m_animations(0)
    763859    , m_transitions(0)
    764860    , m_mask(FillLayer(MaskFillLayer))
     
    788884    , m_boxShadow(o.m_boxShadow ? new ShadowData(*o.m_boxShadow) : 0)
    789885    , m_boxReflect(o.m_boxReflect)
     886    , m_animations(o.m_animations ? new AnimationList(*o.m_animations) : 0)
    790887    , m_transitions(o.m_transitions ? new AnimationList(*o.m_transitions) : 0)
    791888    , m_mask(o.m_mask)
     
    841938        && shadowDataEquivalent(o)
    842939        && reflectionDataEquivalent(o)
     940        && animationDataEquivalent(o)
    843941        && transitionDataEquivalent(o)
    844942        && m_mask == o.m_mask
     
    868966    return true;
    869967
     968}
     969
     970void StyleRareNonInheritedData::updateKeyframes(const CSSStyleSelector* styleSelector)
     971{
     972    if (m_animations) {
     973        for (size_t i = 0; i < m_animations->size(); ++i) {
     974            if ((*m_animations)[i]->isValidAnimation()) {
     975                // When keyframes have been parsed, execute this code.
     976                // RefPtr<KeyframeList> keyframe = styleSelector->findKeyframeRule((*m_animations)[i]->name());
     977                // (*m_animations)[i]->setAnimationKeyframe(keyframe);
     978            }
     979        }
     980    }
     981}
     982
     983bool StyleRareNonInheritedData::animationDataEquivalent(const StyleRareNonInheritedData& o) const
     984{
     985    if (!m_animations && o.m_animations || m_animations && !o.m_animations)
     986        return false;
     987    if (m_animations && o.m_animations && (*m_animations != *o.m_animations))
     988        return false;
     989    return true;
    870990}
    871991
     
    18441964#endif
    18451965
     1966void RenderStyle::adjustAnimations()
     1967{
     1968    AnimationList* animationList = rareNonInheritedData->m_animations;
     1969    if (!animationList)
     1970        return;
     1971
     1972    if (animationList->size() == 0) {
     1973        clearAnimations();
     1974        return;
     1975    }
     1976
     1977    // get rid of empty transitions and anything beyond them
     1978    for (size_t i = 0; i < animationList->size(); ++i) {
     1979        if ((*animationList)[i]->isEmpty()) {
     1980            animationList->resize(i);
     1981            break;
     1982        }
     1983    }
     1984   
     1985    if (animationList->size() == 0) {
     1986        clearAnimations();
     1987        return;
     1988    }
     1989   
     1990    // Repeat patterns into layers that don't have some properties set.
     1991    animationList->fillUnsetProperties();
     1992}
     1993
    18461994void RenderStyle::adjustTransitions()
    18471995{
     
    18842032}
    18852033
     2034AnimationList* RenderStyle::accessAnimations()
     2035{
     2036    AnimationList* list = rareNonInheritedData.access()->m_animations;
     2037    if (!list)
     2038        rareNonInheritedData.access()->m_animations = new AnimationList();
     2039    return rareNonInheritedData->m_animations;
     2040}
     2041
    18862042AnimationList* RenderStyle::accessTransitions()
    18872043{
     
    18922048}
    18932049
    1894 }
     2050const Animation* RenderStyle::transitionForProperty(int property)
     2051{
     2052    if (transitions()) {
     2053        for (size_t i = 0; i < transitions()->size(); ++i) {
     2054            const Animation* p = (*transitions())[i].get();
     2055            if (p->property() == cAnimateAll || p->property() == property) {
     2056                return p;
     2057            }
     2058        }
     2059    }
     2060    return 0;
     2061}
     2062
     2063}
  • trunk/WebCore/rendering/style/RenderStyle.h

    r35545 r35568  
    7373class CachedResource;
    7474class CursorList;
     75class KeyframeList;
    7576class Pair;
    7677class RenderArena;
     
    12581259};
    12591260
     1261enum EAnimPlayState {
     1262    AnimPlayStatePlaying = 0x0,
     1263    AnimPlayStatePaused = 0x1
     1264};
     1265
    12601266class Animation : public RefCounted<Animation> {
    12611267public:
     
    12641270   
    12651271    bool isDelaySet() const { return m_delaySet; }
     1272    bool isDirectionSet() const { return m_directionSet; }
    12661273    bool isDurationSet() const { return m_durationSet; }
     1274    bool isIterationCountSet() const { return m_iterationCountSet; }
     1275    bool isNameSet() const { return m_nameSet; }
     1276    bool isPlayStateSet() const { return m_playStateSet; }
     1277    bool isPropertySet() const { return m_propertySet; }
    12671278    bool isTimingFunctionSet() const { return m_timingFunctionSet; }
    1268     bool isPropertySet() const { return m_propertySet; }
     1279
     1280    // Flags this to be the special "none" animation (animation-name: none)
     1281    bool isNoneAnimation() const { return m_isNone; }
     1282    // We can make placeholder Animation objects to keep the comma-separated lists
     1283    // of properties in sync. isValidAnimation means this is not a placeholder.
     1284    bool isValidAnimation() const { return !m_isNone && !m_name.isEmpty(); }
    12691285
    12701286    bool isEmpty() const
    12711287    {
    1272         return (!m_durationSet && !m_delaySet && !m_timingFunctionSet && !m_propertySet);
     1288        return (!m_directionSet && !m_durationSet && !m_nameSet && !m_playStateSet &&
     1289               !m_iterationCountSet && !m_delaySet && !m_timingFunctionSet && !m_propertySet);
    12731290    }
    12741291
     
    12791296
    12801297    void clearDelay() { m_delaySet = false; }
     1298    void clearDirection() { m_directionSet = false; }
    12811299    void clearDuration() { m_durationSet = false; }
     1300    void clearIterationCount() { m_iterationCountSet = false; }
     1301    void clearName() { m_nameSet = false; }
     1302    void clearPlayState() { m_playStateSet = AnimPlayStatePlaying; }
     1303    void clearProperty() { m_propertySet = false; }
    12821304    void clearTimingFunction() { m_timingFunctionSet = false; }
    12831305
    1284     void clearProperty() { m_propertySet = false; }
    1285 
    12861306    double delay() const { return m_delay; }
     1307    bool direction() const { return m_direction; }
    12871308    double duration() const { return m_duration; }
     1309    int iterationCount() const { return m_iterationCount; }
     1310    const String& name() const { return m_name; }
     1311    unsigned playState() const { return m_playState; }
     1312    int property() const { return m_property; }
    12881313    const TimingFunction& timingFunction() const { return m_timingFunction; }
    1289     int property() const { return m_property; }
     1314
     1315    const RefPtr<KeyframeList>& keyframeList() const { return m_keyframeList; }
    12901316
    12911317    void setDelay(double c) { m_delay = c; m_delaySet = true; }
     1318    void setDirection(bool d) { m_direction = d; m_directionSet = true; }
    12921319    void setDuration(double d) { ASSERT(d >= 0); m_duration = d; m_durationSet = true; }
     1320    void setIterationCount(int c) { m_iterationCount = c; m_iterationCountSet = true; }
     1321    void setName(const String& n) { m_name = n; m_nameSet = true; }
     1322    void setPlayState(unsigned d) { m_playState = d; m_playStateSet = true; }
     1323    void setProperty(int t) { m_property = t; m_propertySet = true; }
    12931324    void setTimingFunction(const TimingFunction& f) { m_timingFunction = f; m_timingFunctionSet = true; }
    1294     void setProperty(int t) { m_property = t; m_propertySet = true; }
     1325
     1326    void setIsNoneAnimation(bool n) { m_isNone = n; }
     1327
     1328    void setAnimationKeyframe(const RefPtr<KeyframeList> keyframe)  { m_keyframeList = keyframe; }
    12951329
    12961330    Animation& operator=(const Animation& o);
    12971331
    12981332    // return true if all members of this class match (excluding m_next)
    1299     bool animationsMatch(const Animation* t) const;
     1333    bool animationsMatch(const Animation* t, bool matchPlayStates=true) const;
    13001334
    13011335    // return true every Animation in the chain (defined by m_next) match
     
    13071341    Animation(const Animation& o);
    13081342   
     1343    double m_delay;
     1344    bool m_direction;
    13091345    double m_duration;
     1346    int m_iterationCount;
     1347    String m_name;
     1348    int m_property;
    13101349    TimingFunction m_timingFunction;
    1311     double m_delay;
    1312     int m_property;
    1313 
     1350
     1351    RefPtr<KeyframeList> m_keyframeList;
     1352
     1353    unsigned m_playState     : 2;
     1354
     1355    bool m_delaySet          : 1;
     1356    bool m_directionSet      : 1;
    13141357    bool m_durationSet       : 1;
     1358    bool m_iterationCountSet : 1;
     1359    bool m_nameSet           : 1;
     1360    bool m_playStateSet      : 1;
     1361    bool m_propertySet       : 1;
    13151362    bool m_timingFunctionSet : 1;
    1316     bool m_delaySet          : 1;
    1317     bool m_propertySet       : 1;
     1363   
     1364    bool m_isNone            : 1;
    13181365};
    13191366
     
    13771424    bool shadowDataEquivalent(const StyleRareNonInheritedData& o) const;
    13781425    bool reflectionDataEquivalent(const StyleRareNonInheritedData& o) const;
     1426    bool animationDataEquivalent(const StyleRareNonInheritedData&) const;
    13791427    bool transitionDataEquivalent(const StyleRareNonInheritedData&) const;
     1428    void updateKeyframes(const CSSStyleSelector* styleSelector);
    13801429
    13811430    int lineClamp; // An Apple extension.
     
    14041453    RefPtr<StyleReflection> m_boxReflect;
    14051454
     1455    AnimationList* m_animations;
    14061456    AnimationList* m_transitions;
    14071457
     
    21022152
    21032153    // Apple-specific property getter methods
     2154    const AnimationList* animations() const { return rareNonInheritedData->m_animations; }
     2155    const AnimationList* transitions() const { return rareNonInheritedData->m_transitions; }
     2156
     2157    AnimationList* accessAnimations();
    21042158    AnimationList* accessTransitions();
    2105     const AnimationList* transitions() const { return rareNonInheritedData->m_transitions; }
     2159
     2160    bool hasAnimations() const { return rareNonInheritedData->m_animations && rareNonInheritedData->m_animations->size() > 0; }
    21062161    bool hasTransitions() const { return rareNonInheritedData->m_transitions && rareNonInheritedData->m_transitions->size() > 0; }
     2162
     2163    // return the first found Animation (including 'all' transitions)
     2164    const Animation* transitionForProperty(int property);
    21072165
    21082166    int lineClamp() const { return rareNonInheritedData->lineClamp; }
     
    23692427
    23702428    // Apple-specific property setters
     2429    void clearAnimations()
     2430    {
     2431        if (rareNonInheritedData.access()->m_animations) {
     2432            delete rareNonInheritedData.access()->m_animations;
     2433            rareNonInheritedData.access()->m_animations = 0;
     2434        }
     2435    }
    23712436    void clearTransitions()
    23722437    {
     
    23772442    }
    23782443
     2444    void inheritAnimations(const AnimationList* parent) { clearAnimations(); if (parent) rareNonInheritedData.access()->m_animations = new AnimationList(*parent); }
    23792445    void inheritTransitions(const AnimationList* parent) { clearTransitions(); if (parent) rareNonInheritedData.access()->m_transitions = new AnimationList(*parent); }
     2446    void adjustAnimations();
    23802447    void adjustTransitions();
     2448    void updateKeyframes(const CSSStyleSelector* styleSelector) { if (rareNonInheritedData.get()) rareNonInheritedData.access()->updateKeyframes(styleSelector); }
     2449
    23812450    void setLineClamp(int c) { SET_VAR(rareNonInheritedData, lineClamp, c); }
    23822451    void setTextSizeAdjust(bool b) { SET_VAR(rareInheritedData, textSizeAdjust, b); }
     
    25352604   
    25362605    // Keep these at the end.
    2537     static float initialDelay() { return 0; }
    2538     static double initialDuration() { return 0; }
    2539     static TimingFunction initialTimingFunction() { return TimingFunction(); }
    2540     static int initialProperty() { return cAnimateAll; }
     2606    static float initialAnimationDelay() { return 0; }
     2607    static bool initialAnimationDirection() { return false; }
     2608    static double initialAnimationDuration() { return 0; }
     2609    static int initialAnimationIterationCount() { return 1; }
     2610    static String initialAnimationName() { return String(); }
     2611    static unsigned initialAnimationPlayState() { return AnimPlayStatePlaying; }
     2612    static int initialAnimationProperty() { return cAnimateAll; }
     2613    static TimingFunction initialAnimationTimingFunction() { return TimingFunction(); }
    25412614    static int initialLineClamp() { return -1; }
    25422615    static bool initialTextSizeAdjust() { return true; }
     
    25482621};
    25492622
     2623#pragma mark -
     2624
     2625class KeyframeValue {
     2626public:
     2627    KeyframeValue() : key(-1) { }
     2628    float key;
     2629    RenderStyle style;
     2630};
     2631
     2632class KeyframeList : public RefCounted<KeyframeList> {
     2633public:
     2634    static PassRefPtr<KeyframeList> create(const AtomicString& inAnimName) { return adoptRef(new KeyframeList(inAnimName)); }
     2635
     2636    bool operator==(const KeyframeList& o) const;
     2637    bool operator!=(const KeyframeList& o) const { return !(*this == o); }
     2638   
     2639    const AtomicString& animationName() const { return m_animationName; }
     2640   
     2641    void insert(float inKey, const RenderStyle& inStyle);
     2642   
     2643    void addProperty(int prop) { m_properties.add(prop); }
     2644    bool containsProperty(int prop) const { return m_properties.contains(prop); }
     2645    HashSet<int>::const_iterator beginProperties() { return m_properties.begin(); }
     2646    HashSet<int>::const_iterator endProperties() { return m_properties.end(); }
     2647   
     2648    void clear() { m_keyframes.clear(); m_properties.clear(); }
     2649    bool isEmpty() const { return m_keyframes.isEmpty(); }
     2650    Vector<KeyframeValue>::const_iterator beginKeyframes() const { return m_keyframes.begin(); }
     2651    Vector<KeyframeValue>::const_iterator endKeyframes() const { return m_keyframes.end(); }
     2652
     2653private:
     2654    KeyframeList(const AtomicString& inAnimName)
     2655    : m_animationName(inAnimName)
     2656    {
     2657        insert(0, RenderStyle());
     2658        insert(1, RenderStyle());
     2659    }
     2660       
     2661protected:
     2662    AtomicString m_animationName;
     2663    Vector<KeyframeValue> m_keyframes;
     2664    HashSet<int> m_properties;       // the properties being animated
     2665};
     2666
    25502667} // namespace WebCore
    25512668
Note: See TracChangeset for help on using the changeset viewer.