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

Unified Diff: Source/bindings/core/v8/PrivateScriptRunner.cpp

Issue 360703003: Implement Blink-in-JS for DOM methods (Closed) Base URL: svn://svn.chromium.org/blink/trunk
Patch Set: Created 6 years, 6 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/bindings/core/v8/PrivateScriptRunner.h ('k') | Source/bindings/core/v8/PrivateScriptRunner.js » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: Source/bindings/core/v8/PrivateScriptRunner.cpp
diff --git a/Source/bindings/core/v8/PrivateScriptRunner.cpp b/Source/bindings/core/v8/PrivateScriptRunner.cpp
index 65b00f53819b91df7bcfd2d1aba7ea8572d7201d..bf1dc50bed2a4b7972e16ca98c00d7f0808164ec 100644
--- a/Source/bindings/core/v8/PrivateScriptRunner.cpp
+++ b/Source/bindings/core/v8/PrivateScriptRunner.cpp
@@ -9,12 +9,26 @@
#include "bindings/core/v8/V8PerContextData.h"
#include "bindings/core/v8/V8ScriptRunner.h"
#include "core/PrivateScriptSources.h"
+#ifndef NDEBUG
+#include "core/PrivateScriptSourcesForTesting.h"
+#endif
namespace WebCore {
static v8::Handle<v8::Value> compilePrivateScript(v8::Isolate* isolate, String className)
{
size_t index;
+#ifndef NDEBUG
+ for (index = 0; index < WTF_ARRAY_LENGTH(kPrivateScriptSourcesForTesting); index++) {
+ if (className == kPrivateScriptSourcesForTesting[index].name)
+ break;
+ }
+ if (index != WTF_ARRAY_LENGTH(kPrivateScriptSourcesForTesting)) {
+ String source(reinterpret_cast<const char*>(kPrivateScriptSourcesForTesting[index].source), kPrivateScriptSourcesForTesting[index].size);
+ return V8ScriptRunner::compileAndRunInternalScript(v8String(isolate, source), isolate);
+ }
+#endif
+
// |kPrivateScriptSources| is defined in V8PrivateScriptSources.h, which is auto-generated
// by make_private_script.py.
for (index = 0; index < WTF_ARRAY_LENGTH(kPrivateScriptSources); index++) {
@@ -26,7 +40,7 @@ static v8::Handle<v8::Value> compilePrivateScript(v8::Isolate* isolate, String c
return V8ScriptRunner::compileAndRunInternalScript(v8String(isolate, source), isolate);
}
-v8::Handle<v8::Value> PrivateScriptRunner::run(ScriptState* scriptState, String className, String functionName, v8::Handle<v8::Value> receiver, int argc, v8::Handle<v8::Value> argv[])
+static v8::Handle<v8::Value> propertyValue(ScriptState* scriptState, String className, String propertyName)
{
ASSERT(scriptState->perContextData());
ASSERT(scriptState->executionContext());
@@ -47,12 +61,15 @@ v8::Handle<v8::Value> PrivateScriptRunner::run(ScriptState* scriptState, String
RELEASE_ASSERT(compiledClass->IsObject());
scriptState->perContextData()->setCompiledPrivateScript(className, compiledClass);
}
+ return v8::Handle<v8::Object>::Cast(compiledClass)->Get(v8String(isolate, propertyName));
+}
- v8::Handle<v8::Value> function = v8::Handle<v8::Object>::Cast(compiledClass)->Get(v8String(isolate, functionName));
- RELEASE_ASSERT(!function.IsEmpty());
- RELEASE_ASSERT(function->IsFunction());
-
- return V8ScriptRunner::callFunction(v8::Handle<v8::Function>::Cast(function), scriptState->executionContext(), receiver, argc, argv, isolate);
+v8::Handle<v8::Value> PrivateScriptRunner::runDOMMethod(ScriptState* scriptState, String className, String operationName, v8::Handle<v8::Value> holder, int argc, v8::Handle<v8::Value> argv[])
+{
+ v8::Handle<v8::Value> operation = propertyValue(scriptState, className, operationName);
+ RELEASE_ASSERT(!operation.IsEmpty());
+ RELEASE_ASSERT(operation->IsFunction());
+ return V8ScriptRunner::callFunction(v8::Handle<v8::Function>::Cast(operation), scriptState->executionContext(), holder, argc, argv, scriptState->isolate());
}
} // namespace WebCore
« no previous file with comments | « Source/bindings/core/v8/PrivateScriptRunner.h ('k') | Source/bindings/core/v8/PrivateScriptRunner.js » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698