Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(642)

Side by Side Diff: Source/core/animation/EffectInput.cpp

Issue 534133002: [WIP] bindings: Introduce PropertyBag (Closed) Base URL: https://chromium.googlesource.com/chromium/blink.git@master
Patch Set: Created 6 years, 3 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « Source/core/animation/AnimationTest.cpp ('k') | Source/core/animation/TimingInput.cpp » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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 40 matching lines...) Expand 10 before | Expand all | Expand 10 after
51 return nullptr; 51 return nullptr;
52 52
53 StyleSheetContents* styleSheetContents = element->document().elementSheet(). contents(); 53 StyleSheetContents* styleSheetContents = element->document().elementSheet(). contents();
54 StringKeyframeVector keyframes; 54 StringKeyframeVector keyframes;
55 double lastOffset = 0; 55 double lastOffset = 0;
56 56
57 for (size_t i = 0; i < keyframeDictionaryVector.size(); ++i) { 57 for (size_t i = 0; i < keyframeDictionaryVector.size(); ++i) {
58 RefPtrWillBeRawPtr<StringKeyframe> keyframe = StringKeyframe::create(); 58 RefPtrWillBeRawPtr<StringKeyframe> keyframe = StringKeyframe::create();
59 59
60 ScriptValue scriptValue; 60 ScriptValue scriptValue;
61 bool frameHasOffset = DictionaryHelper::get(keyframeDictionaryVector[i], "offset", scriptValue) && !scriptValue.isNull(); 61 bool frameHasOffset = keyframeDictionaryVector[i].get("offset", scriptVa lue) && !scriptValue.isNull();
62 62
63 if (frameHasOffset) { 63 if (frameHasOffset) {
64 double offset; 64 double offset;
65 DictionaryHelper::get(keyframeDictionaryVector[i], "offset", offset) ; 65 keyframeDictionaryVector[i].get("offset", offset);
66 66
67 // Keyframes with offsets outside the range [0.0, 1.0] are an error. 67 // Keyframes with offsets outside the range [0.0, 1.0] are an error.
68 if (std::isnan(offset)) { 68 if (std::isnan(offset)) {
69 exceptionState.throwDOMException(InvalidModificationError, "Non numeric offset provided"); 69 exceptionState.throwDOMException(InvalidModificationError, "Non numeric offset provided");
70 } 70 }
71 71
72 if (offset < 0 || offset > 1) { 72 if (offset < 0 || offset > 1) {
73 exceptionState.throwDOMException(InvalidModificationError, "Offs ets provided outside the range [0, 1]"); 73 exceptionState.throwDOMException(InvalidModificationError, "Offs ets provided outside the range [0, 1]");
74 return nullptr; 74 return nullptr;
75 } 75 }
76 76
77 if (offset < lastOffset) { 77 if (offset < lastOffset) {
78 exceptionState.throwDOMException(InvalidModificationError, "Keyf rames with specified offsets are not sorted"); 78 exceptionState.throwDOMException(InvalidModificationError, "Keyf rames with specified offsets are not sorted");
79 return nullptr; 79 return nullptr;
80 } 80 }
81 81
82 lastOffset = offset; 82 lastOffset = offset;
83 83
84 keyframe->setOffset(offset); 84 keyframe->setOffset(offset);
85 } 85 }
86 keyframes.append(keyframe); 86 keyframes.append(keyframe);
87 87
88 String compositeString; 88 String compositeString;
89 DictionaryHelper::get(keyframeDictionaryVector[i], "composite", composit eString); 89 keyframeDictionaryVector[i].get("composite", compositeString);
90 if (compositeString == "add") 90 if (compositeString == "add")
91 keyframe->setComposite(AnimationEffect::CompositeAdd); 91 keyframe->setComposite(AnimationEffect::CompositeAdd);
92 92
93 String timingFunctionString; 93 String timingFunctionString;
94 if (DictionaryHelper::get(keyframeDictionaryVector[i], "easing", timingF unctionString)) { 94 if (keyframeDictionaryVector[i].get("easing", timingFunctionString)) {
95 if (RefPtrWillBeRawPtr<CSSValue> timingFunctionValue = BisonCSSParse r::parseAnimationTimingFunctionValue(timingFunctionString)) 95 if (RefPtrWillBeRawPtr<CSSValue> timingFunctionValue = BisonCSSParse r::parseAnimationTimingFunctionValue(timingFunctionString))
96 keyframe->setEasing(CSSToStyleMap::mapAnimationTimingFunction(ti mingFunctionValue.get(), true)); 96 keyframe->setEasing(CSSToStyleMap::mapAnimationTimingFunction(ti mingFunctionValue.get(), true));
97 } 97 }
98 98
99 Vector<String> keyframeProperties; 99 Vector<String> keyframeProperties;
100 keyframeDictionaryVector[i].getOwnPropertyNames(keyframeProperties); 100 keyframeDictionaryVector[i].getOwnPropertyNames(keyframeProperties);
101 for (size_t j = 0; j < keyframeProperties.size(); ++j) { 101 for (size_t j = 0; j < keyframeProperties.size(); ++j) {
102 String property = keyframeProperties[j]; 102 String property = keyframeProperties[j];
103 CSSPropertyID id = camelCaseCSSPropertyNameToID(property); 103 CSSPropertyID id = camelCaseCSSPropertyNameToID(property);
104 if (id == CSSPropertyInvalid) 104 if (id == CSSPropertyInvalid)
105 continue; 105 continue;
106 String value; 106 String value;
107 DictionaryHelper::get(keyframeDictionaryVector[i], property, value); 107 keyframeDictionaryVector[i].get(property, value);
108 keyframe->setPropertyValue(id, value, styleSheetContents); 108 keyframe->setPropertyValue(id, value, styleSheetContents);
109 } 109 }
110 } 110 }
111 111
112 RefPtrWillBeRawPtr<StringKeyframeEffectModel> keyframeEffectModel = StringKe yframeEffectModel::create(keyframes); 112 RefPtrWillBeRawPtr<StringKeyframeEffectModel> keyframeEffectModel = StringKe yframeEffectModel::create(keyframes);
113 if (!keyframeEffectModel->isReplaceOnly()) { 113 if (!keyframeEffectModel->isReplaceOnly()) {
114 exceptionState.throwDOMException(NotSupportedError, "Partial keyframes a re not supported."); 114 exceptionState.throwDOMException(NotSupportedError, "Partial keyframes a re not supported.");
115 return nullptr; 115 return nullptr;
116 } 116 }
117 keyframeEffectModel->forceConversionsToAnimatableValues(element); 117 keyframeEffectModel->forceConversionsToAnimatableValues(element);
118 118
119 return keyframeEffectModel; 119 return keyframeEffectModel;
120 } 120 }
121 121
122 } // namespace blink 122 } // namespace blink
OLDNEW
« no previous file with comments | « Source/core/animation/AnimationTest.cpp ('k') | Source/core/animation/TimingInput.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698