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

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

Issue 2047293002: Code cleanup: Replace Element with Document in element.animate() (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@_killForceConversionsToAnimatableValues
Patch Set: Fix unit test crash. Created 4 years, 5 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
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 ea361f44c2209bcdb67e822576a0c47c7bec7a65..cdc81c89747959417af7be9ff7676c7c0522c9e2 100644
--- a/third_party/WebKit/Source/core/animation/EffectInput.cpp
+++ b/third_party/WebKit/Source/core/animation/EffectInput.cpp
@@ -38,7 +38,6 @@
#include "core/animation/StringKeyframe.h"
#include "core/css/CSSStyleSheet.h"
#include "core/dom/Document.h"
-#include "core/dom/Element.h"
#include "core/dom/ExceptionCode.h"
#include "core/dom/NodeComputedStyle.h"
#include "wtf/ASCIICType.h"
@@ -78,25 +77,25 @@ bool getAndCheckOffset(const Dictionary& keyframeDictionary, double& offset, dou
return true;
}
-void setKeyframeValue(Element& element, StringKeyframe& keyframe, const String& property, const String& value)
+void setKeyframeValue(Document& document, StringKeyframe& keyframe, const String& property, const String& value)
{
- StyleSheetContents* styleSheetContents = element.document().elementSheet().contents();
- CSSPropertyID cssProperty = AnimationInputHelpers::keyframeAttributeToCSSProperty(property, element.document());
+ StyleSheetContents* styleSheetContents = document.elementSheet().contents();
+ CSSPropertyID cssProperty = AnimationInputHelpers::keyframeAttributeToCSSProperty(property, document);
if (cssProperty != CSSPropertyInvalid) {
- keyframe.setCSSPropertyValue(cssProperty, value, &element, styleSheetContents);
+ keyframe.setCSSPropertyValue(cssProperty, value, styleSheetContents);
return;
}
- cssProperty = AnimationInputHelpers::keyframeAttributeToPresentationAttribute(property, element);
+ cssProperty = AnimationInputHelpers::keyframeAttributeToPresentationAttribute(property);
if (cssProperty != CSSPropertyInvalid) {
- keyframe.setPresentationAttributeValue(cssProperty, value, &element, styleSheetContents);
+ keyframe.setPresentationAttributeValue(cssProperty, value, styleSheetContents);
return;
}
- const QualifiedName* svgAttribute = AnimationInputHelpers::keyframeAttributeToSVGAttribute(property, element);
+ const QualifiedName* svgAttribute = AnimationInputHelpers::keyframeAttributeToSVGAttribute(property);
if (svgAttribute)
keyframe.setSVGAttributeValue(*svgAttribute, value);
}
-EffectModel* createEffectModelFromKeyframes(Element& element, const StringKeyframeVector& keyframes, ExceptionState& exceptionState)
+EffectModel* createEffectModelFromKeyframes(const StringKeyframeVector& keyframes, ExceptionState& exceptionState)
{
StringKeyframeEffectModel* keyframeEffectModel = StringKeyframeEffectModel::create(keyframes, LinearTimingFunction::shared());
if (!RuntimeEnabledFeatures::cssAdditiveAnimationsEnabled()) {
@@ -138,16 +137,16 @@ bool exhaustDictionaryIterator(DictionaryIterator& iterator, ExecutionContext* e
} // namespace
// Spec: http://w3c.github.io/web-animations/#processing-a-frames-argument
-EffectModel* EffectInput::convert(Element* element, const EffectModelOrDictionarySequenceOrDictionary& effectInput, ExecutionContext* executionContext, ExceptionState& exceptionState)
+EffectModel* EffectInput::convert(Document& document, const EffectModelOrDictionarySequenceOrDictionary& effectInput, ExecutionContext* executionContext, ExceptionState& exceptionState)
{
if (effectInput.isEffectModel())
return effectInput.getAsEffectModel();
- if (effectInput.isNull() || !element)
+ if (effectInput.isNull())
return nullptr;
if (effectInput.isDictionarySequence())
- return convertArrayForm(*element, effectInput.getAsDictionarySequence(), exceptionState);
+ return convertArrayForm(document, effectInput.getAsDictionarySequence(), exceptionState);
const Dictionary& dictionary = effectInput.getAsDictionary();
DictionaryIterator iterator = dictionary.getIterator(executionContext);
@@ -155,14 +154,14 @@ EffectModel* EffectInput::convert(Element* element, const EffectModelOrDictionar
// TODO(alancutter): Convert keyframes during iteration rather than after to match spec.
Vector<Dictionary> keyframeDictionaries;
if (exhaustDictionaryIterator(iterator, executionContext, exceptionState, keyframeDictionaries))
- return convertArrayForm(*element, keyframeDictionaries, exceptionState);
+ return convertArrayForm(document, keyframeDictionaries, exceptionState);
return nullptr;
}
- return convertObjectForm(*element, dictionary, exceptionState);
+ return convertObjectForm(document, dictionary, exceptionState);
}
-EffectModel* EffectInput::convertArrayForm(Element& element, const Vector<Dictionary>& keyframeDictionaries, ExceptionState& exceptionState)
+EffectModel* EffectInput::convertArrayForm(Document& document, const Vector<Dictionary>& keyframeDictionaries, ExceptionState& exceptionState)
{
StringKeyframeVector keyframes;
double lastOffset = 0;
@@ -189,7 +188,7 @@ EffectModel* EffectInput::convertArrayForm(Element& element, const Vector<Dictio
String timingFunctionString;
if (DictionaryHelper::get(keyframeDictionary, "easing", timingFunctionString)) {
- RefPtr<TimingFunction> timingFunction = AnimationInputHelpers::parseTimingFunction(timingFunctionString, &element.document(), exceptionState);
+ RefPtr<TimingFunction> timingFunction = AnimationInputHelpers::parseTimingFunction(timingFunctionString, document, exceptionState);
if (!timingFunction)
return nullptr;
keyframe->setEasing(timingFunction);
@@ -213,24 +212,24 @@ EffectModel* EffectInput::convertArrayForm(Element& element, const Vector<Dictio
String value;
DictionaryHelper::get(keyframeDictionary, property, value);
- setKeyframeValue(element, *keyframe.get(), property, value);
+ setKeyframeValue(document, *keyframe.get(), property, value);
}
keyframes.append(keyframe);
}
ASSERT(!exceptionState.hadException());
- return createEffectModelFromKeyframes(element, keyframes, exceptionState);
+ return createEffectModelFromKeyframes(keyframes, exceptionState);
}
-EffectModel* EffectInput::convertObjectForm(Element& element, const Dictionary& keyframeDictionary, ExceptionState& exceptionState)
+EffectModel* EffectInput::convertObjectForm(Document& document, const Dictionary& keyframeDictionary, ExceptionState& exceptionState)
{
StringKeyframeVector keyframes;
String timingFunctionString;
RefPtr<TimingFunction> timingFunction = nullptr;
if (DictionaryHelper::get(keyframeDictionary, "easing", timingFunctionString)) {
- timingFunction = AnimationInputHelpers::parseTimingFunction(timingFunctionString, &element.document(), exceptionState);
+ timingFunction = AnimationInputHelpers::parseTimingFunction(timingFunctionString, document, exceptionState);
if (!timingFunction)
return nullptr;
}
@@ -279,7 +278,7 @@ EffectModel* EffectInput::convertObjectForm(Element& element, const Dictionary&
keyframe->setComposite(EffectModel::CompositeAdd);
// TODO(alancutter): Support "accumulate" keyframe composition.
- setKeyframeValue(element, *keyframe.get(), property, values[i]);
+ setKeyframeValue(document, *keyframe.get(), property, values[i]);
keyframes.append(keyframe);
}
}
@@ -288,7 +287,7 @@ EffectModel* EffectInput::convertObjectForm(Element& element, const Dictionary&
ASSERT(!exceptionState.hadException());
- return createEffectModelFromKeyframes(element, keyframes, exceptionState);
+ return createEffectModelFromKeyframes(keyframes, exceptionState);
}
} // namespace blink
« no previous file with comments | « third_party/WebKit/Source/core/animation/EffectInput.h ('k') | third_party/WebKit/Source/core/animation/EffectInputTest.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698