summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authoraa@chromium.org <aa@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2009-03-13 23:26:13 +0000
committeraa@chromium.org <aa@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2009-03-13 23:26:13 +0000
commitbad146c5b3b1a7d0368320fecdbd5b50dbe97501 (patch)
tree8d5aad70f51fcfba24ccebd3359b7d33209370d7
parentccef48cca72fbc8905a643759092ee0d913aca9c (diff)
downloadchromium_src-bad146c5b3b1a7d0368320fecdbd5b50dbe97501.zip
chromium_src-bad146c5b3b1a7d0368320fecdbd5b50dbe97501.tar.gz
chromium_src-bad146c5b3b1a7d0368320fecdbd5b50dbe97501.tar.bz2
Commit 40144. I had to move to to a separate CL to use gcl's
"try multiple commits" feature. Review URL: http://codereview.chromium.org/46062 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@11683 0039d316-1c4b-4281-b951-d872f2087c98
-rw-r--r--DEPS2
-rw-r--r--chrome/renderer/render_view.cc5
-rw-r--r--chrome/renderer/render_view_unittest.cc5
-rw-r--r--chrome/renderer/user_script_slave.cc15
-rw-r--r--webkit/glue/glue.vcproj4
-rw-r--r--webkit/glue/webdevtoolsclient_impl.cc5
-rw-r--r--webkit/glue/webframe.h19
-rw-r--r--webkit/glue/webframe_impl.cc28
-rw-r--r--webkit/glue/webframe_impl.h6
-rw-r--r--webkit/glue/webscriptsource.h29
-rw-r--r--webkit/port/bindings/v8/NPV8Object.cpp2
-rw-r--r--webkit/port/bindings/v8/ScriptController.cpp15
-rw-r--r--webkit/port/bindings/v8/ScriptController.h7
-rw-r--r--webkit/port/bindings/v8/v8_proxy.cpp135
-rw-r--r--webkit/port/bindings/v8/v8_proxy.h16
-rw-r--r--webkit/webkit.gyp1
16 files changed, 209 insertions, 85 deletions
diff --git a/DEPS b/DEPS
index 1a157c5..c26344c 100644
--- a/DEPS
+++ b/DEPS
@@ -19,7 +19,7 @@ deps = {
"http://googletest.googlecode.com/svn/trunk@167",
"src/third_party/WebKit":
- "/trunk/deps/third_party/WebKit@11633",
+ "/trunk/deps/third_party/WebKit@11682",
"src/third_party/icu38":
"/trunk/deps/third_party/icu38@11496",
diff --git a/chrome/renderer/render_view.cc b/chrome/renderer/render_view.cc
index 8e7a45e..50c98ec 100644
--- a/chrome/renderer/render_view.cc
+++ b/chrome/renderer/render_view.cc
@@ -2478,9 +2478,8 @@ void RenderView::EvaluateScript(const std::wstring& frame_xpath,
if (!web_frame)
return;
- web_frame->ExecuteJavaScript(WideToUTF8(script),
- GURL(), // script url
- 1); // base line number
+ web_frame->ExecuteScript(
+ webkit_glue::WebScriptSource(WideToUTF8(script)));
}
void RenderView::OnScriptEvalRequest(const std::wstring& frame_xpath,
diff --git a/chrome/renderer/render_view_unittest.cc b/chrome/renderer/render_view_unittest.cc
index 96d4704..e81cf4f 100644
--- a/chrome/renderer/render_view_unittest.cc
+++ b/chrome/renderer/render_view_unittest.cc
@@ -10,6 +10,7 @@
#include "chrome/renderer/renderer_webkitclient_impl.h"
#include "testing/gtest/include/gtest/gtest.h"
#include "webkit/glue/webframe.h"
+#include "webkit/glue/webscriptsource.h"
#include "webkit/glue/weburlrequest.h"
#include "webkit/glue/webview.h"
@@ -42,9 +43,7 @@ class RenderViewTest : public testing::Test {
// Executes the given JavaScript in the context of the main frame. The input
// is a NULL-terminated UTF-8 string.
void ExecuteJavaScript(const char* js) {
- GetMainFrame()->ExecuteJavaScript(js,
- GURL(), // script url
- 1); // base line number
+ GetMainFrame()->ExecuteScript(webkit_glue::WebScriptSource(js));
}
// Loads the given HTML into the main frame as a data: URL.
diff --git a/chrome/renderer/user_script_slave.cc b/chrome/renderer/user_script_slave.cc
index bc612f0..6362109 100644
--- a/chrome/renderer/user_script_slave.cc
+++ b/chrome/renderer/user_script_slave.cc
@@ -12,6 +12,7 @@
#include "chrome/common/resource_bundle.h"
#include "googleurl/src/gurl.h"
#include "webkit/glue/webframe.h"
+#include "webkit/glue/webscriptsource.h"
#include "grit/renderer_resources.h"
@@ -100,13 +101,13 @@ bool UserScriptSlave::InjectScripts(WebFrame* frame,
script != scripts_.end(); ++script) {
if ((*script)->MatchesUrl(frame->GetURL()) &&
(*script)->run_location() == location) {
- std::string inject(kUserScriptHead);
- inject.append(api_js_.as_string());
- inject.append(script_contents_[*script].as_string());
- inject.append(kUserScriptTail);
- frame->ExecuteJavaScript(inject,
- GURL((*script)->url().spec()),
- -user_script_start_line_);
+ webkit_glue::WebScriptSource sources[] = {
+ webkit_glue::WebScriptSource(api_js_.as_string()),
+ webkit_glue::WebScriptSource(
+ script_contents_[*script].as_string(), (*script)->url())
+ };
+
+ frame->ExecuteScriptInNewContext(sources, arraysize(sources));
++num_matched;
}
}
diff --git a/webkit/glue/glue.vcproj b/webkit/glue/glue.vcproj
index 20bc1f4..08b5246 100644
--- a/webkit/glue/glue.vcproj
+++ b/webkit/glue/glue.vcproj
@@ -705,6 +705,10 @@
>
</File>
<File
+ RelativePath=".\webscriptsource.h"
+ >
+ </File>
+ <File
RelativePath=".\webtextinput_impl.cc"
>
</File>
diff --git a/webkit/glue/webdevtoolsclient_impl.cc b/webkit/glue/webdevtoolsclient_impl.cc
index 647bbfd..dbbe2d8 100644
--- a/webkit/glue/webdevtoolsclient_impl.cc
+++ b/webkit/glue/webdevtoolsclient_impl.cc
@@ -185,10 +185,7 @@ void WebDevToolsClientImpl::JsHideDOMNodeHighlight(const CppArgumentList& args,
}
void WebDevToolsClientImpl::EvaluateJs(const std::string& expr) {
- web_view_impl_->GetMainFrame()->ExecuteJavaScript(
- expr,
- GURL(), // script url
- 1); // base line number
+ web_view_impl_->GetMainFrame()->ExecuteScript(expr);
}
void WebDevToolsClientImpl::DispatchMessageFromAgent(
diff --git a/webkit/glue/webframe.h b/webkit/glue/webframe.h
index 571b281..ce441d6 100644
--- a/webkit/glue/webframe.h
+++ b/webkit/glue/webframe.h
@@ -6,13 +6,14 @@
#define WEBKIT_GLUE_WEBFRAME_H_
#include "base/scoped_ptr.h"
+#include "googleurl/src/gurl.h"
#include "skia/ext/bitmap_platform_device.h"
#include "skia/ext/platform_canvas.h"
#include "webkit/glue/console_message_level.h"
#include "webkit/glue/feed.h"
#include "webkit/glue/find_in_page_request.h"
+#include "webkit/glue/webscriptsource.h"
-class GURL;
class PlatformContextSkia;
class WebDataSource;
class WebError;
@@ -88,13 +89,15 @@ class WebFrame {
bool replace,
const GURL& fake_url) = 0;
- // Executes a string of JavaScript in the web frame. The script_url param is
- // the URL where the script in question can be found, if any. The renderer may
- // request this URL to show the developer the source of the error. The
- // start_line parameter is the base line number to use for error reporting.
- virtual void ExecuteJavaScript(const std::string& js_code,
- const GURL& script_url,
- int start_line) = 0;
+ // Executes JavaScript in the web frame.
+ virtual void ExecuteScript(const webkit_glue::WebScriptSource& source) = 0;
+
+ // Executes JavaScript in a new context associated with the web frame. The
+ // script gets its own global scope and its own prototypes for intrinsic
+ // JavaScript objects (String, Array, and so-on). It shares the wrappers for
+ // all DOM nodes and DOM constructors.
+ virtual void ExecuteScriptInNewContext(
+ const webkit_glue::WebScriptSource* sources, int num_sources) = 0;
// Returns a string representing the state of the previous page load for
// later use when loading. The previous page is the page that was loaded
diff --git a/webkit/glue/webframe_impl.cc b/webkit/glue/webframe_impl.cc
index 62b27a8..16a0bde8 100644
--- a/webkit/glue/webframe_impl.cc
+++ b/webkit/glue/webframe_impl.cc
@@ -1632,14 +1632,26 @@ void WebFrameImpl::LoadAlternateHTMLErrorPage(const WebRequest* request,
error_page_url));
}
-void WebFrameImpl::ExecuteJavaScript(const std::string& js_code,
- const GURL& script_url,
- int start_line) {
- WebCore::ScriptSourceCode source_code(
- webkit_glue::StdStringToString(js_code),
- webkit_glue::GURLToKURL(script_url),
- start_line);
- frame_->loader()->executeScript(source_code);
+void WebFrameImpl::ExecuteScript(const webkit_glue::WebScriptSource& source) {
+ frame_->loader()->executeScript(
+ WebCore::ScriptSourceCode(
+ webkit_glue::StdStringToString(source.source),
+ webkit_glue::GURLToKURL(source.url),
+ source.start_line));
+}
+
+void WebFrameImpl::ExecuteScriptInNewContext(
+ const webkit_glue::WebScriptSource* sources_in, int num_sources) {
+ Vector<WebCore::ScriptSourceCode> sources;
+
+ for (int i = 0; i < num_sources; ++i) {
+ sources.append(WebCore::ScriptSourceCode(
+ webkit_glue::StdStringToString(sources_in[i].source),
+ webkit_glue::GURLToKURL(sources_in[i].url),
+ sources_in[i].start_line));
+ }
+
+ frame_->script()->evaluateInNewContext(sources);
}
std::wstring WebFrameImpl::GetName() {
diff --git a/webkit/glue/webframe_impl.h b/webkit/glue/webframe_impl.h
index e49802f..f448fa3 100644
--- a/webkit/glue/webframe_impl.h
+++ b/webkit/glue/webframe_impl.h
@@ -90,9 +90,9 @@ class WebFrameImpl : public WebFrame, public base::RefCounted<WebFrameImpl> {
const GURL& error_page_url,
bool replace,
const GURL& fake_url);
- virtual void ExecuteJavaScript(const std::string& js_code,
- const GURL& script_url,
- int start_line);
+ virtual void ExecuteScript(const webkit_glue::WebScriptSource& source);
+ virtual void ExecuteScriptInNewContext(
+ const webkit_glue::WebScriptSource* sources, int num_sources);
virtual bool GetPreviousHistoryState(std::string* history_state) const;
virtual bool GetCurrentHistoryState(std::string* history_state) const;
virtual bool HasCurrentHistoryState() const;
diff --git a/webkit/glue/webscriptsource.h b/webkit/glue/webscriptsource.h
new file mode 100644
index 0000000..5f9fd23
--- /dev/null
+++ b/webkit/glue/webscriptsource.h
@@ -0,0 +1,29 @@
+// Copyright (c) 2006-2009 The Chromium Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+#ifndef WEBKIT_GLUE_WEBSCRIPT_SOURCE_H_
+#define WEBKIT_GLUE_WEBSCRIPT_SOURCE_H_
+
+namespace webkit_glue {
+
+// Describes some script that can be executed within a frame.
+// NOTE: start_line is 1-based (like the corresponding object in WebCore).
+// TODO(aa): Allow clients to specify external data intead of strings to avoid
+// copies.
+struct WebScriptSource {
+ WebScriptSource(const std::string& source)
+ : source(source), start_line(1) {}
+ WebScriptSource(const std::string& source, const GURL& url)
+ : source(source), url(url), start_line(1) {}
+ WebScriptSource(const std::string& source, const GURL& url, int start_line)
+ : source(source), url(url), start_line(start_line) {}
+
+ std::string source;
+ GURL url;
+ int start_line;
+};
+
+} // namespace webkit_glue
+
+#endif // WEBKIT_GLUE_WEBSCRIPT_SOURCE_H_
diff --git a/webkit/port/bindings/v8/NPV8Object.cpp b/webkit/port/bindings/v8/NPV8Object.cpp
index 829fd074..411439f 100644
--- a/webkit/port/bindings/v8/NPV8Object.cpp
+++ b/webkit/port/bindings/v8/NPV8Object.cpp
@@ -272,7 +272,7 @@ bool NPN_EvaluateHelper(NPP npp, bool popupsAllowed, NPObject* npobj, NPString*
// Convert UTF-8 stream to WebCore::String.
WebCore::String script = WebCore::String::fromUTF8(npscript->UTF8Characters, npscript->UTF8Length);
- v8::Local<v8::Value> v8result = proxy->Evaluate(filename, 0, script, 0);
+ v8::Local<v8::Value> v8result = proxy->evaluate(WebCore::ScriptSourceCode(script, WebCore::KURL(filename)), 0);
// If we had an error, return false.
if (v8result.IsEmpty())
diff --git a/webkit/port/bindings/v8/ScriptController.cpp b/webkit/port/bindings/v8/ScriptController.cpp
index 9dff0b8..84ad8b4 100644
--- a/webkit/port/bindings/v8/ScriptController.cpp
+++ b/webkit/port/bindings/v8/ScriptController.cpp
@@ -207,6 +207,10 @@ bool ScriptController::processingUserGesture() const
return false;
}
+void ScriptController::evaluateInNewContext(
+ const Vector<ScriptSourceCode>& sources) {
+ m_proxy->evaluateInNewContext(sources);
+}
// Evaluate a script file in the environment of this proxy.
ScriptValue ScriptController::evaluate(const ScriptSourceCode& sourceCode)
@@ -217,14 +221,7 @@ ScriptValue ScriptController::evaluate(const ScriptSourceCode& sourceCode)
return ScriptValue();
v8::Context::Scope scope(context);
-
- // HTMLTokenizer used to use base zero line numbers for scripts, now it
- // uses base 1. This confuses v8, which uses line offsets from the
- // first line.
- v8::Local<v8::Value> obj = m_proxy->Evaluate(sourceCode.url(),
- sourceCode.startLine() - 1,
- sourceCode.source(),
- NULL);
+ v8::Local<v8::Value> obj = m_proxy->evaluate(sourceCode, NULL);
if (obj.IsEmpty() || obj->IsUndefined())
return ScriptValue();
@@ -289,7 +286,7 @@ void ScriptController::collectGarbage()
v8::Context::Scope scope(context);
- m_proxy->Evaluate("", 0, "if (window.gc) void(gc());", NULL);
+ m_proxy->evaluate(ScriptSourceCode("if (window.gc) void(gc());"), NULL);
}
NPRuntimeFunctions* ScriptController::functions()
diff --git a/webkit/port/bindings/v8/ScriptController.h b/webkit/port/bindings/v8/ScriptController.h
index 1d580fe..e1e9e25 100644
--- a/webkit/port/bindings/v8/ScriptController.h
+++ b/webkit/port/bindings/v8/ScriptController.h
@@ -42,6 +42,7 @@
#include "bindings/npruntime.h"
#include <wtf/HashMap.h>
+#include <wtf/Vector.h>
#include "v8.h"
#include "v8_proxy.h"
@@ -151,6 +152,12 @@ public:
// as a string.
ScriptValue evaluate(const ScriptSourceCode&);
+ // Executes JavaScript in a new context associated with the web frame. The
+ // script gets its own global scope and its own prototypes for intrinsic
+ // JavaScript objects (String, Array, and so-on). It shares the wrappers for
+ // all DOM nodes and DOM constructors.
+ void evaluateInNewContext(const Vector<ScriptSourceCode>& sources);
+
// JSC has a WindowShell object, but for V8, the ScriptController
// is the WindowShell.
bool haveWindowShell() const { return true; }
diff --git a/webkit/port/bindings/v8/v8_proxy.cpp b/webkit/port/bindings/v8/v8_proxy.cpp
index 3ad7143..2725b99 100644
--- a/webkit/port/bindings/v8/v8_proxy.cpp
+++ b/webkit/port/bindings/v8/v8_proxy.cpp
@@ -42,6 +42,7 @@
#include "v8_custom.h"
#include "v8_collection.h"
#include "v8_nodefilter.h"
+#include "V8DOMWindow.h"
#include "ChromiumBridge.h"
@@ -1356,20 +1357,60 @@ bool V8Proxy::HandleOutOfMemory()
return true;
}
-v8::Local<v8::Value> V8Proxy::Evaluate(const String& fileName, int baseLine,
- const String& str, Node* n)
+void V8Proxy::evaluateInNewContext(const Vector<ScriptSourceCode>& sources)
+{
+ InitContextIfNeeded();
+
+ v8::HandleScope handleScope;
+
+ // Set up the DOM window as the prototype of the new global object.
+ v8::Handle<v8::Context> windowContext = m_context;
+ v8::Handle<v8::Object> windowGlobal = windowContext->Global();
+ v8::Handle<v8::Value> windowWrapper =
+ V8Proxy::LookupDOMWrapper(V8ClassIndex::DOMWINDOW, windowGlobal);
+
+ ASSERT(V8Proxy::DOMWrapperToNative<DOMWindow>(windowWrapper) ==
+ m_frame->domWindow());
+
+ v8::Persistent<v8::Context> context =
+ createNewContext(v8::Handle<v8::Object>());
+ v8::Context::Scope context_scope(context);
+ v8::Handle<v8::Object> global = context->Global();
+
+ v8::Handle<v8::String> implicitProtoString = v8::String::New("__proto__");
+ global->Set(implicitProtoString, windowWrapper);
+
+ // Give the code running in the new context a way to get access to the
+ // original context.
+ global->Set(v8::String::New("contentWindow"), windowGlobal);
+
+ // Run code in the new context.
+ for (size_t i = 0; i < sources.size(); ++i)
+ evaluate(sources[i], 0);
+
+ // Using the default security token means that the canAccess is always
+ // called, which is slow.
+ // TODO(aa): Use tokens where possible. This will mean keeping track of all
+ // created contexts so that they can all be updated when the document domain
+ // changes.
+ context->UseDefaultSecurityToken();
+ context.Dispose();
+}
+
+v8::Local<v8::Value> V8Proxy::evaluate(const ScriptSourceCode& source, Node* n)
{
ASSERT(v8::Context::InContext());
// Compile the script.
- v8::Local<v8::String> code = v8ExternalString(str);
+ v8::Local<v8::String> code = v8ExternalString(source.source());
ChromiumBridge::traceEventBegin("v8.compile", n, "");
- v8::Handle<v8::Script> script = CompileScript(code, fileName, baseLine);
+
+ // NOTE: For compatibility with WebCore, ScriptSourceCode's line starts at
+ // 1, whereas v8 starts at 0.
+ v8::Handle<v8::Script> script = CompileScript(code, source.url(),
+ source.startLine() - 1);
ChromiumBridge::traceEventEnd("v8.compile", n, "");
- // Set inlineCode to true for <a href="javascript:doSomething()">
- // and false for <script>doSomething</script>. For some reason, fileName
- // gives us this information.
ChromiumBridge::traceEventBegin("v8.run", n, "");
v8::Local<v8::Value> result;
{
@@ -1378,7 +1419,11 @@ v8::Local<v8::Value> V8Proxy::Evaluate(const String& fileName, int baseLine,
// evaluate from C++ when returning from here
v8::TryCatch try_catch;
try_catch.SetVerbose(true);
- result = RunScript(script, fileName.isNull());
+
+ // Set inlineCode to true for <a href="javascript:doSomething()">
+ // and false for <script>doSomething</script>. We make a rough guess at
+ // this based on whether the script source has a URL.
+ result = RunScript(script, source.url().string().isNull());
}
ChromiumBridge::traceEventEnd("v8.run", n, "");
return result;
@@ -2255,6 +2300,39 @@ bool V8Proxy::CheckNodeSecurity(Node* node)
return CanAccessFrame(target, true);
}
+v8::Persistent<v8::Context> V8Proxy::createNewContext(
+ v8::Handle<v8::Object> global)
+{
+ v8::Persistent<v8::Context> result;
+
+ // Create a new environment using an empty template for the shadow
+ // object. Reuse the global object if one has been created earlier.
+ v8::Persistent<v8::ObjectTemplate> globalTemplate =
+ V8DOMWindow::GetShadowObjectTemplate();
+ if (globalTemplate.IsEmpty())
+ return result;
+
+ // Install a security handler with V8.
+ globalTemplate->SetAccessCheckCallbacks(
+ V8Custom::v8DOMWindowNamedSecurityCheck,
+ V8Custom::v8DOMWindowIndexedSecurityCheck,
+ v8::Integer::New(V8ClassIndex::DOMWINDOW));
+
+ // Dynamically tell v8 about our extensions now.
+ const char** extensionNames = new const char*[m_extensions.size()];
+ int index = 0;
+ V8ExtensionList::iterator it = m_extensions.begin();
+ while (it != m_extensions.end()) {
+ extensionNames[index++] = (*it)->name();
+ ++it;
+ }
+ v8::ExtensionConfiguration extensions(m_extensions.size(), extensionNames);
+ result = v8::Context::New(&extensions, globalTemplate, global);
+ delete [] extensionNames;
+ extensionNames = 0;
+
+ return result;
+}
// Create a new environment and setup the global object.
//
@@ -2316,32 +2394,7 @@ void V8Proxy::InitContextIfNeeded()
v8_initialized = true;
}
- // Create a new environment using an empty template for the shadow
- // object. Reuse the global object if one has been created earlier.
- v8::Persistent<v8::ObjectTemplate> global_template =
- V8DOMWindow::GetShadowObjectTemplate();
- if (global_template.IsEmpty())
- return;
-
- // Install a security handler with V8.
- global_template->SetAccessCheckCallbacks(
- V8Custom::v8DOMWindowNamedSecurityCheck,
- V8Custom::v8DOMWindowIndexedSecurityCheck,
- v8::Integer::New(V8ClassIndex::DOMWINDOW));
-
- // Dynamically tell v8 about our extensions now.
- const char** extension_names = new const char*[m_extensions.size()];
- int index = 0;
- V8ExtensionList::iterator it = m_extensions.begin();
- while (it != m_extensions.end()) {
- extension_names[index++] = (*it)->name();
- ++it;
- }
- v8::ExtensionConfiguration extensions(m_extensions.size(), extension_names);
- m_context = v8::Context::New(&extensions, global_template, m_global);
- delete [] extension_names;
- extension_names = 0;
-
+ m_context = createNewContext(m_global);
if (m_context.IsEmpty())
return;
@@ -3409,6 +3462,20 @@ v8::Handle<v8::Value> V8Proxy::WindowToV8Object(DOMWindow* window)
if (!frame)
return v8::Handle<v8::Object>();
+ // Special case: Because of evaluateInNewContext() one DOMWindow can have
+ // multipe contexts and multiple global objects associated with it. When
+ // code running in one of those contexts accesses the window object, we
+ // want to return the global object associated with that context, not
+ // necessarily the first global object associated with that DOMWindow.
+ v8::Handle<v8::Context> current_context = v8::Context::GetCurrent();
+ v8::Handle<v8::Object> current_global = current_context->Global();
+ v8::Handle<v8::Object> windowWrapper =
+ LookupDOMWrapper(V8ClassIndex::DOMWINDOW, current_global);
+ if (!windowWrapper.IsEmpty())
+ if (DOMWrapperToNative<DOMWindow>(windowWrapper) == window)
+ return current_global;
+
+ // Otherwise, return the global object associated with this frame.
v8::Handle<v8::Context> context = GetContext(frame);
if (context.IsEmpty())
return v8::Handle<v8::Object>();
diff --git a/webkit/port/bindings/v8/v8_proxy.h b/webkit/port/bindings/v8/v8_proxy.h
index 69747b5..cb0e433 100644
--- a/webkit/port/bindings/v8/v8_proxy.h
+++ b/webkit/port/bindings/v8/v8_proxy.h
@@ -13,10 +13,12 @@
#include "ChromiumBridge.h"
#include "Node.h"
#include "NodeFilter.h"
-#include "SecurityOrigin.h" // for WebCore::SecurityOrigin
#include "PlatformString.h" // for WebCore::String
-#include <wtf/PassRefPtr.h> // so generated bindings don't have to
+#include "ScriptSourceCode.h" // for WebCore::ScriptSourceCode
+#include "SecurityOrigin.h" // for WebCore::SecurityOrigin
#include <wtf/Assertions.h>
+#include <wtf/PassRefPtr.h> // so generated bindings don't have to
+#include <wtf/Vector.h>
#include <iterator>
#include <list>
@@ -230,11 +232,16 @@ class V8Proxy {
void setEventHandlerLineno(int lineno) { m_handlerLineno = lineno; }
void finishedWithEvent(Event* event) { }
+ // Evaluate JavaScript in a new context. The script gets its own global scope
+ // and its own prototypes for intrinsic JavaScript objects (String, Array,
+ // and so-on). It shares the wrappers for all DOM nodes and DOM constructors.
+ void evaluateInNewContext(const Vector<ScriptSourceCode>& sources);
+
// Evaluate a script file in the current execution environment.
// The caller must hold an execution context.
// If cannot evalute the script, it returns an error.
- v8::Local<v8::Value> Evaluate(const String& filename, int baseLine,
- const String& code, Node* node);
+ v8::Local<v8::Value> evaluate(const ScriptSourceCode& source,
+ Node* node);
// Run an already compiled script.
v8::Local<v8::Value> RunScript(v8::Handle<v8::Script> script,
@@ -445,6 +452,7 @@ class V8Proxy {
static void RegisterExtension(v8::Extension* extension);
private:
+ v8::Persistent<v8::Context> createNewContext(v8::Handle<v8::Object> global);
void InitContextIfNeeded();
void DisconnectEventListeners();
void SetSecurityToken();
diff --git a/webkit/webkit.gyp b/webkit/webkit.gyp
index 5aff133..60775bb 100644
--- a/webkit/webkit.gyp
+++ b/webkit/webkit.gyp
@@ -4381,6 +4381,7 @@
'glue/webplugin_impl.cc',
'glue/webplugin_impl.h',
'glue/webpreferences.h',
+ 'glue/webscriptsource.h',
'glue/webresponse.h',
'glue/webresponse_impl.h',
'glue/webtextinput.h',