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

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

Issue 2524303002: Emit console warning when element.animate() keyframe value fails to parse (Closed)
Patch Set: Review changes Created 4 years, 1 month 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
Index: third_party/WebKit/Source/core/animation/EffectInput.cpp
diff --git a/third_party/WebKit/Source/core/animation/EffectInput.cpp b/third_party/WebKit/Source/core/animation/EffectInput.cpp
index 2da614f5f0e7a4f763d7b93dc052ebdfc05962a9..afa33e9d6691bc62af2997fefa5a240ac8492570 100644
--- a/third_party/WebKit/Source/core/animation/EffectInput.cpp
+++ b/third_party/WebKit/Source/core/animation/EffectInput.cpp
@@ -42,6 +42,9 @@
#include "core/dom/Element.h"
#include "core/dom/ExceptionCode.h"
#include "core/dom/NodeComputedStyle.h"
+#include "core/frame/FrameConsole.h"
+#include "core/frame/LocalFrame.h"
+#include "core/inspector/ConsoleMessage.h"
#include "wtf/ASCIICType.h"
#include "wtf/HashSet.h"
#include "wtf/NonCopyingSort.h"
@@ -82,18 +85,28 @@ bool checkOffset(double offset,
void setKeyframeValue(Element& element,
StringKeyframe& keyframe,
const String& property,
- const String& value) {
+ const String& value,
+ ExecutionContext* executionContext) {
StyleSheetContents* styleSheetContents =
element.document().elementSheet().contents();
CSSPropertyID cssProperty =
AnimationInputHelpers::keyframeAttributeToCSSProperty(property,
element.document());
if (cssProperty != CSSPropertyInvalid) {
- if (cssProperty == CSSPropertyVariable)
- keyframe.setCSSPropertyValue(AtomicString(property), value,
- styleSheetContents);
- else
- keyframe.setCSSPropertyValue(cssProperty, value, styleSheetContents);
+ MutableStylePropertySet::SetResult setResult =
+ cssProperty == CSSPropertyVariable
+ ? keyframe.setCSSPropertyValue(AtomicString(property), value,
+ styleSheetContents)
+ : keyframe.setCSSPropertyValue(cssProperty, value,
+ styleSheetContents);
+ if (!setResult.didParse && executionContext) {
+ Document& document = toDocument(*executionContext);
+ if (document.frame()) {
+ document.frame()->console().addMessage(ConsoleMessage::create(
+ JSMessageSource, WarningMessageLevel,
+ "Invalid keyframe value for property " + property + ": " + value));
+ }
+ }
return;
}
cssProperty = AnimationInputHelpers::keyframeAttributeToPresentationAttribute(
@@ -168,9 +181,10 @@ EffectModel* EffectInput::convert(
if (effectInput.isNull() || !element)
return nullptr;
- if (effectInput.isDictionarySequence())
+ if (effectInput.isDictionarySequence()) {
return convertArrayForm(*element, effectInput.getAsDictionarySequence(),
- exceptionState);
+ executionContext, exceptionState);
+ }
const Dictionary& dictionary = effectInput.getAsDictionary();
DictionaryIterator iterator = dictionary.getIterator(executionContext);
@@ -179,8 +193,10 @@ EffectModel* EffectInput::convert(
// match spec.
Vector<Dictionary> keyframeDictionaries;
if (exhaustDictionaryIterator(iterator, executionContext, exceptionState,
- keyframeDictionaries))
- return convertArrayForm(*element, keyframeDictionaries, exceptionState);
+ keyframeDictionaries)) {
+ return convertArrayForm(*element, keyframeDictionaries, executionContext,
+ exceptionState);
+ }
return nullptr;
}
@@ -191,6 +207,7 @@ EffectModel* EffectInput::convert(
EffectModel* EffectInput::convertArrayForm(
Element& element,
const Vector<Dictionary>& keyframeDictionaries,
+ ExecutionContext* executionContext,
ExceptionState& exceptionState) {
StringKeyframeVector keyframes;
double lastOffset = 0;
@@ -243,7 +260,8 @@ EffectModel* EffectInput::convertArrayForm(
String value;
DictionaryHelper::get(keyframeDictionary, property, value);
- setKeyframeValue(element, *keyframe.get(), property, value);
+ setKeyframeValue(element, *keyframe.get(), property, value,
+ executionContext);
}
keyframes.append(keyframe);
}
@@ -355,7 +373,8 @@ EffectModel* EffectInput::convertObjectForm(
keyframe->setComposite(EffectModel::CompositeAdd);
// TODO(alancutter): Support "accumulate" keyframe composition.
- setKeyframeValue(element, *keyframe.get(), property, values[i]);
+ setKeyframeValue(element, *keyframe.get(), property, values[i],
+ executionContext);
keyframes.append(keyframe);
}
}
« no previous file with comments | « third_party/WebKit/Source/core/animation/EffectInput.h ('k') | third_party/WebKit/Source/core/animation/StringKeyframe.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698