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

Unified Diff: Source/bindings/v8/ScriptFunction.h

Issue 23254004: Implement ScriptPromise and ScriptFunction (Closed) Base URL: svn://svn.chromium.org/blink/trunk
Patch Set: Control shouldn't reach the end of a non-void function Created 7 years, 4 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: Source/bindings/v8/ScriptFunction.h
diff --git a/Source/core/testing/LayerRect.h b/Source/bindings/v8/ScriptFunction.h
similarity index 61%
copy from Source/core/testing/LayerRect.h
copy to Source/bindings/v8/ScriptFunction.h
index 4827feee4f2476d200f0a986a73c81ca9cb4d020..a47c4515b3e8e93affc72daa17ad196d0d20c6ed 100644
--- a/Source/core/testing/LayerRect.h
+++ b/Source/bindings/v8/ScriptFunction.h
@@ -28,42 +28,40 @@
* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
-#ifndef LayerRect_h
-#define LayerRect_h
+#ifndef ScriptFunction_h
+#define ScriptFunction_h
-#include "core/dom/ClientRect.h"
-
-#include "wtf/PassRefPtr.h"
+#include "bindings/v8/GarbageCollected.h"
+#include "bindings/v8/ScriptValue.h"
+#include "bindings/v8/V8Binding.h"
#include "wtf/RefCounted.h"
-#include "wtf/RefPtr.h"
-#include "wtf/text/WTFString.h"
+#include <v8.h>
namespace WebCore {
-class Node;
-
-class LayerRect : public RefCounted<LayerRect> {
-public:
- static PassRefPtr<LayerRect> create(PassRefPtr<Node> node, const String& layerType, PassRefPtr<ClientRect> rect)
+class ScriptFunction : public GarbageCollected<ScriptFunction> {
+protected:
+ v8::Handle<v8::Function> releaseToV8Function()
{
- return adoptRef(new LayerRect(node, layerType, rect));
+ // FIXME: We need to call v8::Function::EvictFunctionFromCache after
+ // https://codereview.appspot.com/13103043/ lands.
+ return v8::FunctionTemplate::New(&callCallback, releaseToGarbageCollector())->GetFunction();
}
- Node* layerRootNode() const { return m_layerRootNode.get(); }
- String layerType() const { return m_layerType; }
- ClientRect* layerRelativeRect() const { return m_rect.get(); }
-
private:
- LayerRect(PassRefPtr<Node> node, const String& layerName, PassRefPtr<ClientRect> rect)
- : m_layerRootNode(node)
- , m_layerType(layerName)
- , m_rect(rect)
+ virtual ScriptValue call(ScriptValue) = 0;
+
+ static void callCallback(const v8::FunctionCallbackInfo<v8::Value>& args)
{
- }
+ v8::Isolate* isolate = args.GetIsolate();
+ ASSERT(!args.Data().IsEmpty());
+ ScriptFunction* function = ScriptFunction::Cast(args.Data());
+ v8::Local<v8::Value> value = args.Length() > 0 ? args[0] : v8::Local<v8::Value>(v8::Undefined(isolate));
+
+ ScriptValue result = function->call(ScriptValue(value));
- RefPtr<Node> m_layerRootNode;
- String m_layerType;
- RefPtr<ClientRect> m_rect;
+ v8SetReturnValue(args, result.v8Value());
+ }
};
} // namespace WebCore

Powered by Google App Engine
This is Rietveld 408576698