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

Unified Diff: Source/core/animation/EffectInput.cpp

Issue 194733002: Web Animations: Use StringKeyframes for element.animate() (Closed) Base URL: svn://svn.chromium.org/blink/trunk
Patch Set: More comments Created 6 years, 8 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « Source/core/animation/AnimationTest.cpp ('k') | Source/core/animation/Keyframe.h » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: Source/core/animation/EffectInput.cpp
diff --git a/Source/core/animation/EffectInput.cpp b/Source/core/animation/EffectInput.cpp
index 87d1c293a505ae71bd63003515fc86cce3bf9f6e..d08e1c6b6f168c4e8ccaadc1779c5e4c3c1ad3c8 100644
--- a/Source/core/animation/EffectInput.cpp
+++ b/Source/core/animation/EffectInput.cpp
@@ -33,39 +33,35 @@
#include "bindings/v8/Dictionary.h"
#include "core/animation/AnimationHelpers.h"
-#include "core/animation/css/CSSAnimations.h"
+#include "core/animation/KeyframeEffectModel.h"
+#include "core/animation/StringKeyframe.h"
#include "core/css/parser/BisonCSSParser.h"
#include "core/css/resolver/StyleResolver.h"
#include "core/dom/Element.h"
namespace WebCore {
-static bool checkDocumentAndRenderer(Element* element)
+// FIXME: Remove this once we've removed the dependency on Element.
+static bool checkDocumentAndRenderer(Element& element)
{
- if (!element->inActiveDocument())
+ if (!element.inActiveDocument())
return false;
- element->document().updateRenderTreeIfNeeded();
- return element->renderer();
+ element.document().updateRenderTreeIfNeeded();
+ return element.renderer();
}
-PassRefPtrWillBeRawPtr<AnimationEffect> EffectInput::convert(Element* element, const Vector<Dictionary>& keyframeDictionaryVector, ExceptionState& exceptionState, bool unsafe)
+PassRefPtrWillBeRawPtr<AnimationEffect> EffectInput::convert(Element* element, const Vector<Dictionary>& keyframeDictionaryVector, ExceptionState& exceptionState, bool unsafe)
{
// FIXME: This test will not be neccessary once resolution of keyframe values occurs at
// animation application time.
- if (!unsafe && !checkDocumentAndRenderer(element))
+ if (!unsafe && !checkDocumentAndRenderer(*element))
return nullptr;
StyleSheetContents* styleSheetContents = element->document().elementSheet().contents();
-
- // FIXME: Move this code into KeyframeEffectModel, it will be used by the IDL constructor for that class.
- AnimatableValueKeyframeVector keyframes;
- WillBeHeapVector<RefPtrWillBeMember<MutableStylePropertySet> > propertySetVector;
+ StringKeyframeVector keyframes;
for (size_t i = 0; i < keyframeDictionaryVector.size(); ++i) {
- RefPtrWillBeRawPtr<MutableStylePropertySet> propertySet = MutableStylePropertySet::create();
- propertySetVector.append(propertySet);
-
- RefPtrWillBeRawPtr<AnimatableValueKeyframe> keyframe = AnimatableValueKeyframe::create();
+ RefPtrWillBeRawPtr<StringKeyframe> keyframe = StringKeyframe::create();
keyframes.append(keyframe);
double offset;
@@ -86,31 +82,23 @@ PassRefPtrWillBeRawPtr<AnimationEffect> EffectInput::convert(Element* element, c
Vector<String> keyframeProperties;
keyframeDictionaryVector[i].getOwnPropertyNames(keyframeProperties);
-
for (size_t j = 0; j < keyframeProperties.size(); ++j) {
String property = keyframeProperties[j];
CSSPropertyID id = camelCaseCSSPropertyNameToID(property);
-
- // FIXME: There is no way to store invalid properties or invalid values
- // in a Keyframe object, so for now I just skip over them. Eventually we
- // will need to support getFrames(), which should return exactly the
- // keyframes that were input through the API. We will add a layer to wrap
- // KeyframeEffectModel, store input keyframes and implement getFrames.
- if (id == CSSPropertyInvalid || !CSSAnimations::isAnimatableProperty(id))
+ if (id == CSSPropertyInvalid)
continue;
-
String value;
keyframeDictionaryVector[i].get(property, value);
- propertySet->setProperty(id, value, false, styleSheetContents);
+ keyframe->setPropertyValue(id, value, styleSheetContents);
}
}
- // FIXME: Replace this with code that just parses, when that code is available.
- RefPtrWillBeRawPtr<AnimatableValueKeyframeEffectModel> keyframeEffectModel = StyleResolver::createKeyframeEffectModel(*element, propertySetVector, keyframes);
+ RefPtrWillBeRawPtr<StringKeyframeEffectModel> keyframeEffectModel = StringKeyframeEffectModel::create(keyframes);
if (!keyframeEffectModel->isReplaceOnly()) {
exceptionState.throwDOMException(NotSupportedError, "Partial keyframes are not supported.");
return nullptr;
}
+ keyframeEffectModel->forceConversionsToAnimatableValues(element);
return keyframeEffectModel;
}
« no previous file with comments | « Source/core/animation/AnimationTest.cpp ('k') | Source/core/animation/Keyframe.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698