| OLD | NEW |
| 1 // Copyright 2014 The Chromium Authors. All rights reserved. | 1 // Copyright 2014 The Chromium Authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 #include "config.h" | 5 #include "config.h" |
| 6 #include "core/animation/StringKeyframe.h" | 6 #include "core/animation/StringKeyframe.h" |
| 7 | 7 |
| 8 #include "core/XLinkNames.h" | 8 #include "core/XLinkNames.h" |
| 9 #include "core/animation/AngleSVGInterpolation.h" | 9 #include "core/animation/AngleSVGInterpolation.h" |
| 10 #include "core/animation/CSSColorInterpolationType.h" | 10 #include "core/animation/CSSColorInterpolationType.h" |
| (...skipping 20 matching lines...) Expand all Loading... |
| 31 #include "core/animation/LengthPairStyleInterpolation.h" | 31 #include "core/animation/LengthPairStyleInterpolation.h" |
| 32 #include "core/animation/LengthSVGInterpolation.h" | 32 #include "core/animation/LengthSVGInterpolation.h" |
| 33 #include "core/animation/LengthStyleInterpolation.h" | 33 #include "core/animation/LengthStyleInterpolation.h" |
| 34 #include "core/animation/ListSVGInterpolation.h" | 34 #include "core/animation/ListSVGInterpolation.h" |
| 35 #include "core/animation/ListStyleInterpolation.h" | 35 #include "core/animation/ListStyleInterpolation.h" |
| 36 #include "core/animation/NumberOptionalNumberSVGInterpolation.h" | 36 #include "core/animation/NumberOptionalNumberSVGInterpolation.h" |
| 37 #include "core/animation/NumberSVGInterpolation.h" | 37 #include "core/animation/NumberSVGInterpolation.h" |
| 38 #include "core/animation/PathSVGInterpolation.h" | 38 #include "core/animation/PathSVGInterpolation.h" |
| 39 #include "core/animation/PointSVGInterpolation.h" | 39 #include "core/animation/PointSVGInterpolation.h" |
| 40 #include "core/animation/RectSVGInterpolation.h" | 40 #include "core/animation/RectSVGInterpolation.h" |
| 41 #include "core/animation/SVGNumberInterpolationType.h" |
| 41 #include "core/animation/SVGStrokeDasharrayStyleInterpolation.h" | 42 #include "core/animation/SVGStrokeDasharrayStyleInterpolation.h" |
| 42 #include "core/animation/SVGValueInterpolationType.h" | 43 #include "core/animation/SVGValueInterpolationType.h" |
| 43 #include "core/animation/TransformSVGInterpolation.h" | 44 #include "core/animation/TransformSVGInterpolation.h" |
| 44 #include "core/animation/VisibilityStyleInterpolation.h" | 45 #include "core/animation/VisibilityStyleInterpolation.h" |
| 45 #include "core/animation/css/CSSAnimations.h" | 46 #include "core/animation/css/CSSAnimations.h" |
| 46 #include "core/css/CSSPropertyMetadata.h" | 47 #include "core/css/CSSPropertyMetadata.h" |
| 47 #include "core/css/resolver/StyleResolver.h" | 48 #include "core/css/resolver/StyleResolver.h" |
| 48 #include "core/style/ComputedStyle.h" | 49 #include "core/style/ComputedStyle.h" |
| 49 #include "core/svg/SVGElement.h" | 50 #include "core/svg/SVGElement.h" |
| 50 #include "platform/RuntimeEnabledFeatures.h" | 51 #include "platform/RuntimeEnabledFeatures.h" |
| (...skipping 204 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 255 break; | 256 break; |
| 256 default: | 257 default: |
| 257 // TODO(alancutter): Support all interpolable CSS properties here so
we can stop falling back to the old StyleInterpolation implementation. | 258 // TODO(alancutter): Support all interpolable CSS properties here so
we can stop falling back to the old StyleInterpolation implementation. |
| 258 if (CSSPropertyMetadata::isInterpolableProperty(cssProperty)) | 259 if (CSSPropertyMetadata::isInterpolableProperty(cssProperty)) |
| 259 fallbackToLegacy = true; | 260 fallbackToLegacy = true; |
| 260 break; | 261 break; |
| 261 } | 262 } |
| 262 applicableTypes->append(new CSSValueInterpolationType(cssProperty)); | 263 applicableTypes->append(new CSSValueInterpolationType(cssProperty)); |
| 263 } else { | 264 } else { |
| 264 const QualifiedName& attribute = property.svgAttribute(); | 265 const QualifiedName& attribute = property.svgAttribute(); |
| 265 if (attribute == HTMLNames::classAttr | 266 if (attribute == SVGNames::amplitudeAttr |
| 267 || attribute == SVGNames::azimuthAttr |
| 268 || attribute == SVGNames::biasAttr |
| 269 || attribute == SVGNames::diffuseConstantAttr |
| 270 || attribute == SVGNames::divisorAttr |
| 271 || attribute == SVGNames::elevationAttr |
| 272 || attribute == SVGNames::exponentAttr |
| 273 || attribute == SVGNames::interceptAttr |
| 274 || attribute == SVGNames::k1Attr |
| 275 || attribute == SVGNames::k2Attr |
| 276 || attribute == SVGNames::k3Attr |
| 277 || attribute == SVGNames::k4Attr |
| 278 || attribute == SVGNames::limitingConeAngleAttr |
| 279 || attribute == SVGNames::offsetAttr |
| 280 || attribute == SVGNames::pathLengthAttr |
| 281 || attribute == SVGNames::pointsAtXAttr |
| 282 || attribute == SVGNames::pointsAtYAttr |
| 283 || attribute == SVGNames::pointsAtZAttr |
| 284 || attribute == SVGNames::scaleAttr |
| 285 || attribute == SVGNames::seedAttr |
| 286 || attribute == SVGNames::slopeAttr |
| 287 || attribute == SVGNames::specularConstantAttr |
| 288 || attribute == SVGNames::specularExponentAttr |
| 289 || attribute == SVGNames::surfaceScaleAttr |
| 290 || attribute == SVGNames::zAttr) { |
| 291 applicableTypes->append(new SVGNumberInterpolationType(attribute)); |
| 292 } else if (attribute == HTMLNames::classAttr |
| 266 || attribute == SVGNames::clipPathUnitsAttr | 293 || attribute == SVGNames::clipPathUnitsAttr |
| 267 || attribute == SVGNames::edgeModeAttr | 294 || attribute == SVGNames::edgeModeAttr |
| 268 || attribute == SVGNames::filterUnitsAttr | 295 || attribute == SVGNames::filterUnitsAttr |
| 269 || attribute == SVGNames::gradientUnitsAttr | 296 || attribute == SVGNames::gradientUnitsAttr |
| 270 || attribute == SVGNames::inAttr | 297 || attribute == SVGNames::inAttr |
| 271 || attribute == SVGNames::in2Attr | 298 || attribute == SVGNames::in2Attr |
| 272 || attribute == SVGNames::lengthAdjustAttr | 299 || attribute == SVGNames::lengthAdjustAttr |
| 273 || attribute == SVGNames::markerUnitsAttr | 300 || attribute == SVGNames::markerUnitsAttr |
| 274 || attribute == SVGNames::maskContentUnitsAttr | 301 || attribute == SVGNames::maskContentUnitsAttr |
| 275 || attribute == SVGNames::maskUnitsAttr | 302 || attribute == SVGNames::maskUnitsAttr |
| 276 || attribute == SVGNames::methodAttr | 303 || attribute == SVGNames::methodAttr |
| 277 || attribute == SVGNames::modeAttr | 304 || attribute == SVGNames::modeAttr |
| 278 || attribute == SVGNames::operatorAttr | 305 || attribute == SVGNames::operatorAttr |
| 279 || attribute == SVGNames::patternContentUnitsAttr | 306 || attribute == SVGNames::patternContentUnitsAttr |
| 280 || attribute == SVGNames::patternUnitsAttr | 307 || attribute == SVGNames::patternUnitsAttr |
| 281 || attribute == SVGNames::preserveAlphaAttr | 308 || attribute == SVGNames::preserveAlphaAttr |
| 282 || attribute == SVGNames::preserveAspectRatioAttr | 309 || attribute == SVGNames::preserveAspectRatioAttr |
| 283 || attribute == SVGNames::primitiveUnitsAttr | 310 || attribute == SVGNames::primitiveUnitsAttr |
| 284 || attribute == SVGNames::resultAttr | 311 || attribute == SVGNames::resultAttr |
| 285 || attribute == SVGNames::spacingAttr | 312 || attribute == SVGNames::spacingAttr |
| 286 || attribute == SVGNames::spreadMethodAttr | 313 || attribute == SVGNames::spreadMethodAttr |
| 287 || attribute == SVGNames::stitchTilesAttr | 314 || attribute == SVGNames::stitchTilesAttr |
| 288 || attribute == SVGNames::targetAttr | 315 || attribute == SVGNames::targetAttr |
| 289 || attribute == SVGNames::typeAttr | 316 || attribute == SVGNames::typeAttr |
| 290 || attribute == SVGNames::xChannelSelectorAttr | 317 || attribute == SVGNames::xChannelSelectorAttr |
| 291 || attribute == SVGNames::yChannelSelectorAttr | 318 || attribute == SVGNames::yChannelSelectorAttr |
| 292 || attribute == XLinkNames::hrefAttr) { | 319 || attribute == XLinkNames::hrefAttr) { |
| 293 applicableTypes->append(new SVGValueInterpolationType(attribute)); | 320 // Use default SVGValueInterpolationType. |
| 294 } else { | 321 } else { |
| 295 fallbackToLegacy = true; | 322 fallbackToLegacy = true; |
| 296 } | 323 } |
| 324 |
| 325 if (!fallbackToLegacy) |
| 326 applicableTypes->append(new SVGValueInterpolationType(attribute)); |
| 297 } | 327 } |
| 298 | 328 |
| 299 if (fallbackToLegacy) { | 329 if (fallbackToLegacy) { |
| 300 delete applicableTypes; | 330 delete applicableTypes; |
| 301 applicableTypesMap.add(property, nullptr); | 331 applicableTypesMap.add(property, nullptr); |
| 302 return nullptr; | 332 return nullptr; |
| 303 } | 333 } |
| 304 | 334 |
| 305 applicableTypesMap.add(property, applicableTypes); | 335 applicableTypesMap.add(property, applicableTypes); |
| 306 return applicableTypes; | 336 return applicableTypes; |
| (...skipping 225 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 532 return IntegerSVGInterpolation::create(fromValue, toValue, attribute); | 562 return IntegerSVGInterpolation::create(fromValue, toValue, attribute); |
| 533 case AnimatedIntegerOptionalInteger: { | 563 case AnimatedIntegerOptionalInteger: { |
| 534 int min = &attribute->attributeName() == &SVGNames::orderAttr ? 1 : 0; | 564 int min = &attribute->attributeName() == &SVGNames::orderAttr ? 1 : 0; |
| 535 return IntegerOptionalIntegerSVGInterpolation::create(fromValue, toValue
, attribute, min); | 565 return IntegerOptionalIntegerSVGInterpolation::create(fromValue, toValue
, attribute, min); |
| 536 } | 566 } |
| 537 case AnimatedLength: | 567 case AnimatedLength: |
| 538 return LengthSVGInterpolation::create(fromValue, toValue, attribute); | 568 return LengthSVGInterpolation::create(fromValue, toValue, attribute); |
| 539 case AnimatedLengthList: | 569 case AnimatedLengthList: |
| 540 interpolation = ListSVGInterpolation<LengthSVGInterpolation>::maybeCreat
e(fromValue, toValue, attribute); | 570 interpolation = ListSVGInterpolation<LengthSVGInterpolation>::maybeCreat
e(fromValue, toValue, attribute); |
| 541 break; | 571 break; |
| 542 case AnimatedNumber: { | |
| 543 SVGNumberNegativeValuesMode negativeValuesMode = &attribute->attributeNa
me() == &SVGNames::pathLengthAttr ? ForbidNegativeNumbers : AllowNegativeNumbers
; | |
| 544 return NumberSVGInterpolation::create(fromValue, toValue, attribute, neg
ativeValuesMode); | |
| 545 } | |
| 546 case AnimatedNumberOptionalNumber: | 572 case AnimatedNumberOptionalNumber: |
| 547 return NumberOptionalNumberSVGInterpolation::create(fromValue, toValue,
attribute); | 573 return NumberOptionalNumberSVGInterpolation::create(fromValue, toValue,
attribute); |
| 548 case AnimatedNumberList: | 574 case AnimatedNumberList: |
| 549 interpolation = ListSVGInterpolation<NumberSVGInterpolation>::maybeCreat
e(fromValue, toValue, attribute); | 575 interpolation = ListSVGInterpolation<NumberSVGInterpolation>::maybeCreat
e(fromValue, toValue, attribute); |
| 550 break; | 576 break; |
| 551 case AnimatedPath: | 577 case AnimatedPath: |
| 552 interpolation = PathSVGInterpolation::maybeCreate(fromValue, toValue, at
tribute); | 578 interpolation = PathSVGInterpolation::maybeCreate(fromValue, toValue, at
tribute); |
| 553 break; | 579 break; |
| 554 case AnimatedPoints: | 580 case AnimatedPoints: |
| 555 interpolation = ListSVGInterpolation<PointSVGInterpolation>::maybeCreate
(fromValue, toValue, attribute); | 581 interpolation = ListSVGInterpolation<PointSVGInterpolation>::maybeCreate
(fromValue, toValue, attribute); |
| 556 break; | 582 break; |
| 557 case AnimatedRect: | 583 case AnimatedRect: |
| 558 return RectSVGInterpolation::create(fromValue, toValue, attribute); | 584 return RectSVGInterpolation::create(fromValue, toValue, attribute); |
| 559 case AnimatedTransformList: | 585 case AnimatedTransformList: |
| 560 interpolation = ListSVGInterpolation<TransformSVGInterpolation>::maybeCr
eate(fromValue, toValue, attribute); | 586 interpolation = ListSVGInterpolation<TransformSVGInterpolation>::maybeCr
eate(fromValue, toValue, attribute); |
| 561 break; | 587 break; |
| 562 | 588 |
| 589 // Handled by SVGInterpolationTypes. |
| 590 case AnimatedNumber: |
| 591 ASSERT_NOT_REACHED(); |
| 592 // Fallthrough. |
| 593 |
| 563 // TODO(ericwilligers): Support more animation types. | 594 // TODO(ericwilligers): Support more animation types. |
| 564 default: | 595 default: |
| 565 break; | 596 break; |
| 566 } | 597 } |
| 567 if (interpolation) | 598 if (interpolation) |
| 568 return interpolation.release(); | 599 return interpolation.release(); |
| 569 | 600 |
| 570 return DefaultSVGInterpolation::create(fromValue, toValue, attribute); | 601 return DefaultSVGInterpolation::create(fromValue, toValue, attribute); |
| 571 } | 602 } |
| 572 | 603 |
| (...skipping 12 matching lines...) Expand all Loading... |
| 585 RefPtrWillBeRawPtr<SVGPropertyBase> fromValue = attribute->currentValueBase(
)->cloneForAnimation(m_value); | 616 RefPtrWillBeRawPtr<SVGPropertyBase> fromValue = attribute->currentValueBase(
)->cloneForAnimation(m_value); |
| 586 RefPtrWillBeRawPtr<SVGPropertyBase> toValue = attribute->currentValueBase()-
>cloneForAnimation(toSVGPropertySpecificKeyframe(end).value()); | 617 RefPtrWillBeRawPtr<SVGPropertyBase> toValue = attribute->currentValueBase()-
>cloneForAnimation(toSVGPropertySpecificKeyframe(end).value()); |
| 587 | 618 |
| 588 if (!fromValue || !toValue) | 619 if (!fromValue || !toValue) |
| 589 return nullptr; | 620 return nullptr; |
| 590 | 621 |
| 591 return createSVGInterpolation(fromValue.get(), toValue.get(), attribute.get(
)); | 622 return createSVGInterpolation(fromValue.get(), toValue.get(), attribute.get(
)); |
| 592 } | 623 } |
| 593 | 624 |
| 594 } // namespace blink | 625 } // namespace blink |
| OLD | NEW |