Changeset 109342 in webkit
- Timestamp:
- Mar 1, 2012 6:00:55 AM (12 years ago)
- Location:
- trunk
- Files:
-
- 4 added
- 22 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/LayoutTests/ChangeLog
r109334 r109342 1 2012-03-01 Nikolas Zimmermann <nzimmermann@rim.com> 2 3 Introduce SMIL overrideStyle, to make SVG stop mutating CSS styles directly 4 https://bugs.webkit.org/show_bug.cgi?id=79790 5 6 Reviewed by Zoltan Herczeg. 7 8 SVG CSS property animations aren't leaked into the DOM anymore, update the tests. 9 10 * svg/animations/animate-color-transparent-expected.txt: 11 * svg/animations/animate-currentColor-expected.txt: 12 * svg/animations/animate-dynamic-update-attributeName-expected.txt: 13 * svg/animations/animate-inherit-css-property-expected.txt: 14 * svg/animations/attributeTypes-expected.txt: Added. 15 * svg/animations/attributeTypes.html: Added. 16 * svg/animations/resources/attributeTypes.svg: Added. 17 * svg/animations/script-tests/animate-color-transparent.js: 18 (expectTransparent): 19 (expectOtherColor): 20 * svg/animations/script-tests/animate-currentColor.js: 21 (sample1): 22 (sample2): 23 (sample3): 24 * svg/animations/script-tests/animate-dynamic-update-attributeName.js: 25 (sample1): 26 (sample3): 27 * svg/animations/script-tests/animate-inherit-css-property.js: 28 (sample1): 29 (sample2): 30 (sample3): 31 * svg/animations/script-tests/attributeTypes.js: Added. 32 (sample1): 33 (sample2): 34 (sample3): 35 (executeTest): 36 * svg/animations/script-tests/svgstring-animation-fallback-to-discrete.js: 37 (sample1): 38 (sample2): 39 (sample3): 40 * svg/animations/svgstring-animation-fallback-to-discrete-expected.txt: 41 1 42 2012-03-01 Florin Malita <fmalita@google.com> 2 43 -
trunk/LayoutTests/svg/animations/animate-color-transparent-expected.txt
r79675 r109342 6 6 7 7 8 PASS rect.style.fill is '#00ff00' 9 PASS rect.style.fill is '#7f0000' 8 PASS getComputedStyle(rect).fill is '#00ff00' 9 PASS rect.style.fill is "" 10 PASS getComputedStyle(rect).fill is '#7f0000' 11 PASS rect.style.fill is "" 10 12 PASS successfullyParsed is true 11 13 -
trunk/LayoutTests/svg/animations/animate-currentColor-expected.txt
r79675 r109342 6 6 7 7 8 PASS rect.style.fill is '#ff0000' 9 PASS rect.style.fill is '#804000' 10 PASS rect.style.fill is '#008000' 8 PASS getComputedStyle(rect).fill is '#ff0000' 9 PASS rect.style.fill is "" 10 PASS getComputedStyle(rect).fill is '#804000' 11 PASS rect.style.fill is "" 12 PASS getComputedStyle(rect).fill is '#008000' 13 PASS rect.style.fill is "" 11 14 PASS successfullyParsed is true 12 15 -
trunk/LayoutTests/svg/animations/animate-dynamic-update-attributeName-expected.txt
r84999 r109342 6 6 7 7 8 PASS rect.style.color is 'rgb(0, 128, 0)' 9 PASS rect.style.fill is '#008000' 8 PASS getComputedStyle(rect).color is 'rgb(0, 128, 0)' 9 PASS rect.style.color is "" 10 PASS getComputedStyle(rect).fill is '#008000' 11 PASS rect.style.fill is "" 10 12 PASS successfullyParsed is true 11 13 -
trunk/LayoutTests/svg/animations/animate-inherit-css-property-expected.txt
r79675 r109342 6 6 7 7 8 PASS rect.style.fill is '#ff0000' 9 PASS rect.style.fill is '#804000' 10 PASS rect.style.fill is '#008000' 8 PASS getComputedStyle(rect).fill is '#ff0000' 9 PASS rect.style.fill is "" 10 PASS getComputedStyle(rect).fill is '#804000' 11 PASS rect.style.fill is "" 12 PASS getComputedStyle(rect).fill is '#008000' 13 PASS rect.style.fill is "" 11 14 PASS successfullyParsed is true 12 15 -
trunk/LayoutTests/svg/animations/script-tests/animate-color-transparent.js
r107682 r109342 22 22 // Setup animation test 23 23 function expectTransparent() { 24 shouldBe("rect.style.fill", "'#00ff00'"); 24 shouldBe("getComputedStyle(rect).fill", "'#00ff00'"); 25 shouldBeEqualToString("rect.style.fill", ""); 25 26 } 26 27 27 28 function expectOtherColor() { 28 shouldBe("rect.style.fill", "'#7f0000'"); 29 shouldBe("getComputedStyle(rect).fill", "'#7f0000'"); 30 shouldBeEqualToString("rect.style.fill", ""); 29 31 } 30 32 -
trunk/LayoutTests/svg/animations/script-tests/animate-currentColor.js
r107682 r109342 25 25 function sample1() { 26 26 // Check initial/end conditions 27 shouldBe("rect.style.fill", "'#ff0000'"); 27 shouldBe("getComputedStyle(rect).fill", "'#ff0000'"); 28 shouldBeEqualToString("rect.style.fill", ""); 28 29 } 29 30 30 31 function sample2() { 31 32 // Check half-time conditions 32 shouldBe("rect.style.fill", "'#804000'"); 33 shouldBe("getComputedStyle(rect).fill", "'#804000'"); 34 shouldBeEqualToString("rect.style.fill", ""); 33 35 } 34 36 35 37 function sample3() { 36 38 // Check half-time conditions 37 shouldBe("rect.style.fill", "'#008000'"); 39 shouldBe("getComputedStyle(rect).fill", "'#008000'"); 40 shouldBeEqualToString("rect.style.fill", ""); 38 41 } 39 42 -
trunk/LayoutTests/svg/animations/script-tests/animate-dynamic-update-attributeName.js
r107791 r109342 25 25 // Setup animation test 26 26 function sample1() { 27 shouldBe("rect.style.color", "'rgb(0, 128, 0)'"); 27 shouldBe("getComputedStyle(rect).color", "'rgb(0, 128, 0)'"); 28 shouldBeEqualToString("rect.style.color", ""); 28 29 } 29 30 … … 34 35 35 36 function sample3() { 36 shouldBe("rect.style.fill", "'#008000'"); 37 shouldBe("getComputedStyle(rect).fill", "'#008000'"); 38 shouldBeEqualToString("rect.style.fill", ""); 37 39 } 38 40 -
trunk/LayoutTests/svg/animations/script-tests/animate-inherit-css-property.js
r107682 r109342 28 28 function sample1() { 29 29 // Check initial/end conditions 30 shouldBe("rect.style.fill", "'#ff0000'"); 30 shouldBe("getComputedStyle(rect).fill", "'#ff0000'"); 31 shouldBeEqualToString("rect.style.fill", ""); 31 32 } 32 33 33 34 function sample2() { 34 35 // Check half-time conditions 35 shouldBe("rect.style.fill", "'#804000'"); 36 shouldBe("getComputedStyle(rect).fill", "'#804000'"); 37 shouldBeEqualToString("rect.style.fill", ""); 36 38 } 37 39 38 40 function sample3() { 39 41 // Check half-time conditions 40 shouldBe("rect.style.fill", "'#008000'"); 42 shouldBe("getComputedStyle(rect).fill", "'#008000'"); 43 shouldBeEqualToString("rect.style.fill", ""); 41 44 } 42 45 -
trunk/LayoutTests/svg/animations/script-tests/svgstring-animation-fallback-to-discrete.js
r107682 r109342 23 23 function sample1() { 24 24 // Check initial/end conditions 25 shouldBe("rect.style.visibility", "'visible'"); 25 shouldBe("getComputedStyle(rect).visibility", "'visible'"); 26 shouldBeEqualToString("rect.style.visibility", ""); 26 27 } 27 28 28 29 function sample2() { 29 shouldBe("rect.style.visibility", "'hidden'"); 30 shouldBe("getComputedStyle(rect).visibility", "'hidden'"); 31 shouldBeEqualToString("rect.style.visibility", ""); 30 32 } 31 33 32 34 function sample3() { 33 shouldBe("rect.style.visibility", "'visible'"); 35 shouldBe("getComputedStyle(rect).visibility", "'visible'"); 36 shouldBeEqualToString("rect.style.visibility", ""); 34 37 } 35 38 -
trunk/LayoutTests/svg/animations/svgstring-animation-fallback-to-discrete-expected.txt
r107682 r109342 6 6 7 7 8 PASS rect.style.visibility is 'visible' 9 PASS rect.style.visibility is 'hidden' 10 PASS rect.style.visibility is 'visible' 11 PASS rect.style.visibility is 'visible' 8 PASS getComputedStyle(rect).visibility is 'visible' 9 PASS rect.style.visibility is "" 10 PASS getComputedStyle(rect).visibility is 'hidden' 11 PASS rect.style.visibility is "" 12 PASS getComputedStyle(rect).visibility is 'visible' 13 PASS rect.style.visibility is "" 14 PASS getComputedStyle(rect).visibility is 'visible' 15 PASS rect.style.visibility is "" 12 16 PASS successfullyParsed is true 13 17 -
trunk/Source/WebCore/ChangeLog
r109340 r109342 1 2012-03-01 Nikolas Zimmermann <nzimmermann@rim.com> 2 3 Introduce SMIL overrideStyle, to make SVG stop mutating CSS styles directly 4 https://bugs.webkit.org/show_bug.cgi?id=79790 5 6 Reviewed by Zoltan Herczeg. 7 8 Next step towards enabling animVal support for XML attribute animations. 9 When SVG CSS properties are animated using SMIL, we currently mutate 10 the target elements style, and have to keep a baseValue around as String 11 to be able to recover from the DOM mutations at the end, if fill!="freeze". 12 13 The approach required by SMIL is to keep around an override style declaration 14 set and apply it right after the inline style declarations. Implement that 15 finally, to avoid mutating styles directly. 16 17 Test: svg/animations/attributeTypes.html 18 19 * css/CSSStyleSelector.cpp: Model "SMIL animation style" applying just like "inline style" declarations. 20 (WebCore::CSSStyleSelector::addElementStyleProperties): Refactored common code from matchAllRules(). 21 (WebCore::CSSStyleSelector::matchAllRules): Apply "SMIL animation style" after "inline style" declarations, as specified in SMIL2. 22 * css/CSSStyleSelector.h: Add new addElementStyleProperties() helper. 23 * svg/SVGAnimateElement.cpp: Keep track of animation state, if it's about to end, clear "SMIL animation style" upon next applyResultToTarget() call. 24 (WebCore::SVGAnimateElement::SVGAnimateElement): 25 (WebCore::SVGAnimateElement::applyResultsToTarget): Reset the CSS property we're animating int the "SMIL animation style", after animation ends. 26 (Instead of resetting target->style() properties to the old baseValue, as we used to do). 27 (WebCore::SVGAnimateElement::endedActiveInterval): Set m_aboutToStopAnimation to true, so next call to applyResultsToTarget() knows the animation ends. 28 * svg/SVGAnimateElement.h: Store bool m_aboutToSTopAnimation; 29 * svg/SVGAnimationElement.cpp: 30 (WebCore::setTargetAttributeAnimatedCSSValue): 31 (WebCore::setTargetAttributeAnimatedXMLValue): 32 Refactored both of these methods from setTargetAttributeAnimatedValue(). 33 Changed the CSS part, to apply property changes to the "SMIL animation style" instead of the regular StylePropertySet. 34 (WebCore::SVGAnimationElement::setTargetAttributeAnimatedValue): Refactored code, use shouldApplyAnimation() to determine whether this animation should run. 35 (WebCore::SVGAnimationElement::resetAnimationState): New helper calling setTargetAttributeAnimatedValue with a null-string for CSS attributes, when the animation ends. 36 This is used to detect that the CSS property should be removed from the "SMIL animation style". 37 (WebCore::SVGAnimationElement::shouldApplyAnimation): Refactored from existing code, and make it more obvious how attributeType influences the animation, all according to SVG 1.1/SMIL2. 38 * svg/SVGAnimationElement.h: 39 * svg/SVGElement.cpp: Manage the "SMIL animation style", in SVGElementRareData, if needed. Only gets created if SMIL animations on CSS properties run. 40 (WebCore::SVGElement::~SVGElement): Destroy SMIL animation style, upon destruction. 41 (WebCore::SVGElement::animatedSMILStyleProperties): Returns the StylePropertySet for the "SMIL animation style", if it's available. 42 (WebCore::SVGElement::ensureAnimatedSMILStyleProperties): Enforces creating the StylePropertySet for the "SMIL animation style". 43 * svg/SVGElement.h: Expose new methods. 44 * svg/SVGElementRareData.h: Stores the "SMIL animation style", actual managment is done by SVGElement, if needed. 45 (WebCore::SVGElementRareData::animatedSMILStyleProperties): Retrieve it. 46 (WebCore::SVGElementRareData::ensureAnimatedSMILStyleProperties): Create it. 47 (WebCore::SVGElementRareData::destroyAnimatedSMILStyleProperties): Destroy it. 48 * svg/animation/SVGSMILElement.h: Make endedActiveInterval() virtual again, its needed by SVGAnimateElement now. 49 1 50 2012-03-01 Nikolas Zimmermann <nzimmermann@rim.com> 2 51 -
trunk/Source/WebCore/css/CSSStyleSelector.cpp
r109331 r109342 123 123 124 124 #if ENABLE(SVG) 125 #include "SVGElement.h" 125 126 #include "SVGNames.h" 126 127 #endif … … 764 765 } 765 766 767 inline void CSSStyleSelector::addElementStyleProperties(MatchResult& result, StylePropertySet* propertySet, bool isCacheable) 768 { 769 if (!propertySet) 770 return; 771 result.ranges.lastAuthorRule = result.matchedProperties.size(); 772 if (result.ranges.firstAuthorRule == -1) 773 result.ranges.firstAuthorRule = result.ranges.lastAuthorRule; 774 addMatchedProperties(result, propertySet); 775 if (!isCacheable) 776 result.isCacheable = false; 777 } 778 766 779 void CSSStyleSelector::collectMatchingRules(RuleSet* rules, int& firstRuleIndex, int& lastRuleIndex, const MatchOptions& options) 767 780 { … … 1034 1047 // Now check author rules, beginning first with presentational attributes mapped from HTML. 1035 1048 if (m_styledElement) { 1036 if (StylePropertySet* attributeStyle = m_styledElement->attributeStyle()) { 1037 result.ranges.lastAuthorRule = m_matchedRules.size(); 1038 if (result.ranges.firstAuthorRule == -1) 1039 result.ranges.firstAuthorRule = result.ranges.lastAuthorRule; 1040 addMatchedProperties(result, attributeStyle); 1041 } 1049 addElementStyleProperties(result, m_styledElement->attributeStyle()); 1042 1050 1043 1051 // Now we check additional mapped declarations. 1044 1052 // Tables and table cells share an additional mapped rule that must be applied 1045 1053 // after all attributes, since their mapped style depends on the values of multiple attributes. 1046 if (StylePropertySet* additionalStyle = m_styledElement->additionalAttributeStyle()) { 1047 if (result.ranges.firstAuthorRule == -1) 1048 result.ranges.firstAuthorRule = result.matchedProperties.size(); 1049 result.ranges.lastAuthorRule = result.ranges.firstAuthorRule; 1050 addMatchedProperties(result, additionalStyle); 1051 } 1054 addElementStyleProperties(result, m_styledElement->additionalAttributeStyle()); 1052 1055 1053 1056 if (m_styledElement->isHTMLElement()) { … … 1064 1067 1065 1068 // Now check our inline style attribute. 1066 if (m_matchAuthorAndUserStyles && m_styledElement) { 1067 StylePropertySet* inlineDecl = m_styledElement->inlineStyleDecl(); 1068 if (inlineDecl) { 1069 result.ranges.lastAuthorRule = result.matchedProperties.size(); 1070 if (result.ranges.firstAuthorRule == -1) 1071 result.ranges.firstAuthorRule = result.ranges.lastAuthorRule; 1072 addMatchedProperties(result, inlineDecl); 1073 result.isCacheable = false; 1074 } 1075 } 1069 if (m_matchAuthorAndUserStyles && m_styledElement) 1070 addElementStyleProperties(result, m_styledElement->inlineStyleDecl(), false /* isCacheable */); 1071 1072 #if ENABLE(SVG) 1073 // Now check SMIL animation override style. 1074 if (m_matchAuthorAndUserStyles && m_styledElement && m_styledElement->isSVGElement()) 1075 addElementStyleProperties(result, static_cast<SVGElement*>(m_styledElement)->animatedSMILStyleProperties(), false /* isCacheable */); 1076 #endif 1076 1077 } 1077 1078 … … 1129 1130 if (p->inlineStyleDecl()) 1130 1131 return 0; 1132 #if ENABLE(SVG) 1133 if (p->isSVGElement() && static_cast<SVGElement*>(p)->animatedSMILStyleProperties()) 1134 return 0; 1135 #endif 1131 1136 if (p->hasID() && m_features.idsInRules.contains(p->idForStyleResolution().impl())) 1132 1137 return 0; … … 1277 1282 if (element->inlineStyleDecl()) 1278 1283 return false; 1284 #if ENABLE(SVG) 1285 if (element->isSVGElement() && static_cast<SVGElement*>(element)->animatedSMILStyleProperties()) 1286 return false; 1287 #endif 1279 1288 if (!!element->attributeStyle() != !!m_styledElement->attributeStyle()) 1280 1289 return false; … … 1374 1383 if (m_styledElement->inlineStyleDecl()) 1375 1384 return 0; 1385 #if ENABLE(SVG) 1386 if (m_styledElement->isSVGElement() && static_cast<SVGElement*>(m_styledElement)->animatedSMILStyleProperties()) 1387 return 0; 1388 #endif 1376 1389 // Ids stop style sharing if they show up in the stylesheets. 1377 1390 if (m_styledElement->hasID() && m_features.idsInRules.contains(m_styledElement->idForStyleResolution().impl())) -
trunk/Source/WebCore/css/CSSStyleSelector.h
r109227 r109342 296 296 297 297 static void addMatchedProperties(MatchResult&, StylePropertySet* properties, StyleRule* = 0, unsigned linkMatchType = SelectorChecker::MatchAll, bool inRegionRule = false); 298 void addElementStyleProperties(MatchResult&, StylePropertySet*, bool isCacheable = true); 298 299 299 300 void matchAllRules(MatchResult&); -
trunk/Source/WebCore/svg/SVGAnimateElement.cpp
r108134 r109342 42 42 : SVGAnimationElement(tagName, document) 43 43 , m_animatedPropertyType(AnimatedString) 44 , m_aboutToStopAnimation(false) 44 45 , m_fromPropertyValueType(RegularPropertyValue) 45 46 , m_toPropertyValueType(RegularPropertyValue) … … 231 232 ASSERT(m_animatedType); 232 233 234 if (m_aboutToStopAnimation) { 235 m_aboutToStopAnimation = false; 236 resetAnimationState(m_animatedType->valueAsString()); 237 return; 238 } 239 233 240 setTargetAttributeAnimatedValue(m_animatedType->valueAsString()); 234 241 } … … 261 268 } 262 269 270 void SVGAnimateElement::endedActiveInterval() 271 { 272 SVGAnimationElement::endedActiveInterval(); 273 m_aboutToStopAnimation = true; 274 } 275 263 276 } 264 277 #endif // ENABLE(SVG) -
trunk/Source/WebCore/svg/SVGAnimateElement.h
r108134 r109342 66 66 virtual float calculateDistance(const String& fromString, const String& toString); 67 67 68 virtual void endedActiveInterval(); 68 69 virtual void targetElementDidChange(SVGElement* targetElement) OVERRIDE; 69 70 … … 73 74 virtual bool hasValidAttributeType(); 74 75 AnimatedPropertyType m_animatedPropertyType; 76 bool m_aboutToStopAnimation; 75 77 76 78 AnimatedPropertyValueType m_fromPropertyValueType; -
trunk/Source/WebCore/svg/SVGAnimationElement.cpp
r107693 r109342 331 331 } 332 332 333 static inline void setTargetAttributeAnimatedCSSValue(SVGElement* targetElement, const QualifiedName& attributeName, const String& value) 334 { 335 StylePropertySet* propertySet = targetElement->ensureAnimatedSMILStyleProperties(); 336 if (value.isNull()) { 337 if (propertySet->removeProperty(cssPropertyID(attributeName.localName()))) 338 targetElement->setNeedsStyleRecalc(); 339 return; 340 } 341 342 if (propertySet->setProperty(cssPropertyID(attributeName.localName()), value, false, 0)) 343 targetElement->setNeedsStyleRecalc(); 344 } 345 346 static inline void setTargetAttributeAnimatedXMLValue(SVGElement* targetElement, const QualifiedName& attributeName, const String& value) 347 { 348 // FIXME: Detach animVal, if value.isNull() - once animVal support is enabled. 349 targetElement->setAttribute(attributeName, value); 350 } 351 333 352 void SVGAnimationElement::setTargetAttributeAnimatedValue(const String& value) 334 353 { 335 if (!hasValidAttributeType())336 return;337 354 SVGElement* targetElement = this->targetElement(); 338 QualifiedName attributeName = this->attributeName(); 339 if (!targetElement || attributeName == anyQName() || value.isNull()) 340 return; 341 342 // We don't want the instance tree to get rebuild. Instances are updated in the loop below. 355 const QualifiedName& attributeName = this->attributeName(); 356 ShouldApplyAnimation shouldApply = shouldApplyAnimation(targetElement, attributeName); 357 if (shouldApply == DontApplyAnimation) 358 return; 359 360 if (shouldApply == ApplyCSSAnimation) 361 setTargetAttributeAnimatedCSSValue(targetElement, attributeName, value); 362 else 363 setTargetAttributeAnimatedXMLValue(targetElement, attributeName, value); 364 343 365 if (targetElement->isStyled()) 344 366 static_cast<SVGStyledElement*>(targetElement)->setInstanceUpdatesBlocked(true); 345 346 bool attributeIsCSSProperty = isTargetAttributeCSSProperty(targetElement, attributeName); 347 // Stop animation, if attributeType is set to CSS by the user, but the attribute itself is not a CSS property. 348 if (!attributeIsCSSProperty && attributeType() == AttributeTypeCSS) 349 return; 350 351 ExceptionCode ec; 352 if (attributeIsCSSProperty) { 353 // FIXME: This should set the override style, not the inline style. 354 // Sadly override styles are not yet implemented. 355 targetElement->style()->setProperty(attributeName.localName(), value, "", ec); 356 } else { 357 // FIXME: This should set the 'presentation' value, not the actual 358 // attribute value. Whatever that means in practice. 359 targetElement->setAttribute(attributeName, value); 360 } 361 362 if (targetElement->isStyled()) 363 static_cast<SVGStyledElement*>(targetElement)->setInstanceUpdatesBlocked(false); 364 365 // If the target element is used in an <use> instance tree, update that as well. 367 368 // If the target element has instances, update them as well, w/o requiring the <use> tree to be rebuilt. 366 369 const HashSet<SVGElementInstance*>& instances = targetElement->instancesForElement(); 367 370 const HashSet<SVGElementInstance*>::const_iterator end = instances.end(); … … 370 373 if (!shadowTreeElement) 371 374 continue; 372 if (attributeIsCSSProperty) 373 shadowTreeElement->style()->setProperty(attributeName.localName(), value, "", ec); 375 376 if (shouldApply == ApplyCSSAnimation) 377 setTargetAttributeAnimatedCSSValue(shadowTreeElement, attributeName, value); 374 378 else 375 shadowTreeElement->setAttribute(attributeName, value); 376 (*it)->correspondingUseElement()->setNeedsStyleRecalc(); 377 } 378 } 379 379 setTargetAttributeAnimatedCSSValue(shadowTreeElement, attributeName, value); 380 } 381 382 if (targetElement->isStyled()) 383 static_cast<SVGStyledElement*>(targetElement)->setInstanceUpdatesBlocked(false); 384 } 385 386 void SVGAnimationElement::resetAnimationState(const String& baseValue) 387 { 388 // FIXME: This extra check will go away, once animVal is enabled. 389 SVGElement* targetElement = this->targetElement(); 390 const QualifiedName& attributeName = this->attributeName(); 391 ShouldApplyAnimation shouldApply = shouldApplyAnimation(targetElement, attributeName); 392 if (shouldApply == DontApplyAnimation) 393 return; 394 395 if (isFrozen() || shouldApply == ApplyXMLAnimation) 396 setTargetAttributeAnimatedValue(baseValue); 397 else // Only CSS animations support detaching previously animated properties so far, indicating by passing a null-string. 398 setTargetAttributeAnimatedValue(String()); 399 } 400 401 SVGAnimationElement::ShouldApplyAnimation SVGAnimationElement::shouldApplyAnimation(SVGElement* targetElement, const QualifiedName& attributeName) 402 { 403 if (!hasValidAttributeType() || !targetElement || attributeName == anyQName()) 404 return DontApplyAnimation; 405 406 AttributeType attributeType = this->attributeType(); 407 switch (attributeType) { 408 case AttributeTypeAuto: 409 // For attributeType="auto", try CSS first. If that fails, try XML. 410 case AttributeTypeCSS: 411 // If attributeName is a known animatable SVG CSS property, apply the animation. 412 if (isTargetAttributeCSSProperty(targetElement, attributeName)) 413 return ApplyCSSAnimation; 414 // If attributeName is unknown and ttributeType is not 'auto', don't apply the animation. 415 if (attributeType == AttributeTypeCSS) 416 return DontApplyAnimation; 417 // For attributeType="auto", try XML animation now. 418 case AttributeTypeXML: 419 return ApplyXMLAnimation; 420 }; 421 422 ASSERT_NOT_REACHED(); 423 return DontApplyAnimation; 424 } 425 380 426 void SVGAnimationElement::calculateKeyTimesForCalcModePaced() 381 427 { … … 594 640 m_animationValid = calcMode == CalcModePaced || !fastHasAttribute(SVGNames::keyPointsAttr) || (m_keyTimes.size() > 1 && m_keyTimes.size() == m_keyPoints.size()); 595 641 } 596 642 597 643 void SVGAnimationElement::updateAnimation(float percent, unsigned repeat, SVGSMILElement* resultElement) 598 644 { -
trunk/Source/WebCore/svg/SVGAnimationElement.h
r107693 r109342 106 106 virtual void updateAnimation(float percent, unsigned repeat, SVGSMILElement* resultElement); 107 107 108 void resetAnimationState(const String& baseValue); 109 108 110 private: 109 111 virtual void attributeChanged(Attribute*) OVERRIDE; … … 122 124 float calculatePercentForFromTo(float percent) const; 123 125 unsigned calculateKeyTimesIndex(float percent) const; 126 127 enum ShouldApplyAnimation { 128 DontApplyAnimation, 129 ApplyCSSAnimation, 130 ApplyXMLAnimation 131 }; 132 133 ShouldApplyAnimation shouldApplyAnimation(SVGElement* targetElement, const QualifiedName& attributeName); 124 134 125 135 BEGIN_DECLARE_ANIMATED_PROPERTIES(SVGAnimationElement) -
trunk/Source/WebCore/svg/SVGElement.cpp
r109097 r109342 79 79 80 80 SVGElementRareData* rareData = it->second; 81 rareData->destroyAnimatedSMILStyleProperties(); 81 82 if (SVGCursorElement* cursorElement = rareData->cursorElement()) 82 83 cursorElement->removeClient(this); … … 487 488 488 489 return document()->styleSelector()->styleForElement(correspondingElement(), style, false /*allowSharing*/); 490 } 491 492 StylePropertySet* SVGElement::animatedSMILStyleProperties() const 493 { 494 if (hasRareSVGData()) 495 return rareSVGData()->animatedSMILStyleProperties(); 496 return 0; 497 } 498 499 StylePropertySet* SVGElement::ensureAnimatedSMILStyleProperties() 500 { 501 return ensureRareSVGData()->ensureAnimatedSMILStyleProperties(); 489 502 } 490 503 -
trunk/Source/WebCore/svg/SVGElement.h
r108758 r109342 108 108 #endif 109 109 110 StylePropertySet* animatedSMILStyleProperties() const; 111 StylePropertySet* ensureAnimatedSMILStyleProperties(); 112 110 113 protected: 111 114 SVGElement(const QualifiedName&, Document*, ConstructionType = CreateSVGElement); -
trunk/Source/WebCore/svg/SVGElementRareData.h
r95901 r109342 75 75 void setCursorImageValue(CSSCursorImageValue* cursorImageValue) { m_cursorImageValue = cursorImageValue; } 76 76 77 StylePropertySet* animatedSMILStyleProperties() const { return m_animatedSMILStyleProperties.get(); } 78 StylePropertySet* ensureAnimatedSMILStyleProperties() 79 { 80 if (!m_animatedSMILStyleProperties) { 81 m_animatedSMILStyleProperties = StylePropertySet::create(); 82 m_animatedSMILStyleProperties->setStrictParsing(false); 83 } 84 return m_animatedSMILStyleProperties.get(); 85 } 86 87 void destroyAnimatedSMILStyleProperties() 88 { 89 m_animatedSMILStyleProperties.clear(); 90 } 91 77 92 private: 78 93 HashSet<SVGElementInstance*> m_elementInstances; … … 82 97 bool m_instancesUpdatesBlocked : 1; 83 98 bool m_hasPendingResources : 1; 99 RefPtr<StylePropertySet> m_animatedSMILStyleProperties; 84 100 }; 85 101 -
trunk/Source/WebCore/svg/animation/SVGSMILElement.h
r108134 r109342 117 117 // Sub-classes may need to take action when the target is changed. 118 118 virtual void targetElementDidChange(SVGElement*) { } 119 virtual void endedActiveInterval(); 119 120 120 121 private: 121 122 virtual void startedActiveInterval() = 0; 122 123 virtual void updateAnimation(float percent, unsigned repeat, SVGSMILElement* resultElement) = 0; 123 void endedActiveInterval();124 124 125 125 enum BeginOrEnd {
Note: See TracChangeset
for help on using the changeset viewer.