| 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 25 matching lines...) Expand all Loading... |
| 36 #include "core/animation/AnimationInputHelpers.h" | 36 #include "core/animation/AnimationInputHelpers.h" |
| 37 #include "core/animation/KeyframeEffectModel.h" | 37 #include "core/animation/KeyframeEffectModel.h" |
| 38 #include "core/animation/StringKeyframe.h" | 38 #include "core/animation/StringKeyframe.h" |
| 39 #include "core/css/resolver/StyleResolver.h" | 39 #include "core/css/resolver/StyleResolver.h" |
| 40 #include "core/dom/Document.h" | 40 #include "core/dom/Document.h" |
| 41 #include "core/dom/Element.h" | 41 #include "core/dom/Element.h" |
| 42 #include "wtf/NonCopyingSort.h" | 42 #include "wtf/NonCopyingSort.h" |
| 43 | 43 |
| 44 namespace blink { | 44 namespace blink { |
| 45 | 45 |
| 46 static bool isValidValueForInterpolation(const CSSPropertyID& property, const CS
SValue& value) |
| 47 { |
| 48 const CSSPrimitiveValue& primitiveValue = toCSSPrimitiveValue(value); |
| 49 |
| 50 switch (property) { |
| 51 case CSSPropertyFontSizeAdjust: |
| 52 return primitiveValue.getDoubleValue(CSSPrimitiveValue::CSS_NUMBER) > 0; |
| 53 default: |
| 54 break; |
| 55 } |
| 56 return true; |
| 57 } |
| 58 |
| 46 PassRefPtrWillBeRawPtr<AnimationEffect> EffectInput::convert(Element* element, c
onst Vector<Dictionary>& keyframeDictionaryVector, ExceptionState& exceptionStat
e) | 59 PassRefPtrWillBeRawPtr<AnimationEffect> EffectInput::convert(Element* element, c
onst Vector<Dictionary>& keyframeDictionaryVector, ExceptionState& exceptionStat
e) |
| 47 { | 60 { |
| 48 // FIXME: Remove the dependency on element. | 61 // FIXME: Remove the dependency on element. |
| 49 if (!element) | 62 if (!element) |
| 50 return nullptr; | 63 return nullptr; |
| 51 | 64 |
| 52 StyleSheetContents* styleSheetContents = element->document().elementSheet().
contents(); | 65 StyleSheetContents* styleSheetContents = element->document().elementSheet().
contents(); |
| 53 StringKeyframeVector keyframes; | 66 StringKeyframeVector keyframes; |
| 67 PropertySet invalidValueProperties; |
| 54 double lastOffset = 0; | 68 double lastOffset = 0; |
| 55 | 69 |
| 56 for (const auto& keyframeDictionary : keyframeDictionaryVector) { | 70 for (const auto& keyframeDictionary : keyframeDictionaryVector) { |
| 57 RefPtrWillBeRawPtr<StringKeyframe> keyframe = StringKeyframe::create(); | 71 RefPtrWillBeRawPtr<StringKeyframe> keyframe = StringKeyframe::create(); |
| 58 | 72 |
| 59 ScriptValue scriptValue; | 73 ScriptValue scriptValue; |
| 60 bool frameHasOffset = DictionaryHelper::get(keyframeDictionary, "offset"
, scriptValue) && !scriptValue.isNull(); | 74 bool frameHasOffset = DictionaryHelper::get(keyframeDictionary, "offset"
, scriptValue) && !scriptValue.isNull(); |
| 61 | 75 |
| 62 if (frameHasOffset) { | 76 if (frameHasOffset) { |
| 63 double offset; | 77 double offset; |
| (...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 97 | 111 |
| 98 Vector<String> keyframeProperties; | 112 Vector<String> keyframeProperties; |
| 99 keyframeDictionary.getPropertyNames(keyframeProperties); | 113 keyframeDictionary.getPropertyNames(keyframeProperties); |
| 100 for (const auto& property : keyframeProperties) { | 114 for (const auto& property : keyframeProperties) { |
| 101 CSSPropertyID id = AnimationInputHelpers::keyframeAttributeToCSSProp
ertyID(property); | 115 CSSPropertyID id = AnimationInputHelpers::keyframeAttributeToCSSProp
ertyID(property); |
| 102 if (id == CSSPropertyInvalid) | 116 if (id == CSSPropertyInvalid) |
| 103 continue; | 117 continue; |
| 104 String value; | 118 String value; |
| 105 DictionaryHelper::get(keyframeDictionary, property, value); | 119 DictionaryHelper::get(keyframeDictionary, property, value); |
| 106 keyframe->setPropertyValue(id, value, styleSheetContents); | 120 keyframe->setPropertyValue(id, value, styleSheetContents); |
| 121 |
| 122 if (!isValidValueForInterpolation(id, *keyframe->propertyValue(id))) |
| 123 invalidValueProperties.add(id); |
| 107 } | 124 } |
| 108 } | 125 } |
| 109 | 126 |
| 127 for (CSSPropertyID property : invalidValueProperties) { |
| 128 for (const auto& keyframe : keyframes) |
| 129 keyframe->clearPropertyValue(property); |
| 130 } |
| 131 |
| 110 RefPtrWillBeRawPtr<StringKeyframeEffectModel> keyframeEffectModel = StringKe
yframeEffectModel::create(keyframes); | 132 RefPtrWillBeRawPtr<StringKeyframeEffectModel> keyframeEffectModel = StringKe
yframeEffectModel::create(keyframes); |
| 111 if (keyframeEffectModel->hasSyntheticKeyframes()) { | 133 if (keyframeEffectModel->hasSyntheticKeyframes()) { |
| 112 exceptionState.throwDOMException(NotSupportedError, "Partial keyframes a
re not supported."); | 134 exceptionState.throwDOMException(NotSupportedError, "Partial keyframes a
re not supported."); |
| 113 return nullptr; | 135 return nullptr; |
| 114 } | 136 } |
| 115 if (!keyframeEffectModel->isReplaceOnly()) { | 137 if (!keyframeEffectModel->isReplaceOnly()) { |
| 116 exceptionState.throwDOMException(NotSupportedError, "Additive animations
are not supported."); | 138 exceptionState.throwDOMException(NotSupportedError, "Additive animations
are not supported."); |
| 117 return nullptr; | 139 return nullptr; |
| 118 } | 140 } |
| 119 keyframeEffectModel->forceConversionsToAnimatableValues(*element); | 141 keyframeEffectModel->forceConversionsToAnimatableValues(*element); |
| 120 | 142 |
| 121 return keyframeEffectModel; | 143 return keyframeEffectModel; |
| 122 } | 144 } |
| 123 | 145 |
| 124 PassRefPtrWillBeRawPtr<AnimationEffect> EffectInput::convert(Element* element, c
onst AnimationEffectOrDictionarySequence& effectInput, ExceptionState& exception
State) | 146 PassRefPtrWillBeRawPtr<AnimationEffect> EffectInput::convert(Element* element, c
onst AnimationEffectOrDictionarySequence& effectInput, ExceptionState& exception
State) |
| 125 { | 147 { |
| 126 if (effectInput.isAnimationEffect()) | 148 if (effectInput.isAnimationEffect()) |
| 127 return effectInput.getAsAnimationEffect(); | 149 return effectInput.getAsAnimationEffect(); |
| 128 if (effectInput.isDictionarySequence()) | 150 if (effectInput.isDictionarySequence()) |
| 129 return convert(element, effectInput.getAsDictionarySequence(), exception
State); | 151 return convert(element, effectInput.getAsDictionarySequence(), exception
State); |
| 130 return nullptr; | 152 return nullptr; |
| 131 } | 153 } |
| 132 | 154 |
| 133 } // namespace blink | 155 } // namespace blink |
| OLD | NEW |