Merge from Chromium at DEPS revision 228962
This commit was generated by merge_to_master.py.
Change-Id: Ifa868e6d63fe87d2338d9388aa5ea81f746d485f
diff --git a/Source/bindings/v8/ActiveDOMCallback.cpp b/Source/bindings/v8/ActiveDOMCallback.cpp
index 2829a06..0231dad 100644
--- a/Source/bindings/v8/ActiveDOMCallback.cpp
+++ b/Source/bindings/v8/ActiveDOMCallback.cpp
@@ -32,12 +32,12 @@
#include "bindings/v8/ActiveDOMCallback.h"
#include "core/dom/ActiveDOMObject.h"
-#include "core/dom/ScriptExecutionContext.h"
+#include "core/dom/ExecutionContext.h"
#include "core/workers/WorkerGlobalScope.h"
namespace WebCore {
-ActiveDOMCallback::ActiveDOMCallback(ScriptExecutionContext* context)
+ActiveDOMCallback::ActiveDOMCallback(ExecutionContext* context)
: ContextLifecycleObserver(context)
{
}
@@ -48,13 +48,13 @@
bool ActiveDOMCallback::canInvokeCallback() const
{
- ScriptExecutionContext* context = scriptExecutionContext();
+ ExecutionContext* context = executionContext();
return context && !context->activeDOMObjectsAreSuspended() && !context->activeDOMObjectsAreStopped();
}
bool ActiveDOMCallback::isScriptControllerTerminating() const
{
- ScriptExecutionContext* context = scriptExecutionContext();
+ ExecutionContext* context = executionContext();
if (context && context->isWorkerGlobalScope()) {
WorkerScriptController* scriptController = toWorkerGlobalScope(context)->script();
if (!scriptController || scriptController->isExecutionForbidden() || scriptController->isExecutionTerminating())
diff --git a/Source/bindings/v8/ActiveDOMCallback.h b/Source/bindings/v8/ActiveDOMCallback.h
index 2015ddd..a503487 100644
--- a/Source/bindings/v8/ActiveDOMCallback.h
+++ b/Source/bindings/v8/ActiveDOMCallback.h
@@ -36,7 +36,7 @@
namespace WebCore {
-class ScriptExecutionContext;
+class ExecutionContext;
// A base class that prevents binding callbacks from executing when
// active dom objects are stopped or suspended, and is used by the
@@ -47,7 +47,7 @@
// context thread.
class ActiveDOMCallback : public ContextLifecycleObserver {
public:
- ActiveDOMCallback(ScriptExecutionContext* context);
+ explicit ActiveDOMCallback(ExecutionContext*);
virtual ~ActiveDOMCallback();
bool canInvokeCallback() const;
diff --git a/Source/bindings/v8/BindingSecurity.cpp b/Source/bindings/v8/BindingSecurity.cpp
index 56eb47d..dd8b46b 100644
--- a/Source/bindings/v8/BindingSecurity.cpp
+++ b/Source/bindings/v8/BindingSecurity.cpp
@@ -34,8 +34,8 @@
#include "bindings/v8/V8Binding.h"
#include "core/dom/Document.h"
#include "core/html/HTMLFrameElementBase.h"
-#include "core/page/DOMWindow.h"
-#include "core/page/Frame.h"
+#include "core/frame/DOMWindow.h"
+#include "core/frame/Frame.h"
#include "core/page/Settings.h"
#include "weborigin/SecurityOrigin.h"
@@ -89,9 +89,9 @@
return target && canAccessDocument(target->document(), es);
}
-bool BindingSecurity::shouldAllowAccessToNode(Node* target)
+bool BindingSecurity::shouldAllowAccessToNode(Node* target, ExceptionState& es)
{
- return target && canAccessDocument(&target->document());
+ return target && canAccessDocument(&target->document(), es);
}
}
diff --git a/Source/bindings/v8/BindingSecurity.h b/Source/bindings/v8/BindingSecurity.h
index 8fba900..253a7f2 100644
--- a/Source/bindings/v8/BindingSecurity.h
+++ b/Source/bindings/v8/BindingSecurity.h
@@ -47,7 +47,7 @@
class BindingSecurity {
public:
- static bool shouldAllowAccessToNode(Node*);
+ static bool shouldAllowAccessToNode(Node*, ExceptionState&);
static bool shouldAllowAccessToFrame(Frame*, SecurityReportingOption = ReportSecurityError);
static bool shouldAllowAccessToFrame(Frame*, ExceptionState&);
};
diff --git a/Source/bindings/v8/CustomElementConstructorBuilder.cpp b/Source/bindings/v8/CustomElementConstructorBuilder.cpp
index 7aba519..68e6ce6 100644
--- a/Source/bindings/v8/CustomElementConstructorBuilder.cpp
+++ b/Source/bindings/v8/CustomElementConstructorBuilder.cpp
@@ -44,11 +44,11 @@
#include "bindings/v8/V8Binding.h"
#include "bindings/v8/V8HiddenPropertyName.h"
#include "bindings/v8/V8PerContextData.h"
-#include "core/dom/CustomElementCallbackDispatcher.h"
-#include "core/dom/CustomElementDefinition.h"
-#include "core/dom/CustomElementDescriptor.h"
-#include "core/dom/CustomElementException.h"
#include "core/dom/Document.h"
+#include "core/dom/custom/CustomElementCallbackDispatcher.h"
+#include "core/dom/custom/CustomElementDefinition.h"
+#include "core/dom/custom/CustomElementDescriptor.h"
+#include "core/dom/custom/CustomElementException.h"
#include "wtf/Assertions.h"
namespace WebCore {
@@ -133,7 +133,7 @@
{
ASSERT(!m_prototype.IsEmpty());
- RefPtr<ScriptExecutionContext> scriptExecutionContext(toScriptExecutionContext(m_context));
+ RefPtr<ExecutionContext> executionContext(toExecutionContext(m_context));
v8::TryCatch exceptionCatcher;
exceptionCatcher.SetVerbose(true);
@@ -144,7 +144,7 @@
v8::Handle<v8::Function> leftView = retrieveCallback(isolate, "leftViewCallback");
v8::Handle<v8::Function> attributeChanged = retrieveCallback(isolate, "attributeChangedCallback");
- m_callbacks = V8CustomElementLifecycleCallbacks::create(scriptExecutionContext.get(), m_prototype, created, enteredView, leftView, attributeChanged);
+ m_callbacks = V8CustomElementLifecycleCallbacks::create(executionContext.get(), m_prototype, created, enteredView, leftView, attributeChanged);
return m_callbacks.get();
}
diff --git a/Source/bindings/v8/CustomElementConstructorBuilder.h b/Source/bindings/v8/CustomElementConstructorBuilder.h
index 705da91..2ea39e2 100644
--- a/Source/bindings/v8/CustomElementConstructorBuilder.h
+++ b/Source/bindings/v8/CustomElementConstructorBuilder.h
@@ -33,8 +33,8 @@
#include "bindings/v8/ScriptValue.h"
#include "bindings/v8/V8CustomElementLifecycleCallbacks.h"
-#include "core/dom/CustomElementLifecycleCallbacks.h"
#include "core/dom/QualifiedName.h"
+#include "core/dom/custom/CustomElementLifecycleCallbacks.h"
#include "wtf/Noncopyable.h"
#include "wtf/PassRefPtr.h"
#include "wtf/RefPtr.h"
diff --git a/Source/bindings/v8/CustomElementWrapper.cpp b/Source/bindings/v8/CustomElementWrapper.cpp
index eda77f5..128c1e4 100644
--- a/Source/bindings/v8/CustomElementWrapper.cpp
+++ b/Source/bindings/v8/CustomElementWrapper.cpp
@@ -38,7 +38,7 @@
#include "bindings/v8/DOMDataStore.h"
#include "bindings/v8/DOMWrapperWorld.h"
#include "bindings/v8/V8PerContextData.h"
-#include "core/dom/CustomElement.h"
+#include "core/dom/custom/CustomElement.h"
#include "core/html/HTMLElement.h"
#include "core/html/HTMLUnknownElement.h"
#include "core/svg/SVGElement.h"
diff --git a/Source/bindings/v8/DOMRequestState.h b/Source/bindings/v8/DOMRequestState.h
index 0e06ee4..8942218 100644
--- a/Source/bindings/v8/DOMRequestState.h
+++ b/Source/bindings/v8/DOMRequestState.h
@@ -28,7 +28,7 @@
#include "bindings/v8/DOMWrapperWorld.h"
#include "bindings/v8/V8Binding.h"
-#include "core/dom/ScriptExecutionContext.h"
+#include "core/dom/ExecutionContext.h"
#include "v8.h"
#include "wtf/RefPtr.h"
@@ -36,16 +36,16 @@
class DOMRequestState {
public:
- explicit DOMRequestState(ScriptExecutionContext* scriptExecutionContext)
- : m_scriptExecutionContext(scriptExecutionContext)
+ explicit DOMRequestState(ExecutionContext* executionContext)
+ : m_executionContext(executionContext)
, m_world(DOMWrapperWorld::current())
- , m_isolate(toIsolate(scriptExecutionContext))
+ , m_isolate(toIsolate(executionContext))
{
}
void clear()
{
- m_scriptExecutionContext = 0;
+ m_executionContext = 0;
m_world.clear();
}
@@ -63,7 +63,7 @@
v8::Local<v8::Context> context()
{
- return toV8Context(m_scriptExecutionContext, m_world.get());
+ return toV8Context(m_executionContext, m_world.get());
}
v8::Isolate* isolate() const
@@ -72,7 +72,7 @@
}
private:
- ScriptExecutionContext* m_scriptExecutionContext;
+ ExecutionContext* m_executionContext;
RefPtr<DOMWrapperWorld> m_world;
v8::Isolate* m_isolate;
};
diff --git a/Source/bindings/v8/DOMWrapperWorld.cpp b/Source/bindings/v8/DOMWrapperWorld.cpp
index 317ad2b..19b75c8 100644
--- a/Source/bindings/v8/DOMWrapperWorld.cpp
+++ b/Source/bindings/v8/DOMWrapperWorld.cpp
@@ -39,7 +39,7 @@
#include "bindings/v8/V8DOMWrapper.h"
#include "bindings/v8/V8WindowShell.h"
#include "bindings/v8/WrapperTypeInfo.h"
-#include "core/dom/ScriptExecutionContext.h"
+#include "core/dom/ExecutionContext.h"
#include "wtf/HashTraits.h"
#include "wtf/MainThread.h"
#include "wtf/StdLibExtras.h"
diff --git a/Source/bindings/v8/DOMWrapperWorld.h b/Source/bindings/v8/DOMWrapperWorld.h
index 75fa2b2..b07fcb3 100644
--- a/Source/bindings/v8/DOMWrapperWorld.h
+++ b/Source/bindings/v8/DOMWrapperWorld.h
@@ -44,7 +44,7 @@
class DOMDataStore;
class ScriptController;
-class ScriptExecutionContext;
+class ExecutionContext;
enum WorldIdConstants {
MainWorldId = 0,
diff --git a/Source/bindings/v8/DateExtension.cpp b/Source/bindings/v8/DateExtension.cpp
index ebf203c..de69ddf 100644
--- a/Source/bindings/v8/DateExtension.cpp
+++ b/Source/bindings/v8/DateExtension.cpp
@@ -31,6 +31,7 @@
#include "config.h"
#include "bindings/v8/DateExtension.h"
+#include "RuntimeEnabledFeatures.h"
#include "bindings/v8/V8Binding.h"
#include "bindings/v8/V8HiddenPropertyName.h"
#include "bindings/v8/V8ScriptRunner.h"
@@ -69,6 +70,8 @@
DateExtension* DateExtension::get()
{
+ if (!RuntimeEnabledFeatures::dateExtensionEnabled())
+ return 0;
if (!extension)
extension = new DateExtension();
return extension;
diff --git a/Source/bindings/v8/DebuggerScript.js b/Source/bindings/v8/DebuggerScript.js
index ccea7e0..e2a1419 100644
--- a/Source/bindings/v8/DebuggerScript.js
+++ b/Source/bindings/v8/DebuggerScript.js
@@ -223,9 +223,10 @@
execState.prepareStep(Debug.StepAction.StepNext, 1, frameMirror);
}
-DebuggerScript.stepOutOfFunction = function(execState)
+DebuggerScript.stepOutOfFunction = function(execState, callFrame)
{
- execState.prepareStep(Debug.StepAction.StepOut, 1);
+ var frameMirror = callFrame ? callFrame.frameMirror : undefined;
+ execState.prepareStep(Debug.StepAction.StepOut, 1, frameMirror);
}
// Returns array in form:
diff --git a/Source/bindings/v8/Dictionary.cpp b/Source/bindings/v8/Dictionary.cpp
index 7ca45ec..72776e6 100644
--- a/Source/bindings/v8/Dictionary.cpp
+++ b/Source/bindings/v8/Dictionary.cpp
@@ -545,7 +545,7 @@
if (!v8Value->IsFunction())
return false;
- value = V8VoidCallback::create(v8Value, getScriptExecutionContext());
+ value = V8VoidCallback::create(v8Value, getExecutionContext());
return true;
}
diff --git a/Source/bindings/v8/ExceptionState.cpp b/Source/bindings/v8/ExceptionState.cpp
index ad0e663..ae086ac 100644
--- a/Source/bindings/v8/ExceptionState.cpp
+++ b/Source/bindings/v8/ExceptionState.cpp
@@ -46,6 +46,10 @@
{
ASSERT(ec);
ASSERT(m_isolate);
+
+ // SecurityError is thrown via ::throwSecurityError, and _careful_ consideration must be given to the data exposed to JavaScript via the 'sanitizedMessage'.
+ ASSERT(ec != SecurityError);
+
m_code = ec;
setException(V8ThrowException::createDOMException(ec, message, m_isolate));
}
diff --git a/Source/bindings/v8/IDBBindingUtilities.cpp b/Source/bindings/v8/IDBBindingUtilities.cpp
index cf88171..0dd4195 100644
--- a/Source/bindings/v8/IDBBindingUtilities.cpp
+++ b/Source/bindings/v8/IDBBindingUtilities.cpp
@@ -30,7 +30,7 @@
#include "bindings/v8/DOMRequestState.h"
#include "bindings/v8/SerializedScriptValue.h"
#include "bindings/v8/V8Binding.h"
-#include "core/platform/SharedBuffer.h"
+#include "platform/SharedBuffer.h"
#include "modules/indexeddb/IDBKey.h"
#include "modules/indexeddb/IDBKeyPath.h"
#include "modules/indexeddb/IDBKeyRange.h"
diff --git a/Source/bindings/v8/NPV8Object.cpp b/Source/bindings/v8/NPV8Object.cpp
index ef02215..4923df7 100644
--- a/Source/bindings/v8/NPV8Object.cpp
+++ b/Source/bindings/v8/NPV8Object.cpp
@@ -38,10 +38,10 @@
#include "bindings/v8/WrapperTypeInfo.h"
#include "bindings/v8/npruntime_impl.h"
#include "bindings/v8/npruntime_priv.h"
-#include "core/dom/UserGestureIndicator.h"
-#include "core/page/DOMWindow.h"
-#include "core/page/Frame.h"
-#include "wtf/OwnArrayPtr.h"
+#include "core/frame/DOMWindow.h"
+#include "core/frame/Frame.h"
+#include "platform/UserGestureIndicator.h"
+#include "wtf/OwnPtr.h"
#include <stdio.h>
#include "wtf/StringExtras.h"
@@ -87,9 +87,9 @@
return ScriptController::mainWorldContext(object->rootObject->frame());
}
-static PassOwnArrayPtr<v8::Handle<v8::Value> > createValueListFromVariantArgs(const NPVariant* arguments, uint32_t argumentCount, NPObject* owner, v8::Isolate* isolate)
+static PassOwnPtr<v8::Handle<v8::Value>[]> createValueListFromVariantArgs(const NPVariant* arguments, uint32_t argumentCount, NPObject* owner, v8::Isolate* isolate)
{
- OwnArrayPtr<v8::Handle<v8::Value> > argv = adoptArrayPtr(new v8::Handle<v8::Value>[argumentCount]);
+ OwnPtr<v8::Handle<v8::Value>[]> argv = adoptArrayPtr(new v8::Handle<v8::Value>[argumentCount]);
for (uint32_t index = 0; index < argumentCount; index++) {
const NPVariant* arg = &arguments[index];
argv[index] = convertNPVariantToV8Object(arg, owner, isolate);
@@ -256,7 +256,7 @@
// Call the function object.
v8::Handle<v8::Function> function = v8::Handle<v8::Function>::Cast(functionObject);
- OwnArrayPtr<v8::Handle<v8::Value> > argv = createValueListFromVariantArgs(arguments, argumentCount, npObject, isolate);
+ OwnPtr<v8::Handle<v8::Value>[]> argv = createValueListFromVariantArgs(arguments, argumentCount, npObject, isolate);
v8::Local<v8::Value> resultObject = frame->script()->callFunction(function, v8Object, argumentCount, argv.get());
// If we had an error, return false. The spec is a little unclear here, but says "Returns true if the method was
@@ -306,7 +306,7 @@
Frame* frame = v8NpObject->rootObject->frame();
ASSERT(frame);
- OwnArrayPtr<v8::Handle<v8::Value> > argv = createValueListFromVariantArgs(arguments, argumentCount, npObject, isolate);
+ OwnPtr<v8::Handle<v8::Value>[]> argv = createValueListFromVariantArgs(arguments, argumentCount, npObject, isolate);
resultObject = frame->script()->callFunction(function, functionObject, argumentCount, argv.get());
}
// If we had an error, return false. The spec is a little unclear here, but says "Returns true if the method was
@@ -355,7 +355,7 @@
String script = String::fromUTF8(npScript->UTF8Characters, npScript->UTF8Length);
UserGestureIndicator gestureIndicator(popupsAllowed ? DefinitelyProcessingNewUserGesture : PossiblyProcessingUserGesture);
- v8::Local<v8::Value> v8result = frame->script()->compileAndRunScript(ScriptSourceCode(script, KURL(ParsedURLString, filename)));
+ v8::Local<v8::Value> v8result = frame->script()->executeScriptAndReturnValue(context, ScriptSourceCode(script, KURL(ParsedURLString, filename)));
if (v8result.IsEmpty())
return false;
@@ -596,7 +596,7 @@
if (!ctor->IsNull()) {
Frame* frame = object->rootObject->frame();
ASSERT(frame);
- OwnArrayPtr<v8::Handle<v8::Value> > argv = createValueListFromVariantArgs(arguments, argumentCount, npObject, isolate);
+ OwnPtr<v8::Handle<v8::Value>[]> argv = createValueListFromVariantArgs(arguments, argumentCount, npObject, isolate);
resultObject = V8ObjectConstructor::newInstanceInDocument(ctor, argumentCount, argv.get(), frame ? frame->document() : 0);
}
diff --git a/Source/bindings/v8/PageScriptDebugServer.cpp b/Source/bindings/v8/PageScriptDebugServer.cpp
index 8c0d53b..db235b4 100644
--- a/Source/bindings/v8/PageScriptDebugServer.cpp
+++ b/Source/bindings/v8/PageScriptDebugServer.cpp
@@ -40,7 +40,7 @@
#include "bindings/v8/V8WindowShell.h"
#include "core/inspector/InspectorInstrumentation.h"
#include "core/inspector/ScriptDebugListener.h"
-#include "core/page/Frame.h"
+#include "core/frame/Frame.h"
#include "core/page/Page.h"
#include "wtf/OwnPtr.h"
#include "wtf/PassOwnPtr.h"
@@ -143,8 +143,8 @@
void PageScriptDebugServer::compileScript(ScriptState* state, const String& expression, const String& sourceURL, String* scriptId, String* exceptionMessage)
{
- ScriptExecutionContext* scriptExecutionContext = state->scriptExecutionContext();
- RefPtr<Frame> protect = toDocument(scriptExecutionContext)->frame();
+ ExecutionContext* executionContext = state->executionContext();
+ RefPtr<Frame> protect = toDocument(executionContext)->frame();
ScriptDebugServer::compileScript(state, expression, sourceURL, scriptId, exceptionMessage);
if (!scriptId->isNull())
m_compiledScriptURLs.set(*scriptId, sourceURL);
@@ -160,8 +160,8 @@
{
String sourceURL = m_compiledScriptURLs.take(scriptId);
- ScriptExecutionContext* scriptExecutionContext = state->scriptExecutionContext();
- Frame* frame = toDocument(scriptExecutionContext)->frame();
+ ExecutionContext* executionContext = state->executionContext();
+ Frame* frame = toDocument(executionContext)->frame();
InspectorInstrumentationCookie cookie;
if (frame)
cookie = InspectorInstrumentation::willEvaluateScript(frame, sourceURL, TextPosition::minimumPosition().m_line.oneBasedInt());
diff --git a/Source/bindings/v8/ScheduledAction.cpp b/Source/bindings/v8/ScheduledAction.cpp
index e4780f8..a231a38 100644
--- a/Source/bindings/v8/ScheduledAction.cpp
+++ b/Source/bindings/v8/ScheduledAction.cpp
@@ -37,11 +37,11 @@
#include "bindings/v8/V8GCController.h"
#include "bindings/v8/V8ScriptRunner.h"
#include "core/dom/Document.h"
-#include "core/dom/ScriptExecutionContext.h"
-#include "core/page/Frame.h"
-#include "core/platform/chromium/TraceEvent.h"
+#include "core/dom/ExecutionContext.h"
+#include "core/frame/Frame.h"
#include "core/workers/WorkerGlobalScope.h"
#include "core/workers/WorkerThread.h"
+#include "platform/TraceEvent.h"
namespace WebCore {
@@ -69,7 +69,7 @@
m_args[i].dispose();
}
-void ScheduledAction::execute(ScriptExecutionContext* context)
+void ScheduledAction::execute(ExecutionContext* context)
{
if (context->isDocument()) {
Frame* frame = toDocument(context)->frame();
@@ -90,16 +90,17 @@
v8::Handle<v8::Context> context = m_context.newLocal(m_isolate);
if (context.IsEmpty())
return;
- v8::Context::Scope scope(context);
TRACE_EVENT0("v8", "ScheduledAction::execute");
if (!m_function.isEmpty()) {
+ v8::Context::Scope scope(context);
Vector<v8::Handle<v8::Value> > args;
createLocalHandlesForArgs(&args);
frame->script()->callFunction(m_function.newLocal(m_isolate), context->Global(), args.size(), args.data());
- } else
- frame->script()->compileAndRunScript(m_code);
+ } else {
+ frame->script()->executeScriptAndReturnValue(context, ScriptSourceCode(m_code));
+ }
// The frame might be invalid at this point because JavaScript could have released it.
}
diff --git a/Source/bindings/v8/ScheduledAction.h b/Source/bindings/v8/ScheduledAction.h
index 17fa40c..3d3623b 100644
--- a/Source/bindings/v8/ScheduledAction.h
+++ b/Source/bindings/v8/ScheduledAction.h
@@ -41,7 +41,7 @@
namespace WebCore {
class Frame;
-class ScriptExecutionContext;
+class ExecutionContext;
class WorkerGlobalScope;
class ScheduledAction {
@@ -51,7 +51,7 @@
ScheduledAction(v8::Handle<v8::Context>, const String&, const KURL&, v8::Isolate*);
~ScheduledAction();
- void execute(ScriptExecutionContext*);
+ void execute(ExecutionContext*);
private:
void execute(Frame*);
diff --git a/Source/bindings/v8/ScriptCallStackFactory.cpp b/Source/bindings/v8/ScriptCallStackFactory.cpp
index a21bdc2..f5b7171 100644
--- a/Source/bindings/v8/ScriptCallStackFactory.cpp
+++ b/Source/bindings/v8/ScriptCallStackFactory.cpp
@@ -39,14 +39,14 @@
#include "core/inspector/ScriptArguments.h"
#include "core/inspector/ScriptCallFrame.h"
#include "core/inspector/ScriptCallStack.h"
-#include "core/platform/JSONValues.h"
+#include "platform/JSONValues.h"
#include "wtf/text/StringBuilder.h"
#include <v8-debug.h>
namespace WebCore {
-class ScriptExecutionContext;
+class ExecutionContext;
static ScriptCallFrame toScriptCallFrame(v8::Handle<v8::StackFrame> frame)
{
@@ -114,23 +114,13 @@
{
size_t stackSize = 1;
if (InspectorInstrumentation::hasFrontends()) {
- ScriptExecutionContext* scriptExecutionContext = getScriptExecutionContext();
- if (InspectorInstrumentation::consoleAgentEnabled(scriptExecutionContext))
+ ExecutionContext* executionContext = getExecutionContext();
+ if (InspectorInstrumentation::consoleAgentEnabled(executionContext))
stackSize = maxStackSize;
}
return createScriptCallStack(stackSize);
}
-PassRefPtr<ScriptCallStack> createScriptCallStackForConsole(ScriptState*)
-{
- return createScriptCallStackForConsole();
-}
-
-PassRefPtr<ScriptCallStack> createScriptCallStack(ScriptState*, size_t maxStackSize)
-{
- return createScriptCallStackForConsole(maxStackSize);
-}
-
PassRefPtr<ScriptArguments> createScriptArguments(const v8::FunctionCallbackInfo<v8::Value>& v8arguments, unsigned skipArgumentCount)
{
v8::Isolate* isolate = v8arguments.GetIsolate();
diff --git a/Source/bindings/v8/ScriptCallStackFactory.h b/Source/bindings/v8/ScriptCallStackFactory.h
index 36f1cde..ff225e3 100644
--- a/Source/bindings/v8/ScriptCallStackFactory.h
+++ b/Source/bindings/v8/ScriptCallStackFactory.h
@@ -53,10 +53,6 @@
PassRefPtr<ScriptCallStack> createScriptCallStackForConsole(size_t maxStackSize = ScriptCallStack::maxCallStackSizeToCapture);
PassRefPtr<ScriptArguments> createScriptArguments(const v8::FunctionCallbackInfo<v8::Value>& v8arguments, unsigned skipArgumentCount);
-// This is just an alias to 'createScriptCallStackForConsole();' for compat with JSC.
-PassRefPtr<ScriptCallStack> createScriptCallStackForConsole(ScriptState*);
-PassRefPtr<ScriptCallStack> createScriptCallStack(ScriptState*, size_t maxStackSize = ScriptCallStack::maxCallStackSizeToCapture);
-
} // namespace WebCore
#endif // ScriptCallStackFactory_h
diff --git a/Source/bindings/v8/ScriptController.cpp b/Source/bindings/v8/ScriptController.cpp
index d400a91..f9c10f0 100644
--- a/Source/bindings/v8/ScriptController.cpp
+++ b/Source/bindings/v8/ScriptController.cpp
@@ -50,28 +50,28 @@
#include "bindings/v8/npruntime_impl.h"
#include "bindings/v8/npruntime_priv.h"
#include "core/dom/Document.h"
-#include "core/events/Event.h"
-#include "core/events/EventListener.h"
-#include "core/events/EventNames.h"
#include "core/dom/Node.h"
#include "core/dom/ScriptableDocumentParser.h"
-#include "core/dom/UserGestureIndicator.h"
+#include "core/events/Event.h"
+#include "core/events/EventListener.h"
+#include "core/events/ThreadLocalEventNames.h"
#include "core/html/HTMLPlugInElement.h"
#include "core/inspector/InspectorInstrumentation.h"
#include "core/inspector/ScriptCallStack.h"
#include "core/loader/DocumentLoader.h"
#include "core/loader/FrameLoader.h"
#include "core/loader/FrameLoaderClient.h"
-#include "core/page/ContentSecurityPolicy.h"
-#include "core/page/DOMWindow.h"
-#include "core/page/Frame.h"
+#include "core/frame/ContentSecurityPolicy.h"
+#include "core/frame/DOMWindow.h"
+#include "core/frame/Frame.h"
#include "core/page/Page.h"
#include "core/page/Settings.h"
#include "core/platform/HistogramSupport.h"
-#include "core/platform/NotImplemented.h"
-#include "core/platform/Widget.h"
-#include "core/platform/chromium/TraceEvent.h"
#include "core/plugins/PluginView.h"
+#include "platform/NotImplemented.h"
+#include "platform/TraceEvent.h"
+#include "platform/UserGestureIndicator.h"
+#include "platform/Widget.h"
#include "weborigin/SecurityOrigin.h"
#include "wtf/CurrentTime.h"
#include "wtf/StdLibExtras.h"
@@ -92,7 +92,6 @@
, m_sourceURL(0)
, m_isolate(v8::Isolate::GetCurrent())
, m_windowShell(V8WindowShell::create(frame, mainThreadNormalWorld(), m_isolate))
- , m_paused(false)
, m_windowScriptNPObject(0)
{
}
@@ -147,22 +146,11 @@
m_windowShell->updateSecurityOrigin();
}
-bool ScriptController::processingUserGesture()
-{
- return UserGestureIndicator::processingUserGesture();
-}
-
v8::Local<v8::Value> ScriptController::callFunction(v8::Handle<v8::Function> function, v8::Handle<v8::Object> receiver, int argc, v8::Handle<v8::Value> args[])
{
// Keep Frame (and therefore ScriptController) alive.
RefPtr<Frame> protect(m_frame);
- return ScriptController::callFunctionWithInstrumentation(m_frame ? m_frame->document() : 0, function, receiver, argc, args, m_isolate);
-}
-
-ScriptValue ScriptController::callFunctionEvenIfScriptDisabled(v8::Handle<v8::Function> function, v8::Handle<v8::Object> receiver, int argc, v8::Handle<v8::Value> argv[])
-{
- // FIXME: This should probably perform the same isPaused check that happens in ScriptController::executeScript.
- return ScriptValue(callFunction(function, receiver, argc, argv), m_isolate);
+ return ScriptController::callFunction(m_frame->document(), function, receiver, argc, args, m_isolate);
}
static void resourceInfo(const v8::Handle<v8::Function> function, String& resourceName, int& lineNumber)
@@ -190,7 +178,7 @@
return builder.toString();
}
-v8::Local<v8::Value> ScriptController::callFunctionWithInstrumentation(ScriptExecutionContext* context, v8::Handle<v8::Function> function, v8::Handle<v8::Object> receiver, int argc, v8::Handle<v8::Value> args[], v8::Isolate* isolate)
+v8::Local<v8::Value> ScriptController::callFunction(ExecutionContext* context, v8::Handle<v8::Function> function, v8::Handle<v8::Object> receiver, int argc, v8::Handle<v8::Value> args[], v8::Isolate* isolate)
{
InspectorInstrumentationCookie cookie;
if (InspectorInstrumentation::timelineAgentEnabled(context)) {
@@ -206,9 +194,9 @@
return result;
}
-v8::Local<v8::Value> ScriptController::compileAndRunScript(const ScriptSourceCode& source, AccessControlStatus corsStatus)
+v8::Local<v8::Value> ScriptController::executeScriptAndReturnValue(v8::Handle<v8::Context> context, const ScriptSourceCode& source, AccessControlStatus corsStatus)
{
- ASSERT(v8::Context::InContext());
+ v8::Context::Scope scope(context);
InspectorInstrumentationCookie cookie = InspectorInstrumentation::willEvaluateScript(m_frame, source.url().isNull() ? String() : source.url().string(), source.startLine());
@@ -321,9 +309,6 @@
return contextForWorld(this, mainThreadNormalWorld());
Frame* frame = toFrameIfNotDetached(context);
- if (!m_frame)
- return v8::Local<v8::Context>();
-
if (m_frame == frame)
return v8::Local<v8::Context>::New(m_isolate, context);
@@ -379,7 +364,7 @@
v8Context->SetErrorMessageForCodeGenerationFromStrings(v8String(errorMessage, m_isolate));
}
-PassScriptInstance ScriptController::createScriptInstanceForWidget(Widget* widget)
+PassRefPtr<SharedPersistent<v8::Object> > ScriptController::createPluginWrapper(Widget* widget)
{
ASSERT(widget);
@@ -419,7 +404,7 @@
// Track the plugin object. We've been given a reference to the object.
m_pluginObjects.set(widget, npObject);
- return V8ScriptInstance::create(wrapper, m_isolate);
+ return SharedPersistent<v8::Object>::create(wrapper, m_isolate);
}
void ScriptController::cleanupScriptObjectsForPlugin(Widget* nativeHandle)
@@ -598,22 +583,6 @@
return allowed;
}
-ScriptValue ScriptController::executeScript(const String& script, bool forceUserGesture)
-{
- UserGestureIndicator gestureIndicator(forceUserGesture ? DefinitelyProcessingNewUserGesture : PossiblyProcessingUserGesture);
- return executeScript(ScriptSourceCode(script, m_frame->document()->url()));
-}
-
-ScriptValue ScriptController::executeScript(const ScriptSourceCode& sourceCode)
-{
- if (!canExecuteScripts(AboutToExecuteScript) || isPaused())
- return ScriptValue();
-
- RefPtr<Frame> protect(m_frame); // Script execution can destroy the frame, and thus the ScriptController.
-
- return executeScriptInMainWorld(sourceCode);
-}
-
bool ScriptController::executeScriptIfJavaScriptURL(const KURL& url)
{
if (!protocolIsJavaScript(url))
@@ -633,7 +602,7 @@
bool locationChangeBefore = m_frame->navigationScheduler()->locationChangePending();
String decodedURL = decodeURLEscapeSequences(url.string());
- ScriptValue result = executeScript(decodedURL.substring(javascriptSchemeLength));
+ ScriptValue result = evaluateScriptInMainWorld(ScriptSourceCode(decodedURL.substring(javascriptSchemeLength)), NotSharableCrossOrigin, DoNotExecuteScriptWhenScriptsDisabled);
// If executing script caused this frame to be removed from the page, we
// don't want to try to replace its document!
@@ -657,8 +626,26 @@
return true;
}
-ScriptValue ScriptController::executeScriptInMainWorld(const ScriptSourceCode& sourceCode, AccessControlStatus corsStatus)
+void ScriptController::executeScriptInMainWorld(const String& script, ExecuteScriptPolicy policy)
{
+ evaluateScriptInMainWorld(ScriptSourceCode(script), NotSharableCrossOrigin, policy);
+}
+
+void ScriptController::executeScriptInMainWorld(const ScriptSourceCode& sourceCode, AccessControlStatus corsStatus)
+{
+ evaluateScriptInMainWorld(sourceCode, corsStatus, DoNotExecuteScriptWhenScriptsDisabled);
+}
+
+ScriptValue ScriptController::executeScriptInMainWorldAndReturnValue(const ScriptSourceCode& sourceCode)
+{
+ return evaluateScriptInMainWorld(sourceCode, NotSharableCrossOrigin, DoNotExecuteScriptWhenScriptsDisabled);
+}
+
+ScriptValue ScriptController::evaluateScriptInMainWorld(const ScriptSourceCode& sourceCode, AccessControlStatus corsStatus, ExecuteScriptPolicy policy)
+{
+ if (policy == DoNotExecuteScriptWhenScriptsDisabled && !canExecuteScripts(AboutToExecuteScript))
+ return ScriptValue();
+
String sourceURL = sourceCode.url();
const String* savedSourceURL = m_sourceURL;
m_sourceURL = &sourceURL;
@@ -675,9 +662,7 @@
OwnPtr<ScriptSourceCode> maybeProcessedSourceCode = InspectorInstrumentation::preprocess(m_frame, sourceCode);
const ScriptSourceCode& sourceCodeToCompile = maybeProcessedSourceCode ? *maybeProcessedSourceCode : sourceCode;
- v8::Context::Scope scope(v8Context);
- v8::Local<v8::Value> object = compileAndRunScript(sourceCodeToCompile, corsStatus);
-
+ v8::Local<v8::Value> object = executeScriptAndReturnValue(v8Context, sourceCodeToCompile, corsStatus);
m_sourceURL = savedSourceURL;
if (object.IsEmpty())
@@ -705,7 +690,7 @@
v8::Local<v8::Array> resultArray = v8::Array::New(sources.size());
for (size_t i = 0; i < sources.size(); ++i) {
- v8::Local<v8::Value> evaluationResult = compileAndRunScript(sources[i]);
+ v8::Local<v8::Value> evaluationResult = executeScriptAndReturnValue(context, sources[i]);
if (evaluationResult.IsEmpty())
evaluationResult = v8::Local<v8::Value>::New(m_isolate, v8::Undefined(m_isolate));
resultArray->Set(i, evaluationResult);
diff --git a/Source/bindings/v8/ScriptController.h b/Source/bindings/v8/ScriptController.h
index 975c24c..0dfb23a 100644
--- a/Source/bindings/v8/ScriptController.h
+++ b/Source/bindings/v8/ScriptController.h
@@ -31,8 +31,8 @@
#ifndef ScriptController_h
#define ScriptController_h
-#include "bindings/v8/ScriptInstance.h"
#include "bindings/v8/ScriptValue.h"
+#include "bindings/v8/SharedPersistent.h"
#include "core/fetch/CrossOriginAccessControl.h"
#include "wtf/Forward.h"
@@ -67,6 +67,11 @@
class ScriptController {
public:
+ enum ExecuteScriptPolicy {
+ ExecuteScriptWhenScriptsDisabled,
+ DoNotExecuteScriptWhenScriptsDisabled
+ };
+
ScriptController(Frame*);
~ScriptController();
@@ -74,11 +79,11 @@
V8WindowShell* windowShell(DOMWrapperWorld*);
V8WindowShell* existingWindowShell(DOMWrapperWorld*);
- ScriptValue executeScript(const ScriptSourceCode&);
- ScriptValue executeScript(const String& script, bool forceUserGesture = false);
-
// Evaluate JavaScript in the main world.
- ScriptValue executeScriptInMainWorld(const ScriptSourceCode&, AccessControlStatus = NotSharableCrossOrigin);
+ void executeScriptInMainWorld(const String&, ExecuteScriptPolicy = DoNotExecuteScriptWhenScriptsDisabled);
+ void executeScriptInMainWorld(const ScriptSourceCode&, AccessControlStatus = NotSharableCrossOrigin);
+ ScriptValue executeScriptInMainWorldAndReturnValue(const ScriptSourceCode&);
+ v8::Local<v8::Value> executeScriptAndReturnValue(v8::Handle<v8::Context>, const ScriptSourceCode&, AccessControlStatus = NotSharableCrossOrigin);
// Executes JavaScript in an isolated world. The script gets its own global scope,
// its own prototypes for intrinsic JavaScript objects (String, Array, and so-on),
@@ -93,11 +98,8 @@
// Returns true if argument is a JavaScript URL.
bool executeScriptIfJavaScriptURL(const KURL&);
- v8::Local<v8::Value> compileAndRunScript(const ScriptSourceCode&, AccessControlStatus = NotSharableCrossOrigin);
-
v8::Local<v8::Value> callFunction(v8::Handle<v8::Function>, v8::Handle<v8::Object>, int argc, v8::Handle<v8::Value> argv[]);
- ScriptValue callFunctionEvenIfScriptDisabled(v8::Handle<v8::Function>, v8::Handle<v8::Object>, int argc, v8::Handle<v8::Value> argv[]);
- static v8::Local<v8::Value> callFunctionWithInstrumentation(ScriptExecutionContext*, v8::Handle<v8::Function>, v8::Handle<v8::Object> receiver, int argc, v8::Handle<v8::Value> args[], v8::Isolate*);
+ static v8::Local<v8::Value> callFunction(ExecutionContext*, v8::Handle<v8::Function>, v8::Handle<v8::Object> receiver, int argc, v8::Handle<v8::Value> args[], v8::Isolate*);
// Returns true if the current world is isolated, and has its own Content
// Security Policy. In this case, the policy of the main world should be
@@ -107,7 +109,7 @@
// Creates a property of the global object of a frame.
void bindToWindowObject(Frame*, const String& key, NPObject*);
- PassScriptInstance createScriptInstanceForWidget(Widget*);
+ PassRefPtr<SharedPersistent<v8::Object> > createPluginWrapper(Widget*);
void enableEval();
void disableEval(const String& errorMessage);
@@ -127,11 +129,6 @@
TextPosition eventHandlerPosition() const;
- static bool processingUserGesture();
-
- void setPaused(bool paused) { m_paused = paused; }
- bool isPaused() const { return m_paused; }
-
const String* sourceURL() const { return m_sourceURL; } // 0 if we are not evaluating any script.
void clearWindowShell();
@@ -165,6 +162,7 @@
typedef HashMap<int, OwnPtr<V8WindowShell> > IsolatedWorldMap;
typedef HashMap<Widget*, NPObject*> PluginObjectMap;
+ ScriptValue evaluateScriptInMainWorld(const ScriptSourceCode&, AccessControlStatus, ExecuteScriptPolicy);
void clearForClose(bool destroyGlobal);
Frame* m_frame;
@@ -174,8 +172,6 @@
OwnPtr<V8WindowShell> m_windowShell;
IsolatedWorldMap m_isolatedWorlds;
- bool m_paused;
-
// A mapping between Widgets and their corresponding script object.
// This list is used so that when the plugin dies, we can immediately
// invalidate all sub-objects which are associated with that plugin.
diff --git a/Source/bindings/v8/ScriptDebugServer.cpp b/Source/bindings/v8/ScriptDebugServer.cpp
index 2caa721..34f6bc7 100644
--- a/Source/bindings/v8/ScriptDebugServer.cpp
+++ b/Source/bindings/v8/ScriptDebugServer.cpp
@@ -222,7 +222,7 @@
continueProgram();
}
-void ScriptDebugServer::stepOverStatement(const ScriptValue& frame)
+void ScriptDebugServer::stepCommandWithFrame(const char* functionName, const ScriptValue& frame)
{
ASSERT(isPaused());
v8::HandleScope handleScope(m_isolate);
@@ -239,17 +239,18 @@
callFrame
};
- callDebuggerMethod("stepOverStatement", 2, argv);
+ callDebuggerMethod(functionName, 2, argv);
continueProgram();
}
-void ScriptDebugServer::stepOutOfFunction()
+void ScriptDebugServer::stepOverStatement(const ScriptValue& frame)
{
- ASSERT(isPaused());
- v8::HandleScope handleScope(m_isolate);
- v8::Handle<v8::Value> argv[] = { m_executionState.newLocal(m_isolate) };
- callDebuggerMethod(stepOutV8MethodName, 1, argv);
- continueProgram();
+ stepCommandWithFrame("stepOverStatement", frame);
+}
+
+void ScriptDebugServer::stepOutOfFunction(const ScriptValue& frame)
+{
+ stepCommandWithFrame(stepOutV8MethodName, frame);
}
bool ScriptDebugServer::setScriptSource(const String& sourceID, const String& newContent, bool preview, String* error, RefPtr<TypeBuilder::Debugger::SetScriptSourceError>& errorData, ScriptValue* newCallFrames, ScriptObject* result)
@@ -610,7 +611,7 @@
return;
v8::Context::Scope contextScope(context);
v8::TryCatch tryCatch;
- v8::Local<v8::Value> value = V8ScriptRunner::runCompiledScript(script, state->scriptExecutionContext(), m_isolate);
+ v8::Local<v8::Value> value = V8ScriptRunner::runCompiledScript(script, state->executionContext(), m_isolate);
*wasThrown = false;
if (tryCatch.HasCaught()) {
*wasThrown = true;
diff --git a/Source/bindings/v8/ScriptDebugServer.h b/Source/bindings/v8/ScriptDebugServer.h
index ab40574..761bc7f 100644
--- a/Source/bindings/v8/ScriptDebugServer.h
+++ b/Source/bindings/v8/ScriptDebugServer.h
@@ -76,7 +76,7 @@
void continueProgram();
void stepIntoStatement();
void stepOverStatement(const ScriptValue& frame);
- void stepOutOfFunction();
+ void stepOutOfFunction(const ScriptValue& frame);
bool setScriptSource(const String& sourceID, const String& newContent, bool preview, String* error, RefPtr<TypeBuilder::Debugger::SetScriptSourceError>&, ScriptValue* newCallFrames, ScriptObject* result);
void updateCallStack(ScriptValue* callFrame);
@@ -136,6 +136,7 @@
v8::Isolate* m_isolate;
private:
+ void stepCommandWithFrame(const char* functionName, const ScriptValue& frame);
PassRefPtr<JavaScriptCallFrame> wrapCallFrames(v8::Handle<v8::Object> executionState, int maximumLimit);
bool executeSkipPauseRequest(ScriptDebugListener::SkipPauseRequest, v8::Handle<v8::Object> executionState);
diff --git a/Source/bindings/v8/ScriptEventListener.cpp b/Source/bindings/v8/ScriptEventListener.cpp
index abd3d4d..b99b22d 100644
--- a/Source/bindings/v8/ScriptEventListener.cpp
+++ b/Source/bindings/v8/ScriptEventListener.cpp
@@ -39,7 +39,7 @@
#include "core/dom/Document.h"
#include "core/dom/DocumentParser.h"
#include "core/events/EventListener.h"
-#include "core/page/Frame.h"
+#include "core/frame/Frame.h"
namespace WebCore {
diff --git a/Source/bindings/v8/ScriptFunctionCall.cpp b/Source/bindings/v8/ScriptFunctionCall.cpp
index 5a3a6f6..a5cfcc7 100644
--- a/Source/bindings/v8/ScriptFunctionCall.cpp
+++ b/Source/bindings/v8/ScriptFunctionCall.cpp
@@ -41,7 +41,6 @@
#include "bindings/v8/V8Utilities.h"
#include <v8.h>
-#include "wtf/OwnArrayPtr.h"
namespace WebCore {
@@ -135,13 +134,13 @@
ASSERT(value->IsFunction());
v8::Local<v8::Function> function = v8::Local<v8::Function>::Cast(value);
- OwnArrayPtr<v8::Handle<v8::Value> > args = adoptArrayPtr(new v8::Handle<v8::Value>[m_arguments.size()]);
+ OwnPtr<v8::Handle<v8::Value>[]> args = adoptArrayPtr(new v8::Handle<v8::Value>[m_arguments.size()]);
for (size_t i = 0; i < m_arguments.size(); ++i) {
args[i] = m_arguments[i].v8Value();
ASSERT(!args[i].IsEmpty());
}
- v8::Local<v8::Value> result = V8ScriptRunner::callFunction(function, getScriptExecutionContext(), thisObject, m_arguments.size(), args.get(), m_scriptState->isolate());
+ v8::Local<v8::Value> result = V8ScriptRunner::callFunction(function, getExecutionContext(), thisObject, m_arguments.size(), args.get(), m_scriptState->isolate());
if (!scope.success()) {
hadException = true;
return ScriptValue();
@@ -170,7 +169,7 @@
ASSERT(value->IsFunction());
v8::Local<v8::Function> constructor = v8::Local<v8::Function>::Cast(value);
- OwnArrayPtr<v8::Handle<v8::Value> > args = adoptArrayPtr(new v8::Handle<v8::Value>[m_arguments.size()]);
+ OwnPtr<v8::Handle<v8::Value>[]> args = adoptArrayPtr(new v8::Handle<v8::Value>[m_arguments.size()]);
for (size_t i = 0; i < m_arguments.size(); ++i)
args[i] = m_arguments[i].v8Value();
@@ -185,6 +184,7 @@
ScriptCallback::ScriptCallback(ScriptState* state, const ScriptValue& function)
: ScriptCallArgumentHandler(state)
+ , m_scriptState(state)
, m_function(function)
{
}
@@ -199,11 +199,11 @@
v8::Handle<v8::Object> object = v8::Context::GetCurrent()->Global();
v8::Handle<v8::Function> function = v8::Handle<v8::Function>::Cast(m_function.v8Value());
- OwnArrayPtr<v8::Handle<v8::Value> > args = adoptArrayPtr(new v8::Handle<v8::Value>[m_arguments.size()]);
+ OwnPtr<v8::Handle<v8::Value>[]> args = adoptArrayPtr(new v8::Handle<v8::Value>[m_arguments.size()]);
for (size_t i = 0; i < m_arguments.size(); ++i)
args[i] = m_arguments[i].v8Value();
- v8::Handle<v8::Value> result = ScriptController::callFunctionWithInstrumentation(0, function, object, m_arguments.size(), args.get(), m_scriptState->isolate());
+ v8::Handle<v8::Value> result = ScriptController::callFunction(m_scriptState->executionContext(), function, object, m_arguments.size(), args.get(), m_scriptState->isolate());
return ScriptValue(result, m_scriptState->isolate());
}
diff --git a/Source/bindings/v8/ScriptFunctionCall.h b/Source/bindings/v8/ScriptFunctionCall.h
index f0050e5..032b6a0 100644
--- a/Source/bindings/v8/ScriptFunctionCall.h
+++ b/Source/bindings/v8/ScriptFunctionCall.h
@@ -79,6 +79,7 @@
ScriptValue call();
private:
+ ScriptState* m_scriptState;
ScriptValue m_function;
};
diff --git a/Source/bindings/v8/ScriptHeapSnapshot.cpp b/Source/bindings/v8/ScriptHeapSnapshot.cpp
index 76ea368..fdb2f47 100644
--- a/Source/bindings/v8/ScriptHeapSnapshot.cpp
+++ b/Source/bindings/v8/ScriptHeapSnapshot.cpp
@@ -32,7 +32,7 @@
#include "bindings/v8/ScriptHeapSnapshot.h"
#include "bindings/v8/V8Binding.h"
-#include "core/platform/JSONValues.h"
+#include "platform/JSONValues.h"
#include <v8.h>
#include <v8-profiler.h>
#include "wtf/PassRefPtr.h"
diff --git a/Source/bindings/v8/ScriptInstance.cpp b/Source/bindings/v8/ScriptInstance.cpp
deleted file mode 100644
index 6898d07..0000000
--- a/Source/bindings/v8/ScriptInstance.cpp
+++ /dev/null
@@ -1,41 +0,0 @@
-/*
- * Copyright (C) 2008, 2009 Google Inc. All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions are
- * met:
- *
- * * Redistributions of source code must retain the above copyright
- * notice, this list of conditions and the following disclaimer.
- * * Redistributions in binary form must reproduce the above
- * copyright notice, this list of conditions and the following disclaimer
- * in the documentation and/or other materials provided with the
- * distribution.
- * * Neither the name of Google Inc. nor the names of its
- * contributors may be used to endorse or promote products derived from
- * this software without specific prior written permission.
- *
- * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
- * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
- * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
- * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
- * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
- * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
- * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
- * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
- * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
- * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
- * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
- */
-
-#include "config.h"
-#include "bindings/v8/ScriptInstance.h"
-
-namespace WebCore {
-
-V8ScriptInstance::V8ScriptInstance(v8::Handle<v8::Object> instance, v8::Isolate* isolate)
- : m_instance(isolate, instance)
-{
-}
-
-} // namespace WebCore
diff --git a/Source/bindings/v8/ScriptInstance.h b/Source/bindings/v8/ScriptInstance.h
deleted file mode 100644
index 803e8ef..0000000
--- a/Source/bindings/v8/ScriptInstance.h
+++ /dev/null
@@ -1,59 +0,0 @@
-/*
- * Copyright (C) 2008, 2009 Google Inc. All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions are
- * met:
- *
- * * Redistributions of source code must retain the above copyright
- * notice, this list of conditions and the following disclaimer.
- * * Redistributions in binary form must reproduce the above
- * copyright notice, this list of conditions and the following disclaimer
- * in the documentation and/or other materials provided with the
- * distribution.
- * * Neither the name of Google Inc. nor the names of its
- * contributors may be used to endorse or promote products derived from
- * this software without specific prior written permission.
- *
- * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
- * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
- * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
- * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
- * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
- * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
- * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
- * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
- * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
- * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
- * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
- */
-
-#ifndef ScriptInstance_h
-#define ScriptInstance_h
-
-#include "bindings/v8/ScopedPersistent.h"
-#include <v8.h>
-#include "wtf/PassRefPtr.h"
-#include "wtf/RefCounted.h"
-#include "wtf/RefPtr.h"
-
-namespace WebCore {
-
-class V8ScriptInstance : public RefCounted<V8ScriptInstance> {
-public:
- static PassRefPtr<V8ScriptInstance> create(v8::Handle<v8::Object> instance, v8::Isolate* isolate) { return adoptRef(new V8ScriptInstance(instance, isolate)); }
-
- v8::Local<v8::Object> newLocal(v8::Isolate* isolate) { return m_instance.newLocal(isolate); }
-
-private:
- V8ScriptInstance(v8::Handle<v8::Object>, v8::Isolate*);
-
- ScopedPersistent<v8::Object> m_instance;
-};
-
-typedef RefPtr<V8ScriptInstance> ScriptInstance;
-typedef PassRefPtr<V8ScriptInstance> PassScriptInstance;
-
-} // namespace WebCore
-
-#endif // ScriptInstance_h
diff --git a/Source/bindings/v8/ScriptPromiseResolver.cpp b/Source/bindings/v8/ScriptPromiseResolver.cpp
index 8e2e5b3..7882490 100644
--- a/Source/bindings/v8/ScriptPromiseResolver.cpp
+++ b/Source/bindings/v8/ScriptPromiseResolver.cpp
@@ -80,7 +80,7 @@
m_promise.clear();
}
-PassRefPtr<ScriptPromiseResolver> ScriptPromiseResolver::create(ScriptExecutionContext* context)
+PassRefPtr<ScriptPromiseResolver> ScriptPromiseResolver::create(ExecutionContext* context)
{
ASSERT(v8::Context::InContext());
ASSERT(context);
@@ -124,7 +124,7 @@
ASSERT(v8::Context::InContext());
if (!isPending())
return;
- V8PromiseCustom::resolve(m_promise.v8Value().As<v8::Object>(), value, V8PromiseCustom::Asynchronous, m_isolate);
+ V8PromiseCustom::resolve(m_promise.v8Value().As<v8::Object>(), value, m_isolate);
detachPromiseForResolve();
}
@@ -133,7 +133,7 @@
ASSERT(v8::Context::InContext());
if (!isPending())
return;
- V8PromiseCustom::reject(m_promise.v8Value().As<v8::Object>(), value, V8PromiseCustom::Asynchronous, m_isolate);
+ V8PromiseCustom::reject(m_promise.v8Value().As<v8::Object>(), value, m_isolate);
detachPromiseForResolve();
}
diff --git a/Source/bindings/v8/ScriptPromiseResolver.h b/Source/bindings/v8/ScriptPromiseResolver.h
index 7c93e06..d51448c 100644
--- a/Source/bindings/v8/ScriptPromiseResolver.h
+++ b/Source/bindings/v8/ScriptPromiseResolver.h
@@ -42,7 +42,7 @@
namespace WebCore {
-class ScriptExecutionContext;
+class ExecutionContext;
// ScriptPromiseResolver is a class for performing operations on Promise
// (resolve / reject) from C++ world.
@@ -78,7 +78,7 @@
class ScriptPromiseResolver : public RefCounted<ScriptPromiseResolver> {
WTF_MAKE_NONCOPYABLE(ScriptPromiseResolver);
public:
- static PassRefPtr<ScriptPromiseResolver> create(ScriptExecutionContext*);
+ static PassRefPtr<ScriptPromiseResolver> create(ExecutionContext*);
static PassRefPtr<ScriptPromiseResolver> create();
// A ScriptPromiseResolver should be resolved / rejected before
diff --git a/Source/bindings/v8/ScriptState.cpp b/Source/bindings/v8/ScriptState.cpp
index 0304680..6760ddb 100644
--- a/Source/bindings/v8/ScriptState.cpp
+++ b/Source/bindings/v8/ScriptState.cpp
@@ -36,7 +36,7 @@
#include "bindings/v8/ScriptController.h"
#include "bindings/v8/V8HiddenPropertyName.h"
#include "bindings/v8/WorkerScriptController.h"
-#include "core/page/Frame.h"
+#include "core/frame/Frame.h"
#include "core/workers/WorkerGlobalScope.h"
#include <v8.h>
#include "wtf/Assertions.h"
@@ -60,10 +60,10 @@
return toDOMWindow(m_context.newLocal(m_isolate));
}
-ScriptExecutionContext* ScriptState::scriptExecutionContext() const
+ExecutionContext* ScriptState::executionContext() const
{
v8::HandleScope handleScope(m_isolate);
- return toScriptExecutionContext(m_context.newLocal(m_isolate));
+ return toExecutionContext(m_context.newLocal(m_isolate));
}
ScriptState* ScriptState::forContext(v8::Handle<v8::Context> context)
diff --git a/Source/bindings/v8/ScriptState.h b/Source/bindings/v8/ScriptState.h
index b6f7e37..de2f3ec 100644
--- a/Source/bindings/v8/ScriptState.h
+++ b/Source/bindings/v8/ScriptState.h
@@ -41,7 +41,7 @@
class DOMWindow;
class DOMWrapperWorld;
class Frame;
-class ScriptExecutionContext;
+class ExecutionContext;
class WorkerGlobalScope;
class ScriptState {
@@ -66,7 +66,7 @@
}
DOMWindow* domWindow() const;
- ScriptExecutionContext* scriptExecutionContext() const;
+ ExecutionContext* executionContext() const;
bool evalEnabled() const;
void setEvalEnabled(bool);
diff --git a/Source/bindings/v8/ScriptValue.cpp b/Source/bindings/v8/ScriptValue.cpp
index 4926ed9..4afe386 100644
--- a/Source/bindings/v8/ScriptValue.cpp
+++ b/Source/bindings/v8/ScriptValue.cpp
@@ -35,7 +35,7 @@
#include "bindings/v8/SerializedScriptValue.h"
#include "bindings/v8/V8Binding.h"
#include "core/dom/MessagePort.h"
-#include "core/platform/JSONValues.h"
+#include "platform/JSONValues.h"
#include "wtf/ArrayBuffer.h"
namespace WebCore {
diff --git a/Source/bindings/v8/SerializedScriptValue.cpp b/Source/bindings/v8/SerializedScriptValue.cpp
index 8f9d608..984d5e7 100644
--- a/Source/bindings/v8/SerializedScriptValue.cpp
+++ b/Source/bindings/v8/SerializedScriptValue.cpp
@@ -58,8 +58,7 @@
#include "core/fileapi/FileList.h"
#include "core/html/ImageData.h"
#include "core/html/canvas/DataView.h"
-#include "core/platform/AsyncFileSystem.h"
-#include "core/platform/SharedBuffer.h"
+#include "platform/SharedBuffer.h"
#include "wtf/ArrayBuffer.h"
#include "wtf/ArrayBufferContents.h"
#include "wtf/ArrayBufferView.h"
@@ -239,10 +238,6 @@
return !(depth & (depth - 1));
}
-// Increment this for each incompatible change to the wire format.
-// Version 2: Added StringUCharTag for UChar v8 strings.
-static const uint32_t wireFormatVersion = 2;
-
static const int maxDepth = 20000;
// VarInt encoding constants.
@@ -366,7 +361,7 @@
void writeVersion()
{
append(VersionTag);
- doWriteUint32(wireFormatVersion);
+ doWriteUint32(SerializedScriptValue::wireFormatVersion);
}
void writeInt32(int32_t value)
@@ -399,10 +394,10 @@
doWriteNumber(number);
}
- void writeBlob(const String& url, const String& type, unsigned long long size)
+ void writeBlob(const String& uuid, const String& type, unsigned long long size)
{
append(BlobTag);
- doWriteWebCoreString(url);
+ doWriteWebCoreString(uuid);
doWriteWebCoreString(type);
doWriteUint64(size);
}
@@ -415,12 +410,10 @@
doWriteWebCoreString(url);
}
- void writeFile(const String& path, const String& url, const String& type)
+ void writeFile(const File& file)
{
append(FileTag);
- doWriteWebCoreString(path);
- doWriteWebCoreString(url);
- doWriteWebCoreString(type);
+ doWriteFile(file);
}
void writeFileList(const FileList& fileList)
@@ -428,11 +421,8 @@
append(FileListTag);
uint32_t length = fileList.length();
doWriteUint32(length);
- for (unsigned i = 0; i < length; ++i) {
- doWriteWebCoreString(fileList.item(i)->path());
- doWriteWebCoreString(fileList.item(i)->url().string());
- doWriteWebCoreString(fileList.item(i)->type());
- }
+ for (unsigned i = 0; i < length; ++i)
+ doWriteFile(*fileList.item(i));
}
void writeArrayBuffer(const ArrayBuffer& arrayBuffer)
@@ -567,6 +557,13 @@
v8::Isolate* getIsolate() { return m_isolate; }
private:
+ void doWriteFile(const File& file)
+ {
+ doWriteWebCoreString(file.path());
+ doWriteWebCoreString(file.uuid());
+ doWriteWebCoreString(file.type());
+ }
+
void doWriteArrayBuffer(const ArrayBuffer& arrayBuffer)
{
uint32_t byteLength = arrayBuffer.byteLength();
@@ -706,14 +703,14 @@
JSFailure
};
- Serializer(Writer& writer, MessagePortArray* messagePorts, ArrayBufferArray* arrayBuffers, Vector<String>& blobURLs, v8::TryCatch& tryCatch, v8::Isolate* isolate)
+ Serializer(Writer& writer, MessagePortArray* messagePorts, ArrayBufferArray* arrayBuffers, BlobDataHandleMap& blobDataHandles, v8::TryCatch& tryCatch, v8::Isolate* isolate)
: m_writer(writer)
, m_tryCatch(tryCatch)
, m_depth(0)
, m_execDepth(0)
, m_status(Success)
, m_nextObjectReference(0)
- , m_blobURLs(blobURLs)
+ , m_blobDataHandles(blobDataHandles)
, m_isolate(isolate)
{
ASSERT(!tryCatch.HasCaught());
@@ -1081,8 +1078,8 @@
Blob* blob = V8Blob::toNative(value.As<v8::Object>());
if (!blob)
return;
- m_writer.writeBlob(blob->url().string(), blob->type(), blob->size());
- m_blobURLs.append(blob->url().string());
+ m_writer.writeBlob(blob->uuid(), blob->type(), blob->size());
+ m_blobDataHandles.add(blob->uuid(), blob->blobDataHandle());
}
StateBase* writeDOMFileSystem(v8::Handle<v8::Value> value, StateBase* next)
@@ -1101,8 +1098,8 @@
File* file = V8File::toNative(value.As<v8::Object>());
if (!file)
return;
- m_writer.writeFile(file->path(), file->url().string(), file->type());
- m_blobURLs.append(file->url().string());
+ m_writer.writeFile(*file);
+ m_blobDataHandles.add(file->uuid(), file->blobDataHandle());
}
void writeFileList(v8::Handle<v8::Value> value)
@@ -1113,7 +1110,7 @@
m_writer.writeFileList(*fileList);
unsigned length = fileList->length();
for (unsigned i = 0; i < length; ++i)
- m_blobURLs.append(fileList->item(i)->url().string());
+ m_blobDataHandles.add(fileList->item(i)->uuid(), fileList->item(i)->blobDataHandle());
}
void writeImageData(v8::Handle<v8::Value> value)
@@ -1232,7 +1229,7 @@
ObjectPool m_transferredMessagePorts;
ObjectPool m_transferredArrayBuffers;
uint32_t m_nextObjectReference;
- Vector<String>& m_blobURLs;
+ BlobDataHandleMap& m_blobDataHandles;
v8::Isolate* m_isolate;
};
@@ -1342,12 +1339,13 @@
// restoring information about saved objects of composite types.
class Reader {
public:
- Reader(const uint8_t* buffer, int length, v8::Isolate* isolate)
+ Reader(const uint8_t* buffer, int length, v8::Isolate* isolate, const BlobDataHandleMap& blobDataHandles)
: m_buffer(buffer)
, m_length(length)
, m_position(0)
, m_version(0)
, m_isolate(isolate)
+ , m_blobDataHandles(blobDataHandles)
{
ASSERT(!(reinterpret_cast<size_t>(buffer) & 1));
ASSERT(length >= 0);
@@ -1857,17 +1855,19 @@
bool readBlob(v8::Handle<v8::Value>* value)
{
- String url;
+ if (m_version < 3)
+ return false;
+ String uuid;
String type;
uint64_t size;
- if (!readWebCoreString(&url))
+ if (!readWebCoreString(&uuid))
return false;
if (!readWebCoreString(&type))
return false;
if (!doReadUint64(&size))
return false;
- PassRefPtr<Blob> blob = Blob::create(KURL(ParsedURLString, url), type, size);
- *value = toV8(blob, v8::Handle<v8::Object>(), m_isolate);
+ RefPtr<Blob> blob = Blob::create(getOrCreateBlobDataHandle(uuid, type, size));
+ *value = toV8(blob.release(), v8::Handle<v8::Object>(), m_isolate);
return true;
}
@@ -1882,49 +1882,54 @@
return false;
if (!readWebCoreString(&url))
return false;
- RefPtr<DOMFileSystem> fs = DOMFileSystem::create(getScriptExecutionContext(), name, static_cast<WebCore::FileSystemType>(type), KURL(ParsedURLString, url));
+ RefPtr<DOMFileSystem> fs = DOMFileSystem::create(getExecutionContext(), name, static_cast<WebCore::FileSystemType>(type), KURL(ParsedURLString, url));
*value = toV8(fs.release(), v8::Handle<v8::Object>(), m_isolate);
return true;
}
bool readFile(v8::Handle<v8::Value>* value)
{
- String path;
- String url;
- String type;
- if (!readWebCoreString(&path))
+ RefPtr<File> file = doReadFileHelper();
+ if (!file)
return false;
- if (!readWebCoreString(&url))
- return false;
- if (!readWebCoreString(&type))
- return false;
- PassRefPtr<File> file = File::create(path, KURL(ParsedURLString, url), type);
- *value = toV8(file, v8::Handle<v8::Object>(), m_isolate);
+ *value = toV8(file.release(), v8::Handle<v8::Object>(), m_isolate);
return true;
}
bool readFileList(v8::Handle<v8::Value>* value)
{
+ if (m_version < 3)
+ return false;
uint32_t length;
if (!doReadUint32(&length))
return false;
- PassRefPtr<FileList> fileList = FileList::create();
+ RefPtr<FileList> fileList = FileList::create();
for (unsigned i = 0; i < length; ++i) {
- String path;
- String urlString;
- String type;
- if (!readWebCoreString(&path))
+ RefPtr<File> file = doReadFileHelper();
+ if (!file)
return false;
- if (!readWebCoreString(&urlString))
- return false;
- if (!readWebCoreString(&type))
- return false;
- fileList->append(File::create(path, KURL(ParsedURLString, urlString), type));
+ fileList->append(file.release());
}
- *value = toV8(fileList, v8::Handle<v8::Object>(), m_isolate);
+ *value = toV8(fileList.release(), v8::Handle<v8::Object>(), m_isolate);
return true;
}
+ PassRefPtr<File> doReadFileHelper()
+ {
+ if (m_version < 3)
+ return 0;
+ String path;
+ String uuid;
+ String type;
+ if (!readWebCoreString(&path))
+ return 0;
+ if (!readWebCoreString(&uuid))
+ return 0;
+ if (!readWebCoreString(&type))
+ return 0;
+ return File::create(path, getOrCreateBlobDataHandle(uuid, type));
+ }
+
template<class T>
bool doReadUintHelper(T* value)
{
@@ -1961,11 +1966,32 @@
return true;
}
+ PassRefPtr<BlobDataHandle> getOrCreateBlobDataHandle(const String& uuid, const String& type, long long size = -1)
+ {
+ // The containing ssv may have a BDH for this uuid if this ssv is just being
+ // passed from main to worker thread (for example). We use those values when creating
+ // the new blob instead of cons'ing up a new BDH.
+ //
+ // FIXME: Maybe we should require that it work that way where the ssv must have a BDH for any
+ // blobs it comes across during deserialization. Would require callers to explicitly populate
+ // the collection of BDH's for blobs to work, which would encourage lifetimes to be considered
+ // when passing ssv's around cross process. At present, we get 'lucky' in some cases because
+ // the blob in the src process happens to still exist at the time the dest process is deserializing.
+ // For example in sharedWorker.postMesssage(...).
+ BlobDataHandleMap::const_iterator it = m_blobDataHandles.find(uuid);
+ if (it != m_blobDataHandles.end()) {
+ // make assertions about type and size?
+ return it->value;
+ }
+ return BlobDataHandle::create(uuid, type, size);
+ }
+
const uint8_t* m_buffer;
const unsigned m_length;
unsigned m_position;
uint32_t m_version;
v8::Isolate* m_isolate;
+ const BlobDataHandleMap& m_blobDataHandles;
};
@@ -1984,7 +2010,7 @@
v8::Handle<v8::Value> deserialize()
{
- if (!m_reader.readVersion(m_version) || m_version > wireFormatVersion)
+ if (!m_reader.readVersion(m_version) || m_version > SerializedScriptValue::wireFormatVersion)
return v8NullWithCheck(m_reader.getIsolate());
m_reader.setVersion(m_version);
v8::HandleScope scope(m_reader.getIsolate());
@@ -2434,7 +2460,7 @@
Serializer::Status status;
{
v8::TryCatch tryCatch;
- Serializer serializer(writer, messagePorts, arrayBuffers, m_blobURLs, tryCatch, isolate);
+ Serializer serializer(writer, messagePorts, arrayBuffers, m_blobDataHandles, tryCatch, isolate);
status = serializer.serialize(value);
if (status == Serializer::JSException) {
didThrow = true;
@@ -2498,7 +2524,7 @@
// storage. Instead, it should use SharedBuffer or Vector<uint8_t>. The
// information stored in m_data isn't even encoded in UTF-16. Instead,
// unicode characters are encoded as UTF-8 with two code units per UChar.
- Reader reader(reinterpret_cast<const uint8_t*>(m_data.impl()->characters16()), 2 * m_data.length(), isolate);
+ Reader reader(reinterpret_cast<const uint8_t*>(m_data.impl()->characters16()), 2 * m_data.length(), isolate, m_blobDataHandles);
Deserializer deserializer(reader, messagePorts, m_arrayBufferContentsArray.get());
// deserialize() can run arbitrary script (e.g., setters), which could result in |this| being destroyed.
@@ -2535,9 +2561,4 @@
}
}
-uint32_t SerializedScriptValue::wireFormatVersion()
-{
- return WebCore::wireFormatVersion;
-}
-
} // namespace WebCore
diff --git a/Source/bindings/v8/SerializedScriptValue.h b/Source/bindings/v8/SerializedScriptValue.h
index b959ae1..2d94ec9 100644
--- a/Source/bindings/v8/SerializedScriptValue.h
+++ b/Source/bindings/v8/SerializedScriptValue.h
@@ -33,6 +33,7 @@
#include "bindings/v8/ScriptValue.h"
+#include "wtf/HashMap.h"
#include "wtf/ThreadSafeRefCounted.h"
#include <v8.h>
@@ -45,13 +46,20 @@
namespace WebCore {
+class BlobDataHandle;
class MessagePort;
typedef Vector<RefPtr<MessagePort>, 1> MessagePortArray;
typedef Vector<RefPtr<WTF::ArrayBuffer>, 1> ArrayBufferArray;
+typedef HashMap<String, RefPtr<BlobDataHandle> > BlobDataHandleMap;
class SerializedScriptValue : public ThreadSafeRefCounted<SerializedScriptValue> {
public:
+ // Increment this for each incompatible change to the wire format.
+ // Version 2: Added StringUCharTag for UChar v8 strings.
+ // Version 3: Switched to using uuids as blob data identifiers.
+ static const uint32_t wireFormatVersion = 3;
+
virtual ~SerializedScriptValue();
// If a serialization error occurs (e.g., cyclic input value) this
@@ -79,8 +87,6 @@
static PassRefPtr<SerializedScriptValue> numberValue(double);
static PassRefPtr<SerializedScriptValue> numberValue(double, v8::Isolate*);
- static uint32_t wireFormatVersion();
-
PassRefPtr<SerializedScriptValue> release();
String toWireString() const { return m_data; }
@@ -93,7 +99,9 @@
ScriptValue deserializeForInspector(ScriptState*);
- const Vector<String>& blobURLs() const { return m_blobURLs; }
+ // Only reflects the truth if the SSV was created by walking a v8 value, not reliable
+ // if the SSV was created createdFromWire(data).
+ bool containsBlobs() const { return !m_blobDataHandles.isEmpty(); }
// Informs the V8 about external memory allocated and owned by this object. Large values should contribute
// to GC counters to eventually trigger a GC, otherwise flood of postMessage() can cause OOM.
@@ -120,7 +128,7 @@
String m_data;
OwnPtr<ArrayBufferContentsArray> m_arrayBufferContentsArray;
- Vector<String> m_blobURLs;
+ BlobDataHandleMap m_blobDataHandles;
intptr_t m_externallyAllocatedMemory;
};
diff --git a/Source/bindings/v8/V8AbstractEventListener.cpp b/Source/bindings/v8/V8AbstractEventListener.cpp
index 7fe68ab..ea57332 100644
--- a/Source/bindings/v8/V8AbstractEventListener.cpp
+++ b/Source/bindings/v8/V8AbstractEventListener.cpp
@@ -39,9 +39,11 @@
#include "bindings/v8/V8HiddenPropertyName.h"
#include "core/events/BeforeUnloadEvent.h"
#include "core/events/Event.h"
-#include "core/events/EventNames.h"
+#include "core/events/ThreadLocalEventNames.h"
#include "core/inspector/InspectorCounters.h"
#include "core/workers/WorkerGlobalScope.h"
+#include "public/platform/Platform.h"
+#include "wtf/CurrentTime.h"
namespace WebCore {
@@ -51,7 +53,8 @@
, m_world(world)
, m_isolate(isolate)
{
- ThreadLocalInspectorCounters::current().incrementCounter(ThreadLocalInspectorCounters::JSEventListenerCounter);
+ if (isMainThread())
+ InspectorCounters::incrementCounter(InspectorCounters::JSEventListenerCounter);
}
V8AbstractEventListener::~V8AbstractEventListener()
@@ -60,10 +63,11 @@
v8::HandleScope scope(m_isolate);
V8EventListenerList::clearWrapper(m_listener.newLocal(m_isolate), m_isAttribute, m_isolate);
}
- ThreadLocalInspectorCounters::current().decrementCounter(ThreadLocalInspectorCounters::JSEventListenerCounter);
+ if (isMainThread())
+ InspectorCounters::decrementCounter(InspectorCounters::JSEventListenerCounter);
}
-void V8AbstractEventListener::handleEvent(ScriptExecutionContext* context, Event* event)
+void V8AbstractEventListener::handleEvent(ExecutionContext* context, Event* event)
{
// Don't reenter V8 if execution was terminated in this instance of V8.
if (context->isJSExecutionForbidden())
@@ -98,7 +102,7 @@
m_listener.makeWeak(this, &makeWeakCallback);
}
-void V8AbstractEventListener::invokeEventHandler(ScriptExecutionContext* context, Event* event, v8::Local<v8::Value> jsEvent)
+void V8AbstractEventListener::invokeEventHandler(ExecutionContext* context, Event* event, v8::Local<v8::Value> jsEvent)
{
// If jsEvent is empty, attempt to set it as a hidden value would crash v8.
if (jsEvent.IsEmpty())
@@ -113,9 +117,11 @@
v8::Local<v8::Value> returnValue;
// In beforeunload/unload handlers, we want to avoid sleeps which do tight loops of calling Date.getTime().
- if (event->type() == eventNames().beforeunloadEvent || event->type() == eventNames().unloadEvent)
+ if (DateExtension::get() && (event->type() == EventTypeNames::beforeunload || event->type() == EventTypeNames::unload))
DateExtension::get()->setAllowSleep(false, v8Context->GetIsolate());
+ double eventStart = currentTime();
+
{
// Catch exceptions thrown in the event handler so they do not propagate to javascript code that caused the event to fire.
v8::TryCatch tryCatch;
@@ -148,8 +154,12 @@
tryCatch.Reset();
}
- if (event->type() == eventNames().beforeunloadEvent || event->type() == eventNames().unloadEvent)
- DateExtension::get()->setAllowSleep(true, v8Context->GetIsolate());
+ if (event->type() == EventTypeNames::beforeunload || event->type() == EventTypeNames::unload) {
+ double eventEnd = currentTime();
+ WebKit::Platform::current()->histogramCustomCounts("Renderer.unloadEventsDurationMS", (eventEnd - eventStart) * 1000, 0, 5000, 30);
+ if (DateExtension::get())
+ DateExtension::get()->setAllowSleep(true, v8Context->GetIsolate());
+ }
ASSERT(!handleOutOfMemory() || returnValue.IsEmpty());
@@ -172,7 +182,7 @@
return returnValue->IsBoolean() && !returnValue->BooleanValue();
}
-v8::Local<v8::Object> V8AbstractEventListener::getReceiverObject(ScriptExecutionContext* context, Event* event)
+v8::Local<v8::Object> V8AbstractEventListener::getReceiverObject(ExecutionContext* context, Event* event)
{
v8::Isolate* isolate = toV8Context(context, world())->GetIsolate();
v8::Local<v8::Object> listener = m_listener.newLocal(isolate);
diff --git a/Source/bindings/v8/V8AbstractEventListener.h b/Source/bindings/v8/V8AbstractEventListener.h
index 1fdca6b..c4cb5d7 100644
--- a/Source/bindings/v8/V8AbstractEventListener.h
+++ b/Source/bindings/v8/V8AbstractEventListener.h
@@ -71,12 +71,12 @@
virtual bool operator==(const EventListener& other) { return this == &other; }
- virtual void handleEvent(ScriptExecutionContext*, Event*);
+ virtual void handleEvent(ExecutionContext*, Event*);
virtual bool isLazy() const { return false; }
// Returns the listener object, either a function or an object.
- v8::Local<v8::Object> getListenerObject(ScriptExecutionContext* context)
+ v8::Local<v8::Object> getListenerObject(ExecutionContext* context)
{
// prepareListenerObject can potentially deref this event listener
// as it may attempt to compile a function (lazy event listener), get an error
@@ -115,20 +115,20 @@
protected:
V8AbstractEventListener(bool isAttribute, PassRefPtr<DOMWrapperWorld>, v8::Isolate*);
- virtual void prepareListenerObject(ScriptExecutionContext*) { }
+ virtual void prepareListenerObject(ExecutionContext*) { }
void setListenerObject(v8::Handle<v8::Object> listener);
- void invokeEventHandler(ScriptExecutionContext*, Event*, v8::Local<v8::Value> jsEvent);
+ void invokeEventHandler(ExecutionContext*, Event*, v8::Local<v8::Value> jsEvent);
// Get the receiver object to use for event listener call.
- v8::Local<v8::Object> getReceiverObject(ScriptExecutionContext*, Event*);
+ v8::Local<v8::Object> getReceiverObject(ExecutionContext*, Event*);
private:
// Implementation of EventListener function.
virtual bool virtualisAttribute() const { return m_isAttribute; }
- virtual v8::Local<v8::Value> callListenerFunction(ScriptExecutionContext*, v8::Handle<v8::Value> jsevent, Event*) = 0;
+ virtual v8::Local<v8::Value> callListenerFunction(ExecutionContext*, v8::Handle<v8::Value> jsevent, Event*) = 0;
virtual bool shouldPreventDefault(v8::Local<v8::Value> returnValue);
diff --git a/Source/bindings/v8/V8Binding.cpp b/Source/bindings/v8/V8Binding.cpp
index 1901643..9afa921 100644
--- a/Source/bindings/v8/V8Binding.cpp
+++ b/Source/bindings/v8/V8Binding.cpp
@@ -50,7 +50,7 @@
#include "core/inspector/BindingVisitors.h"
#include "core/loader/FrameLoader.h"
#include "core/loader/FrameLoaderClient.h"
-#include "core/page/Frame.h"
+#include "core/frame/Frame.h"
#include "core/page/Settings.h"
#include "core/workers/WorkerGlobalScope.h"
#include "core/xml/XPathNSResolver.h"
@@ -439,18 +439,18 @@
return V8Window::toNative(window);
}
-ScriptExecutionContext* toScriptExecutionContext(v8::Handle<v8::Context> context)
+ExecutionContext* toExecutionContext(v8::Handle<v8::Context> context)
{
v8::Handle<v8::Object> global = context->Global();
v8::Handle<v8::Object> windowWrapper = global->FindInstanceInPrototypeChain(V8Window::GetTemplate(context->GetIsolate(), MainWorld));
if (!windowWrapper.IsEmpty())
- return V8Window::toNative(windowWrapper)->scriptExecutionContext();
+ return V8Window::toNative(windowWrapper)->executionContext();
windowWrapper = global->FindInstanceInPrototypeChain(V8Window::GetTemplate(context->GetIsolate(), IsolatedWorld));
if (!windowWrapper.IsEmpty())
- return V8Window::toNative(windowWrapper)->scriptExecutionContext();
+ return V8Window::toNative(windowWrapper)->executionContext();
v8::Handle<v8::Object> workerWrapper = global->FindInstanceInPrototypeChain(V8WorkerGlobalScope::GetTemplate(context->GetIsolate(), WorkerWorld));
if (!workerWrapper.IsEmpty())
- return V8WorkerGlobalScope::toNative(workerWrapper)->scriptExecutionContext();
+ return V8WorkerGlobalScope::toNative(workerWrapper)->executionContext();
// FIXME: Is this line of code reachable?
return 0;
}
@@ -467,7 +467,7 @@
return toDOMWindow(context);
}
-ScriptExecutionContext* activeScriptExecutionContext()
+ExecutionContext* activeExecutionContext()
{
v8::Handle<v8::Context> context = v8::Context::GetCalling();
if (context.IsEmpty()) {
@@ -476,7 +476,7 @@
// entered context.
context = v8::Context::GetEntered();
}
- return toScriptExecutionContext(context);
+ return toExecutionContext(context);
}
DOMWindow* firstDOMWindow()
@@ -500,7 +500,7 @@
return 0;
}
-v8::Local<v8::Context> toV8Context(ScriptExecutionContext* context, DOMWrapperWorld* world)
+v8::Local<v8::Context> toV8Context(ExecutionContext* context, DOMWrapperWorld* world)
{
if (context->isDocument()) {
ASSERT(world);
@@ -602,7 +602,7 @@
mainIsolate = isolate;
}
-v8::Isolate* toIsolate(ScriptExecutionContext* context)
+v8::Isolate* toIsolate(ExecutionContext* context)
{
if (context && context->isDocument())
return mainThreadIsolate();
diff --git a/Source/bindings/v8/V8Binding.h b/Source/bindings/v8/V8Binding.h
index 9da35ec..d00ee43 100644
--- a/Source/bindings/v8/V8Binding.h
+++ b/Source/bindings/v8/V8Binding.h
@@ -49,7 +49,7 @@
class Document;
class Frame;
class NodeFilter;
- class ScriptExecutionContext;
+ class ExecutionContext;
class ScriptWrappable;
class XPathNSResolver;
@@ -596,15 +596,15 @@
v8::Handle<v8::Object> toInnerGlobalObject(v8::Handle<v8::Context>);
DOMWindow* toDOMWindow(v8::Handle<v8::Context>);
- ScriptExecutionContext* toScriptExecutionContext(v8::Handle<v8::Context>);
+ ExecutionContext* toExecutionContext(v8::Handle<v8::Context>);
DOMWindow* activeDOMWindow();
- ScriptExecutionContext* activeScriptExecutionContext();
+ ExecutionContext* activeExecutionContext();
DOMWindow* firstDOMWindow();
Document* currentDocument();
- // Returns the context associated with a ScriptExecutionContext.
- v8::Local<v8::Context> toV8Context(ScriptExecutionContext*, DOMWrapperWorld*);
+ // Returns the context associated with a ExecutionContext.
+ v8::Local<v8::Context> toV8Context(ExecutionContext*, DOMWrapperWorld*);
// Returns the frame object of the window object associated with
// a context, if the window is currently being displayed in the Frame.
@@ -655,7 +655,7 @@
v8::Local<v8::Value> getHiddenValueFromMainWorldWrapper(v8::Isolate*, ScriptWrappable*, v8::Handle<v8::String> key);
v8::Isolate* mainThreadIsolate();
- v8::Isolate* toIsolate(ScriptExecutionContext*);
+ v8::Isolate* toIsolate(ExecutionContext*);
v8::Isolate* toIsolate(Frame*);
// Can only be called by WebKit::initialize
diff --git a/Source/bindings/v8/V8Callback.cpp b/Source/bindings/v8/V8Callback.cpp
index 33ba790..543b1bf 100644
--- a/Source/bindings/v8/V8Callback.cpp
+++ b/Source/bindings/v8/V8Callback.cpp
@@ -36,12 +36,12 @@
namespace WebCore {
-bool invokeCallback(v8::Handle<v8::Object> callback, int argc, v8::Handle<v8::Value> argv[], bool& callbackReturnValue, ScriptExecutionContext* scriptExecutionContext, v8::Isolate* isolate)
+bool invokeCallback(v8::Handle<v8::Object> callback, int argc, v8::Handle<v8::Value> argv[], bool& callbackReturnValue, ExecutionContext* executionContext, v8::Isolate* isolate)
{
- return invokeCallback(callback, v8::Context::GetCurrent()->Global(), argc, argv, callbackReturnValue, scriptExecutionContext, isolate);
+ return invokeCallback(callback, v8::Context::GetCurrent()->Global(), argc, argv, callbackReturnValue, executionContext, isolate);
}
-bool invokeCallback(v8::Handle<v8::Object> callback, v8::Handle<v8::Object> thisObject, int argc, v8::Handle<v8::Value> argv[], bool& callbackReturnValue, ScriptExecutionContext* scriptExecutionContext, v8::Isolate* isolate)
+bool invokeCallback(v8::Handle<v8::Object> callback, v8::Handle<v8::Object> thisObject, int argc, v8::Handle<v8::Value> argv[], bool& callbackReturnValue, ExecutionContext* executionContext, v8::Isolate* isolate)
{
v8::TryCatch exceptionCatcher;
exceptionCatcher.SetVerbose(true);
@@ -59,7 +59,7 @@
if (callbackFunction.IsEmpty())
return false;
- v8::Handle<v8::Value> result = ScriptController::callFunctionWithInstrumentation(scriptExecutionContext, callbackFunction, thisObject, argc, argv, isolate);
+ v8::Handle<v8::Value> result = ScriptController::callFunction(executionContext, callbackFunction, thisObject, argc, argv, isolate);
callbackReturnValue = !result.IsEmpty() && result->BooleanValue();
return exceptionCatcher.HasCaught();
diff --git a/Source/bindings/v8/V8Callback.h b/Source/bindings/v8/V8Callback.h
index bfcaa60..c514f67 100644
--- a/Source/bindings/v8/V8Callback.h
+++ b/Source/bindings/v8/V8Callback.h
@@ -38,10 +38,10 @@
namespace WebCore {
-class ScriptExecutionContext;
+class ExecutionContext;
-bool invokeCallback(v8::Handle<v8::Object> callback, int argc, v8::Handle<v8::Value> argv[], bool& callbackReturnValue, ScriptExecutionContext*, v8::Isolate*);
-bool invokeCallback(v8::Handle<v8::Object> callback, v8::Handle<v8::Object> thisObject, int argc, v8::Handle<v8::Value> argv[], bool& callbackReturnValue, ScriptExecutionContext*, v8::Isolate*);
+bool invokeCallback(v8::Handle<v8::Object> callback, int argc, v8::Handle<v8::Value> argv[], bool& callbackReturnValue, ExecutionContext*, v8::Isolate*);
+bool invokeCallback(v8::Handle<v8::Object> callback, v8::Handle<v8::Object> thisObject, int argc, v8::Handle<v8::Value> argv[], bool& callbackReturnValue, ExecutionContext*, v8::Isolate*);
enum CallbackAllowedValueFlag {
CallbackAllowUndefined = 1,
@@ -68,7 +68,7 @@
return 0;
}
- return V8CallbackType::create(value, getScriptExecutionContext());
+ return V8CallbackType::create(value, getExecutionContext());
}
} // namespace WebCore
diff --git a/Source/bindings/v8/V8CustomElementLifecycleCallbacks.cpp b/Source/bindings/v8/V8CustomElementLifecycleCallbacks.cpp
index 1c3e3c8..5078be0 100644
--- a/Source/bindings/v8/V8CustomElementLifecycleCallbacks.cpp
+++ b/Source/bindings/v8/V8CustomElementLifecycleCallbacks.cpp
@@ -38,7 +38,7 @@
#include "bindings/v8/V8Binding.h"
#include "bindings/v8/V8HiddenPropertyName.h"
#include "bindings/v8/V8PerContextData.h"
-#include "core/dom/ScriptExecutionContext.h"
+#include "core/dom/ExecutionContext.h"
#include "wtf/PassOwnPtr.h"
namespace WebCore {
@@ -49,9 +49,9 @@
V(leftView, LeftView) \
V(attributeChanged, AttributeChanged)
-PassRefPtr<V8CustomElementLifecycleCallbacks> V8CustomElementLifecycleCallbacks::create(ScriptExecutionContext* scriptExecutionContext, v8::Handle<v8::Object> prototype, v8::Handle<v8::Function> created, v8::Handle<v8::Function> enteredView, v8::Handle<v8::Function> leftView, v8::Handle<v8::Function> attributeChanged)
+PassRefPtr<V8CustomElementLifecycleCallbacks> V8CustomElementLifecycleCallbacks::create(ExecutionContext* executionContext, v8::Handle<v8::Object> prototype, v8::Handle<v8::Function> created, v8::Handle<v8::Function> enteredView, v8::Handle<v8::Function> leftView, v8::Handle<v8::Function> attributeChanged)
{
- v8::Isolate* isolate = toIsolate(scriptExecutionContext);
+ v8::Isolate* isolate = toIsolate(executionContext);
// A given object can only be used as a Custom Element prototype
// once; see customElementIsInterfacePrototypeObject
#define SET_HIDDEN_PROPERTY(Value, Name) \
@@ -62,7 +62,7 @@
CALLBACK_LIST(SET_HIDDEN_PROPERTY)
#undef SET_HIDDEN_PROPERTY
- return adoptRef(new V8CustomElementLifecycleCallbacks(scriptExecutionContext, prototype, created, enteredView, leftView, attributeChanged));
+ return adoptRef(new V8CustomElementLifecycleCallbacks(executionContext, prototype, created, enteredView, leftView, attributeChanged));
}
static CustomElementLifecycleCallbacks::CallbackType flagSet(v8::Handle<v8::Function> enteredView, v8::Handle<v8::Function> leftView, v8::Handle<v8::Function> attributeChanged)
@@ -88,15 +88,15 @@
handle->clear();
}
-V8CustomElementLifecycleCallbacks::V8CustomElementLifecycleCallbacks(ScriptExecutionContext* scriptExecutionContext, v8::Handle<v8::Object> prototype, v8::Handle<v8::Function> created, v8::Handle<v8::Function> enteredView, v8::Handle<v8::Function> leftView, v8::Handle<v8::Function> attributeChanged)
+V8CustomElementLifecycleCallbacks::V8CustomElementLifecycleCallbacks(ExecutionContext* executionContext, v8::Handle<v8::Object> prototype, v8::Handle<v8::Function> created, v8::Handle<v8::Function> enteredView, v8::Handle<v8::Function> leftView, v8::Handle<v8::Function> attributeChanged)
: CustomElementLifecycleCallbacks(flagSet(enteredView, leftView, attributeChanged))
- , ActiveDOMCallback(scriptExecutionContext)
+ , ActiveDOMCallback(executionContext)
, m_world(DOMWrapperWorld::current())
- , m_prototype(toIsolate(scriptExecutionContext), prototype)
- , m_created(toIsolate(scriptExecutionContext), created)
- , m_enteredView(toIsolate(scriptExecutionContext), enteredView)
- , m_leftView(toIsolate(scriptExecutionContext), leftView)
- , m_attributeChanged(toIsolate(scriptExecutionContext), attributeChanged)
+ , m_prototype(toIsolate(executionContext), prototype)
+ , m_created(toIsolate(executionContext), created)
+ , m_enteredView(toIsolate(executionContext), enteredView)
+ , m_leftView(toIsolate(executionContext), leftView)
+ , m_attributeChanged(toIsolate(executionContext), attributeChanged)
, m_owner(0)
{
m_prototype.makeWeak(&m_prototype, weakCallback<v8::Object>);
@@ -111,10 +111,10 @@
V8PerContextData* V8CustomElementLifecycleCallbacks::creationContextData()
{
- if (!scriptExecutionContext())
+ if (!executionContext())
return 0;
- v8::Handle<v8::Context> context = toV8Context(scriptExecutionContext(), m_world.get());
+ v8::Handle<v8::Context> context = toV8Context(executionContext(), m_world.get());
if (context.IsEmpty())
return 0;
@@ -126,7 +126,7 @@
if (!m_owner)
return;
- v8::HandleScope handleScope(toIsolate(scriptExecutionContext()));
+ v8::HandleScope handleScope(toIsolate(executionContext()));
if (V8PerContextData* perContextData = creationContextData())
perContextData->clearCustomElementBinding(m_owner);
}
@@ -154,9 +154,9 @@
element->setCustomElementState(Element::Upgraded);
- v8::Isolate* isolate = toIsolate(scriptExecutionContext());
+ v8::Isolate* isolate = toIsolate(executionContext());
v8::HandleScope handleScope(isolate);
- v8::Handle<v8::Context> context = toV8Context(scriptExecutionContext(), m_world.get());
+ v8::Handle<v8::Context> context = toV8Context(executionContext(), m_world.get());
if (context.IsEmpty())
return;
@@ -184,7 +184,7 @@
v8::TryCatch exceptionCatcher;
exceptionCatcher.SetVerbose(true);
- ScriptController::callFunctionWithInstrumentation(scriptExecutionContext(), callback, receiver, 0, 0, isolate);
+ ScriptController::callFunction(executionContext(), callback, receiver, 0, 0, isolate);
}
void V8CustomElementLifecycleCallbacks::enteredView(Element* element)
@@ -202,9 +202,9 @@
if (!canInvokeCallback())
return;
- v8::Isolate* isolate = toIsolate(scriptExecutionContext());
+ v8::Isolate* isolate = toIsolate(executionContext());
v8::HandleScope handleScope(isolate);
- v8::Handle<v8::Context> context = toV8Context(scriptExecutionContext(), m_world.get());
+ v8::Handle<v8::Context> context = toV8Context(executionContext(), m_world.get());
if (context.IsEmpty())
return;
@@ -225,7 +225,7 @@
v8::TryCatch exceptionCatcher;
exceptionCatcher.SetVerbose(true);
- ScriptController::callFunctionWithInstrumentation(scriptExecutionContext(), callback, receiver, WTF_ARRAY_LENGTH(argv), argv, isolate);
+ ScriptController::callFunction(executionContext(), callback, receiver, WTF_ARRAY_LENGTH(argv), argv, isolate);
}
void V8CustomElementLifecycleCallbacks::call(const ScopedPersistent<v8::Function>& weakCallback, Element* element)
@@ -233,8 +233,8 @@
if (!canInvokeCallback())
return;
- v8::HandleScope handleScope(toIsolate(scriptExecutionContext()));
- v8::Handle<v8::Context> context = toV8Context(scriptExecutionContext(), m_world.get());
+ v8::HandleScope handleScope(toIsolate(executionContext()));
+ v8::Handle<v8::Context> context = toV8Context(executionContext(), m_world.get());
if (context.IsEmpty())
return;
@@ -250,7 +250,7 @@
v8::TryCatch exceptionCatcher;
exceptionCatcher.SetVerbose(true);
- ScriptController::callFunctionWithInstrumentation(scriptExecutionContext(), callback, receiver, 0, 0, isolate);
+ ScriptController::callFunction(executionContext(), callback, receiver, 0, 0, isolate);
}
} // namespace WebCore
diff --git a/Source/bindings/v8/V8CustomElementLifecycleCallbacks.h b/Source/bindings/v8/V8CustomElementLifecycleCallbacks.h
index c504ea5..0135463 100644
--- a/Source/bindings/v8/V8CustomElementLifecycleCallbacks.h
+++ b/Source/bindings/v8/V8CustomElementLifecycleCallbacks.h
@@ -34,7 +34,7 @@
#include "bindings/v8/ActiveDOMCallback.h"
#include "bindings/v8/DOMWrapperWorld.h"
#include "bindings/v8/ScopedPersistent.h"
-#include "core/dom/CustomElementLifecycleCallbacks.h"
+#include "core/dom/custom/CustomElementLifecycleCallbacks.h"
#include "wtf/PassOwnPtr.h"
#include "wtf/PassRefPtr.h"
#include <v8.h>
@@ -43,19 +43,19 @@
class CustomElementLifecycleCallbacks;
class Element;
-class ScriptExecutionContext;
+class ExecutionContext;
class V8PerContextData;
class V8CustomElementLifecycleCallbacks : public CustomElementLifecycleCallbacks, ActiveDOMCallback {
public:
- static PassRefPtr<V8CustomElementLifecycleCallbacks> create(ScriptExecutionContext*, v8::Handle<v8::Object> prototype, v8::Handle<v8::Function> created, v8::Handle<v8::Function> enteredView, v8::Handle<v8::Function> leftView, v8::Handle<v8::Function> attributeChanged);
+ static PassRefPtr<V8CustomElementLifecycleCallbacks> create(ExecutionContext*, v8::Handle<v8::Object> prototype, v8::Handle<v8::Function> created, v8::Handle<v8::Function> enteredView, v8::Handle<v8::Function> leftView, v8::Handle<v8::Function> attributeChanged);
virtual ~V8CustomElementLifecycleCallbacks();
bool setBinding(CustomElementDefinition* owner, PassOwnPtr<CustomElementBinding>);
private:
- V8CustomElementLifecycleCallbacks(ScriptExecutionContext*, v8::Handle<v8::Object> prototype, v8::Handle<v8::Function> created, v8::Handle<v8::Function> enteredView, v8::Handle<v8::Function> leftView, v8::Handle<v8::Function> attributeChanged);
+ V8CustomElementLifecycleCallbacks(ExecutionContext*, v8::Handle<v8::Object> prototype, v8::Handle<v8::Function> created, v8::Handle<v8::Function> enteredView, v8::Handle<v8::Function> leftView, v8::Handle<v8::Function> attributeChanged);
virtual void created(Element*) OVERRIDE;
virtual void enteredView(Element*) OVERRIDE;
diff --git a/Source/bindings/v8/V8DOMConfiguration.cpp b/Source/bindings/v8/V8DOMConfiguration.cpp
index a266907..986c455 100644
--- a/Source/bindings/v8/V8DOMConfiguration.cpp
+++ b/Source/bindings/v8/V8DOMConfiguration.cpp
@@ -43,8 +43,8 @@
{
for (size_t i = 0; i < constantCount; ++i) {
const ConstantConfiguration* constant = &constants[i];
- functionDescriptor->Set(v8::String::NewSymbol(constant->name), v8::Integer::New(constant->value, isolate), v8::ReadOnly);
- prototype->Set(v8::String::NewSymbol(constant->name), v8::Integer::New(constant->value, isolate), v8::ReadOnly);
+ functionDescriptor->Set(v8::String::NewSymbol(constant->name), v8::Integer::New(constant->value, isolate), static_cast<v8::PropertyAttribute>(v8::ReadOnly | v8::DontDelete));
+ prototype->Set(v8::String::NewSymbol(constant->name), v8::Integer::New(constant->value, isolate), static_cast<v8::PropertyAttribute>(v8::ReadOnly | v8::DontDelete));
}
}
diff --git a/Source/bindings/v8/V8ErrorHandler.cpp b/Source/bindings/v8/V8ErrorHandler.cpp
index 328378c..bcded3b 100644
--- a/Source/bindings/v8/V8ErrorHandler.cpp
+++ b/Source/bindings/v8/V8ErrorHandler.cpp
@@ -37,10 +37,10 @@
#include "bindings/v8/V8HiddenPropertyName.h"
#include "bindings/v8/V8ScriptRunner.h"
#include "core/dom/Document.h"
+#include "core/dom/ExecutionContext.h"
#include "core/events/ErrorEvent.h"
-#include "core/events/EventNames.h"
-#include "core/dom/ScriptExecutionContext.h"
-#include "core/page/Frame.h"
+#include "core/events/ThreadLocalEventNames.h"
+#include "core/frame/Frame.h"
namespace WebCore {
@@ -49,9 +49,9 @@
{
}
-v8::Local<v8::Value> V8ErrorHandler::callListenerFunction(ScriptExecutionContext* context, v8::Handle<v8::Value> jsEvent, Event* event)
+v8::Local<v8::Value> V8ErrorHandler::callListenerFunction(ExecutionContext* context, v8::Handle<v8::Value> jsEvent, Event* event)
{
- if (!event->hasInterface(eventNames().interfaceForErrorEvent))
+ if (!event->hasInterface(EventNames::ErrorEvent))
return V8EventListener::callListenerFunction(context, jsEvent, event);
ErrorEvent* errorEvent = static_cast<ErrorEvent*>(event);
@@ -76,7 +76,7 @@
if (worldType(isolate) == WorkerWorld)
returnValue = V8ScriptRunner::callFunction(callFunction, context, thisValue, WTF_ARRAY_LENGTH(parameters), parameters, isolate);
else
- returnValue = ScriptController::callFunctionWithInstrumentation(0, callFunction, thisValue, WTF_ARRAY_LENGTH(parameters), parameters, isolate);
+ returnValue = ScriptController::callFunction(context, callFunction, thisValue, WTF_ARRAY_LENGTH(parameters), parameters, isolate);
}
return returnValue;
}
diff --git a/Source/bindings/v8/V8ErrorHandler.h b/Source/bindings/v8/V8ErrorHandler.h
index faaf430..cfaa69d 100644
--- a/Source/bindings/v8/V8ErrorHandler.h
+++ b/Source/bindings/v8/V8ErrorHandler.h
@@ -52,7 +52,7 @@
private:
V8ErrorHandler(v8::Local<v8::Object> listener, bool isInline, v8::Isolate*);
- virtual v8::Local<v8::Value> callListenerFunction(ScriptExecutionContext*, v8::Handle<v8::Value> jsEvent, Event*);
+ virtual v8::Local<v8::Value> callListenerFunction(ExecutionContext*, v8::Handle<v8::Value> jsEvent, Event*);
virtual bool shouldPreventDefault(v8::Local<v8::Value> returnValue);
};
diff --git a/Source/bindings/v8/V8EventListener.cpp b/Source/bindings/v8/V8EventListener.cpp
index 687e33e..053b2bd 100644
--- a/Source/bindings/v8/V8EventListener.cpp
+++ b/Source/bindings/v8/V8EventListener.cpp
@@ -33,7 +33,7 @@
#include "bindings/v8/ScriptController.h"
#include "core/dom/Document.h"
-#include "core/page/Frame.h"
+#include "core/frame/Frame.h"
namespace WebCore {
@@ -43,7 +43,7 @@
setListenerObject(listener);
}
-v8::Local<v8::Function> V8EventListener::getListenerFunction(ScriptExecutionContext* context)
+v8::Local<v8::Function> V8EventListener::getListenerFunction(ExecutionContext* context)
{
v8::Local<v8::Object> listener = getListenerObject(context);
@@ -66,7 +66,7 @@
return v8::Local<v8::Function>();
}
-v8::Local<v8::Value> V8EventListener::callListenerFunction(ScriptExecutionContext* context, v8::Handle<v8::Value> jsEvent, Event* event)
+v8::Local<v8::Value> V8EventListener::callListenerFunction(ExecutionContext* context, v8::Handle<v8::Value> jsEvent, Event* event)
{
v8::Local<v8::Function> handlerFunction = getListenerFunction(context);
diff --git a/Source/bindings/v8/V8EventListener.h b/Source/bindings/v8/V8EventListener.h
index 38ca53e..1358848 100644
--- a/Source/bindings/v8/V8EventListener.h
+++ b/Source/bindings/v8/V8EventListener.h
@@ -53,9 +53,9 @@
protected:
V8EventListener(v8::Local<v8::Object> listener, bool isAttribute, v8::Isolate*);
- v8::Local<v8::Function> getListenerFunction(ScriptExecutionContext*);
+ v8::Local<v8::Function> getListenerFunction(ExecutionContext*);
- virtual v8::Local<v8::Value> callListenerFunction(ScriptExecutionContext*, v8::Handle<v8::Value> jsEvent, Event*);
+ virtual v8::Local<v8::Value> callListenerFunction(ExecutionContext*, v8::Handle<v8::Value> jsEvent, Event*);
};
} // namespace WebCore
diff --git a/Source/bindings/v8/V8GCController.cpp b/Source/bindings/v8/V8GCController.cpp
index ab880d8..d19dd64 100644
--- a/Source/bindings/v8/V8GCController.cpp
+++ b/Source/bindings/v8/V8GCController.cpp
@@ -31,6 +31,7 @@
#include "config.h"
#include "bindings/v8/V8GCController.h"
+#include <algorithm>
#include "V8MessagePort.h"
#include "V8MutationObserver.h"
#include "V8Node.h"
@@ -44,8 +45,7 @@
#include "core/dom/shadow/ElementShadow.h"
#include "core/dom/shadow/ShadowRoot.h"
#include "core/html/HTMLImageElement.h"
-#include "core/platform/chromium/TraceEvent.h"
-#include <algorithm>
+#include "platform/TraceEvent.h"
namespace WebCore {
diff --git a/Source/bindings/v8/V8GCForContextDispose.h b/Source/bindings/v8/V8GCForContextDispose.h
index ae338a6..d6b3a0e 100644
--- a/Source/bindings/v8/V8GCForContextDispose.h
+++ b/Source/bindings/v8/V8GCForContextDispose.h
@@ -31,8 +31,8 @@
#ifndef V8GCForContextDispose_h
#define V8GCForContextDispose_h
-#include "core/platform/Timer.h"
#include <v8.h>
+#include "platform/Timer.h"
namespace WebCore {
diff --git a/Source/bindings/v8/V8HiddenPropertyName.h b/Source/bindings/v8/V8HiddenPropertyName.h
index 066536d..48093af 100644
--- a/Source/bindings/v8/V8HiddenPropertyName.h
+++ b/Source/bindings/v8/V8HiddenPropertyName.h
@@ -59,7 +59,8 @@
V(sleepFunction) \
V(state) \
V(toStringString) \
- V(typedArrayHiddenCopyMethod)
+ V(typedArrayHiddenCopyMethod) \
+ V(thenableHiddenPromise)
class V8HiddenPropertyName {
public:
diff --git a/Source/bindings/v8/V8Initializer.cpp b/Source/bindings/v8/V8Initializer.cpp
index 8f00688..7e6e1cf 100644
--- a/Source/bindings/v8/V8Initializer.cpp
+++ b/Source/bindings/v8/V8Initializer.cpp
@@ -43,14 +43,15 @@
#include "core/dom/Document.h"
#include "core/dom/ExceptionCode.h"
#include "core/inspector/ScriptCallStack.h"
-#include "core/page/ConsoleTypes.h"
-#include "core/page/ContentSecurityPolicy.h"
-#include "core/page/DOMWindow.h"
-#include "core/page/Frame.h"
+#include "core/frame/ConsoleTypes.h"
+#include "core/frame/ContentSecurityPolicy.h"
+#include "core/frame/DOMWindow.h"
+#include "core/frame/Frame.h"
#include "core/platform/MemoryUsageSupport.h"
#include "wtf/RefPtr.h"
#include "wtf/text/WTFString.h"
#include <v8-debug.h>
+#include <v8-defaults.h>
namespace WebCore {
@@ -85,7 +86,12 @@
static void messageHandlerInMainThread(v8::Handle<v8::Message> message, v8::Handle<v8::Value> data)
{
- DOMWindow* firstWindow = firstDOMWindow();
+ // If called during context initialization, there will be no entered context.
+ v8::Handle<v8::Context> enteredContext = v8::Context::GetEntered();
+ if (enteredContext.IsEmpty())
+ return;
+
+ DOMWindow* firstWindow = toDOMWindow(enteredContext);
if (!firstWindow->isCurrentlyDisplayedInFrame())
return;
@@ -115,6 +121,7 @@
// This method might be called while we're creating a new context. In this case, we
// avoid storing the exception object, as we can't create a wrapper during context creation.
+ // FIXME: Can we even get here during initialization now that we bail out when GetEntered returns an empty handle?
DOMWrapperWorld* world = DOMWrapperWorld::current();
Frame* frame = firstWindow->document()->frame();
if (world && frame && frame->script()->existingWindowShell(world))
@@ -136,8 +143,8 @@
static bool codeGenerationCheckCallbackInMainThread(v8::Local<v8::Context> context)
{
- if (ScriptExecutionContext* scriptExecutionContext = toScriptExecutionContext(context)) {
- if (ContentSecurityPolicy* policy = toDocument(scriptExecutionContext)->contentSecurityPolicy())
+ if (ExecutionContext* executionContext = toExecutionContext(context)) {
+ if (ContentSecurityPolicy* policy = toDocument(executionContext)->contentSecurityPolicy())
return policy->allowEval(ScriptState::forContext(context));
}
return false;
@@ -167,6 +174,7 @@
v8::V8::AddMessageListener(messageHandlerInMainThread);
v8::V8::SetFailedAccessCheckCallbackFunction(failedAccessCheckCallbackInMainThread);
v8::V8::SetAllowCodeGenerationFromStringsCallback(codeGenerationCheckCallbackInMainThread);
+ v8::SetDefaultResourceConstraintsForCurrentPlatform();
ScriptProfiler::initialize();
V8PerIsolateData::ensureInitialized(isolate);
}
@@ -187,7 +195,7 @@
isReportingException = true;
// During the frame teardown, there may not be a valid context.
- if (ScriptExecutionContext* context = getScriptExecutionContext()) {
+ if (ExecutionContext* context = getExecutionContext()) {
String errorMessage = toWebCoreString(message->Get());
String sourceURL = toWebCoreString(message->GetScriptResourceName());
RefPtr<ErrorEvent> event = ErrorEvent::create(errorMessage, sourceURL, message->GetLineNumber(), message->GetStartColumn(), DOMWrapperWorld::current());
@@ -210,6 +218,7 @@
v8::V8::SetFatalErrorHandler(reportFatalErrorInWorker);
v8::ResourceConstraints resourceConstraints;
+ v8::ConfigureResourceConstraintsForCurrentPlatform(&resourceConstraints);
uint32_t here;
resourceConstraints.set_stack_limit(&here - kWorkerMaxStackSize / sizeof(uint32_t*));
v8::SetResourceConstraints(&resourceConstraints);
diff --git a/Source/bindings/v8/V8LazyEventListener.cpp b/Source/bindings/v8/V8LazyEventListener.cpp
index 50a6e65..03b2025 100644
--- a/Source/bindings/v8/V8LazyEventListener.cpp
+++ b/Source/bindings/v8/V8LazyEventListener.cpp
@@ -45,8 +45,8 @@
#include "core/html/HTMLElement.h"
#include "core/html/HTMLFormElement.h"
#include "core/inspector/InspectorInstrumentation.h"
-#include "core/page/ContentSecurityPolicy.h"
-#include "core/page/Frame.h"
+#include "core/frame/ContentSecurityPolicy.h"
+#include "core/frame/Frame.h"
#include "wtf/StdLibExtras.h"
@@ -74,7 +74,7 @@
return v8::Local<v8::Object>::New(isolate, value.As<v8::Object>());
}
-v8::Local<v8::Value> V8LazyEventListener::callListenerFunction(ScriptExecutionContext* context, v8::Handle<v8::Value> jsEvent, Event* event)
+v8::Local<v8::Value> V8LazyEventListener::callListenerFunction(ExecutionContext* context, v8::Handle<v8::Value> jsEvent, Event* event)
{
v8::Local<v8::Object> listenerObject = getListenerObject(context);
if (listenerObject.IsEmpty())
@@ -108,7 +108,7 @@
v8SetReturnValue(args, args.Holder()->GetHiddenValue(V8HiddenPropertyName::toStringString(args.GetIsolate())));
}
-void V8LazyEventListener::prepareListenerObject(ScriptExecutionContext* context)
+void V8LazyEventListener::prepareListenerObject(ExecutionContext* context)
{
if (context->isDocument() && !toDocument(context)->allowInlineEventHandlers(m_node, this, m_sourceURL, m_position.m_line)) {
clearListenerObject();
diff --git a/Source/bindings/v8/V8LazyEventListener.h b/Source/bindings/v8/V8LazyEventListener.h
index 415d9fe..4bc040f 100644
--- a/Source/bindings/v8/V8LazyEventListener.h
+++ b/Source/bindings/v8/V8LazyEventListener.h
@@ -56,12 +56,12 @@
virtual bool isLazy() const { return true; }
protected:
- virtual void prepareListenerObject(ScriptExecutionContext*);
+ virtual void prepareListenerObject(ExecutionContext*);
private:
V8LazyEventListener(const AtomicString& functionName, const AtomicString& eventParameterName, const String& code, const String sourceURL, const TextPosition&, Node*, v8::Isolate*);
- virtual v8::Local<v8::Value> callListenerFunction(ScriptExecutionContext*, v8::Handle<v8::Value> jsEvent, Event*);
+ virtual v8::Local<v8::Value> callListenerFunction(ExecutionContext*, v8::Handle<v8::Value> jsEvent, Event*);
// Needs to return true for all event handlers implemented in JavaScript so that
// the SVG code does not add the event handler in both
diff --git a/Source/bindings/v8/V8MutationCallback.cpp b/Source/bindings/v8/V8MutationCallback.cpp
index bd8733d..c4f944c 100644
--- a/Source/bindings/v8/V8MutationCallback.cpp
+++ b/Source/bindings/v8/V8MutationCallback.cpp
@@ -31,12 +31,12 @@
#include "bindings/v8/ScriptController.h"
#include "bindings/v8/V8Binding.h"
#include "bindings/v8/V8HiddenPropertyName.h"
-#include "core/dom/ScriptExecutionContext.h"
+#include "core/dom/ExecutionContext.h"
#include "wtf/Assertions.h"
namespace WebCore {
-V8MutationCallback::V8MutationCallback(v8::Handle<v8::Function> callback, ScriptExecutionContext* context, v8::Handle<v8::Object> owner, v8::Isolate* isolate)
+V8MutationCallback::V8MutationCallback(v8::Handle<v8::Function> callback, ExecutionContext* context, v8::Handle<v8::Object> owner, v8::Isolate* isolate)
: ActiveDOMCallback(context)
, m_callback(isolate, callback)
, m_world(DOMWrapperWorld::current())
@@ -53,7 +53,7 @@
v8::HandleScope handleScope(m_isolate);
- v8::Handle<v8::Context> v8Context = toV8Context(scriptExecutionContext(), m_world.get());
+ v8::Handle<v8::Context> v8Context = toV8Context(executionContext(), m_world.get());
if (v8Context.IsEmpty())
return;
@@ -78,7 +78,7 @@
v8::TryCatch exceptionCatcher;
exceptionCatcher.SetVerbose(true);
- ScriptController::callFunctionWithInstrumentation(scriptExecutionContext(), callback, thisObject, 2, argv, m_isolate);
+ ScriptController::callFunction(executionContext(), callback, thisObject, 2, argv, m_isolate);
}
void V8MutationCallback::makeWeakCallback(v8::Isolate*, v8::Persistent<v8::Function>*, V8MutationCallback* callback)
diff --git a/Source/bindings/v8/V8MutationCallback.h b/Source/bindings/v8/V8MutationCallback.h
index 1261250..ad225c9 100644
--- a/Source/bindings/v8/V8MutationCallback.h
+++ b/Source/bindings/v8/V8MutationCallback.h
@@ -36,21 +36,21 @@
namespace WebCore {
-class ScriptExecutionContext;
+class ExecutionContext;
class V8MutationCallback : public MutationCallback, public ActiveDOMCallback {
public:
- static PassRefPtr<V8MutationCallback> create(v8::Handle<v8::Function> callback, ScriptExecutionContext* context, v8::Handle<v8::Object> owner, v8::Isolate* isolate)
+ static PassRefPtr<V8MutationCallback> create(v8::Handle<v8::Function> callback, ExecutionContext* context, v8::Handle<v8::Object> owner, v8::Isolate* isolate)
{
ASSERT(context);
return adoptRef(new V8MutationCallback(callback, context, owner, isolate));
}
virtual void call(const Vector<RefPtr<MutationRecord> >&, MutationObserver*) OVERRIDE;
- virtual ScriptExecutionContext* scriptExecutionContext() const OVERRIDE { return ContextLifecycleObserver::scriptExecutionContext(); }
+ virtual ExecutionContext* executionContext() const OVERRIDE { return ContextLifecycleObserver::executionContext(); }
private:
- V8MutationCallback(v8::Handle<v8::Function>, ScriptExecutionContext*, v8::Handle<v8::Object>, v8::Isolate*);
+ V8MutationCallback(v8::Handle<v8::Function>, ExecutionContext*, v8::Handle<v8::Object>, v8::Isolate*);
static void makeWeakCallback(v8::Isolate*, v8::Persistent<v8::Function>*, V8MutationCallback*);
diff --git a/Source/bindings/v8/V8NPObject.cpp b/Source/bindings/v8/V8NPObject.cpp
index 00eaed8..de4f136 100644
--- a/Source/bindings/v8/V8NPObject.cpp
+++ b/Source/bindings/v8/V8NPObject.cpp
@@ -43,7 +43,7 @@
#include "bindings/v8/npruntime_impl.h"
#include "bindings/v8/npruntime_priv.h"
#include "core/html/HTMLPlugInElement.h"
-#include "wtf/OwnArrayPtr.h"
+#include "wtf/OwnPtr.h"
namespace WebCore {
@@ -82,11 +82,10 @@
element = V8HTMLEmbedElement::toNative(args.Holder());
else
element = V8HTMLObjectElement::toNative(args.Holder());
- ScriptInstance scriptInstance = element->getInstance();
- if (scriptInstance) {
+ if (RefPtr<SharedPersistent<v8::Object> > wrapper = element->pluginWrapper()) {
v8::Isolate* isolate = v8::Isolate::GetCurrent();
v8::HandleScope handleScope(isolate);
- npObject = v8ObjectToNPObject(scriptInstance->newLocal(isolate));
+ npObject = v8ObjectToNPObject(wrapper->newLocal(isolate));
} else
npObject = 0;
} else {
@@ -108,7 +107,7 @@
// Wrap up parameters.
int numArgs = args.Length();
- OwnArrayPtr<NPVariant> npArgs = adoptArrayPtr(new NPVariant[numArgs]);
+ OwnPtr<NPVariant[]> npArgs = adoptArrayPtr(new NPVariant[numArgs]);
for (int i = 0; i < numArgs; i++)
convertV8ObjectToNPVariant(args[i], npObject, &npArgs[i], args.GetIsolate());
diff --git a/Source/bindings/v8/V8NPUtils.cpp b/Source/bindings/v8/V8NPUtils.cpp
index b54f747..779b0a9 100644
--- a/Source/bindings/v8/V8NPUtils.cpp
+++ b/Source/bindings/v8/V8NPUtils.cpp
@@ -36,7 +36,7 @@
#include "bindings/v8/V8NPObject.h"
#include "bindings/v8/npruntime_impl.h"
#include "bindings/v8/npruntime_priv.h"
-#include "core/page/DOMWindow.h"
+#include "core/frame/DOMWindow.h"
#include "wtf/text/WTFString.h"
namespace WebCore {
diff --git a/Source/bindings/v8/V8NodeFilterCondition.cpp b/Source/bindings/v8/V8NodeFilterCondition.cpp
index 58e8b9b..9502008 100644
--- a/Source/bindings/v8/V8NodeFilterCondition.cpp
+++ b/Source/bindings/v8/V8NodeFilterCondition.cpp
@@ -37,7 +37,7 @@
#include "bindings/v8/V8HiddenPropertyName.h"
#include "core/dom/Node.h"
#include "core/dom/NodeFilter.h"
-#include "wtf/OwnArrayPtr.h"
+#include "wtf/OwnPtr.h"
namespace WebCore {
@@ -77,11 +77,11 @@
callback = v8::Handle<v8::Function>::Cast(value);
}
- OwnArrayPtr<v8::Handle<v8::Value> > args = adoptArrayPtr(new v8::Handle<v8::Value>[1]);
+ OwnPtr<v8::Handle<v8::Value>[]> args = adoptArrayPtr(new v8::Handle<v8::Value>[1]);
args[0] = toV8(node, v8::Handle<v8::Object>(), state->isolate());
v8::Handle<v8::Object> object = v8::Context::GetCurrent()->Global();
- v8::Handle<v8::Value> result = ScriptController::callFunctionWithInstrumentation(0, callback, object, 1, args.get(), isolate);
+ v8::Handle<v8::Value> result = ScriptController::callFunction(state->executionContext(), callback, object, 1, args.get(), isolate);
if (exceptionCatcher.HasCaught()) {
state->setException(exceptionCatcher.Exception());
diff --git a/Source/bindings/v8/V8ObjectConstructor.cpp b/Source/bindings/v8/V8ObjectConstructor.cpp
index be00a83..38a3024 100644
--- a/Source/bindings/v8/V8ObjectConstructor.cpp
+++ b/Source/bindings/v8/V8ObjectConstructor.cpp
@@ -28,8 +28,8 @@
#include "bindings/v8/V8Binding.h"
#include "bindings/v8/V8ScriptRunner.h"
#include "core/dom/Document.h"
-#include "core/page/Frame.h"
-#include "core/platform/chromium/TraceEvent.h"
+#include "core/frame/Frame.h"
+#include "platform/TraceEvent.h"
namespace WebCore {
diff --git a/Source/bindings/v8/V8RecursionScope.h b/Source/bindings/v8/V8RecursionScope.h
index 6d66bdb..3bc3da7 100644
--- a/Source/bindings/v8/V8RecursionScope.h
+++ b/Source/bindings/v8/V8RecursionScope.h
@@ -32,7 +32,7 @@
#define V8RecursionScope_h
#include "bindings/v8/V8PerIsolateData.h"
-#include "core/dom/ScriptExecutionContext.h"
+#include "core/dom/ExecutionContext.h"
#include "wtf/Noncopyable.h"
namespace WebCore {
@@ -57,7 +57,7 @@
class V8RecursionScope {
WTF_MAKE_NONCOPYABLE(V8RecursionScope);
public:
- explicit V8RecursionScope(ScriptExecutionContext* context)
+ explicit V8RecursionScope(ExecutionContext* context)
: m_isDocumentContext(context && context->isDocument())
{
V8PerIsolateData::current()->incrementRecursionLevel();
diff --git a/Source/bindings/v8/V8ScriptRunner.cpp b/Source/bindings/v8/V8ScriptRunner.cpp
index 713cef0..d62af64 100644
--- a/Source/bindings/v8/V8ScriptRunner.cpp
+++ b/Source/bindings/v8/V8ScriptRunner.cpp
@@ -29,10 +29,10 @@
#include "bindings/v8/V8Binding.h"
#include "bindings/v8/V8GCController.h"
#include "bindings/v8/V8RecursionScope.h"
-#include "core/dom/ScriptExecutionContext.h"
+#include "core/dom/ExecutionContext.h"
#include "core/fetch/CachedMetadata.h"
#include "core/fetch/ScriptResource.h"
-#include "core/platform/chromium/TraceEvent.h"
+#include "platform/TraceEvent.h"
namespace WebCore {
@@ -75,7 +75,7 @@
return v8::Script::Compile(code, &origin, scriptData);
}
-v8::Local<v8::Value> V8ScriptRunner::runCompiledScript(v8::Handle<v8::Script> script, ScriptExecutionContext* context, v8::Isolate* isolate)
+v8::Local<v8::Value> V8ScriptRunner::runCompiledScript(v8::Handle<v8::Script> script, ExecutionContext* context, v8::Isolate* isolate)
{
TRACE_EVENT0("v8", "v8.run");
TRACE_EVENT_SCOPED_SAMPLING_STATE("V8", "Execution");
@@ -88,6 +88,8 @@
if (handleOutOfMemory())
return v8::Local<v8::Value>();
+ RELEASE_ASSERT(!context->isIteratingOverObservers());
+
// Run the script and keep track of the current recursion depth.
v8::Local<v8::Value> result;
{
@@ -119,7 +121,7 @@
return result;
}
-v8::Local<v8::Value> V8ScriptRunner::callFunction(v8::Handle<v8::Function> function, ScriptExecutionContext* context, v8::Handle<v8::Object> receiver, int argc, v8::Handle<v8::Value> args[], v8::Isolate* isolate)
+v8::Local<v8::Value> V8ScriptRunner::callFunction(v8::Handle<v8::Function> function, ExecutionContext* context, v8::Handle<v8::Value> receiver, int argc, v8::Handle<v8::Value> args[], v8::Isolate* isolate)
{
TRACE_EVENT0("v8", "v8.callFunction");
TRACE_EVENT_SCOPED_SAMPLING_STATE("V8", "Execution");
@@ -127,13 +129,15 @@
if (V8RecursionScope::recursionLevel() >= kMaxRecursionDepth)
return handleMaxRecursionDepthExceeded(isolate);
+ RELEASE_ASSERT(!context->isIteratingOverObservers());
+
V8RecursionScope recursionScope(context);
v8::Local<v8::Value> result = function->Call(receiver, argc, args);
crashIfV8IsDead();
return result;
}
-v8::Local<v8::Value> V8ScriptRunner::callInternalFunction(v8::Handle<v8::Function> function, v8::Handle<v8::Object> receiver, int argc, v8::Handle<v8::Value> args[], v8::Isolate* isolate)
+v8::Local<v8::Value> V8ScriptRunner::callInternalFunction(v8::Handle<v8::Function> function, v8::Handle<v8::Value> receiver, int argc, v8::Handle<v8::Value> args[], v8::Isolate* isolate)
{
TRACE_EVENT0("v8", "v8.callFunction");
TRACE_EVENT_SCOPED_SAMPLING_STATE("V8", "Execution");
@@ -143,10 +147,11 @@
return result;
}
-v8::Local<v8::Value> V8ScriptRunner::callAsFunction(v8::Handle<v8::Object> object, v8::Handle<v8::Object> receiver, int argc, v8::Handle<v8::Value> args[])
+v8::Local<v8::Value> V8ScriptRunner::callAsFunction(v8::Handle<v8::Object> object, v8::Handle<v8::Value> receiver, int argc, v8::Handle<v8::Value> args[])
{
TRACE_EVENT0("v8", "v8.callFunction");
TRACE_EVENT_SCOPED_SAMPLING_STATE("V8", "Execution");
+
V8RecursionScope::MicrotaskSuppression recursionScope;
v8::Local<v8::Value> result = object->CallAsFunction(receiver, argc, args);
crashIfV8IsDead();
@@ -157,6 +162,7 @@
{
TRACE_EVENT0("v8", "v8.callFunction");
TRACE_EVENT_SCOPED_SAMPLING_STATE("V8", "Execution");
+
V8RecursionScope::MicrotaskSuppression recursionScope;
v8::Local<v8::Value> result = object->CallAsConstructor(argc, args);
crashIfV8IsDead();
@@ -167,6 +173,7 @@
{
TRACE_EVENT0("v8", "v8.newInstance");
TRACE_EVENT_SCOPED_SAMPLING_STATE("V8", "Execution");
+
V8RecursionScope::MicrotaskSuppression scope;
v8::Local<v8::Object> result = objectTemplate->NewInstance();
crashIfV8IsDead();
@@ -177,13 +184,14 @@
{
TRACE_EVENT0("v8", "v8.newInstance");
TRACE_EVENT_SCOPED_SAMPLING_STATE("V8", "Execution");
+
V8RecursionScope::MicrotaskSuppression scope;
v8::Local<v8::Object> result = function->NewInstance(argc, argv);
crashIfV8IsDead();
return result;
}
-v8::Local<v8::Object> V8ScriptRunner::instantiateObjectInDocument(v8::Handle<v8::Function> function, ScriptExecutionContext* context, int argc, v8::Handle<v8::Value> argv[])
+v8::Local<v8::Object> V8ScriptRunner::instantiateObjectInDocument(v8::Handle<v8::Function> function, ExecutionContext* context, int argc, v8::Handle<v8::Value> argv[])
{
TRACE_EVENT0("v8", "v8.newInstance");
TRACE_EVENT_SCOPED_SAMPLING_STATE("V8", "Execution");
diff --git a/Source/bindings/v8/V8ScriptRunner.h b/Source/bindings/v8/V8ScriptRunner.h
index 8ceab0f..70c24c0 100644
--- a/Source/bindings/v8/V8ScriptRunner.h
+++ b/Source/bindings/v8/V8ScriptRunner.h
@@ -35,7 +35,7 @@
namespace WebCore {
class ScriptResource;
-class ScriptExecutionContext;
+class ExecutionContext;
class V8ScriptRunner {
public:
@@ -43,15 +43,15 @@
// a HandleScope and a ContextScope.
static PassOwnPtr<v8::ScriptData> precompileScript(v8::Handle<v8::String>, ScriptResource*);
static v8::Local<v8::Script> compileScript(v8::Handle<v8::String>, const String&, const TextPosition&, v8::ScriptData*, v8::Isolate*, AccessControlStatus = SharableCrossOrigin);
- static v8::Local<v8::Value> runCompiledScript(v8::Handle<v8::Script>, ScriptExecutionContext*, v8::Isolate*);
+ static v8::Local<v8::Value> runCompiledScript(v8::Handle<v8::Script>, ExecutionContext*, v8::Isolate*);
static v8::Local<v8::Value> compileAndRunInternalScript(v8::Handle<v8::String>, v8::Isolate*, const String& = String(), const TextPosition& = TextPosition(), v8::ScriptData* = 0);
- static v8::Local<v8::Value> callInternalFunction(v8::Handle<v8::Function>, v8::Handle<v8::Object>, int argc, v8::Handle<v8::Value> args[], v8::Isolate*);
- static v8::Local<v8::Value> callFunction(v8::Handle<v8::Function>, ScriptExecutionContext*, v8::Handle<v8::Object> receiver, int argc, v8::Handle<v8::Value> args[], v8::Isolate*);
- static v8::Local<v8::Value> callAsFunction(v8::Handle<v8::Object>, v8::Handle<v8::Object> receiver, int argc, v8::Handle<v8::Value> args[]);
+ static v8::Local<v8::Value> callInternalFunction(v8::Handle<v8::Function>, v8::Handle<v8::Value> receiver, int argc, v8::Handle<v8::Value> args[], v8::Isolate*);
+ static v8::Local<v8::Value> callFunction(v8::Handle<v8::Function>, ExecutionContext*, v8::Handle<v8::Value> receiver, int argc, v8::Handle<v8::Value> args[], v8::Isolate*);
+ static v8::Local<v8::Value> callAsFunction(v8::Handle<v8::Object>, v8::Handle<v8::Value> receiver, int argc, v8::Handle<v8::Value> args[]);
static v8::Local<v8::Value> callAsConstructor(v8::Handle<v8::Object>, int argc, v8::Handle<v8::Value> args[]);
static v8::Local<v8::Object> instantiateObject(v8::Handle<v8::ObjectTemplate>);
static v8::Local<v8::Object> instantiateObject(v8::Handle<v8::Function>, int argc = 0, v8::Handle<v8::Value> argv[] = 0);
- static v8::Local<v8::Object> instantiateObjectInDocument(v8::Handle<v8::Function>, ScriptExecutionContext*, int argc = 0, v8::Handle<v8::Value> argv[] = 0);
+ static v8::Local<v8::Object> instantiateObjectInDocument(v8::Handle<v8::Function>, ExecutionContext*, int argc = 0, v8::Handle<v8::Value> argv[] = 0);
};
diff --git a/Source/bindings/v8/V8Utilities.cpp b/Source/bindings/v8/V8Utilities.cpp
index 9978fc5..c2903db 100644
--- a/Source/bindings/v8/V8Utilities.cpp
+++ b/Source/bindings/v8/V8Utilities.cpp
@@ -38,9 +38,9 @@
#include "bindings/v8/custom/V8ArrayBufferCustom.h"
#include "core/dom/Document.h"
#include "core/dom/ExceptionCode.h"
+#include "core/dom/ExecutionContext.h"
#include "core/dom/MessagePort.h"
-#include "core/dom/ScriptExecutionContext.h"
-#include "core/page/Frame.h"
+#include "core/frame/Frame.h"
#include "core/workers/WorkerGlobalScope.h"
#include "wtf/ArrayBuffer.h"
#include "wtf/text/WTFString.h"
@@ -153,7 +153,7 @@
createHiddenDependency(object, newValue, cacheIndex, isolate);
}
-ScriptExecutionContext* getScriptExecutionContext()
+ExecutionContext* getExecutionContext()
{
if (WorkerScriptController* controller = WorkerScriptController::controllerForContext())
return controller->workerGlobalScope();
diff --git a/Source/bindings/v8/V8Utilities.h b/Source/bindings/v8/V8Utilities.h
index 425df2d..f1e664d 100644
--- a/Source/bindings/v8/V8Utilities.h
+++ b/Source/bindings/v8/V8Utilities.h
@@ -42,7 +42,7 @@
class EventListener;
class MessagePort;
- class ScriptExecutionContext;
+ class ExecutionContext;
// Use an array to hold dependents. It works like a ref-counted scheme. A value can be added more than once to the DOM object.
void createHiddenDependency(v8::Handle<v8::Object>, v8::Local<v8::Value>, int cacheIndex, v8::Isolate*);
@@ -51,7 +51,7 @@
// Combo create/remove, for generated event-handler-setter bindings:
void transferHiddenDependency(v8::Handle<v8::Object>, EventListener* oldValue, v8::Local<v8::Value> newValue, int cacheIndex, v8::Isolate*);
- ScriptExecutionContext* getScriptExecutionContext();
+ ExecutionContext* getExecutionContext();
typedef WTF::Vector<RefPtr<MessagePort>, 1> MessagePortArray;
typedef WTF::Vector<RefPtr<ArrayBuffer>, 1> ArrayBufferArray;
diff --git a/Source/bindings/v8/V8WindowShell.cpp b/Source/bindings/v8/V8WindowShell.cpp
index f68494d..c1ae9d6 100644
--- a/Source/bindings/v8/V8WindowShell.cpp
+++ b/Source/bindings/v8/V8WindowShell.cpp
@@ -51,13 +51,14 @@
#include "core/loader/DocumentLoader.h"
#include "core/loader/FrameLoader.h"
#include "core/loader/FrameLoaderClient.h"
-#include "core/page/ContentSecurityPolicy.h"
-#include "core/page/Frame.h"
+#include "core/frame/ContentSecurityPolicy.h"
+#include "core/frame/Frame.h"
#include "core/page/Page.h"
#include "core/platform/HistogramSupport.h"
+#include "platform/TraceEvent.h"
#include "weborigin/SecurityOrigin.h"
#include "wtf/Assertions.h"
-#include "wtf/OwnArrayPtr.h"
+#include "wtf/OwnPtr.h"
#include "wtf/StringExtras.h"
#include "wtf/text/CString.h"
#include <algorithm>
@@ -184,6 +185,8 @@
if (!m_context.isEmpty())
return true;
+ TRACE_EVENT0("v8", "V8WindowShell::initializeIfNeeded");
+
v8::HandleScope handleScope(m_isolate);
V8Initializer::initializeMainThreadIfNeeded(m_isolate);
@@ -268,11 +271,12 @@
double contextCreationStartInSeconds = currentTime();
// Used to avoid sleep calls in unload handlers.
- ScriptController::registerExtensionIfNeeded(DateExtension::get());
+ if (DateExtension::get())
+ ScriptController::registerExtensionIfNeeded(DateExtension::get());
// Dynamically tell v8 about our extensions now.
const V8Extensions& extensions = ScriptController::registeredExtensions();
- OwnArrayPtr<const char*> extensionNames = adoptArrayPtr(new const char*[extensions.size()]);
+ OwnPtr<const char*[]> extensionNames = adoptArrayPtr(new const char*[extensions.size()]);
int index = 0;
int extensionGroup = m_world->extensionGroup();
int worldId = m_world->worldId();
diff --git a/Source/bindings/v8/V8WorkerGlobalScopeEventListener.cpp b/Source/bindings/v8/V8WorkerGlobalScopeEventListener.cpp
index 1ba0ff9..5bb0510 100644
--- a/Source/bindings/v8/V8WorkerGlobalScopeEventListener.cpp
+++ b/Source/bindings/v8/V8WorkerGlobalScopeEventListener.cpp
@@ -49,7 +49,7 @@
{
}
-void V8WorkerGlobalScopeEventListener::handleEvent(ScriptExecutionContext* context, Event* event)
+void V8WorkerGlobalScopeEventListener::handleEvent(ExecutionContext* context, Event* event)
{
if (!context)
return;
@@ -78,7 +78,7 @@
invokeEventHandler(context, event, v8::Local<v8::Value>::New(isolate, jsEvent));
}
-v8::Local<v8::Value> V8WorkerGlobalScopeEventListener::callListenerFunction(ScriptExecutionContext* context, v8::Handle<v8::Value> jsEvent, Event* event)
+v8::Local<v8::Value> V8WorkerGlobalScopeEventListener::callListenerFunction(ExecutionContext* context, v8::Handle<v8::Value> jsEvent, Event* event)
{
v8::Local<v8::Function> handlerFunction = getListenerFunction(context);
v8::Local<v8::Object> receiver = getReceiverObject(context, event);
@@ -106,7 +106,7 @@
return result;
}
-v8::Local<v8::Object> V8WorkerGlobalScopeEventListener::getReceiverObject(ScriptExecutionContext* context, Event* event)
+v8::Local<v8::Object> V8WorkerGlobalScopeEventListener::getReceiverObject(ExecutionContext* context, Event* event)
{
v8::Local<v8::Object> listener = getListenerObject(context);
diff --git a/Source/bindings/v8/V8WorkerGlobalScopeEventListener.h b/Source/bindings/v8/V8WorkerGlobalScopeEventListener.h
index 571b70d..1acf7c4 100644
--- a/Source/bindings/v8/V8WorkerGlobalScopeEventListener.h
+++ b/Source/bindings/v8/V8WorkerGlobalScopeEventListener.h
@@ -46,14 +46,14 @@
return adoptRef(new V8WorkerGlobalScopeEventListener(listener, isInline, isolate));
}
- virtual void handleEvent(ScriptExecutionContext*, Event*);
+ virtual void handleEvent(ExecutionContext*, Event*);
protected:
V8WorkerGlobalScopeEventListener(v8::Local<v8::Object> listener, bool isInline, v8::Isolate*);
private:
- virtual v8::Local<v8::Value> callListenerFunction(ScriptExecutionContext*, v8::Handle<v8::Value> jsEvent, Event*);
- v8::Local<v8::Object> getReceiverObject(ScriptExecutionContext*, Event*);
+ virtual v8::Local<v8::Value> callListenerFunction(ExecutionContext*, v8::Handle<v8::Value> jsEvent, Event*);
+ v8::Local<v8::Object> getReceiverObject(ExecutionContext*, Event*);
};
} // namespace WebCore
diff --git a/Source/bindings/v8/WorkerScriptController.cpp b/Source/bindings/v8/WorkerScriptController.cpp
index 83ba3a7..e47a00e 100644
--- a/Source/bindings/v8/WorkerScriptController.cpp
+++ b/Source/bindings/v8/WorkerScriptController.cpp
@@ -44,7 +44,7 @@
#include "bindings/v8/V8ScriptRunner.h"
#include "bindings/v8/WrapperTypeInfo.h"
#include "core/inspector/ScriptCallStack.h"
-#include "core/page/DOMTimer.h"
+#include "core/frame/DOMTimer.h"
#include "core/workers/WorkerGlobalScope.h"
#include "core/workers/WorkerObjectProxy.h"
#include "core/workers/WorkerThread.h"
diff --git a/Source/bindings/v8/custom/V8AlgorithmCustom.cpp b/Source/bindings/v8/custom/V8AlgorithmCustom.cpp
index 83d58bf..9c50137 100644
--- a/Source/bindings/v8/custom/V8AlgorithmCustom.cpp
+++ b/Source/bindings/v8/custom/V8AlgorithmCustom.cpp
@@ -37,6 +37,7 @@
#include "V8HmacParams.h"
#include "V8RsaKeyGenParams.h"
#include "V8RsaSsaParams.h"
+#include "platform/NotImplemented.h"
namespace WebCore {
@@ -60,6 +61,11 @@
return wrap(static_cast<RsaSsaParams*>(impl), creationContext, isolate);
case WebKit::WebCryptoAlgorithmParamsTypeRsaKeyGenParams:
return wrap(static_cast<RsaKeyGenParams*>(impl), creationContext, isolate);
+ case WebKit::WebCryptoAlgorithmParamsTypeAesGcmParams:
+ case WebKit::WebCryptoAlgorithmParamsTypeRsaOaepParams:
+ // TODO
+ notImplemented();
+ break;
}
ASSERT_NOT_REACHED();
diff --git a/Source/bindings/v8/custom/V8AudioBufferSourceNodeCustom.cpp b/Source/bindings/v8/custom/V8AudioBufferSourceNodeCustom.cpp
deleted file mode 100644
index 8f43ddb..0000000
--- a/Source/bindings/v8/custom/V8AudioBufferSourceNodeCustom.cpp
+++ /dev/null
@@ -1,58 +0,0 @@
-/*
- * Copyright (C) 2011, Google Inc. All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- * 1. Redistributions of source code must retain the above copyright
- * notice, this list of conditions and the following disclaimer.
- * 2. Redistributions in binary form must reproduce the above copyright
- * notice, this list of conditions and the following disclaimer in the
- * documentation and/or other materials provided with the distribution.
- *
- * THIS SOFTWARE IS PROVIDED BY APPLE INC. AND ITS CONTRIBUTORS ``AS IS'' AND ANY
- * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
- * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
- * DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR ITS CONTRIBUTORS BE LIABLE FOR ANY
- * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
- * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
- * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON
- * ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
- * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
- * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
- */
-
-#include "config.h"
-#if ENABLE(WEB_AUDIO)
-#include "V8AudioBufferSourceNode.h"
-
-#include "V8AudioBuffer.h"
-#include "bindings/v8/V8Binding.h"
-#include "modules/webaudio/AudioBuffer.h"
-#include "modules/webaudio/AudioBufferSourceNode.h"
-
-namespace WebCore {
-
-void V8AudioBufferSourceNode::bufferAttributeSetterCustom(v8::Local<v8::String> name, v8::Local<v8::Value> value, const v8::PropertyCallbackInfo<void>& info)
-{
- v8::Handle<v8::Object> holder = info.Holder();
- AudioBufferSourceNode* imp = V8AudioBufferSourceNode::toNative(holder);
-
- AudioBuffer* buffer = 0;
- if (V8AudioBuffer::HasInstance(value, info.GetIsolate(), worldType(info.GetIsolate()))) {
- buffer = V8AudioBuffer::toNative(value->ToObject());
- if (buffer && !imp->setBuffer(buffer)) {
- throwTypeError("AudioBuffer unsupported number of channels", info.GetIsolate());
- return;
- }
- }
-
- if (!buffer) {
- throwTypeError("Value is not of type AudioBuffer", info.GetIsolate());
- return;
- }
-}
-
-} // namespace WebCore
-
-#endif // ENABLE(WEB_AUDIO)
diff --git a/Source/bindings/v8/custom/V8AudioContextCustom.cpp b/Source/bindings/v8/custom/V8AudioContextCustom.cpp
deleted file mode 100644
index 86e3971..0000000
--- a/Source/bindings/v8/custom/V8AudioContextCustom.cpp
+++ /dev/null
@@ -1,77 +0,0 @@
-/*
- * Copyright (C) 2010, Google Inc. All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- * 1. Redistributions of source code must retain the above copyright
- * notice, this list of conditions and the following disclaimer.
- * 2. Redistributions in binary form must reproduce the above copyright
- * notice, this list of conditions and the following disclaimer in the
- * documentation and/or other materials provided with the distribution.
- *
- * THIS SOFTWARE IS PROVIDED BY APPLE INC. AND ITS CONTRIBUTORS ``AS IS'' AND ANY
- * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
- * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
- * DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR ITS CONTRIBUTORS BE LIABLE FOR ANY
- * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
- * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
- * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON
- * ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
- * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
- * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
- */
-
-#include "config.h"
-#if ENABLE(WEB_AUDIO)
-#include "V8AudioContext.h"
-
-#include "V8AudioBuffer.h"
-#include "V8OfflineAudioContext.h"
-#include "bindings/v8/V8Binding.h"
-#include "bindings/v8/custom/V8ArrayBufferCustom.h"
-#include "core/dom/Document.h"
-#include "modules/webaudio/AudioBuffer.h"
-#include "modules/webaudio/AudioContext.h"
-#include "modules/webaudio/OfflineAudioContext.h"
-#include "wtf/ArrayBuffer.h"
-
-namespace WebCore {
-
-void V8AudioContext::constructorCustom(const v8::FunctionCallbackInfo<v8::Value>& args)
-{
- Document* document = currentDocument();
-
- RefPtr<AudioContext> audioContext;
-
- if (!args.Length()) {
- // Constructor for default AudioContext which talks to audio hardware.
- audioContext = AudioContext::create(document);
- if (!audioContext.get()) {
- throwError(v8SyntaxError, "audio resources unavailable for AudioContext construction", args.GetIsolate());
- return;
- }
- } else {
- // Constructor for offline (render-target) AudioContext which renders into an AudioBuffer.
- // new AudioContext(in unsigned long numberOfChannels, in unsigned long numberOfFrames, in float sampleRate);
- document->addConsoleMessage(JSMessageSource, WarningMessageLevel,
- "Deprecated AudioContext constructor: use OfflineAudioContext instead");
-
- V8OfflineAudioContext::constructorCallback(args);
- return;
- }
-
- if (!audioContext.get()) {
- throwError(v8SyntaxError, "Error creating AudioContext", args.GetIsolate());
- return;
- }
-
- // Transform the holder into a wrapper object for the audio context.
- v8::Handle<v8::Object> wrapper = args.Holder();
- V8DOMWrapper::associateObjectWithWrapper<V8AudioContext>(audioContext.release(), &info, wrapper, args.GetIsolate(), WrapperConfiguration::Dependent);
- args.GetReturnValue().Set(wrapper);
-}
-
-} // namespace WebCore
-
-#endif // ENABLE(WEB_AUDIO)
diff --git a/Source/bindings/v8/custom/V8BlobCustom.cpp b/Source/bindings/v8/custom/V8BlobCustom.cpp
index 2552ebd..0e32d22 100644
--- a/Source/bindings/v8/custom/V8BlobCustom.cpp
+++ b/Source/bindings/v8/custom/V8BlobCustom.cpp
@@ -31,7 +31,6 @@
#include "config.h"
#include "V8Blob.h"
-#include "V8File.h"
#include "bindings/v8/Dictionary.h"
#include "bindings/v8/V8Binding.h"
#include "bindings/v8/V8Utilities.h"
@@ -42,14 +41,6 @@
namespace WebCore {
-v8::Handle<v8::Object> wrap(Blob* impl, v8::Handle<v8::Object> creationContext, v8::Isolate* isolate)
-{
- ASSERT(impl);
- if (impl->isFile())
- return wrap(toFile(impl), creationContext, isolate);
- return V8Blob::createWrapper(impl, creationContext, isolate);
-}
-
void V8Blob::constructorCustom(const v8::FunctionCallbackInfo<v8::Value>& args)
{
if (!args.Length()) {
@@ -89,7 +80,7 @@
throwError(v8SyntaxError, "type must consist of ASCII characters", args.GetIsolate());
return;
}
- type.makeLower();
+ type = type.lower();
}
ASSERT(endings == "transparent" || endings == "native");
diff --git a/Source/bindings/v8/custom/V8CSSValueCustom.cpp b/Source/bindings/v8/custom/V8CSSValueCustom.cpp
index dfbff49..3db5c35 100644
--- a/Source/bindings/v8/custom/V8CSSValueCustom.cpp
+++ b/Source/bindings/v8/custom/V8CSSValueCustom.cpp
@@ -45,20 +45,20 @@
v8::Handle<v8::Object> wrap(CSSValue* impl, v8::Handle<v8::Object> creationContext, v8::Isolate* isolate)
{
ASSERT(impl);
- if (impl->isCSSTransformValue())
- return wrap(static_cast<CSSTransformValue*>(impl), creationContext, isolate);
- if (impl->isCSSMixFunctionValue())
- return wrap(static_cast<CSSMixFunctionValue*>(impl), creationContext, isolate);
- if (impl->isCSSFilterValue())
- return wrap(static_cast<CSSFilterValue*>(impl), creationContext, isolate);
+ if (impl->isTransformValue())
+ return wrap(toCSSTransformValue(impl), creationContext, isolate);
+ if (impl->isMixFunctionValue())
+ return wrap(toCSSMixFunctionValue(impl), creationContext, isolate);
+ if (impl->isFilterValue())
+ return wrap(toCSSFilterValue(impl), creationContext, isolate);
if (impl->isValueList())
return wrap(toCSSValueList(impl), creationContext, isolate);
if (impl->isPrimitiveValue())
return wrap(toCSSPrimitiveValue(impl), creationContext, isolate);
if (impl->isSVGPaint())
- return wrap(static_cast<SVGPaint*>(impl), creationContext, isolate);
+ return wrap(toSVGPaint(impl), creationContext, isolate);
if (impl->isSVGColor())
- return wrap(static_cast<SVGColor*>(impl), creationContext, isolate);
+ return wrap(toSVGColor(impl), creationContext, isolate);
return V8CSSValue::createWrapper(impl, creationContext, isolate);
}
diff --git a/Source/bindings/v8/custom/V8CanvasRenderingContext2DCustom.cpp b/Source/bindings/v8/custom/V8CanvasRenderingContext2DCustom.cpp
index 9a6325f..dbad56f 100644
--- a/Source/bindings/v8/custom/V8CanvasRenderingContext2DCustom.cpp
+++ b/Source/bindings/v8/custom/V8CanvasRenderingContext2DCustom.cpp
@@ -42,7 +42,7 @@
#include "core/html/canvas/CanvasPattern.h"
#include "core/html/canvas/CanvasRenderingContext2D.h"
#include "core/html/canvas/CanvasStyle.h"
-#include "core/platform/graphics/FloatRect.h"
+#include "platform/geometry/FloatRect.h"
namespace WebCore {
diff --git a/Source/bindings/v8/custom/V8ClipboardCustom.cpp b/Source/bindings/v8/custom/V8ClipboardCustom.cpp
deleted file mode 100644
index 9a22519..0000000
--- a/Source/bindings/v8/custom/V8ClipboardCustom.cpp
+++ /dev/null
@@ -1,112 +0,0 @@
-/*
- * Copyright (C) 2007-2009 Google Inc. All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions are
- * met:
- *
- * * Redistributions of source code must retain the above copyright
- * notice, this list of conditions and the following disclaimer.
- * * Redistributions in binary form must reproduce the above
- * copyright notice, this list of conditions and the following disclaimer
- * in the documentation and/or other materials provided with the
- * distribution.
- * * Neither the name of Google Inc. nor the names of its
- * contributors may be used to endorse or promote products derived from
- * this software without specific prior written permission.
- *
- * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
- * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
- * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
- * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
- * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
- * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
- * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
- * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
- * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
- * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
- * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
- */
-
-#include "config.h"
-#include "V8Clipboard.h"
-
-#include "HTMLNames.h"
-#include "V8Node.h"
-#include "bindings/v8/V8Binding.h"
-#include "core/dom/Clipboard.h"
-#include "core/dom/Element.h"
-#include "core/dom/Node.h"
-#include "core/html/HTMLImageElement.h"
-#include "core/platform/graphics/IntPoint.h"
-
-namespace WebCore {
-
-void V8Clipboard::typesAttributeGetterCustom(v8::Local<v8::String> name, const v8::PropertyCallbackInfo<v8::Value>& info)
-{
- Clipboard* clipboard = V8Clipboard::toNative(info.Holder());
-
- ListHashSet<String> types = clipboard->types();
- if (types.isEmpty()) {
- v8SetReturnValueNull(info);
- return;
- }
-
- v8::Local<v8::Array> result = v8::Array::New(types.size());
- ListHashSet<String>::const_iterator end = types.end();
- int index = 0;
- for (ListHashSet<String>::const_iterator it = types.begin(); it != end; ++it, ++index)
- result->Set(v8::Integer::New(index, info.GetIsolate()), v8String(*it, info.GetIsolate()));
-
- v8SetReturnValue(info, result);
-}
-
-void V8Clipboard::clearDataMethodCustom(const v8::FunctionCallbackInfo<v8::Value>& args)
-{
- Clipboard* clipboard = V8Clipboard::toNative(args.Holder());
-
- if (!args.Length()) {
- clipboard->clearAllData();
- return;
- }
-
- if (args.Length() != 1) {
- throwError(v8SyntaxError, "clearData: Invalid number of arguments", args.GetIsolate());
- return;
- }
-
- V8TRYCATCH_FOR_V8STRINGRESOURCE_VOID(V8StringResource<>, type, args[0]);
- clipboard->clearData(type);
-}
-
-void V8Clipboard::setDragImageMethodCustom(const v8::FunctionCallbackInfo<v8::Value>& args)
-{
- Clipboard* clipboard = V8Clipboard::toNative(args.Holder());
-
- if (!clipboard->isForDragAndDrop())
- return;
-
- if (args.Length() != 3) {
- throwError(v8SyntaxError, "setDragImage: Invalid number of arguments", args.GetIsolate());
- return;
- }
-
- int x = toInt32(args[1]);
- int y = toInt32(args[2]);
-
- Node* node = 0;
- if (V8Node::HasInstance(args[0], args.GetIsolate(), worldType(args.GetIsolate())))
- node = V8Node::toNative(v8::Handle<v8::Object>::Cast(args[0]));
-
- if (!node || !node->isElementNode()) {
- throwTypeError("setDragImageFromElement: Invalid first argument", args.GetIsolate());
- return;
- }
-
- if (toElement(node)->hasTagName(HTMLNames::imgTag) && !node->inDocument())
- clipboard->setDragImage(toHTMLImageElement(node)->cachedImage(), IntPoint(x, y));
- else
- clipboard->setDragImageElement(node, IntPoint(x, y));
-}
-
-} // namespace WebCore
diff --git a/Source/bindings/v8/custom/V8CustomSQLStatementErrorCallback.cpp b/Source/bindings/v8/custom/V8CustomSQLStatementErrorCallback.cpp
index a484851..5a5aaf1 100644
--- a/Source/bindings/v8/custom/V8CustomSQLStatementErrorCallback.cpp
+++ b/Source/bindings/v8/custom/V8CustomSQLStatementErrorCallback.cpp
@@ -34,7 +34,7 @@
#include "V8SQLError.h"
#include "V8SQLTransaction.h"
#include "bindings/v8/V8Callback.h"
-#include "core/dom/ScriptExecutionContext.h"
+#include "core/dom/ExecutionContext.h"
#include "wtf/Assertions.h"
namespace WebCore {
@@ -47,7 +47,7 @@
v8::Isolate* isolate = v8::Isolate::GetCurrent();
v8::HandleScope handleScope(isolate);
- v8::Handle<v8::Context> v8Context = toV8Context(scriptExecutionContext(), m_world.get());
+ v8::Handle<v8::Context> v8Context = toV8Context(executionContext(), m_world.get());
if (v8Context.IsEmpty())
return true;
@@ -71,7 +71,7 @@
// statement, if any, or onto the next overall step otherwise. Otherwise,
// the error callback did not return false, or there was no error callback.
// Jump to the last step in the overall steps.
- return invokeCallback(m_callback.newLocal(isolate), 2, argv, callbackReturnValue, scriptExecutionContext(), isolate) || callbackReturnValue;
+ return invokeCallback(m_callback.newLocal(isolate), 2, argv, callbackReturnValue, executionContext(), isolate) || callbackReturnValue;
}
} // namespace WebCore
diff --git a/Source/bindings/v8/custom/V8CustomXPathNSResolver.cpp b/Source/bindings/v8/custom/V8CustomXPathNSResolver.cpp
index 5d8ff3e..3da3b86 100644
--- a/Source/bindings/v8/custom/V8CustomXPathNSResolver.cpp
+++ b/Source/bindings/v8/custom/V8CustomXPathNSResolver.cpp
@@ -33,10 +33,10 @@
#include "bindings/v8/ScriptController.h"
#include "bindings/v8/V8Binding.h"
#include "bindings/v8/V8Utilities.h"
-#include "core/dom/ScriptExecutionContext.h"
+#include "core/dom/ExecutionContext.h"
#include "core/inspector/ScriptCallStack.h"
-#include "core/page/DOMWindow.h"
-#include "core/page/Frame.h"
+#include "core/frame/DOMWindow.h"
+#include "core/frame/Frame.h"
#include "core/page/Page.h"
#include "core/page/PageConsole.h"
#include "wtf/text/WTFString.h"
@@ -85,7 +85,7 @@
v8::Handle<v8::Value> argv[argc] = { v8String(prefix, m_isolate) };
v8::Handle<v8::Function> function = lookupNamespaceURIFunc.IsEmpty() ? v8::Handle<v8::Function>::Cast(m_resolver) : lookupNamespaceURIFunc;
- v8::Handle<v8::Value> retval = ScriptController::callFunctionWithInstrumentation(0, function, m_resolver, argc, argv, m_isolate);
+ v8::Handle<v8::Value> retval = ScriptController::callFunction(activeExecutionContext(), function, m_resolver, argc, argv, m_isolate);
// Eat exceptions from namespace resolver and return an empty string. This will most likely cause NamespaceError.
if (tryCatch.HasCaught())
diff --git a/Source/bindings/v8/custom/V8DocumentCustom.cpp b/Source/bindings/v8/custom/V8DocumentCustom.cpp
index 26a117c..1f864b8 100644
--- a/Source/bindings/v8/custom/V8DocumentCustom.cpp
+++ b/Source/bindings/v8/custom/V8DocumentCustom.cpp
@@ -33,9 +33,7 @@
#include "V8CanvasRenderingContext2D.h"
#include "V8DOMImplementation.h"
-#include "V8HTMLDocument.h"
#include "V8Node.h"
-#include "V8SVGDocument.h"
#include "V8Touch.h"
#include "V8TouchList.h"
#include "V8WebGLRenderingContext.h"
@@ -45,14 +43,13 @@
#include "bindings/v8/ScriptController.h"
#include "bindings/v8/V8Binding.h"
#include "bindings/v8/V8DOMWrapper.h"
-#include "bindings/v8/V8WindowShell.h"
#include "bindings/v8/custom/V8CustomXPathNSResolver.h"
#include "core/dom/Document.h"
#include "core/dom/ExceptionCode.h"
#include "core/dom/Node.h"
#include "core/dom/TouchList.h"
#include "core/html/canvas/CanvasRenderingContext.h"
-#include "core/page/Frame.h"
+#include "core/frame/Frame.h"
#include "core/xml/DocumentXPathEvaluator.h"
#include "core/xml/XPathNSResolver.h"
#include "core/xml/XPathResult.h"
@@ -87,21 +84,4 @@
v8SetReturnValueFast(args, result.release(), document.get());
}
-v8::Handle<v8::Object> wrap(Document* impl, v8::Handle<v8::Object> creationContext, v8::Isolate* isolate)
-{
- ASSERT(impl);
- if (impl->isHTMLDocument())
- return wrap(toHTMLDocument(impl), creationContext, isolate);
- if (impl->isSVGDocument())
- return wrap(toSVGDocument(impl), creationContext, isolate);
- v8::Handle<v8::Object> wrapper = V8Document::createWrapper(impl, creationContext, isolate);
- if (wrapper.IsEmpty())
- return wrapper;
- if (!isolatedWorldForEnteredContext()) {
- if (Frame* frame = impl->frame())
- frame->script()->windowShell(mainThreadNormalWorld())->updateDocumentWrapper(wrapper);
- }
- return wrapper;
-}
-
} // namespace WebCore
diff --git a/Source/bindings/v8/custom/V8DocumentLocationCustom.cpp b/Source/bindings/v8/custom/V8DocumentLocationCustom.cpp
deleted file mode 100644
index c9b98ef..0000000
--- a/Source/bindings/v8/custom/V8DocumentLocationCustom.cpp
+++ /dev/null
@@ -1,67 +0,0 @@
-/*
- * Copyright (C) 2000 Harri Porten (porten@kde.org)
- * Copyright (C) 2001 Peter Kelly (pmk@post.com)
- * Copyright (C) 2004, 2005, 2006 Apple Computer, Inc.
- * Copyright (C) 2006 James G. Speth (speth@end.com)
- * Copyright (C) 2006 Samuel Weinig (sam@webkit.org)
- * Copyright (C) 2007, 2008, 2009 Google Inc. All Rights Reserved.
- *
- * This library is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Lesser General Public
- * License as published by the Free Software Foundation; either
- * version 2 of the License, or (at your option) any later version.
- *
- * This library is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with this library; if not, write to the Free Software
- * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
- */
-
-#include "config.h"
-#include "V8Document.h"
-
-#include "V8Location.h"
-#include "bindings/v8/V8Binding.h"
-#include "core/page/DOMWindow.h"
-#include "core/page/Location.h"
-
-namespace WebCore {
-
-void V8Document::locationAttributeGetterCustom(v8::Local<v8::String> name, const v8::PropertyCallbackInfo<v8::Value>& info)
-{
- Document* document = V8Document::toNative(info.Holder());
- if (!document->frame()) {
- v8SetReturnValueNull(info);
- return;
- }
-
- DOMWindow* window = document->domWindow();
- v8SetReturnValueFast(info, window->location(), document);
-}
-
-void V8Document::locationAttributeSetterCustom(v8::Local<v8::String> name, v8::Local<v8::Value> value, const v8::PropertyCallbackInfo<void>& info)
-{
- Document* document = V8Document::toNative(info.Holder());
- if (!document->frame())
- return;
-
- DOMWindow* active = activeDOMWindow();
- if (!active)
- return;
-
- DOMWindow* first = firstDOMWindow();
- if (!first)
- return;
-
- DOMWindow* window = document->domWindow();
- if (Location* location = window->location()) {
- V8TRYCATCH_FOR_V8STRINGRESOURCE_VOID(V8StringResource<>, stringValue, value);
- location->setHref(active, first, stringValue);
- }
-}
-
-} // namespace WebCore
diff --git a/Source/bindings/v8/custom/V8ElementCustom.cpp b/Source/bindings/v8/custom/V8ElementCustom.cpp
deleted file mode 100644
index 1a345fe..0000000
--- a/Source/bindings/v8/custom/V8ElementCustom.cpp
+++ /dev/null
@@ -1,50 +0,0 @@
-/*
- * Copyright (C) 2012 Google Inc. All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions are
- * met:
- *
- * * Redistributions of source code must retain the above copyright
- * notice, this list of conditions and the following disclaimer.
- * * Redistributions in binary form must reproduce the above
- * copyright notice, this list of conditions and the following disclaimer
- * in the documentation and/or other materials provided with the
- * distribution.
- * * Neither the name of Google Inc. nor the names of its
- * contributors may be used to endorse or promote products derived from
- * this software without specific prior written permission.
- *
- * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
- * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
- * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
- * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
- * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
- * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
- * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
- * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
- * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
- * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
- * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
- */
-
-#include "config.h"
-#include "V8Element.h"
-
-#include "V8HTMLElement.h"
-#include "V8SVGElement.h"
-
-namespace WebCore {
-
-// This code is duplicated in V8Node::wrap for performance. It must be kept in sync.
-v8::Handle<v8::Object> wrap(Element* impl, v8::Handle<v8::Object> creationContext, v8::Isolate* isolate)
-{
- ASSERT(impl);
- if (impl->isHTMLElement())
- return wrap(toHTMLElement(impl), creationContext, isolate);
- if (impl->isSVGElement())
- return wrap(toSVGElement(impl), creationContext, isolate);
- return V8Element::createWrapper(impl, creationContext, isolate);
-}
-
-}
diff --git a/Source/bindings/v8/custom/V8EventCustom.cpp b/Source/bindings/v8/custom/V8EventCustom.cpp
index f2132b0..f51c72e 100644
--- a/Source/bindings/v8/custom/V8EventCustom.cpp
+++ b/Source/bindings/v8/custom/V8EventCustom.cpp
@@ -38,7 +38,7 @@
#include "core/dom/Clipboard.h"
#include "core/events/ClipboardEvent.h"
#include "core/events/Event.h"
-#include "core/events/EventNames.h"
+#include "core/events/ThreadLocalEventNames.h"
namespace WebCore {
@@ -53,7 +53,7 @@
}
#define TRY_TO_WRAP_WITH_INTERFACE(interfaceName) \
- if (eventNames().interfaceFor##interfaceName == desiredInterface) \
+ if (EventNames::interfaceName == desiredInterface) \
return wrap(static_cast<interfaceName*>(event), creationContext, isolate);
v8::Handle<v8::Object> wrap(Event* event, v8::Handle<v8::Object> creationContext, v8::Isolate *isolate)
@@ -63,7 +63,7 @@
String desiredInterface = event->interfaceName();
// We need to check Event first to avoid infinite recursion.
- if (eventNames().interfaceForEvent == desiredInterface)
+ if (EventNames::Event == desiredInterface)
return V8Event::createWrapper(event, creationContext, isolate);
EVENT_INTERFACES_FOR_EACH(TRY_TO_WRAP_WITH_INTERFACE)
diff --git a/Source/bindings/v8/custom/V8EventTargetCustom.cpp b/Source/bindings/v8/custom/V8EventTargetCustom.cpp
index 8bfbfb6..ab395ab 100644
--- a/Source/bindings/v8/custom/V8EventTargetCustom.cpp
+++ b/Source/bindings/v8/custom/V8EventTargetCustom.cpp
@@ -37,7 +37,7 @@
namespace WebCore {
#define TRY_TO_WRAP_WITH_INTERFACE(interfaceName) \
- if (eventNames().interfaceFor##interfaceName == desiredInterface) \
+ if (EventTargetNames::interfaceName == desiredInterface) \
return toV8(static_cast<interfaceName*>(impl), creationContext, isolate);
v8::Handle<v8::Value> toV8(EventTarget* impl, v8::Handle<v8::Object> creationContext, v8::Isolate* isolate)
diff --git a/Source/bindings/v8/custom/V8FileReaderCustom.cpp b/Source/bindings/v8/custom/V8FileReaderCustom.cpp
index 5b2c9b0..ef7e27e 100644
--- a/Source/bindings/v8/custom/V8FileReaderCustom.cpp
+++ b/Source/bindings/v8/custom/V8FileReaderCustom.cpp
@@ -33,7 +33,7 @@
#include "bindings/v8/V8Binding.h"
#include "bindings/v8/custom/V8ArrayBufferCustom.h"
-#include "core/dom/ScriptExecutionContext.h"
+#include "core/dom/ExecutionContext.h"
namespace WebCore {
diff --git a/Source/bindings/v8/custom/V8HTMLAllCollectionCustom.cpp b/Source/bindings/v8/custom/V8HTMLAllCollectionCustom.cpp
index 35458ff..97fb74b 100644
--- a/Source/bindings/v8/custom/V8HTMLAllCollectionCustom.cpp
+++ b/Source/bindings/v8/custom/V8HTMLAllCollectionCustom.cpp
@@ -105,7 +105,7 @@
Node* ownerNode = imp->ownerNode();
ASSERT(ownerNode);
- UseCounter::count(&ownerNode->document(), UseCounter::DocumentAllLegacyCall);
+ UseCounter::count(ownerNode->document(), UseCounter::DocumentAllLegacyCall);
if (args.Length() == 1) {
v8SetReturnValue(args, getItem(imp, args[0], args));
diff --git a/Source/bindings/v8/custom/V8HTMLDocumentCustom.cpp b/Source/bindings/v8/custom/V8HTMLDocumentCustom.cpp
index 5641961..fe292ed 100644
--- a/Source/bindings/v8/custom/V8HTMLDocumentCustom.cpp
+++ b/Source/bindings/v8/custom/V8HTMLDocumentCustom.cpp
@@ -38,13 +38,12 @@
#include "V8Window.h"
#include "bindings/v8/ScriptController.h"
#include "bindings/v8/V8Binding.h"
-#include "bindings/v8/V8WindowShell.h"
#include "core/html/HTMLAllCollection.h"
#include "core/html/HTMLCollection.h"
#include "core/html/HTMLDocument.h"
#include "core/html/HTMLIFrameElement.h"
-#include "core/page/Frame.h"
-#include "wtf/OwnArrayPtr.h"
+#include "core/frame/Frame.h"
+#include "wtf/OwnPtr.h"
#include "wtf/RefPtr.h"
#include "wtf/StdLibExtras.h"
#include "wtf/text/StringBuilder.h"
@@ -99,7 +98,7 @@
return;
}
// Wrap up the arguments and call the function.
- OwnArrayPtr<v8::Local<v8::Value> > params = adoptArrayPtr(new v8::Local<v8::Value>[args.Length()]);
+ OwnPtr<v8::Local<v8::Value>[]> params = adoptArrayPtr(new v8::Local<v8::Value>[args.Length()]);
for (int i = 0; i < args.Length(); i++)
params[i] = args[i];
@@ -112,17 +111,4 @@
v8SetReturnValue(args, args.Holder());
}
-v8::Handle<v8::Object> wrap(HTMLDocument* impl, v8::Handle<v8::Object> creationContext, v8::Isolate* isolate)
-{
- ASSERT(impl);
- v8::Handle<v8::Object> wrapper = V8HTMLDocument::createWrapper(impl, creationContext, isolate);
- if (wrapper.IsEmpty())
- return wrapper;
- if (!isolatedWorldForEnteredContext()) {
- if (Frame* frame = impl->frame())
- frame->script()->windowShell(mainThreadNormalWorld())->updateDocumentWrapper(wrapper);
- }
- return wrapper;
-}
-
} // namespace WebCore
diff --git a/Source/bindings/v8/custom/V8HTMLOptionsCollectionCustom.cpp b/Source/bindings/v8/custom/V8HTMLOptionsCollectionCustom.cpp
index 3e488fc..cc58eda 100644
--- a/Source/bindings/v8/custom/V8HTMLOptionsCollectionCustom.cpp
+++ b/Source/bindings/v8/custom/V8HTMLOptionsCollectionCustom.cpp
@@ -34,6 +34,7 @@
#include "V8HTMLOptionElement.h"
#include "V8Node.h"
#include "V8NodeList.h"
+#include "bindings/v8/ExceptionMessages.h"
#include "bindings/v8/ExceptionState.h"
#include "bindings/v8/V8Binding.h"
#include "core/dom/ExceptionCode.h"
@@ -86,7 +87,7 @@
bool ok;
V8TRYCATCH_VOID(int, index, toInt32(args[1], ok));
if (!ok)
- es.throwUninformativeAndGenericDOMException(TypeMismatchError);
+ es.throwDOMException(TypeMismatchError, ExceptionMessages::failedToExecute("add", "HTMLOptionsCollection", "The index provided could not be interpreted as an integer."));
else
imp->add(option, index, es);
}
@@ -102,7 +103,7 @@
ExceptionState es(info.GetIsolate());
if (!std::isnan(v) && !std::isinf(v)) {
if (v < 0.0)
- es.throwUninformativeAndGenericDOMException(IndexSizeError);
+ es.throwDOMException(IndexSizeError, ExceptionMessages::failedToSet("length", "HTMLOptionsCollection", "The value provided (" + String::number(v) + ") is negative. Lengths must be greater than or equal to 0."));
else if (v > static_cast<double>(UINT_MAX))
newLength = UINT_MAX;
else
diff --git a/Source/bindings/v8/custom/V8HTMLPlugInElementCustom.cpp b/Source/bindings/v8/custom/V8HTMLPlugInElementCustom.cpp
index 34e00cf..fa21c65 100644
--- a/Source/bindings/v8/custom/V8HTMLPlugInElementCustom.cpp
+++ b/Source/bindings/v8/custom/V8HTMLPlugInElementCustom.cpp
@@ -33,7 +33,7 @@
#include "V8HTMLAppletElement.h"
#include "V8HTMLEmbedElement.h"
#include "V8HTMLObjectElement.h"
-#include "bindings/v8/ScriptInstance.h"
+#include "bindings/v8/SharedPersistent.h"
#include "bindings/v8/V8Binding.h"
#include "bindings/v8/V8NPObject.h"
#include "core/page/UseCounter.h"
@@ -47,11 +47,11 @@
static void npObjectNamedGetter(v8::Local<v8::String> name, const v8::PropertyCallbackInfo<v8::Value>& info)
{
HTMLPlugInElement* imp = C::toNative(info.Holder());
- ScriptInstance scriptInstance = imp->getInstance();
- if (!scriptInstance)
+ RefPtr<SharedPersistent<v8::Object> > wrapper = imp->pluginWrapper();
+ if (!wrapper)
return;
- v8::Local<v8::Object> instance = scriptInstance->newLocal(info.GetIsolate());
+ v8::Local<v8::Object> instance = wrapper->newLocal(info.GetIsolate());
if (instance.IsEmpty())
return;
@@ -62,11 +62,11 @@
static void npObjectNamedSetter(v8::Local<v8::String> name, v8::Local<v8::Value> value, const v8::PropertyCallbackInfo<v8::Value>& info)
{
HTMLPlugInElement* imp = C::toNative(info.Holder());
- ScriptInstance scriptInstance = imp->getInstance();
- if (!scriptInstance)
+ RefPtr<SharedPersistent<v8::Object> > wrapper = imp->pluginWrapper();
+ if (!wrapper)
return;
- v8::Local<v8::Object> instance = scriptInstance->newLocal(info.GetIsolate());
+ v8::Local<v8::Object> instance = wrapper->newLocal(info.GetIsolate());
if (instance.IsEmpty())
return;
@@ -106,21 +106,21 @@
void V8HTMLAppletElement::legacyCallCustom(const v8::FunctionCallbackInfo<v8::Value>& args)
{
HTMLPlugInElement* imp = V8HTMLAppletElement::toNative(args.Holder());
- UseCounter::count(&imp->document(), UseCounter::HTMLAppletElementLegacyCall);
+ UseCounter::count(imp->document(), UseCounter::HTMLAppletElementLegacyCall);
npObjectInvokeDefaultHandler(args);
}
void V8HTMLEmbedElement::legacyCallCustom(const v8::FunctionCallbackInfo<v8::Value>& args)
{
HTMLPlugInElement* imp = V8HTMLEmbedElement::toNative(args.Holder());
- UseCounter::count(&imp->document(), UseCounter::HTMLEmbedElementLegacyCall);
+ UseCounter::count(imp->document(), UseCounter::HTMLEmbedElementLegacyCall);
npObjectInvokeDefaultHandler(args);
}
void V8HTMLObjectElement::legacyCallCustom(const v8::FunctionCallbackInfo<v8::Value>& args)
{
HTMLPlugInElement* imp = V8HTMLObjectElement::toNative(args.Holder());
- UseCounter::count(&imp->document(), UseCounter::HTMLObjectElementLegacyCall);
+ UseCounter::count(imp->document(), UseCounter::HTMLObjectElementLegacyCall);
npObjectInvokeDefaultHandler(args);
}
@@ -128,11 +128,11 @@
void npObjectIndexedGetter(uint32_t index, const v8::PropertyCallbackInfo<v8::Value>& info)
{
HTMLPlugInElement* imp = C::toNative(info.Holder());
- ScriptInstance scriptInstance = imp->getInstance();
- if (!scriptInstance)
+ RefPtr<SharedPersistent<v8::Object> > wrapper = imp->pluginWrapper();
+ if (!wrapper)
return;
- v8::Local<v8::Object> instance = scriptInstance->newLocal(info.GetIsolate());
+ v8::Local<v8::Object> instance = wrapper->newLocal(info.GetIsolate());
if (instance.IsEmpty())
return;
@@ -143,11 +143,11 @@
void npObjectIndexedSetter(uint32_t index, v8::Local<v8::Value> value, const v8::PropertyCallbackInfo<v8::Value>& info)
{
HTMLPlugInElement* imp = C::toNative(info.Holder());
- ScriptInstance scriptInstance = imp->getInstance();
- if (!scriptInstance)
+ RefPtr<SharedPersistent<v8::Object> > wrapper = imp->pluginWrapper();
+ if (!wrapper)
return;
- v8::Local<v8::Object> instance = scriptInstance->newLocal(info.GetIsolate());
+ v8::Local<v8::Object> instance = wrapper->newLocal(info.GetIsolate());
if (instance.IsEmpty())
return;
diff --git a/Source/bindings/v8/custom/V8HistoryCustom.cpp b/Source/bindings/v8/custom/V8HistoryCustom.cpp
index 0300b0c..8e3936c 100644
--- a/Source/bindings/v8/custom/V8HistoryCustom.cpp
+++ b/Source/bindings/v8/custom/V8HistoryCustom.cpp
@@ -37,7 +37,7 @@
#include "bindings/v8/V8Binding.h"
#include "bindings/v8/V8HiddenPropertyName.h"
#include "core/dom/ExceptionCode.h"
-#include "core/page/History.h"
+#include "core/frame/History.h"
namespace WebCore {
diff --git a/Source/bindings/v8/custom/V8InjectedScriptHostCustom.cpp b/Source/bindings/v8/custom/V8InjectedScriptHostCustom.cpp
index 51b25c9..e8206bf 100644
--- a/Source/bindings/v8/custom/V8InjectedScriptHostCustom.cpp
+++ b/Source/bindings/v8/custom/V8InjectedScriptHostCustom.cpp
@@ -38,6 +38,7 @@
#include "V8NodeList.h"
#include "V8Storage.h"
#include "bindings/v8/BindingSecurity.h"
+#include "bindings/v8/ExceptionState.h"
#include "bindings/v8/ScriptDebugServer.h"
#include "bindings/v8/ScriptValue.h"
#include "bindings/v8/V8AbstractEventListener.h"
@@ -56,8 +57,8 @@
#include "core/inspector/InjectedScript.h"
#include "core/inspector/InjectedScriptHost.h"
#include "core/inspector/InspectorDOMAgent.h"
-#include "core/platform/JSONValues.h"
#include "modules/webdatabase/Database.h"
+#include "platform/JSONValues.h"
namespace WebCore {
@@ -76,7 +77,8 @@
v8::Local<v8::Context> context = state->context();
v8::Context::Scope contextScope(context);
- if (!BindingSecurity::shouldAllowAccessToNode(node))
+ ExceptionState es(isolate);
+ if (!BindingSecurity::shouldAllowAccessToNode(node, es))
return ScriptValue(v8::Null(isolate), isolate);
return ScriptValue(toV8(node, v8::Handle<v8::Object>(), isolate), isolate);
}
diff --git a/Source/bindings/v8/custom/V8InjectedScriptManager.cpp b/Source/bindings/v8/custom/V8InjectedScriptManager.cpp
index 5b551da..bb7ee02 100644
--- a/Source/bindings/v8/custom/V8InjectedScriptManager.cpp
+++ b/Source/bindings/v8/custom/V8InjectedScriptManager.cpp
@@ -40,7 +40,7 @@
#include "bindings/v8/V8ObjectConstructor.h"
#include "bindings/v8/V8ScriptRunner.h"
#include "core/inspector/InjectedScriptHost.h"
-#include "core/page/DOMWindow.h"
+#include "core/frame/DOMWindow.h"
#include "wtf/RefPtr.h"
namespace WebCore {
diff --git a/Source/bindings/v8/custom/V8MessageChannelCustom.cpp b/Source/bindings/v8/custom/V8MessageChannelCustom.cpp
index 9952073..39e5a03 100644
--- a/Source/bindings/v8/custom/V8MessageChannelCustom.cpp
+++ b/Source/bindings/v8/custom/V8MessageChannelCustom.cpp
@@ -43,7 +43,7 @@
void V8MessageChannel::constructorCustom(const v8::FunctionCallbackInfo<v8::Value>& args)
{
- ScriptExecutionContext* context = getScriptExecutionContext();
+ ExecutionContext* context = getExecutionContext();
RefPtr<MessageChannel> obj = MessageChannel::create(context);
diff --git a/Source/bindings/v8/custom/V8MutationObserverCustom.cpp b/Source/bindings/v8/custom/V8MutationObserverCustom.cpp
index 596978a..8291733 100644
--- a/Source/bindings/v8/custom/V8MutationObserverCustom.cpp
+++ b/Source/bindings/v8/custom/V8MutationObserverCustom.cpp
@@ -52,7 +52,7 @@
return;
}
- ScriptExecutionContext* context = getScriptExecutionContext();
+ ExecutionContext* context = getExecutionContext();
v8::Handle<v8::Object> wrapper = args.Holder();
RefPtr<MutationCallback> callback = V8MutationCallback::create(v8::Handle<v8::Function>::Cast(arg), context, wrapper, args.GetIsolate());
diff --git a/Source/bindings/v8/custom/V8NodeCustom.cpp b/Source/bindings/v8/custom/V8NodeCustom.cpp
index ff02372..6cd9c97 100644
--- a/Source/bindings/v8/custom/V8NodeCustom.cpp
+++ b/Source/bindings/v8/custom/V8NodeCustom.cpp
@@ -49,15 +49,16 @@
#include "bindings/v8/V8AbstractEventListener.h"
#include "bindings/v8/V8Binding.h"
#include "bindings/v8/V8EventListener.h"
-#include "core/dom/CustomElementCallbackDispatcher.h"
#include "core/dom/Document.h"
+#include "core/dom/custom/CustomElementCallbackDispatcher.h"
#include "core/events/EventListener.h"
#include "core/dom/shadow/ShadowRoot.h"
#include "wtf/RefPtr.h"
namespace WebCore {
-// This function is customized to take advantage of the optional 4th argument: AttachBehavior
+// These functions are custom to prevent a wrapper lookup of the return value which is always
+// part of the arguments.
void V8Node::insertBeforeMethodCustom(const v8::FunctionCallbackInfo<v8::Value>& args)
{
v8::Handle<v8::Object> holder = args.Holder();
@@ -74,7 +75,6 @@
v8SetReturnValue(args, args[0]);
}
-// This function is customized to take advantage of the optional 4th argument: AttachBehavior
void V8Node::replaceChildMethodCustom(const v8::FunctionCallbackInfo<v8::Value>& args)
{
v8::Handle<v8::Object> holder = args.Holder();
@@ -106,7 +106,6 @@
v8SetReturnValue(args, args[0]);
}
-// This function is customized to take advantage of the optional 4th argument: AttachBehavior
void V8Node::appendChildMethodCustom(const v8::FunctionCallbackInfo<v8::Value>& args)
{
v8::Handle<v8::Object> holder = args.Holder();
diff --git a/Source/bindings/v8/custom/V8PerformanceEntryCustom.cpp b/Source/bindings/v8/custom/V8PerformanceEntryCustom.cpp
index a115da8..1519732 100644
--- a/Source/bindings/v8/custom/V8PerformanceEntryCustom.cpp
+++ b/Source/bindings/v8/custom/V8PerformanceEntryCustom.cpp
@@ -34,10 +34,10 @@
#include "V8PerformanceMark.h"
#include "V8PerformanceMeasure.h"
#include "V8PerformanceResourceTiming.h"
-#include "core/page/Performance.h"
-#include "core/page/PerformanceMark.h"
-#include "core/page/PerformanceMeasure.h"
-#include "core/page/PerformanceResourceTiming.h"
+#include "core/timing/Performance.h"
+#include "core/timing/PerformanceMark.h"
+#include "core/timing/PerformanceMeasure.h"
+#include "core/timing/PerformanceResourceTiming.h"
#include "wtf/RefPtr.h"
namespace WebCore {
diff --git a/Source/bindings/v8/custom/V8PopStateEventCustom.cpp b/Source/bindings/v8/custom/V8PopStateEventCustom.cpp
index 0c6c1c6..9bb5988 100644
--- a/Source/bindings/v8/custom/V8PopStateEventCustom.cpp
+++ b/Source/bindings/v8/custom/V8PopStateEventCustom.cpp
@@ -35,7 +35,7 @@
#include "bindings/v8/SerializedScriptValue.h"
#include "bindings/v8/V8HiddenPropertyName.h"
#include "core/events/PopStateEvent.h"
-#include "core/page/History.h"
+#include "core/frame/History.h"
namespace WebCore {
diff --git a/Source/bindings/v8/custom/V8PromiseCustom.cpp b/Source/bindings/v8/custom/V8PromiseCustom.cpp
index a0b7cbf..08a414b 100644
--- a/Source/bindings/v8/custom/V8PromiseCustom.cpp
+++ b/Source/bindings/v8/custom/V8PromiseCustom.cpp
@@ -31,21 +31,25 @@
#include "config.h"
#include "bindings/v8/custom/V8PromiseCustom.h"
+#include <v8.h>
#include "V8Promise.h"
#include "bindings/v8/ScopedPersistent.h"
#include "bindings/v8/ScriptFunctionCall.h"
#include "bindings/v8/ScriptState.h"
#include "bindings/v8/V8Binding.h"
+#include "bindings/v8/V8HiddenPropertyName.h"
#include "bindings/v8/V8PerIsolateData.h"
#include "bindings/v8/V8ScriptRunner.h"
#include "bindings/v8/WrapperTypeInfo.h"
#include "core/dom/Document.h"
-#include "core/page/DOMWindow.h"
-#include "core/platform/Task.h"
+#include "core/dom/ExecutionContextTask.h"
+#include "core/frame/DOMWindow.h"
#include "core/workers/WorkerGlobalScope.h"
+#include "platform/Task.h"
+#include "wtf/Deque.h"
#include "wtf/Functional.h"
+#include "wtf/Noncopyable.h"
#include "wtf/PassOwnPtr.h"
-#include <v8.h>
namespace WebCore {
@@ -66,18 +70,11 @@
return instanceTemplate;
}
-v8::Local<v8::ObjectTemplate> wrapperCallbackEnvironmentObjectTemplate(v8::Isolate* isolate)
+v8::Local<v8::ObjectTemplate> promiseAllEnvironmentObjectTemplate(v8::Isolate* isolate)
{
// This is only for getting a unique pointer which we can pass to privateTemplate.
static int privateTemplateUniqueKey = 0;
- return cachedObjectTemplate(&privateTemplateUniqueKey, V8PromiseCustom::WrapperCallbackEnvironmentFieldCount, isolate);
-}
-
-v8::Local<v8::ObjectTemplate> promiseEveryEnvironmentObjectTemplate(v8::Isolate* isolate)
-{
- // This is only for getting a unique pointer which we can pass to privateTemplate.
- static int privateTemplateUniqueKey = 0;
- return cachedObjectTemplate(&privateTemplateUniqueKey, V8PromiseCustom::PromiseEveryEnvironmentFieldCount, isolate);
+ return cachedObjectTemplate(&privateTemplateUniqueKey, V8PromiseCustom::PromiseAllEnvironmentFieldCount, isolate);
}
v8::Local<v8::ObjectTemplate> primitiveWrapperObjectTemplate(v8::Isolate* isolate)
@@ -94,28 +91,126 @@
return cachedObjectTemplate(&privateTemplateUniqueKey, V8PromiseCustom::InternalFieldCount, isolate);
}
-class PromiseTask : public ScriptExecutionContext::Task {
-public:
- PromiseTask(v8::Handle<v8::Function> callback, v8::Handle<v8::Object> receiver, v8::Handle<v8::Value> result, v8::Isolate* isolate)
- : m_callback(isolate, callback)
- , m_receiver(isolate, receiver)
- , m_result(isolate, result)
- {
- ASSERT(!m_callback.isEmpty());
- ASSERT(!m_receiver.isEmpty());
- ASSERT(!m_result.isEmpty());
- }
- virtual ~PromiseTask() { }
+void promiseResolveCallback(const v8::FunctionCallbackInfo<v8::Value>& args)
+{
+ ASSERT(!args.Data().IsEmpty());
+ v8::Local<v8::Object> promise = args.Data().As<v8::Object>();
+ v8::Local<v8::Value> result = v8::Undefined(args.GetIsolate());
+ if (args.Length() > 0)
+ result = args[0];
- virtual void performTask(ScriptExecutionContext*) OVERRIDE;
+ V8PromiseCustom::resolve(promise, result, args.GetIsolate());
+}
+
+void promiseRejectCallback(const v8::FunctionCallbackInfo<v8::Value>& args)
+{
+ ASSERT(!args.Data().IsEmpty());
+ v8::Local<v8::Object> promise = args.Data().As<v8::Object>();
+ v8::Local<v8::Value> result = v8::Undefined(args.GetIsolate());
+ if (args.Length() > 0)
+ result = args[0];
+
+ V8PromiseCustom::reject(promise, result, args.GetIsolate());
+}
+
+void promiseAllFulfillCallback(const v8::FunctionCallbackInfo<v8::Value>& args)
+{
+ v8::Isolate* isolate = args.GetIsolate();
+ ASSERT(!args.Data().IsEmpty());
+ v8::Local<v8::Object> environment = args.Data().As<v8::Object>();
+ v8::Local<v8::Value> result = v8::Undefined(isolate);
+ if (args.Length() > 0)
+ result = args[0];
+
+ v8::Local<v8::Object> promise = environment->GetInternalField(V8PromiseCustom::PromiseAllEnvironmentPromiseIndex).As<v8::Object>();
+ v8::Local<v8::Object> countdownWrapper = environment->GetInternalField(V8PromiseCustom::PromiseAllEnvironmentCountdownIndex).As<v8::Object>();
+ v8::Local<v8::Integer> index = environment->GetInternalField(V8PromiseCustom::PromiseAllEnvironmentIndexIndex).As<v8::Integer>();
+ v8::Local<v8::Array> results = environment->GetInternalField(V8PromiseCustom::PromiseAllEnvironmentResultsIndex).As<v8::Array>();
+
+ results->Set(index->Value(), result);
+
+ v8::Local<v8::Integer> countdown = countdownWrapper->GetInternalField(V8PromiseCustom::PrimitiveWrapperPrimitiveIndex).As<v8::Integer>();
+ ASSERT(countdown->Value() >= 1);
+ if (countdown->Value() == 1) {
+ V8PromiseCustom::resolve(promise, results, isolate);
+ return;
+ }
+ countdownWrapper->SetInternalField(V8PromiseCustom::PrimitiveWrapperPrimitiveIndex, v8::Integer::New(countdown->Value() - 1, isolate));
+}
+
+v8::Local<v8::Object> promiseAllEnvironment(v8::Handle<v8::Object> promise, v8::Handle<v8::Object> countdownWrapper, int index, v8::Handle<v8::Array> results, v8::Isolate* isolate)
+{
+ v8::Local<v8::ObjectTemplate> objectTemplate = promiseAllEnvironmentObjectTemplate(isolate);
+ v8::Local<v8::Object> environment = objectTemplate->NewInstance();
+
+ environment->SetInternalField(V8PromiseCustom::PromiseAllEnvironmentPromiseIndex, promise);
+ environment->SetInternalField(V8PromiseCustom::PromiseAllEnvironmentCountdownIndex, countdownWrapper);
+ environment->SetInternalField(V8PromiseCustom::PromiseAllEnvironmentIndexIndex, v8::Integer::New(index, isolate));
+ environment->SetInternalField(V8PromiseCustom::PromiseAllEnvironmentResultsIndex, results);
+ return environment;
+}
+
+// Clear |internal|'s derived array.
+void clearDerived(v8::Handle<v8::Object> internal)
+{
+ internal->SetInternalField(V8PromiseCustom::InternalFulfillCallbackIndex, v8::Array::New());
+ internal->SetInternalField(V8PromiseCustom::InternalRejectCallbackIndex, v8::Array::New());
+ internal->SetInternalField(V8PromiseCustom::InternalDerivedPromiseIndex, v8::Array::New());
+}
+
+// Add a tuple (|derivedPromise|, |onFulfilled|, |onRejected|) to
+// |internal|'s derived array.
+// |internal| must be a Promise internal object.
+// |derivedPromise| must be a Promise instance.
+// |onFulfilled| and |onRejected| can be an empty value respectively.
+void addToDerived(v8::Handle<v8::Object> internal, v8::Handle<v8::Object> derivedPromise, v8::Handle<v8::Function> onFulfilled, v8::Handle<v8::Function> onRejected, v8::Isolate* isolate)
+{
+ v8::Local<v8::Array> fulfillCallbacks = internal->GetInternalField(V8PromiseCustom::InternalFulfillCallbackIndex).As<v8::Array>();
+ v8::Local<v8::Array> rejectCallbacks = internal->GetInternalField(V8PromiseCustom::InternalRejectCallbackIndex).As<v8::Array>();
+ v8::Local<v8::Array> derivedPromises = internal->GetInternalField(V8PromiseCustom::InternalDerivedPromiseIndex).As<v8::Array>();
+
+ if (onFulfilled.IsEmpty()) {
+ fulfillCallbacks->Set(fulfillCallbacks->Length(), v8::Undefined(isolate));
+ } else {
+ fulfillCallbacks->Set(fulfillCallbacks->Length(), onFulfilled);
+ }
+
+ if (onRejected.IsEmpty()) {
+ rejectCallbacks->Set(rejectCallbacks->Length(), v8::Undefined(isolate));
+ } else {
+ rejectCallbacks->Set(rejectCallbacks->Length(), onRejected);
+ }
+
+ ASSERT(!derivedPromise.IsEmpty());
+ derivedPromises->Set(derivedPromises->Length(), derivedPromise);
+
+ // Since they are treated as a tuple,
+ // we need to guaranteed that the length of these arrays are same.
+ ASSERT(fulfillCallbacks->Length() == rejectCallbacks->Length() && rejectCallbacks->Length() == derivedPromises->Length());
+}
+
+class CallHandlerTask : public ExecutionContextTask {
+public:
+ CallHandlerTask(v8::Handle<v8::Object> promise, v8::Handle<v8::Function> handler, v8::Handle<v8::Value> argument, v8::Isolate* isolate)
+ : m_promise(isolate, promise)
+ , m_handler(isolate, handler)
+ , m_argument(isolate, argument)
+ {
+ ASSERT(!m_promise.isEmpty());
+ ASSERT(!m_handler.isEmpty());
+ ASSERT(!m_argument.isEmpty());
+ }
+ virtual ~CallHandlerTask() { }
+
+ virtual void performTask(ExecutionContext*) OVERRIDE;
private:
- ScopedPersistent<v8::Function> m_callback;
- ScopedPersistent<v8::Object> m_receiver;
- ScopedPersistent<v8::Value> m_result;
+ ScopedPersistent<v8::Object> m_promise;
+ ScopedPersistent<v8::Function> m_handler;
+ ScopedPersistent<v8::Value> m_argument;
};
-void PromiseTask::performTask(ScriptExecutionContext* context)
+void CallHandlerTask::performTask(ExecutionContext* context)
{
ASSERT(context);
if (context->activeDOMObjectsAreStopped())
@@ -134,161 +229,251 @@
v8::HandleScope handleScope(isolate);
v8::Handle<v8::Context> v8Context = state->context();
v8::Context::Scope scope(v8Context);
- v8::Handle<v8::Value> args[] = { m_result.newLocal(isolate) };
- V8ScriptRunner::callFunction(m_callback.newLocal(isolate), context, m_receiver.newLocal(isolate), WTF_ARRAY_LENGTH(args), args, isolate);
+ v8::Handle<v8::Value> args[] = { m_argument.newLocal(isolate) };
+ v8::TryCatch trycatch;
+ v8::Local<v8::Value> value = V8ScriptRunner::callFunction(m_handler.newLocal(isolate), context, v8::Undefined(isolate), WTF_ARRAY_LENGTH(args), args, isolate);
+ if (value.IsEmpty()) {
+ V8PromiseCustom::reject(m_promise.newLocal(isolate), trycatch.Exception(), isolate);
+ } else {
+ V8PromiseCustom::resolve(m_promise.newLocal(isolate), value, isolate);
+ }
+}
+
+class UpdateDerivedTask : public ExecutionContextTask {
+public:
+ UpdateDerivedTask(v8::Handle<v8::Object> promise, v8::Handle<v8::Function> onFulfilled, v8::Handle<v8::Function> onRejected, v8::Handle<v8::Object> originatorValueObject, v8::Isolate* isolate)
+ : m_promise(isolate, promise)
+ , m_onFulfilled(isolate, onFulfilled)
+ , m_onRejected(isolate, onRejected)
+ , m_originatorValueObject(isolate, originatorValueObject)
+ {
+ ASSERT(!m_promise.isEmpty());
+ ASSERT(!m_originatorValueObject.isEmpty());
+ }
+ virtual ~UpdateDerivedTask() { }
+
+ virtual void performTask(ExecutionContext*) OVERRIDE;
+
+private:
+ ScopedPersistent<v8::Object> m_promise;
+ ScopedPersistent<v8::Function> m_onFulfilled;
+ ScopedPersistent<v8::Function> m_onRejected;
+ ScopedPersistent<v8::Object> m_originatorValueObject;
};
-v8::Handle<v8::Value> postTask(v8::Handle<v8::Function> callback, v8::Handle<v8::Object> receiver, v8::Handle<v8::Value> value, v8::Isolate* isolate)
+void UpdateDerivedTask::performTask(ExecutionContext* context)
{
- ScriptExecutionContext* scriptExecutionContext = getScriptExecutionContext();
- ASSERT(scriptExecutionContext && scriptExecutionContext->isContextThread());
- scriptExecutionContext->postTask(adoptPtr(new PromiseTask(callback, receiver, value, isolate)));
- return v8::Undefined(isolate);
-}
+ ASSERT(context);
+ if (context->activeDOMObjectsAreStopped())
+ return;
-void wrapperCallback(const v8::FunctionCallbackInfo<v8::Value>& args)
-{
- v8::Isolate* isolate = args.GetIsolate();
- ASSERT(!args.Data().IsEmpty());
- v8::Local<v8::Object> environment = args.Data().As<v8::Object>();
- v8::Local<v8::Value> result = v8::Undefined(isolate);
- if (args.Length() > 0)
- result = args[0];
+ ScriptState* state = 0;
+ if (context->isDocument()) {
+ state = mainWorldScriptState(static_cast<Document*>(context)->frame());
+ } else {
+ ASSERT(context->isWorkerGlobalScope());
+ state = scriptStateFromWorkerGlobalScope(toWorkerGlobalScope(context));
+ }
+ ASSERT(state);
- v8::Local<v8::Object> promise = environment->GetInternalField(V8PromiseCustom::WrapperCallbackEnvironmentPromiseIndex).As<v8::Object>();
- v8::Local<v8::Function> callback = environment->GetInternalField(V8PromiseCustom::WrapperCallbackEnvironmentCallbackIndex).As<v8::Function>();
+ v8::Isolate* isolate = state->isolate();
+ v8::HandleScope handleScope(isolate);
+ v8::Handle<v8::Context> v8Context = state->context();
+ v8::Context::Scope scope(v8Context);
- v8::Local<v8::Value> argv[] = {
- result,
- };
+ v8::Local<v8::Object> originatorValueObject = m_originatorValueObject.newLocal(isolate);
+ v8::Local<v8::Value> coercedAlready = originatorValueObject->GetHiddenValue(V8HiddenPropertyName::thenableHiddenPromise(isolate));
+ if (!coercedAlready.IsEmpty() && coercedAlready->IsObject()) {
+ ASSERT(V8PromiseCustom::isPromise(coercedAlready.As<v8::Object>(), isolate));
+ V8PromiseCustom::updateDerivedFromPromise(m_promise.newLocal(isolate), m_onFulfilled.newLocal(isolate), m_onRejected.newLocal(isolate), coercedAlready.As<v8::Object>(), isolate);
+ return;
+ }
+
+ v8::Local<v8::Value> then;
v8::TryCatch trycatch;
- result = V8ScriptRunner::callFunction(callback, getScriptExecutionContext(), promise, WTF_ARRAY_LENGTH(argv), argv, isolate);
- if (result.IsEmpty()) {
- V8PromiseCustom::reject(promise, trycatch.Exception(), V8PromiseCustom::Synchronous, isolate);
+ then = originatorValueObject->Get(v8::String::NewSymbol("then"));
+ if (then.IsEmpty()) {
+ // If calling the [[Get]] internal method threw an exception, catch it and run updateDerivedFromReason.
+ V8PromiseCustom::updateDerivedFromReason(m_promise.newLocal(isolate), m_onRejected.newLocal(isolate), trycatch.Exception(), isolate);
return;
}
- V8PromiseCustom::resolve(promise, result, V8PromiseCustom::Synchronous, isolate);
-}
-v8::Local<v8::Object> wrapperCallbackEnvironment(v8::Handle<v8::Object> promise, v8::Handle<v8::Function> callback, v8::Isolate* isolate)
-{
- v8::Local<v8::ObjectTemplate> objectTemplate = wrapperCallbackEnvironmentObjectTemplate(isolate);
- v8::Local<v8::Object> environment = objectTemplate->NewInstance();
- environment->SetInternalField(V8PromiseCustom::WrapperCallbackEnvironmentPromiseIndex, promise);
- environment->SetInternalField(V8PromiseCustom::WrapperCallbackEnvironmentCallbackIndex, callback);
- return environment;
-}
-
-void promiseFulfillCallback(const v8::FunctionCallbackInfo<v8::Value>& args)
-{
- ASSERT(!args.Data().IsEmpty());
- v8::Local<v8::Object> promise = args.Data().As<v8::Object>();
- v8::Local<v8::Value> result = v8::Undefined(args.GetIsolate());
- if (args.Length() > 0)
- result = args[0];
-
- V8PromiseCustom::fulfill(promise, result, V8PromiseCustom::Synchronous, args.GetIsolate());
-}
-
-void promiseResolveCallback(const v8::FunctionCallbackInfo<v8::Value>& args)
-{
- ASSERT(!args.Data().IsEmpty());
- v8::Local<v8::Object> promise = args.Data().As<v8::Object>();
- v8::Local<v8::Value> result = v8::Undefined(args.GetIsolate());
- if (args.Length() > 0)
- result = args[0];
-
- V8PromiseCustom::resolve(promise, result, V8PromiseCustom::Synchronous, args.GetIsolate());
-}
-
-void promiseRejectCallback(const v8::FunctionCallbackInfo<v8::Value>& args)
-{
- ASSERT(!args.Data().IsEmpty());
- v8::Local<v8::Object> promise = args.Data().As<v8::Object>();
- v8::Local<v8::Value> result = v8::Undefined(args.GetIsolate());
- if (args.Length() > 0)
- result = args[0];
-
- V8PromiseCustom::reject(promise, result, V8PromiseCustom::Synchronous, args.GetIsolate());
-}
-
-void callCallbacks(v8::Handle<v8::Array> callbacks, v8::Handle<v8::Value> result, V8PromiseCustom::SynchronousMode mode, v8::Isolate* isolate)
-{
- v8::Local<v8::Object> global = isolate->GetCurrentContext()->Global();
- for (uint32_t i = 0, length = callbacks->Length(); i < length; ++i) {
- v8::Local<v8::Value> value = callbacks->Get(i);
- v8::Local<v8::Function> callback = value.As<v8::Function>();
- V8PromiseCustom::call(callback, global, result, mode, isolate);
- }
-}
-
-void promiseEveryFulfillCallback(const v8::FunctionCallbackInfo<v8::Value>& args)
-{
- v8::Isolate* isolate = args.GetIsolate();
- ASSERT(!args.Data().IsEmpty());
- v8::Local<v8::Object> environment = args.Data().As<v8::Object>();
- v8::Local<v8::Value> result = v8::Undefined(isolate);
- if (args.Length() > 0)
- result = args[0];
-
- v8::Local<v8::Object> promise = environment->GetInternalField(V8PromiseCustom::PromiseEveryEnvironmentPromiseIndex).As<v8::Object>();
- v8::Local<v8::Object> countdownWrapper = environment->GetInternalField(V8PromiseCustom::PromiseEveryEnvironmentCountdownIndex).As<v8::Object>();
- v8::Local<v8::Integer> index = environment->GetInternalField(V8PromiseCustom::PromiseEveryEnvironmentIndexIndex).As<v8::Integer>();
- v8::Local<v8::Array> results = environment->GetInternalField(V8PromiseCustom::PromiseEveryEnvironmentResultsIndex).As<v8::Array>();
-
- results->Set(index->Value(), result);
-
- v8::Local<v8::Integer> countdown = countdownWrapper->GetInternalField(V8PromiseCustom::PrimitiveWrapperPrimitiveIndex).As<v8::Integer>();
- ASSERT(countdown->Value() >= 1);
- if (countdown->Value() == 1) {
- V8PromiseCustom::resolve(promise, results, V8PromiseCustom::Synchronous, isolate);
+ if (then->IsFunction()) {
+ ASSERT(then->IsObject());
+ v8::Local<v8::Object> coerced = V8PromiseCustom::coerceThenable(originatorValueObject, then.As<v8::Function>(), isolate);
+ V8PromiseCustom::updateDerivedFromPromise(m_promise.newLocal(isolate), m_onFulfilled.newLocal(isolate), m_onRejected.newLocal(isolate), coerced, isolate);
return;
}
- countdownWrapper->SetInternalField(V8PromiseCustom::PrimitiveWrapperPrimitiveIndex, v8::Integer::New(countdown->Value() - 1, isolate));
+
+ V8PromiseCustom::updateDerivedFromValue(m_promise.newLocal(isolate), m_onFulfilled.newLocal(isolate), originatorValueObject, isolate);
}
-v8::Local<v8::Object> promiseEveryEnvironment(v8::Handle<v8::Object> promise, v8::Handle<v8::Object> countdownWrapper, int index, v8::Handle<v8::Array> results, v8::Isolate* isolate)
-{
- v8::Local<v8::ObjectTemplate> objectTemplate = promiseEveryEnvironmentObjectTemplate(isolate);
- v8::Local<v8::Object> environment = objectTemplate->NewInstance();
+// Since Promises state propagation routines are executed recursively, they cause
+// stack overflow.
+// (e.g. UpdateDerived -> UpdateDerivedFromValue -> SetValue ->
+// PropagateToDerived -> UpdateDerived)
+//
+// To fix that, we introduce PromisePropagator. It holds the stack. When
+// propagating the result to the derived tuples, we append the derived tuples
+// to the stack. After that, we drain the stack to propagate the result to
+// the stored tuples.
+//
+// PromisePropagator should be held on the stack and should not be held
+// as other object's member. PromisePropagator holds Derived tuples. Since
+// Derived tuples hold persistent handles to JS objects, retaining
+// PromisePropagator in the heap causes memory leaks.
+//
+class PromisePropagator {
+ WTF_MAKE_NONCOPYABLE(PromisePropagator);
+public:
+ PromisePropagator() { }
- environment->SetInternalField(V8PromiseCustom::PromiseEveryEnvironmentPromiseIndex, promise);
- environment->SetInternalField(V8PromiseCustom::PromiseEveryEnvironmentCountdownIndex, countdownWrapper);
- environment->SetInternalField(V8PromiseCustom::PromiseEveryEnvironmentIndexIndex, v8::Integer::New(index, isolate));
- environment->SetInternalField(V8PromiseCustom::PromiseEveryEnvironmentResultsIndex, results);
- return environment;
+ void performPropagation(v8::Isolate*);
+
+ void setValue(v8::Handle<v8::Object> promise, v8::Handle<v8::Value>, v8::Isolate*);
+ void setReason(v8::Handle<v8::Object> promise, v8::Handle<v8::Value>, v8::Isolate*);
+ void propagateToDerived(v8::Handle<v8::Object> promise, v8::Isolate*);
+ void updateDerived(v8::Handle<v8::Object> derivedPromise, v8::Handle<v8::Function> onFulfilled, v8::Handle<v8::Function> onRejected, v8::Handle<v8::Object> originator, v8::Isolate*);
+ void updateDerivedFromValue(v8::Handle<v8::Object> derivedPromise, v8::Handle<v8::Function> onFulfilled, v8::Handle<v8::Value>, v8::Isolate*);
+ void updateDerivedFromReason(v8::Handle<v8::Object> derivedPromise, v8::Handle<v8::Function> onRejected, v8::Handle<v8::Value>, v8::Isolate*);
+ void updateDerivedFromPromise(v8::Handle<v8::Object> derivedPromise, v8::Handle<v8::Function> onFulfilled, v8::Handle<v8::Function> onRejected, v8::Handle<v8::Object> promise, v8::Isolate*);
+
+private:
+ class Derived {
+ WTF_MAKE_NONCOPYABLE(Derived);
+ public:
+ Derived(v8::Handle<v8::Object> promise, v8::Handle<v8::Function> onFulfilled, v8::Handle<v8::Function> onRejected, v8::Handle<v8::Object> originator, v8::Isolate* isolate)
+ : m_promise(isolate, promise)
+ , m_onFulfilled(isolate, onFulfilled)
+ , m_onRejected(isolate, onRejected)
+ , m_originator(isolate, originator)
+ {
+ ASSERT(!m_promise.isEmpty());
+ ASSERT(!m_originator.isEmpty());
+ }
+
+ static PassOwnPtr<Derived> create(v8::Handle<v8::Object> promise, v8::Handle<v8::Function> onFulfilled, v8::Handle<v8::Function> onRejected, v8::Handle<v8::Object> originator, v8::Isolate* isolate)
+ {
+ return adoptPtr(new Derived(promise, onFulfilled, onRejected, originator, isolate));
+ }
+
+ v8::Local<v8::Object> promise(v8::Isolate* isolate) const { return m_promise.newLocal(isolate); }
+ v8::Local<v8::Function> onFulfilled(v8::Isolate* isolate) const { return m_onFulfilled.newLocal(isolate); }
+ v8::Local<v8::Function> onRejected(v8::Isolate* isolate) const { return m_onRejected.newLocal(isolate); }
+ v8::Local<v8::Object> originator(v8::Isolate* isolate) const { return m_originator.newLocal(isolate); }
+
+ private:
+ ScopedPersistent<v8::Object> m_promise;
+ ScopedPersistent<v8::Function> m_onFulfilled;
+ ScopedPersistent<v8::Function> m_onRejected;
+ ScopedPersistent<v8::Object> m_originator;
+ };
+
+ Deque<OwnPtr<Derived> > m_derivedStack;
+};
+
+void PromisePropagator::performPropagation(v8::Isolate* isolate)
+{
+ while (!m_derivedStack.isEmpty()) {
+ v8::HandleScope handleScope(isolate);
+ OwnPtr<Derived> derived = m_derivedStack.takeLast();
+ updateDerived(derived->promise(isolate), derived->onFulfilled(isolate), derived->onRejected(isolate), derived->originator(isolate), isolate);
+ }
}
-void promiseResolve(const v8::FunctionCallbackInfo<v8::Value>& args)
+void PromisePropagator::setValue(v8::Handle<v8::Object> promise, v8::Handle<v8::Value> value, v8::Isolate* isolate)
{
- v8::Local<v8::Object> promise = args.Data().As<v8::Object>();
- ASSERT(!promise.IsEmpty());
v8::Local<v8::Object> internal = V8PromiseCustom::getInternal(promise);
- if (V8PromiseCustom::getState(internal) != V8PromiseCustom::Pending)
- return;
- v8::Isolate* isolate = args.GetIsolate();
- V8PromiseCustom::setState(V8PromiseCustom::getInternal(promise), V8PromiseCustom::Following, isolate);
-
- v8::Local<v8::Value> result = v8::Undefined(isolate);
- if (args.Length() > 0)
- result = args[0];
- V8PromiseCustom::resolve(promise, result, V8PromiseCustom::Asynchronous, isolate);
+ ASSERT(V8PromiseCustom::getState(internal) != V8PromiseCustom::Fulfilled && V8PromiseCustom::getState(internal) != V8PromiseCustom::Rejected);
+ V8PromiseCustom::setState(internal, V8PromiseCustom::Fulfilled, value, isolate);
+ propagateToDerived(promise, isolate);
}
-void promiseReject(const v8::FunctionCallbackInfo<v8::Value>& args)
+void PromisePropagator::setReason(v8::Handle<v8::Object> promise, v8::Handle<v8::Value> reason, v8::Isolate* isolate)
{
- v8::Local<v8::Object> promise = args.Data().As<v8::Object>();
- ASSERT(!promise.IsEmpty());
v8::Local<v8::Object> internal = V8PromiseCustom::getInternal(promise);
- if (V8PromiseCustom::getState(internal) != V8PromiseCustom::Pending)
- return;
- v8::Isolate* isolate = args.GetIsolate();
- V8PromiseCustom::setState(V8PromiseCustom::getInternal(promise), V8PromiseCustom::Following, isolate);
+ ASSERT(V8PromiseCustom::getState(internal) != V8PromiseCustom::Fulfilled && V8PromiseCustom::getState(internal) != V8PromiseCustom::Rejected);
+ V8PromiseCustom::setState(internal, V8PromiseCustom::Rejected, reason, isolate);
+ propagateToDerived(promise, isolate);
+}
- v8::Local<v8::Value> result = v8::Undefined(isolate);
- if (args.Length() > 0)
- result = args[0];
- V8PromiseCustom::reject(promise, result, V8PromiseCustom::Asynchronous, isolate);
+void PromisePropagator::propagateToDerived(v8::Handle<v8::Object> promise, v8::Isolate* isolate)
+{
+ v8::Local<v8::Object> internal = V8PromiseCustom::getInternal(promise);
+ ASSERT(V8PromiseCustom::getState(internal) == V8PromiseCustom::Fulfilled || V8PromiseCustom::getState(internal) == V8PromiseCustom::Rejected);
+ v8::Local<v8::Array> fulfillCallbacks = internal->GetInternalField(V8PromiseCustom::InternalFulfillCallbackIndex).As<v8::Array>();
+ v8::Local<v8::Array> rejectCallbacks = internal->GetInternalField(V8PromiseCustom::InternalRejectCallbackIndex).As<v8::Array>();
+ v8::Local<v8::Array> derivedPromises = internal->GetInternalField(V8PromiseCustom::InternalDerivedPromiseIndex).As<v8::Array>();
+ // Since they are treated as a tuple,
+ // we need to guaranteed that the length of these arrays are same.
+ ASSERT(fulfillCallbacks->Length() == rejectCallbacks->Length() && rejectCallbacks->Length() == derivedPromises->Length());
+
+ // Append Derived tuple to the stack in reverse order.
+ for (uint32_t count = 0, length = derivedPromises->Length(); count < length; ++count) {
+ uint32_t i = length - count - 1;
+ v8::Local<v8::Object> derivedPromise = derivedPromises->Get(i).As<v8::Object>();
+
+ v8::Local<v8::Function> onFulfilled, onRejected;
+ v8::Local<v8::Value> onFulfilledValue = fulfillCallbacks->Get(i);
+ if (onFulfilledValue->IsFunction()) {
+ onFulfilled = onFulfilledValue.As<v8::Function>();
+ }
+ v8::Local<v8::Value> onRejectedValue = rejectCallbacks->Get(i);
+ if (onRejectedValue->IsFunction()) {
+ onRejected = onRejectedValue.As<v8::Function>();
+ }
+
+ m_derivedStack.append(Derived::create(derivedPromise, onFulfilled, onRejected, promise, isolate));
+ }
+ clearDerived(internal);
+}
+
+void PromisePropagator::updateDerivedFromValue(v8::Handle<v8::Object> derivedPromise, v8::Handle<v8::Function> onFulfilled, v8::Handle<v8::Value> value, v8::Isolate* isolate)
+{
+ if (!onFulfilled.IsEmpty()) {
+ V8PromiseCustom::callHandler(derivedPromise, onFulfilled, value, isolate);
+ } else {
+ setValue(derivedPromise, value, isolate);
+ }
+}
+
+void PromisePropagator::updateDerivedFromReason(v8::Handle<v8::Object> derivedPromise, v8::Handle<v8::Function> onRejected, v8::Handle<v8::Value> reason, v8::Isolate* isolate)
+{
+ if (!onRejected.IsEmpty()) {
+ V8PromiseCustom::callHandler(derivedPromise, onRejected, reason, isolate);
+ } else {
+ setReason(derivedPromise, reason, isolate);
+ }
+}
+
+void PromisePropagator::updateDerived(v8::Handle<v8::Object> derivedPromise, v8::Handle<v8::Function> onFulfilled, v8::Handle<v8::Function> onRejected, v8::Handle<v8::Object> originator, v8::Isolate* isolate)
+{
+ v8::Local<v8::Object> originatorInternal = V8PromiseCustom::getInternal(originator);
+ V8PromiseCustom::PromiseState originatorState = V8PromiseCustom::getState(originatorInternal);
+ ASSERT(originatorState == V8PromiseCustom::Fulfilled || originatorState == V8PromiseCustom::Rejected);
+ v8::Local<v8::Value> originatorValue = originatorInternal->GetInternalField(V8PromiseCustom::InternalResultIndex);
+ if (originatorState == V8PromiseCustom::Fulfilled) {
+ if (originatorValue->IsObject()) {
+ ExecutionContext* executionContext = getExecutionContext();
+ ASSERT(executionContext && executionContext->isContextThread());
+ executionContext->postTask(adoptPtr(new UpdateDerivedTask(derivedPromise, onFulfilled, onRejected, originatorValue.As<v8::Object>(), isolate)));
+ } else {
+ updateDerivedFromValue(derivedPromise, onFulfilled, originatorValue, isolate);
+ }
+ } else {
+ updateDerivedFromReason(derivedPromise, onRejected, originatorValue, isolate);
+ }
+}
+
+void PromisePropagator::updateDerivedFromPromise(v8::Handle<v8::Object> derivedPromise, v8::Handle<v8::Function> onFulfilled, v8::Handle<v8::Function> onRejected, v8::Handle<v8::Object> promise, v8::Isolate* isolate)
+{
+ v8::Local<v8::Object> internal = V8PromiseCustom::getInternal(promise);
+ V8PromiseCustom::PromiseState state = V8PromiseCustom::getState(internal);
+ if (state == V8PromiseCustom::Fulfilled || state == V8PromiseCustom::Rejected) {
+ updateDerived(derivedPromise, onFulfilled, onRejected, promise, isolate);
+ } else {
+ addToDerived(internal, derivedPromise, onFulfilled, onRejected, isolate);
+ }
}
} // namespace
@@ -304,14 +489,13 @@
v8::Local<v8::Function> init = args[0].As<v8::Function>();
v8::Local<v8::Object> promise = V8PromiseCustom::createPromise(args.Holder(), isolate);
v8::Handle<v8::Value> argv[] = {
- createClosure(promiseResolve, promise, isolate),
- createClosure(promiseReject, promise, isolate)
+ createClosure(promiseResolveCallback, promise, isolate),
+ createClosure(promiseRejectCallback, promise, isolate)
};
v8::TryCatch trycatch;
- if (V8ScriptRunner::callFunction(init, getScriptExecutionContext(), promise, WTF_ARRAY_LENGTH(argv), argv, isolate).IsEmpty()) {
+ if (V8ScriptRunner::callFunction(init, getExecutionContext(), v8::Undefined(isolate), WTF_ARRAY_LENGTH(argv), argv, isolate).IsEmpty()) {
// An exception is thrown. Reject the promise if its resolved flag is unset.
- if (V8PromiseCustom::getState(V8PromiseCustom::getInternal(promise)) == V8PromiseCustom::Pending)
- V8PromiseCustom::reject(promise, trycatch.Exception(), V8PromiseCustom::Asynchronous, isolate);
+ V8PromiseCustom::reject(promise, trycatch.Exception(), isolate);
}
v8SetReturnValue(args, promise);
return;
@@ -320,48 +504,48 @@
void V8Promise::thenMethodCustom(const v8::FunctionCallbackInfo<v8::Value>& args)
{
v8::Isolate* isolate = args.GetIsolate();
- v8::Local<v8::Function> fulfillWrapper, rejectWrapper;
+ v8::Local<v8::Function> onFulfilled, onRejected;
v8::Local<v8::Object> promise = V8PromiseCustom::createPromise(args.Holder(), isolate);
if (args.Length() > 0 && !args[0]->IsUndefined()) {
if (!args[0]->IsFunction()) {
- v8SetReturnValue(args, throwTypeError("fulfillCallback must be a function or undefined", isolate));
+ v8SetReturnValue(args, throwTypeError("onFulfilled must be a function or undefined", isolate));
return;
}
- fulfillWrapper = createClosure(wrapperCallback, wrapperCallbackEnvironment(promise, args[0].As<v8::Function>(), isolate), isolate);
- } else {
- fulfillWrapper = createClosure(promiseFulfillCallback, promise, isolate);
+ onFulfilled = args[0].As<v8::Function>();
}
if (args.Length() > 1 && !args[1]->IsUndefined()) {
if (!args[1]->IsFunction()) {
- v8SetReturnValue(args, throwTypeError("rejectCallback must be a function or undefined", isolate));
+ v8SetReturnValue(args, throwTypeError("onRejected must be a function or undefined", isolate));
return;
}
- rejectWrapper = createClosure(wrapperCallback, wrapperCallbackEnvironment(promise, args[1].As<v8::Function>(), isolate), isolate);
- } else {
- rejectWrapper = createClosure(promiseRejectCallback, promise, isolate);
+ onRejected = args[1].As<v8::Function>();
}
- V8PromiseCustom::append(args.Holder(), fulfillWrapper, rejectWrapper, isolate);
- v8SetReturnValue(args, promise);
+ v8SetReturnValue(args, V8PromiseCustom::then(args.Holder(), onFulfilled, onRejected, isolate));
+}
+
+void V8Promise::castMethodCustom(const v8::FunctionCallbackInfo<v8::Value>& args)
+{
+ v8::Isolate* isolate = args.GetIsolate();
+ v8::Local<v8::Value> result = v8::Undefined(isolate);
+ if (args.Length() > 0)
+ result = args[0];
+
+ v8SetReturnValue(args, V8PromiseCustom::toPromise(result, isolate));
}
void V8Promise::catchMethodCustom(const v8::FunctionCallbackInfo<v8::Value>& args)
{
v8::Isolate* isolate = args.GetIsolate();
- v8::Local<v8::Function> fulfillWrapper, rejectWrapper;
- v8::Local<v8::Object> promise = V8PromiseCustom::createPromise(args.Holder(), isolate);
+ v8::Local<v8::Function> onFulfilled, onRejected;
if (args.Length() > 0 && !args[0]->IsUndefined()) {
if (!args[0]->IsFunction()) {
- v8SetReturnValue(args, throwTypeError("rejectCallback must be a function or undefined", isolate));
+ v8SetReturnValue(args, throwTypeError("onRejected must be a function or undefined", isolate));
return;
}
- rejectWrapper = createClosure(wrapperCallback, wrapperCallbackEnvironment(promise, args[0].As<v8::Function>(), isolate), isolate);
- } else {
- rejectWrapper = createClosure(promiseRejectCallback, promise, isolate);
+ onRejected = args[0].As<v8::Function>();
}
- fulfillWrapper = createClosure(promiseFulfillCallback, promise, isolate);
- V8PromiseCustom::append(args.Holder(), fulfillWrapper, rejectWrapper, isolate);
- v8SetReturnValue(args, promise);
+ v8SetReturnValue(args, V8PromiseCustom::then(args.Holder(), onFulfilled, onRejected, isolate));
}
void V8Promise::resolveMethodCustom(const v8::FunctionCallbackInfo<v8::Value>& args)
@@ -372,7 +556,7 @@
result = args[0];
v8::Local<v8::Object> promise = V8PromiseCustom::createPromise(args.Holder(), isolate);
- V8PromiseCustom::resolve(promise, result, V8PromiseCustom::Asynchronous, isolate);
+ V8PromiseCustom::resolve(promise, result, isolate);
v8SetReturnValue(args, promise);
}
@@ -384,55 +568,67 @@
result = args[0];
v8::Local<v8::Object> promise = V8PromiseCustom::createPromise(args.Holder(), isolate);
- V8PromiseCustom::reject(promise, result, V8PromiseCustom::Asynchronous, isolate);
+ V8PromiseCustom::reject(promise, result, isolate);
v8SetReturnValue(args, promise);
}
-void V8Promise::anyMethodCustom(const v8::FunctionCallbackInfo<v8::Value>& args)
+void V8Promise::raceMethodCustom(const v8::FunctionCallbackInfo<v8::Value>& args)
{
v8::Isolate* isolate = args.GetIsolate();
v8::Local<v8::Object> promise = V8PromiseCustom::createPromise(args.Holder(), isolate);
- if (!args.Length()) {
- V8PromiseCustom::resolve(promise, v8::Undefined(isolate), V8PromiseCustom::Asynchronous, isolate);
+ if (!args.Length() || !args[0]->IsArray()) {
v8SetReturnValue(args, promise);
return;
}
- v8::Local<v8::Function> fulfillCallback = createClosure(promiseResolveCallback, promise, isolate);
- v8::Local<v8::Function> rejectCallback = createClosure(promiseRejectCallback, promise, isolate);
+ // FIXME: Now we limit the iterable type to the Array type.
+ v8::Local<v8::Array> iterable = args[0].As<v8::Array>();
+ v8::Local<v8::Function> onFulfilled = createClosure(promiseResolveCallback, promise, isolate);
+ v8::Local<v8::Function> onRejected = createClosure(promiseRejectCallback, promise, isolate);
- for (int i = 0; i < args.Length(); ++i) {
- v8::Local<v8::Object> eachPromise = V8PromiseCustom::createPromise(args.Holder(), isolate);
- V8PromiseCustom::resolve(eachPromise, args[i], V8PromiseCustom::Asynchronous, isolate);
- V8PromiseCustom::append(eachPromise, fulfillCallback, rejectCallback, isolate);
+ for (unsigned i = 0, length = iterable->Length(); i < length; ++i) {
+ // Array-holes should not be skipped by for-of iteration semantics.
+ V8TRYCATCH_VOID(v8::Local<v8::Value>, nextValue, iterable->Get(i));
+ v8::Local<v8::Object> nextPromise = V8PromiseCustom::toPromise(nextValue, isolate);
+ V8PromiseCustom::then(nextPromise, onFulfilled, onRejected, isolate);
}
v8SetReturnValue(args, promise);
}
-void V8Promise::everyMethodCustom(const v8::FunctionCallbackInfo<v8::Value>& args)
+void V8Promise::allMethodCustom(const v8::FunctionCallbackInfo<v8::Value>& args)
{
v8::Isolate* isolate = args.GetIsolate();
v8::Local<v8::Object> promise = V8PromiseCustom::createPromise(args.Holder(), isolate);
+ v8::Local<v8::Array> results = v8::Array::New();
- if (!args.Length()) {
- V8PromiseCustom::resolve(promise, v8::Undefined(isolate), V8PromiseCustom::Asynchronous, isolate);
+ if (!args.Length() || !args[0]->IsArray()) {
+ V8PromiseCustom::resolve(promise, results, isolate);
+ v8SetReturnValue(args, promise);
+ return;
+ }
+
+ // FIXME: Now we limit the iterable type to the Array type.
+ v8::Local<v8::Array> iterable = args[0].As<v8::Array>();
+
+ if (!iterable->Length()) {
+ V8PromiseCustom::resolve(promise, results, isolate);
v8SetReturnValue(args, promise);
return;
}
v8::Local<v8::ObjectTemplate> objectTemplate = primitiveWrapperObjectTemplate(isolate);
v8::Local<v8::Object> countdownWrapper = objectTemplate->NewInstance();
- countdownWrapper->SetInternalField(V8PromiseCustom::PrimitiveWrapperPrimitiveIndex, v8::Integer::New(args.Length(), isolate));
- v8::Local<v8::Array> results = v8::Array::New();
+ countdownWrapper->SetInternalField(V8PromiseCustom::PrimitiveWrapperPrimitiveIndex, v8::Integer::New(iterable->Length(), isolate));
- v8::Local<v8::Function> rejectCallback = createClosure(promiseRejectCallback, promise, isolate);
- for (int i = 0; i < args.Length(); ++i) {
- v8::Local<v8::Object> environment = promiseEveryEnvironment(promise, countdownWrapper, i, results, isolate);
- v8::Local<v8::Function> fulfillCallback = createClosure(promiseEveryFulfillCallback, environment, isolate);
- v8::Local<v8::Object> eachPromise = V8PromiseCustom::createPromise(args.Holder(), isolate);
- V8PromiseCustom::resolve(eachPromise, args[i], V8PromiseCustom::Asynchronous, isolate);
- V8PromiseCustom::append(eachPromise, fulfillCallback, rejectCallback, isolate);
+ v8::Local<v8::Function> onRejected = createClosure(promiseRejectCallback, promise, isolate);
+ for (unsigned i = 0, length = iterable->Length(); i < length; ++i) {
+ // Array-holes should not be skipped by for-of iteration semantics.
+ v8::Local<v8::Object> environment = promiseAllEnvironment(promise, countdownWrapper, i, results, isolate);
+ v8::Local<v8::Function> onFulfilled = createClosure(promiseAllFulfillCallback, environment, isolate);
+ V8TRYCATCH_VOID(v8::Local<v8::Value>, nextValue, iterable->Get(i));
+ v8::Local<v8::Object> nextPromise = V8PromiseCustom::toPromise(nextValue, isolate);
+ V8PromiseCustom::then(nextPromise, onFulfilled, onRejected, isolate);
}
v8SetReturnValue(args, promise);
}
@@ -445,118 +641,19 @@
v8::Local<v8::Object> internal = internalTemplate->NewInstance();
v8::Local<v8::Object> promise = V8DOMWrapper::createWrapper(creationContext, &V8Promise::info, 0, isolate);
- clearInternal(internal, V8PromiseCustom::Pending, v8::Undefined(isolate), isolate);
+ clearDerived(internal);
+ setState(internal, Pending, v8::Undefined(isolate), isolate);
promise->SetInternalField(v8DOMWrapperObjectIndex, internal);
return promise;
}
-void V8PromiseCustom::fulfill(v8::Handle<v8::Object> promise, v8::Handle<v8::Value> result, SynchronousMode mode, v8::Isolate* isolate)
-{
- v8::Local<v8::Object> internal = getInternal(promise);
- PromiseState state = getState(internal);
- if (state == Fulfilled || state == Rejected)
- return;
-
- ASSERT(state == Pending || state == Following);
- v8::Local<v8::Array> callbacks = internal->GetInternalField(V8PromiseCustom::InternalFulfillCallbackIndex).As<v8::Array>();
- clearInternal(internal, Fulfilled, result, isolate);
-
- callCallbacks(callbacks, result, mode, isolate);
-}
-
-void V8PromiseCustom::resolve(v8::Handle<v8::Object> promise, v8::Handle<v8::Value> result, SynchronousMode mode, v8::Isolate* isolate)
-{
- ASSERT(!result.IsEmpty());
-
- v8::Local<v8::Value> then;
- if (result->IsObject()) {
- v8::TryCatch trycatch;
- then = result.As<v8::Object>()->Get(v8::String::NewSymbol("then"));
- if (then.IsEmpty()) {
- // If calling the [[Get]] internal method threw an exception, catch it and run reject.
- reject(promise, trycatch.Exception(), mode, isolate);
- return;
- }
- }
-
- if (!then.IsEmpty() && then->IsFunction()) {
- ASSERT(result->IsObject());
- v8::TryCatch trycatch;
- v8::Handle<v8::Value> argv[] = {
- createClosure(promiseResolveCallback, promise, isolate),
- createClosure(promiseRejectCallback, promise, isolate),
- };
- if (V8ScriptRunner::callFunction(then.As<v8::Function>(), getScriptExecutionContext(), result.As<v8::Object>(), WTF_ARRAY_LENGTH(argv), argv, isolate).IsEmpty())
- reject(promise, trycatch.Exception(), mode, isolate);
- return;
- }
-
- fulfill(promise, result, mode, isolate);
-}
-
-void V8PromiseCustom::reject(v8::Handle<v8::Object> promise, v8::Handle<v8::Value> result, SynchronousMode mode, v8::Isolate* isolate)
-{
- v8::Local<v8::Object> internal = getInternal(promise);
- PromiseState state = getState(internal);
- if (state == Fulfilled || state == Rejected)
- return;
-
- ASSERT(state == Pending || state == Following);
- v8::Local<v8::Array> callbacks = internal->GetInternalField(V8PromiseCustom::InternalRejectCallbackIndex).As<v8::Array>();
- clearInternal(internal, Rejected, result, isolate);
-
- callCallbacks(callbacks, result, mode, isolate);
-}
-
-void V8PromiseCustom::append(v8::Handle<v8::Object> promise, v8::Handle<v8::Function> fulfillCallback, v8::Handle<v8::Function> rejectCallback, v8::Isolate* isolate)
-{
- // fulfillCallback and rejectCallback can be empty.
- v8::Local<v8::Object> internal = getInternal(promise);
-
- PromiseState state = getState(internal);
- if (state == Fulfilled) {
- if (!fulfillCallback.IsEmpty()) {
- v8::Local<v8::Value> result = internal->GetInternalField(V8PromiseCustom::InternalResultIndex);
- v8::Local<v8::Object> global = isolate->GetCurrentContext()->Global();
- call(fulfillCallback, global, result, Asynchronous, isolate);
- }
- return;
- }
- if (state == Rejected) {
- if (!rejectCallback.IsEmpty()) {
- v8::Local<v8::Value> result = internal->GetInternalField(V8PromiseCustom::InternalResultIndex);
- v8::Local<v8::Object> global = isolate->GetCurrentContext()->Global();
- call(rejectCallback, global, result, Asynchronous, isolate);
- }
- return;
- }
-
- ASSERT(state == Pending || state == Following);
- if (!fulfillCallback.IsEmpty()) {
- v8::Local<v8::Array> callbacks = internal->GetInternalField(InternalFulfillCallbackIndex).As<v8::Array>();
- callbacks->Set(callbacks->Length(), fulfillCallback);
- }
- if (!rejectCallback.IsEmpty()) {
- v8::Local<v8::Array> callbacks = internal->GetInternalField(InternalRejectCallbackIndex).As<v8::Array>();
- callbacks->Set(callbacks->Length(), rejectCallback);
- }
-}
-
v8::Local<v8::Object> V8PromiseCustom::getInternal(v8::Handle<v8::Object> promise)
{
v8::Local<v8::Value> value = promise->GetInternalField(v8DOMWrapperObjectIndex);
return value.As<v8::Object>();
}
-void V8PromiseCustom::clearInternal(v8::Handle<v8::Object> internal, PromiseState state, v8::Handle<v8::Value> value, v8::Isolate* isolate)
-{
- setState(internal, state, isolate);
- internal->SetInternalField(V8PromiseCustom::InternalResultIndex, value);
- internal->SetInternalField(V8PromiseCustom::InternalFulfillCallbackIndex, v8::Array::New());
- internal->SetInternalField(V8PromiseCustom::InternalRejectCallbackIndex, v8::Array::New());
-}
-
V8PromiseCustom::PromiseState V8PromiseCustom::getState(v8::Handle<v8::Object> internal)
{
v8::Handle<v8::Value> value = internal->GetInternalField(V8PromiseCustom::InternalStateIndex);
@@ -566,24 +663,161 @@
return static_cast<PromiseState>(number);
}
-void V8PromiseCustom::setState(v8::Handle<v8::Object> internal, PromiseState state, v8::Isolate* isolate)
+void V8PromiseCustom::setState(v8::Handle<v8::Object> internal, PromiseState state, v8::Handle<v8::Value> value, v8::Isolate* isolate)
{
+ ASSERT(!value.IsEmpty());
ASSERT(state == Pending || state == Fulfilled || state == Rejected || state == Following);
- internal->SetInternalField(V8PromiseCustom::InternalStateIndex, v8::Integer::New(state, isolate));
+ internal->SetInternalField(InternalStateIndex, v8::Integer::New(state, isolate));
+ internal->SetInternalField(InternalResultIndex, value);
}
-void V8PromiseCustom::call(v8::Handle<v8::Function> function, v8::Handle<v8::Object> receiver, v8::Handle<v8::Value> result, SynchronousMode mode, v8::Isolate* isolate)
+bool V8PromiseCustom::isPromise(v8::Handle<v8::Value> maybePromise, v8::Isolate* isolate)
{
- if (mode == Synchronous) {
- v8::Context::Scope scope(isolate->GetCurrentContext());
- // If an exception is thrown, catch it and do nothing.
- v8::TryCatch trycatch;
- v8::Handle<v8::Value> args[] = { result };
- V8ScriptRunner::callFunction(function, getScriptExecutionContext(), receiver, WTF_ARRAY_LENGTH(args), args, isolate);
+ WrapperWorldType currentWorldType = worldType(isolate);
+ return V8Promise::GetTemplate(isolate, currentWorldType)->HasInstance(maybePromise);
+}
+
+v8::Local<v8::Object> V8PromiseCustom::toPromise(v8::Handle<v8::Value> maybePromise, v8::Isolate* isolate)
+{
+ // FIXME: Currently we don't check [[PromiseConstructor]] since we limit
+ // the creation of the promise objects only from the Blink Promise
+ // constructor.
+ if (isPromise(maybePromise, isolate))
+ return maybePromise.As<v8::Object>();
+
+ v8::Local<v8::Object> promise = createPromise(v8::Handle<v8::Object>(), isolate);
+ resolve(promise, maybePromise, isolate);
+ return promise;
+}
+
+void V8PromiseCustom::resolve(v8::Handle<v8::Object> promise, v8::Handle<v8::Value> result, v8::Isolate* isolate)
+{
+ ASSERT(!result.IsEmpty());
+ v8::Local<v8::Object> internal = getInternal(promise);
+ PromiseState state = getState(internal);
+ if (state != Pending)
+ return;
+
+ if (isPromise(result, isolate)) {
+ v8::Local<v8::Object> valuePromise = result.As<v8::Object>();
+ v8::Local<v8::Object> valueInternal = getInternal(valuePromise);
+ PromiseState valueState = getState(valueInternal);
+ if (promise->SameValue(valuePromise)) {
+ v8::Local<v8::Value> reason = V8ThrowException::createTypeError("Resolve a promise with itself", isolate);
+ setReason(promise, reason, isolate);
+ } else if (valueState == Following) {
+ v8::Local<v8::Object> valuePromiseFollowing = valueInternal->GetInternalField(InternalResultIndex).As<v8::Object>();
+ setState(internal, Following, valuePromiseFollowing, isolate);
+ addToDerived(getInternal(valuePromiseFollowing), promise, v8::Handle<v8::Function>(), v8::Handle<v8::Function>(), isolate);
+ } else if (valueState == Fulfilled) {
+ setValue(promise, valueInternal->GetInternalField(InternalResultIndex), isolate);
+ } else if (valueState == Rejected) {
+ setReason(promise, valueInternal->GetInternalField(InternalResultIndex), isolate);
+ } else {
+ ASSERT(valueState == Pending);
+ setState(internal, Following, valuePromise, isolate);
+ addToDerived(valueInternal, promise, v8::Handle<v8::Function>(), v8::Handle<v8::Function>(), isolate);
+ }
} else {
- ASSERT(mode == Asynchronous);
- postTask(function, receiver, result, isolate);
+ setValue(promise, result, isolate);
}
}
+void V8PromiseCustom::reject(v8::Handle<v8::Object> promise, v8::Handle<v8::Value> reason, v8::Isolate* isolate)
+{
+ v8::Local<v8::Object> internal = getInternal(promise);
+ PromiseState state = getState(internal);
+ if (state != Pending)
+ return;
+ setReason(promise, reason, isolate);
+}
+
+v8::Local<v8::Object> V8PromiseCustom::then(v8::Handle<v8::Object> promise, v8::Handle<v8::Function> onFulfilled, v8::Handle<v8::Function> onRejected, v8::Isolate* isolate)
+{
+ v8::Handle<v8::Object> internal = getInternal(promise);
+ while (getState(internal) == Following) {
+ promise = internal->GetInternalField(InternalResultIndex).As<v8::Object>();
+ internal = getInternal(promise);
+ }
+ // FIXME: Currently we don't lookup "constructor" property since we limit
+ // the creation of the promise objects only from the Blink Promise
+ // constructor.
+ v8::Local<v8::Object> derivedPromise = createPromise(v8::Handle<v8::Object>(), isolate);
+ updateDerivedFromPromise(derivedPromise, onFulfilled, onRejected, promise, isolate);
+ return derivedPromise;
+}
+
+void V8PromiseCustom::setValue(v8::Handle<v8::Object> promise, v8::Handle<v8::Value> value, v8::Isolate* isolate)
+{
+ PromisePropagator propagator;
+ propagator.setValue(promise, value, isolate);
+ propagator.performPropagation(isolate);
+}
+
+void V8PromiseCustom::setReason(v8::Handle<v8::Object> promise, v8::Handle<v8::Value> reason, v8::Isolate* isolate)
+{
+ PromisePropagator propagator;
+ propagator.setReason(promise, reason, isolate);
+ propagator.performPropagation(isolate);
+}
+
+void V8PromiseCustom::propagateToDerived(v8::Handle<v8::Object> promise, v8::Isolate* isolate)
+{
+ PromisePropagator propagator;
+ propagator.propagateToDerived(promise, isolate);
+ propagator.performPropagation(isolate);
+}
+
+void V8PromiseCustom::updateDerived(v8::Handle<v8::Object> derivedPromise, v8::Handle<v8::Function> onFulfilled, v8::Handle<v8::Function> onRejected, v8::Handle<v8::Object> originator, v8::Isolate* isolate)
+{
+ PromisePropagator propagator;
+ propagator.updateDerived(derivedPromise, onFulfilled, onRejected, originator, isolate);
+ propagator.performPropagation(isolate);
+}
+
+void V8PromiseCustom::updateDerivedFromValue(v8::Handle<v8::Object> derivedPromise, v8::Handle<v8::Function> onFulfilled, v8::Handle<v8::Value> value, v8::Isolate* isolate)
+{
+ PromisePropagator propagator;
+ propagator.updateDerivedFromValue(derivedPromise, onFulfilled, value, isolate);
+ propagator.performPropagation(isolate);
+}
+
+void V8PromiseCustom::updateDerivedFromReason(v8::Handle<v8::Object> derivedPromise, v8::Handle<v8::Function> onRejected, v8::Handle<v8::Value> reason, v8::Isolate* isolate)
+{
+ PromisePropagator propagator;
+ propagator.updateDerivedFromReason(derivedPromise, onRejected, reason, isolate);
+ propagator.performPropagation(isolate);
+}
+
+void V8PromiseCustom::updateDerivedFromPromise(v8::Handle<v8::Object> derivedPromise, v8::Handle<v8::Function> onFulfilled, v8::Handle<v8::Function> onRejected, v8::Handle<v8::Object> promise, v8::Isolate* isolate)
+{
+ PromisePropagator propagator;
+ propagator.updateDerivedFromPromise(derivedPromise, onFulfilled, onRejected, promise, isolate);
+ propagator.performPropagation(isolate);
+}
+
+v8::Local<v8::Object> V8PromiseCustom::coerceThenable(v8::Handle<v8::Object> thenable, v8::Handle<v8::Function> then, v8::Isolate* isolate)
+{
+ ASSERT(!thenable.IsEmpty());
+ ASSERT(!then.IsEmpty());
+ v8::Local<v8::Object> promise = createPromise(v8::Handle<v8::Object>(), isolate);
+ v8::Handle<v8::Value> argv[] = {
+ createClosure(promiseResolveCallback, promise, isolate),
+ createClosure(promiseRejectCallback, promise, isolate)
+ };
+ v8::TryCatch trycatch;
+ if (V8ScriptRunner::callFunction(then, getExecutionContext(), thenable, WTF_ARRAY_LENGTH(argv), argv, isolate).IsEmpty()) {
+ reject(promise, trycatch.Exception(), isolate);
+ }
+ thenable->SetHiddenValue(V8HiddenPropertyName::thenableHiddenPromise(isolate), promise);
+ return promise;
+}
+
+void V8PromiseCustom::callHandler(v8::Handle<v8::Object> promise, v8::Handle<v8::Function> handler, v8::Handle<v8::Value> argument, v8::Isolate* isolate)
+{
+ ExecutionContext* executionContext = getExecutionContext();
+ ASSERT(executionContext && executionContext->isContextThread());
+ executionContext->postTask(adoptPtr(new CallHandlerTask(promise, handler, argument, isolate)));
+}
+
} // namespace WebCore
diff --git a/Source/bindings/v8/custom/V8PromiseCustom.h b/Source/bindings/v8/custom/V8PromiseCustom.h
index 42e1bd9..1751c1e 100644
--- a/Source/bindings/v8/custom/V8PromiseCustom.h
+++ b/Source/bindings/v8/custom/V8PromiseCustom.h
@@ -38,21 +38,16 @@
InternalResultIndex,
InternalFulfillCallbackIndex,
InternalRejectCallbackIndex,
+ InternalDerivedPromiseIndex,
InternalFieldCount, // This entry must always be at the bottom.
};
- enum WrapperCallbackEnvironmentFieldIndex {
- WrapperCallbackEnvironmentPromiseIndex,
- WrapperCallbackEnvironmentCallbackIndex,
- WrapperCallbackEnvironmentFieldCount, // This entry must always be at the bottom.
- };
-
- enum PromiseEveryEnvironmentFieldIndex {
- PromiseEveryEnvironmentPromiseIndex,
- PromiseEveryEnvironmentCountdownIndex,
- PromiseEveryEnvironmentIndexIndex,
- PromiseEveryEnvironmentResultsIndex,
- PromiseEveryEnvironmentFieldCount, // This entry must always be at the bottom.
+ enum PromiseAllEnvironmentFieldIndex {
+ PromiseAllEnvironmentPromiseIndex,
+ PromiseAllEnvironmentCountdownIndex,
+ PromiseAllEnvironmentIndexIndex,
+ PromiseAllEnvironmentResultsIndex,
+ PromiseAllEnvironmentFieldCount, // This entry must always be at the bottom.
};
enum PrimitiveWrapperFieldIndex {
@@ -67,40 +62,73 @@
Following,
};
- enum SynchronousMode {
- Synchronous,
- Asynchronous,
- };
-
static v8::Local<v8::Object> createPromise(v8::Handle<v8::Object> creationContext, v8::Isolate*);
// |promise| must be a Promise instance.
- static void fulfill(v8::Handle<v8::Object> promise, v8::Handle<v8::Value> result, SynchronousMode, v8::Isolate*);
- // |promise| must be a Promise instance.
- static void resolve(v8::Handle<v8::Object> promise, v8::Handle<v8::Value> result, SynchronousMode, v8::Isolate*);
- // |promise| must be a Promise instance.
- static void reject(v8::Handle<v8::Object> promise, v8::Handle<v8::Value> result, SynchronousMode, v8::Isolate*);
-
- // |promise| must be a Promise instance.
- // |fulfillCallback| and |rejectCallback| can be an empty function respectively.
- static void append(v8::Handle<v8::Object> promise, v8::Handle<v8::Function> fulfillCallback, v8::Handle<v8::Function> rejectCallback, v8::Isolate*);
-
- // |promise| must be a Promise instance.
static v8::Local<v8::Object> getInternal(v8::Handle<v8::Object> promise);
// |internal| must be a Promise internal object.
- // Clear the Promise internal object with the given state and result.
- // This function clears callbacks in the object.
- static void clearInternal(v8::Handle<v8::Object> internal, PromiseState, v8::Handle<v8::Value> result, v8::Isolate*);
-
- // |internal| must be a Promise internal object.
static PromiseState getState(v8::Handle<v8::Object> internal);
- // |internal| must be a Promise internal object.
- static void setState(v8::Handle<v8::Object> internal, PromiseState, v8::Isolate*);
- // Call |function| synchronously or asynchronously, depending on |mode|.
- // If |function| throws an exception, this function catches it and does not rethrow.
- static void call(v8::Handle<v8::Function> /* function */, v8::Handle<v8::Object> receiver, v8::Handle<v8::Value> result, SynchronousMode /* mode */, v8::Isolate*);
+ // |internal| must be a Promise internal object.
+ // Set a |promise|'s state and result that correspond to the state.
+ static void setState(v8::Handle<v8::Object> internal, PromiseState, v8::Handle<v8::Value>, v8::Isolate*);
+
+ // Return true if |maybePromise| is a Promise instance.
+ static bool isPromise(v8::Handle<v8::Value> maybePromise, v8::Isolate*);
+
+ // Coerces |maybePromise| to a Promise instance.
+ static v8::Local<v8::Object> toPromise(v8::Handle<v8::Value> maybePromise, v8::Isolate*);
+
+ // |promise| must be a Promise instance.
+ static void resolve(v8::Handle<v8::Object> promise, v8::Handle<v8::Value> result, v8::Isolate*);
+
+ // |promise| must be a Promise instance.
+ static void reject(v8::Handle<v8::Object> promise, v8::Handle<v8::Value> result, v8::Isolate*);
+
+ // |promise| must be a Promise instance.
+ // |onFulfilled| and |onRejected| can be an empty value respectively.
+ // Appends |onFulfilled| and/or |onRejected| handlers to |promise|.
+ static v8::Local<v8::Object> then(v8::Handle<v8::Object> promise, v8::Handle<v8::Function> onFulfilled, v8::Handle<v8::Function> onRejected, v8::Isolate*);
+
+ // |promise| must be a Promise instance.
+ // Set a |promise|'s value and propagate it to derived promises.
+ static void setValue(v8::Handle<v8::Object> promise, v8::Handle<v8::Value>, v8::Isolate*);
+
+ // |promise| must be a Promise instance.
+ // Set a |promise|'s failure reason and propagate it to derived promises.
+ static void setReason(v8::Handle<v8::Object> promise, v8::Handle<v8::Value>, v8::Isolate*);
+
+ // |promise| must be a Promise instance.
+ // Propagate a |promise|'s value or reason to all of its derived promies.
+ static void propagateToDerived(v8::Handle<v8::Object> promise, v8::Isolate*);
+
+ // |derivedPromise| and |originator| must be a Promise instance.
+ // |onFulfilled| and |onRejected| can be an empty value respectively.
+ // Propagate |originator|'s state to |derivedPromise|.
+ static void updateDerived(v8::Handle<v8::Object> derivedPromise, v8::Handle<v8::Function> onFulfilled, v8::Handle<v8::Function> onRejected, v8::Handle<v8::Object> originator, v8::Isolate*);
+
+ // |derivedPromise| must be a Promise instance.
+ // Propagate a value to |derivedPromise|.
+ static void updateDerivedFromValue(v8::Handle<v8::Object> derivedPromise, v8::Handle<v8::Function> onFulfilled, v8::Handle<v8::Value>, v8::Isolate*);
+
+ // |derivedPromise| must be a Promise instance.
+ // Propagate a failure reason to |derivedPromise|.
+ static void updateDerivedFromReason(v8::Handle<v8::Object> derivedPromise, v8::Handle<v8::Function> onRejected, v8::Handle<v8::Value>, v8::Isolate*);
+
+ // |derivedPromise| and |promise| must be a Promise instance.
+ // |onFulfilled| and |onRejected| can be an empty value respectively.
+ // Propagate |promise|'s state to |derivedPromise|.
+ static void updateDerivedFromPromise(v8::Handle<v8::Object> derivedPromise, v8::Handle<v8::Function> onFulfilled, v8::Handle<v8::Function> onRejected, v8::Handle<v8::Object> promise, v8::Isolate*);
+
+ // Returns a Promise instance that will be fulfilled or rejected by
+ // |thenable|'s result.
+ static v8::Local<v8::Object> coerceThenable(v8::Handle<v8::Object> thenable, v8::Handle<v8::Function> then, v8::Isolate*);
+
+ // |promise| must be a Promise instance.
+ // Applies a transformation to an argument and use it to update derived
+ // promies.
+ static void callHandler(v8::Handle<v8::Object> promise, v8::Handle<v8::Function> handler, v8::Handle<v8::Value> argument, v8::Isolate*);
};
} // namespace WebCore
diff --git a/Source/bindings/v8/custom/V8SQLTransactionCustom.cpp b/Source/bindings/v8/custom/V8SQLTransactionCustom.cpp
index a12c38d..9dd4a9d 100644
--- a/Source/bindings/v8/custom/V8SQLTransactionCustom.cpp
+++ b/Source/bindings/v8/custom/V8SQLTransactionCustom.cpp
@@ -36,7 +36,7 @@
#include "bindings/v8/ExceptionState.h"
#include "bindings/v8/V8Binding.h"
#include "core/dom/ExceptionCode.h"
-#include "core/platform/sql/SQLValue.h"
+#include "modules/webdatabase/sqlite/SQLValue.h"
#include "modules/webdatabase/Database.h"
#include "wtf/Vector.h"
@@ -88,7 +88,7 @@
SQLTransaction* transaction = V8SQLTransaction::toNative(args.Holder());
- ScriptExecutionContext* scriptExecutionContext = getScriptExecutionContext();
+ ExecutionContext* executionContext = getExecutionContext();
RefPtr<SQLStatementCallback> callback;
if (args.Length() > 2 && !isUndefinedOrNull(args[2])) {
@@ -96,7 +96,7 @@
setDOMException(TypeMismatchError, args.GetIsolate());
return;
}
- callback = V8SQLStatementCallback::create(args[2], scriptExecutionContext);
+ callback = V8SQLStatementCallback::create(args[2], executionContext);
}
RefPtr<SQLStatementErrorCallback> errorCallback;
@@ -105,7 +105,7 @@
setDOMException(TypeMismatchError, args.GetIsolate());
return;
}
- errorCallback = V8SQLStatementErrorCallback::create(args[3], scriptExecutionContext);
+ errorCallback = V8SQLStatementErrorCallback::create(args[3], executionContext);
}
ExceptionState es(args.GetIsolate());
diff --git a/Source/bindings/v8/custom/V8SQLTransactionSyncCustom.cpp b/Source/bindings/v8/custom/V8SQLTransactionSyncCustom.cpp
index 11c232d..8dea405 100644
--- a/Source/bindings/v8/custom/V8SQLTransactionSyncCustom.cpp
+++ b/Source/bindings/v8/custom/V8SQLTransactionSyncCustom.cpp
@@ -35,7 +35,7 @@
#include "bindings/v8/ExceptionState.h"
#include "bindings/v8/V8Binding.h"
#include "core/dom/ExceptionCode.h"
-#include "core/platform/sql/SQLValue.h"
+#include "modules/webdatabase/sqlite/SQLValue.h"
#include "modules/webdatabase/DatabaseSync.h"
#include "modules/webdatabase/SQLResultSet.h"
#include "wtf/Vector.h"
diff --git a/Source/bindings/v8/custom/V8SVGDocumentCustom.cpp b/Source/bindings/v8/custom/V8SVGDocumentCustom.cpp
deleted file mode 100644
index 668d37b..0000000
--- a/Source/bindings/v8/custom/V8SVGDocumentCustom.cpp
+++ /dev/null
@@ -1,53 +0,0 @@
-/*
- * Copyright (C) 2010 Google Inc. All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions are
- * met:
- *
- * * Redistributions of source code must retain the above copyright
- * notice, this list of conditions and the following disclaimer.
- * * Redistributions in binary form must reproduce the above
- * copyright notice, this list of conditions and the following disclaimer
- * in the documentation and/or other materials provided with the
- * distribution.
- * * Neither the name of Google Inc. nor the names of its
- * contributors may be used to endorse or promote products derived from
- * this software without specific prior written permission.
- *
- * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
- * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
- * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
- * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
- * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
- * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
- * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
- * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
- * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
- * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
- * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
- */
-
-#include "config.h"
-#include "V8SVGDocument.h"
-
-#include "bindings/v8/ScriptController.h"
-#include "bindings/v8/V8WindowShell.h"
-#include "core/page/Frame.h"
-
-namespace WebCore {
-
-v8::Handle<v8::Object> wrap(SVGDocument* impl, v8::Handle<v8::Object> creationContext, v8::Isolate* isolate)
-{
- ASSERT(impl);
- v8::Handle<v8::Object> wrapper = V8SVGDocument::createWrapper(impl, creationContext, isolate);
- if (wrapper.IsEmpty())
- return wrapper;
- if (!isolatedWorldForEnteredContext()) {
- if (Frame* frame = impl->frame())
- frame->script()->windowShell(mainThreadNormalWorld())->updateDocumentWrapper(wrapper);
- }
- return wrapper;
-}
-
-} // namespace WebCore
diff --git a/Source/bindings/v8/custom/V8TypedArrayCustom.h b/Source/bindings/v8/custom/V8TypedArrayCustom.h
index 1c92af4..e4b4bd7 100644
--- a/Source/bindings/v8/custom/V8TypedArrayCustom.h
+++ b/Source/bindings/v8/custom/V8TypedArrayCustom.h
@@ -145,7 +145,7 @@
ASSERT(!DOMDataStore::containsWrapper<Binding>(impl.get(), isolate));
RefPtr<ArrayBuffer> buffer = impl->buffer();
- v8::Local<v8::Value> v8Buffer = v8::Local<v8::Value>::New(WebCore::toV8(buffer.get(), creationContext, isolate));
+ v8::Local<v8::Value> v8Buffer = WebCore::toV8(buffer.get(), creationContext, isolate);
ASSERT(v8Buffer->IsArrayBuffer());
diff --git a/Source/bindings/v8/custom/V8WebGLRenderingContextCustom.cpp b/Source/bindings/v8/custom/V8WebGLRenderingContextCustom.cpp
index ed4b39e..088d53f 100644
--- a/Source/bindings/v8/custom/V8WebGLRenderingContextCustom.cpp
+++ b/Source/bindings/v8/custom/V8WebGLRenderingContextCustom.cpp
@@ -73,7 +73,7 @@
#include "bindings/v8/custom/V8Uint8ArrayCustom.h"
#include "core/dom/ExceptionCode.h"
#include "core/html/canvas/WebGLRenderingContext.h"
-#include "core/platform/NotImplemented.h"
+#include "platform/NotImplemented.h"
#include "wtf/FastMalloc.h"
#include <limits>
diff --git a/Source/bindings/v8/custom/V8WindowCustom.cpp b/Source/bindings/v8/custom/V8WindowCustom.cpp
index e0cdbc3..6fd8a32 100644
--- a/Source/bindings/v8/custom/V8WindowCustom.cpp
+++ b/Source/bindings/v8/custom/V8WindowCustom.cpp
@@ -53,13 +53,13 @@
#include "core/loader/FrameLoadRequest.h"
#include "core/loader/FrameLoader.h"
#include "core/page/Chrome.h"
-#include "core/page/ContentSecurityPolicy.h"
-#include "core/page/DOMTimer.h"
-#include "core/page/DOMWindow.h"
-#include "core/page/DOMWindowTimers.h"
-#include "core/page/Frame.h"
-#include "core/page/FrameView.h"
-#include "core/page/Location.h"
+#include "core/frame/ContentSecurityPolicy.h"
+#include "core/frame/DOMTimer.h"
+#include "core/frame/DOMWindow.h"
+#include "core/frame/DOMWindowTimers.h"
+#include "core/frame/Frame.h"
+#include "core/frame/FrameView.h"
+#include "core/frame/Location.h"
#include "core/page/Page.h"
#include "core/page/Settings.h"
#include "core/page/WindowFeatures.h"
@@ -68,7 +68,7 @@
#include "core/storage/Storage.h"
#include "core/workers/SharedWorkerRepository.h"
#include "wtf/ArrayBuffer.h"
-#include "wtf/OwnArrayPtr.h"
+#include "wtf/OwnPtr.h"
namespace WebCore {
@@ -82,7 +82,7 @@
return;
DOMWindow* imp = V8Window::toNative(args.Holder());
- ScriptExecutionContext* scriptContext = static_cast<ScriptExecutionContext*>(imp->document());
+ ExecutionContext* scriptContext = static_cast<ExecutionContext*>(imp->document());
if (!scriptContext) {
es.throwUninformativeAndGenericDOMException(InvalidAccessError);
@@ -116,7 +116,7 @@
OwnPtr<ScheduledAction> action;
if (function->IsFunction()) {
int paramCount = argumentCount >= 2 ? argumentCount - 2 : 0;
- OwnArrayPtr<v8::Local<v8::Value> > params;
+ OwnPtr<v8::Local<v8::Value>[]> params;
if (paramCount > 0) {
params = adoptArrayPtr(new v8::Local<v8::Value>[paramCount]);
for (int i = 0; i < paramCount; i++) {
@@ -205,17 +205,9 @@
{
DOMWindow* imp = V8Window::toNative(info.Holder());
- DOMWindow* active = activeDOMWindow();
- if (!active)
- return;
-
- DOMWindow* first = firstDOMWindow();
- if (!first)
- return;
-
if (Location* location = imp->location()) {
V8TRYCATCH_FOR_V8STRINGRESOURCE_VOID(V8StringResource<>, href, value);
- location->setHref(active, first, href);
+ location->setHref(activeDOMWindow(), firstDOMWindow(), href);
}
}
diff --git a/Source/bindings/v8/custom/V8WorkerGlobalScopeCustom.cpp b/Source/bindings/v8/custom/V8WorkerGlobalScopeCustom.cpp
index 2c3dc2f..395a95c 100644
--- a/Source/bindings/v8/custom/V8WorkerGlobalScopeCustom.cpp
+++ b/Source/bindings/v8/custom/V8WorkerGlobalScopeCustom.cpp
@@ -38,12 +38,12 @@
#include "bindings/v8/V8WorkerGlobalScopeEventListener.h"
#include "bindings/v8/WorkerScriptController.h"
#include "core/inspector/ScriptCallStack.h"
-#include "core/page/ContentSecurityPolicy.h"
-#include "core/page/DOMTimer.h"
-#include "core/page/DOMWindowTimers.h"
+#include "core/frame/ContentSecurityPolicy.h"
+#include "core/frame/DOMTimer.h"
+#include "core/frame/DOMWindowTimers.h"
#include "core/workers/WorkerGlobalScope.h"
#include "modules/websockets/WebSocket.h"
-#include "wtf/OwnArrayPtr.h"
+#include "wtf/OwnPtr.h"
namespace WebCore {
@@ -73,7 +73,7 @@
action = adoptPtr(new ScheduledAction(v8Context, toWebCoreString(function.As<v8::String>()), workerGlobalScope->url(), args.GetIsolate()));
} else if (function->IsFunction()) {
size_t paramCount = argumentCount >= 2 ? argumentCount - 2 : 0;
- OwnArrayPtr<v8::Local<v8::Value> > params;
+ OwnPtr<v8::Local<v8::Value>[]> params;
if (paramCount > 0) {
params = adoptArrayPtr(new v8::Local<v8::Value>[paramCount]);
for (size_t i = 0; i < paramCount; ++i)
diff --git a/Source/bindings/v8/custom/V8XMLHttpRequestCustom.cpp b/Source/bindings/v8/custom/V8XMLHttpRequestCustom.cpp
index aac8a68..3237130 100644
--- a/Source/bindings/v8/custom/V8XMLHttpRequestCustom.cpp
+++ b/Source/bindings/v8/custom/V8XMLHttpRequestCustom.cpp
@@ -53,7 +53,7 @@
void V8XMLHttpRequest::constructorCustom(const v8::FunctionCallbackInfo<v8::Value>& args)
{
- ScriptExecutionContext* context = getScriptExecutionContext();
+ ExecutionContext* context = getExecutionContext();
RefPtr<SecurityOrigin> securityOrigin;
if (context->isDocument()) {
@@ -173,7 +173,7 @@
V8TRYCATCH_FOR_V8STRINGRESOURCE_VOID(V8StringResource<>, method, args[0]);
V8TRYCATCH_FOR_V8STRINGRESOURCE_VOID(V8StringResource<>, urlstring, args[1]);
- ScriptExecutionContext* context = getScriptExecutionContext();
+ ExecutionContext* context = getExecutionContext();
KURL url = context->completeURL(urlstring);
ExceptionState es(args.GetIsolate());
@@ -210,7 +210,7 @@
{
XMLHttpRequest* xmlHttpRequest = V8XMLHttpRequest::toNative(args.Holder());
- InspectorInstrumentation::willSendXMLHttpRequest(xmlHttpRequest->scriptExecutionContext(), xmlHttpRequest->url());
+ InspectorInstrumentation::willSendXMLHttpRequest(xmlHttpRequest->executionContext(), xmlHttpRequest->url());
ExceptionState es(args.GetIsolate());
if (args.Length() < 1)