OLD | NEW |
1 /* | 1 /* |
2 * Copyright (C) 2013 Google Inc. All rights reserved. | 2 * Copyright (C) 2013 Google Inc. All rights reserved. |
3 * | 3 * |
4 * Redistribution and use in source and binary forms, with or without | 4 * Redistribution and use in source and binary forms, with or without |
5 * modification, are permitted provided that the following conditions are | 5 * modification, are permitted provided that the following conditions are |
6 * met: | 6 * met: |
7 * | 7 * |
8 * * Redistributions of source code must retain the above copyright | 8 * * Redistributions of source code must retain the above copyright |
9 * notice, this list of conditions and the following disclaimer. | 9 * notice, this list of conditions and the following disclaimer. |
10 * * Redistributions in binary form must reproduce the above | 10 * * Redistributions in binary form must reproduce the above |
(...skipping 22 matching lines...) Expand all Loading... |
33 | 33 |
34 #include "core/StylePropertyShorthand.h" | 34 #include "core/StylePropertyShorthand.h" |
35 #include "core/animation/ActiveAnimations.h" | 35 #include "core/animation/ActiveAnimations.h" |
36 #include "core/animation/AnimationTimeline.h" | 36 #include "core/animation/AnimationTimeline.h" |
37 #include "core/animation/CompositorAnimations.h" | 37 #include "core/animation/CompositorAnimations.h" |
38 #include "core/animation/KeyframeEffectModel.h" | 38 #include "core/animation/KeyframeEffectModel.h" |
39 #include "core/animation/LegacyStyleInterpolation.h" | 39 #include "core/animation/LegacyStyleInterpolation.h" |
40 #include "core/animation/css/CSSAnimatableValueFactory.h" | 40 #include "core/animation/css/CSSAnimatableValueFactory.h" |
41 #include "core/animation/css/CSSPropertyEquality.h" | 41 #include "core/animation/css/CSSPropertyEquality.h" |
42 #include "core/css/CSSKeyframeRule.h" | 42 #include "core/css/CSSKeyframeRule.h" |
| 43 #include "core/css/CSSPropertyMetadata.h" |
43 #include "core/css/resolver/CSSToStyleMap.h" | 44 #include "core/css/resolver/CSSToStyleMap.h" |
44 #include "core/css/resolver/StyleResolver.h" | 45 #include "core/css/resolver/StyleResolver.h" |
45 #include "core/dom/Element.h" | 46 #include "core/dom/Element.h" |
46 #include "core/dom/PseudoElement.h" | 47 #include "core/dom/PseudoElement.h" |
47 #include "core/dom/StyleEngine.h" | 48 #include "core/dom/StyleEngine.h" |
48 #include "core/events/TransitionEvent.h" | 49 #include "core/events/TransitionEvent.h" |
49 #include "core/events/WebKitAnimationEvent.h" | 50 #include "core/events/WebKitAnimationEvent.h" |
50 #include "core/frame/UseCounter.h" | 51 #include "core/frame/UseCounter.h" |
51 #include "core/rendering/RenderLayer.h" | 52 #include "core/rendering/RenderLayer.h" |
52 #include "core/rendering/RenderObject.h" | 53 #include "core/rendering/RenderObject.h" |
(...skipping 58 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
111 if (property == CSSPropertyWebkitAnimationTimingFunction || property
== CSSPropertyAnimationTimingFunction) { | 112 if (property == CSSPropertyWebkitAnimationTimingFunction || property
== CSSPropertyAnimationTimingFunction) { |
112 CSSValue* value = properties.propertyAt(j).value(); | 113 CSSValue* value = properties.propertyAt(j).value(); |
113 RefPtr<TimingFunction> timingFunction; | 114 RefPtr<TimingFunction> timingFunction; |
114 if (value->isInheritedValue() && parentStyle->animations()) | 115 if (value->isInheritedValue() && parentStyle->animations()) |
115 timingFunction = parentStyle->animations()->timingFunctionLi
st()[0]; | 116 timingFunction = parentStyle->animations()->timingFunctionLi
st()[0]; |
116 else if (value->isInheritedValue() || value->isInitialValue()) | 117 else if (value->isInheritedValue() || value->isInitialValue()) |
117 timingFunction = CSSTimingData::initialTimingFunction(); | 118 timingFunction = CSSTimingData::initialTimingFunction(); |
118 else | 119 else |
119 timingFunction = CSSToStyleMap::mapAnimationTimingFunction(t
oCSSValueList(value)->item(0)); | 120 timingFunction = CSSToStyleMap::mapAnimationTimingFunction(t
oCSSValueList(value)->item(0)); |
120 keyframe->setEasing(timingFunction.release()); | 121 keyframe->setEasing(timingFunction.release()); |
121 } else if (CSSAnimations::isAnimatableProperty(property)) { | 122 } else if (CSSPropertyMetadata::isAnimatableProperty(property)) { |
122 keyframe->setPropertyValue(property, CSSAnimatableValueFactory::
create(property, *keyframeStyle).get()); | 123 keyframe->setPropertyValue(property, CSSAnimatableValueFactory::
create(property, *keyframeStyle).get()); |
123 } | 124 } |
124 } | 125 } |
125 keyframes.append(keyframe); | 126 keyframes.append(keyframe); |
126 // The last keyframe specified at a given offset is used. | 127 // The last keyframe specified at a given offset is used. |
127 for (size_t j = 1; j < offsets.size(); ++j) { | 128 for (size_t j = 1; j < offsets.size(); ++j) { |
128 keyframes.append(toAnimatableValueKeyframe(keyframe->cloneWithOffset
(offsets[j]).get())); | 129 keyframes.append(toAnimatableValueKeyframe(keyframe->cloneWithOffset
(offsets[j]).get())); |
129 } | 130 } |
130 } | 131 } |
131 ASSERT(!keyframes.isEmpty()); | 132 ASSERT(!keyframes.isEmpty()); |
(...skipping 352 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
484 if (animateAll) | 485 if (animateAll) |
485 anyTransitionHadTransitionAll = true; | 486 anyTransitionHadTransitionAll = true; |
486 const StylePropertyShorthand& propertyList = animateAll ? CSSAnimati
ons::animatableProperties() : shorthandForProperty(property); | 487 const StylePropertyShorthand& propertyList = animateAll ? CSSAnimati
ons::animatableProperties() : shorthandForProperty(property); |
487 // If not a shorthand we only execute one iteration of this loop, an
d refer to the property directly. | 488 // If not a shorthand we only execute one iteration of this loop, an
d refer to the property directly. |
488 for (unsigned j = 0; !j || j < propertyList.length(); ++j) { | 489 for (unsigned j = 0; !j || j < propertyList.length(); ++j) { |
489 CSSPropertyID id = propertyList.length() ? propertyList.properti
es()[j] : property; | 490 CSSPropertyID id = propertyList.length() ? propertyList.properti
es()[j] : property; |
490 CSSPropertyID eventId = id; | 491 CSSPropertyID eventId = id; |
491 | 492 |
492 if (!animateAll) { | 493 if (!animateAll) { |
493 id = propertyForAnimation(id); | 494 id = propertyForAnimation(id); |
494 if (CSSAnimations::isAnimatableProperty(id)) | 495 if (CSSPropertyMetadata::isAnimatableProperty(id)) |
495 listedProperties.set(id); | 496 listedProperties.set(id); |
496 else | 497 else |
497 continue; | 498 continue; |
498 } | 499 } |
499 | 500 |
500 // FIXME: We should transition if an !important property changes
even when an animation is running, | 501 // FIXME: We should transition if an !important property changes
even when an animation is running, |
501 // but this is a bit hard to do with the current applyMatchedPro
perties system. | 502 // but this is a bit hard to do with the current applyMatchedPro
perties system. |
502 if (!update->activeInterpolationsForAnimations().contains(id) | 503 if (!update->activeInterpolationsForAnimations().contains(id) |
503 && (!activeAnimations || !activeAnimations->cssAnimations().
m_previousActiveInterpolationsForAnimations.contains(id))) { | 504 && (!activeAnimations || !activeAnimations->cssAnimations().
m_previousActiveInterpolationsForAnimations.contains(id))) { |
504 calculateTransitionUpdateForProperty(id, eventId, *transitio
nData, i, oldStyle, style, activeTransitions, update, element); | 505 calculateTransitionUpdateForProperty(id, eventId, *transitio
nData, i, oldStyle, style, activeTransitions, update, element); |
(...skipping 147 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
652 | 653 |
653 m_previousPhase = currentPhase; | 654 m_previousPhase = currentPhase; |
654 } | 655 } |
655 | 656 |
656 void CSSAnimations::TransitionEventDelegate::trace(Visitor* visitor) | 657 void CSSAnimations::TransitionEventDelegate::trace(Visitor* visitor) |
657 { | 658 { |
658 visitor->trace(m_target); | 659 visitor->trace(m_target); |
659 AnimationNode::EventDelegate::trace(visitor); | 660 AnimationNode::EventDelegate::trace(visitor); |
660 } | 661 } |
661 | 662 |
662 bool CSSAnimations::isAnimatableProperty(CSSPropertyID property) | |
663 { | |
664 switch (property) { | |
665 case CSSPropertyBackgroundColor: | |
666 case CSSPropertyBackgroundImage: | |
667 case CSSPropertyBackgroundPositionX: | |
668 case CSSPropertyBackgroundPositionY: | |
669 case CSSPropertyBackgroundSize: | |
670 case CSSPropertyBaselineShift: | |
671 case CSSPropertyBorderBottomColor: | |
672 case CSSPropertyBorderBottomLeftRadius: | |
673 case CSSPropertyBorderBottomRightRadius: | |
674 case CSSPropertyBorderBottomWidth: | |
675 case CSSPropertyBorderImageOutset: | |
676 case CSSPropertyBorderImageSlice: | |
677 case CSSPropertyBorderImageSource: | |
678 case CSSPropertyBorderImageWidth: | |
679 case CSSPropertyBorderLeftColor: | |
680 case CSSPropertyBorderLeftWidth: | |
681 case CSSPropertyBorderRightColor: | |
682 case CSSPropertyBorderRightWidth: | |
683 case CSSPropertyBorderTopColor: | |
684 case CSSPropertyBorderTopLeftRadius: | |
685 case CSSPropertyBorderTopRightRadius: | |
686 case CSSPropertyBorderTopWidth: | |
687 case CSSPropertyBottom: | |
688 case CSSPropertyBoxShadow: | |
689 case CSSPropertyClip: | |
690 case CSSPropertyColor: | |
691 case CSSPropertyFill: | |
692 case CSSPropertyFillOpacity: | |
693 case CSSPropertyFlexBasis: | |
694 case CSSPropertyFlexGrow: | |
695 case CSSPropertyFlexShrink: | |
696 case CSSPropertyFloodColor: | |
697 case CSSPropertyFloodOpacity: | |
698 case CSSPropertyFontSize: | |
699 case CSSPropertyFontWeight: | |
700 case CSSPropertyHeight: | |
701 case CSSPropertyLeft: | |
702 case CSSPropertyLetterSpacing: | |
703 case CSSPropertyLightingColor: | |
704 case CSSPropertyLineHeight: | |
705 case CSSPropertyListStyleImage: | |
706 case CSSPropertyMarginBottom: | |
707 case CSSPropertyMarginLeft: | |
708 case CSSPropertyMarginRight: | |
709 case CSSPropertyMarginTop: | |
710 case CSSPropertyMaxHeight: | |
711 case CSSPropertyMaxWidth: | |
712 case CSSPropertyMinHeight: | |
713 case CSSPropertyMinWidth: | |
714 case CSSPropertyObjectPosition: | |
715 case CSSPropertyOpacity: | |
716 case CSSPropertyOrphans: | |
717 case CSSPropertyOutlineColor: | |
718 case CSSPropertyOutlineOffset: | |
719 case CSSPropertyOutlineWidth: | |
720 case CSSPropertyPaddingBottom: | |
721 case CSSPropertyPaddingLeft: | |
722 case CSSPropertyPaddingRight: | |
723 case CSSPropertyPaddingTop: | |
724 case CSSPropertyRight: | |
725 case CSSPropertyStopColor: | |
726 case CSSPropertyStopOpacity: | |
727 case CSSPropertyStroke: | |
728 case CSSPropertyStrokeDasharray: | |
729 case CSSPropertyStrokeDashoffset: | |
730 case CSSPropertyStrokeMiterlimit: | |
731 case CSSPropertyStrokeOpacity: | |
732 case CSSPropertyStrokeWidth: | |
733 case CSSPropertyTextDecorationColor: | |
734 case CSSPropertyTextIndent: | |
735 case CSSPropertyTextShadow: | |
736 case CSSPropertyTop: | |
737 case CSSPropertyVerticalAlign: | |
738 case CSSPropertyVisibility: | |
739 case CSSPropertyWebkitBackgroundSize: | |
740 case CSSPropertyWebkitBorderHorizontalSpacing: | |
741 case CSSPropertyWebkitBorderVerticalSpacing: | |
742 case CSSPropertyWebkitBoxShadow: | |
743 case CSSPropertyWebkitClipPath: | |
744 case CSSPropertyWebkitColumnCount: | |
745 case CSSPropertyWebkitColumnGap: | |
746 case CSSPropertyWebkitColumnRuleColor: | |
747 case CSSPropertyWebkitColumnRuleWidth: | |
748 case CSSPropertyWebkitColumnWidth: | |
749 case CSSPropertyWebkitFilter: | |
750 case CSSPropertyWebkitMaskBoxImageOutset: | |
751 case CSSPropertyWebkitMaskBoxImageSlice: | |
752 case CSSPropertyWebkitMaskBoxImageSource: | |
753 case CSSPropertyWebkitMaskBoxImageWidth: | |
754 case CSSPropertyWebkitMaskImage: | |
755 case CSSPropertyWebkitMaskPositionX: | |
756 case CSSPropertyWebkitMaskPositionY: | |
757 case CSSPropertyWebkitMaskSize: | |
758 case CSSPropertyPerspective: | |
759 case CSSPropertyPerspectiveOrigin: | |
760 case CSSPropertyShapeOutside: | |
761 case CSSPropertyShapeMargin: | |
762 case CSSPropertyShapeImageThreshold: | |
763 case CSSPropertyWebkitTextStrokeColor: | |
764 case CSSPropertyTransform: | |
765 case CSSPropertyTransformOrigin: | |
766 case CSSPropertyWidows: | |
767 case CSSPropertyWidth: | |
768 case CSSPropertyWordSpacing: | |
769 case CSSPropertyZIndex: | |
770 case CSSPropertyZoom: | |
771 return true; | |
772 default: | |
773 return false; | |
774 } | |
775 } | |
776 | |
777 const StylePropertyShorthand& CSSAnimations::animatableProperties() | 663 const StylePropertyShorthand& CSSAnimations::animatableProperties() |
778 { | 664 { |
779 DEFINE_STATIC_LOCAL(Vector<CSSPropertyID>, properties, ()); | 665 DEFINE_STATIC_LOCAL(Vector<CSSPropertyID>, properties, ()); |
780 DEFINE_STATIC_LOCAL(StylePropertyShorthand, propertyShorthand, ()); | 666 DEFINE_STATIC_LOCAL(StylePropertyShorthand, propertyShorthand, ()); |
781 if (properties.isEmpty()) { | 667 if (properties.isEmpty()) { |
782 for (int i = firstCSSProperty; i < lastCSSProperty; ++i) { | 668 for (int i = firstCSSProperty; i < lastCSSProperty; ++i) { |
783 CSSPropertyID id = convertToCSSPropertyID(i); | 669 CSSPropertyID id = convertToCSSPropertyID(i); |
784 if (isAnimatableProperty(id)) | 670 if (CSSPropertyMetadata::isAnimatableProperty(id)) |
785 properties.append(id); | 671 properties.append(id); |
786 } | 672 } |
787 propertyShorthand = StylePropertyShorthand(CSSPropertyInvalid, propertie
s.begin(), properties.size()); | 673 propertyShorthand = StylePropertyShorthand(CSSPropertyInvalid, propertie
s.begin(), properties.size()); |
788 } | 674 } |
789 return propertyShorthand; | 675 return propertyShorthand; |
790 } | 676 } |
791 | 677 |
792 // Animation properties are not allowed to be affected by Web Animations. | 678 // Animation properties are not allowed to be affected by Web Animations. |
793 // http://dev.w3.org/fxtf/web-animations/#not-animatable | 679 // http://dev.w3.org/fxtf/web-animations/#not-animatable |
794 bool CSSAnimations::isAllowedAnimation(CSSPropertyID property) | 680 bool CSSAnimations::isAllowedAnimation(CSSPropertyID property) |
(...skipping 49 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
844 #if ENABLE(OILPAN) | 730 #if ENABLE(OILPAN) |
845 visitor->trace(m_newTransitions); | 731 visitor->trace(m_newTransitions); |
846 visitor->trace(m_activeInterpolationsForAnimations); | 732 visitor->trace(m_activeInterpolationsForAnimations); |
847 visitor->trace(m_activeInterpolationsForTransitions); | 733 visitor->trace(m_activeInterpolationsForTransitions); |
848 visitor->trace(m_newAnimations); | 734 visitor->trace(m_newAnimations); |
849 visitor->trace(m_cancelledAnimationPlayers); | 735 visitor->trace(m_cancelledAnimationPlayers); |
850 #endif | 736 #endif |
851 } | 737 } |
852 | 738 |
853 } // namespace blink | 739 } // namespace blink |
OLD | NEW |