| Index: Source/web/WebLocalFrameImpl.cpp
|
| diff --git a/Source/web/WebLocalFrameImpl.cpp b/Source/web/WebLocalFrameImpl.cpp
|
| index a4b6bf98c91f95aff7373f6899df13992026a770..681463b96fe9abe6928d5f5abbf99d8aaecaa9e6 100644
|
| --- a/Source/web/WebLocalFrameImpl.cpp
|
| +++ b/Source/web/WebLocalFrameImpl.cpp
|
| @@ -100,6 +100,7 @@
|
| #include "core/dom/MessagePort.h"
|
| #include "core/dom/Node.h"
|
| #include "core/dom/NodeTraversal.h"
|
| +#include "core/dom/SuspendableScriptRunner.h"
|
| #include "core/dom/shadow/ShadowRoot.h"
|
| #include "core/editing/Editor.h"
|
| #include "core/editing/FrameSelection.h"
|
| @@ -296,6 +297,16 @@ WebPluginContainerImpl* WebLocalFrameImpl::pluginContainerFromNode(LocalFrame* f
|
| return toWebPluginContainerImpl(node.pluginContainer());
|
| }
|
|
|
| +Vector<ScriptSourceCode> WebLocalFrameImpl::createSourcesVector(const WebScriptSource* sourcesIn, unsigned numSources)
|
| +{
|
| + Vector<ScriptSourceCode> sources;
|
| + for (unsigned i = 0; i < numSources; ++i) {
|
| + TextPosition position(OrdinalNumber::fromOneBasedInt(sourcesIn[i].startLine), OrdinalNumber::first());
|
| + sources.append(ScriptSourceCode(sourcesIn[i].code, sourcesIn[i].url, position));
|
| + }
|
| + return sources;
|
| +}
|
| +
|
| // Simple class to override some of PrintContext behavior. Some of the methods
|
| // made virtual so that they can be overridden by ChromePluginPrintContext.
|
| class ChromePrintContext : public PrintContext {
|
| @@ -706,12 +717,7 @@ void WebLocalFrameImpl::executeScriptInIsolatedWorld(int worldID, const WebScrip
|
| RELEASE_ASSERT(worldID > 0);
|
| RELEASE_ASSERT(worldID < EmbedderWorldIdLimit);
|
|
|
| - Vector<ScriptSourceCode> sources;
|
| - for (unsigned i = 0; i < numSources; ++i) {
|
| - TextPosition position(OrdinalNumber::fromOneBasedInt(sourcesIn[i].startLine), OrdinalNumber::first());
|
| - sources.append(ScriptSourceCode(sourcesIn[i].code, sourcesIn[i].url, position));
|
| - }
|
| -
|
| + Vector<ScriptSourceCode> sources = createSourcesVector(sourcesIn, numSources);
|
| v8::HandleScope handleScope(toIsolate(frame()));
|
| frame()->script().executeScriptInIsolatedWorld(worldID, sources, extensionGroup, 0);
|
| }
|
| @@ -783,18 +789,22 @@ v8::Handle<v8::Value> WebLocalFrameImpl::executeScriptAndReturnValue(const WebSc
|
| return frame()->script().executeScriptInMainWorldAndReturnValue(ScriptSourceCode(source.code, source.url, position));
|
| }
|
|
|
| +void WebLocalFrameImpl::asyncExecuteScriptAndReturnValue(const WebScriptSource& sourceIn, WebScriptCallback* callback)
|
| +{
|
| + ASSERT(frame());
|
| +
|
| + Vector<ScriptSourceCode> sources = createSourcesVector(&sourceIn, 1);
|
| + SuspendableScriptRunner* runner = new SuspendableScriptRunner(frame(), 0, sources, 0, callback);
|
| + runner->run();
|
| +}
|
| +
|
| void WebLocalFrameImpl::executeScriptInIsolatedWorld(int worldID, const WebScriptSource* sourcesIn, unsigned numSources, int extensionGroup, WebVector<v8::Local<v8::Value> >* results)
|
| {
|
| ASSERT(frame());
|
| RELEASE_ASSERT(worldID > 0);
|
| RELEASE_ASSERT(worldID < EmbedderWorldIdLimit);
|
|
|
| - Vector<ScriptSourceCode> sources;
|
| -
|
| - for (unsigned i = 0; i < numSources; ++i) {
|
| - TextPosition position(OrdinalNumber::fromOneBasedInt(sourcesIn[i].startLine), OrdinalNumber::first());
|
| - sources.append(ScriptSourceCode(sourcesIn[i].code, sourcesIn[i].url, position));
|
| - }
|
| + Vector<ScriptSourceCode> sources = createSourcesVector(sourcesIn, numSources);
|
|
|
| if (results) {
|
| Vector<v8::Local<v8::Value> > scriptResults;
|
| @@ -809,6 +819,17 @@ void WebLocalFrameImpl::executeScriptInIsolatedWorld(int worldID, const WebScrip
|
| }
|
| }
|
|
|
| +void WebLocalFrameImpl::asyncExecuteScriptInIsolatedWorld(int worldID, const WebScriptSource* sourcesIn, unsigned numSources, int extensionGroup, WebScriptCallback* callback)
|
| +{
|
| + ASSERT(frame());
|
| + RELEASE_ASSERT(worldID > 0);
|
| + RELEASE_ASSERT(worldID < EmbedderWorldIdLimit);
|
| +
|
| + Vector<ScriptSourceCode> sources = createSourcesVector(sourcesIn, numSources);
|
| + SuspendableScriptRunner* runner = new SuspendableScriptRunner(frame(), worldID, sources, extensionGroup, callback);
|
| + runner->run();
|
| +}
|
| +
|
| v8::Handle<v8::Value> WebLocalFrameImpl::callFunctionEvenIfScriptDisabled(v8::Handle<v8::Function> function, v8::Handle<v8::Value> receiver, int argc, v8::Handle<v8::Value> argv[])
|
| {
|
| ASSERT(frame());
|
|
|