| 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 15 matching lines...) Expand all Loading... |
| 26 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT | 26 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT |
| 27 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE | 27 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE |
| 28 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. | 28 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. |
| 29 */ | 29 */ |
| 30 | 30 |
| 31 #include "core/animation/EffectInput.h" | 31 #include "core/animation/EffectInput.h" |
| 32 | 32 |
| 33 #include "bindings/core/v8/Dictionary.h" | 33 #include "bindings/core/v8/Dictionary.h" |
| 34 #include "bindings/core/v8/UnionTypesCore.h" | 34 #include "bindings/core/v8/UnionTypesCore.h" |
| 35 #include "core/animation/AnimationInputHelpers.h" | 35 #include "core/animation/AnimationInputHelpers.h" |
| 36 #include "core/animation/CompositorAnimations.h" |
| 36 #include "core/animation/KeyframeEffectModel.h" | 37 #include "core/animation/KeyframeEffectModel.h" |
| 37 #include "core/animation/StringKeyframe.h" | 38 #include "core/animation/StringKeyframe.h" |
| 38 #include "core/css/CSSStyleSheet.h" | 39 #include "core/css/CSSStyleSheet.h" |
| 39 #include "core/dom/Document.h" | 40 #include "core/dom/Document.h" |
| 40 #include "core/dom/Element.h" | 41 #include "core/dom/Element.h" |
| 41 #include "core/dom/ExceptionCode.h" | 42 #include "core/dom/ExceptionCode.h" |
| 42 #include "core/dom/NodeComputedStyle.h" | 43 #include "core/dom/NodeComputedStyle.h" |
| 43 #include "wtf/ASCIICType.h" | 44 #include "wtf/ASCIICType.h" |
| 44 #include "wtf/HashSet.h" | 45 #include "wtf/HashSet.h" |
| 45 #include "wtf/NonCopyingSort.h" | 46 #include "wtf/NonCopyingSort.h" |
| 46 | 47 |
| 47 namespace blink { | 48 namespace blink { |
| 48 | 49 |
| 49 EffectModel* EffectInput::convert(Element* element, const Vector<Dictionary>& ke
yframeDictionaryVector, ExceptionState& exceptionState) | 50 EffectModel* EffectInput::convert(Element* element, const Vector<Dictionary>& ke
yframeDictionaryVector, ExceptionState& exceptionState) |
| 50 { | 51 { |
| 51 if (!element) | 52 if (!element) |
| 52 return nullptr; | 53 return nullptr; |
| 53 | 54 |
| 54 // TODO(alancutter): Remove this once composited animations no longer depend
on AnimatableValues. | |
| 55 if (element->inActiveDocument()) | |
| 56 element->document().updateLayoutTreeForNodeIfNeeded(element); | |
| 57 | |
| 58 StyleSheetContents* styleSheetContents = element->document().elementSheet().
contents(); | 55 StyleSheetContents* styleSheetContents = element->document().elementSheet().
contents(); |
| 59 StringKeyframeVector keyframes; | 56 StringKeyframeVector keyframes; |
| 60 double lastOffset = 0; | 57 double lastOffset = 0; |
| 58 bool encounteredCompositableProperty = false; |
| 61 | 59 |
| 62 for (const auto& keyframeDictionary : keyframeDictionaryVector) { | 60 for (const auto& keyframeDictionary : keyframeDictionaryVector) { |
| 63 RefPtr<StringKeyframe> keyframe = StringKeyframe::create(); | 61 RefPtr<StringKeyframe> keyframe = StringKeyframe::create(); |
| 64 | 62 |
| 65 ScriptValue scriptValue; | 63 ScriptValue scriptValue; |
| 66 bool frameHasOffset = DictionaryHelper::get(keyframeDictionary, "offset"
, scriptValue) && !scriptValue.isNull(); | 64 bool frameHasOffset = DictionaryHelper::get(keyframeDictionary, "offset"
, scriptValue) && !scriptValue.isNull(); |
| 67 | 65 |
| 68 if (frameHasOffset) { | 66 if (frameHasOffset) { |
| 69 double offset; | 67 double offset; |
| 70 DictionaryHelper::get(keyframeDictionary, "offset", offset); | 68 DictionaryHelper::get(keyframeDictionary, "offset", offset); |
| (...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 103 } | 101 } |
| 104 | 102 |
| 105 Vector<String> keyframeProperties; | 103 Vector<String> keyframeProperties; |
| 106 keyframeDictionary.getPropertyNames(keyframeProperties); | 104 keyframeDictionary.getPropertyNames(keyframeProperties); |
| 107 for (const auto& property : keyframeProperties) { | 105 for (const auto& property : keyframeProperties) { |
| 108 String value; | 106 String value; |
| 109 DictionaryHelper::get(keyframeDictionary, property, value); | 107 DictionaryHelper::get(keyframeDictionary, property, value); |
| 110 | 108 |
| 111 CSSPropertyID cssProperty = AnimationInputHelpers::keyframeAttribute
ToCSSProperty(property); | 109 CSSPropertyID cssProperty = AnimationInputHelpers::keyframeAttribute
ToCSSProperty(property); |
| 112 if (cssProperty != CSSPropertyInvalid) { | 110 if (cssProperty != CSSPropertyInvalid) { |
| 111 if (!encounteredCompositableProperty && CompositorAnimations::is
CompositableProperty(cssProperty)) |
| 112 encounteredCompositableProperty = true; |
| 113 |
| 113 keyframe->setCSSPropertyValue(cssProperty, value, element, style
SheetContents); | 114 keyframe->setCSSPropertyValue(cssProperty, value, element, style
SheetContents); |
| 114 continue; | 115 continue; |
| 115 } | 116 } |
| 116 | 117 |
| 117 if (property == "offset" | 118 if (property == "offset" |
| 118 || property == "composite" | 119 || property == "composite" |
| 119 || property == "easing") { | 120 || property == "easing") { |
| 120 continue; | 121 continue; |
| 121 } | 122 } |
| 122 | 123 |
| 123 cssProperty = AnimationInputHelpers::keyframeAttributeToPresentation
Attribute(property, *element); | 124 cssProperty = AnimationInputHelpers::keyframeAttributeToPresentation
Attribute(property, *element); |
| 124 if (cssProperty != CSSPropertyInvalid) { | 125 if (cssProperty != CSSPropertyInvalid) { |
| 125 keyframe->setPresentationAttributeValue(cssProperty, value, elem
ent, styleSheetContents); | 126 keyframe->setPresentationAttributeValue(cssProperty, value, elem
ent, styleSheetContents); |
| 126 continue; | 127 continue; |
| 127 } | 128 } |
| 128 | 129 |
| 129 const QualifiedName* svgAttribute = AnimationInputHelpers::keyframeA
ttributeToSVGAttribute(property, *element); | 130 const QualifiedName* svgAttribute = AnimationInputHelpers::keyframeA
ttributeToSVGAttribute(property, *element); |
| 130 if (svgAttribute) | 131 if (svgAttribute) |
| 131 keyframe->setSVGAttributeValue(*svgAttribute, value); | 132 keyframe->setSVGAttributeValue(*svgAttribute, value); |
| 132 } | 133 } |
| 133 } | 134 } |
| 134 | 135 |
| 136 // TODO(alancutter): Remove this once composited animations no longer depend
on AnimatableValues. |
| 137 if (encounteredCompositableProperty && element->inActiveDocument()) |
| 138 element->document().updateLayoutTreeForNodeIfNeeded(element); |
| 139 |
| 135 StringKeyframeEffectModel* keyframeEffectModel = StringKeyframeEffectModel::
create(keyframes); | 140 StringKeyframeEffectModel* keyframeEffectModel = StringKeyframeEffectModel::
create(keyframes); |
| 136 if (!RuntimeEnabledFeatures::cssAdditiveAnimationsEnabled()) { | 141 if (!RuntimeEnabledFeatures::cssAdditiveAnimationsEnabled()) { |
| 137 for (const auto& keyframeGroup : keyframeEffectModel->getPropertySpecifi
cKeyframeGroups()) { | 142 for (const auto& keyframeGroup : keyframeEffectModel->getPropertySpecifi
cKeyframeGroups()) { |
| 138 PropertyHandle property = keyframeGroup.key; | 143 PropertyHandle property = keyframeGroup.key; |
| 139 if (!property.isCSSProperty()) | 144 if (!property.isCSSProperty()) |
| 140 continue; | 145 continue; |
| 141 | 146 |
| 142 for (const auto& keyframe : keyframeGroup.value->keyframes()) { | 147 for (const auto& keyframe : keyframeGroup.value->keyframes()) { |
| 143 if (keyframe->isNeutral()) { | 148 if (keyframe->isNeutral()) { |
| 144 exceptionState.throwDOMException(NotSupportedError, "Partial
keyframes are not supported."); | 149 exceptionState.throwDOMException(NotSupportedError, "Partial
keyframes are not supported."); |
| (...skipping 19 matching lines...) Expand all Loading... |
| 164 return convert(element, effectInput.getAsDictionarySequence(), exception
State); | 169 return convert(element, effectInput.getAsDictionarySequence(), exception
State); |
| 165 if (effectInput.isDictionary()) { | 170 if (effectInput.isDictionary()) { |
| 166 Vector<Dictionary> keyframes; | 171 Vector<Dictionary> keyframes; |
| 167 keyframes.append(effectInput.getAsDictionary()); | 172 keyframes.append(effectInput.getAsDictionary()); |
| 168 return convert(element, keyframes, exceptionState); | 173 return convert(element, keyframes, exceptionState); |
| 169 } | 174 } |
| 170 return nullptr; | 175 return nullptr; |
| 171 } | 176 } |
| 172 | 177 |
| 173 } // namespace blink | 178 } // namespace blink |
| OLD | NEW |