Index: Source/bindings/v8/ScriptPromise.h |
diff --git a/Source/core/animation/AnimatableUnknown.h b/Source/bindings/v8/ScriptPromise.h |
similarity index 57% |
copy from Source/core/animation/AnimatableUnknown.h |
copy to Source/bindings/v8/ScriptPromise.h |
index c136380f5895896249ed7d6e02356791d562c6dc..02f0a227b39aa701b9e539d8c07e953d79d9e451 100644 |
--- a/Source/core/animation/AnimatableUnknown.h |
+++ b/Source/bindings/v8/ScriptPromise.h |
@@ -28,52 +28,75 @@ |
* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. |
*/ |
-#ifndef AnimatableUnknown_h |
-#define AnimatableUnknown_h |
+#ifndef ScriptPromise_h |
+#define ScriptPromise_h |
-#include "core/animation/AnimatableValue.h" |
+#include "bindings/v8/ScopedPersistent.h" |
+#include "bindings/v8/ScriptValue.h" |
+#include "bindings/v8/V8ScriptRunner.h" |
+#include <v8.h> |
namespace WebCore { |
-class AnimatableUnknown : public AnimatableValue { |
+// ScriptPromise is the class for representing Promise values in C++ world. |
+// ScriptPromise holds a Promise. |
+// So holding a ScriptPromise as a member variable in DOM object causes |
+// memory leaks since it has a reference from C++ to V8. |
+// |
+class ScriptPromise { |
public: |
- virtual ~AnimatableUnknown() { } |
+ ScriptPromise() |
+ : m_promise() |
+ { |
+ } |
- static PassRefPtr<AnimatableUnknown> create(PassRefPtr<CSSValue> value) |
+ explicit ScriptPromise(ScriptValue promise) |
+ : m_promise(promise) |
{ |
- return adoptRef(new AnimatableUnknown(value)); |
+ ASSERT(!m_promise.hasNoValue()); |
} |
- PassRefPtr<CSSValue> toCSSValue() const { return m_value; } |
+ explicit ScriptPromise(v8::Handle<v8::Value> promise) |
+ : m_promise(promise) |
+ { |
+ ASSERT(!m_promise.hasNoValue()); |
+ } |
-protected: |
- virtual PassRefPtr<AnimatableValue> interpolateTo(const AnimatableValue* value, double fraction) const OVERRIDE |
+ bool isObject() const |
{ |
- return defaultInterpolateTo(this, value, fraction); |
+ return m_promise.isObject(); |
} |
- virtual PassRefPtr<AnimatableValue> addWith(const AnimatableValue* value) const OVERRIDE |
+ bool isNull() const |
{ |
- return defaultAddWith(this, value); |
+ return m_promise.isNull(); |
} |
-private: |
- explicit AnimatableUnknown(PassRefPtr<CSSValue> value) |
- : AnimatableValue(TypeUnknown) |
- , m_value(value) |
+ bool isUndefinedOrNull() const |
{ |
- ASSERT(m_value); |
+ return m_promise.isUndefined() || m_promise.isNull(); |
} |
- const RefPtr<CSSValue> m_value; |
-}; |
+ v8::Handle<v8::Value> v8Value() const |
+ { |
+ return m_promise.v8Value(); |
+ } |
-inline const AnimatableUnknown* toAnimatableUnknown(const AnimatableValue* value) |
-{ |
- ASSERT_WITH_SECURITY_IMPLICATION(value && value->isUnknown()); |
- return static_cast<const AnimatableUnknown*>(value); |
-} |
+ bool hasNoValue() const |
+ { |
+ return m_promise.hasNoValue(); |
+ } |
+ |
+ void clear() |
+ { |
+ m_promise.clear(); |
+ } |
+ |
+private: |
+ ScriptValue m_promise; |
+}; |
} // namespace WebCore |
-#endif // AnimatableUnknown_h |
+ |
+#endif // ScriptPromise_h |