Changeset 37077 in webkit
- Timestamp:
- Sep 29, 2008 2:31:26 PM (16 years ago)
- Location:
- trunk
- Files:
-
- 2 added
- 14 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/LayoutTests/ChangeLog
r37076 r37077 1 2008-09-29 Chris Marrin <cmarrin@apple.com> 2 3 Reviewed by Dave Hyatt 4 5 * animations/lineheight-animation-expected.txt: Added. 6 * animations/lineheight-animation.html: Added. 7 1 8 2008-09-29 Chris Marrin <cmarrin@apple.com> 2 9 -
trunk/WebCore/ChangeLog
r37076 r37077 1 2008-09-29 Chris Marrin <cmarrin@apple.com> 2 3 Reviewed by Dave Hyatt 4 5 Fixed https://bugs.webkit.org/show_bug.cgi?id=20995 6 Rewrite keyframe resolution to be like styleForElement() 7 8 Test: animations/lineheight-animation.html 9 10 * css/CSSStyleSelector.cpp: 11 (WebCore::CSSStyleSelector::addKeyframeStyle): 12 (WebCore::CSSStyleSelector::~CSSStyleSelector): 13 (WebCore::CSSStyleSelector::keyframeStylesForAnimation): 14 (WebCore::CSSRuleSet::addRulesFromSheet): 15 (WebCore::CSSStyleSelector::mapAnimationName): 16 * css/CSSStyleSelector.h: 17 * page/animation/CompositeAnimation.cpp: 18 (WebCore::CompositeAnimation::updateKeyframeAnimations): 19 * page/animation/KeyframeAnimation.cpp: 20 (WebCore::KeyframeAnimation::KeyframeAnimation): 21 (WebCore::KeyframeAnimation::animate): 22 (WebCore::KeyframeAnimation::hasAnimationForProperty): 23 (WebCore::KeyframeAnimation::sendAnimationEvent): 24 (WebCore::KeyframeAnimation::overrideAnimations): 25 (WebCore::KeyframeAnimation::resumeOverriddenAnimations): 26 (WebCore::KeyframeAnimation::affectsProperty): 27 (WebCore::KeyframeAnimation::validateTransformFunctionList): 28 * page/animation/KeyframeAnimation.h: 29 * rendering/style/Animation.cpp: 30 (WebCore::Animation::animationsMatch): 31 * rendering/style/Animation.h: 32 * rendering/style/KeyframeList.cpp: 33 (WebCore::KeyframeList::~KeyframeList): 34 (WebCore::KeyframeList::clear): 35 (WebCore::KeyframeList::insert): 36 * rendering/style/KeyframeList.h: 37 (WebCore::KeyframeValue::KeyframeValue): 38 (WebCore::KeyframeList::KeyframeList): 39 (WebCore::KeyframeList::operator!=): 40 (WebCore::KeyframeList::animationName): 41 (WebCore::KeyframeList::addProperty): 42 (WebCore::KeyframeList::containsProperty): 43 (WebCore::KeyframeList::beginProperties): 44 (WebCore::KeyframeList::endProperties): 45 (WebCore::KeyframeList::isEmpty): 46 (WebCore::KeyframeList::size): 47 (WebCore::KeyframeList::beginKeyframes): 48 (WebCore::KeyframeList::endKeyframes): 49 * rendering/style/RenderStyle.h: 50 * rendering/style/StyleRareNonInheritedData.cpp: 51 * rendering/style/StyleRareNonInheritedData.h: 52 1 53 2008-09-29 Chris Marrin <cmarrin@apple.com> 2 54 -
trunk/WebCore/css/CSSStyleSelector.cpp
r36918 r37077 445 445 446 446 // This is a simplified style setting function for keyframe styles 447 void CSSStyleSelector::addKeyframeStyle(Document* doc, const WebKitCSSKeyframesRule* rule) 448 { 449 // Create the keyframe list 447 void CSSStyleSelector::addKeyframeStyle(PassRefPtr<WebKitCSSKeyframesRule> rule) 448 { 450 449 AtomicString s(rule->name()); 451 RefPtr<KeyframeList> list; 452 if (m_keyframeRuleMap.contains(s.impl())) 453 list = m_keyframeRuleMap.get(s.impl()).get(); 454 else { 455 list = KeyframeList::create(s); 456 m_keyframeRuleMap.add(s.impl(), list); 457 } 458 list->clear(); 459 460 // Add all the keyframes 461 for (unsigned i = 0; i < rule->length(); ++i) { 462 const WebKitCSSKeyframeRule* kf = rule->item(i); 463 m_style = new (doc->renderArena()) RenderStyle(); 464 m_style->ref(); 465 CSSMutableStyleDeclaration* decl = kf->style(); 466 DeprecatedValueListConstIterator<CSSProperty> end; 467 468 // Record all the properties in this keyframe 469 for (DeprecatedValueListConstIterator<CSSProperty> it = decl->valuesIterator(); it != end; ++it) { 470 const CSSProperty& current = *it; 471 applyProperty(current.id(), current.value()); 472 list->addProperty(current.id()); 473 } 474 475 // Add this keyframe to all the indicated key times 476 Vector<float> keys; 477 kf->getKeys(keys); 478 479 for (size_t keyIndex = 0; keyIndex < keys.size(); ++keyIndex) { 480 float key = keys[keyIndex]; 481 list->insert(key, *m_style); 482 } 483 484 m_style->deref(doc->renderArena()); 485 m_style = 0; 486 } 487 488 // Make sure there is a 0% and a 100% keyframe 489 float first = list->beginKeyframes()->key; 490 float last = (list->endKeyframes()-1)->key; 491 if (first != 0 || last != 1) { 492 list->clear(); 493 return; 494 } 450 m_keyframesRuleMap.add(s.impl(), rule); 495 451 } 496 452 … … 512 468 delete m_userStyle; 513 469 deleteAllValues(m_viewportDependentMediaQueryResults); 514 m_keyframe RuleMap.clear();470 m_keyframesRuleMap.clear(); 515 471 } 516 472 … … 1221 1177 // Now return the style. 1222 1178 return m_style; 1179 } 1180 1181 void CSSStyleSelector::keyframeStylesForAnimation(Element* e, const RenderStyle* elementStyle, KeyframeList& list) 1182 { 1183 list.clear(); 1184 1185 // Get the keyframesRule for this name 1186 if (!e || list.animationName().isEmpty()) 1187 return; 1188 1189 if (!m_keyframesRuleMap.contains(list.animationName().impl())) 1190 return; 1191 1192 const WebKitCSSKeyframesRule* rule = m_keyframesRuleMap.find(list.animationName().impl()).get()->second.get(); 1193 1194 // Construct and populate the style for each keyframe 1195 for (unsigned i = 0; i < rule->length(); ++i) { 1196 // Apply the declaration to the style. This is a simplified version of the logic in styleForElement 1197 initElementAndPseudoState(e); 1198 initForStyleResolve(e); 1199 1200 const WebKitCSSKeyframeRule* kf = rule->item(i); 1201 addMatchedDeclaration(kf->style()); 1202 1203 // Create the style 1204 m_style = new (e->document()->renderArena()) RenderStyle(*elementStyle); 1205 m_style->ref(); 1206 1207 m_lineHeightValue = 0; 1208 1209 // We don't need to bother with !important. Since there is only ever one 1210 // decl, there's nothing to override. So just add the first properties. 1211 applyDeclarations(true, false, 0, m_matchedDecls.size() - 1); 1212 1213 // If our font got dirtied, go ahead and update it now. 1214 if (m_fontDirty) 1215 updateFont(); 1216 1217 // Line-height is set when we are sure we decided on the font-size 1218 if (m_lineHeightValue) 1219 applyProperty(CSSPropertyLineHeight, m_lineHeightValue); 1220 1221 // Now do rest of the properties. 1222 applyDeclarations(false, false, 0, m_matchedDecls.size() - 1); 1223 1224 // If our font got dirtied by one of the non-essential font props, 1225 // go ahead and update it a second time. 1226 if (m_fontDirty) 1227 updateFont(); 1228 1229 // Add all the animating properties to the list 1230 DeprecatedValueListConstIterator<CSSProperty> end; 1231 for (DeprecatedValueListConstIterator<CSSProperty> it = kf->style()->valuesIterator(); it != end; ++it) 1232 list.addProperty((*it).id()); 1233 1234 // Add this keyframe style to all the indicated key times 1235 Vector<float> keys; 1236 kf->getKeys(keys); 1237 for (size_t keyIndex = 0; keyIndex < keys.size(); ++keyIndex) { 1238 float key = keys[keyIndex]; 1239 list.insert(key, m_style); 1240 } 1241 m_style->deref(e->document()->renderArena()); 1242 m_style = 0; 1243 } 1244 1245 // Make sure there is a 0% and a 100% keyframe 1246 float first = list.beginKeyframes()->key; 1247 float last = (list.endKeyframes()-1)->key; 1248 if (first != 0 || last != 1) 1249 list.clear(); 1223 1250 } 1224 1251 … … 2416 2443 } else if (childItem->isKeyframesRule() && styleSelector) { 2417 2444 // Add this keyframe rule to our set. 2418 const WebKitCSSKeyframesRule* keyframesRule = static_cast<WebKitCSSKeyframesRule*>(childItem); 2419 styleSelector->addKeyframeStyle(sheet->doc(), keyframesRule); 2445 styleSelector->addKeyframeStyle(static_cast<WebKitCSSKeyframesRule*>(childItem)); 2420 2446 } 2421 2447 } // for rules … … 2430 2456 if (!variables->media() || medium.eval(variables->media(), styleSelector)) 2431 2457 styleSelector->addVariables(variables); 2432 } else if (item->isKeyframesRule()) { 2433 WebKitCSSKeyframesRule* r = static_cast<WebKitCSSKeyframesRule*>(item); 2434 styleSelector->addKeyframeStyle(sheet->doc(), r); 2435 } 2458 } else if (item->isKeyframesRule()) 2459 styleSelector->addKeyframeStyle(static_cast<WebKitCSSKeyframesRule*>(item)); 2436 2460 } 2437 2461 } … … 5112 5136 CSSPrimitiveValue* primitiveValue = static_cast<CSSPrimitiveValue*>(value); 5113 5137 5114 if (primitiveValue->getIdent() == CSSValueNone) {5138 if (primitiveValue->getIdent() == CSSValueNone) 5115 5139 layer->setIsNoneAnimation(true); 5116 } else {5140 else 5117 5141 layer->setName(primitiveValue->getStringValue()); 5118 5119 // resolve to the keyframes5120 RefPtr<KeyframeList> keyframe = findKeyframeRule(primitiveValue->getStringValue());5121 layer->setAnimationKeyframe(keyframe);5122 }5123 5142 } 5124 5143 -
trunk/WebCore/css/CSSStyleSelector.h
r36619 r37077 85 85 void initForStyleResolve(Element*, RenderStyle* parentStyle = 0, RenderStyle::PseudoId = RenderStyle::NOPSEUDO); 86 86 RenderStyle* styleForElement(Element*, RenderStyle* parentStyle = 0, bool allowSharing = true, bool resolveForRootDefault = false); 87 void keyframeStylesForAnimation(Element*, const RenderStyle*, KeyframeList& list); 87 88 88 89 RenderStyle* pseudoStyleForElement(RenderStyle::PseudoId, Element*, RenderStyle* parentStyle = 0); … … 140 141 void resolveVariablesForDeclaration(CSSMutableStyleDeclaration* decl, CSSMutableStyleDeclaration* newDecl, HashSet<String>& usedBlockVariables); 141 142 142 KeyframeList* findKeyframeRule(const String& name) const 143 { 144 if (name.isEmpty()) 145 return 0; 146 147 AtomicString s(name); 148 if (!m_keyframeRuleMap.contains(s.impl())) 149 return 0; 150 return m_keyframeRuleMap.find(s.impl()).get()->second.get(); 151 } 152 153 void addKeyframeStyle(Document* doc, const WebKitCSSKeyframesRule* rule); 143 void addKeyframeStyle(PassRefPtr<WebKitCSSKeyframesRule> rule); 154 144 155 145 static bool createTransformOperations(CSSValue* inValue, RenderStyle* inStyle, TransformOperations& outOperations); … … 183 173 Color m_backgroundColor; 184 174 185 typedef HashMap<AtomicStringImpl*, RefPtr< KeyframeList> > KeyframeRuleMap;186 Keyframe RuleMap m_keyframeRuleMap;175 typedef HashMap<AtomicStringImpl*, RefPtr<WebKitCSSKeyframesRule> > KeyframesRuleMap; 176 KeyframesRuleMap m_keyframesRuleMap; 187 177 188 178 public: -
trunk/WebCore/page/animation/CompositeAnimation.cpp
r37076 r37077 34 34 #include "ImplicitAnimation.h" 35 35 #include "KeyframeAnimation.h" 36 #include "KeyframeList.h"37 36 #include "RenderObject.h" 38 37 #include "RenderStyle.h" … … 155 154 keyframeAnim->setAnimation(anim); 156 155 keyframeAnim->setIndex(i); 157 } else if ((anim->duration() || anim->delay()) && anim->iterationCount() 158 && anim->keyframeList() && !anim->keyframeList()->isEmpty()) { 156 } else if ((anim->duration() || anim->delay()) && anim->iterationCount()) { 159 157 keyframeAnim = new KeyframeAnimation(const_cast<Animation*>(anim), renderer, i, this, currentStyle ? currentStyle : targetStyle); 160 158 m_keyframeAnimations.set(keyframeAnim->name().impl(), keyframeAnim); -
trunk/WebCore/page/animation/KeyframeAnimation.cpp
r37074 r37077 31 31 32 32 #include "CSSPropertyNames.h" 33 #include "CSSStyleSelector.h" 33 34 #include "CompositeAnimation.h" 34 35 #include "EventNames.h" … … 37 38 38 39 namespace WebCore { 40 41 KeyframeAnimation::KeyframeAnimation(const Animation* animation, RenderObject* renderer, int index, CompositeAnimation* compAnim, const RenderStyle* unanimatedStyle) 42 : AnimationBase(animation, renderer, compAnim) 43 , m_keyframes(renderer, animation->name()) 44 , m_index(index) 45 , m_unanimatedStyle(0) 46 { 47 // Set the transform animation list 48 validateTransformFunctionList(); 49 50 if (unanimatedStyle) { 51 const_cast<RenderStyle*>(unanimatedStyle)->ref(); 52 m_unanimatedStyle = unanimatedStyle; 53 } 54 55 // Get the keyframe RenderStyles 56 if (m_object && m_object->element() && m_object->element()->isElementNode()) 57 m_object->document()->styleSelector()->keyframeStylesForAnimation(static_cast<Element*>(m_object->element()), unanimatedStyle, m_keyframes); 58 } 39 59 40 60 KeyframeAnimation::~KeyframeAnimation() … … 84 104 double scale = 1; 85 105 double offset = 0; 86 if (m_keyframes.get()) { 87 Vector<KeyframeValue>::const_iterator end = m_keyframes->endKeyframes(); 88 for (Vector<KeyframeValue>::const_iterator it = m_keyframes->beginKeyframes(); it != end; ++it) { 89 if (t < it->key) { 90 // The first key should always be 0, so we should never succeed on the first key 91 if (!fromStyle) 92 break; 93 scale = 1.0 / (it->key - offset); 94 toStyle = const_cast<RenderStyle*>(&(it->style)); 106 Vector<KeyframeValue>::const_iterator endKeyframes = m_keyframes.endKeyframes(); 107 for (Vector<KeyframeValue>::const_iterator it = m_keyframes.beginKeyframes(); it != endKeyframes; ++it) { 108 if (t < it->key) { 109 // The first key should always be 0, so we should never succeed on the first key 110 if (!fromStyle) 95 111 break; 96 } 97 98 offset = it->key; 99 fromStyle = const_cast<RenderStyle*>(&(it->style)); 100 } 112 scale = 1.0 / (it->key - offset); 113 toStyle = it->style; 114 break; 115 } 116 117 offset = it->key; 118 fromStyle = it->style; 101 119 } 102 120 … … 118 136 double prog = progress(scale, offset, timingFunction); 119 137 120 HashSet<int>::const_iterator end = m_keyframes->endProperties();121 for (HashSet<int>::const_iterator it = m_keyframes ->beginProperties(); it != end; ++it) {138 HashSet<int>::const_iterator endProperties = m_keyframes.endProperties(); 139 for (HashSet<int>::const_iterator it = m_keyframes.beginProperties(); it != endProperties; ++it) { 122 140 if (blendProperties(this, *it, animatedStyle, fromStyle, toStyle, prog)) 123 141 setAnimating(); … … 127 145 bool KeyframeAnimation::hasAnimationForProperty(int property) const 128 146 { 129 HashSet<int>::const_iterator end = m_keyframes ->endProperties();130 for (HashSet<int>::const_iterator it = m_keyframes ->beginProperties(); it != end; ++it) {147 HashSet<int>::const_iterator end = m_keyframes.endProperties(); 148 for (HashSet<int>::const_iterator it = m_keyframes.beginProperties(); it != end; ++it) { 131 149 if (*it == property) 132 150 return true; … … 181 199 if (Element* element = elementForEventDispatch()) { 182 200 m_waitingForEndEvent = true; 183 m_animationEventDispatcher.startTimer(element, m_ name, -1, true, eventType, elapsedTime);201 m_animationEventDispatcher.startTimer(element, m_keyframes.animationName(), -1, true, eventType, elapsedTime); 184 202 return true; // Did dispatch an event 185 203 } … … 192 210 { 193 211 // This will override implicit animations that match the properties in the keyframe animation 194 HashSet<int>::const_iterator end = m_keyframes ->endProperties();195 for (HashSet<int>::const_iterator it = m_keyframes ->beginProperties(); it != end; ++it)212 HashSet<int>::const_iterator end = m_keyframes.endProperties(); 213 for (HashSet<int>::const_iterator it = m_keyframes.beginProperties(); it != end; ++it) 196 214 compositeAnimation()->overrideImplicitAnimations(*it); 197 215 } … … 200 218 { 201 219 // This will resume overridden implicit animations 202 HashSet<int>::const_iterator end = m_keyframes ->endProperties();203 for (HashSet<int>::const_iterator it = m_keyframes ->beginProperties(); it != end; ++it)220 HashSet<int>::const_iterator end = m_keyframes.endProperties(); 221 for (HashSet<int>::const_iterator it = m_keyframes.beginProperties(); it != end; ++it) 204 222 compositeAnimation()->resumeOverriddenImplicitAnimations(*it); 205 223 } … … 207 225 bool KeyframeAnimation::affectsProperty(int property) const 208 226 { 209 HashSet<int>::const_iterator end = m_keyframes ->endProperties();210 for (HashSet<int>::const_iterator it = m_keyframes ->beginProperties(); it != end; ++it) {227 HashSet<int>::const_iterator end = m_keyframes.endProperties(); 228 for (HashSet<int>::const_iterator it = m_keyframes.beginProperties(); it != end; ++it) { 211 229 if (*it == property) 212 230 return true; … … 219 237 m_transformFunctionListValid = false; 220 238 221 if ( !m_keyframes.get() || m_keyframes->size() < 2 || !m_keyframes->containsProperty(CSSPropertyWebkitTransform))222 return; 223 224 Vector<KeyframeValue>::const_iterator end = m_keyframes ->endKeyframes();239 if (m_keyframes.size() < 2 || !m_keyframes.containsProperty(CSSPropertyWebkitTransform)) 240 return; 241 242 Vector<KeyframeValue>::const_iterator end = m_keyframes.endKeyframes(); 225 243 226 244 // Empty transforms match anything, so find the first non-empty entry as the reference … … 228 246 Vector<KeyframeValue>::const_iterator firstIt = end; 229 247 230 for (Vector<KeyframeValue>::const_iterator it = m_keyframes ->beginKeyframes(); it != end; ++it, ++firstIndex) {231 if (it->style .transform().operations().size() > 0) {248 for (Vector<KeyframeValue>::const_iterator it = m_keyframes.beginKeyframes(); it != end; ++it, ++firstIndex) { 249 if (it->style->transform().operations().size() > 0) { 232 250 firstIt = it; 233 251 break; … … 238 256 return; 239 257 240 const TransformOperations* firstVal = &firstIt->style .transform();258 const TransformOperations* firstVal = &firstIt->style->transform(); 241 259 242 260 // See if the keyframes are valid 243 261 for (Vector<KeyframeValue>::const_iterator it = firstIt+1; it != end; ++it) { 244 const TransformOperations* val = &it->style .transform();262 const TransformOperations* val = &it->style->transform(); 245 263 246 264 // A null transform matches anything -
trunk/WebCore/page/animation/KeyframeAnimation.h
r36687 r37077 41 41 class KeyframeAnimation : public AnimationBase { 42 42 public: 43 KeyframeAnimation(const Animation* animation, RenderObject* renderer, int index, CompositeAnimation* compAnim, const RenderStyle* unanimatedStyle) 44 : AnimationBase(animation, renderer, compAnim) 45 , m_keyframes(animation->keyframeList()) 46 , m_name(animation->name()) 47 , m_index(index) 48 , m_unanimatedStyle(0) 49 { 50 // Set the transform animation list 51 validateTransformFunctionList(); 52 53 if (unanimatedStyle) { 54 const_cast<RenderStyle*>(unanimatedStyle)->ref(); 55 m_unanimatedStyle = unanimatedStyle; 56 } 57 } 58 43 KeyframeAnimation(const Animation* animation, RenderObject* renderer, int index, CompositeAnimation* compAnim, const RenderStyle* unanimatedStyle); 59 44 virtual ~KeyframeAnimation(); 60 45 61 46 virtual void animate(CompositeAnimation*, RenderObject*, const RenderStyle* currentStyle, const RenderStyle* targetStyle, RenderStyle*& animatedStyle); 62 47 63 void setName(const String& s) { m_name = s; } 64 const AtomicString& name() const { return m_name; } 48 const AtomicString& name() const { return m_keyframes.animationName(); } 65 49 int index() const { return m_index; } 66 50 void setIndex(int i) { m_index = i; } … … 90 74 private: 91 75 // The keyframes that we are blending. 92 RefPtr<KeyframeList>m_keyframes;93 AtomicString m_name; 76 KeyframeList m_keyframes; 77 94 78 // The order in which this animation appears in the animation-name style. 95 79 int m_index; -
trunk/WebCore/rendering/style/Animation.cpp
r36619 r37077 23 23 #include "Animation.h" 24 24 25 #include "KeyframeList.h"26 25 #include "RenderStyle.h" 27 26 … … 124 123 return false; 125 124 126 if (matchPlayStates && (m_playState != o->m_playState || m_playStateSet != o->m_playStateSet)) 127 return false; 128 129 // now check keyframes 130 if ((m_keyframeList.get() && !o->m_keyframeList.get()) || (!m_keyframeList.get() && o->m_keyframeList.get())) 131 return false; 132 if (!(m_keyframeList.get())) 133 return true; 134 return *m_keyframeList == *o->m_keyframeList; 135 } 136 137 const RefPtr<KeyframeList>& Animation::keyframeList() const 138 { 139 return m_keyframeList; 140 } 141 142 void Animation::setAnimationKeyframe(const RefPtr<KeyframeList> keyframeList) 143 { 144 m_keyframeList = keyframeList; 125 return !matchPlayStates || (m_playState == o->m_playState && m_playStateSet == o->m_playStateSet); 145 126 } 146 127 -
trunk/WebCore/rendering/style/Animation.h
r36619 r37077 32 32 33 33 namespace WebCore { 34 35 class KeyframeList;36 34 37 35 class Animation : public RefCounted<Animation> { … … 85 83 const TimingFunction& timingFunction() const { return m_timingFunction; } 86 84 87 const RefPtr<KeyframeList>& keyframeList() const;88 89 85 void setDelay(double c) { m_delay = c; m_delaySet = true; } 90 86 void setDirection(bool d) { m_direction = d; m_directionSet = true; } … … 97 93 98 94 void setIsNoneAnimation(bool n) { m_isNone = n; } 99 100 void setAnimationKeyframe(const RefPtr<KeyframeList> keyframe);101 95 102 96 Animation& operator=(const Animation& o); … … 121 115 TimingFunction m_timingFunction; 122 116 123 RefPtr<KeyframeList> m_keyframeList;124 125 117 unsigned m_playState : 2; 126 118 -
trunk/WebCore/rendering/style/KeyframeList.cpp
r36619 r37077 22 22 #include "config.h" 23 23 #include "KeyframeList.h" 24 #include "RenderObject.h" 24 25 25 26 namespace WebCore { 27 28 KeyframeList::~KeyframeList() 29 { 30 clear(); 31 } 32 33 void KeyframeList::clear() 34 { 35 for (Vector<KeyframeValue>::const_iterator it = m_keyframes.begin(); it != m_keyframes.end(); ++it) 36 if (it->style) 37 it->style->deref(m_renderer->renderArena()); 38 39 m_keyframes.clear(); 40 m_properties.clear(); 41 } 26 42 27 43 bool KeyframeList::operator==(const KeyframeList& o) const … … 44 60 } 45 61 46 void KeyframeList::insert(float inKey, const RenderStyle& inStyle)62 void KeyframeList::insert(float key, RenderStyle* style) 47 63 { 48 if ( inKey < 0 || inKey > 1)64 if (key < 0 || key > 1) 49 65 return; 50 66 67 int index = -1; 68 51 69 for (size_t i = 0; i < m_keyframes.size(); ++i) { 52 if (m_keyframes[i].key == inKey) {53 m_keyframes[i].style = inStyle;54 return;70 if (m_keyframes[i].key == key) { 71 index = (int) i; 72 break; 55 73 } 56 if (m_keyframes[i].key > inKey) {74 if (m_keyframes[i].key > key) { 57 75 // insert before 58 76 m_keyframes.insert(i, KeyframeValue()); 59 m_keyframes[i].key = inKey; 60 m_keyframes[i].style = inStyle; 61 return; 77 index = (int) i; 78 break; 62 79 } 63 80 } 64 65 // append 66 m_keyframes.append(KeyframeValue()); 67 m_keyframes[m_keyframes.size()-1].key = inKey; 68 m_keyframes[m_keyframes.size()-1].style = inStyle; 81 82 if (index < 0) { 83 // append 84 index = (int) m_keyframes.size(); 85 m_keyframes.append(KeyframeValue()); 86 } 87 88 if (style) 89 style->ref(); 90 if (m_keyframes[index].style) 91 m_keyframes[index].style->deref(m_renderer->renderArena()); 92 m_keyframes[index].key = key; 93 m_keyframes[index].style = style; 69 94 } 70 95 -
trunk/WebCore/rendering/style/KeyframeList.h
r36619 r37077 27 27 28 28 #include "AtomicString.h" 29 #include "RenderStyle.h"30 29 #include <wtf/Vector.h> 31 30 #include <wtf/HashSet.h> 32 #include <wtf/PassRefPtr.h>33 #include <wtf/RefCounted.h>34 31 35 32 namespace WebCore { 33 34 class RenderObject; 35 class RenderStyle; 36 36 37 37 class KeyframeValue { … … 39 39 KeyframeValue() 40 40 : key(-1) 41 , style(0) 41 42 { 42 43 } 43 44 44 45 float key; 45 RenderStyle style;46 RenderStyle* style; 46 47 }; 47 48 48 class KeyframeList : public RefCounted<KeyframeList>{49 class KeyframeList { 49 50 public: 50 static PassRefPtr<KeyframeList> create(const AtomicString& animationName) { return adoptRef(new KeyframeList(animationName)); } 51 51 KeyframeList(RenderObject* renderer, const AtomicString& animationName) 52 : m_animationName(animationName) 53 , m_renderer(renderer) 54 { 55 insert(0, 0); 56 insert(1, 0); 57 } 58 ~KeyframeList(); 59 52 60 bool operator==(const KeyframeList& o) const; 53 61 bool operator!=(const KeyframeList& o) const { return !(*this == o); } … … 55 63 const AtomicString& animationName() const { return m_animationName; } 56 64 57 void insert(float inKey, const RenderStyle& inStyle);65 void insert(float key, RenderStyle* style); 58 66 59 67 void addProperty(int prop) { m_properties.add(prop); } 60 68 bool containsProperty(int prop) const { return m_properties.contains(prop); } 61 HashSet<int>::const_iterator beginProperties() { return m_properties.begin(); }62 HashSet<int>::const_iterator endProperties() { return m_properties.end(); }69 HashSet<int>::const_iterator beginProperties() const { return m_properties.begin(); } 70 HashSet<int>::const_iterator endProperties() const { return m_properties.end(); } 63 71 64 void clear() { m_keyframes.clear(); m_properties.clear(); }72 void clear(); 65 73 bool isEmpty() const { return m_keyframes.isEmpty(); } 66 74 size_t size() const { return m_keyframes.size(); } … … 69 77 70 78 private: 71 KeyframeList(const AtomicString& animationName)72 : m_animationName(animationName)73 {74 insert(0, RenderStyle());75 insert(1, RenderStyle());76 }77 78 79 AtomicString m_animationName; 79 80 Vector<KeyframeValue> m_keyframes; 80 81 HashSet<int> m_properties; // the properties being animated 82 RenderObject* m_renderer; 81 83 }; 82 84 -
trunk/WebCore/rendering/style/RenderStyle.h
r36635 r37077 946 946 void adjustAnimations(); 947 947 void adjustTransitions(); 948 void updateKeyframes(const CSSStyleSelector* styleSelector) { if (rareNonInheritedData.get()) rareNonInheritedData.access()->updateKeyframes(styleSelector); }949 948 950 949 void setLineClamp(int c) { SET_VAR(rareNonInheritedData, lineClamp, c); } -
trunk/WebCore/rendering/style/StyleRareNonInheritedData.cpp
r36634 r37077 24 24 25 25 #include "CSSStyleSelector.h" 26 #include "KeyframeList.h"27 26 #include "RenderStyle.h" 28 27 … … 148 147 } 149 148 150 void StyleRareNonInheritedData::updateKeyframes(const CSSStyleSelector* styleSelector)151 {152 if (m_animations) {153 for (size_t i = 0; i < m_animations->size(); ++i) {154 if (m_animations->animation(i)->isValidAnimation()) {155 RefPtr<KeyframeList> keyframe = styleSelector->findKeyframeRule(m_animations->animation(i)->name());156 m_animations->animation(i)->setAnimationKeyframe(keyframe);157 }158 }159 }160 }161 162 149 bool StyleRareNonInheritedData::animationDataEquivalent(const StyleRareNonInheritedData& o) const 163 150 { -
trunk/WebCore/rendering/style/StyleRareNonInheritedData.h
r36623 r37077 75 75 bool animationDataEquivalent(const StyleRareNonInheritedData&) const; 76 76 bool transitionDataEquivalent(const StyleRareNonInheritedData&) const; 77 void updateKeyframes(const CSSStyleSelector* styleSelector);78 77 79 78 int lineClamp; // An Apple extension.
Note: See TracChangeset
for help on using the changeset viewer.