Merge from Chromium at DEPS revision 257591
This commit was generated by merge_to_master.py.
Change-Id: I834f3ca85c1ef7ec2c1061847a3d92aa461da043
diff --git a/Source/bindings/v8/BindingSecurity.cpp b/Source/bindings/v8/BindingSecurity.cpp
index 6663ec8..59cc6b1 100644
--- a/Source/bindings/v8/BindingSecurity.cpp
+++ b/Source/bindings/v8/BindingSecurity.cpp
@@ -35,21 +35,21 @@
#include "core/dom/Document.h"
#include "core/html/HTMLFrameElementBase.h"
#include "core/frame/DOMWindow.h"
-#include "core/frame/Frame.h"
+#include "core/frame/LocalFrame.h"
#include "core/frame/Settings.h"
#include "platform/weborigin/SecurityOrigin.h"
namespace WebCore {
-static bool isDocumentAccessibleFromDOMWindow(Document* targetDocument, DOMWindow* activeWindow)
+static bool isDocumentAccessibleFromDOMWindow(Document* targetDocument, DOMWindow* callingWindow)
{
if (!targetDocument)
return false;
- if (!activeWindow)
+ if (!callingWindow)
return false;
- if (activeWindow->document()->securityOrigin()->canAccess(targetDocument->securityOrigin()))
+ if (callingWindow->document()->securityOrigin()->canAccess(targetDocument->securityOrigin()))
return true;
return false;
@@ -57,35 +57,35 @@
static bool canAccessDocument(v8::Isolate* isolate, Document* targetDocument, ExceptionState& exceptionState)
{
- DOMWindow* activeWindow = activeDOMWindow(isolate);
- if (isDocumentAccessibleFromDOMWindow(targetDocument, activeWindow))
+ DOMWindow* callingWindow = callingDOMWindow(isolate);
+ if (isDocumentAccessibleFromDOMWindow(targetDocument, callingWindow))
return true;
if (targetDocument->domWindow())
- exceptionState.throwSecurityError(targetDocument->domWindow()->sanitizedCrossDomainAccessErrorMessage(activeWindow), targetDocument->domWindow()->crossDomainAccessErrorMessage(activeWindow));
+ exceptionState.throwSecurityError(targetDocument->domWindow()->sanitizedCrossDomainAccessErrorMessage(callingWindow), targetDocument->domWindow()->crossDomainAccessErrorMessage(callingWindow));
return false;
}
static bool canAccessDocument(v8::Isolate* isolate, Document* targetDocument, SecurityReportingOption reportingOption = ReportSecurityError)
{
- DOMWindow* activeWindow = activeDOMWindow(isolate);
- if (isDocumentAccessibleFromDOMWindow(targetDocument, activeWindow))
+ DOMWindow* callingWindow = callingDOMWindow(isolate);
+ if (isDocumentAccessibleFromDOMWindow(targetDocument, callingWindow))
return true;
if (reportingOption == ReportSecurityError && targetDocument->domWindow()) {
- if (Frame* frame = targetDocument->frame())
- frame->domWindow()->printErrorMessage(targetDocument->domWindow()->crossDomainAccessErrorMessage(activeWindow));
+ if (LocalFrame* frame = targetDocument->frame())
+ frame->domWindow()->printErrorMessage(targetDocument->domWindow()->crossDomainAccessErrorMessage(callingWindow));
}
return false;
}
-bool BindingSecurity::shouldAllowAccessToFrame(v8::Isolate* isolate, Frame* target, SecurityReportingOption reportingOption)
+bool BindingSecurity::shouldAllowAccessToFrame(v8::Isolate* isolate, LocalFrame* target, SecurityReportingOption reportingOption)
{
return target && canAccessDocument(isolate, target->document(), reportingOption);
}
-bool BindingSecurity::shouldAllowAccessToFrame(v8::Isolate* isolate, Frame* target, ExceptionState& exceptionState)
+bool BindingSecurity::shouldAllowAccessToFrame(v8::Isolate* isolate, LocalFrame* target, ExceptionState& exceptionState)
{
return target && canAccessDocument(isolate, target->document(), exceptionState);
}
diff --git a/Source/bindings/v8/BindingSecurity.h b/Source/bindings/v8/BindingSecurity.h
index 04560a8..66db992 100644
--- a/Source/bindings/v8/BindingSecurity.h
+++ b/Source/bindings/v8/BindingSecurity.h
@@ -38,7 +38,7 @@
class DOMWindow;
class ExceptionState;
-class Frame;
+class LocalFrame;
class Node;
enum SecurityReportingOption {
@@ -49,8 +49,8 @@
class BindingSecurity {
public:
static bool shouldAllowAccessToNode(v8::Isolate*, Node*, ExceptionState&);
- static bool shouldAllowAccessToFrame(v8::Isolate*, Frame*, SecurityReportingOption = ReportSecurityError);
- static bool shouldAllowAccessToFrame(v8::Isolate*, Frame*, ExceptionState&);
+ static bool shouldAllowAccessToFrame(v8::Isolate*, LocalFrame*, SecurityReportingOption = ReportSecurityError);
+ static bool shouldAllowAccessToFrame(v8::Isolate*, LocalFrame*, ExceptionState&);
};
}
diff --git a/Source/bindings/v8/CustomElementConstructorBuilder.cpp b/Source/bindings/v8/CustomElementConstructorBuilder.cpp
index 36b998a..fd0f161 100644
--- a/Source/bindings/v8/CustomElementConstructorBuilder.cpp
+++ b/Source/bindings/v8/CustomElementConstructorBuilder.cpp
@@ -43,6 +43,7 @@
#include "bindings/v8/ScriptState.h"
#include "bindings/v8/UnsafePersistent.h"
#include "bindings/v8/V8Binding.h"
+#include "bindings/v8/V8HiddenValue.h"
#include "bindings/v8/V8PerContextData.h"
#include "core/dom/Document.h"
#include "core/dom/custom/CustomElementCallbackDispatcher.h"
@@ -189,10 +190,10 @@
m_constructor->SetName(v8Type->IsNull() ? v8TagName : v8Type.As<v8::String>());
- setHiddenValue(isolate, m_constructor, "customElementDocument", toV8(document, m_context->Global(), isolate));
- setHiddenValue(isolate, m_constructor, "customElementNamespaceURI", v8String(isolate, descriptor.namespaceURI()));
- setHiddenValue(isolate, m_constructor, "customElementTagName", v8TagName);
- setHiddenValue(isolate, m_constructor, "customElementType", v8Type);
+ V8HiddenValue::setHiddenValue(isolate, m_constructor, V8HiddenValue::customElementDocument(isolate), toV8(document, m_context->Global(), isolate));
+ V8HiddenValue::setHiddenValue(isolate, m_constructor, V8HiddenValue::customElementNamespaceURI(isolate), v8String(isolate, descriptor.namespaceURI()));
+ V8HiddenValue::setHiddenValue(isolate, m_constructor, V8HiddenValue::customElementTagName(isolate), v8TagName);
+ V8HiddenValue::setHiddenValue(isolate, m_constructor, V8HiddenValue::customElementType(isolate), v8Type);
v8::Handle<v8::String> prototypeKey = v8String(isolate, "prototype");
ASSERT(m_constructor->HasOwnProperty(prototypeKey));
@@ -205,7 +206,7 @@
// property.
m_constructor->ForceSet(prototypeKey, m_prototype, v8::PropertyAttribute(v8::ReadOnly | v8::DontEnum | v8::DontDelete));
- setHiddenValue(isolate, m_prototype, "customElementIsInterfacePrototypeObject", v8::True(isolate));
+ V8HiddenValue::setHiddenValue(isolate, m_prototype, V8HiddenValue::customElementIsInterfacePrototypeObject(isolate), v8::True(isolate));
m_prototype->ForceSet(v8String(isolate, "constructor"), m_constructor, v8::DontEnum);
return true;
@@ -213,7 +214,7 @@
bool CustomElementConstructorBuilder::prototypeIsValid(const AtomicString& type, ExceptionState& exceptionState) const
{
- if (m_prototype->InternalFieldCount() || !getHiddenValue(m_context->GetIsolate(), m_prototype, "customElementIsInterfacePrototypeObject").IsEmpty()) {
+ if (m_prototype->InternalFieldCount() || !V8HiddenValue::getHiddenValue(m_context->GetIsolate(), m_prototype, V8HiddenValue::customElementIsInterfacePrototypeObject(m_context->GetIsolate())).IsEmpty()) {
CustomElementException::throwException(CustomElementException::PrototypeInUse, type, exceptionState);
return false;
}
@@ -268,10 +269,10 @@
return;
}
- Document* document = V8Document::toNative(getHiddenValue(isolate, info.Callee(), "customElementDocument").As<v8::Object>());
- V8TRYCATCH_FOR_V8STRINGRESOURCE_VOID(V8StringResource<>, namespaceURI, getHiddenValue(isolate, info.Callee(), "customElementNamespaceURI"));
- V8TRYCATCH_FOR_V8STRINGRESOURCE_VOID(V8StringResource<>, tagName, getHiddenValue(isolate, info.Callee(), "customElementTagName"));
- v8::Handle<v8::Value> maybeType = getHiddenValue(isolate, info.Callee(), "customElementType");
+ Document* document = V8Document::toNative(V8HiddenValue::getHiddenValue(info.GetIsolate(), info.Callee(), V8HiddenValue::customElementDocument(isolate)).As<v8::Object>());
+ V8TRYCATCH_FOR_V8STRINGRESOURCE_VOID(V8StringResource<>, namespaceURI, V8HiddenValue::getHiddenValue(isolate, info.Callee(), V8HiddenValue::customElementNamespaceURI(isolate)));
+ V8TRYCATCH_FOR_V8STRINGRESOURCE_VOID(V8StringResource<>, tagName, V8HiddenValue::getHiddenValue(isolate, info.Callee(), V8HiddenValue::customElementTagName(isolate)));
+ v8::Handle<v8::Value> maybeType = V8HiddenValue::getHiddenValue(info.GetIsolate(), info.Callee(), V8HiddenValue::customElementType(isolate));
V8TRYCATCH_FOR_V8STRINGRESOURCE_VOID(V8StringResource<>, type, maybeType);
ExceptionState exceptionState(ExceptionState::ConstructionContext, "CustomElement", info.Holder(), info.GetIsolate());
diff --git a/Source/bindings/v8/DOMDataStore.cpp b/Source/bindings/v8/DOMDataStore.cpp
index aa739a6..e4ec115 100644
--- a/Source/bindings/v8/DOMDataStore.cpp
+++ b/Source/bindings/v8/DOMDataStore.cpp
@@ -37,17 +37,15 @@
namespace WebCore {
-DOMDataStore::DOMDataStore(WrapperWorldType type)
- : m_type(type)
+DOMDataStore::DOMDataStore(bool isMainWorld)
+ : m_isMainWorld(isMainWorld)
, m_wrapperMap(v8::Isolate::GetCurrent()) // FIXME Don't call GetCurrent twice.
{
- V8PerIsolateData::current()->registerDOMDataStore(this);
}
DOMDataStore::~DOMDataStore()
{
- ASSERT(m_type != MainWorld); // We never actually destruct the main world's DOMDataStore.
- V8PerIsolateData::current()->unregisterDOMDataStore(this);
+ ASSERT(!m_isMainWorld); // We never actually destruct the main world's DOMDataStore.
m_wrapperMap.clear();
}
diff --git a/Source/bindings/v8/DOMDataStore.h b/Source/bindings/v8/DOMDataStore.h
index 8e2f60b..c45034c 100644
--- a/Source/bindings/v8/DOMDataStore.h
+++ b/Source/bindings/v8/DOMDataStore.h
@@ -46,7 +46,7 @@
class DOMDataStore {
WTF_MAKE_NONCOPYABLE(DOMDataStore);
public:
- explicit DOMDataStore(WrapperWorldType);
+ explicit DOMDataStore(bool isMainWorld);
~DOMDataStore();
static DOMDataStore& current(v8::Isolate*);
@@ -139,7 +139,7 @@
template<typename V8T, typename T>
inline v8::Handle<v8::Object> get(T* object, v8::Isolate* isolate)
{
- if (ScriptWrappable::wrapperCanBeStoredInObject(object) && m_type == MainWorld)
+ if (ScriptWrappable::wrapperCanBeStoredInObject(object) && m_isMainWorld)
return ScriptWrappable::getUnsafeWrapperFromObject(object).newLocal(isolate);
return m_wrapperMap.newLocal(V8T::toInternalPointer(object), isolate);
}
@@ -147,7 +147,7 @@
template<typename V8T, typename T>
inline void setReference(const v8::Persistent<v8::Object>& parent, T* child, v8::Isolate* isolate)
{
- if (ScriptWrappable::wrapperCanBeStoredInObject(child) && m_type == MainWorld) {
+ if (ScriptWrappable::wrapperCanBeStoredInObject(child) && m_isMainWorld) {
ScriptWrappable::getUnsafeWrapperFromObject(child).setReferenceFrom(parent, isolate);
return;
}
@@ -157,7 +157,7 @@
template<typename V8T, typename T>
inline bool setReturnValueFrom(v8::ReturnValue<v8::Value> returnValue, T* object)
{
- if (ScriptWrappable::wrapperCanBeStoredInObject(object) && m_type == MainWorld)
+ if (ScriptWrappable::wrapperCanBeStoredInObject(object) && m_isMainWorld)
return ScriptWrappable::setReturnValue(returnValue, object);
return m_wrapperMap.setReturnValueFrom(returnValue, V8T::toInternalPointer(object));
}
@@ -165,7 +165,7 @@
template<typename V8T, typename T>
inline bool containsWrapper(T* object)
{
- if (ScriptWrappable::wrapperCanBeStoredInObject(object) && m_type == MainWorld)
+ if (ScriptWrappable::wrapperCanBeStoredInObject(object) && m_isMainWorld)
return !ScriptWrappable::getUnsafeWrapperFromObject(object).isEmpty();
return m_wrapperMap.containsKey(V8T::toInternalPointer(object));
}
@@ -176,7 +176,7 @@
{
ASSERT(!!object);
ASSERT(!wrapper.IsEmpty());
- if (ScriptWrappable::wrapperCanBeStoredInObject(object) && m_type == MainWorld) {
+ if (ScriptWrappable::wrapperCanBeStoredInObject(object) && m_isMainWorld) {
ScriptWrappable::setWrapperInObject(object, wrapper, isolate, configuration);
return;
}
@@ -195,11 +195,11 @@
{
// Verify our assumptions about the main world.
UnsafePersistent<v8::Object> unsafePersistent = wrappable->unsafePersistent();
- ASSERT(unsafePersistent.isEmpty() || !(holder == *unsafePersistent.persistent()) || current(v8::Isolate::GetCurrent()).m_type == MainWorld);
+ ASSERT(unsafePersistent.isEmpty() || !(holder == *unsafePersistent.persistent()) || current(v8::Isolate::GetCurrent()).m_isMainWorld);
return holder == *unsafePersistent.persistent();
}
- WrapperWorldType m_type;
+ bool m_isMainWorld;
DOMWrapperMap<void> m_wrapperMap;
};
diff --git a/Source/bindings/v8/DOMWrapperMap.h b/Source/bindings/v8/DOMWrapperMap.h
index 0b4396f..20fe762 100644
--- a/Source/bindings/v8/DOMWrapperMap.h
+++ b/Source/bindings/v8/DOMWrapperMap.h
@@ -32,7 +32,6 @@
#define DOMWrapperMap_h
#include "bindings/v8/UnsafePersistent.h"
-#include "bindings/v8/V8Utilities.h"
#include "bindings/v8/WrapperTypeInfo.h"
#include <v8.h>
#include "wtf/HashMap.h"
diff --git a/Source/bindings/v8/DOMWrapperWorld.cpp b/Source/bindings/v8/DOMWrapperWorld.cpp
index 7fb57ae..f85f815 100644
--- a/Source/bindings/v8/DOMWrapperWorld.cpp
+++ b/Source/bindings/v8/DOMWrapperWorld.cpp
@@ -41,12 +41,12 @@
#include "bindings/v8/WrapperTypeInfo.h"
#include "core/dom/ExecutionContext.h"
#include "wtf/HashTraits.h"
-#include "wtf/MainThread.h"
#include "wtf/StdLibExtras.h"
namespace WebCore {
unsigned DOMWrapperWorld::isolatedWorldCount = 0;
+DOMWrapperWorld* DOMWrapperWorld::worldOfInitializingWindow = 0;
PassRefPtr<DOMWrapperWorld> DOMWrapperWorld::create(int worldId, int extensionGroup)
{
@@ -56,21 +56,8 @@
DOMWrapperWorld::DOMWrapperWorld(int worldId, int extensionGroup)
: m_worldId(worldId)
, m_extensionGroup(extensionGroup)
+ , m_domDataStore(adoptPtr(new DOMDataStore(isMainWorld())))
{
- if (isMainWorld())
- m_domDataStore = adoptPtr(new DOMDataStore(MainWorld));
- else if (isIsolatedWorld())
- m_domDataStore = adoptPtr(new DOMDataStore(IsolatedWorld));
- else if (isWorkerWorld())
- m_domDataStore = adoptPtr(new DOMDataStore(WorkerWorld));
-}
-
-DOMWrapperWorld* DOMWrapperWorld::current(v8::Isolate* isolate)
-{
- v8::Handle<v8::Context> context = isolate->GetCurrentContext();
- if (context.IsEmpty() || !toDOMWindow(context))
- return 0;
- return world(context);
}
DOMWrapperWorld* DOMWrapperWorld::mainWorld()
@@ -88,7 +75,7 @@
return map;
}
-void DOMWrapperWorld::getAllWorldsInMainThread(Vector<RefPtr<DOMWrapperWorld> >& worlds)
+void DOMWrapperWorld::allWorldsInMainThread(Vector<RefPtr<DOMWrapperWorld> >& worlds)
{
ASSERT(isMainThread());
worlds.append(mainWorld());
@@ -101,6 +88,8 @@
{
ASSERT(!isMainWorld());
+ dispose();
+
if (!isIsolatedWorld())
return;
@@ -117,10 +106,15 @@
ASSERT(map.size() == isolatedWorldCount);
}
+void DOMWrapperWorld::dispose()
+{
+ m_domDataStore.clear();
+}
+
#ifndef NDEBUG
static bool isIsolatedWorldId(int worldId)
{
- return worldId != MainWorldId && worldId != WorkerWorldId;
+ return MainWorldId < worldId && worldId < IsolatedWorldIdLimit;
}
#endif
@@ -207,29 +201,4 @@
isolatedWorldContentSecurityPolicies().remove(worldId);
}
-typedef HashMap<int, OwnPtr<V8DOMActivityLogger>, WTF::IntHash<int>, WTF::UnsignedWithZeroKeyHashTraits<int> > DOMActivityLoggerMap;
-static DOMActivityLoggerMap& domActivityLoggers()
-{
- ASSERT(isMainThread());
- DEFINE_STATIC_LOCAL(DOMActivityLoggerMap, map, ());
- return map;
-}
-
-void DOMWrapperWorld::setActivityLogger(int worldId, PassOwnPtr<V8DOMActivityLogger> logger)
-{
- domActivityLoggers().set(worldId, logger);
-}
-
-V8DOMActivityLogger* DOMWrapperWorld::activityLogger(int worldId)
-{
- DOMActivityLoggerMap& loggers = domActivityLoggers();
- DOMActivityLoggerMap::iterator it = loggers.find(worldId);
- return it == loggers.end() ? 0 : it->value.get();
-}
-
-bool DOMWrapperWorld::contextHasCorrectPrototype(v8::Handle<v8::Context> context)
-{
- return V8WindowShell::contextHasCorrectPrototype(context);
-}
-
} // namespace WebCore
diff --git a/Source/bindings/v8/DOMWrapperWorld.h b/Source/bindings/v8/DOMWrapperWorld.h
index 17f23ff..b9e0533 100644
--- a/Source/bindings/v8/DOMWrapperWorld.h
+++ b/Source/bindings/v8/DOMWrapperWorld.h
@@ -31,14 +31,14 @@
#ifndef DOMWrapperWorld_h
#define DOMWrapperWorld_h
-#include "bindings/v8/V8DOMActivityLogger.h"
#include "bindings/v8/V8PerContextData.h"
#include "platform/weborigin/SecurityOrigin.h"
-#include <v8.h>
+#include "wtf/MainThread.h"
#include "wtf/PassRefPtr.h"
#include "wtf/RefCounted.h"
#include "wtf/RefPtr.h"
#include "wtf/text/WTFString.h"
+#include <v8.h>
namespace WebCore {
@@ -51,29 +51,43 @@
// Embedder isolated worlds can use IDs in [1, 1<<29).
EmbedderWorldIdLimit = (1 << 29),
ScriptPreprocessorIsolatedWorldId,
+ IsolatedWorldIdLimit,
WorkerWorldId,
+ TestingWorldId,
};
// This class represent a collection of DOM wrappers for a specific world.
class DOMWrapperWorld : public RefCounted<DOMWrapperWorld> {
public:
- static PassRefPtr<DOMWrapperWorld> create(int worldId, int extensionGroup);
+ static PassRefPtr<DOMWrapperWorld> create(int worldId = -1, int extensionGroup = -1);
static const int mainWorldExtensionGroup = 0;
static PassRefPtr<DOMWrapperWorld> ensureIsolatedWorld(int worldId, int extensionGroup);
~DOMWrapperWorld();
+ void dispose();
static bool isolatedWorldsExist() { return isolatedWorldCount; }
- static void getAllWorldsInMainThread(Vector<RefPtr<DOMWrapperWorld> >& worlds);
+ static void allWorldsInMainThread(Vector<RefPtr<DOMWrapperWorld> >& worlds);
static DOMWrapperWorld* world(v8::Handle<v8::Context> context)
{
- ASSERT(contextHasCorrectPrototype(context));
- return V8PerContextDataHolder::from(context)->world();
+ ASSERT(!context.IsEmpty());
+ return V8PerContextData::world(context);
}
- // Will return null if there is no DOMWrapperWorld for the current v8::Context
- static DOMWrapperWorld* current(v8::Isolate*);
+ // Will return null if there is no DOMWrapperWorld for the current context.
+ static DOMWrapperWorld* current(v8::Isolate* isolate)
+ {
+ if (isMainThread() && worldOfInitializingWindow) {
+ // It's possible that current() is being called while window is being initialized.
+ // In order to make current() workable during the initialization phase,
+ // we cache the world of the initializing window on worldOfInitializingWindow.
+ // If there is no initiazing window, worldOfInitializingWindow is 0.
+ return worldOfInitializingWindow;
+ }
+ return world(isolate->GetCurrentContext());
+ }
+
static DOMWrapperWorld* mainWorld();
// Associates an isolated world (see above for description) with a security
@@ -95,24 +109,27 @@
static void clearIsolatedWorldContentSecurityPolicy(int worldID);
bool isolatedWorldHasContentSecurityPolicy();
- // Associate a logger with the world identified by worldId (worlId may be 0
- // identifying the main world).
- static void setActivityLogger(int worldId, PassOwnPtr<V8DOMActivityLogger>);
- static V8DOMActivityLogger* activityLogger(int worldId);
-
bool isMainWorld() const { return m_worldId == MainWorldId; }
bool isWorkerWorld() const { return m_worldId == WorkerWorldId; }
- bool isIsolatedWorld() const { return !isMainWorld() && !isWorkerWorld(); }
+ bool isIsolatedWorld() const { return MainWorldId < m_worldId && m_worldId < IsolatedWorldIdLimit; }
int worldId() const { return m_worldId; }
int extensionGroup() const { return m_extensionGroup; }
DOMDataStore& domDataStore() { return *m_domDataStore; }
-private:
- static unsigned isolatedWorldCount;
+ static void setWorldOfInitializingWindow(DOMWrapperWorld* world)
+ {
+ ASSERT(isMainThread());
+ worldOfInitializingWindow = world;
+ }
+ // FIXME: Remove this method once we fix crbug.com/345014.
+ static bool windowIsBeingInitialized() { return !!worldOfInitializingWindow; }
+private:
DOMWrapperWorld(int worldId, int extensionGroup);
- static bool contextHasCorrectPrototype(v8::Handle<v8::Context>);
+
+ static unsigned isolatedWorldCount;
+ static DOMWrapperWorld* worldOfInitializingWindow;
const int m_worldId;
const int m_extensionGroup;
diff --git a/Source/bindings/v8/DebuggerScript.js b/Source/bindings/v8/DebuggerScript.js
index 2f92b48..f8b36a9 100644
--- a/Source/bindings/v8/DebuggerScript.js
+++ b/Source/bindings/v8/DebuggerScript.js
@@ -70,10 +70,10 @@
return null;
var result = [];
for (var i = 0; i < count; i++) {
- var scopeMirror = mirror.scope(i);
+ var scopeDetails = mirror.scope(i).details();
result[i] = {
- type: scopeMirror.scopeType(),
- object: DebuggerScript._buildScopeObject(scopeMirror)
+ type: scopeDetails.type(),
+ object: DebuggerScript._buildScopeObject(scopeDetails.type(), scopeDetails.object())
};
}
return result;
@@ -310,43 +310,95 @@
return (script.compilationType() === Debug.ScriptCompilationType.Eval);
}
+// NOTE: This function is performance critical, as it can be run on every
+// statement that generates an async event (like addEventListener) to support
+// asynchronous call stacks. Thus, when possible, initialize the data lazily.
DebuggerScript._frameMirrorToJSCallFrame = function(frameMirror, callerFrame)
{
- // Get function name and display name.
- var funcMirror;
- var displayName;
- try {
- funcMirror = frameMirror.func();
- if (funcMirror) {
- var valueMirror = funcMirror.property("displayName").value();
- if (valueMirror && valueMirror.isString())
- displayName = valueMirror.value();
- }
- } catch(e) {
+ // Stuff that can not be initialized lazily (i.e. valid while paused with a valid break_id).
+ // The frameMirror and scopeMirror can be accessed only while paused on the debugger.
+ var frameDetails = frameMirror.details();
+
+ var funcObject = frameDetails.func();
+ var sourcePosition = frameDetails.sourcePosition();
+ var thisObject = frameDetails.receiver();
+
+ var isAtReturn = !!frameDetails.isAtReturn();
+ var returnValue = isAtReturn ? frameDetails.returnValue() : undefined;
+
+ var scopeMirrors = frameMirror.allScopes();
+ var scopeTypes = new Array(scopeMirrors.length);
+ var scopeObjects = new Array(scopeMirrors.length);
+ for (var i = 0; i < scopeMirrors.length; ++i) {
+ var scopeDetails = scopeMirrors[i].details();
+ scopeTypes[i] = scopeDetails.type();
+ scopeObjects[i] = scopeDetails.object();
}
- var functionName;
- if (funcMirror)
- functionName = displayName || funcMirror.name() || funcMirror.inferredName();
- // Get script ID.
- var script = funcMirror.script();
- var sourceID = script && script.id();
+ // Calculated lazily.
+ var scopeChain;
+ var funcMirror;
+ var location;
- // Get location.
- var location = frameMirror.sourceLocation();
+ function lazyScopeChain()
+ {
+ if (!scopeChain) {
+ scopeChain = [];
+ for (var i = 0; i < scopeObjects.length; ++i)
+ scopeChain.push(DebuggerScript._buildScopeObject(scopeTypes[i], scopeObjects[i]));
+ scopeObjects = null; // Free for GC.
+ }
+ return scopeChain;
+ }
- // Get this object.
- var thisObject = frameMirror.details_.receiver();
+ function ensureFuncMirror()
+ {
+ if (!funcMirror) {
+ funcMirror = MakeMirror(funcObject);
+ if (!funcMirror.isFunction())
+ funcMirror = new UnresolvedFunctionMirror(funcObject);
+ }
+ return funcMirror;
+ }
- var isAtReturn = !!frameMirror.details_.isAtReturn();
- var returnValue = isAtReturn ? frameMirror.details_.returnValue() : undefined;
+ function ensureLocation()
+ {
+ if (!location) {
+ var script = ensureFuncMirror().script();
+ if (script)
+ location = script.locationFromPosition(sourcePosition, true);
+ if (!location)
+ location = { line: 0, column: 0 };
+ }
+ return location;
+ }
- var scopeChain = [];
- var scopeType = [];
- for (var i = 0; i < frameMirror.scopeCount(); i++) {
- var scopeMirror = frameMirror.scope(i);
- scopeType.push(scopeMirror.scopeType());
- scopeChain.push(DebuggerScript._buildScopeObject(scopeMirror));
+ function line()
+ {
+ return ensureLocation().line;
+ }
+
+ function column()
+ {
+ return ensureLocation().column;
+ }
+
+ function sourceID()
+ {
+ var script = ensureFuncMirror().script();
+ return script && script.id();
+ }
+
+ function functionName()
+ {
+ var func = ensureFuncMirror();
+ if (!func.resolved())
+ return undefined;
+ var displayName;
+ var valueMirror = func.property("displayName").value();
+ if (valueMirror && valueMirror.isString())
+ displayName = valueMirror.value();
+ return displayName || func.name() || func.inferredName();
}
function evaluate(expression)
@@ -370,7 +422,7 @@
var stepInPositionsProtocol;
if (stepInPositionsV8) {
stepInPositionsProtocol = [];
- var script = frameMirror.func().script();
+ var script = ensureFuncMirror().script();
if (script) {
var scriptId = String(script.id());
for (var i = 0; i < stepInPositionsV8.length; i++) {
@@ -388,12 +440,12 @@
return {
"sourceID": sourceID,
- "line": location ? location.line : 0,
- "column": location ? location.column : 0,
+ "line": line,
+ "column": column,
"functionName": functionName,
"thisObject": thisObject,
- "scopeChain": scopeChain,
- "scopeType": scopeType,
+ "scopeChain": lazyScopeChain,
+ "scopeType": scopeTypes,
"evaluate": evaluate,
"caller": callerFrame,
"restart": restart,
@@ -405,36 +457,35 @@
};
}
-DebuggerScript._buildScopeObject = function(scopeMirror) {
- var scopeObject;
- switch (scopeMirror.scopeType()) {
+DebuggerScript._buildScopeObject = function(scopeType, scopeObject)
+{
+ var result;
+ switch (scopeType) {
case ScopeType.Local:
case ScopeType.Closure:
case ScopeType.Catch:
// For transient objects we create a "persistent" copy that contains
// the same properties.
- scopeObject = {};
// Reset scope object prototype to null so that the proto properties
// don't appear in the local scope section.
- scopeObject.__proto__ = null;
- var scopeObjectMirror = scopeMirror.scopeObject();
- var properties = scopeObjectMirror.properties();
+ result = { __proto__: null };
+ var properties = MakeMirror(scopeObject, true /* transient */).properties();
for (var j = 0; j < properties.length; j++) {
var name = properties[j].name();
if (name.charAt(0) === ".")
continue; // Skip internal variables like ".arguments"
- scopeObject[name] = properties[j].value_;
+ result[name] = properties[j].value_;
}
break;
case ScopeType.Global:
case ScopeType.With:
- scopeObject = scopeMirror.details_.object();
+ result = scopeObject;
break;
case ScopeType.Block:
// Unsupported yet. Mustn't be reachable.
break;
}
- return scopeObject;
+ return result;
}
return DebuggerScript;
diff --git a/Source/bindings/v8/Dictionary.cpp b/Source/bindings/v8/Dictionary.cpp
index bd039fd..4d2bb39 100644
--- a/Source/bindings/v8/Dictionary.cpp
+++ b/Source/bindings/v8/Dictionary.cpp
@@ -42,7 +42,6 @@
#include "bindings/v8/ExceptionMessages.h"
#include "bindings/v8/ExceptionState.h"
#include "bindings/v8/V8Binding.h"
-#include "bindings/v8/V8Utilities.h"
#include "bindings/v8/custom/V8ArrayBufferViewCustom.h"
#include "bindings/v8/custom/V8Uint8ArrayCustom.h"
#include "modules/indexeddb/IDBKeyRange.h"
@@ -331,15 +330,13 @@
return true;
}
-bool Dictionary::get(const String& key, RefPtrWillBeRawPtr<Storage>& value) const
+bool Dictionary::get(const String& key, RefPtrWillBeMember<Storage>& value) const
{
v8::Local<v8::Value> v8Value;
if (!getKey(key, v8Value))
return false;
- value = 0;
- if (V8Storage::hasInstance(v8Value, m_isolate))
- value = V8Storage::toNative(v8::Handle<v8::Object>::Cast(v8Value));
+ value = V8Storage::toNativeWithTypeCheck(m_isolate, v8Value);
return true;
}
@@ -427,9 +424,7 @@
if (!getKey(key, v8Value))
return false;
- value = 0;
- if (V8Uint8Array::hasInstance(v8Value, m_isolate))
- value = V8Uint8Array::toNative(v8::Handle<v8::Object>::Cast(v8Value));
+ value = V8Uint8Array::toNativeWithTypeCheck(m_isolate, v8Value);
return true;
}
@@ -439,9 +434,7 @@
if (!getKey(key, v8Value))
return false;
- value = 0;
- if (V8ArrayBufferView::hasInstance(v8Value, m_isolate))
- value = V8ArrayBufferView::toNative(v8::Handle<v8::Object>::Cast(v8Value));
+ value = V8ArrayBufferView::toNativeWithTypeCheck(m_isolate, v8Value);
return true;
}
@@ -451,9 +444,7 @@
if (!getKey(key, v8Value))
return false;
- value = 0;
- if (V8MIDIPort::hasInstance(v8Value, m_isolate))
- value = V8MIDIPort::toNative(v8::Handle<v8::Object>::Cast(v8Value));
+ value = V8MIDIPort::toNativeWithTypeCheck(m_isolate, v8Value);
return true;
}
@@ -463,9 +454,7 @@
if (!getKey(key, v8Value))
return false;
- value = 0;
- if (V8MediaKeyError::hasInstance(v8Value, m_isolate))
- value = V8MediaKeyError::toNative(v8::Handle<v8::Object>::Cast(v8Value));
+ value = V8MediaKeyError::toNativeWithTypeCheck(m_isolate, v8Value);
return true;
}
@@ -481,7 +470,7 @@
// FIXME: this will need to be changed so it can also return an AudioTrack or a VideoTrack once
// we add them.
- v8::Handle<v8::Object> track = wrapper->FindInstanceInPrototypeChain(V8TextTrack::domTemplate(m_isolate, worldType(m_isolate)));
+ v8::Handle<v8::Object> track = V8TextTrack::findInstanceInPrototypeChain(wrapper, m_isolate);
if (!track.IsEmpty())
source = V8TextTrack::toNative(track);
}
@@ -495,9 +484,7 @@
if (!getKey(key, v8Value))
return false;
- value = 0;
- if (V8SpeechRecognitionError::hasInstance(v8Value, m_isolate))
- value = V8SpeechRecognitionError::toNative(v8::Handle<v8::Object>::Cast(v8Value));
+ value = V8SpeechRecognitionError::toNativeWithTypeCheck(m_isolate, v8Value);
return true;
}
@@ -507,9 +494,7 @@
if (!getKey(key, v8Value))
return false;
- value = 0;
- if (V8SpeechRecognitionResult::hasInstance(v8Value, m_isolate))
- value = V8SpeechRecognitionResult::toNative(v8::Handle<v8::Object>::Cast(v8Value));
+ value = V8SpeechRecognitionResult::toNativeWithTypeCheck(m_isolate, v8Value);
return true;
}
@@ -519,9 +504,7 @@
if (!getKey(key, v8Value))
return false;
- value = 0;
- if (V8SpeechRecognitionResultList::hasInstance(v8Value, m_isolate))
- value = V8SpeechRecognitionResultList::toNative(v8::Handle<v8::Object>::Cast(v8Value));
+ value = V8SpeechRecognitionResultList::toNativeWithTypeCheck(m_isolate, v8Value);
return true;
}
@@ -531,9 +514,7 @@
if (!getKey(key, v8Value))
return false;
- value = 0;
- if (V8MediaStream::hasInstance(v8Value, m_isolate))
- value = V8MediaStream::toNative(v8::Handle<v8::Object>::Cast(v8Value));
+ value = V8MediaStream::toNativeWithTypeCheck(m_isolate, v8Value);
return true;
}
@@ -543,12 +524,12 @@
if (!getKey(key, v8Value))
return false;
- value = 0;
+ value = nullptr;
// We need to handle a DOMWindow specially, because a DOMWindow wrapper
// exists on a prototype chain of v8Value.
if (v8Value->IsObject()) {
v8::Handle<v8::Object> wrapper = v8::Handle<v8::Object>::Cast(v8Value);
- v8::Handle<v8::Object> window = wrapper->FindInstanceInPrototypeChain(V8Window::domTemplate(m_isolate, worldTypeInMainThread(m_isolate)));
+ v8::Handle<v8::Object> window = V8Window::findInstanceInPrototypeChain(wrapper, m_isolate);
if (!window.IsEmpty()) {
value = toWrapperTypeInfo(window)->toEventTarget(window);
return true;
@@ -667,20 +648,13 @@
return get(key, value);
}
-bool Dictionary::get(const String& key, RefPtr<DOMError>& value) const
+bool Dictionary::get(const String& key, RefPtrWillBeRawPtr<DOMError>& value) const
{
v8::Local<v8::Value> v8Value;
if (!getKey(key, v8Value))
return false;
- DOMError* error = 0;
- if (v8Value->IsObject()) {
- v8::Handle<v8::Object> wrapper = v8::Handle<v8::Object>::Cast(v8Value);
- v8::Handle<v8::Object> domError = wrapper->FindInstanceInPrototypeChain(V8DOMError::domTemplate(m_isolate, worldType(m_isolate)));
- if (!domError.IsEmpty())
- error = V8DOMError::toNative(domError);
- }
- value = error;
+ value = V8DOMError::toNativeWithTypeCheck(m_isolate, v8Value);
return true;
}
@@ -768,12 +742,7 @@
void Dictionary::ConversionContext::throwTypeError(const String& detail)
{
- if (forConstructor()) {
- exceptionState().throwTypeError(detail);
- } else {
- ASSERT(!methodName().isEmpty());
- exceptionState().throwTypeError(ExceptionMessages::failedToExecute(interfaceName(), methodName(), detail));
- }
+ exceptionState().throwTypeError(detail);
}
} // namespace WebCore
diff --git a/Source/bindings/v8/Dictionary.h b/Source/bindings/v8/Dictionary.h
index 7d19bba..2dce932 100644
--- a/Source/bindings/v8/Dictionary.h
+++ b/Source/bindings/v8/Dictionary.h
@@ -28,6 +28,7 @@
#include "bindings/v8/ExceptionMessages.h"
#include "bindings/v8/ExceptionState.h"
+#include "bindings/v8/Nullable.h"
#include "bindings/v8/ScriptValue.h"
#include "bindings/v8/V8Binding.h"
#include "bindings/v8/V8BindingMacros.h"
@@ -80,7 +81,7 @@
bool get(const String&, unsigned long&) const;
bool get(const String&, unsigned long long&) const;
bool get(const String&, RefPtr<DOMWindow>&) const;
- bool get(const String&, RefPtrWillBeRawPtr<Storage>&) const;
+ bool get(const String&, RefPtrWillBeMember<Storage>&) const;
bool get(const String&, MessagePortArray&) const;
bool get(const String&, RefPtr<Uint8Array>&) const;
bool get(const String&, RefPtr<ArrayBufferView>&) const;
@@ -96,7 +97,7 @@
bool get(const String&, Dictionary&) const;
bool get(const String&, Vector<String>&) const;
bool get(const String&, ArrayValue&) const;
- bool get(const String&, RefPtr<DOMError>&) const;
+ bool get(const String&, RefPtrWillBeRawPtr<DOMError>&) const;
bool get(const String&, OwnPtr<VoidCallback>&) const;
bool get(const String&, v8::Local<v8::Value>&) const;
@@ -154,6 +155,9 @@
template<typename IntegralType>
bool convert(ConversionContext&, const String&, IntegralType&) const;
+ template<typename IntegralType>
+ bool convert(ConversionContext&, const String&, Nullable<IntegralType>&) const;
+
bool convert(ConversionContext&, const String&, MessagePortArray&) const;
bool convert(ConversionContext&, const String&, HashSet<AtomicString>&) const;
bool convert(ConversionContext&, const String&, Dictionary&) const;
@@ -302,6 +306,28 @@
return true;
}
+template<typename T> bool Dictionary::convert(ConversionContext& context, const String& key, Nullable<T>& value) const
+{
+ ConversionContextScope scope(context);
+
+ v8::Local<v8::Value> v8Value;
+ if (!getKey(key, v8Value))
+ return true;
+
+ if (context.isNullable() && WebCore::isUndefinedOrNull(v8Value)) {
+ value = Nullable<T>();
+ return true;
+ }
+
+ T converted = IntegralTypeTraits<T>::toIntegral(v8Value, NormalConversion, context.exceptionState());
+
+ if (context.exceptionState().throwIfNeeded())
+ return false;
+
+ value = Nullable<T>(converted);
+ return true;
+}
+
template<template <typename> class PointerType, typename T> bool Dictionary::convert(ConversionContext& context, const String& key, PointerType<T>& value) const
{
ConversionContextScope scope(context);
diff --git a/Source/bindings/v8/ExceptionMessages.cpp b/Source/bindings/v8/ExceptionMessages.cpp
index 1fbc9da..83e3779 100644
--- a/Source/bindings/v8/ExceptionMessages.cpp
+++ b/Source/bindings/v8/ExceptionMessages.cpp
@@ -41,6 +41,11 @@
return "Failed to construct '" + type + (!detail.isEmpty() ? String("': " + detail) : String("'"));
}
+String ExceptionMessages::failedToEnumerate(const String& type, const String& detail)
+{
+ return "Failed to enumerate the properties of '" + type + (!detail.isEmpty() ? String("': " + detail) : String("'"));
+}
+
String ExceptionMessages::failedToExecute(const String& method, const String& type, const String& detail)
{
return "Failed to execute '" + method + "' on '" + type + (!detail.isEmpty() ? String("': " + detail) : String("'"));
@@ -61,14 +66,29 @@
return "Failed to delete the '" + property + "' property from '" + type + "': " + detail;
}
+String ExceptionMessages::failedToGetIndexed(const String& type, const String& detail)
+{
+ return "Failed to read an indexed property from '" + type + "': " + detail;
+}
+
+String ExceptionMessages::failedToSetIndexed(const String& type, const String& detail)
+{
+ return "Failed to set an indexed property on '" + type + "': " + detail;
+}
+
+String ExceptionMessages::failedToDeleteIndexed(const String& type, const String& detail)
+{
+ return "Failed to delete an indexed property from '" + type + "': " + detail;
+}
+
String ExceptionMessages::incorrectPropertyType(const String& property, const String& detail)
{
return "The '" + property + "' property " + detail;
}
-String ExceptionMessages::incorrectArgumentType(int argumentIndex, const String& detail)
+String ExceptionMessages::argumentNullOrIncorrectType(int argumentIndex, const String& expectedType)
{
- return "The " + ordinalNumber(argumentIndex) + " argument " + detail;
+ return "The " + ordinalNumber(argumentIndex) + " argument provided is either null, or an invalid " + expectedType + " object.";
}
String ExceptionMessages::notAnArrayTypeArgumentOrValue(int argumentIndex)
@@ -129,15 +149,16 @@
return detail ? String::format("This object is read-only, because %s.", detail) : readOnly;
}
-String ExceptionMessages::indexExceedsMaximumBound(const char* name, unsigned given, unsigned bound)
+template <>
+String ExceptionMessages::formatNumber<float>(float number)
{
- bool eq = given == bound;
- return String::format("The %s provided (%u) is greater than %sthe maximum bound (%u).", name, given, eq ? "or equal to " : "", bound);
+ return formatPotentiallyNonFiniteNumber(number);
}
-String ExceptionMessages::indexOutsideRange(const char* name, double given, double lowerBound, BoundType lowerInclusive, double upperBound, BoundType upperInclusive)
+template <>
+String ExceptionMessages::formatNumber<double>(double number)
{
- return String::format("The %s provided (%f) is outside the range %c%f, %f%c.", name, given, lowerBound == ExclusiveBound ? '(' : '[', lowerBound, upperBound, upperBound == ExclusiveBound ? ')' : ']');
+ return formatPotentiallyNonFiniteNumber(number);
}
} // namespace WebCore
diff --git a/Source/bindings/v8/ExceptionMessages.h b/Source/bindings/v8/ExceptionMessages.h
index c7ade8b..8547560 100644
--- a/Source/bindings/v8/ExceptionMessages.h
+++ b/Source/bindings/v8/ExceptionMessages.h
@@ -31,6 +31,8 @@
#ifndef ExceptionMessages_h
#define ExceptionMessages_h
+#include "wtf/MathExtras.h"
+#include "wtf/text/StringBuilder.h"
#include "wtf/text/WTFString.h"
namespace WebCore {
@@ -45,14 +47,19 @@
};
static String failedToConstruct(const String& type, const String& detail = String());
+ static String failedToEnumerate(const String& type, const String& detail = String());
static String failedToExecute(const String& method, const String& type, const String& detail = String());
static String failedToGet(const String& property, const String& type, const String& detail);
static String failedToSet(const String& property, const String& type, const String& detail);
static String failedToDelete(const String& property, const String& type, const String& detail);
+ static String failedToGetIndexed(const String& type, const String& detail);
+ static String failedToSetIndexed(const String& type, const String& detail);
+ static String failedToDeleteIndexed(const String& type, const String& detail);
- static String incorrectArgumentType(int argumentIndex, const String& detail);
static String incorrectPropertyType(const String& property, const String& detail);
+ static String argumentNullOrIncorrectType(int argumentIndex, const String& expectedType);
+
// If > 0, the argument index that failed type check (1-indexed.)
// If == 0, a (non-argument) value (e.g., a setter) failed the same check.
static String notAnArrayTypeArgumentOrValue(int argumentIndex);
@@ -64,13 +71,92 @@
static String readOnly(const char* detail = 0);
- static String indexExceedsMaximumBound(const char* name, unsigned given, unsigned bound);
- static String indexOutsideRange(const char* name, double given, double lowerBound, BoundType lowerType, double upperBound, BoundType upperType);
+ template <typename NumberType>
+ static String indexExceedsMaximumBound(const char* name, NumberType given, NumberType bound)
+ {
+ bool eq = given == bound;
+ StringBuilder result;
+ result.append("The ");
+ result.append(name);
+ result.append(" provided (");
+ result.append(formatNumber(given));
+ result.append(") is greater than ");
+ result.append(eq ? "or equal to " : "");
+ result.append("the maximum bound (");
+ result.append(formatNumber(bound));
+ result.append(").");
+ return result.toString();
+ }
+
+ template <typename NumberType>
+ static String indexExceedsMinimumBound(const char* name, NumberType given, NumberType bound)
+ {
+ bool eq = given == bound;
+ StringBuilder result;
+ result.append("The ");
+ result.append(name);
+ result.append(" provided (");
+ result.append(formatNumber(given));
+ result.append(") is less than ");
+ result.append(eq ? "or equal to " : "");
+ result.append("the minimum bound (");
+ result.append(formatNumber(bound));
+ result.append(").");
+ return result.toString();
+ }
+
+ template <typename NumberType>
+ static String indexOutsideRange(const char* name, NumberType given, NumberType lowerBound, BoundType lowerType, NumberType upperBound, BoundType upperType)
+ {
+ StringBuilder result;
+ result.append("The ");
+ result.append(name);
+ result.append(" provided (");
+ result.append(formatNumber(given));
+ result.append(") is outside the range ");
+ result.append(lowerType == ExclusiveBound ? '(' : '[');
+ result.append(formatNumber(lowerBound));
+ result.append(", ");
+ result.append(formatNumber(upperBound));
+ result.append(upperType == ExclusiveBound ? ')' : ']');
+ result.append('.');
+ return result.toString();
+ }
+
+ template <typename NumType>
+ static String formatNumber(NumType number)
+ {
+ return formatFiniteNumber(number);
+ }
private:
static String ordinalNumber(int number);
+
+
+ template <typename NumType>
+ static String formatFiniteNumber(NumType number)
+ {
+ if (number > 1e20 || number < -1e20)
+ return String::format("%e", 1.0*number);
+ return String::number(number);
+ }
+
+ template <typename NumType>
+ static String formatPotentiallyNonFiniteNumber(NumType number)
+ {
+ if (std::isnan(number))
+ return "NaN";
+ if (std::isinf(number))
+ return number > 0 ? "Infinity" : "-Infinity";
+ if (number > 1e20 || number < -1e20)
+ return String::format("%e", number);
+ return String::number(number);
+ }
};
+template <> String ExceptionMessages::formatNumber<float>(float number);
+template <> String ExceptionMessages::formatNumber<double>(double number);
+
} // namespace WebCore
#endif // ExceptionMessages_h
diff --git a/Source/bindings/v8/ExceptionState.cpp b/Source/bindings/v8/ExceptionState.cpp
index 37deb82..8061edc 100644
--- a/Source/bindings/v8/ExceptionState.cpp
+++ b/Source/bindings/v8/ExceptionState.cpp
@@ -53,6 +53,7 @@
m_code = ec;
String processedMessage = addExceptionContext(message);
+ m_message = processedMessage;
setException(V8ThrowException::createDOMException(ec, processedMessage, m_creationContext, m_isolate));
}
@@ -61,7 +62,9 @@
ASSERT(m_isolate);
m_code = SecurityError;
String finalSanitized = addExceptionContext(sanitizedMessage);
+ m_message = finalSanitized;
String finalUnsanitized = addExceptionContext(unsanitizedMessage);
+
setException(V8ThrowException::createDOMException(SecurityError, finalSanitized, finalUnsanitized, m_creationContext, m_isolate));
}
@@ -80,6 +83,7 @@
{
ASSERT(m_isolate);
m_code = TypeError;
+ m_message = message;
setException(V8ThrowException::createTypeError(addExceptionContext(message), m_isolate));
}
@@ -87,33 +91,39 @@
{
ASSERT_NOT_REACHED();
m_code = ec;
+ m_message = message;
}
-void NonThrowableExceptionState::throwTypeError(const String&)
+void NonThrowableExceptionState::throwTypeError(const String& message)
{
ASSERT_NOT_REACHED();
m_code = TypeError;
+ m_message = message;
}
-void NonThrowableExceptionState::throwSecurityError(const String&, const String&)
+void NonThrowableExceptionState::throwSecurityError(const String& sanitizedMessage, const String&)
{
ASSERT_NOT_REACHED();
m_code = SecurityError;
+ m_message = sanitizedMessage;
}
void TrackExceptionState::throwDOMException(const ExceptionCode& ec, const String& message)
{
m_code = ec;
+ m_message = message;
}
-void TrackExceptionState::throwTypeError(const String&)
+void TrackExceptionState::throwTypeError(const String& message)
{
m_code = TypeError;
+ m_message = message;
}
-void TrackExceptionState::throwSecurityError(const String&, const String&)
+void TrackExceptionState::throwSecurityError(const String& sanitizedMessage, const String&)
{
m_code = SecurityError;
+ m_message = sanitizedMessage;
}
String ExceptionState::addExceptionContext(const String& message) const
@@ -131,8 +141,17 @@
processedMessage = ExceptionMessages::failedToGet(propertyName(), interfaceName(), message);
else if (m_context == SetterContext)
processedMessage = ExceptionMessages::failedToSet(propertyName(), interfaceName(), message);
- } else if (!propertyName() && interfaceName() && m_context == ConstructionContext) {
- processedMessage = ExceptionMessages::failedToConstruct(interfaceName(), message);
+ } else if (!propertyName() && interfaceName()) {
+ if (m_context == ConstructionContext)
+ processedMessage = ExceptionMessages::failedToConstruct(interfaceName(), message);
+ else if (m_context == EnumerationContext)
+ processedMessage = ExceptionMessages::failedToEnumerate(interfaceName(), message);
+ else if (m_context == IndexedDeletionContext)
+ processedMessage = ExceptionMessages::failedToDeleteIndexed(interfaceName(), message);
+ else if (m_context == IndexedGetterContext)
+ processedMessage = ExceptionMessages::failedToGetIndexed(interfaceName(), message);
+ else if (m_context == IndexedSetterContext)
+ processedMessage = ExceptionMessages::failedToSetIndexed(interfaceName(), message);
}
return processedMessage;
}
diff --git a/Source/bindings/v8/ExceptionState.h b/Source/bindings/v8/ExceptionState.h
index 5235318..fbe338f 100644
--- a/Source/bindings/v8/ExceptionState.h
+++ b/Source/bindings/v8/ExceptionState.h
@@ -50,17 +50,14 @@
DeletionContext,
GetterContext,
SetterContext,
+ EnumerationContext,
+ QueryContext,
+ IndexedGetterContext,
+ IndexedSetterContext,
+ IndexedDeletionContext,
UnknownContext, // FIXME: Remove this once we've flipped over to the new API.
};
- explicit ExceptionState(const v8::Handle<v8::Object>& creationContext, v8::Isolate* isolate)
- : m_code(0)
- , m_context(UnknownContext)
- , m_propertyName(0)
- , m_interfaceName(0)
- , m_creationContext(creationContext)
- , m_isolate(isolate) { }
-
ExceptionState(Context context, const char* propertyName, const char* interfaceName, const v8::Handle<v8::Object>& creationContext, v8::Isolate* isolate)
: m_code(0)
, m_context(context)
@@ -75,26 +72,24 @@
, m_propertyName(0)
, m_interfaceName(interfaceName)
, m_creationContext(creationContext)
- , m_isolate(isolate) { ASSERT(m_context == ConstructionContext); }
+ , m_isolate(isolate) { ASSERT(m_context == ConstructionContext || m_context == EnumerationContext || m_context == IndexedSetterContext || m_context == IndexedGetterContext || m_context == IndexedDeletionContext); }
virtual void throwDOMException(const ExceptionCode&, const String& message);
virtual void throwTypeError(const String& message);
virtual void throwSecurityError(const String& sanitizedMessage, const String& unsanitizedMessage = String());
- // Please don't use these methods. Use ::throwDOMException and ::throwTypeError, and pass in a useful exception message.
- virtual void throwUninformativeAndGenericDOMException(const ExceptionCode& ec) { throwDOMException(ec, String()); }
-
bool hadException() const { return !m_exception.isEmpty() || m_code; }
void clearException();
ExceptionCode code() const { return m_code; }
+ const String& message() const { return m_message; }
bool throwIfNeeded()
{
if (m_exception.isEmpty()) {
if (!m_code)
return false;
- throwUninformativeAndGenericDOMException(m_code);
+ throwDOMException(m_code, String()); // FIXME: Do we ever hit this? If so, where and why?
}
V8ThrowException::throwError(m_exception.newLocal(m_isolate), m_isolate);
@@ -113,6 +108,7 @@
protected:
ExceptionCode m_code;
Context m_context;
+ String m_message;
const char* m_propertyName;
const char* m_interfaceName;
@@ -129,7 +125,7 @@
// Used if exceptions can/should not be directly thrown.
class NonThrowableExceptionState FINAL : public ExceptionState {
public:
- NonThrowableExceptionState(): ExceptionState(v8::Handle<v8::Object>(), v8::Isolate::GetCurrent()) { }
+ NonThrowableExceptionState(): ExceptionState(ExceptionState::UnknownContext, 0, 0, v8::Handle<v8::Object>(), v8::Isolate::GetCurrent()) { }
virtual void throwDOMException(const ExceptionCode&, const String& message) OVERRIDE;
virtual void throwTypeError(const String& message = String()) OVERRIDE;
virtual void throwSecurityError(const String& sanitizedMessage, const String& unsanitizedMessage = String()) OVERRIDE;
@@ -138,7 +134,7 @@
// Used if any exceptions thrown are ignorable.
class TrackExceptionState FINAL : public ExceptionState {
public:
- TrackExceptionState(): ExceptionState(v8::Handle<v8::Object>(), v8::Isolate::GetCurrent()) { }
+ TrackExceptionState(): ExceptionState(ExceptionState::UnknownContext, 0, 0, v8::Handle<v8::Object>(), v8::Isolate::GetCurrent()) { }
virtual void throwDOMException(const ExceptionCode&, const String& message) OVERRIDE;
virtual void throwTypeError(const String& message = String()) OVERRIDE;
virtual void throwSecurityError(const String& sanitizedMessage, const String& unsanitizedMessage = String()) OVERRIDE;
diff --git a/Source/bindings/v8/ExceptionStatePlaceholder.cpp b/Source/bindings/v8/ExceptionStatePlaceholder.cpp
index 9d33119..85d3ee0 100644
--- a/Source/bindings/v8/ExceptionStatePlaceholder.cpp
+++ b/Source/bindings/v8/ExceptionStatePlaceholder.cpp
@@ -36,7 +36,7 @@
#if !ASSERT_DISABLED
NoExceptionStateAssertionChecker::NoExceptionStateAssertionChecker(const char* file, int line)
- : ExceptionState(v8::Handle<v8::Object>(), 0)
+ : ExceptionState(ExceptionState::UnknownContext, 0, 0, v8::Handle<v8::Object>(), 0)
, m_file(file)
, m_line(line) { }
diff --git a/Source/bindings/v8/ExceptionStatePlaceholder.h b/Source/bindings/v8/ExceptionStatePlaceholder.h
index f193ba3..6bf6c30 100644
--- a/Source/bindings/v8/ExceptionStatePlaceholder.h
+++ b/Source/bindings/v8/ExceptionStatePlaceholder.h
@@ -43,7 +43,7 @@
class IgnorableExceptionState FINAL : public ExceptionState {
public:
- IgnorableExceptionState(): ExceptionState(v8::Handle<v8::Object>(), 0) { }
+ IgnorableExceptionState(): ExceptionState(ExceptionState::UnknownContext, 0, 0, v8::Handle<v8::Object>(), 0) { }
ExceptionState& returnThis() { return *this; }
virtual void throwDOMException(const ExceptionCode&, const String& message = String()) OVERRIDE { }
virtual void throwTypeError(const String& message = String()) OVERRIDE { }
diff --git a/Source/bindings/v8/IDBBindingUtilities.cpp b/Source/bindings/v8/IDBBindingUtilities.cpp
index d668f84..0e53c67 100644
--- a/Source/bindings/v8/IDBBindingUtilities.cpp
+++ b/Source/bindings/v8/IDBBindingUtilities.cpp
@@ -39,6 +39,7 @@
#include "bindings/v8/DOMRequestState.h"
#include "bindings/v8/SerializedScriptValue.h"
#include "bindings/v8/V8Binding.h"
+#include "bindings/v8/V8HiddenValue.h"
#include "bindings/v8/custom/V8ArrayBufferViewCustom.h"
#include "bindings/v8/custom/V8Uint8ArrayCustom.h"
#include "modules/indexeddb/IDBKey.h"
@@ -123,7 +124,7 @@
// so that event listeners are retained.
v8::Handle<v8::Value> cursor = toV8(impl->idbCursor(), creationContext, isolate);
v8::Handle<v8::Value> request = toV8(impl->idbCursor()->request(), creationContext, isolate);
- setHiddenValue(isolate, cursor->ToObject(), "idbCursorRequest", request);
+ V8HiddenValue::setHiddenValue(isolate, cursor->ToObject(), V8HiddenValue::idbCursorRequest(isolate), request);
return cursor;
}
case IDBAny::IDBCursorWithValueType: {
@@ -131,7 +132,7 @@
// so that event listeners are retained.
v8::Handle<v8::Value> cursor = toV8(impl->idbCursorWithValue(), creationContext, isolate);
v8::Handle<v8::Value> request = toV8(impl->idbCursorWithValue()->request(), creationContext, isolate);
- setHiddenValue(isolate, cursor->ToObject(), "idbCursorRequest", request);
+ V8HiddenValue::setHiddenValue(isolate, cursor->ToObject(), V8HiddenValue::idbCursorRequest(isolate), request);
return cursor;
}
case IDBAny::IDBDatabaseType:
@@ -187,9 +188,9 @@
v8::Handle<v8::Array> array = v8::Handle<v8::Array>::Cast(value);
if (stack.contains(array))
- return 0;
+ return nullptr;
if (stack.size() >= maximumDepth)
- return 0;
+ return nullptr;
stack.append(array);
IDBKey::KeyArray subkeys;
@@ -206,7 +207,7 @@
stack.removeLast();
return IDBKey::createArray(subkeys);
}
- return 0;
+ return nullptr;
}
static PassRefPtr<IDBKey> createIDBKeyFromValue(v8::Handle<v8::Value> value, v8::Isolate* isolate, bool allowExperimentalTypes = false)
@@ -317,7 +318,7 @@
v8::Handle<v8::Value> v8Value(value.v8Value());
v8::Handle<v8::Value> v8Key(getNthValueOnKeyPath(v8Value, keyPathElements, keyPathElements.size(), isolate));
if (v8Key.IsEmpty())
- return 0;
+ return nullptr;
return createIDBKeyFromValue(v8Key, isolate, allowExperimentalTypes);
}
@@ -331,7 +332,7 @@
for (size_t i = 0; i < array.size(); ++i) {
RefPtr<IDBKey> key = createIDBKeyFromScriptValueAndKeyPath(value, array[i], isolate, allowExperimentalTypes);
if (!key)
- return 0;
+ return nullptr;
result.append(key);
}
return IDBKey::createArray(result);
@@ -344,7 +345,7 @@
PassRefPtr<IDBKey> createIDBKeyFromScriptValueAndKeyPath(DOMRequestState* state, const ScriptValue& value, const IDBKeyPath& keyPath)
{
IDB_TRACE("createIDBKeyFromScriptValueAndKeyPath");
- v8::Isolate* isolate = state ? state->context()->GetIsolate() : v8::Isolate::GetCurrent();
+ v8::Isolate* isolate = state ? state->isolate() : v8::Isolate::GetCurrent();
return createIDBKeyFromScriptValueAndKeyPath(value, keyPath, isolate);
}
@@ -404,7 +405,7 @@
ScriptValue idbAnyToScriptValue(DOMRequestState* state, PassRefPtr<IDBAny> any)
{
- v8::Isolate* isolate = state ? state->context()->GetIsolate() : v8::Isolate::GetCurrent();
+ v8::Isolate* isolate = state ? state->isolate() : v8::Isolate::GetCurrent();
ASSERT(isolate->InContext());
v8::Local<v8::Context> context = state ? state->context() : isolate->GetCurrentContext();
v8::HandleScope handleScope(isolate);
@@ -414,7 +415,7 @@
ScriptValue idbKeyToScriptValue(DOMRequestState* state, PassRefPtr<IDBKey> key)
{
- v8::Isolate* isolate = state ? state->context()->GetIsolate() : v8::Isolate::GetCurrent();
+ v8::Isolate* isolate = state ? state->isolate() : v8::Isolate::GetCurrent();
ASSERT(isolate->InContext());
v8::Local<v8::Context> context = state ? state->context() : isolate->GetCurrentContext();
v8::HandleScope handleScope(isolate);
@@ -424,7 +425,7 @@
PassRefPtr<IDBKey> scriptValueToIDBKey(DOMRequestState* state, const ScriptValue& scriptValue)
{
- v8::Isolate* isolate = state ? state->context()->GetIsolate() : v8::Isolate::GetCurrent();
+ v8::Isolate* isolate = state ? state->isolate() : v8::Isolate::GetCurrent();
ASSERT(isolate->InContext());
v8::HandleScope handleScope(isolate);
v8::Handle<v8::Value> v8Value(scriptValue.v8Value());
@@ -433,12 +434,10 @@
PassRefPtr<IDBKeyRange> scriptValueToIDBKeyRange(DOMRequestState* state, const ScriptValue& scriptValue)
{
- v8::Isolate* isolate = state ? state->context()->GetIsolate() : v8::Isolate::GetCurrent();
+ v8::Isolate* isolate = state ? state->isolate() : v8::Isolate::GetCurrent();
v8::HandleScope handleScope(isolate);
v8::Handle<v8::Value> value(scriptValue.v8Value());
- if (V8IDBKeyRange::hasInstance(value, isolate))
- return V8IDBKeyRange::toNative(value.As<v8::Object>());
- return 0;
+ return V8IDBKeyRange::toNativeWithTypeCheck(isolate, value);
}
#ifndef NDEBUG
@@ -447,7 +446,7 @@
RefPtr<IDBKey> key(prpKey);
DOMRequestState::Scope scope(*state);
- v8::Isolate* isolate = state ? state->context()->GetIsolate() : v8::Isolate::GetCurrent();
+ v8::Isolate* isolate = state ? state->isolate() : v8::Isolate::GetCurrent();
ScriptValue keyValue = idbKeyToScriptValue(state, key);
ScriptValue scriptValue(deserializeIDBValueBuffer(buffer.get(), isolate), isolate);
diff --git a/Source/bindings/v8/IDBBindingUtilitiesTest.cpp b/Source/bindings/v8/IDBBindingUtilitiesTest.cpp
index b9a00c2..28c853a 100644
--- a/Source/bindings/v8/IDBBindingUtilitiesTest.cpp
+++ b/Source/bindings/v8/IDBBindingUtilitiesTest.cpp
@@ -28,7 +28,6 @@
#include "bindings/v8/V8Binding.h"
#include "bindings/v8/V8PerIsolateData.h"
-#include "bindings/v8/V8Utilities.h"
#include "modules/indexeddb/IDBKey.h"
#include "modules/indexeddb/IDBKeyPath.h"
@@ -93,14 +92,11 @@
class IDBKeyFromValueAndKeyPathTest : public testing::Test {
public:
IDBKeyFromValueAndKeyPathTest()
- : m_handleScope(v8::Isolate::GetCurrent())
- , m_scope(v8::Context::New(v8::Isolate::GetCurrent()))
+ : m_scope(V8ExecutionScope::create(v8::Isolate::GetCurrent()))
{
}
-
private:
- v8::HandleScope m_handleScope;
- v8::Context::Scope m_scope;
+ OwnPtr<V8ExecutionScope> m_scope;
};
TEST_F(IDBKeyFromValueAndKeyPathTest, TopLevelPropertyStringValue)
diff --git a/Source/bindings/v8/NPV8Object.cpp b/Source/bindings/v8/NPV8Object.cpp
index ecfe93c..080e0d0 100644
--- a/Source/bindings/v8/NPV8Object.cpp
+++ b/Source/bindings/v8/NPV8Object.cpp
@@ -39,7 +39,7 @@
#include "bindings/v8/npruntime_impl.h"
#include "bindings/v8/npruntime_priv.h"
#include "core/frame/DOMWindow.h"
-#include "core/frame/Frame.h"
+#include "core/frame/LocalFrame.h"
#include "platform/UserGestureIndicator.h"
#include "wtf/OwnPtr.h"
@@ -250,7 +250,7 @@
return false;
}
- Frame* frame = v8NpObject->rootObject->frame();
+ LocalFrame* frame = v8NpObject->rootObject->frame();
ASSERT(frame);
// Call the function object.
@@ -302,7 +302,7 @@
v8::Local<v8::Value> resultObject;
v8::Handle<v8::Function> function = v8::Local<v8::Function>::Cast(functionObject);
if (!function->IsNull()) {
- Frame* frame = v8NpObject->rootObject->frame();
+ LocalFrame* frame = v8NpObject->rootObject->frame();
ASSERT(frame);
OwnPtr<v8::Handle<v8::Value>[]> argv = createValueListFromVariantArgs(arguments, argumentCount, npObject, isolate);
@@ -348,7 +348,7 @@
if (!popupsAllowed)
filename = "npscript";
- Frame* frame = v8NpObject->rootObject->frame();
+ LocalFrame* frame = v8NpObject->rootObject->frame();
ASSERT(frame);
String script = String::fromUTF8(npScript->UTF8Characters, npScript->UTF8Length);
@@ -556,7 +556,7 @@
// Convert the results into an array of NPIdentifiers.
v8::Handle<v8::Array> props = v8::Handle<v8::Array>::Cast(propsObj);
*count = props->Length();
- *identifier = static_cast<NPIdentifier*>(malloc(sizeof(NPIdentifier*) * *count));
+ *identifier = static_cast<NPIdentifier*>(calloc(*count, sizeof(NPIdentifier)));
for (uint32_t i = 0; i < *count; ++i) {
v8::Local<v8::Value> name = props->Get(v8::Integer::New(context->GetIsolate(), i));
(*identifier)[i] = getStringIdentifier(v8::Local<v8::String>::Cast(name));
@@ -594,7 +594,7 @@
v8::Local<v8::Value> resultObject;
v8::Handle<v8::Function> ctor = v8::Handle<v8::Function>::Cast(ctorObj);
if (!ctor->IsNull()) {
- Frame* frame = object->rootObject->frame();
+ LocalFrame* frame = object->rootObject->frame();
ASSERT(frame);
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/Nullable.h b/Source/bindings/v8/Nullable.h
new file mode 100644
index 0000000..0f8356c
--- /dev/null
+++ b/Source/bindings/v8/Nullable.h
@@ -0,0 +1,51 @@
+// Copyright 2014 The Chromium Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+#ifndef Nullable_h
+#define Nullable_h
+
+#include "wtf/Assertions.h"
+
+namespace WebCore {
+
+template <typename T>
+class Nullable {
+public:
+ Nullable()
+ : m_value()
+ , m_isNull(true) { }
+
+ Nullable(const T& value)
+ : m_value(value)
+ , m_isNull(false) { }
+
+ Nullable(const Nullable& other)
+ : m_value(other.m_value)
+ , m_isNull(other.m_isNull) { }
+
+ Nullable& operator=(const Nullable& other)
+ {
+ m_value = other.m_value;
+ m_isNull = other.m_isNull;
+ return *this;
+ }
+
+ T get() const { ASSERT(!m_isNull); return m_value; }
+ bool isNull() const { return m_isNull; }
+
+ operator bool() const { return !m_isNull && m_value; }
+
+ bool operator==(const Nullable& other) const
+ {
+ return (m_isNull && other.m_isNull) || (!m_isNull && !other.m_isNull && m_value == other.m_value);
+ }
+
+private:
+ T m_value;
+ bool m_isNull;
+};
+
+} // namespace WebCore
+
+#endif // Nullable_h
diff --git a/Source/bindings/v8/PageScriptDebugServer.cpp b/Source/bindings/v8/PageScriptDebugServer.cpp
index f02407a..8311d67 100644
--- a/Source/bindings/v8/PageScriptDebugServer.cpp
+++ b/Source/bindings/v8/PageScriptDebugServer.cpp
@@ -33,15 +33,18 @@
#include "V8Window.h"
+#include "bindings/v8/DOMWrapperWorld.h"
#include "bindings/v8/ScriptController.h"
#include "bindings/v8/ScriptSourceCode.h"
#include "bindings/v8/V8Binding.h"
#include "bindings/v8/V8ScriptRunner.h"
#include "bindings/v8/V8WindowShell.h"
+#include "core/frame/FrameHost.h"
+#include "core/frame/LocalFrame.h"
+#include "core/frame/PageConsole.h"
+#include "core/frame/UseCounter.h"
#include "core/inspector/InspectorInstrumentation.h"
#include "core/inspector/ScriptDebugListener.h"
-#include "core/frame/Frame.h"
-#include "core/frame/FrameHost.h"
#include "core/page/Page.h"
#include "wtf/OwnPtr.h"
#include "wtf/PassOwnPtr.h"
@@ -51,17 +54,20 @@
namespace WebCore {
-static Frame* retrieveFrameWithGlobalObjectCheck(v8::Handle<v8::Context> context)
+static LocalFrame* retrieveFrameWithGlobalObjectCheck(v8::Handle<v8::Context> context)
{
if (context.IsEmpty())
return 0;
- // Test that context has associated global dom window object.
- v8::Handle<v8::Object> global = context->Global();
- if (global.IsEmpty())
+ // FIXME: This is a temporary hack for crbug.com/345014.
+ // Currently it's possible that V8 can trigger Debugger::ProcessDebugEvent for a context
+ // that is being initialized (i.e., inside Context::New() of the context).
+ // We should fix the V8 side so that it won't trigger the event for a half-baked context
+ // because there is no way in the embedder side to check if the context is half-baked or not.
+ if (isMainThread() && DOMWrapperWorld::windowIsBeingInitialized())
return 0;
- global = global->FindInstanceInPrototypeChain(V8Window::domTemplate(context->GetIsolate(), worldTypeInMainThread(context->GetIsolate())));
+ v8::Handle<v8::Value> global = V8Window::findInstanceInPrototypeChain(context->Global(), context->GetIsolate());
if (global.IsEmpty())
return 0;
@@ -145,7 +151,7 @@
void PageScriptDebugServer::compileScript(ScriptState* state, const String& expression, const String& sourceURL, String* scriptId, String* exceptionMessage)
{
ExecutionContext* executionContext = state->executionContext();
- RefPtr<Frame> protect = toDocument(executionContext)->frame();
+ RefPtr<LocalFrame> protect = toDocument(executionContext)->frame();
ScriptDebugServer::compileScript(state, expression, sourceURL, scriptId, exceptionMessage);
if (!scriptId->isNull())
m_compiledScriptURLs.set(*scriptId, sourceURL);
@@ -162,12 +168,12 @@
String sourceURL = m_compiledScriptURLs.take(scriptId);
ExecutionContext* executionContext = state->executionContext();
- Frame* frame = toDocument(executionContext)->frame();
+ LocalFrame* frame = toDocument(executionContext)->frame();
InspectorInstrumentationCookie cookie;
if (frame)
cookie = InspectorInstrumentation::willEvaluateScript(frame, sourceURL, TextPosition::minimumPosition().m_line.oneBasedInt());
- RefPtr<Frame> protect = frame;
+ RefPtr<LocalFrame> protect = frame;
ScriptDebugServer::runScript(state, scriptId, result, wasThrown, exceptionMessage);
if (frame)
@@ -177,7 +183,7 @@
ScriptDebugListener* PageScriptDebugServer::getDebugListenerForContext(v8::Handle<v8::Context> context)
{
v8::HandleScope scope(m_isolate);
- Frame* frame = retrieveFrameWithGlobalObjectCheck(context);
+ LocalFrame* frame = retrieveFrameWithGlobalObjectCheck(context);
if (!frame)
return 0;
return m_listenersMap.get(frame->page());
@@ -186,7 +192,7 @@
void PageScriptDebugServer::runMessageLoopOnPause(v8::Handle<v8::Context> context)
{
v8::HandleScope scope(m_isolate);
- Frame* frame = retrieveFrameWithGlobalObjectCheck(context);
+ LocalFrame* frame = retrieveFrameWithGlobalObjectCheck(context);
m_pausedPage = frame->page();
// Wait for continue or step command.
@@ -207,7 +213,7 @@
void PageScriptDebugServer::preprocessBeforeCompile(const v8::Debug::EventDetails& eventDetails)
{
v8::Handle<v8::Context> eventContext = eventDetails.GetEventContext();
- Frame* frame = retrieveFrameWithGlobalObjectCheck(eventContext);
+ LocalFrame* frame = retrieveFrameWithGlobalObjectCheck(eventContext);
if (!frame)
return;
@@ -237,7 +243,7 @@
static bool isCreatingPreprocessor = false;
-bool PageScriptDebugServer::canPreprocess(Frame* frame)
+bool PageScriptDebugServer::canPreprocess(LocalFrame* frame)
{
ASSERT(frame);
@@ -261,7 +267,7 @@
}
// Source to Source processing iff debugger enabled and it has loaded a preprocessor.
-PassOwnPtr<ScriptSourceCode> PageScriptDebugServer::preprocess(Frame* frame, const ScriptSourceCode& sourceCode)
+PassOwnPtr<ScriptSourceCode> PageScriptDebugServer::preprocess(LocalFrame* frame, const ScriptSourceCode& sourceCode)
{
if (!canPreprocess(frame))
return PassOwnPtr<ScriptSourceCode>();
@@ -270,7 +276,7 @@
return adoptPtr(new ScriptSourceCode(preprocessedSource, sourceCode.url()));
}
-String PageScriptDebugServer::preprocessEventListener(Frame* frame, const String& source, const String& url, const String& functionName)
+String PageScriptDebugServer::preprocessEventListener(LocalFrame* frame, const String& source, const String& url, const String& functionName)
{
if (!canPreprocess(frame))
return source;
@@ -278,4 +284,16 @@
return m_scriptPreprocessor->preprocessSourceCode(source, url, functionName);
}
+void PageScriptDebugServer::muteWarningsAndDeprecations()
+{
+ PageConsole::mute();
+ UseCounter::muteForInspector();
+}
+
+void PageScriptDebugServer::unmuteWarningsAndDeprecations()
+{
+ PageConsole::unmute();
+ UseCounter::unmuteForInspector();
+}
+
} // namespace WebCore
diff --git a/Source/bindings/v8/PageScriptDebugServer.h b/Source/bindings/v8/PageScriptDebugServer.h
index 4a7078c..6926c14 100644
--- a/Source/bindings/v8/PageScriptDebugServer.h
+++ b/Source/bindings/v8/PageScriptDebugServer.h
@@ -65,8 +65,11 @@
virtual void runScript(ScriptState*, const String& scriptId, ScriptValue* result, bool* wasThrown, String* exceptionMessage) OVERRIDE;
virtual void setPreprocessorSource(const String&) OVERRIDE;
virtual void preprocessBeforeCompile(const v8::Debug::EventDetails&) OVERRIDE;
- virtual PassOwnPtr<ScriptSourceCode> preprocess(Frame*, const ScriptSourceCode&) OVERRIDE;
- virtual String preprocessEventListener(Frame*, const String& source, const String& url, const String& functionName) OVERRIDE;
+ virtual PassOwnPtr<ScriptSourceCode> preprocess(LocalFrame*, const ScriptSourceCode&) OVERRIDE;
+ virtual String preprocessEventListener(LocalFrame*, const String& source, const String& url, const String& functionName) OVERRIDE;
+
+ virtual void muteWarningsAndDeprecations() OVERRIDE;
+ virtual void unmuteWarningsAndDeprecations() OVERRIDE;
private:
PageScriptDebugServer();
@@ -84,7 +87,7 @@
OwnPtr<ScriptSourceCode> m_preprocessorSourceCode;
OwnPtr<ScriptPreprocessor> m_scriptPreprocessor;
- bool canPreprocess(Frame*);
+ bool canPreprocess(LocalFrame*);
};
} // namespace WebCore
diff --git a/Source/bindings/v8/ScheduledAction.cpp b/Source/bindings/v8/ScheduledAction.cpp
index 1de2039..89161e3 100644
--- a/Source/bindings/v8/ScheduledAction.cpp
+++ b/Source/bindings/v8/ScheduledAction.cpp
@@ -38,7 +38,7 @@
#include "bindings/v8/V8ScriptRunner.h"
#include "core/dom/Document.h"
#include "core/dom/ExecutionContext.h"
-#include "core/frame/Frame.h"
+#include "core/frame/LocalFrame.h"
#include "core/workers/WorkerGlobalScope.h"
#include "core/workers/WorkerThread.h"
#include "platform/TraceEvent.h"
@@ -72,7 +72,7 @@
void ScheduledAction::execute(ExecutionContext* context)
{
if (context->isDocument()) {
- Frame* frame = toDocument(context)->frame();
+ LocalFrame* frame = toDocument(context)->frame();
if (!frame)
return;
if (!frame->script().canExecuteScripts(AboutToExecuteScript))
@@ -83,7 +83,7 @@
}
}
-void ScheduledAction::execute(Frame* frame)
+void ScheduledAction::execute(LocalFrame* frame)
{
v8::HandleScope handleScope(m_isolate);
diff --git a/Source/bindings/v8/ScheduledAction.h b/Source/bindings/v8/ScheduledAction.h
index 9b03a02..014cd91 100644
--- a/Source/bindings/v8/ScheduledAction.h
+++ b/Source/bindings/v8/ScheduledAction.h
@@ -40,7 +40,7 @@
namespace WebCore {
-class Frame;
+class LocalFrame;
class ExecutionContext;
class WorkerGlobalScope;
@@ -54,7 +54,7 @@
void execute(ExecutionContext*);
private:
- void execute(Frame*);
+ void execute(LocalFrame*);
void execute(WorkerGlobalScope*);
void createLocalHandlesForArgs(Vector<v8::Handle<v8::Value> >* handles);
diff --git a/Source/bindings/v8/ScriptCallStackFactory.cpp b/Source/bindings/v8/ScriptCallStackFactory.cpp
index e1d531c..b6c66d3 100644
--- a/Source/bindings/v8/ScriptCallStackFactory.cpp
+++ b/Source/bindings/v8/ScriptCallStackFactory.cpp
@@ -34,7 +34,6 @@
#include "bindings/v8/ScriptScope.h"
#include "bindings/v8/ScriptValue.h"
#include "bindings/v8/V8Binding.h"
-#include "bindings/v8/V8Utilities.h"
#include "core/inspector/InspectorInstrumentation.h"
#include "core/inspector/ScriptArguments.h"
#include "core/inspector/ScriptCallFrame.h"
@@ -104,7 +103,7 @@
{
v8::Isolate* isolate = v8::Isolate::GetCurrent();
if (!isolate->InContext())
- return 0;
+ return nullptr;
v8::HandleScope handleScope(isolate);
v8::Handle<v8::StackTrace> stackTrace(v8::StackTrace::CurrentStackTrace(isolate, maxStackSize, stackTraceOptions));
return createScriptCallStack(stackTrace, maxStackSize, emptyStackIsAllowed, isolate);
diff --git a/Source/bindings/v8/ScriptController.cpp b/Source/bindings/v8/ScriptController.cpp
index 59e3c32..eabf555 100644
--- a/Source/bindings/v8/ScriptController.cpp
+++ b/Source/bindings/v8/ScriptController.cpp
@@ -54,16 +54,16 @@
#include "core/events/Event.h"
#include "core/events/EventListener.h"
#include "core/events/ThreadLocalEventNames.h"
+#include "core/frame/DOMWindow.h"
+#include "core/frame/LocalFrame.h"
+#include "core/frame/Settings.h"
+#include "core/frame/csp/ContentSecurityPolicy.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/frame/ContentSecurityPolicy.h"
-#include "core/frame/DOMWindow.h"
-#include "core/frame/Frame.h"
-#include "core/frame/Settings.h"
#include "core/plugins/PluginView.h"
#include "platform/NotImplemented.h"
#include "platform/TraceEvent.h"
@@ -80,7 +80,7 @@
namespace WebCore {
-bool ScriptController::canAccessFromCurrentOrigin(Frame *frame)
+bool ScriptController::canAccessFromCurrentOrigin(LocalFrame *frame)
{
if (!frame)
return false;
@@ -88,7 +88,7 @@
return !isolate->InContext() || BindingSecurity::shouldAllowAccessToFrame(isolate, frame);
}
-ScriptController::ScriptController(Frame* frame)
+ScriptController::ScriptController(LocalFrame* frame)
: m_frame(frame)
, m_sourceURL(0)
, m_isolate(v8::Isolate::GetCurrent())
@@ -123,23 +123,12 @@
}
}
-void ScriptController::clearForOutOfMemory()
-{
- clearForClose(true);
-}
-
-void ScriptController::clearForClose(bool destroyGlobal)
-{
- m_windowShell->clearForClose(destroyGlobal);
- for (IsolatedWorldMap::iterator iter = m_isolatedWorlds.begin(); iter != m_isolatedWorlds.end(); ++iter)
- iter->value->clearForClose(destroyGlobal);
- V8GCController::hintForCollectGarbage();
-}
-
void ScriptController::clearForClose()
{
double start = currentTime();
- clearForClose(false);
+ m_windowShell->clearForClose();
+ for (IsolatedWorldMap::iterator iter = m_isolatedWorlds.begin(); iter != m_isolatedWorlds.end(); ++iter)
+ iter->value->clearForClose();
blink::Platform::current()->histogramCustomCounts("WebCore.ScriptController.clearForClose", (currentTime() - start) * 1000, 0, 10000, 50);
}
@@ -148,10 +137,10 @@
m_windowShell->updateSecurityOrigin(origin);
}
-v8::Local<v8::Value> ScriptController::callFunction(v8::Handle<v8::Function> function, v8::Handle<v8::Object> receiver, int argc, v8::Handle<v8::Value> info[])
+v8::Local<v8::Value> ScriptController::callFunction(v8::Handle<v8::Function> function, v8::Handle<v8::Value> receiver, int argc, v8::Handle<v8::Value> info[])
{
- // Keep Frame (and therefore ScriptController) alive.
- RefPtr<Frame> protect(m_frame);
+ // Keep LocalFrame (and therefore ScriptController) alive.
+ RefPtr<LocalFrame> protect(m_frame);
return ScriptController::callFunction(m_frame->document(), function, receiver, argc, info, m_isolate);
}
@@ -169,7 +158,7 @@
return true;
}
-v8::Local<v8::Value> ScriptController::callFunction(ExecutionContext* context, v8::Handle<v8::Function> function, v8::Handle<v8::Object> receiver, int argc, v8::Handle<v8::Value> info[], v8::Isolate* isolate)
+v8::Local<v8::Value> ScriptController::callFunction(ExecutionContext* context, v8::Handle<v8::Function> function, v8::Handle<v8::Value> receiver, int argc, v8::Handle<v8::Value> info[], v8::Isolate* isolate)
{
InspectorInstrumentationCookie cookie;
if (InspectorInstrumentation::timelineAgentEnabled(context)) {
@@ -208,8 +197,8 @@
// 1, whereas v8 starts at 0.
v8::Handle<v8::Script> script = V8ScriptRunner::compileScript(code, source.url(), source.startPosition(), scriptData.get(), m_isolate, corsStatus);
- // Keep Frame (and therefore ScriptController) alive.
- RefPtr<Frame> protect(m_frame);
+ // Keep LocalFrame (and therefore ScriptController) alive.
+ RefPtr<LocalFrame> protect(m_frame);
result = V8ScriptRunner::runCompiledScript(script, m_frame->document(), m_isolate);
ASSERT(!tryCatch.HasCaught() || result.IsEmpty());
}
@@ -263,10 +252,11 @@
bool ScriptController::shouldBypassMainWorldContentSecurityPolicy()
{
+ v8::Handle<v8::Context> context = m_isolate->GetCurrentContext();
+ if (context.IsEmpty() || !toDOMWindow(context))
+ return false;
DOMWrapperWorld* world = DOMWrapperWorld::current(m_isolate);
- if (world && world->isIsolatedWorld())
- return world->isolatedWorldHasContentSecurityPolicy();
- return false;
+ return world->isIsolatedWorld() ? world->isolatedWorldHasContentSecurityPolicy() : false;
}
TextPosition ScriptController::eventHandlerPosition() const
@@ -278,7 +268,7 @@
}
// Create a V8 object with an interceptor of NPObjectPropertyGetter.
-void ScriptController::bindToWindowObject(Frame* frame, const String& key, NPObject* object)
+void ScriptController::bindToWindowObject(LocalFrame* frame, const String& key, NPObject* object)
{
v8::HandleScope handleScope(m_isolate);
@@ -318,13 +308,13 @@
ASSERT(widget);
if (!widget->isPluginView())
- return 0;
+ return nullptr;
NPObject* npObject = toPluginView(widget)->scriptableObject();
if (!npObject)
- return 0;
+ return nullptr;
- // Frame Memory Management for NPObjects
+ // LocalFrame Memory Management for NPObjects
// -------------------------------------
// NPObjects are treated differently than other objects wrapped by JS.
// NPObjects can be created either by the browser (e.g. the main
@@ -333,7 +323,7 @@
// is especially careful to ensure NPObjects terminate at frame teardown because
// if a plugin leaks a reference, it could leak its objects (or the browser's objects).
//
- // The Frame maintains a list of plugin objects (m_pluginObjects)
+ // The LocalFrame maintains a list of plugin objects (m_pluginObjects)
// which it can use to quickly find the wrapped embed object.
//
// Inside the NPRuntime, we've added a few methods for registering
@@ -389,7 +379,7 @@
return 0;
}
-static NPObject* createScriptObject(Frame* frame, v8::Isolate* isolate)
+static NPObject* createScriptObject(LocalFrame* frame, v8::Isolate* isolate)
{
v8::HandleScope handleScope(isolate);
v8::Handle<v8::Context> v8Context = toV8Context(isolate, frame, DOMWrapperWorld::mainWorld());
@@ -452,7 +442,6 @@
for (IsolatedWorldMap::iterator iter = m_isolatedWorlds.begin(); iter != m_isolatedWorlds.end(); ++iter)
iter->value->clearForNavigation();
clearScriptObjects();
- V8GCController::hintForCollectGarbage();
blink::Platform::current()->histogramCustomCounts("WebCore.ScriptController.clearWindowShell", (currentTime() - start) * 1000, 0, 10000, 50);
}
@@ -542,9 +531,9 @@
|| !m_frame->document()->contentSecurityPolicy()->allowJavaScriptURLs(m_frame->document()->url(), eventHandlerPosition().m_line))
return true;
- // We need to hold onto the Frame here because executing script can
+ // We need to hold onto the LocalFrame here because executing script can
// destroy the frame.
- RefPtr<Frame> protector(m_frame);
+ RefPtr<LocalFrame> protector(m_frame);
RefPtr<Document> ownerDocument(m_frame->document());
const int javascriptSchemeLength = sizeof("javascript:") - 1;
@@ -607,7 +596,7 @@
if (v8Context.IsEmpty())
return ScriptValue();
- RefPtr<Frame> protect(m_frame);
+ RefPtr<LocalFrame> protect(m_frame);
if (m_frame->loader().stateMachine()->isDisplayingInitialEmptyDocument())
m_frame->loader().didAccessInitialDocument();
diff --git a/Source/bindings/v8/ScriptController.h b/Source/bindings/v8/ScriptController.h
index 88cab83..6a9ece2 100644
--- a/Source/bindings/v8/ScriptController.h
+++ b/Source/bindings/v8/ScriptController.h
@@ -49,7 +49,7 @@
class DOMWrapperWorld;
class ExecutionContext;
class Event;
-class Frame;
+class LocalFrame;
class HTMLDocument;
class HTMLPlugInElement;
class KURL;
@@ -73,7 +73,7 @@
DoNotExecuteScriptWhenScriptsDisabled
};
- ScriptController(Frame*);
+ ScriptController(LocalFrame*);
~ScriptController();
bool initializeMainWorld();
@@ -99,8 +99,8 @@
// Returns true if argument is a JavaScript URL.
bool executeScriptIfJavaScriptURL(const KURL&);
- v8::Local<v8::Value> callFunction(v8::Handle<v8::Function>, v8::Handle<v8::Object>, int argc, v8::Handle<v8::Value> argv[]);
- static v8::Local<v8::Value> callFunction(ExecutionContext*, v8::Handle<v8::Function>, v8::Handle<v8::Object> receiver, int argc, v8::Handle<v8::Value> info[], v8::Isolate*);
+ v8::Local<v8::Value> callFunction(v8::Handle<v8::Function>, v8::Handle<v8::Value>, int argc, v8::Handle<v8::Value> argv[]);
+ static v8::Local<v8::Value> callFunction(ExecutionContext*, v8::Handle<v8::Function>, v8::Handle<v8::Value> receiver, int argc, v8::Handle<v8::Value> info[], 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
@@ -108,14 +108,14 @@
bool shouldBypassMainWorldContentSecurityPolicy();
// Creates a property of the global object of a frame.
- void bindToWindowObject(Frame*, const String& key, NPObject*);
+ void bindToWindowObject(LocalFrame*, const String& key, NPObject*);
PassRefPtr<SharedPersistent<v8::Object> > createPluginWrapper(Widget*);
void enableEval();
void disableEval(const String& errorMessage);
- static bool canAccessFromCurrentOrigin(Frame*);
+ static bool canAccessFromCurrentOrigin(LocalFrame*);
static void setCaptureCallStackForUncaughtExceptions(bool);
void collectIsolatedContexts(Vector<std::pair<ScriptState*, SecurityOrigin*> >&);
@@ -135,7 +135,6 @@
void cleanupScriptObjectsForPlugin(Widget*);
void clearForClose();
- void clearForOutOfMemory();
NPObject* createScriptObjectForPluginElement(HTMLPlugInElement*);
NPObject* windowScriptNPObject();
@@ -156,9 +155,8 @@
typedef HashMap<Widget*, NPObject*> PluginObjectMap;
ScriptValue evaluateScriptInMainWorld(const ScriptSourceCode&, AccessControlStatus, ExecuteScriptPolicy);
- void clearForClose(bool destroyGlobal);
- Frame* m_frame;
+ LocalFrame* m_frame;
const String* m_sourceURL;
v8::Isolate* m_isolate;
diff --git a/Source/bindings/v8/ScriptDebugServer.cpp b/Source/bindings/v8/ScriptDebugServer.cpp
index 637e568..862fc22 100644
--- a/Source/bindings/v8/ScriptDebugServer.cpp
+++ b/Source/bindings/v8/ScriptDebugServer.cpp
@@ -618,12 +618,12 @@
}
}
-PassOwnPtr<ScriptSourceCode> ScriptDebugServer::preprocess(Frame*, const ScriptSourceCode&)
+PassOwnPtr<ScriptSourceCode> ScriptDebugServer::preprocess(LocalFrame*, const ScriptSourceCode&)
{
return PassOwnPtr<ScriptSourceCode>();
}
-String ScriptDebugServer::preprocessEventListener(Frame*, const String& source, const String& url, const String& functionName)
+String ScriptDebugServer::preprocessEventListener(LocalFrame*, const String& source, const String& url, const String& functionName)
{
return source;
}
diff --git a/Source/bindings/v8/ScriptDebugServer.h b/Source/bindings/v8/ScriptDebugServer.h
index 3d0e07a..f268529 100644
--- a/Source/bindings/v8/ScriptDebugServer.h
+++ b/Source/bindings/v8/ScriptDebugServer.h
@@ -101,8 +101,11 @@
virtual void runScript(ScriptState*, const String& scriptId, ScriptValue* result, bool* wasThrown, String* exceptionMessage);
virtual void setPreprocessorSource(const String&) { }
virtual void preprocessBeforeCompile(const v8::Debug::EventDetails&) { }
- virtual PassOwnPtr<ScriptSourceCode> preprocess(Frame*, const ScriptSourceCode&);
- virtual String preprocessEventListener(Frame*, const String& source, const String& url, const String& functionName);
+ virtual PassOwnPtr<ScriptSourceCode> preprocess(LocalFrame*, const ScriptSourceCode&);
+ virtual String preprocessEventListener(LocalFrame*, const String& source, const String& url, const String& functionName);
+
+ virtual void muteWarningsAndDeprecations() { }
+ virtual void unmuteWarningsAndDeprecations() { }
protected:
explicit ScriptDebugServer(v8::Isolate*);
diff --git a/Source/bindings/v8/ScriptEventListener.cpp b/Source/bindings/v8/ScriptEventListener.cpp
index 2af6e17..76abf69 100644
--- a/Source/bindings/v8/ScriptEventListener.cpp
+++ b/Source/bindings/v8/ScriptEventListener.cpp
@@ -40,7 +40,7 @@
#include "core/dom/Document.h"
#include "core/dom/DocumentParser.h"
#include "core/events/EventListener.h"
-#include "core/frame/Frame.h"
+#include "core/frame/LocalFrame.h"
namespace WebCore {
@@ -55,18 +55,18 @@
{
ASSERT(node);
if (value.isNull())
- return 0;
+ return nullptr;
// FIXME: Very strange: we initialize zero-based number with '1'.
TextPosition position(OrdinalNumber::fromZeroBasedInt(1), OrdinalNumber::first());
String sourceURL;
v8::Isolate* isolate;
- if (Frame* frame = node->document().frame()) {
+ if (LocalFrame* frame = node->document().frame()) {
isolate = toIsolate(frame);
ScriptController& scriptController = frame->script();
if (!scriptController.canExecuteScripts(AboutToExecuteScript))
- return 0;
+ return nullptr;
position = scriptController.eventHandlerPosition();
sourceURL = node->document().url().string();
} else {
@@ -76,17 +76,17 @@
return V8LazyEventListener::create(name.localName(), eventParameterName(node->isSVGElement()), value, sourceURL, position, node, isolate);
}
-PassRefPtr<V8LazyEventListener> createAttributeEventListener(Frame* frame, const QualifiedName& name, const AtomicString& value)
+PassRefPtr<V8LazyEventListener> createAttributeEventListener(LocalFrame* frame, const QualifiedName& name, const AtomicString& value)
{
if (!frame)
- return 0;
+ return nullptr;
if (value.isNull())
- return 0;
+ return nullptr;
ScriptController& scriptController = frame->script();
if (!scriptController.canExecuteScripts(AboutToExecuteScript))
- return 0;
+ return nullptr;
TextPosition position = scriptController.eventHandlerPosition();
String sourceURL = frame->document()->url().string();
@@ -148,7 +148,7 @@
return ScriptValue(function, isolate);
}
-ScriptState* eventListenerHandlerScriptState(Frame* frame, EventListener* listener)
+ScriptState* eventListenerHandlerScriptState(LocalFrame* frame, EventListener* listener)
{
if (listener->type() != EventListener::JSEventListenerType)
return 0;
diff --git a/Source/bindings/v8/ScriptEventListener.h b/Source/bindings/v8/ScriptEventListener.h
index bfb75eb..cd688b9 100644
--- a/Source/bindings/v8/ScriptEventListener.h
+++ b/Source/bindings/v8/ScriptEventListener.h
@@ -40,15 +40,15 @@
class Document;
class EventListener;
- class Frame;
+ class LocalFrame;
class Node;
class QualifiedName;
PassRefPtr<V8LazyEventListener> createAttributeEventListener(Node*, const QualifiedName&, const AtomicString& value);
- PassRefPtr<V8LazyEventListener> createAttributeEventListener(Frame*, const QualifiedName&, const AtomicString& value);
+ PassRefPtr<V8LazyEventListener> createAttributeEventListener(LocalFrame*, const QualifiedName&, const AtomicString& value);
String eventListenerHandlerBody(Document*, EventListener*);
ScriptValue eventListenerHandler(Document*, EventListener*);
- ScriptState* eventListenerHandlerScriptState(Frame*, EventListener*);
+ ScriptState* eventListenerHandlerScriptState(LocalFrame*, EventListener*);
bool eventListenerHandlerLocation(Document*, EventListener*, String& sourceName, String& scriptId, int& lineNumber);
} // namespace WebCore
diff --git a/Source/bindings/v8/ScriptFunctionCall.cpp b/Source/bindings/v8/ScriptFunctionCall.cpp
index 6f6947c..2ef9297 100644
--- a/Source/bindings/v8/ScriptFunctionCall.cpp
+++ b/Source/bindings/v8/ScriptFunctionCall.cpp
@@ -38,7 +38,6 @@
#include "bindings/v8/V8Binding.h"
#include "bindings/v8/V8ObjectConstructor.h"
#include "bindings/v8/V8ScriptRunner.h"
-#include "bindings/v8/V8Utilities.h"
#include <v8.h>
diff --git a/Source/bindings/v8/V8Utilities.h b/Source/bindings/v8/ScriptObjectTraits.h
similarity index 61%
rename from Source/bindings/v8/V8Utilities.h
rename to Source/bindings/v8/ScriptObjectTraits.h
index f805f46..1bdb203 100644
--- a/Source/bindings/v8/V8Utilities.h
+++ b/Source/bindings/v8/ScriptObjectTraits.h
@@ -1,5 +1,5 @@
/*
- * Copyright (C) 2006, 2007, 2008, 2009 Google Inc. All rights reserved.
+ * Copyright (C) 2014 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
@@ -28,32 +28,28 @@
* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
-#ifndef V8Utilities_h
-#define V8Utilities_h
+#ifndef ScriptObjectTraits_h
+#define ScriptObjectTraits_h
-#include "wtf/Forward.h"
-#include "wtf/Vector.h"
-#include <v8.h>
-
-namespace WTF {
-class ArrayBuffer;
-}
+#include "bindings/v8/ScriptObject.h"
+#include "bindings/v8/ScriptState.h"
+#include "wtf/HashTraits.h"
namespace WebCore {
- class EventListener;
- class MessagePort;
- class ExecutionContext;
- class ExceptionState;
+struct ScriptObjectHash {
+ static unsigned hash(const ScriptObject& object) { return object.v8Object()->GetIdentityHash(); }
+ static bool equal(const ScriptObject& a, const ScriptObject& b) { return a == b; }
+ static const bool safeToCompareToEmptyOrDeleted = true;
+};
- typedef WTF::Vector<RefPtr<MessagePort>, 1> MessagePortArray;
- typedef WTF::Vector<RefPtr<ArrayBuffer>, 1> ArrayBufferArray;
+struct ScriptObjectHashTraits : WTF::GenericHashTraits<ScriptObject> {
+ static const bool emptyValueIsZero = false;
+ static ScriptObject emptyValue() { return ScriptObject(ScriptState::current(), ScriptValue::createNull()); }
+ static void constructDeletedValue(ScriptObject& slot) { slot = ScriptObject(); }
+ static bool isDeletedValue(ScriptObject value) { return value.hasNoValue(); }
+};
- // Helper function which pulls the values out of a JS sequence and into a MessagePortArray.
- // Also validates the elements per sections 4.1.13 and 4.1.15 of the WebIDL spec and section 8.3.3
- // of the HTML5 spec and generates exceptions as appropriate.
- // Returns true if the array was filled, or false if the passed value was not of an appropriate type.
- bool extractTransferables(v8::Local<v8::Value>, int, MessagePortArray&, ArrayBufferArray&, ExceptionState&, v8::Isolate*);
} // namespace WebCore
-#endif // V8Utilities_h
+#endif // !defined(ScriptObjectTraits_h)
diff --git a/Source/bindings/v8/ScriptPreprocessor.cpp b/Source/bindings/v8/ScriptPreprocessor.cpp
index 5203828..ecf71b7 100644
--- a/Source/bindings/v8/ScriptPreprocessor.cpp
+++ b/Source/bindings/v8/ScriptPreprocessor.cpp
@@ -36,14 +36,14 @@
#include "bindings/v8/ScriptValue.h"
#include "bindings/v8/V8Binding.h"
#include "bindings/v8/V8ScriptRunner.h"
-#include "core/frame/Frame.h"
#include "core/frame/FrameHost.h"
+#include "core/frame/LocalFrame.h"
#include "core/frame/PageConsole.h"
#include "wtf/TemporaryChange.h"
namespace WebCore {
-ScriptPreprocessor::ScriptPreprocessor(const ScriptSourceCode& preprocessorSourceCode, Frame* frame)
+ScriptPreprocessor::ScriptPreprocessor(const ScriptSourceCode& preprocessorSourceCode, LocalFrame* frame)
: m_isolate(V8PerIsolateData::mainThreadIsolate())
, m_isPreprocessing(false)
{
diff --git a/Source/bindings/v8/ScriptPreprocessor.h b/Source/bindings/v8/ScriptPreprocessor.h
index 4fb2d29..26ff107 100644
--- a/Source/bindings/v8/ScriptPreprocessor.h
+++ b/Source/bindings/v8/ScriptPreprocessor.h
@@ -45,7 +45,7 @@
class ScriptPreprocessor {
WTF_MAKE_NONCOPYABLE(ScriptPreprocessor);
public:
- ScriptPreprocessor(const ScriptSourceCode&, Frame*);
+ ScriptPreprocessor(const ScriptSourceCode&, LocalFrame*);
String preprocessSourceCode(const String& sourceCode, const String& sourceName);
String preprocessSourceCode(const String& sourceCode, const String& sourceName, const String& functionName);
bool isPreprocessing() { return m_isPreprocessing; }
diff --git a/Source/bindings/v8/ScriptProfiler.cpp b/Source/bindings/v8/ScriptProfiler.cpp
index 85bb107..b10c825 100644
--- a/Source/bindings/v8/ScriptProfiler.cpp
+++ b/Source/bindings/v8/ScriptProfiler.cpp
@@ -77,11 +77,11 @@
v8::Isolate* isolate = v8::Isolate::GetCurrent();
v8::CpuProfiler* profiler = isolate->GetCpuProfiler();
if (!profiler)
- return 0;
+ return nullptr;
v8::HandleScope handleScope(isolate);
const v8::CpuProfile* profile = profiler->StopCpuProfiling(v8String(isolate, title));
if (!profile)
- return 0;
+ return nullptr;
String profileTitle = toCoreString(profile->GetTitle());
double idleTime = 0.0;
@@ -233,13 +233,13 @@
v8::Isolate* isolate = v8::Isolate::GetCurrent();
v8::HeapProfiler* profiler = isolate->GetHeapProfiler();
if (!profiler)
- return 0;
+ return nullptr;
v8::HandleScope handleScope(isolate);
ASSERT(control);
ActivityControlAdapter adapter(control);
GlobalObjectNameResolver resolver;
const v8::HeapSnapshot* snapshot = profiler->TakeHeapSnapshot(v8String(isolate, title), &adapter, &resolver);
- return snapshot ? ScriptHeapSnapshot::create(snapshot) : 0;
+ return snapshot ? ScriptHeapSnapshot::create(snapshot) : nullptr;
}
static v8::RetainedObjectInfo* retainedDOMInfo(uint16_t classId, v8::Handle<v8::Value> wrapper)
diff --git a/Source/bindings/v8/ScriptPromise.cpp b/Source/bindings/v8/ScriptPromise.cpp
index c389c2a..17d03b2 100644
--- a/Source/bindings/v8/ScriptPromise.cpp
+++ b/Source/bindings/v8/ScriptPromise.cpp
@@ -39,6 +39,16 @@
namespace WebCore {
+ScriptPromise::ScriptPromise(v8::Handle<v8::Value> value, v8::Isolate* isolate)
+{
+ if (value.IsEmpty() || !V8PromiseCustom::isPromise(value, isolate)) {
+ m_promise = ScriptValue(v8::Handle<v8::Value>(), isolate);
+ V8ThrowException::throwTypeError("the given value is not a Promise", isolate);
+ return;
+ }
+ m_promise = ScriptValue(value, isolate);
+}
+
ScriptPromise ScriptPromise::then(PassOwnPtr<ScriptFunction> onFulfilled, PassOwnPtr<ScriptFunction> onRejected)
{
if (m_promise.hasNoValue() || !m_promise.isObject())
@@ -47,17 +57,12 @@
return ScriptPromise(V8PromiseCustom::then(promise, adoptByGarbageCollector(onFulfilled), adoptByGarbageCollector(onRejected), isolate()), isolate());
}
-ScriptPromise::ScriptPromise(const ScriptValue& value)
+ScriptPromise ScriptPromise::createPending()
{
- if (value.hasNoValue())
- return;
- v8::Local<v8::Value> v8Value(value.v8Value());
- v8::Isolate* isolate = value.isolate();
- if (V8PromiseCustom::isPromise(v8Value, isolate)) {
- m_promise = value;
- return;
- }
- m_promise = ScriptValue(V8PromiseCustom::toPromise(v8Value, isolate), isolate);
+ v8::Isolate* isolate = v8::Isolate::GetCurrent();
+ ASSERT(isolate->InContext());
+ v8::Handle<v8::Object> promise = V8PromiseCustom::createPromise(v8::Object::New(isolate), isolate);
+ return ScriptPromise(promise, isolate);
}
ScriptPromise ScriptPromise::createPending(ExecutionContext* context)
@@ -71,12 +76,16 @@
return ScriptPromise(promise, isolate);
}
-ScriptPromise ScriptPromise::createPending()
+ScriptPromise ScriptPromise::cast(const ScriptValue& value)
{
- v8::Isolate* isolate = v8::Isolate::GetCurrent();
- ASSERT(isolate->InContext());
- v8::Handle<v8::Object> promise = V8PromiseCustom::createPromise(v8::Object::New(isolate), isolate);
- return ScriptPromise(promise, isolate);
+ if (value.hasNoValue())
+ return ScriptPromise();
+ v8::Local<v8::Value> v8Value(value.v8Value());
+ v8::Isolate* isolate = value.isolate();
+ if (V8PromiseCustom::isPromise(v8Value, isolate)) {
+ return ScriptPromise(v8Value, isolate);
+ }
+ return ScriptPromise(V8PromiseCustom::toPromise(v8Value, isolate), isolate);
}
} // namespace WebCore
diff --git a/Source/bindings/v8/ScriptPromise.h b/Source/bindings/v8/ScriptPromise.h
index a4fe2be..35de810 100644
--- a/Source/bindings/v8/ScriptPromise.h
+++ b/Source/bindings/v8/ScriptPromise.h
@@ -52,17 +52,9 @@
// Constructs an empty promise.
ScriptPromise() { }
- // Constructs a ScriptPromise from |value|.
- // i.e. the constructed ScriptPromise holds |Promise.cast(value)|.
- // Note: if |value| is a non-Promise value, two ScriptPromises constructed
- // with it hold different Promises each other.
- explicit ScriptPromise(const ScriptValue& /* value */);
-
- ScriptPromise(v8::Handle<v8::Value> promise, v8::Isolate* isolate)
- : m_promise(promise, isolate)
- {
- ASSERT(!m_promise.hasNoValue());
- }
+ // Constructs a ScriptPromise from |promise|.
+ // If |promise| is not a Promise object, throws a v8 TypeError.
+ ScriptPromise(v8::Handle<v8::Value> promise, v8::Isolate*);
ScriptPromise then(PassOwnPtr<ScriptFunction> onFulfilled, PassOwnPtr<ScriptFunction> onRejected = PassOwnPtr<ScriptFunction>());
@@ -101,10 +93,18 @@
m_promise.clear();
}
- static ScriptPromise createPending();
- static ScriptPromise createPending(ExecutionContext*);
+ // Constructs and returns a ScriptPromise from |value|.
+ // if |value| is not a Promise object, returns a Promise object
+ // resolved with |value|.
+ static ScriptPromise cast(const ScriptValue& /*value*/);
private:
+ friend class ScriptPromiseResolver;
+
+ static ScriptPromise createPending();
+ static ScriptPromise createPending(ExecutionContext*);
+ static ScriptPromise createPending(v8::Isolate*) { return createPending(); }
+
ScriptValue m_promise;
};
diff --git a/Source/bindings/v8/ScriptPromiseResolver.cpp b/Source/bindings/v8/ScriptPromiseResolver.cpp
index fec672f..b9c2704 100644
--- a/Source/bindings/v8/ScriptPromiseResolver.cpp
+++ b/Source/bindings/v8/ScriptPromiseResolver.cpp
@@ -41,9 +41,15 @@
namespace WebCore {
-ScriptPromiseResolver::ScriptPromiseResolver(ScriptPromise promise)
- : m_isolate(promise.isolate())
- , m_promise(promise)
+ScriptPromiseResolver::ScriptPromiseResolver(ExecutionContext* context)
+ : m_isolate(toIsolate(context))
+ , m_promise(ScriptPromise::createPending(context))
+{
+}
+
+ScriptPromiseResolver::ScriptPromiseResolver(v8::Isolate* isolate)
+ : m_isolate(isolate)
+ , m_promise(ScriptPromise::createPending(isolate))
{
}
@@ -55,17 +61,17 @@
m_promise.clear();
}
-PassRefPtr<ScriptPromiseResolver> ScriptPromiseResolver::create(ScriptPromise promise, ExecutionContext* context)
+PassRefPtr<ScriptPromiseResolver> ScriptPromiseResolver::create(ExecutionContext* context)
{
- ASSERT(promise.isolate()->InContext());
ASSERT(context);
- return adoptRef(new ScriptPromiseResolver(promise));
+ ASSERT(toIsolate(context)->InContext());
+ return adoptRef(new ScriptPromiseResolver(context));
}
-PassRefPtr<ScriptPromiseResolver> ScriptPromiseResolver::create(ScriptPromise promise)
+PassRefPtr<ScriptPromiseResolver> ScriptPromiseResolver::create(v8::Isolate* isolate)
{
- ASSERT(promise.isolate()->InContext());
- return adoptRef(new ScriptPromiseResolver(promise));
+ ASSERT(isolate->InContext());
+ return adoptRef(new ScriptPromiseResolver(isolate));
}
bool ScriptPromiseResolver::isPending() const
diff --git a/Source/bindings/v8/ScriptPromiseResolver.h b/Source/bindings/v8/ScriptPromiseResolver.h
index e651b9d..200638e 100644
--- a/Source/bindings/v8/ScriptPromiseResolver.h
+++ b/Source/bindings/v8/ScriptPromiseResolver.h
@@ -50,7 +50,7 @@
// (resolve / reject) from C++ world.
// ScriptPromiseResolver holds a PromiseResolver.
// Here is a typical usage:
-// 1. Create a ScriptPromiseResolver from a ScriptPromise.
+// 1. Create a ScriptPromiseResolver.
// 2. Pass the promise object of the holder to a JavaScript program
// (such as XMLHttpRequest return value).
// 3. Call resolve or reject when the operation completes or
@@ -67,8 +67,8 @@
class ScriptPromiseResolver : public RefCounted<ScriptPromiseResolver> {
WTF_MAKE_NONCOPYABLE(ScriptPromiseResolver);
public:
- static PassRefPtr<ScriptPromiseResolver> create(ScriptPromise, ExecutionContext*);
- static PassRefPtr<ScriptPromiseResolver> create(ScriptPromise);
+ static PassRefPtr<ScriptPromiseResolver> create(ExecutionContext*);
+ static PassRefPtr<ScriptPromiseResolver> create(v8::Isolate*);
// A ScriptPromiseResolver should be resolved / rejected before
// its destruction.
@@ -134,7 +134,9 @@
void reject(ScriptValue);
private:
- ScriptPromiseResolver(ScriptPromise);
+ ScriptPromiseResolver(ExecutionContext*);
+ ScriptPromiseResolver(v8::Isolate*);
+
void resolve(v8::Handle<v8::Value>);
void reject(v8::Handle<v8::Value>);
diff --git a/Source/bindings/v8/ScriptPromiseResolverTest.cpp b/Source/bindings/v8/ScriptPromiseResolverTest.cpp
index c080408..30fe569 100644
--- a/Source/bindings/v8/ScriptPromiseResolverTest.cpp
+++ b/Source/bindings/v8/ScriptPromiseResolverTest.cpp
@@ -47,27 +47,21 @@
public:
ScriptPromiseResolverTest()
: m_isolate(v8::Isolate::GetCurrent())
- , m_handleScope(m_isolate)
- , m_context(m_isolate, v8::Context::New(m_isolate))
- , m_contextScope(m_context.newLocal(m_isolate))
{
}
void SetUp()
{
- v8::Handle<v8::Context> context(m_context.newLocal(m_isolate));
- V8PerContextDataHolder::install(context, DOMWrapperWorld::current(m_isolate));
- m_perContextData = V8PerContextData::create(context);
- m_perContextData->init();
- m_promise = ScriptPromise::createPending();
- m_resolver = ScriptPromiseResolver::create(m_promise);
+ m_scope = V8ExecutionScope::create(m_isolate);
+ m_resolver = ScriptPromiseResolver::create(m_isolate);
+ m_promise = m_resolver->promise();
}
void TearDown()
{
- m_resolver = 0;
+ m_resolver = nullptr;
m_promise.clear();
- m_perContextData.clear();
+ m_scope.clear();
}
V8PromiseCustom::PromiseState state()
@@ -88,12 +82,10 @@
protected:
v8::Isolate* m_isolate;
- v8::HandleScope m_handleScope;
- ScopedPersistent<v8::Context> m_context;
- v8::Context::Scope m_contextScope;
RefPtr<ScriptPromiseResolver> m_resolver;
ScriptPromise m_promise;
- OwnPtr<V8PerContextData> m_perContextData;
+private:
+ OwnPtr<V8ExecutionScope> m_scope;
};
TEST_F(ScriptPromiseResolverTest, initialState)
diff --git a/Source/bindings/v8/ScriptPromiseTest.cpp b/Source/bindings/v8/ScriptPromiseTest.cpp
index 07153f1..c40fa5e 100644
--- a/Source/bindings/v8/ScriptPromiseTest.cpp
+++ b/Source/bindings/v8/ScriptPromiseTest.cpp
@@ -32,6 +32,7 @@
#include "bindings/v8/ScriptPromise.h"
#include "bindings/v8/DOMWrapperWorld.h"
+#include "bindings/v8/ScriptPromiseResolver.h"
#include "bindings/v8/ScriptValue.h"
#include "bindings/v8/V8Binding.h"
#include "bindings/v8/custom/V8PromiseCustom.h"
@@ -43,27 +44,20 @@
namespace {
+void callback(const v8::FunctionCallbackInfo<v8::Value>& info) { }
+
class ScriptPromiseTest : public testing::Test {
public:
ScriptPromiseTest()
: m_isolate(v8::Isolate::GetCurrent())
- , m_handleScope(m_isolate)
- , m_context(m_isolate, v8::Context::New(m_isolate))
- , m_contextScope(m_context.newLocal(m_isolate))
{
+ m_scope = V8ExecutionScope::create(m_isolate);
}
- void SetUp()
+ ~ScriptPromiseTest()
{
- v8::Handle<v8::Context> context(m_context.newLocal(m_isolate));
- V8PerContextDataHolder::install(context, DOMWrapperWorld::current(m_isolate));
- m_perContextData = V8PerContextData::create(context);
- m_perContextData->init();
- }
-
- void TearDown()
- {
- m_perContextData.clear();
+ // FIXME: We put this statement here to clear an exception from the isolate.
+ createClosure(callback, v8::Undefined(m_isolate), m_isolate);
}
V8PromiseCustom::PromiseState state(ScriptPromise promise)
@@ -73,16 +67,23 @@
protected:
v8::Isolate* m_isolate;
- v8::HandleScope m_handleScope;
- ScopedPersistent<v8::Context> m_context;
- v8::Context::Scope m_contextScope;
- OwnPtr<V8PerContextData> m_perContextData;
+
+private:
+ OwnPtr<V8ExecutionScope> m_scope;
};
+TEST_F(ScriptPromiseTest, constructFromNonPromise)
+{
+ v8::TryCatch trycatch;
+ ScriptPromise promise(v8::Undefined(m_isolate), m_isolate);
+ ASSERT_TRUE(trycatch.HasCaught());
+ ASSERT_TRUE(promise.hasNoValue());
+}
+
TEST_F(ScriptPromiseTest, castPromise)
{
- ScriptPromise promise = ScriptPromise::createPending();
- ScriptPromise newPromise(ScriptValue(promise.v8Value(), m_isolate));
+ ScriptPromise promise = ScriptPromiseResolver::create(m_isolate)->promise();
+ ScriptPromise newPromise = ScriptPromise::cast(ScriptValue(promise.v8Value(), m_isolate));
ASSERT_FALSE(promise.hasNoValue());
EXPECT_EQ(V8PromiseCustom::Pending, state(promise));
@@ -92,8 +93,8 @@
TEST_F(ScriptPromiseTest, castNonPromise)
{
ScriptValue value = ScriptValue(v8String(m_isolate, "hello"), m_isolate);
- ScriptPromise promise1(ScriptValue(value.v8Value(), m_isolate));
- ScriptPromise promise2(ScriptValue(value.v8Value(), m_isolate));
+ ScriptPromise promise1 = ScriptPromise::cast(ScriptValue(value.v8Value(), m_isolate));
+ ScriptPromise promise2 = ScriptPromise::cast(ScriptValue(value.v8Value(), m_isolate));
ASSERT_FALSE(promise1.hasNoValue());
ASSERT_FALSE(promise2.hasNoValue());
diff --git a/Source/bindings/v8/ScriptRegexp.cpp b/Source/bindings/v8/ScriptRegexp.cpp
index d0be2a1..0d5df30 100644
--- a/Source/bindings/v8/ScriptRegexp.cpp
+++ b/Source/bindings/v8/ScriptRegexp.cpp
@@ -31,7 +31,7 @@
#include "bindings/v8/V8Binding.h"
#include "bindings/v8/V8PerIsolateData.h"
-#include "bindings/v8/V8RecursionScope.h"
+#include "bindings/v8/V8ScriptRunner.h"
namespace WebCore {
@@ -39,8 +39,8 @@
{
v8::Isolate* isolate = v8::Isolate::GetCurrent();
v8::HandleScope handleScope(isolate);
- v8::Local<v8::Context> context = V8PerIsolateData::from(isolate)->ensureRegexContext();
- v8::Context::Scope scope(context);
+ v8::Context::Scope contextScope(V8PerIsolateData::from(isolate)->ensureRegexContext());
+ v8::TryCatch tryCatch;
unsigned flags = v8::RegExp::kNone;
if (caseSensitivity == TextCaseInsensitive)
@@ -48,8 +48,7 @@
if (multilineMode == MultilineEnabled)
flags |= v8::RegExp::kMultiline;
- v8::TryCatch tryCatch;
- v8::Local<v8::RegExp> regex = v8::RegExp::New(v8String(context->GetIsolate(), pattern), static_cast<v8::RegExp::Flags>(flags));
+ v8::Local<v8::RegExp> regex = v8::RegExp::New(v8String(isolate, pattern), static_cast<v8::RegExp::Flags>(flags));
// If the regex failed to compile we'll get an empty handle.
if (!regex.IsEmpty())
@@ -70,17 +69,13 @@
v8::Isolate* isolate = v8::Isolate::GetCurrent();
v8::HandleScope handleScope(isolate);
- v8::Local<v8::Context> context = V8PerIsolateData::current()->ensureRegexContext();
- v8::Context::Scope scope(context);
+ v8::Context::Scope contextScope(V8PerIsolateData::from(isolate)->ensureRegexContext());
v8::TryCatch tryCatch;
- V8RecursionScope::MicrotaskSuppression microtaskScope;
-
v8::Local<v8::RegExp> regex = m_regex.newLocal(isolate);
v8::Local<v8::Function> exec = regex->Get(v8AtomicString(isolate, "exec")).As<v8::Function>();
-
- v8::Handle<v8::Value> argv[] = { v8String(context->GetIsolate(), string.substring(startFrom)) };
- v8::Local<v8::Value> returnValue = exec->Call(regex, 1, argv);
+ v8::Handle<v8::Value> argv[] = { v8String(isolate, string.substring(startFrom)) };
+ v8::Local<v8::Value> returnValue = V8ScriptRunner::callInternalFunction(exec, regex, WTF_ARRAY_LENGTH(argv), argv, isolate);
// RegExp#exec returns null if there's no match, otherwise it returns an
// Array of strings with the first being the whole match string and others
@@ -94,7 +89,6 @@
v8::Local<v8::Array> result = returnValue.As<v8::Array>();
int matchOffset = result->Get(v8AtomicString(isolate, "index"))->ToInt32()->Value();
-
if (matchLength) {
v8::Local<v8::String> match = result->Get(0).As<v8::String>();
*matchLength = match->Length();
diff --git a/Source/bindings/v8/ScriptState.cpp b/Source/bindings/v8/ScriptState.cpp
index 5ac5889..e25534a 100644
--- a/Source/bindings/v8/ScriptState.cpp
+++ b/Source/bindings/v8/ScriptState.cpp
@@ -34,8 +34,9 @@
#include "V8Window.h"
#include "V8WorkerGlobalScope.h"
#include "bindings/v8/ScriptController.h"
+#include "bindings/v8/V8HiddenValue.h"
#include "bindings/v8/WorkerScriptController.h"
-#include "core/frame/Frame.h"
+#include "core/frame/LocalFrame.h"
#include "core/workers/WorkerGlobalScope.h"
#include <v8.h>
#include "wtf/Assertions.h"
@@ -71,12 +72,12 @@
v8::Local<v8::Object> innerGlobal = v8::Local<v8::Object>::Cast(context->Global()->GetPrototype());
- v8::Local<v8::Value> scriptStateWrapper = getHiddenValue(context->GetIsolate(), innerGlobal, "scriptState");
+ v8::Local<v8::Value> scriptStateWrapper = V8HiddenValue::getHiddenValue(context->GetIsolate(), innerGlobal, V8HiddenValue::scriptState(context->GetIsolate()));
if (!scriptStateWrapper.IsEmpty() && scriptStateWrapper->IsExternal())
return static_cast<ScriptState*>(v8::External::Cast(*scriptStateWrapper)->Value());
ScriptState* scriptState = new ScriptState(context);
- setHiddenValue(context->GetIsolate(), innerGlobal, "scriptState", v8::External::New(context->GetIsolate(), scriptState));
+ V8HiddenValue::setHiddenValue(context->GetIsolate(), innerGlobal, V8HiddenValue::scriptState(context->GetIsolate()), v8::External::New(context->GetIsolate(), scriptState));
return scriptState;
}
@@ -106,7 +107,7 @@
return context()->AllowCodeGenerationFromStrings(enabled);
}
-ScriptState* mainWorldScriptState(Frame* frame)
+ScriptState* mainWorldScriptState(LocalFrame* frame)
{
v8::Isolate* isolate = toIsolate(frame);
v8::HandleScope handleScope(isolate);
diff --git a/Source/bindings/v8/ScriptState.h b/Source/bindings/v8/ScriptState.h
index 8885644..b2d03cc 100644
--- a/Source/bindings/v8/ScriptState.h
+++ b/Source/bindings/v8/ScriptState.h
@@ -32,7 +32,6 @@
#define ScriptState_h
#include "bindings/v8/ScopedPersistent.h"
-#include "bindings/v8/V8Utilities.h"
#include <v8.h>
#include "wtf/Noncopyable.h"
@@ -40,7 +39,7 @@
class DOMWindow;
class DOMWrapperWorld;
-class Frame;
+class LocalFrame;
class ExecutionContext;
class WorkerGlobalScope;
@@ -82,7 +81,7 @@
~ScriptState();
private:
- friend ScriptState* mainWorldScriptState(Frame*);
+ friend ScriptState* mainWorldScriptState(LocalFrame*);
explicit ScriptState(v8::Handle<v8::Context>);
static void setWeakCallback(const v8::WeakCallbackData<v8::Context, ScriptState>&);
@@ -115,7 +114,7 @@
ScopedPersistent<v8::Context> m_context;
};
-ScriptState* mainWorldScriptState(Frame*);
+ScriptState* mainWorldScriptState(LocalFrame*);
ScriptState* scriptStateFromWorkerGlobalScope(WorkerGlobalScope*);
diff --git a/Source/bindings/v8/ScriptValue.cpp b/Source/bindings/v8/ScriptValue.cpp
index 99a9c35..793f7ec 100644
--- a/Source/bindings/v8/ScriptValue.cpp
+++ b/Source/bindings/v8/ScriptValue.cpp
@@ -68,11 +68,11 @@
{
if (value.IsEmpty()) {
ASSERT_NOT_REACHED();
- return 0;
+ return nullptr;
}
if (!maxDepth)
- return 0;
+ return nullptr;
maxDepth--;
if (value->IsNull() || value->IsUndefined())
@@ -91,7 +91,7 @@
v8::Local<v8::Value> value = array->Get(v8::Int32::New(isolate, i));
RefPtr<JSONValue> element = v8ToJSONValue(value, maxDepth, isolate);
if (!element)
- return 0;
+ return nullptr;
inspectorArray->pushValue(element);
}
return inspectorArray;
@@ -108,14 +108,14 @@
continue;
RefPtr<JSONValue> propertyValue = v8ToJSONValue(object->Get(name), maxDepth, isolate);
if (!propertyValue)
- return 0;
- V8TRYCATCH_FOR_V8STRINGRESOURCE_RETURN(V8StringResource<WithNullCheck>, nameString, name, 0);
+ return nullptr;
+ V8TRYCATCH_FOR_V8STRINGRESOURCE_RETURN(V8StringResource<WithNullCheck>, nameString, name, nullptr);
jsonObject->setValue(nameString, propertyValue);
}
return jsonObject;
}
ASSERT_NOT_REACHED();
- return 0;
+ return nullptr;
}
PassRefPtr<JSONValue> ScriptValue::toJSONValue(ScriptState* scriptState) const
diff --git a/Source/bindings/v8/ScriptValue.h b/Source/bindings/v8/ScriptValue.h
index 124ea11..15f42b7 100644
--- a/Source/bindings/v8/ScriptValue.h
+++ b/Source/bindings/v8/ScriptValue.h
@@ -52,7 +52,7 @@
ScriptValue(v8::Handle<v8::Value> value, v8::Isolate* isolate)
: m_isolate(isolate)
- , m_value(value.IsEmpty() ? 0 : SharedPersistent<v8::Value>::create(value, isolate))
+ , m_value(value.IsEmpty() ? nullptr : SharedPersistent<v8::Value>::create(value, isolate))
{
}
@@ -151,7 +151,7 @@
void clear()
{
- m_value = 0;
+ m_value = nullptr;
}
v8::Handle<v8::Value> v8Value() const
diff --git a/Source/bindings/v8/ScriptWrappable.h b/Source/bindings/v8/ScriptWrappable.h
index 1fc27b4..27f1199 100644
--- a/Source/bindings/v8/ScriptWrappable.h
+++ b/Source/bindings/v8/ScriptWrappable.h
@@ -32,7 +32,6 @@
#define ScriptWrappable_h
#include "bindings/v8/UnsafePersistent.h"
-#include "bindings/v8/V8Utilities.h"
#include "bindings/v8/WrapperTypeInfo.h"
#include "heap/Handle.h"
#include <v8.h>
diff --git a/Source/bindings/v8/SerializedScriptValue.cpp b/Source/bindings/v8/SerializedScriptValue.cpp
index 24a156b..dac52fa 100644
--- a/Source/bindings/v8/SerializedScriptValue.cpp
+++ b/Source/bindings/v8/SerializedScriptValue.cpp
@@ -41,7 +41,7 @@
#include "bindings/v8/ScriptScope.h"
#include "bindings/v8/ScriptState.h"
#include "bindings/v8/V8Binding.h"
-#include "bindings/v8/V8Utilities.h"
+#include "bindings/v8/WorkerScriptController.h"
#include "bindings/v8/custom/V8ArrayBufferCustom.h"
#include "bindings/v8/custom/V8ArrayBufferViewCustom.h"
#include "bindings/v8/custom/V8DataViewCustom.h"
@@ -61,6 +61,7 @@
#include "core/fileapi/FileList.h"
#include "core/html/ImageData.h"
#include "core/html/canvas/DataView.h"
+#include "heap/Handle.h"
#include "platform/SharedBuffer.h"
#include "wtf/ArrayBuffer.h"
#include "wtf/ArrayBufferContents.h"
@@ -279,9 +280,8 @@
class Writer {
WTF_MAKE_NONCOPYABLE(Writer);
public:
- explicit Writer(v8::Isolate* isolate)
+ Writer()
: m_position(0)
- , m_isolate(isolate)
{
}
@@ -551,8 +551,6 @@
doWriteUint32(length);
}
- v8::Isolate* getIsolate() { return m_isolate; }
-
private:
void doWriteFile(const File& file)
{
@@ -682,7 +680,6 @@
Vector<BufferValueType> m_buffer;
unsigned m_position;
- v8::Isolate* m_isolate;
};
static v8::Handle<v8::Object> toV8Object(MessagePort* impl, v8::Isolate* isolate)
@@ -725,11 +722,11 @@
ASSERT(!tryCatch.HasCaught());
if (messagePorts) {
for (size_t i = 0; i < messagePorts->size(); i++)
- m_transferredMessagePorts.set(toV8Object(messagePorts->at(i).get(), m_writer.getIsolate()), i);
+ m_transferredMessagePorts.set(toV8Object(messagePorts->at(i).get(), isolate), i);
}
if (arrayBuffers) {
for (size_t i = 0; i < arrayBuffers->size(); i++) {
- v8::Handle<v8::Object> v8ArrayBuffer = toV8Object(arrayBuffers->at(i).get(), m_writer.getIsolate());
+ v8::Handle<v8::Object> v8ArrayBuffer = toV8Object(arrayBuffers->at(i).get(), isolate);
// Coalesce multiple occurences of the same buffer to the first index.
if (!m_transferredArrayBuffers.contains(v8ArrayBuffer))
m_transferredArrayBuffers.set(v8ArrayBuffer, i);
@@ -1055,13 +1052,16 @@
m_writer.writeBooleanObject(booleanObject->ValueOf());
}
- void writeBlob(v8::Handle<v8::Value> value)
+ StateBase* writeBlob(v8::Handle<v8::Value> value, StateBase* next)
{
Blob* blob = V8Blob::toNative(value.As<v8::Object>());
if (!blob)
- return;
+ return 0;
+ if (blob->hasBeenClosed())
+ return handleError(DataCloneError, "A Blob object has been closed, and could therefore not be cloned.", next);
m_writer.writeBlob(blob->uuid(), blob->type(), blob->size());
m_blobDataHandles.add(blob->uuid(), blob->blobDataHandle());
+ return 0;
}
StateBase* writeDOMFileSystem(v8::Handle<v8::Value> value, StateBase* next)
@@ -1075,13 +1075,16 @@
return 0;
}
- void writeFile(v8::Handle<v8::Value> value)
+ StateBase* writeFile(v8::Handle<v8::Value> value, StateBase* next)
{
File* file = V8File::toNative(value.As<v8::Object>());
if (!file)
- return;
+ return 0;
+ if (file->hasBeenClosed())
+ return handleError(DataCloneError, "A File object has been closed, and could therefore not be cloned.", next);
m_writer.writeFile(*file);
m_blobDataHandles.add(file->uuid(), file->blobDataHandle());
+ return 0;
}
void writeFileList(v8::Handle<v8::Value> value)
@@ -1118,7 +1121,7 @@
return 0;
if (!arrayBufferView->buffer())
return handleError(DataCloneError, "An ArrayBuffer could not be cloned.", next);
- v8::Handle<v8::Value> underlyingBuffer = toV8(arrayBufferView->buffer(), v8::Handle<v8::Object>(), m_writer.getIsolate());
+ v8::Handle<v8::Value> underlyingBuffer = toV8(arrayBufferView->buffer(), v8::Handle<v8::Object>(), m_isolate);
if (underlyingBuffer.IsEmpty())
return handleError(DataCloneError, "An ArrayBuffer could not be cloned.", next);
StateBase* stateOut = doSerializeArrayBuffer(underlyingBuffer, next);
@@ -1283,9 +1286,9 @@
else if (value->IsArray()) {
return startArrayState(value.As<v8::Array>(), next);
} else if (V8File::hasInstance(value, m_isolate))
- writeFile(value);
+ return writeFile(value, next);
else if (V8Blob::hasInstance(value, m_isolate))
- writeBlob(value);
+ return writeBlob(value, next);
else if (V8DOMFileSystem::hasInstance(value, m_isolate))
return writeDOMFileSystem(value, next);
else if (V8FileList::hasInstance(value, m_isolate))
@@ -1730,9 +1733,9 @@
{
uint32_t byteLength;
if (!doReadUint32(&byteLength))
- return 0;
+ return nullptr;
if (m_position + byteLength > m_length)
- return 0;
+ return nullptr;
const void* bufferStart = m_buffer + m_position;
RefPtr<ArrayBuffer> arrayBuffer = ArrayBuffer::create(bufferStart, byteLength);
arrayBuffer->setDeallocationObserver(V8ArrayBufferDeallocationObserver::instanceTemplate());
@@ -1858,7 +1861,7 @@
return false;
if (!doReadUint64(&size))
return false;
- RefPtr<Blob> blob = Blob::create(getOrCreateBlobDataHandle(uuid, type, size));
+ RefPtrWillBeRawPtr<Blob> blob = Blob::create(getOrCreateBlobDataHandle(uuid, type, size));
*value = toV8(blob.release(), v8::Handle<v8::Object>(), m_isolate);
return true;
}
@@ -1874,14 +1877,14 @@
return false;
if (!readWebCoreString(&url))
return false;
- RefPtr<DOMFileSystem> fs = DOMFileSystem::create(currentExecutionContext(m_isolate), name, static_cast<WebCore::FileSystemType>(type), KURL(ParsedURLString, url));
+ RefPtrWillBeRawPtr<DOMFileSystem> fs = DOMFileSystem::create(currentExecutionContext(m_isolate), 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)
{
- RefPtr<File> file = doReadFileHelper();
+ RefPtrWillBeRawPtr<File> file = doReadFileHelper();
if (!file)
return false;
*value = toV8(file.release(), v8::Handle<v8::Object>(), m_isolate);
@@ -1895,9 +1898,9 @@
uint32_t length;
if (!doReadUint32(&length))
return false;
- RefPtr<FileList> fileList = FileList::create();
+ RefPtrWillBeRawPtr<FileList> fileList = FileList::create();
for (unsigned i = 0; i < length; ++i) {
- RefPtr<File> file = doReadFileHelper();
+ RefPtrWillBeRawPtr<File> file = doReadFileHelper();
if (!file)
return false;
fileList->append(file.release());
@@ -1906,10 +1909,10 @@
return true;
}
- PassRefPtr<File> doReadFileHelper()
+ PassRefPtrWillBeRawPtr<File> doReadFileHelper()
{
if (m_version < 3)
- return 0;
+ return nullptr;
String path;
String name;
String relativePath;
@@ -1919,22 +1922,22 @@
uint64_t size = 0;
double lastModified = 0;
if (!readWebCoreString(&path))
- return 0;
+ return nullptr;
if (m_version >= 4 && !readWebCoreString(&name))
- return 0;
+ return nullptr;
if (m_version >= 4 && !readWebCoreString(&relativePath))
- return 0;
+ return nullptr;
if (!readWebCoreString(&uuid))
- return 0;
+ return nullptr;
if (!readWebCoreString(&type))
- return 0;
+ return nullptr;
if (m_version >= 4 && !doReadUint32(&hasSnapshot))
- return 0;
+ return nullptr;
if (hasSnapshot) {
if (!doReadUint64(&size))
- return 0;
+ return nullptr;
if (!doReadNumber(&lastModified))
- return 0;
+ return nullptr;
}
return File::create(path, name, relativePath, hasSnapshot > 0, size, lastModified, getOrCreateBlobDataHandle(uuid, type));
}
@@ -2283,7 +2286,7 @@
PassRefPtr<SerializedScriptValue> SerializedScriptValue::create(const String& data, v8::Isolate* isolate)
{
- Writer writer(isolate);
+ Writer writer;
writer.writeWebCoreString(data);
String wireData = writer.takeWireString();
return adoptRef(new SerializedScriptValue(wireData));
@@ -2296,12 +2299,7 @@
PassRefPtr<SerializedScriptValue> SerializedScriptValue::nullValue()
{
- return nullValue(v8::Isolate::GetCurrent());
-}
-
-PassRefPtr<SerializedScriptValue> SerializedScriptValue::nullValue(v8::Isolate* isolate)
-{
- Writer writer(isolate);
+ Writer writer;
writer.writeNull();
String wireData = writer.takeWireString();
return adoptRef(new SerializedScriptValue(wireData));
@@ -2331,12 +2329,21 @@
{
}
-inline void neuterBinding(ArrayBuffer* object)
+static void neuterArrayBufferInAllWorlds(ArrayBuffer* object)
{
v8::Isolate* isolate = v8::Isolate::GetCurrent();
- Vector<DOMDataStore*>& allStores = V8PerIsolateData::from(isolate)->allStores();
- for (size_t i = 0; i < allStores.size(); i++) {
- v8::Handle<v8::Object> wrapper = allStores[i]->get<V8ArrayBuffer>(object, isolate);
+ if (isMainThread()) {
+ Vector<RefPtr<DOMWrapperWorld> > worlds;
+ DOMWrapperWorld::allWorldsInMainThread(worlds);
+ for (size_t i = 0; i < worlds.size(); i++) {
+ v8::Handle<v8::Object> wrapper = worlds[i]->domDataStore().get<V8ArrayBuffer>(object, isolate);
+ if (!wrapper.IsEmpty()) {
+ ASSERT(wrapper->IsArrayBuffer());
+ v8::Handle<v8::ArrayBuffer>::Cast(wrapper)->Neuter();
+ }
+ }
+ } else {
+ v8::Handle<v8::Object> wrapper = DOMWrapperWorld::current(isolate)->domDataStore().get<V8ArrayBuffer>(object, isolate);
if (!wrapper.IsEmpty()) {
ASSERT(wrapper->IsArrayBuffer());
v8::Handle<v8::ArrayBuffer>::Cast(wrapper)->Neuter();
@@ -2369,7 +2376,7 @@
return nullptr;
}
- neuterBinding(arrayBuffers[i].get());
+ neuterArrayBufferInAllWorlds(arrayBuffers[i].get());
}
return contents.release();
}
@@ -2377,7 +2384,7 @@
SerializedScriptValue::SerializedScriptValue(v8::Handle<v8::Value> value, MessagePortArray* messagePorts, ArrayBufferArray* arrayBuffers, ExceptionState& exceptionState, v8::Isolate* isolate)
: m_externallyAllocatedMemory(0)
{
- Writer writer(isolate);
+ Writer writer;
Serializer::Status status;
String errorMessage;
{
@@ -2439,6 +2446,57 @@
return deserializer.deserialize();
}
+bool SerializedScriptValue::extractTransferables(v8::Local<v8::Value> value, int argumentIndex, MessagePortArray& ports, ArrayBufferArray& arrayBuffers, ExceptionState& exceptionState, v8::Isolate* isolate)
+{
+ if (isUndefinedOrNull(value)) {
+ ports.resize(0);
+ arrayBuffers.resize(0);
+ return true;
+ }
+
+ uint32_t length = 0;
+ if (value->IsArray()) {
+ v8::Local<v8::Array> array = v8::Local<v8::Array>::Cast(value);
+ length = array->Length();
+ } else if (toV8Sequence(value, length, isolate).IsEmpty()) {
+ exceptionState.throwTypeError(ExceptionMessages::notAnArrayTypeArgumentOrValue(argumentIndex + 1));
+ return false;
+ }
+
+ v8::Local<v8::Object> transferrables = v8::Local<v8::Object>::Cast(value);
+
+ // Validate the passed array of transferrables.
+ for (unsigned i = 0; i < length; ++i) {
+ v8::Local<v8::Value> transferrable = transferrables->Get(i);
+ // Validation of non-null objects, per HTML5 spec 10.3.3.
+ if (isUndefinedOrNull(transferrable)) {
+ exceptionState.throwDOMException(DataCloneError, "Value at index " + String::number(i) + " is an untransferable " + (transferrable->IsUndefined() ? "'undefined'" : "'null'") + " value.");
+ return false;
+ }
+ // Validation of Objects implementing an interface, per WebIDL spec 4.1.15.
+ if (V8MessagePort::hasInstance(transferrable, isolate)) {
+ RefPtr<MessagePort> port = V8MessagePort::toNative(v8::Handle<v8::Object>::Cast(transferrable));
+ // Check for duplicate MessagePorts.
+ if (ports.contains(port)) {
+ exceptionState.throwDOMException(DataCloneError, "Message port at index " + String::number(i) + " is a duplicate of an earlier port.");
+ return false;
+ }
+ ports.append(port.release());
+ } else if (V8ArrayBuffer::hasInstance(transferrable, isolate)) {
+ RefPtr<ArrayBuffer> arrayBuffer = V8ArrayBuffer::toNative(v8::Handle<v8::Object>::Cast(transferrable));
+ if (arrayBuffers.contains(arrayBuffer)) {
+ exceptionState.throwDOMException(DataCloneError, "ArrayBuffer at index " + String::number(i) + " is a duplicate of an earlier ArrayBuffer.");
+ return false;
+ }
+ arrayBuffers.append(arrayBuffer.release());
+ } else {
+ exceptionState.throwDOMException(DataCloneError, "Value at index " + String::number(i) + " does not have a transferable type.");
+ return false;
+ }
+ }
+ return true;
+}
+
void SerializedScriptValue::registerMemoryAllocatedWithCurrentScriptContext()
{
if (m_externallyAllocatedMemory)
diff --git a/Source/bindings/v8/SerializedScriptValue.h b/Source/bindings/v8/SerializedScriptValue.h
index a5324a9..9113e2b 100644
--- a/Source/bindings/v8/SerializedScriptValue.h
+++ b/Source/bindings/v8/SerializedScriptValue.h
@@ -82,7 +82,6 @@
static PassRefPtr<SerializedScriptValue> createAndSwallowExceptions(v8::Handle<v8::Value>, v8::Isolate*);
static PassRefPtr<SerializedScriptValue> nullValue();
- static PassRefPtr<SerializedScriptValue> nullValue(v8::Isolate*);
String toWireString() const { return m_data; }
void toWireBytes(Vector<char>&) const;
@@ -92,6 +91,12 @@
v8::Handle<v8::Value> deserialize(MessagePortArray* = 0);
v8::Handle<v8::Value> deserialize(v8::Isolate*, MessagePortArray* = 0);
+ // Helper function which pulls the values out of a JS sequence and into a MessagePortArray.
+ // Also validates the elements per sections 4.1.13 and 4.1.15 of the WebIDL spec and section 8.3.3
+ // of the HTML5 spec and generates exceptions as appropriate.
+ // Returns true if the array was filled, or false if the passed value was not of an appropriate type.
+ static bool extractTransferables(v8::Local<v8::Value>, int, MessagePortArray&, ArrayBufferArray&, ExceptionState&, v8::Isolate*);
+
// 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(); }
diff --git a/Source/bindings/v8/V8AbstractEventListener.cpp b/Source/bindings/v8/V8AbstractEventListener.cpp
index 93134d5..a5370e6 100644
--- a/Source/bindings/v8/V8AbstractEventListener.cpp
+++ b/Source/bindings/v8/V8AbstractEventListener.cpp
@@ -35,6 +35,7 @@
#include "V8EventTarget.h"
#include "bindings/v8/V8Binding.h"
#include "bindings/v8/V8EventListenerList.h"
+#include "bindings/v8/V8HiddenValue.h"
#include "core/events/BeforeUnloadEvent.h"
#include "core/events/Event.h"
#include "core/events/ThreadLocalEventNames.h"
@@ -43,7 +44,7 @@
namespace WebCore {
-V8AbstractEventListener::V8AbstractEventListener(bool isAttribute, PassRefPtr<DOMWrapperWorld> world, v8::Isolate* isolate)
+V8AbstractEventListener::V8AbstractEventListener(bool isAttribute, DOMWrapperWorld* world, v8::Isolate* isolate)
: EventListener(JSEventListenerType)
, m_isAttribute(isAttribute)
, m_world(world)
@@ -107,22 +108,20 @@
v8::Local<v8::Context> v8Context = toV8Context(context, world());
if (v8Context.IsEmpty())
return;
+ v8::Isolate* isolate = v8Context->GetIsolate();
- // We push the event being processed into the global object, so that it can be exposed by DOMWindow's bindings.
- v8::Handle<v8::String> eventSymbol = v8AtomicString(v8Context->GetIsolate(), "event");
v8::Local<v8::Value> returnValue;
-
{
// Catch exceptions thrown in the event handler so they do not propagate to javascript code that caused the event to fire.
v8::TryCatch tryCatch;
tryCatch.SetVerbose(true);
// Save the old 'event' property so we can restore it later.
- v8::Local<v8::Value> savedEvent = getHiddenValue(v8Context->GetIsolate(), v8Context->Global(), eventSymbol);
+ v8::Local<v8::Value> savedEvent = V8HiddenValue::getHiddenValue(v8Context->GetIsolate(), v8Context->Global(), V8HiddenValue::event(isolate));
tryCatch.Reset();
// Make the event available in the global object, so DOMWindow can expose it.
- setHiddenValue(v8Context->GetIsolate(), v8Context->Global(), eventSymbol, jsEvent);
+ V8HiddenValue::setHiddenValue(v8Context->GetIsolate(), v8Context->Global(), V8HiddenValue::event(isolate), jsEvent);
tryCatch.Reset();
returnValue = callListenerFunction(context, jsEvent, event);
@@ -138,14 +137,12 @@
// Restore the old event. This must be done for all exit paths through this method.
if (savedEvent.IsEmpty())
- setHiddenValue(v8Context->GetIsolate(), v8Context->Global(), eventSymbol, v8::Undefined(v8Context->GetIsolate()));
+ V8HiddenValue::setHiddenValue(v8Context->GetIsolate(), v8Context->Global(), V8HiddenValue::event(isolate), v8::Undefined(v8Context->GetIsolate()));
else
- setHiddenValue(v8Context->GetIsolate(), v8Context->Global(), eventSymbol, savedEvent);
+ V8HiddenValue::setHiddenValue(v8Context->GetIsolate(), v8Context->Global(), V8HiddenValue::event(isolate), savedEvent);
tryCatch.Reset();
}
- ASSERT(!handleOutOfMemory() || returnValue.IsEmpty());
-
if (returnValue.IsEmpty())
return;
diff --git a/Source/bindings/v8/V8AbstractEventListener.h b/Source/bindings/v8/V8AbstractEventListener.h
index 8520a9c..37b1542 100644
--- a/Source/bindings/v8/V8AbstractEventListener.h
+++ b/Source/bindings/v8/V8AbstractEventListener.h
@@ -33,7 +33,6 @@
#include "bindings/v8/DOMWrapperWorld.h"
#include "bindings/v8/ScopedPersistent.h"
-#include "bindings/v8/V8Utilities.h"
#include "core/events/EventListener.h"
#include <v8.h>
#include "wtf/PassRefPtr.h"
@@ -114,7 +113,7 @@
v8::Isolate* isolate() const { return m_isolate; }
protected:
- V8AbstractEventListener(bool isAttribute, PassRefPtr<DOMWrapperWorld>, v8::Isolate*);
+ V8AbstractEventListener(bool isAttribute, DOMWrapperWorld*, v8::Isolate*);
virtual void prepareListenerObject(ExecutionContext*) { }
diff --git a/Source/bindings/v8/V8Binding.cpp b/Source/bindings/v8/V8Binding.cpp
index 29ecfad..84d5c1e 100644
--- a/Source/bindings/v8/V8Binding.cpp
+++ b/Source/bindings/v8/V8Binding.cpp
@@ -47,11 +47,11 @@
#include "core/dom/Element.h"
#include "core/dom/NodeFilter.h"
#include "core/dom/QualifiedName.h"
+#include "core/frame/LocalFrame.h"
+#include "core/frame/Settings.h"
#include "core/inspector/BindingVisitors.h"
#include "core/loader/FrameLoader.h"
#include "core/loader/FrameLoaderClient.h"
-#include "core/frame/Frame.h"
-#include "core/frame/Settings.h"
#include "core/workers/WorkerGlobalScope.h"
#include "core/xml/XPathNSResolver.h"
#include "wtf/ArrayBufferContents.h"
@@ -67,17 +67,6 @@
namespace WebCore {
-v8::Handle<v8::Value> setDOMException(int exceptionCode, v8::Isolate* isolate)
-{
- // FIXME: pass in an ExceptionState instead for better creationContext.
- return V8ThrowException::throwDOMException(exceptionCode, v8::Handle<v8::Object>(), isolate);
-}
-
-v8::Handle<v8::Value> setDOMException(int exceptionCode, const String& message, v8::Isolate* isolate)
-{
- return V8ThrowException::throwDOMException(exceptionCode, message, v8::Handle<v8::Object>(), isolate);
-}
-
v8::Handle<v8::Value> throwError(V8ErrorType errorType, const String& message, v8::Isolate* isolate)
{
return V8ThrowException::throwError(errorType, message, isolate);
@@ -469,9 +458,9 @@
return numberObject->NumberValue();
}
-PassRefPtr<XPathNSResolver> toXPathNSResolver(v8::Handle<v8::Value> value, v8::Isolate* isolate)
+PassRefPtrWillBeRawPtr<XPathNSResolver> toXPathNSResolver(v8::Handle<v8::Value> value, v8::Isolate* isolate)
{
- RefPtr<XPathNSResolver> resolver;
+ RefPtrWillBeRawPtr<XPathNSResolver> resolver;
if (V8XPathNSResolver::hasInstance(value, isolate))
resolver = V8XPathNSResolver::toNative(v8::Handle<v8::Object>::Cast(value));
else if (value->IsObject())
@@ -484,11 +473,7 @@
if (value.IsEmpty() || !value->IsObject())
return 0;
- v8::Handle<v8::Object> global = v8::Handle<v8::Object>::Cast(value);
- v8::Handle<v8::Object> windowWrapper = global->FindInstanceInPrototypeChain(V8Window::domTemplate(isolate, MainWorld));
- if (!windowWrapper.IsEmpty())
- return V8Window::toNative(windowWrapper);
- windowWrapper = global->FindInstanceInPrototypeChain(V8Window::domTemplate(isolate, IsolatedWorld));
+ v8::Handle<v8::Object> windowWrapper = V8Window::findInstanceInPrototypeChain(v8::Handle<v8::Object>::Cast(value), isolate);
if (!windowWrapper.IsEmpty())
return V8Window::toNative(windowWrapper);
return 0;
@@ -496,26 +481,22 @@
DOMWindow* toDOMWindow(v8::Handle<v8::Context> context)
{
+ if (context.IsEmpty())
+ return 0;
return toDOMWindow(context->Global(), context->GetIsolate());
}
-ExecutionContext* toExecutionContext(v8::Handle<v8::Context> context)
+DOMWindow* enteredDOMWindow(v8::Isolate* isolate)
{
- v8::Handle<v8::Object> global = context->Global();
- v8::Handle<v8::Object> windowWrapper = global->FindInstanceInPrototypeChain(V8Window::domTemplate(context->GetIsolate(), MainWorld));
- if (!windowWrapper.IsEmpty())
- return V8Window::toNative(windowWrapper)->executionContext();
- windowWrapper = global->FindInstanceInPrototypeChain(V8Window::domTemplate(context->GetIsolate(), IsolatedWorld));
- if (!windowWrapper.IsEmpty())
- return V8Window::toNative(windowWrapper)->executionContext();
- v8::Handle<v8::Object> workerWrapper = global->FindInstanceInPrototypeChain(V8WorkerGlobalScope::domTemplate(context->GetIsolate(), WorkerWorld));
- if (!workerWrapper.IsEmpty())
- return V8WorkerGlobalScope::toNative(workerWrapper)->executionContext();
- // FIXME: Is this line of code reachable?
- return 0;
+ return toDOMWindow(isolate->GetEnteredContext());
}
-DOMWindow* activeDOMWindow(v8::Isolate* isolate)
+DOMWindow* currentDOMWindow(v8::Isolate* isolate)
+{
+ return toDOMWindow(isolate->GetCurrentContext());
+}
+
+DOMWindow* callingDOMWindow(v8::Isolate* isolate)
{
v8::Handle<v8::Context> context = isolate->GetCallingContext();
if (context.IsEmpty()) {
@@ -527,7 +508,25 @@
return toDOMWindow(context);
}
-ExecutionContext* activeExecutionContext(v8::Isolate* isolate)
+ExecutionContext* toExecutionContext(v8::Handle<v8::Context> context)
+{
+ v8::Handle<v8::Object> global = context->Global();
+ v8::Handle<v8::Object> windowWrapper = V8Window::findInstanceInPrototypeChain(global, context->GetIsolate());
+ if (!windowWrapper.IsEmpty())
+ return V8Window::toNative(windowWrapper)->executionContext();
+ v8::Handle<v8::Object> workerWrapper = V8WorkerGlobalScope::findInstanceInPrototypeChain(global, context->GetIsolate());
+ if (!workerWrapper.IsEmpty())
+ return V8WorkerGlobalScope::toNative(workerWrapper)->executionContext();
+ // FIXME: Is this line of code reachable?
+ return 0;
+}
+
+ExecutionContext* currentExecutionContext(v8::Isolate* isolate)
+{
+ return toExecutionContext(isolate->GetCurrentContext());
+}
+
+ExecutionContext* callingExecutionContext(v8::Isolate* isolate)
{
v8::Handle<v8::Context> context = isolate->GetCallingContext();
if (context.IsEmpty()) {
@@ -539,29 +538,12 @@
return toExecutionContext(context);
}
-DOMWindow* firstDOMWindow(v8::Isolate* isolate)
-{
- return toDOMWindow(isolate->GetEnteredContext());
-}
-
-Document* currentDocument(v8::Isolate* isolate)
-{
- return toDOMWindow(isolate->GetCurrentContext())->document();
-}
-
-ExecutionContext* currentExecutionContext(v8::Isolate* isolate)
-{
- if (WorkerScriptController* controller = WorkerScriptController::controllerForContext(isolate))
- return &controller->workerGlobalScope();
- return currentDocument(isolate);
-}
-
-Frame* toFrameIfNotDetached(v8::Handle<v8::Context> context)
+LocalFrame* toFrameIfNotDetached(v8::Handle<v8::Context> context)
{
DOMWindow* window = toDOMWindow(context);
if (window && window->isCurrentlyDisplayedInFrame())
return window->frame();
- // We return 0 here because |context| is detached from the Frame. If we
+ // We return 0 here because |context| is detached from the LocalFrame. If we
// did return |frame| we could get in trouble because the frame could be
// navigated to another security origin.
return 0;
@@ -571,49 +553,26 @@
{
ASSERT(context);
if (context->isDocument()) {
- ASSERT(world);
- if (Frame* frame = toDocument(context)->frame())
+ if (LocalFrame* frame = toDocument(context)->frame())
return frame->script().windowShell(world)->context();
} else if (context->isWorkerGlobalScope()) {
- ASSERT(!world);
if (WorkerScriptController* script = toWorkerGlobalScope(context)->script())
return script->context();
}
return v8::Local<v8::Context>();
}
-v8::Local<v8::Context> toV8Context(v8::Isolate* isolate, Frame* frame, DOMWrapperWorld* world)
+v8::Local<v8::Context> toV8Context(v8::Isolate* isolate, LocalFrame* frame, DOMWrapperWorld* world)
{
if (!frame)
return v8::Local<v8::Context>();
v8::Local<v8::Context> context = frame->script().windowShell(world)->context();
if (context.IsEmpty())
return v8::Local<v8::Context>();
- Frame* attachedFrame= toFrameIfNotDetached(context);
+ LocalFrame* attachedFrame= toFrameIfNotDetached(context);
return frame == attachedFrame ? context : v8::Local<v8::Context>();
}
-bool handleOutOfMemory()
-{
- v8::Local<v8::Context> context = v8::Isolate::GetCurrent()->GetCurrentContext();
-
- if (!context->HasOutOfMemoryException())
- return false;
-
- // Warning, error, disable JS for this frame?
- Frame* frame = toFrameIfNotDetached(context);
- if (!frame)
- return true;
-
- frame->script().clearForOutOfMemory();
- frame->loader().client()->didExhaustMemoryAvailableForScript();
-
- if (Settings* settings = frame->settings())
- settings->setScriptEnabled(false);
-
- return true;
-}
-
v8::Local<v8::Value> handleMaxRecursionDepthExceeded(v8::Isolate* isolate)
{
throwError(v8RangeError, "Maximum call stack size exceeded.", isolate);
@@ -629,72 +588,12 @@
}
}
-WrapperWorldType worldType(v8::Isolate* isolate)
-{
- V8PerIsolateData* data = V8PerIsolateData::from(isolate);
- if (data->isMainThread())
- return worldTypeInMainThread(isolate);
- return WorkerWorld;
-}
-
-WrapperWorldType worldTypeInMainThread(v8::Isolate* isolate)
-{
- if (!DOMWrapperWorld::isolatedWorldsExist())
- return MainWorld;
- ASSERT(!isolate->GetEnteredContext().IsEmpty());
- DOMWrapperWorld* world = DOMWrapperWorld::world(isolate->GetEnteredContext());
- if (world->isMainWorld())
- return MainWorld;
- return IsolatedWorld;
-}
-
v8::Handle<v8::Function> getBoundFunction(v8::Handle<v8::Function> function)
{
v8::Handle<v8::Value> boundFunction = function->GetBoundFunction();
return boundFunction->IsFunction() ? v8::Handle<v8::Function>::Cast(boundFunction) : function;
}
-v8::Local<v8::Value> getHiddenValue(v8::Isolate* isolate, v8::Handle<v8::Object> object, const char* key)
-{
- return getHiddenValue(isolate, object, v8AtomicString(isolate, key));
-}
-
-v8::Local<v8::Value> getHiddenValue(v8::Isolate* isolate, v8::Handle<v8::Object> object, v8::Handle<v8::String> key)
-{
- return object->GetHiddenValue(key);
-}
-
-bool setHiddenValue(v8::Isolate* isolate, v8::Handle<v8::Object> object, const char* key, v8::Handle<v8::Value> value)
-{
- return setHiddenValue(isolate, object, v8AtomicString(isolate, key), value);
-}
-
-bool setHiddenValue(v8::Isolate* isolate, v8::Handle<v8::Object> object, v8::Handle<v8::String> key, v8::Handle<v8::Value> value)
-{
- return object->SetHiddenValue(key, value);
-}
-
-bool deleteHiddenValue(v8::Isolate* isolate, v8::Handle<v8::Object> object, const char* key)
-{
- return deleteHiddenValue(isolate, object, v8AtomicString(isolate, key));
-}
-
-bool deleteHiddenValue(v8::Isolate* isolate, v8::Handle<v8::Object> object, v8::Handle<v8::String> key)
-{
- return object->DeleteHiddenValue(key);
-}
-
-v8::Local<v8::Value> getHiddenValueFromMainWorldWrapper(v8::Isolate* isolate, ScriptWrappable* wrappable, const char* key)
-{
- return getHiddenValueFromMainWorldWrapper(isolate, wrappable, v8AtomicString(isolate, key));
-}
-
-v8::Local<v8::Value> getHiddenValueFromMainWorldWrapper(v8::Isolate* isolate, ScriptWrappable* wrappable, v8::Handle<v8::String> key)
-{
- v8::Local<v8::Object> wrapper = wrappable->newLocalWrapper(isolate);
- return wrapper.IsEmpty() ? v8::Local<v8::Value>() : getHiddenValue(isolate, wrapper, key);
-}
-
void addHiddenValueToArray(v8::Handle<v8::Object> object, v8::Local<v8::Value> value, int arrayIndex, v8::Isolate* isolate)
{
v8::Local<v8::Value> arrayValue = object->GetInternalField(arrayIndex);
@@ -744,10 +643,24 @@
return v8::Isolate::GetCurrent();
}
-v8::Isolate* toIsolate(Frame* frame)
+v8::Isolate* toIsolate(LocalFrame* frame)
{
ASSERT(frame);
return frame->script().isolate();
}
+PassOwnPtr<V8ExecutionScope> V8ExecutionScope::create(v8::Isolate* isolate)
+{
+ return adoptPtr(new V8ExecutionScope(isolate));
+}
+
+V8ExecutionScope::V8ExecutionScope(v8::Isolate* isolate)
+ : m_handleScope(isolate)
+ , m_context(v8::Context::New(isolate))
+ , m_contextScope(m_context)
+ , m_world(DOMWrapperWorld::create())
+ , m_perContextData(V8PerContextData::create(m_context, m_world))
+{
+}
+
} // namespace WebCore
diff --git a/Source/bindings/v8/V8Binding.h b/Source/bindings/v8/V8Binding.h
index a3ab104..1d2d7ce 100644
--- a/Source/bindings/v8/V8Binding.h
+++ b/Source/bindings/v8/V8Binding.h
@@ -46,678 +46,702 @@
namespace WebCore {
- class DOMWindow;
- class Document;
- class EventListener;
- class ExceptionState;
- class Frame;
- class NodeFilter;
- class ExecutionContext;
- class ScriptWrappable;
- class XPathNSResolver;
+class DOMWindow;
+class Document;
+class EventListener;
+class ExecutionContext;
+class ExceptionState;
+class LocalFrame;
+class NodeFilter;
+class ScriptWrappable;
+class V8PerContextData;
+class XPathNSResolver;
- const int kMaxRecursionDepth = 22;
+const int kMaxRecursionDepth = 22;
- // Schedule a DOM exception to be thrown, if the exception code is different
- // from zero.
- v8::Handle<v8::Value> setDOMException(int, v8::Isolate*);
- v8::Handle<v8::Value> setDOMException(int, const String&, v8::Isolate*);
+// Schedule a JavaScript error to be thrown.
+v8::Handle<v8::Value> throwError(V8ErrorType, const String&, v8::Isolate*);
- // Schedule a JavaScript error to be thrown.
- v8::Handle<v8::Value> throwError(V8ErrorType, const String&, v8::Isolate*);
+// Schedule a JavaScript error to be thrown.
+v8::Handle<v8::Value> throwError(v8::Handle<v8::Value>, v8::Isolate*);
- // Schedule a JavaScript error to be thrown.
- v8::Handle<v8::Value> throwError(v8::Handle<v8::Value>, v8::Isolate*);
+// A helper for throwing JavaScript TypeError.
+v8::Handle<v8::Value> throwTypeError(const String&, v8::Isolate*);
- // A helper for throwing JavaScript TypeError.
- v8::Handle<v8::Value> throwTypeError(const String&, v8::Isolate*);
+v8::ArrayBuffer::Allocator* v8ArrayBufferAllocator();
- v8::ArrayBuffer::Allocator* v8ArrayBufferAllocator();
+inline v8::Handle<v8::Value> argumentOrNull(const v8::FunctionCallbackInfo<v8::Value>& info, int index)
+{
+ return index >= info.Length() ? v8::Local<v8::Value>() : info[index];
+}
- inline v8::Handle<v8::Value> argumentOrNull(const v8::FunctionCallbackInfo<v8::Value>& info, int index)
- {
- return index >= info.Length() ? v8::Local<v8::Value>() : info[index];
+template<typename CallbackInfo, typename V>
+inline void v8SetReturnValue(const CallbackInfo& info, V v)
+{
+ info.GetReturnValue().Set(v);
+}
+
+template<typename CallbackInfo>
+inline void v8SetReturnValueBool(const CallbackInfo& info, bool v)
+{
+ info.GetReturnValue().Set(v);
+}
+
+template<typename CallbackInfo>
+inline void v8SetReturnValueInt(const CallbackInfo& info, int v)
+{
+ info.GetReturnValue().Set(v);
+}
+
+template<typename CallbackInfo>
+inline void v8SetReturnValueUnsigned(const CallbackInfo& info, unsigned v)
+{
+ info.GetReturnValue().Set(v);
+}
+
+template<typename CallbackInfo>
+inline void v8SetReturnValueNull(const CallbackInfo& info)
+{
+ info.GetReturnValue().SetNull();
+}
+
+template<typename CallbackInfo>
+inline void v8SetReturnValueUndefined(const CallbackInfo& info)
+{
+ info.GetReturnValue().SetUndefined();
+}
+
+template<typename CallbackInfo>
+inline void v8SetReturnValueEmptyString(const CallbackInfo& info)
+{
+ info.GetReturnValue().SetEmptyString();
+}
+
+template <class CallbackInfo>
+inline void v8SetReturnValueString(const CallbackInfo& info, const String& string, v8::Isolate* isolate)
+{
+ if (string.isNull()) {
+ v8SetReturnValueEmptyString(info);
+ return;
}
+ V8PerIsolateData::from(isolate)->stringCache()->setReturnValueFromString(info.GetReturnValue(), string.impl());
+}
- template<typename CallbackInfo, typename V>
- inline void v8SetReturnValue(const CallbackInfo& info, V v)
- {
- info.GetReturnValue().Set(v);
+template <class CallbackInfo>
+inline void v8SetReturnValueStringOrNull(const CallbackInfo& info, const String& string, v8::Isolate* isolate)
+{
+ if (string.isNull()) {
+ v8SetReturnValueNull(info);
+ return;
}
+ V8PerIsolateData::from(isolate)->stringCache()->setReturnValueFromString(info.GetReturnValue(), string.impl());
+}
- template<typename CallbackInfo>
- inline void v8SetReturnValueBool(const CallbackInfo& info, bool v)
- {
- info.GetReturnValue().Set(v);
+template <class CallbackInfo>
+inline void v8SetReturnValueStringOrUndefined(const CallbackInfo& info, const String& string, v8::Isolate* isolate)
+{
+ if (string.isNull()) {
+ v8SetReturnValueUndefined(info);
+ return;
}
+ V8PerIsolateData::from(isolate)->stringCache()->setReturnValueFromString(info.GetReturnValue(), string.impl());
+}
- template<typename CallbackInfo>
- inline void v8SetReturnValueInt(const CallbackInfo& info, int v)
+// Convert v8::String to a WTF::String. If the V8 string is not already
+// an external string then it is transformed into an external string at this
+// point to avoid repeated conversions.
+inline String toCoreString(v8::Handle<v8::String> value)
+{
+ return v8StringToWebCoreString<String>(value, Externalize);
+}
+
+inline String toCoreStringWithNullCheck(v8::Handle<v8::String> value)
+{
+ if (value.IsEmpty() || value->IsNull())
+ return String();
+ return toCoreString(value);
+}
+
+inline String toCoreStringWithUndefinedOrNullCheck(v8::Handle<v8::String> value)
+{
+ if (value.IsEmpty() || value->IsNull() || value->IsUndefined())
+ return String();
+ return toCoreString(value);
+}
+
+inline AtomicString toCoreAtomicString(v8::Handle<v8::String> value)
+{
+ return v8StringToWebCoreString<AtomicString>(value, Externalize);
+}
+
+// This method will return a null String if the v8::Value does not contain a v8::String.
+// It will not call ToString() on the v8::Value. If you want ToString() to be called,
+// please use the V8TRYCATCH_FOR_V8STRINGRESOURCE_*() macros instead.
+inline String toCoreStringWithUndefinedOrNullCheck(v8::Handle<v8::Value> value)
+{
+ if (value.IsEmpty() || !value->IsString())
+ return String();
+ return toCoreString(value.As<v8::String>());
+}
+
+// Convert a string to a V8 string.
+// Return a V8 external string that shares the underlying buffer with the given
+// WebCore string. The reference counting mechanism is used to keep the
+// underlying buffer alive while the string is still live in the V8 engine.
+inline v8::Handle<v8::String> v8String(v8::Isolate* isolate, const String& string)
+{
+ if (string.isNull())
+ return v8::String::Empty(isolate);
+ return V8PerIsolateData::from(isolate)->stringCache()->v8ExternalString(string.impl(), isolate);
+}
+
+inline v8::Handle<v8::String> v8AtomicString(v8::Isolate* isolate, const char* str)
+{
+ ASSERT(isolate);
+ return v8::String::NewFromUtf8(isolate, str, v8::String::kInternalizedString, strlen(str));
+}
+
+inline v8::Handle<v8::String> v8AtomicString(v8::Isolate* isolate, const char* str, size_t length)
+{
+ ASSERT(isolate);
+ return v8::String::NewFromUtf8(isolate, str, v8::String::kInternalizedString, length);
+}
+
+inline v8::Handle<v8::Value> v8Undefined()
+{
+ return v8::Handle<v8::Value>();
+}
+
+template <class T>
+struct V8ValueTraits {
+ static inline v8::Handle<v8::Value> arrayV8Value(const T& value, v8::Isolate* isolate)
{
- info.GetReturnValue().Set(v);
+ return toV8(WTF::getPtr(value), v8::Handle<v8::Object>(), isolate);
}
+};
- template<typename CallbackInfo>
- inline void v8SetReturnValueUnsigned(const CallbackInfo& info, unsigned v)
+template<>
+struct V8ValueTraits<String> {
+ static inline v8::Handle<v8::Value> arrayV8Value(const String& value, v8::Isolate* isolate)
{
- info.GetReturnValue().Set(v);
+ return v8String(isolate, value);
}
+};
- template<typename CallbackInfo>
- inline void v8SetReturnValueNull(const CallbackInfo& info)
+template<>
+struct V8ValueTraits<AtomicString> {
+ static inline v8::Handle<v8::Value> arrayV8Value(const AtomicString& value, v8::Isolate* isolate)
{
- info.GetReturnValue().SetNull();
+ return v8String(isolate, value);
}
+};
- template<typename CallbackInfo>
- inline void v8SetReturnValueUndefined(const CallbackInfo& info)
+template<>
+struct V8ValueTraits<unsigned> {
+ static inline v8::Handle<v8::Value> arrayV8Value(const unsigned& value, v8::Isolate* isolate)
{
- info.GetReturnValue().SetUndefined();
+ return v8::Integer::NewFromUnsigned(isolate, value);
}
+};
- template<typename CallbackInfo>
- inline void v8SetReturnValueEmptyString(const CallbackInfo& info)
+template<>
+struct V8ValueTraits<unsigned long> {
+ static inline v8::Handle<v8::Value> arrayV8Value(const unsigned long& value, v8::Isolate* isolate)
{
- info.GetReturnValue().SetEmptyString();
+ return v8::Integer::NewFromUnsigned(isolate, value);
}
+};
- template <class CallbackInfo>
- inline void v8SetReturnValueString(const CallbackInfo& info, const String& string, v8::Isolate* isolate)
+template<>
+struct V8ValueTraits<float> {
+ static inline v8::Handle<v8::Value> arrayV8Value(const float& value, v8::Isolate* isolate)
{
- if (string.isNull()) {
- v8SetReturnValueEmptyString(info);
- return;
- }
- V8PerIsolateData::from(isolate)->stringCache()->setReturnValueFromString(info.GetReturnValue(), string.impl());
+ return v8::Number::New(isolate, value);
}
+};
- template <class CallbackInfo>
- inline void v8SetReturnValueStringOrNull(const CallbackInfo& info, const String& string, v8::Isolate* isolate)
+template<>
+struct V8ValueTraits<double> {
+ static inline v8::Handle<v8::Value> arrayV8Value(const double& value, v8::Isolate* isolate)
{
- if (string.isNull()) {
- v8SetReturnValueNull(info);
- return;
- }
- V8PerIsolateData::from(isolate)->stringCache()->setReturnValueFromString(info.GetReturnValue(), string.impl());
+ return v8::Number::New(isolate, value);
}
+};
- template <class CallbackInfo>
- inline void v8SetReturnValueStringOrUndefined(const CallbackInfo& info, const String& string, v8::Isolate* isolate)
+template<typename T, size_t inlineCapacity>
+v8::Handle<v8::Value> v8Array(const Vector<T, inlineCapacity>& iterator, v8::Isolate* isolate)
+{
+ v8::Local<v8::Array> result = v8::Array::New(isolate, iterator.size());
+ int index = 0;
+ typename Vector<T, inlineCapacity>::const_iterator end = iterator.end();
+ typedef V8ValueTraits<T> TraitsType;
+ for (typename Vector<T, inlineCapacity>::const_iterator iter = iterator.begin(); iter != end; ++iter)
+ result->Set(v8::Integer::New(isolate, index++), TraitsType::arrayV8Value(*iter, isolate));
+ return result;
+}
+
+template<typename T, size_t inlineCapacity>
+v8::Handle<v8::Value> v8Array(const HeapVector<T, inlineCapacity>& iterator, v8::Isolate* isolate)
+{
+ v8::Local<v8::Array> result = v8::Array::New(isolate, iterator.size());
+ int index = 0;
+ typename HeapVector<T, inlineCapacity>::const_iterator end = iterator.end();
+ typedef V8ValueTraits<T> TraitsType;
+ for (typename HeapVector<T, inlineCapacity>::const_iterator iter = iterator.begin(); iter != end; ++iter)
+ result->Set(v8::Integer::New(isolate, index++), TraitsType::arrayV8Value(*iter, isolate));
+ return result;
+}
+
+// Conversion flags, used in toIntXX/toUIntXX.
+enum IntegerConversionConfiguration {
+ NormalConversion,
+ EnforceRange,
+ Clamp
+};
+
+// Convert a value to a 8-bit signed integer. The conversion fails if the
+// value cannot be converted to a number or the range violated per WebIDL:
+// http://www.w3.org/TR/WebIDL/#es-byte
+int8_t toInt8(v8::Handle<v8::Value>, IntegerConversionConfiguration, ExceptionState&);
+inline int8_t toInt8(v8::Handle<v8::Value> value, ExceptionState& exceptionState)
+{
+ return toInt8(value, NormalConversion, exceptionState);
+}
+
+// Convert a value to a 8-bit integer assuming the conversion cannot fail.
+int8_t toInt8(v8::Handle<v8::Value>);
+
+// Convert a value to a 8-bit unsigned integer. The conversion fails if the
+// value cannot be converted to a number or the range violated per WebIDL:
+// http://www.w3.org/TR/WebIDL/#es-octet
+uint8_t toUInt8(v8::Handle<v8::Value>, IntegerConversionConfiguration, ExceptionState&);
+inline uint8_t toUInt8(v8::Handle<v8::Value> value, ExceptionState& exceptionState)
+{
+ return toUInt8(value, NormalConversion, exceptionState);
+}
+
+// Convert a value to a 8-bit unsigned integer assuming the conversion cannot fail.
+uint8_t toUInt8(v8::Handle<v8::Value>);
+
+// Convert a value to a 16-bit signed integer. The conversion fails if the
+// value cannot be converted to a number or the range violated per WebIDL:
+// http://www.w3.org/TR/WebIDL/#es-short
+int16_t toInt16(v8::Handle<v8::Value>, IntegerConversionConfiguration, ExceptionState&);
+inline int16_t toInt16(v8::Handle<v8::Value> value, ExceptionState& exceptionState)
+{
+ return toInt16(value, NormalConversion, exceptionState);
+}
+
+// Convert a value to a 16-bit integer assuming the conversion cannot fail.
+int16_t toInt16(v8::Handle<v8::Value>);
+
+// Convert a value to a 16-bit unsigned integer. The conversion fails if the
+// value cannot be converted to a number or the range violated per WebIDL:
+// http://www.w3.org/TR/WebIDL/#es-unsigned-short
+uint16_t toUInt16(v8::Handle<v8::Value>, IntegerConversionConfiguration, ExceptionState&);
+inline uint16_t toUInt16(v8::Handle<v8::Value> value, ExceptionState& exceptionState)
+{
+ return toUInt16(value, NormalConversion, exceptionState);
+}
+
+// Convert a value to a 16-bit unsigned integer assuming the conversion cannot fail.
+uint16_t toUInt16(v8::Handle<v8::Value>);
+
+// Convert a value to a 32-bit signed integer. The conversion fails if the
+// value cannot be converted to a number or the range violated per WebIDL:
+// http://www.w3.org/TR/WebIDL/#es-long
+int32_t toInt32(v8::Handle<v8::Value>, IntegerConversionConfiguration, ExceptionState&);
+inline int32_t toInt32(v8::Handle<v8::Value> value, ExceptionState& exceptionState)
+{
+ return toInt32(value, NormalConversion, exceptionState);
+}
+
+// Convert a value to a 32-bit integer assuming the conversion cannot fail.
+int32_t toInt32(v8::Handle<v8::Value>);
+
+// Convert a value to a 32-bit unsigned integer. The conversion fails if the
+// value cannot be converted to a number or the range violated per WebIDL:
+// http://www.w3.org/TR/WebIDL/#es-unsigned-long
+uint32_t toUInt32(v8::Handle<v8::Value>, IntegerConversionConfiguration, ExceptionState&);
+inline uint32_t toUInt32(v8::Handle<v8::Value> value, ExceptionState& exceptionState)
+{
+ return toUInt32(value, NormalConversion, exceptionState);
+}
+
+// Convert a value to a 32-bit unsigned integer assuming the conversion cannot fail.
+uint32_t toUInt32(v8::Handle<v8::Value>);
+
+// Convert a value to a 64-bit signed integer. The conversion fails if the
+// value cannot be converted to a number or the range violated per WebIDL:
+// http://www.w3.org/TR/WebIDL/#es-long-long
+int64_t toInt64(v8::Handle<v8::Value>, IntegerConversionConfiguration, ExceptionState&);
+inline int64_t toInt64(v8::Handle<v8::Value> value, ExceptionState& exceptionState)
+{
+ return toInt64(value, NormalConversion, exceptionState);
+}
+
+// Convert a value to a 64-bit integer assuming the conversion cannot fail.
+int64_t toInt64(v8::Handle<v8::Value>);
+
+// Convert a value to a 64-bit unsigned integer. The conversion fails if the
+// value cannot be converted to a number or the range violated per WebIDL:
+// http://www.w3.org/TR/WebIDL/#es-unsigned-long-long
+uint64_t toUInt64(v8::Handle<v8::Value>, IntegerConversionConfiguration, ExceptionState&);
+inline uint64_t toUInt64(v8::Handle<v8::Value> value, ExceptionState& exceptionState)
+{
+ return toUInt64(value, NormalConversion, exceptionState);
+}
+
+// Convert a value to a 64-bit unsigned integer assuming the conversion cannot fail.
+uint64_t toUInt64(v8::Handle<v8::Value>);
+
+// Convert a value to a single precision float, which might fail.
+float toFloat(v8::Handle<v8::Value>, ExceptionState&);
+
+// Convert a value to a single precision float assuming the conversion cannot fail.
+inline float toFloat(v8::Local<v8::Value> value)
+{
+ return static_cast<float>(value->NumberValue());
+}
+
+inline v8::Handle<v8::Boolean> v8Boolean(bool value, v8::Isolate* isolate)
+{
+ return value ? v8::True(isolate) : v8::False(isolate);
+}
+
+inline double toCoreDate(v8::Handle<v8::Value> object)
+{
+ if (object->IsDate())
+ return v8::Handle<v8::Date>::Cast(object)->ValueOf();
+ if (object->IsNumber())
+ return object->NumberValue();
+ return std::numeric_limits<double>::quiet_NaN();
+}
+
+inline v8::Handle<v8::Value> v8DateOrNull(double value, v8::Isolate* isolate)
+{
+ ASSERT(isolate);
+ return std::isfinite(value) ? v8::Date::New(isolate, value) : v8::Handle<v8::Value>::Cast(v8::Null(isolate));
+}
+
+// FIXME: Remove the special casing for NodeFilter and XPathNSResolver.
+PassRefPtr<NodeFilter> toNodeFilter(v8::Handle<v8::Value>, v8::Isolate*);
+PassRefPtrWillBeRawPtr<XPathNSResolver> toXPathNSResolver(v8::Handle<v8::Value>, v8::Isolate*);
+
+template<class T> struct NativeValueTraits;
+
+template<>
+struct NativeValueTraits<String> {
+ static inline String nativeValue(const v8::Handle<v8::Value>& value, v8::Isolate* isolate)
{
- if (string.isNull()) {
- v8SetReturnValueUndefined(info);
- return;
- }
- V8PerIsolateData::from(isolate)->stringCache()->setReturnValueFromString(info.GetReturnValue(), string.impl());
+ V8TRYCATCH_FOR_V8STRINGRESOURCE_RETURN(V8StringResource<>, stringValue, value, String());
+ return stringValue;
}
+};
- // Convert v8::String to a WTF::String. If the V8 string is not already
- // an external string then it is transformed into an external string at this
- // point to avoid repeated conversions.
- inline String toCoreString(v8::Handle<v8::String> value)
+template<>
+struct NativeValueTraits<unsigned> {
+ static inline unsigned nativeValue(const v8::Handle<v8::Value>& value, v8::Isolate* isolate)
{
- return v8StringToWebCoreString<String>(value, Externalize);
+ return toUInt32(value);
}
+};
- inline String toCoreStringWithNullCheck(v8::Handle<v8::String> value)
- {
- if (value.IsEmpty() || value->IsNull())
- return String();
- return toCoreString(value);
- }
-
- inline String toCoreStringWithUndefinedOrNullCheck(v8::Handle<v8::String> value)
- {
- if (value.IsEmpty() || value->IsNull() || value->IsUndefined())
- return String();
- return toCoreString(value);
- }
-
- inline AtomicString toCoreAtomicString(v8::Handle<v8::String> value)
- {
- return v8StringToWebCoreString<AtomicString>(value, Externalize);
- }
-
- // This method will return a null String if the v8::Value does not contain a v8::String.
- // It will not call ToString() on the v8::Value. If you want ToString() to be called,
- // please use the V8TRYCATCH_FOR_V8STRINGRESOURCE_*() macros instead.
- inline String toCoreStringWithUndefinedOrNullCheck(v8::Handle<v8::Value> value)
- {
- if (value.IsEmpty() || !value->IsString())
- return String();
-
- return toCoreString(value.As<v8::String>());
- }
-
- // Convert a string to a V8 string.
- // Return a V8 external string that shares the underlying buffer with the given
- // WebCore string. The reference counting mechanism is used to keep the
- // underlying buffer alive while the string is still live in the V8 engine.
- inline v8::Handle<v8::String> v8String(v8::Isolate* isolate, const String& string)
- {
- if (string.isNull())
- return v8::String::Empty(isolate);
- return V8PerIsolateData::from(isolate)->stringCache()->v8ExternalString(string.impl(), isolate);
- }
-
- inline v8::Handle<v8::String> v8AtomicString(v8::Isolate* isolate, const char* str)
- {
- ASSERT(isolate);
- return v8::String::NewFromUtf8(isolate, str, v8::String::kInternalizedString, strlen(str));
- }
-
- inline v8::Handle<v8::String> v8AtomicString(v8::Isolate* isolate, const char* str, size_t length)
- {
- ASSERT(isolate);
- return v8::String::NewFromUtf8(isolate, str, v8::String::kInternalizedString, length);
- }
-
- inline v8::Handle<v8::Value> v8Undefined()
- {
- return v8::Handle<v8::Value>();
- }
-
- template <class T>
- struct V8ValueTraits {
- static inline v8::Handle<v8::Value> arrayV8Value(const T& value, v8::Isolate* isolate)
- {
- return toV8(WTF::getPtr(value), v8::Handle<v8::Object>(), isolate);
- }
- };
-
- template<>
- struct V8ValueTraits<String> {
- static inline v8::Handle<v8::Value> arrayV8Value(const String& value, v8::Isolate* isolate)
- {
- return v8String(isolate, value);
- }
- };
-
- template<>
- struct V8ValueTraits<AtomicString> {
- static inline v8::Handle<v8::Value> arrayV8Value(const AtomicString& value, v8::Isolate* isolate)
- {
- return v8String(isolate, value);
- }
- };
-
- template<>
- struct V8ValueTraits<unsigned> {
- static inline v8::Handle<v8::Value> arrayV8Value(const unsigned& value, v8::Isolate* isolate)
- {
- return v8::Integer::NewFromUnsigned(isolate, value);
- }
- };
-
- template<>
- struct V8ValueTraits<unsigned long> {
- static inline v8::Handle<v8::Value> arrayV8Value(const unsigned long& value, v8::Isolate* isolate)
- {
- return v8::Integer::NewFromUnsigned(isolate, value);
- }
- };
-
- template<>
- struct V8ValueTraits<float> {
- static inline v8::Handle<v8::Value> arrayV8Value(const float& value, v8::Isolate* isolate)
- {
- return v8::Number::New(isolate, value);
- }
- };
-
- template<>
- struct V8ValueTraits<double> {
- static inline v8::Handle<v8::Value> arrayV8Value(const double& value, v8::Isolate* isolate)
- {
- return v8::Number::New(isolate, value);
- }
- };
-
- template<typename T, size_t inlineCapacity>
- v8::Handle<v8::Value> v8Array(const Vector<T, inlineCapacity>& iterator, v8::Isolate* isolate)
- {
- v8::Local<v8::Array> result = v8::Array::New(isolate, iterator.size());
- int index = 0;
- typename Vector<T, inlineCapacity>::const_iterator end = iterator.end();
- typedef V8ValueTraits<T> TraitsType;
- for (typename Vector<T, inlineCapacity>::const_iterator iter = iterator.begin(); iter != end; ++iter)
- result->Set(v8::Integer::New(isolate, index++), TraitsType::arrayV8Value(*iter, isolate));
- return result;
- }
-
- template<typename T, size_t inlineCapacity>
- v8::Handle<v8::Value> v8Array(const HeapVector<T, inlineCapacity>& iterator, v8::Isolate* isolate)
- {
- v8::Local<v8::Array> result = v8::Array::New(isolate, iterator.size());
- int index = 0;
- typename HeapVector<T, inlineCapacity>::const_iterator end = iterator.end();
- typedef V8ValueTraits<T> TraitsType;
- for (typename HeapVector<T, inlineCapacity>::const_iterator iter = iterator.begin(); iter != end; ++iter)
- result->Set(v8::Integer::New(isolate, index++), TraitsType::arrayV8Value(*iter, isolate));
- return result;
- }
-
- // Conversion flags, used in toIntXX/toUIntXX.
- enum IntegerConversionConfiguration {
- NormalConversion,
- EnforceRange,
- Clamp
- };
-
- // Convert a value to a 8-bit signed integer. The conversion fails if the
- // value cannot be converted to a number or the range violated per WebIDL:
- // http://www.w3.org/TR/WebIDL/#es-byte
- int8_t toInt8(v8::Handle<v8::Value>, IntegerConversionConfiguration, ExceptionState&);
- inline int8_t toInt8(v8::Handle<v8::Value> value, ExceptionState& exceptionState)
- {
- return toInt8(value, NormalConversion, exceptionState);
- }
-
- // Convert a value to a 8-bit integer assuming the conversion cannot fail.
- int8_t toInt8(v8::Handle<v8::Value>);
-
- // Convert a value to a 8-bit unsigned integer. The conversion fails if the
- // value cannot be converted to a number or the range violated per WebIDL:
- // http://www.w3.org/TR/WebIDL/#es-octet
- uint8_t toUInt8(v8::Handle<v8::Value>, IntegerConversionConfiguration, ExceptionState&);
- inline uint8_t toUInt8(v8::Handle<v8::Value> value, ExceptionState& exceptionState)
- {
- return toUInt8(value, NormalConversion, exceptionState);
- }
-
- // Convert a value to a 8-bit unsigned integer assuming the conversion cannot fail.
- uint8_t toUInt8(v8::Handle<v8::Value>);
-
- // Convert a value to a 16-bit signed integer. The conversion fails if the
- // value cannot be converted to a number or the range violated per WebIDL:
- // http://www.w3.org/TR/WebIDL/#es-short
- int16_t toInt16(v8::Handle<v8::Value>, IntegerConversionConfiguration, ExceptionState&);
- inline int16_t toInt16(v8::Handle<v8::Value> value, ExceptionState& exceptionState)
- {
- return toInt16(value, NormalConversion, exceptionState);
- }
-
- // Convert a value to a 16-bit integer assuming the conversion cannot fail.
- int16_t toInt16(v8::Handle<v8::Value>);
-
- // Convert a value to a 16-bit unsigned integer. The conversion fails if the
- // value cannot be converted to a number or the range violated per WebIDL:
- // http://www.w3.org/TR/WebIDL/#es-unsigned-short
- uint16_t toUInt16(v8::Handle<v8::Value>, IntegerConversionConfiguration, ExceptionState&);
- inline uint16_t toUInt16(v8::Handle<v8::Value> value, ExceptionState& exceptionState)
- {
- return toUInt16(value, NormalConversion, exceptionState);
- }
-
- // Convert a value to a 16-bit unsigned integer assuming the conversion cannot fail.
- uint16_t toUInt16(v8::Handle<v8::Value>);
-
- // Convert a value to a 32-bit signed integer. The conversion fails if the
- // value cannot be converted to a number or the range violated per WebIDL:
- // http://www.w3.org/TR/WebIDL/#es-long
- int32_t toInt32(v8::Handle<v8::Value>, IntegerConversionConfiguration, ExceptionState&);
- inline int32_t toInt32(v8::Handle<v8::Value> value, ExceptionState& exceptionState)
- {
- return toInt32(value, NormalConversion, exceptionState);
- }
-
- // Convert a value to a 32-bit integer assuming the conversion cannot fail.
- int32_t toInt32(v8::Handle<v8::Value>);
-
- // Convert a value to a 32-bit unsigned integer. The conversion fails if the
- // value cannot be converted to a number or the range violated per WebIDL:
- // http://www.w3.org/TR/WebIDL/#es-unsigned-long
- uint32_t toUInt32(v8::Handle<v8::Value>, IntegerConversionConfiguration, ExceptionState&);
- inline uint32_t toUInt32(v8::Handle<v8::Value> value, ExceptionState& exceptionState)
- {
- return toUInt32(value, NormalConversion, exceptionState);
- }
-
- // Convert a value to a 32-bit unsigned integer assuming the conversion cannot fail.
- uint32_t toUInt32(v8::Handle<v8::Value>);
-
- // Convert a value to a 64-bit signed integer. The conversion fails if the
- // value cannot be converted to a number or the range violated per WebIDL:
- // http://www.w3.org/TR/WebIDL/#es-long-long
- int64_t toInt64(v8::Handle<v8::Value>, IntegerConversionConfiguration, ExceptionState&);
- inline int64_t toInt64(v8::Handle<v8::Value> value, ExceptionState& exceptionState)
- {
- return toInt64(value, NormalConversion, exceptionState);
- }
-
- // Convert a value to a 64-bit integer assuming the conversion cannot fail.
- int64_t toInt64(v8::Handle<v8::Value>);
-
- // Convert a value to a 64-bit unsigned integer. The conversion fails if the
- // value cannot be converted to a number or the range violated per WebIDL:
- // http://www.w3.org/TR/WebIDL/#es-unsigned-long-long
- uint64_t toUInt64(v8::Handle<v8::Value>, IntegerConversionConfiguration, ExceptionState&);
- inline uint64_t toUInt64(v8::Handle<v8::Value> value, ExceptionState& exceptionState)
- {
- return toUInt64(value, NormalConversion, exceptionState);
- }
-
- // Convert a value to a 64-bit unsigned integer assuming the conversion cannot fail.
- uint64_t toUInt64(v8::Handle<v8::Value>);
-
- // Convert a value to a single precision float, which might fail.
- float toFloat(v8::Handle<v8::Value>, ExceptionState&);
-
- // Convert a value to a single precision float assuming the conversion cannot fail.
- inline float toFloat(v8::Local<v8::Value> value)
+template<>
+struct NativeValueTraits<float> {
+ static inline float nativeValue(const v8::Handle<v8::Value>& value, v8::Isolate* isolate)
{
return static_cast<float>(value->NumberValue());
}
+};
- inline v8::Handle<v8::Boolean> v8Boolean(bool value, v8::Isolate* isolate)
+template<>
+struct NativeValueTraits<double> {
+ static inline double nativeValue(const v8::Handle<v8::Value>& value, v8::Isolate* isolate)
{
- return value ? v8::True(isolate) : v8::False(isolate);
+ return static_cast<double>(value->NumberValue());
}
+};
- inline double toCoreDate(v8::Handle<v8::Value> object)
+template<>
+struct NativeValueTraits<v8::Handle<v8::Value> > {
+ static inline v8::Handle<v8::Value> nativeValue(const v8::Handle<v8::Value>& value, v8::Isolate* isolate)
{
- if (object->IsDate())
- return v8::Handle<v8::Date>::Cast(object)->ValueOf();
- if (object->IsNumber())
- return object->NumberValue();
- return std::numeric_limits<double>::quiet_NaN();
+ return value;
}
+};
- inline v8::Handle<v8::Value> v8DateOrNull(double value, v8::Isolate* isolate)
- {
- ASSERT(isolate);
- return std::isfinite(value) ? v8::Date::New(isolate, value) : v8::Handle<v8::Value>::Cast(v8::Null(isolate));
- }
+v8::Handle<v8::Value> toV8Sequence(v8::Handle<v8::Value>, uint32_t& length, v8::Isolate*);
- // FIXME: Remove the special casing for NodeFilter and XPathNSResolver.
- PassRefPtr<NodeFilter> toNodeFilter(v8::Handle<v8::Value>, v8::Isolate*);
- PassRefPtr<XPathNSResolver> toXPathNSResolver(v8::Handle<v8::Value>, v8::Isolate*);
-
- template<class T> struct NativeValueTraits;
-
- template<>
- struct NativeValueTraits<String> {
- static inline String nativeValue(const v8::Handle<v8::Value>& value, v8::Isolate* isolate)
- {
- V8TRYCATCH_FOR_V8STRINGRESOURCE_RETURN(V8StringResource<>, stringValue, value, String());
- return stringValue;
- }
- };
-
- template<>
- struct NativeValueTraits<unsigned> {
- static inline unsigned nativeValue(const v8::Handle<v8::Value>& value, v8::Isolate* isolate)
- {
- return toUInt32(value);
- }
- };
-
- template<>
- struct NativeValueTraits<float> {
- static inline float nativeValue(const v8::Handle<v8::Value>& value, v8::Isolate* isolate)
- {
- return static_cast<float>(value->NumberValue());
- }
- };
-
- template<>
- struct NativeValueTraits<double> {
- static inline double nativeValue(const v8::Handle<v8::Value>& value, v8::Isolate* isolate)
- {
- return static_cast<double>(value->NumberValue());
- }
- };
-
- template<>
- struct NativeValueTraits<v8::Handle<v8::Value> > {
- static inline v8::Handle<v8::Value> nativeValue(const v8::Handle<v8::Value>& value, v8::Isolate* isolate)
- {
- return value;
- }
- };
-
- // Converts a JavaScript value to an array as per the Web IDL specification:
- // http://www.w3.org/TR/2012/CR-WebIDL-20120419/#es-array
- template <class T, class V8T>
- Vector<RefPtr<T> > toRefPtrNativeArrayUnchecked(v8::Local<v8::Value> v8Value, uint32_t length, v8::Isolate* isolate, bool* success = 0)
- {
- Vector<RefPtr<T> > result;
- result.reserveInitialCapacity(length);
- v8::Local<v8::Object> object = v8::Local<v8::Object>::Cast(v8Value);
- for (uint32_t i = 0; i < length; ++i) {
- v8::Handle<v8::Value> element = object->Get(i);
-
- if (V8T::hasInstance(element, isolate)) {
- v8::Handle<v8::Object> elementObject = v8::Handle<v8::Object>::Cast(element);
- result.uncheckedAppend(V8T::toNative(elementObject));
- } else {
- if (success)
- *success = false;
- throwTypeError("Invalid Array element type", isolate);
- return Vector<RefPtr<T> >();
- }
- }
- return result;
- }
-
- v8::Handle<v8::Value> toV8Sequence(v8::Handle<v8::Value>, uint32_t& length, v8::Isolate*);
-
- template <class T, class V8T>
- Vector<RefPtr<T> > toRefPtrNativeArray(v8::Handle<v8::Value> value, int argumentIndex, v8::Isolate* isolate, bool* success = 0)
- {
- if (success)
- *success = true;
-
- v8::Local<v8::Value> v8Value(v8::Local<v8::Value>::New(isolate, value));
- uint32_t length = 0;
- if (value->IsArray()) {
- length = v8::Local<v8::Array>::Cast(v8Value)->Length();
- } else if (toV8Sequence(value, length, isolate).IsEmpty()) {
- throwTypeError(ExceptionMessages::notAnArrayTypeArgumentOrValue(argumentIndex), isolate);
+// Converts a JavaScript value to an array as per the Web IDL specification:
+// http://www.w3.org/TR/2012/CR-WebIDL-20120419/#es-array
+template <class T, class V8T>
+Vector<RefPtr<T> > toRefPtrNativeArrayUnchecked(v8::Local<v8::Value> v8Value, uint32_t length, v8::Isolate* isolate, bool* success = 0)
+{
+ Vector<RefPtr<T> > result;
+ result.reserveInitialCapacity(length);
+ v8::Local<v8::Object> object = v8::Local<v8::Object>::Cast(v8Value);
+ for (uint32_t i = 0; i < length; ++i) {
+ v8::Handle<v8::Value> element = object->Get(i);
+ if (V8T::hasInstance(element, isolate)) {
+ v8::Handle<v8::Object> elementObject = v8::Handle<v8::Object>::Cast(element);
+ result.uncheckedAppend(V8T::toNative(elementObject));
+ } else {
+ if (success)
+ *success = false;
+ throwTypeError("Invalid Array element type", isolate);
return Vector<RefPtr<T> >();
}
+ }
+ return result;
+}
- return toRefPtrNativeArrayUnchecked<T, V8T>(v8Value, length, isolate, success);
+template <class T, class V8T>
+Vector<RefPtr<T> > toRefPtrNativeArray(v8::Handle<v8::Value> value, int argumentIndex, v8::Isolate* isolate, bool* success = 0)
+{
+ if (success)
+ *success = true;
+
+ v8::Local<v8::Value> v8Value(v8::Local<v8::Value>::New(isolate, value));
+ uint32_t length = 0;
+ if (value->IsArray()) {
+ length = v8::Local<v8::Array>::Cast(v8Value)->Length();
+ } else if (toV8Sequence(value, length, isolate).IsEmpty()) {
+ throwTypeError(ExceptionMessages::notAnArrayTypeArgumentOrValue(argumentIndex), isolate);
+ return Vector<RefPtr<T> >();
+ }
+ return toRefPtrNativeArrayUnchecked<T, V8T>(v8Value, length, isolate, success);
+}
+
+template <class T, class V8T>
+Vector<RefPtr<T> > toRefPtrNativeArray(v8::Handle<v8::Value> value, const String& propertyName, v8::Isolate* isolate, bool* success = 0)
+{
+ if (success)
+ *success = true;
+
+ v8::Local<v8::Value> v8Value(v8::Local<v8::Value>::New(isolate, value));
+ uint32_t length = 0;
+ if (value->IsArray()) {
+ length = v8::Local<v8::Array>::Cast(v8Value)->Length();
+ } else if (toV8Sequence(value, length, isolate).IsEmpty()) {
+ throwTypeError(ExceptionMessages::notASequenceTypeProperty(propertyName), isolate);
+ return Vector<RefPtr<T> >();
+ }
+ return toRefPtrNativeArrayUnchecked<T, V8T>(v8Value, length, isolate, success);
+}
+
+template <class T, class V8T>
+HeapVector<Member<T> > toMemberNativeArray(v8::Handle<v8::Value> value, int argumentIndex, v8::Isolate* isolate, bool* success = 0)
+{
+ if (success)
+ *success = true;
+
+ v8::Local<v8::Value> v8Value(v8::Local<v8::Value>::New(isolate, value));
+ uint32_t length = 0;
+ if (value->IsArray()) {
+ length = v8::Local<v8::Array>::Cast(v8Value)->Length();
+ } else if (toV8Sequence(value, length, isolate).IsEmpty()) {
+ throwTypeError(ExceptionMessages::notAnArrayTypeArgumentOrValue(argumentIndex), isolate);
+ return HeapVector<Member<T> >();
}
- template <class T, class V8T>
- Vector<RefPtr<T> > toRefPtrNativeArray(v8::Handle<v8::Value> value, const String& propertyName, v8::Isolate* isolate, bool* success = 0)
+ HeapVector<Member<T> > result;
+ result.reserveInitialCapacity(length);
+ v8::Local<v8::Object> object = v8::Local<v8::Object>::Cast(v8Value);
+ for (uint32_t i = 0; i < length; ++i) {
+ v8::Handle<v8::Value> element = object->Get(i);
+ if (V8T::hasInstance(element, isolate)) {
+ v8::Handle<v8::Object> elementObject = v8::Handle<v8::Object>::Cast(element);
+ result.uncheckedAppend(V8T::toNative(elementObject));
+ } else {
+ if (success)
+ *success = false;
+ throwTypeError("Invalid Array element type", isolate);
+ return HeapVector<Member<T> >();
+ }
+ }
+ return result;
+}
+
+// Converts a JavaScript value to an array as per the Web IDL specification:
+// http://www.w3.org/TR/2012/CR-WebIDL-20120419/#es-array
+template <class T>
+Vector<T> toNativeArray(v8::Handle<v8::Value> value, int argumentIndex, v8::Isolate* isolate)
+{
+ v8::Local<v8::Value> v8Value(v8::Local<v8::Value>::New(isolate, value));
+ uint32_t length = 0;
+ if (value->IsArray()) {
+ length = v8::Local<v8::Array>::Cast(v8Value)->Length();
+ } else if (toV8Sequence(value, length, isolate).IsEmpty()) {
+ throwTypeError(ExceptionMessages::notAnArrayTypeArgumentOrValue(argumentIndex), isolate);
+ return Vector<T>();
+ }
+
+ Vector<T> result;
+ result.reserveInitialCapacity(length);
+ typedef NativeValueTraits<T> TraitsType;
+ v8::Local<v8::Object> object = v8::Local<v8::Object>::Cast(v8Value);
+ for (uint32_t i = 0; i < length; ++i)
+ result.uncheckedAppend(TraitsType::nativeValue(object->Get(i), isolate));
+ return result;
+}
+
+template <class T>
+Vector<T> toNativeArguments(const v8::FunctionCallbackInfo<v8::Value>& info, int startIndex)
+{
+ ASSERT(startIndex <= info.Length());
+ Vector<T> result;
+ typedef NativeValueTraits<T> TraitsType;
+ int length = info.Length();
+ result.reserveInitialCapacity(length);
+ for (int i = startIndex; i < length; ++i)
+ result.uncheckedAppend(TraitsType::nativeValue(info[i], info.GetIsolate()));
+ return result;
+}
+
+// Validates that the passed object is a sequence type per WebIDL spec
+// http://www.w3.org/TR/2012/CR-WebIDL-20120419/#es-sequence
+inline v8::Handle<v8::Value> toV8Sequence(v8::Handle<v8::Value> value, uint32_t& length, v8::Isolate* isolate)
+{
+ // Attempt converting to a sequence if the value is not already an array but is
+ // any kind of object except for a native Date object or a native RegExp object.
+ ASSERT(!value->IsArray());
+ // FIXME: Do we really need to special case Date and RegExp object?
+ // https://www.w3.org/Bugs/Public/show_bug.cgi?id=22806
+ if (!value->IsObject() || value->IsDate() || value->IsRegExp()) {
+ // The caller is responsible for reporting a TypeError.
+ return v8Undefined();
+ }
+
+ v8::Local<v8::Value> v8Value(v8::Local<v8::Value>::New(isolate, value));
+ v8::Local<v8::Object> object = v8::Local<v8::Object>::Cast(v8Value);
+ v8::Local<v8::String> lengthSymbol = v8AtomicString(isolate, "length");
+
+ // FIXME: The specification states that the length property should be used as fallback, if value
+ // is not a platform object that supports indexed properties. If it supports indexed properties,
+ // length should actually be one greater than value’s maximum indexed property index.
+ V8TRYCATCH(v8::Local<v8::Value>, lengthValue, object->Get(lengthSymbol));
+
+ if (lengthValue->IsUndefined() || lengthValue->IsNull()) {
+ // The caller is responsible for reporting a TypeError.
+ return v8Undefined();
+ }
+
+ V8TRYCATCH(uint32_t, sequenceLength, lengthValue->Int32Value());
+ length = sequenceLength;
+ return v8Value;
+}
+
+v8::Isolate* toIsolate(ExecutionContext*);
+v8::Isolate* toIsolate(LocalFrame*);
+
+DOMWindow* toDOMWindow(v8::Handle<v8::Value>, v8::Isolate*);
+DOMWindow* toDOMWindow(v8::Handle<v8::Context>);
+DOMWindow* enteredDOMWindow(v8::Isolate*);
+DOMWindow* currentDOMWindow(v8::Isolate*);
+DOMWindow* callingDOMWindow(v8::Isolate*);
+ExecutionContext* toExecutionContext(v8::Handle<v8::Context>);
+ExecutionContext* currentExecutionContext(v8::Isolate*);
+ExecutionContext* callingExecutionContext(v8::Isolate*);
+
+// Returns a V8 context associated with a ExecutionContext and a DOMWrapperWorld.
+// This method returns an empty context if there is no frame or the frame is already detached.
+v8::Local<v8::Context> toV8Context(ExecutionContext*, DOMWrapperWorld*);
+// Returns a V8 context associated with a LocalFrame and a DOMWrapperWorld.
+// This method returns an empty context if the frame is already detached.
+v8::Local<v8::Context> toV8Context(v8::Isolate*, LocalFrame*, DOMWrapperWorld*);
+
+// Returns the frame object of the window object associated with
+// a context, if the window is currently being displayed in the LocalFrame.
+LocalFrame* toFrameIfNotDetached(v8::Handle<v8::Context>);
+
+// If the current context causes out of memory, JavaScript setting
+// is disabled and it returns true.
+bool handleOutOfMemory();
+v8::Local<v8::Value> handleMaxRecursionDepthExceeded(v8::Isolate*);
+void crashIfV8IsDead();
+
+inline bool isUndefinedOrNull(v8::Handle<v8::Value> value)
+{
+ return value->IsNull() || value->IsUndefined();
+}
+v8::Handle<v8::Function> getBoundFunction(v8::Handle<v8::Function>);
+
+// Attaches |environment| to |function| and returns it.
+inline v8::Local<v8::Function> createClosure(v8::FunctionCallback function, v8::Handle<v8::Value> environment, v8::Isolate* isolate)
+{
+ return v8::Function::New(isolate, function, environment);
+}
+
+// FIXME: This will be soon embedded in the generated code.
+template<class Collection> static void indexedPropertyEnumerator(const v8::PropertyCallbackInfo<v8::Array>& info)
+{
+ Collection* collection = reinterpret_cast<Collection*>(info.Holder()->GetAlignedPointerFromInternalField(v8DOMWrapperObjectIndex));
+ int length = collection->length();
+ v8::Handle<v8::Array> properties = v8::Array::New(info.GetIsolate(), length);
+ for (int i = 0; i < length; ++i) {
+ // FIXME: Do we need to check that the item function returns a non-null value for this index?
+ v8::Handle<v8::Integer> integer = v8::Integer::New(info.GetIsolate(), i);
+ properties->Set(integer, integer);
+ }
+ v8SetReturnValue(info, properties);
+}
+
+// These methods store hidden values into an array that is stored in the internal field of a DOM wrapper.
+void addHiddenValueToArray(v8::Handle<v8::Object>, v8::Local<v8::Value>, int cacheIndex, v8::Isolate*);
+void removeHiddenValueFromArray(v8::Handle<v8::Object>, v8::Local<v8::Value>, int cacheIndex, v8::Isolate*);
+void moveEventListenerToNewWrapper(v8::Handle<v8::Object>, EventListener* oldValue, v8::Local<v8::Value> newValue, int cacheIndex, v8::Isolate*);
+
+// Converts a DOM object to a v8 value.
+// This is a no-inline version of toV8(). If you want to call toV8()
+// without creating #include cycles, you can use this function instead.
+// Each specialized implementation will be generated.
+template<typename T>
+v8::Handle<v8::Value> toV8NoInline(T* impl, v8::Handle<v8::Object> creationContext, v8::Isolate*);
+
+// Result values for platform object 'deleter' methods,
+// http://www.w3.org/TR/WebIDL/#delete
+enum DeleteResult {
+ DeleteSuccess,
+ DeleteReject,
+ DeleteUnknownProperty
+};
+
+class V8IsolateInterruptor : public ThreadState::Interruptor {
+public:
+ explicit V8IsolateInterruptor(v8::Isolate* isolate) : m_isolate(isolate) { }
+
+ static void onInterruptCallback(v8::Isolate* isolate, void* data)
{
- if (success)
- *success = true;
-
- v8::Local<v8::Value> v8Value(v8::Local<v8::Value>::New(isolate, value));
- uint32_t length = 0;
- if (value->IsArray()) {
- length = v8::Local<v8::Array>::Cast(v8Value)->Length();
- } else if (toV8Sequence(value, length, isolate).IsEmpty()) {
- throwTypeError(ExceptionMessages::notASequenceTypeProperty(propertyName), isolate);
- return Vector<RefPtr<T> >();
- }
-
- return toRefPtrNativeArrayUnchecked<T, V8T>(v8Value, length, isolate, success);
+ reinterpret_cast<V8IsolateInterruptor*>(data)->onInterrupted();
}
- // Converts a JavaScript value to an array as per the Web IDL specification:
- // http://www.w3.org/TR/2012/CR-WebIDL-20120419/#es-array
- template <class T>
- Vector<T> toNativeArray(v8::Handle<v8::Value> value, int argumentIndex, v8::Isolate* isolate)
+ virtual void requestInterrupt() OVERRIDE
{
- v8::Local<v8::Value> v8Value(v8::Local<v8::Value>::New(isolate, value));
- uint32_t length = 0;
- if (value->IsArray()) {
- length = v8::Local<v8::Array>::Cast(v8Value)->Length();
- } else if (toV8Sequence(value, length, isolate).IsEmpty()) {
- throwTypeError(ExceptionMessages::notAnArrayTypeArgumentOrValue(argumentIndex), isolate);
- return Vector<T>();
- }
-
- Vector<T> result;
- result.reserveInitialCapacity(length);
- typedef NativeValueTraits<T> TraitsType;
- v8::Local<v8::Object> object = v8::Local<v8::Object>::Cast(v8Value);
- for (uint32_t i = 0; i < length; ++i)
- result.uncheckedAppend(TraitsType::nativeValue(object->Get(i), isolate));
- return result;
+ m_isolate->RequestInterrupt(&onInterruptCallback, this);
}
- template <class T>
- Vector<T> toNativeArguments(const v8::FunctionCallbackInfo<v8::Value>& info, int startIndex)
+ virtual void clearInterrupt() OVERRIDE
{
- ASSERT(startIndex <= info.Length());
- Vector<T> result;
- typedef NativeValueTraits<T> TraitsType;
- int length = info.Length();
- result.reserveInitialCapacity(length);
- for (int i = startIndex; i < length; ++i)
- result.uncheckedAppend(TraitsType::nativeValue(info[i], info.GetIsolate()));
- return result;
+ m_isolate->ClearInterrupt();
}
- // Validates that the passed object is a sequence type per WebIDL spec
- // http://www.w3.org/TR/2012/CR-WebIDL-20120419/#es-sequence
- inline v8::Handle<v8::Value> toV8Sequence(v8::Handle<v8::Value> value, uint32_t& length, v8::Isolate* isolate)
- {
- // Attempt converting to a sequence if the value is not already an array but is
- // any kind of object except for a native Date object or a native RegExp object.
- ASSERT(!value->IsArray());
- // FIXME: Do we really need to special case Date and RegExp object?
- // https://www.w3.org/Bugs/Public/show_bug.cgi?id=22806
- if (!value->IsObject() || value->IsDate() || value->IsRegExp()) {
- // The caller is responsible for reporting a TypeError.
- return v8Undefined();
- }
+private:
+ v8::Isolate* m_isolate;
+};
- v8::Local<v8::Value> v8Value(v8::Local<v8::Value>::New(isolate, value));
- v8::Local<v8::Object> object = v8::Local<v8::Object>::Cast(v8Value);
- v8::Local<v8::String> lengthSymbol = v8AtomicString(isolate, "length");
+class V8ExecutionScope {
+public:
+ static PassOwnPtr<V8ExecutionScope> create(v8::Isolate*);
+ explicit V8ExecutionScope(v8::Isolate*);
- // FIXME: The specification states that the length property should be used as fallback, if value
- // is not a platform object that supports indexed properties. If it supports indexed properties,
- // length should actually be one greater than value’s maximum indexed property index.
- V8TRYCATCH(v8::Local<v8::Value>, lengthValue, object->Get(lengthSymbol));
-
- if (lengthValue->IsUndefined() || lengthValue->IsNull()) {
- // The caller is responsible for reporting a TypeError.
- return v8Undefined();
- }
-
- V8TRYCATCH(uint32_t, sequenceLength, lengthValue->Int32Value());
- length = sequenceLength;
-
- return v8Value;
- }
-
- v8::Isolate* toIsolate(ExecutionContext*);
- v8::Isolate* toIsolate(Frame*);
-
- WrapperWorldType worldType(v8::Isolate*);
- WrapperWorldType worldTypeInMainThread(v8::Isolate*);
-
- DOMWindow* toDOMWindow(v8::Handle<v8::Value>, v8::Isolate*);
- DOMWindow* toDOMWindow(v8::Handle<v8::Context>);
- ExecutionContext* toExecutionContext(v8::Handle<v8::Context>);
-
- DOMWindow* activeDOMWindow(v8::Isolate*);
- ExecutionContext* activeExecutionContext(v8::Isolate*);
- DOMWindow* firstDOMWindow(v8::Isolate*);
- Document* currentDocument(v8::Isolate*);
- ExecutionContext* currentExecutionContext(v8::Isolate*);
-
- // Returns a V8 context associated with a ExecutionContext and a DOMWrapperWorld.
- // This method returns an empty context if there is no frame or the frame is already detached.
- v8::Local<v8::Context> toV8Context(ExecutionContext*, DOMWrapperWorld*);
- // Returns a V8 context associated with a Frame and a DOMWrapperWorld.
- // This method returns an empty context if the frame is already detached.
- v8::Local<v8::Context> toV8Context(v8::Isolate*, Frame*, DOMWrapperWorld*);
-
- // Returns the frame object of the window object associated with
- // a context, if the window is currently being displayed in the Frame.
- Frame* toFrameIfNotDetached(v8::Handle<v8::Context>);
-
- // If the current context causes out of memory, JavaScript setting
- // is disabled and it returns true.
- bool handleOutOfMemory();
- v8::Local<v8::Value> handleMaxRecursionDepthExceeded(v8::Isolate*);
- void crashIfV8IsDead();
-
- inline bool isUndefinedOrNull(v8::Handle<v8::Value> value)
- {
- return value->IsNull() || value->IsUndefined();
- }
- v8::Handle<v8::Function> getBoundFunction(v8::Handle<v8::Function>);
-
- // Attaches |environment| to |function| and returns it.
- inline v8::Local<v8::Function> createClosure(v8::FunctionCallback function, v8::Handle<v8::Value> environment, v8::Isolate* isolate)
- {
- return v8::Function::New(isolate, function, environment);
- }
-
- // FIXME: This will be soon embedded in the generated code.
- template<class Collection> static void indexedPropertyEnumerator(const v8::PropertyCallbackInfo<v8::Array>& info)
- {
- Collection* collection = reinterpret_cast<Collection*>(info.Holder()->GetAlignedPointerFromInternalField(v8DOMWrapperObjectIndex));
- int length = collection->length();
- v8::Handle<v8::Array> properties = v8::Array::New(info.GetIsolate(), length);
- for (int i = 0; i < length; ++i) {
- // FIXME: Do we need to check that the item function returns a non-null value for this index?
- v8::Handle<v8::Integer> integer = v8::Integer::New(info.GetIsolate(), i);
- properties->Set(integer, integer);
- }
- v8SetReturnValue(info, properties);
- }
-
- v8::Local<v8::Value> getHiddenValue(v8::Isolate*, v8::Handle<v8::Object>, const char*);
- v8::Local<v8::Value> getHiddenValue(v8::Isolate*, v8::Handle<v8::Object>, v8::Handle<v8::String>);
- bool setHiddenValue(v8::Isolate*, v8::Handle<v8::Object>, const char*, v8::Handle<v8::Value>);
- bool setHiddenValue(v8::Isolate*, v8::Handle<v8::Object>, v8::Handle<v8::String>, v8::Handle<v8::Value>);
- bool deleteHiddenValue(v8::Isolate*, v8::Handle<v8::Object>, const char*);
- bool deleteHiddenValue(v8::Isolate*, v8::Handle<v8::Object>, v8::Handle<v8::String>);
- v8::Local<v8::Value> getHiddenValueFromMainWorldWrapper(v8::Isolate*, ScriptWrappable*, const char*);
- v8::Local<v8::Value> getHiddenValueFromMainWorldWrapper(v8::Isolate*, ScriptWrappable*, v8::Handle<v8::String>);
-
- // These methods store hidden values into an array that is stored in the internal field of a DOM wrapper.
- void addHiddenValueToArray(v8::Handle<v8::Object>, v8::Local<v8::Value>, int cacheIndex, v8::Isolate*);
- void removeHiddenValueFromArray(v8::Handle<v8::Object>, v8::Local<v8::Value>, int cacheIndex, v8::Isolate*);
- void moveEventListenerToNewWrapper(v8::Handle<v8::Object>, EventListener* oldValue, v8::Local<v8::Value> newValue, int cacheIndex, v8::Isolate*);
-
- // Converts a DOM object to a v8 value.
- // This is a no-inline version of toV8(). If you want to call toV8()
- // without creating #include cycles, you can use this function instead.
- // Each specialized implementation will be generated.
- template<typename T>
- v8::Handle<v8::Value> toV8NoInline(T* impl, v8::Handle<v8::Object> creationContext, v8::Isolate*);
-
- // Result values for platform object 'deleter' methods,
- // http://www.w3.org/TR/WebIDL/#delete
- enum DeleteResult {
- DeleteSuccess,
- DeleteReject,
- DeleteUnknownProperty
- };
-
- class V8IsolateInterruptor : public ThreadState::Interruptor {
- public:
- explicit V8IsolateInterruptor(v8::Isolate* isolate) : m_isolate(isolate) { }
-
- static void onInterruptCallback(v8::Isolate* isolate, void* data)
- {
- reinterpret_cast<V8IsolateInterruptor*>(data)->onInterrupted();
- }
-
- virtual void requestInterrupt() OVERRIDE
- {
- m_isolate->RequestInterrupt(&onInterruptCallback, this);
- }
-
- virtual void clearInterrupt() OVERRIDE
- {
- m_isolate->ClearInterrupt();
- }
-
- private:
- v8::Isolate* m_isolate;
- };
+private:
+ v8::HandleScope m_handleScope;
+ v8::Handle<v8::Context> m_context;
+ v8::Context::Scope m_contextScope;
+ RefPtr<DOMWrapperWorld> m_world;
+ OwnPtr<V8PerContextData> m_perContextData;
+};
} // namespace WebCore
diff --git a/Source/bindings/v8/V8Callback.h b/Source/bindings/v8/V8Callback.h
index fd88915..49dffcc 100644
--- a/Source/bindings/v8/V8Callback.h
+++ b/Source/bindings/v8/V8Callback.h
@@ -31,8 +31,8 @@
#ifndef V8Callback_h
#define V8Callback_h
+#include "bindings/v8/ExceptionState.h"
#include "bindings/v8/V8Binding.h"
-#include "bindings/v8/V8Utilities.h"
#include "core/dom/ExceptionCode.h"
#include <v8.h>
@@ -53,7 +53,7 @@
// 'FunctionOnly' is assumed for the created callback.
template <typename V8CallbackType>
-PassOwnPtr<V8CallbackType> createFunctionOnlyCallback(v8::Local<v8::Value> value, bool& succeeded, v8::Isolate* isolate, CallbackAllowedValueFlags acceptedValues = 0)
+PassOwnPtr<V8CallbackType> createFunctionOnlyCallback(v8::Local<v8::Value> value, unsigned index, bool& succeeded, v8::Isolate* isolate, ExceptionState& exceptionState, CallbackAllowedValueFlags acceptedValues = 0)
{
succeeded = true;
@@ -65,7 +65,8 @@
if (!value->IsFunction()) {
succeeded = false;
- setDOMException(TypeMismatchError, isolate);
+ exceptionState.throwDOMException(TypeMismatchError, ExceptionMessages::argumentNullOrIncorrectType(index, "Function"));
+ exceptionState.throwIfNeeded();
return nullptr;
}
diff --git a/Source/bindings/v8/V8CustomElementLifecycleCallbacks.cpp b/Source/bindings/v8/V8CustomElementLifecycleCallbacks.cpp
index b8d3d3e..9d03759 100644
--- a/Source/bindings/v8/V8CustomElementLifecycleCallbacks.cpp
+++ b/Source/bindings/v8/V8CustomElementLifecycleCallbacks.cpp
@@ -36,6 +36,7 @@
#include "bindings/v8/DOMDataStore.h"
#include "bindings/v8/ScriptController.h"
#include "bindings/v8/V8Binding.h"
+#include "bindings/v8/V8HiddenValue.h"
#include "bindings/v8/V8PerContextData.h"
#include "core/dom/ExecutionContext.h"
#include "core/inspector/InspectorInstrumentation.h"
@@ -54,13 +55,13 @@
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) \
- ASSERT(getHiddenValue(isolate, prototype, "customElement" #Name).IsEmpty()); \
+#define SET_HIDDEN_VALUE(Value, Name) \
+ ASSERT(V8HiddenValue::getHiddenValue(isolate, prototype, V8HiddenValue::customElement##Name(isolate)).IsEmpty()); \
if (!Value.IsEmpty()) \
- setHiddenValue(isolate, prototype, "customElement" #Name, Value);
+ V8HiddenValue::setHiddenValue(isolate, prototype, V8HiddenValue::customElement##Name(isolate), Value);
- CALLBACK_LIST(SET_HIDDEN_PROPERTY)
-#undef SET_HIDDEN_PROPERTY
+ CALLBACK_LIST(SET_HIDDEN_VALUE)
+#undef SET_HIDDEN_VALUE
return adoptRef(new V8CustomElementLifecycleCallbacks(executionContext, prototype, created, attached, detached, attributeChanged));
}
diff --git a/Source/bindings/v8/V8DOMActivityLogger.cpp b/Source/bindings/v8/V8DOMActivityLogger.cpp
new file mode 100644
index 0000000..d671ac5
--- /dev/null
+++ b/Source/bindings/v8/V8DOMActivityLogger.cpp
@@ -0,0 +1,35 @@
+// Copyright 2014 The Chromium Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+#include "config.h"
+#include "bindings/v8/V8DOMActivityLogger.h"
+
+#include "bindings/v8/V8Binding.h"
+#include "wtf/HashMap.h"
+#include "wtf/MainThread.h"
+
+namespace WebCore {
+
+typedef HashMap<int, OwnPtr<V8DOMActivityLogger>, WTF::IntHash<int>, WTF::UnsignedWithZeroKeyHashTraits<int> > DOMActivityLoggerMap;
+
+static DOMActivityLoggerMap& domActivityLoggers()
+{
+ ASSERT(isMainThread());
+ DEFINE_STATIC_LOCAL(DOMActivityLoggerMap, map, ());
+ return map;
+}
+
+void V8DOMActivityLogger::setActivityLogger(int worldId, PassOwnPtr<V8DOMActivityLogger> logger)
+{
+ domActivityLoggers().set(worldId, logger);
+}
+
+V8DOMActivityLogger* V8DOMActivityLogger::activityLogger(int worldId)
+{
+ DOMActivityLoggerMap& loggers = domActivityLoggers();
+ DOMActivityLoggerMap::iterator it = loggers.find(worldId);
+ return it == loggers.end() ? 0 : it->value.get();
+}
+
+} // namespace WebCore
diff --git a/Source/bindings/v8/V8DOMActivityLogger.h b/Source/bindings/v8/V8DOMActivityLogger.h
index 93915a6..54c653d 100644
--- a/Source/bindings/v8/V8DOMActivityLogger.h
+++ b/Source/bindings/v8/V8DOMActivityLogger.h
@@ -31,8 +31,9 @@
#ifndef V8DOMActivityLogger_h
#define V8DOMActivityLogger_h
-#include <v8.h>
+#include "wtf/PassOwnPtr.h"
#include "wtf/text/WTFString.h"
+#include <v8.h>
namespace WebCore {
@@ -41,6 +42,11 @@
virtual ~V8DOMActivityLogger() { }
virtual void log(const String& apiName, int argc, const v8::Handle<v8::Value>* argv, const String& extraInfo) { }
+
+ // Associates a logger with the world identified by worldId (worlId may be 0
+ // identifying the main world).
+ static void setActivityLogger(int worldId, PassOwnPtr<V8DOMActivityLogger>);
+ static V8DOMActivityLogger* activityLogger(int worldId);
};
} // namespace WebCore
diff --git a/Source/bindings/v8/V8DOMConfiguration.cpp b/Source/bindings/v8/V8DOMConfiguration.cpp
index a4e1657..ffbee35 100644
--- a/Source/bindings/v8/V8DOMConfiguration.cpp
+++ b/Source/bindings/v8/V8DOMConfiguration.cpp
@@ -33,18 +33,19 @@
namespace WebCore {
-void V8DOMConfiguration::installAttributes(v8::Handle<v8::ObjectTemplate> instanceTemplate, v8::Handle<v8::ObjectTemplate> prototype, const AttributeConfiguration* attributes, size_t attributeCount, v8::Isolate* isolate, WrapperWorldType currentWorldType)
+void V8DOMConfiguration::installAttributes(v8::Handle<v8::ObjectTemplate> instanceTemplate, v8::Handle<v8::ObjectTemplate> prototype, const AttributeConfiguration* attributes, size_t attributeCount, v8::Isolate* isolate)
{
for (size_t i = 0; i < attributeCount; ++i)
- installAttribute(instanceTemplate, prototype, attributes[i], isolate, currentWorldType);
+ installAttribute(instanceTemplate, prototype, attributes[i], isolate);
}
-void V8DOMConfiguration::installAccessors(v8::Handle<v8::ObjectTemplate> prototype, v8::Handle<v8::Signature> signature, const AccessorConfiguration* accessors, size_t accessorCount, v8::Isolate* isolate, WrapperWorldType currentWorldType)
+void V8DOMConfiguration::installAccessors(v8::Handle<v8::ObjectTemplate> prototype, v8::Handle<v8::Signature> signature, const AccessorConfiguration* accessors, size_t accessorCount, v8::Isolate* isolate)
{
+ bool isMainWorld = DOMWrapperWorld::current(isolate)->isMainWorld();
for (size_t i = 0; i < accessorCount; ++i) {
v8::FunctionCallback getterCallback = accessors[i].getter;
v8::FunctionCallback setterCallback = accessors[i].setter;
- if (currentWorldType == MainWorld) {
+ if (isMainWorld) {
if (accessors[i].getterForMainWorld)
getterCallback = accessors[i].getterForMainWorld;
if (accessors[i].setterForMainWorld)
@@ -75,11 +76,12 @@
}
}
-void V8DOMConfiguration::installCallbacks(v8::Handle<v8::ObjectTemplate> prototype, v8::Handle<v8::Signature> signature, v8::PropertyAttribute attributes, const MethodConfiguration* callbacks, size_t callbackCount, v8::Isolate* isolate, WrapperWorldType currentWorldType)
+void V8DOMConfiguration::installCallbacks(v8::Handle<v8::ObjectTemplate> prototype, v8::Handle<v8::Signature> signature, v8::PropertyAttribute attributes, const MethodConfiguration* callbacks, size_t callbackCount, v8::Isolate* isolate)
{
+ bool isMainWorld = DOMWrapperWorld::current(isolate)->isMainWorld();
for (size_t i = 0; i < callbackCount; ++i) {
v8::FunctionCallback callback = callbacks[i].callback;
- if (currentWorldType == MainWorld && callbacks[i].callbackForMainWorld)
+ if (isMainWorld && callbacks[i].callbackForMainWorld)
callback = callbacks[i].callbackForMainWorld;
v8::Local<v8::FunctionTemplate> functionTemplate = v8::FunctionTemplate::New(isolate, callback, v8Undefined(), signature, callbacks[i].length);
functionTemplate->RemovePrototype();
@@ -91,7 +93,7 @@
const AttributeConfiguration* attributes, size_t attributeCount,
const AccessorConfiguration* accessors, size_t accessorCount,
const MethodConfiguration* callbacks, size_t callbackCount,
- v8::Isolate* isolate, WrapperWorldType currentWorldType)
+ v8::Isolate* isolate)
{
functionDescriptor->SetClassName(v8AtomicString(isolate, interfaceName));
v8::Local<v8::ObjectTemplate> instanceTemplate = functionDescriptor->InstanceTemplate();
@@ -107,11 +109,11 @@
v8::Local<v8::Signature> defaultSignature = v8::Signature::New(isolate, functionDescriptor);
if (attributeCount)
- installAttributes(instanceTemplate, functionDescriptor->PrototypeTemplate(), attributes, attributeCount, isolate, currentWorldType);
+ installAttributes(instanceTemplate, functionDescriptor->PrototypeTemplate(), attributes, attributeCount, isolate);
if (accessorCount)
- installAccessors(functionDescriptor->PrototypeTemplate(), defaultSignature, accessors, accessorCount, isolate, currentWorldType);
+ installAccessors(functionDescriptor->PrototypeTemplate(), defaultSignature, accessors, accessorCount, isolate);
if (callbackCount)
- installCallbacks(functionDescriptor->PrototypeTemplate(), defaultSignature, static_cast<v8::PropertyAttribute>(v8::DontDelete), callbacks, callbackCount, isolate, currentWorldType);
+ installCallbacks(functionDescriptor->PrototypeTemplate(), defaultSignature, static_cast<v8::PropertyAttribute>(v8::DontDelete), callbacks, callbackCount, isolate);
return defaultSignature;
}
diff --git a/Source/bindings/v8/V8DOMConfiguration.h b/Source/bindings/v8/V8DOMConfiguration.h
index baa2cf6..29f1958 100644
--- a/Source/bindings/v8/V8DOMConfiguration.h
+++ b/Source/bindings/v8/V8DOMConfiguration.h
@@ -69,25 +69,14 @@
v8::PropertyAttribute attribute;
};
- static void installAttributes(v8::Handle<v8::ObjectTemplate>, v8::Handle<v8::ObjectTemplate>, const AttributeConfiguration*, size_t attributeCount, v8::Isolate*, WrapperWorldType currentWorldType);
+ static void installAttributes(v8::Handle<v8::ObjectTemplate>, v8::Handle<v8::ObjectTemplate>, const AttributeConfiguration*, size_t attributeCount, v8::Isolate*);
template<class ObjectOrTemplate>
static inline void installAttribute(v8::Handle<ObjectOrTemplate> instanceTemplate, v8::Handle<ObjectOrTemplate> prototype, const AttributeConfiguration& attribute, v8::Isolate* isolate)
{
- (attribute.onPrototype ? prototype : instanceTemplate)->SetAccessor(v8::String::NewFromUtf8(isolate, attribute.name, v8::String::kInternalizedString),
- attribute.getter,
- attribute.setter,
- v8::External::New(isolate, const_cast<WrapperTypeInfo*>(attribute.data)),
- attribute.settings,
- attribute.attribute);
- }
-
- template<class ObjectOrTemplate>
- static inline void installAttribute(v8::Handle<ObjectOrTemplate> instanceTemplate, v8::Handle<ObjectOrTemplate> prototype, const AttributeConfiguration& attribute, v8::Isolate* isolate, WrapperWorldType currentWorldType)
- {
v8::AccessorGetterCallback getter = attribute.getter;
v8::AccessorSetterCallback setter = attribute.setter;
- if (currentWorldType == MainWorld) {
+ if (DOMWrapperWorld::current(isolate)->isMainWorld()) {
if (attribute.getterForMainWorld)
getter = attribute.getterForMainWorld;
if (attribute.setterForMainWorld)
@@ -120,15 +109,15 @@
int length;
};
- static void installCallbacks(v8::Handle<v8::ObjectTemplate>, v8::Handle<v8::Signature>, v8::PropertyAttribute, const MethodConfiguration*, size_t callbackCount, v8::Isolate*, WrapperWorldType);
+ static void installCallbacks(v8::Handle<v8::ObjectTemplate>, v8::Handle<v8::Signature>, v8::PropertyAttribute, const MethodConfiguration*, size_t callbackCount, v8::Isolate*);
- static void installAccessors(v8::Handle<v8::ObjectTemplate>, v8::Handle<v8::Signature>, const AccessorConfiguration*, size_t accessorCount, v8::Isolate*, WrapperWorldType);
+ static void installAccessors(v8::Handle<v8::ObjectTemplate>, v8::Handle<v8::Signature>, const AccessorConfiguration*, size_t accessorCount, v8::Isolate*);
static v8::Local<v8::Signature> installDOMClassTemplate(v8::Handle<v8::FunctionTemplate>, const char* interfaceName, v8::Handle<v8::FunctionTemplate> parentClass, size_t fieldCount,
const AttributeConfiguration*, size_t attributeCount,
const AccessorConfiguration*, size_t accessorCount,
const MethodConfiguration*, size_t callbackCount,
- v8::Isolate*, WrapperWorldType);
+ v8::Isolate*);
};
} // namespace WebCore
diff --git a/Source/bindings/v8/V8DOMWrapper.cpp b/Source/bindings/v8/V8DOMWrapper.cpp
index ce81b7a..ed73ce3 100644
--- a/Source/bindings/v8/V8DOMWrapper.cpp
+++ b/Source/bindings/v8/V8DOMWrapper.cpp
@@ -43,19 +43,17 @@
static v8::Local<v8::Object> wrapInShadowTemplate(v8::Local<v8::Object> wrapper, Node* impl, v8::Isolate* isolate)
{
- // This is only for getting a unique pointer which we can pass to privateTemplate.
- static int shadowTemplateUniqueKey;
- WrapperWorldType currentWorldType = worldType(isolate);
+ static int shadowTemplateKey; // This address is used for a key to look up the dom template.
V8PerIsolateData* data = V8PerIsolateData::from(isolate);
- v8::Handle<v8::FunctionTemplate> shadowTemplate = data->privateTemplateIfExists(currentWorldType, &shadowTemplateUniqueKey);
+ v8::Handle<v8::FunctionTemplate> shadowTemplate = data->existingDOMTemplate(&shadowTemplateKey);
if (shadowTemplate.IsEmpty()) {
shadowTemplate = v8::FunctionTemplate::New(isolate);
if (shadowTemplate.IsEmpty())
return v8::Local<v8::Object>();
shadowTemplate->SetClassName(v8AtomicString(isolate, "HTMLDocument"));
- shadowTemplate->Inherit(V8HTMLDocument::domTemplate(isolate, currentWorldType));
+ shadowTemplate->Inherit(V8HTMLDocument::domTemplate(isolate));
shadowTemplate->InstanceTemplate()->SetInternalFieldCount(V8HTMLDocument::internalFieldCount);
- data->setPrivateTemplate(currentWorldType, &shadowTemplateUniqueKey, shadowTemplate);
+ data->setDOMTemplate(&shadowTemplateKey, shadowTemplate);
}
v8::Local<v8::Function> shadowConstructor = shadowTemplate->GetFunction();
@@ -75,7 +73,7 @@
V8WrapperInstantiationScope scope(creationContext, isolate);
V8PerContextData* perContextData = V8PerContextData::from(scope.context());
- v8::Local<v8::Object> wrapper = perContextData ? perContextData->createWrapperFromCache(type) : V8ObjectConstructor::newInstance(type->domTemplate(isolate, worldTypeInMainThread(isolate))->GetFunction());
+ v8::Local<v8::Object> wrapper = perContextData ? perContextData->createWrapperFromCache(type) : V8ObjectConstructor::newInstance(type->domTemplate(isolate)->GetFunction());
if (type == &V8HTMLDocument::wrapperTypeInfo && !wrapper.IsEmpty())
wrapper = wrapInShadowTemplate(wrapper, static_cast<Node*>(impl), isolate);
diff --git a/Source/bindings/v8/V8DOMWrapper.h b/Source/bindings/v8/V8DOMWrapper.h
index bc078e4..5895996 100644
--- a/Source/bindings/v8/V8DOMWrapper.h
+++ b/Source/bindings/v8/V8DOMWrapper.h
@@ -48,7 +48,7 @@
template<typename V8T, typename T>
static inline v8::Handle<v8::Object> associateObjectWithWrapper(PassRefPtr<T>, const WrapperTypeInfo*, v8::Handle<v8::Object>, v8::Isolate*, WrapperConfiguration::Lifetime);
template<typename V8T, typename T>
- static inline v8::Handle<v8::Object> associateObjectWithWrapper(RawPtr<T>, const WrapperTypeInfo*, v8::Handle<v8::Object>, v8::Isolate*, WrapperConfiguration::Lifetime);
+ static inline v8::Handle<v8::Object> associateObjectWithWrapper(RawPtr<T> object, const WrapperTypeInfo* type, v8::Handle<v8::Object> wrapper, v8::Isolate* isolate, WrapperConfiguration::Lifetime lifetime) { return associateObjectWithWrapper<V8T, T>(object.get(), type, wrapper, isolate, lifetime); }
template<typename V8T, typename T>
static inline v8::Handle<v8::Object> associateObjectWithWrapper(T*, const WrapperTypeInfo*, v8::Handle<v8::Object>, v8::Isolate*, WrapperConfiguration::Lifetime);
static inline void setNativeInfo(v8::Handle<v8::Object>, const WrapperTypeInfo*, void*);
@@ -103,12 +103,12 @@
}
template<typename V8T, typename T>
- inline v8::Handle<v8::Object> V8DOMWrapper::associateObjectWithWrapper(RawPtr<T> object, const WrapperTypeInfo* type, v8::Handle<v8::Object> wrapper, v8::Isolate* isolate, WrapperConfiguration::Lifetime lifetime)
+ inline v8::Handle<v8::Object> V8DOMWrapper::associateObjectWithWrapper(T* object, const WrapperTypeInfo* type, v8::Handle<v8::Object> wrapper, v8::Isolate* isolate, WrapperConfiguration::Lifetime lifetime)
{
- setNativeInfoWithPersistentHandle(wrapper, type, V8T::toInternalPointer(object.get()), new Persistent<T>(object));
+ setNativeInfoWithPersistentHandle(wrapper, type, V8T::toInternalPointer(object), new Persistent<T>(object));
ASSERT(isDOMWrapper(wrapper));
- WrapperConfiguration configuration = buildWrapperConfiguration(object.get(), lifetime);
- DOMDataStore::setWrapper<V8T>(object.get(), wrapper, isolate, configuration);
+ WrapperConfiguration configuration = buildWrapperConfiguration(object, lifetime);
+ DOMDataStore::setWrapper<V8T>(object, wrapper, isolate, configuration);
return wrapper;
}
diff --git a/Source/bindings/v8/V8ErrorHandler.cpp b/Source/bindings/v8/V8ErrorHandler.cpp
index c9691b7..b70ef20 100644
--- a/Source/bindings/v8/V8ErrorHandler.cpp
+++ b/Source/bindings/v8/V8ErrorHandler.cpp
@@ -34,12 +34,13 @@
#include "V8ErrorEvent.h"
#include "bindings/v8/ScriptController.h"
#include "bindings/v8/V8Binding.h"
+#include "bindings/v8/V8HiddenValue.h"
#include "bindings/v8/V8ScriptRunner.h"
#include "core/dom/Document.h"
#include "core/dom/ExecutionContext.h"
#include "core/events/ErrorEvent.h"
#include "core/events/ThreadLocalEventNames.h"
-#include "core/frame/Frame.h"
+#include "core/frame/LocalFrame.h"
namespace WebCore {
@@ -65,14 +66,14 @@
v8::Local<v8::Function> callFunction = v8::Local<v8::Function>::Cast(listener);
v8::Local<v8::Object> thisValue = isolate->GetCurrentContext()->Global();
- v8::Local<v8::Value> error = getHiddenValue(isolate, jsEvent->ToObject(), "error");
+ v8::Local<v8::Value> error = V8HiddenValue::getHiddenValue(isolate, jsEvent->ToObject(), V8HiddenValue::error(isolate));
if (error.IsEmpty())
error = v8::Null(isolate);
v8::Handle<v8::Value> parameters[5] = { v8String(isolate, errorEvent->message()), v8String(isolate, errorEvent->filename()), v8::Integer::New(isolate, errorEvent->lineno()), v8::Integer::New(isolate, errorEvent->colno()), error };
v8::TryCatch tryCatch;
tryCatch.SetVerbose(true);
- if (worldType(isolate) == WorkerWorld)
+ if (DOMWrapperWorld::current(isolate)->isWorkerWorld())
returnValue = V8ScriptRunner::callFunction(callFunction, context, thisValue, WTF_ARRAY_LENGTH(parameters), parameters, isolate);
else
returnValue = ScriptController::callFunction(context, callFunction, thisValue, WTF_ARRAY_LENGTH(parameters), parameters, isolate);
@@ -86,7 +87,7 @@
v8::Local<v8::Value> wrappedEvent = toV8(event, v8::Handle<v8::Object>(), isolate);
if (!wrappedEvent.IsEmpty()) {
ASSERT(wrappedEvent->IsObject());
- setHiddenValue(isolate, v8::Local<v8::Object>::Cast(wrappedEvent), "error", data);
+ V8HiddenValue::setHiddenValue(isolate, v8::Local<v8::Object>::Cast(wrappedEvent), V8HiddenValue::error(isolate), data);
}
}
diff --git a/Source/bindings/v8/V8ErrorHandler.h b/Source/bindings/v8/V8ErrorHandler.h
index 8412e41..74882d3 100644
--- a/Source/bindings/v8/V8ErrorHandler.h
+++ b/Source/bindings/v8/V8ErrorHandler.h
@@ -38,7 +38,7 @@
namespace WebCore {
class ErrorEvent;
-class Frame;
+class LocalFrame;
class V8ErrorHandler FINAL : public V8EventListener {
public:
diff --git a/Source/bindings/v8/V8EventListener.cpp b/Source/bindings/v8/V8EventListener.cpp
index 1bdfe18..207bdf5 100644
--- a/Source/bindings/v8/V8EventListener.cpp
+++ b/Source/bindings/v8/V8EventListener.cpp
@@ -34,7 +34,7 @@
#include "bindings/v8/ScriptController.h"
#include "bindings/v8/V8Binding.h"
#include "core/dom/Document.h"
-#include "core/frame/Frame.h"
+#include "core/frame/LocalFrame.h"
namespace WebCore {
@@ -82,7 +82,7 @@
if (!context->isDocument())
return v8::Local<v8::Value>();
- Frame* frame = toDocument(context)->frame();
+ LocalFrame* frame = toDocument(context)->frame();
if (!frame)
return v8::Local<v8::Value>();
diff --git a/Source/bindings/v8/V8EventListener.h b/Source/bindings/v8/V8EventListener.h
index 4cb85fc..772525e 100644
--- a/Source/bindings/v8/V8EventListener.h
+++ b/Source/bindings/v8/V8EventListener.h
@@ -38,7 +38,7 @@
namespace WebCore {
class Event;
- class Frame;
+ class LocalFrame;
// V8EventListener is a wrapper of a JS object implements EventListener interface (has handleEvent(event) method), or a JS function
// that can handle the event.
diff --git a/Source/bindings/v8/V8EventListenerList.cpp b/Source/bindings/v8/V8EventListenerList.cpp
index f08e51b..31d9392 100644
--- a/Source/bindings/v8/V8EventListenerList.cpp
+++ b/Source/bindings/v8/V8EventListenerList.cpp
@@ -42,7 +42,7 @@
v8::Isolate* isolate = v8::Isolate::GetCurrent();
v8::Handle<v8::Context> context = isolate->GetCurrentContext();
if (context.IsEmpty())
- return 0;
+ return nullptr;
if (lookup == ListenerFindOnly) {
// Used by EventTarget::removeEventListener, specifically
// EventTargetV8Internal::removeEventListenerMethod
diff --git a/Source/bindings/v8/V8EventListenerList.h b/Source/bindings/v8/V8EventListenerList.h
index 8df7e1a..ec3493a 100644
--- a/Source/bindings/v8/V8EventListenerList.h
+++ b/Source/bindings/v8/V8EventListenerList.h
@@ -36,7 +36,7 @@
namespace WebCore {
-class Frame;
+class LocalFrame;
enum ListenerLookupType {
ListenerFindOnly,
@@ -50,7 +50,7 @@
{
ASSERT(isolate->InContext());
if (!value->IsObject())
- return 0;
+ return nullptr;
v8::Handle<v8::String> wrapperProperty = getHiddenProperty(false, isolate);
return doFindWrapper(v8::Local<v8::Object>::Cast(value), wrapperProperty, isolate);
@@ -62,7 +62,7 @@
static void clearWrapper(v8::Handle<v8::Object> listenerObject, bool isAttribute, v8::Isolate* isolate)
{
v8::Handle<v8::String> wrapperProperty = getHiddenProperty(isAttribute, isolate);
- deleteHiddenValue(isolate, listenerObject, wrapperProperty);
+ listenerObject->DeleteHiddenValue(wrapperProperty);
}
static PassRefPtr<EventListener> getEventListener(v8::Local<v8::Value>, bool isAttribute, ListenerLookupType);
@@ -72,7 +72,7 @@
{
ASSERT(isolate->InContext());
v8::HandleScope scope(isolate);
- v8::Local<v8::Value> listener = getHiddenValue(isolate, object, wrapperProperty);
+ v8::Local<v8::Value> listener = object->GetHiddenValue(wrapperProperty);
if (listener.IsEmpty())
return 0;
return static_cast<V8EventListener*>(v8::External::Cast(*listener)->Value());
@@ -91,7 +91,7 @@
if (!value->IsObject()
// Non-callable attribute setter input is treated as null (no wrapper)
|| (isAttribute && !value->IsFunction()))
- return 0;
+ return nullptr;
v8::Local<v8::Object> object = v8::Local<v8::Object>::Cast(value);
v8::Handle<v8::String> wrapperProperty = getHiddenProperty(isAttribute, isolate);
@@ -102,7 +102,7 @@
RefPtr<V8EventListener> wrapperPtr = WrapperType::create(object, isAttribute, isolate);
if (wrapperPtr)
- setHiddenValue(isolate, object, wrapperProperty, v8::External::New(isolate, wrapperPtr.get()));
+ object->SetHiddenValue(wrapperProperty, v8::External::New(isolate, wrapperPtr.get()));
return wrapperPtr;
}
diff --git a/Source/bindings/v8/V8GCController.cpp b/Source/bindings/v8/V8GCController.cpp
index 29a5c81..bffb6fc 100644
--- a/Source/bindings/v8/V8GCController.cpp
+++ b/Source/bindings/v8/V8GCController.cpp
@@ -70,11 +70,12 @@
Node* V8GCController::opaqueRootForGC(Node* node, v8::Isolate*)
{
+ ASSERT(node);
// FIXME: Remove the special handling for image elements.
// The same special handling is in V8GCController::gcTree().
// Maybe should image elements be active DOM nodes?
// See https://code.google.com/p/chromium/issues/detail?id=164882
- if (node->inDocument() || (node->hasTagName(HTMLNames::imgTag) && toHTMLImageElement(node)->hasPendingActivity()))
+ if (node->inDocument() || (isHTMLImageElement(*node) && toHTMLImageElement(*node).hasPendingActivity()))
return &node->document();
if (node->isAttributeNode()) {
@@ -134,7 +135,7 @@
// The same special handling is in V8GCController::opaqueRootForGC().
// Maybe should image elements be active DOM nodes?
// See https://code.google.com/p/chromium/issues/detail?id=164882
- if (node->hasTagName(HTMLNames::imgTag) && toHTMLImageElement(node)->hasPendingActivity())
+ if (isHTMLImageElement(*node) && toHTMLImageElement(*node).hasPendingActivity())
return;
// FIXME: Remove the special handling for SVG context elements.
if (node->isSVGElement() && toSVGElement(node)->isContextElement())
@@ -187,8 +188,8 @@
}
// <template> has a |content| property holding a DOM fragment which we must traverse,
// just like we do for the shadow trees above.
- if (node->hasTagName(HTMLNames::templateTag)) {
- if (!traverseTree(toHTMLTemplateElement(node)->content(), partiallyDependentNodes))
+ if (isHTMLTemplateElement(*node)) {
+ if (!traverseTree(toHTMLTemplateElement(*node).content(), partiallyDependentNodes))
return false;
}
}
@@ -390,24 +391,9 @@
TRACE_EVENT_SET_NONCONST_SAMPLING_STATE(V8PerIsolateData::from(isolate)->previousSamplingState());
}
-void V8GCController::hintForCollectGarbage()
-{
- V8PerIsolateData* data = V8PerIsolateData::current();
- if (!data->shouldCollectGarbageSoon())
- return;
- const int longIdlePauseInMS = 1000;
- data->clearShouldCollectGarbageSoon();
- v8::V8::ContextDisposedNotification();
- v8::V8::IdleNotification(longIdlePauseInMS);
-}
-
void V8GCController::collectGarbage(v8::Isolate* isolate)
{
- v8::HandleScope handleScope(isolate);
- v8::Local<v8::Context> context = v8::Context::New(isolate);
- if (context.IsEmpty())
- return;
- v8::Context::Scope contextScope(context);
+ V8ExecutionScope scope(isolate);
V8ScriptRunner::compileAndRunInternalScript(v8String(isolate, "if (gc) gc();"), isolate);
}
diff --git a/Source/bindings/v8/V8GCController.h b/Source/bindings/v8/V8GCController.h
index b0aa802..a493f27 100644
--- a/Source/bindings/v8/V8GCController.h
+++ b/Source/bindings/v8/V8GCController.h
@@ -47,7 +47,6 @@
static void majorGCPrologue(bool constructRetainedObjectInfos, v8::Isolate*);
static void majorGCEpilogue(v8::Isolate*);
- static void hintForCollectGarbage();
static void collectGarbage(v8::Isolate*);
static Node* opaqueRootForGC(Node*, v8::Isolate*);
diff --git a/Source/bindings/v8/V8GCForContextDispose.cpp b/Source/bindings/v8/V8GCForContextDispose.cpp
index e7d40bd..b9da910 100644
--- a/Source/bindings/v8/V8GCForContextDispose.cpp
+++ b/Source/bindings/v8/V8GCForContextDispose.cpp
@@ -46,7 +46,7 @@
m_didDisposeContextForMainFrame = m_didDisposeContextForMainFrame || isMainFrame;
v8::V8::ContextDisposedNotification();
if (!m_pseudoIdleTimer.isActive())
- m_pseudoIdleTimer.startOneShot(0.8);
+ m_pseudoIdleTimer.startOneShot(0.8, FROM_HERE);
}
void V8GCForContextDispose::notifyIdleSooner(double maximumFireInterval)
@@ -55,7 +55,7 @@
double nextFireInterval = m_pseudoIdleTimer.nextFireInterval();
if (nextFireInterval > maximumFireInterval) {
m_pseudoIdleTimer.stop();
- m_pseudoIdleTimer.startOneShot(maximumFireInterval);
+ m_pseudoIdleTimer.startOneShot(maximumFireInterval, FROM_HERE);
}
}
}
diff --git a/Source/bindings/v8/V8HiddenValue.cpp b/Source/bindings/v8/V8HiddenValue.cpp
new file mode 100644
index 0000000..ab6e97d
--- /dev/null
+++ b/Source/bindings/v8/V8HiddenValue.cpp
@@ -0,0 +1,46 @@
+// Copyright 2014 The Chromium Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+#include "config.h"
+#include "bindings/v8/V8HiddenValue.h"
+
+#include "bindings/v8/ScriptWrappable.h"
+#include "bindings/v8/V8Binding.h"
+
+namespace WebCore {
+
+#define V8_DEFINE_METHOD(name) \
+v8::Handle<v8::String> V8HiddenValue::name(v8::Isolate* isolate) \
+{ \
+ V8HiddenValue* hiddenValue = V8PerIsolateData::from(isolate)->hiddenValue(); \
+ if (hiddenValue->m_##name.isEmpty()) { \
+ hiddenValue->m_##name.set(isolate, v8AtomicString(isolate, #name)); \
+ } \
+ return hiddenValue->m_##name.newLocal(isolate); \
+}
+
+V8_HIDDEN_VALUES(V8_DEFINE_METHOD);
+
+v8::Local<v8::Value> V8HiddenValue::getHiddenValue(v8::Isolate* isolate, v8::Handle<v8::Object> object, v8::Handle<v8::String> key)
+{
+ return object->GetHiddenValue(key);
+}
+
+bool V8HiddenValue::setHiddenValue(v8::Isolate* isolate, v8::Handle<v8::Object> object, v8::Handle<v8::String> key, v8::Handle<v8::Value> value)
+{
+ return object->SetHiddenValue(key, value);
+}
+
+bool V8HiddenValue::deleteHiddenValue(v8::Isolate* isolate, v8::Handle<v8::Object> object, v8::Handle<v8::String> key)
+{
+ return object->DeleteHiddenValue(key);
+}
+
+v8::Local<v8::Value> V8HiddenValue::getHiddenValueFromMainWorldWrapper(v8::Isolate* isolate, ScriptWrappable* wrappable, v8::Handle<v8::String> key)
+{
+ v8::Local<v8::Object> wrapper = wrappable->newLocalWrapper(isolate);
+ return wrapper.IsEmpty() ? v8::Local<v8::Value>() : getHiddenValue(isolate, wrapper, key);
+}
+
+} // namespace WebCore
diff --git a/Source/bindings/v8/V8HiddenValue.h b/Source/bindings/v8/V8HiddenValue.h
new file mode 100644
index 0000000..75da4ef
--- /dev/null
+++ b/Source/bindings/v8/V8HiddenValue.h
@@ -0,0 +1,61 @@
+// Copyright 2014 The Chromium Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+#ifndef V8HiddenValue_h
+#define V8HiddenValue_h
+
+#include "bindings/v8/ScopedPersistent.h"
+#include <v8.h>
+
+namespace WebCore {
+
+class ScriptWrappable;
+
+#define V8_HIDDEN_VALUES(V) \
+ V(arrayBufferData) \
+ V(customElementAttached) \
+ V(customElementAttributeChanged) \
+ V(customElementCreated) \
+ V(customElementDetached) \
+ V(customElementDocument) \
+ V(customElementIsInterfacePrototypeObject) \
+ V(customElementNamespaceURI) \
+ V(customElementTagName) \
+ V(customElementType) \
+ V(callback) \
+ V(condition) \
+ V(data) \
+ V(detail) \
+ V(document) \
+ V(error) \
+ V(event) \
+ V(idbCursorRequest) \
+ V(port1) \
+ V(port2) \
+ V(state) \
+ V(stringData) \
+ V(scriptState) \
+ V(thenableHiddenPromise) \
+ V(toStringString)
+
+class V8HiddenValue {
+public:
+#define V8_DECLARE_METHOD(name) static v8::Handle<v8::String> name(v8::Isolate* isolate);
+ V8_HIDDEN_VALUES(V8_DECLARE_METHOD);
+#undef V8_DECLARE_METHOD
+
+ static v8::Local<v8::Value> getHiddenValue(v8::Isolate*, v8::Handle<v8::Object>, v8::Handle<v8::String>);
+ static bool setHiddenValue(v8::Isolate*, v8::Handle<v8::Object>, v8::Handle<v8::String>, v8::Handle<v8::Value>);
+ static bool deleteHiddenValue(v8::Isolate*, v8::Handle<v8::Object>, v8::Handle<v8::String>);
+ static v8::Local<v8::Value> getHiddenValueFromMainWorldWrapper(v8::Isolate*, ScriptWrappable*, v8::Handle<v8::String>);
+
+private:
+#define V8_DECLARE_FIELD(name) ScopedPersistent<v8::String> m_##name;
+ V8_HIDDEN_VALUES(V8_DECLARE_FIELD);
+#undef V8_DECLARE_FIELD
+};
+
+} // namespace WebCore
+
+#endif // V8HiddenValue_h
diff --git a/Source/bindings/v8/V8Initializer.cpp b/Source/bindings/v8/V8Initializer.cpp
index f6c0f52..ed0edf1 100644
--- a/Source/bindings/v8/V8Initializer.cpp
+++ b/Source/bindings/v8/V8Initializer.cpp
@@ -41,11 +41,12 @@
#include "bindings/v8/V8PerContextData.h"
#include "core/dom/Document.h"
#include "core/dom/ExceptionCode.h"
-#include "core/inspector/ScriptCallStack.h"
#include "core/frame/ConsoleTypes.h"
-#include "core/frame/ContentSecurityPolicy.h"
#include "core/frame/DOMWindow.h"
-#include "core/frame/Frame.h"
+#include "core/frame/LocalFrame.h"
+#include "core/frame/csp/ContentSecurityPolicy.h"
+#include "core/inspector/ScriptCallStack.h"
+#include "platform/TraceEvent.h"
#include "public/platform/Platform.h"
#include "wtf/RefPtr.h"
#include "wtf/text/WTFString.h"
@@ -53,12 +54,12 @@
namespace WebCore {
-static Frame* findFrame(v8::Local<v8::Object> host, v8::Local<v8::Value> data, v8::Isolate* isolate)
+static LocalFrame* findFrame(v8::Local<v8::Object> host, v8::Local<v8::Value> data, v8::Isolate* isolate)
{
const WrapperTypeInfo* type = WrapperTypeInfo::unwrap(data);
if (V8Window::wrapperTypeInfo.equals(type)) {
- v8::Handle<v8::Object> windowWrapper = host->FindInstanceInPrototypeChain(V8Window::domTemplate(isolate, worldTypeInMainThread(isolate)));
+ v8::Handle<v8::Object> windowWrapper = V8Window::findInstanceInPrototypeChain(host, isolate);
if (windowWrapper.IsEmpty())
return 0;
return V8Window::toNative(windowWrapper)->frame();
@@ -85,13 +86,9 @@
static void messageHandlerInMainThread(v8::Handle<v8::Message> message, v8::Handle<v8::Value> data)
{
v8::Isolate* isolate = v8::Isolate::GetCurrent();
- // If called during context initialization, there will be no entered context.
- v8::Handle<v8::Context> enteredContext = isolate->GetEnteredContext();
- if (enteredContext.IsEmpty())
- return;
-
- DOMWindow* firstWindow = toDOMWindow(enteredContext);
- if (!firstWindow->isCurrentlyDisplayedInFrame())
+ // If called during context initialization, there will be no entered window.
+ DOMWindow* enteredWindow = enteredDOMWindow(isolate);
+ if (!enteredWindow || !enteredWindow->isCurrentlyDisplayedInFrame())
return;
String errorMessage = toCoreString(message->Get());
@@ -104,7 +101,7 @@
v8::Handle<v8::Value> resourceName = message->GetScriptResourceName();
bool shouldUseDocumentURL = resourceName.IsEmpty() || !resourceName->IsString();
- String resource = shouldUseDocumentURL ? firstWindow->document()->url() : toCoreString(resourceName.As<v8::String>());
+ String resource = shouldUseDocumentURL ? enteredWindow->document()->url() : toCoreString(resourceName.As<v8::String>());
AccessControlStatus corsStatus = message->IsSharedCrossOrigin() ? SharableCrossOrigin : NotSharableCrossOrigin;
DOMWrapperWorld* world = DOMWrapperWorld::current(isolate);
@@ -122,22 +119,23 @@
// 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?
- Frame* frame = firstWindow->document()->frame();
+ LocalFrame* frame = enteredWindow->document()->frame();
if (world && frame && frame->script().existingWindowShell(world))
V8ErrorHandler::storeExceptionOnErrorEventWrapper(event.get(), data, v8::Isolate::GetCurrent());
- firstWindow->document()->reportException(event.release(), callStack, corsStatus);
+ enteredWindow->document()->reportException(event.release(), callStack, corsStatus);
}
static void failedAccessCheckCallbackInMainThread(v8::Local<v8::Object> host, v8::AccessType type, v8::Local<v8::Value> data)
{
v8::Isolate* isolate = v8::Isolate::GetCurrent();
- Frame* target = findFrame(host, data, isolate);
+ LocalFrame* target = findFrame(host, data, isolate);
if (!target)
return;
DOMWindow* targetWindow = target->domWindow();
- ExceptionState exceptionState(v8::Handle<v8::Object>(), isolate);
- exceptionState.throwSecurityError(targetWindow->sanitizedCrossDomainAccessErrorMessage(activeDOMWindow(isolate)), targetWindow->crossDomainAccessErrorMessage(activeDOMWindow(isolate)));
+ // FIXME: We should modify V8 to pass in more contextual information (context, property, and object).
+ ExceptionState exceptionState(ExceptionState::UnknownContext, 0, 0, v8::Handle<v8::Object>(), isolate);
+ exceptionState.throwSecurityError(targetWindow->sanitizedCrossDomainAccessErrorMessage(callingDOMWindow(isolate)), targetWindow->crossDomainAccessErrorMessage(callingDOMWindow(isolate)));
exceptionState.throwIfNeeded();
}
@@ -145,11 +143,20 @@
{
if (ExecutionContext* executionContext = toExecutionContext(context)) {
if (ContentSecurityPolicy* policy = toDocument(executionContext)->contentSecurityPolicy())
- return policy->allowScriptEval(ScriptState::forContext(context));
+ return policy->allowEval(ScriptState::forContext(context));
}
return false;
}
+static void timerTraceProfilerInMainThread(const char* name, int status)
+{
+ if (!status) {
+ TRACE_EVENT_BEGIN0("V8", name);
+ } else {
+ TRACE_EVENT_END0("V8", name);
+ }
+}
+
static void initializeV8Common(v8::Isolate* isolate)
{
v8::ResourceConstraints constraints;
@@ -158,7 +165,6 @@
v8::V8::AddGCPrologueCallback(V8GCController::gcPrologue);
v8::V8::AddGCEpilogueCallback(V8GCController::gcEpilogue);
- v8::V8::IgnoreOutOfMemoryException();
v8::Debug::SetLiveEditEnabled(false);
}
@@ -179,6 +185,9 @@
v8::V8::AddMessageListener(messageHandlerInMainThread);
v8::V8::SetFailedAccessCheckCallbackFunction(failedAccessCheckCallbackInMainThread);
v8::V8::SetAllowCodeGenerationFromStringsCallback(codeGenerationCheckCallbackInMainThread);
+
+ isolate->SetEventLogger(timerTraceProfilerInMainThread);
+
ScriptProfiler::initialize();
}
@@ -207,7 +216,7 @@
AccessControlStatus corsStatus = message->IsSharedCrossOrigin() ? SharableCrossOrigin : NotSharableCrossOrigin;
V8ErrorHandler::storeExceptionOnErrorEventWrapper(event.get(), data, isolate);
- context->reportException(event.release(), 0, corsStatus);
+ context->reportException(event.release(), nullptr, corsStatus);
}
isReportingException = false;
diff --git a/Source/bindings/v8/V8LazyEventListener.cpp b/Source/bindings/v8/V8LazyEventListener.cpp
index 030a1d4..da430bd 100644
--- a/Source/bindings/v8/V8LazyEventListener.cpp
+++ b/Source/bindings/v8/V8LazyEventListener.cpp
@@ -38,14 +38,15 @@
#include "bindings/v8/ScriptSourceCode.h"
#include "bindings/v8/V8Binding.h"
#include "bindings/v8/V8DOMWrapper.h"
+#include "bindings/v8/V8HiddenValue.h"
#include "bindings/v8/V8ScriptRunner.h"
#include "core/dom/Document.h"
#include "core/dom/Node.h"
#include "core/html/HTMLElement.h"
#include "core/html/HTMLFormElement.h"
#include "core/inspector/InspectorInstrumentation.h"
-#include "core/frame/ContentSecurityPolicy.h"
-#include "core/frame/Frame.h"
+#include "core/frame/LocalFrame.h"
+#include "core/frame/csp/ContentSecurityPolicy.h"
#include "wtf/StdLibExtras.h"
@@ -91,7 +92,7 @@
if (!context->isDocument())
return v8::Local<v8::Value>();
- Frame* frame = toDocument(context)->frame();
+ LocalFrame* frame = toDocument(context)->frame();
if (!frame)
return v8::Local<v8::Value>();
@@ -104,7 +105,7 @@
static void V8LazyEventListenerToString(const v8::FunctionCallbackInfo<v8::Value>& info)
{
- v8SetReturnValue(info, getHiddenValue(info.GetIsolate(), info.Holder(), "toStringString"));
+ v8SetReturnValue(info, V8HiddenValue::getHiddenValue(info.GetIsolate(), info.Holder(), V8HiddenValue::toStringString(info.GetIsolate())));
}
void V8LazyEventListener::prepareListenerObject(ExecutionContext* context)
@@ -204,7 +205,7 @@
v8::Local<v8::Function> toStringFunction = v8::Function::New(isolate, V8LazyEventListenerToString);
ASSERT(!toStringFunction.IsEmpty());
String toStringString = "function " + m_functionName + "(" + m_eventParameterName + ") {\n " + m_code + "\n}";
- setHiddenValue(isolate, wrappedFunction, "toStringString", v8String(isolate, toStringString));
+ V8HiddenValue::setHiddenValue(isolate, wrappedFunction, V8HiddenValue::toStringString(isolate), v8String(isolate, toStringString));
wrappedFunction->Set(v8AtomicString(isolate, "toString"), toStringFunction);
wrappedFunction->SetName(v8String(isolate, m_functionName));
diff --git a/Source/bindings/v8/V8LazyEventListener.h b/Source/bindings/v8/V8LazyEventListener.h
index f86e01c..283d008 100644
--- a/Source/bindings/v8/V8LazyEventListener.h
+++ b/Source/bindings/v8/V8LazyEventListener.h
@@ -40,7 +40,7 @@
namespace WebCore {
class Event;
- class Frame;
+ class LocalFrame;
class HTMLFormElement;
class Node;
diff --git a/Source/bindings/v8/V8MutationCallback.cpp b/Source/bindings/v8/V8MutationCallback.cpp
index c579382..da0320d 100644
--- a/Source/bindings/v8/V8MutationCallback.cpp
+++ b/Source/bindings/v8/V8MutationCallback.cpp
@@ -30,6 +30,7 @@
#include "V8MutationRecord.h"
#include "bindings/v8/ScriptController.h"
#include "bindings/v8/V8Binding.h"
+#include "bindings/v8/V8HiddenValue.h"
#include "core/dom/ExecutionContext.h"
#include "wtf/Assertions.h"
@@ -41,7 +42,7 @@
, m_world(DOMWrapperWorld::current(isolate))
, m_isolate(isolate)
{
- setHiddenValue(m_isolate, owner, "callback", callback);
+ V8HiddenValue::setHiddenValue(m_isolate, owner, V8HiddenValue::callback(m_isolate), callback);
m_callback.setWeak(this, &setWeakCallback);
}
diff --git a/Source/bindings/v8/V8MutationCallback.h b/Source/bindings/v8/V8MutationCallback.h
index 743ea98..0334b8b 100644
--- a/Source/bindings/v8/V8MutationCallback.h
+++ b/Source/bindings/v8/V8MutationCallback.h
@@ -29,7 +29,6 @@
#include "bindings/v8/ActiveDOMCallback.h"
#include "bindings/v8/DOMWrapperWorld.h"
#include "bindings/v8/ScopedPersistent.h"
-#include "bindings/v8/V8Utilities.h"
#include "core/dom/MutationCallback.h"
#include "wtf/OwnPtr.h"
#include "wtf/RefPtr.h"
diff --git a/Source/bindings/v8/V8NPObject.cpp b/Source/bindings/v8/V8NPObject.cpp
index 3899c67..a3f8ab7 100644
--- a/Source/bindings/v8/V8NPObject.cpp
+++ b/Source/bindings/v8/V8NPObject.cpp
@@ -69,20 +69,18 @@
static void npObjectInvokeImpl(const v8::FunctionCallbackInfo<v8::Value>& info, InvokeFunctionType functionId)
{
NPObject* npObject;
+ v8::Isolate* isolate = info.GetIsolate();
// These three types are subtypes of HTMLPlugInElement.
- if (V8HTMLAppletElement::hasInstance(info.Holder(), info.GetIsolate()) || V8HTMLEmbedElement::hasInstance(info.Holder(), info.GetIsolate())
- || V8HTMLObjectElement::hasInstance(info.Holder(), info.GetIsolate())) {
- // The holder object is a subtype of HTMLPlugInElement.
- HTMLPlugInElement* element;
- if (V8HTMLAppletElement::hasInstance(info.Holder(), info.GetIsolate()))
- element = V8HTMLAppletElement::toNative(info.Holder());
- else if (V8HTMLEmbedElement::hasInstance(info.Holder(), info.GetIsolate()))
- element = V8HTMLEmbedElement::toNative(info.Holder());
- else
- element = V8HTMLObjectElement::toNative(info.Holder());
+ HTMLPlugInElement* element = V8HTMLAppletElement::toNativeWithTypeCheck(isolate, info.Holder());
+ if (!element) {
+ element = V8HTMLEmbedElement::toNativeWithTypeCheck(isolate, info.Holder());
+ if (!element) {
+ element = V8HTMLObjectElement::toNativeWithTypeCheck(isolate, info.Holder());
+ }
+ }
+ if (element) {
if (RefPtr<SharedPersistent<v8::Object> > wrapper = element->pluginWrapper()) {
- v8::Isolate* isolate = v8::Isolate::GetCurrent();
v8::HandleScope handleScope(isolate);
npObject = v8ObjectToNPObject(wrapper->newLocal(isolate));
} else
@@ -100,7 +98,7 @@
// Verify that our wrapper wasn't using a NPObject which has already been deleted.
if (!npObject || !_NPN_IsAlive(npObject)) {
- throwError(v8ReferenceError, "NPObject deleted", info.GetIsolate());
+ throwError(v8ReferenceError, "NPObject deleted", isolate);
return;
}
@@ -109,7 +107,7 @@
OwnPtr<NPVariant[]> npArgs = adoptArrayPtr(new NPVariant[numArgs]);
for (int i = 0; i < numArgs; i++)
- convertV8ObjectToNPVariant(info[i], npObject, &npArgs[i], info.GetIsolate());
+ convertV8ObjectToNPVariant(info[i], npObject, &npArgs[i], isolate);
NPVariant result;
VOID_TO_NPVARIANT(result);
@@ -136,7 +134,7 @@
}
if (!retval)
- throwError(v8GeneralError, "Error calling method on NPObject.", info.GetIsolate());
+ throwError(v8GeneralError, "Error calling method on NPObject.", isolate);
for (int i = 0; i < numArgs; i++)
_NPN_ReleaseVariantValue(&npArgs[i]);
@@ -144,7 +142,7 @@
// Unwrap return values.
v8::Handle<v8::Value> returnValue;
if (_NPN_IsAlive(npObject))
- returnValue = convertNPVariantToV8Object(&result, npObject, info.GetIsolate());
+ returnValue = convertNPVariantToV8Object(&result, npObject, isolate);
_NPN_ReleaseVariantValue(&result);
v8SetReturnValue(info, returnValue);
diff --git a/Source/bindings/v8/V8NPUtils.cpp b/Source/bindings/v8/V8NPUtils.cpp
index bda952b..cba26eb 100644
--- a/Source/bindings/v8/V8NPUtils.cpp
+++ b/Source/bindings/v8/V8NPUtils.cpp
@@ -69,7 +69,7 @@
str->WriteUtf8(utf8Chars, length, 0, v8::String::HINT_MANY_WRITES_EXPECTED);
STRINGN_TO_NPVARIANT(utf8Chars, length-1, *result);
} else if (object->IsObject()) {
- DOMWindow* window = toDOMWindow(isolate->GetCurrentContext());
+ DOMWindow* window = currentDOMWindow(isolate);
NPObject* npobject = npCreateV8ScriptObject(0, v8::Handle<v8::Object>::Cast(object), window, isolate);
if (npobject)
_NPN_RegisterObject(npobject, owner);
diff --git a/Source/bindings/v8/V8NodeFilterCondition.cpp b/Source/bindings/v8/V8NodeFilterCondition.cpp
index e714fd5..77ec3a1 100644
--- a/Source/bindings/v8/V8NodeFilterCondition.cpp
+++ b/Source/bindings/v8/V8NodeFilterCondition.cpp
@@ -34,6 +34,7 @@
#include "V8Node.h"
#include "bindings/v8/ScriptController.h"
#include "bindings/v8/ScriptState.h"
+#include "bindings/v8/V8HiddenValue.h"
#include "core/dom/Node.h"
#include "core/dom/NodeFilter.h"
#include "wtf/OwnPtr.h"
@@ -43,7 +44,7 @@
V8NodeFilterCondition::V8NodeFilterCondition(v8::Handle<v8::Value> filter, v8::Handle<v8::Object> owner, v8::Isolate* isolate)
: m_filter(isolate, filter)
{
- setHiddenValue(isolate, owner, "condition", filter);
+ V8HiddenValue::setHiddenValue(isolate, owner, V8HiddenValue::condition(isolate), filter);
m_filter.setWeak(this, &setWeakCallback);
}
@@ -68,7 +69,7 @@
callback = v8::Handle<v8::Function>::Cast(filter);
else {
v8::Local<v8::Value> value = filter->ToObject()->Get(v8AtomicString(isolate, "acceptNode"));
- if (!value->IsFunction()) {
+ if (value.IsEmpty() || !value->IsFunction()) {
throwTypeError("NodeFilter object does not have an acceptNode function", state->isolate());
return NodeFilter::FILTER_REJECT;
}
diff --git a/Source/bindings/v8/V8ObjectConstructor.cpp b/Source/bindings/v8/V8ObjectConstructor.cpp
index 6ebfbab..b94cb53 100644
--- a/Source/bindings/v8/V8ObjectConstructor.cpp
+++ b/Source/bindings/v8/V8ObjectConstructor.cpp
@@ -28,7 +28,7 @@
#include "bindings/v8/V8Binding.h"
#include "bindings/v8/V8ScriptRunner.h"
#include "core/dom/Document.h"
-#include "core/frame/Frame.h"
+#include "core/frame/LocalFrame.h"
#include "platform/TraceEvent.h"
diff --git a/Source/bindings/v8/V8PerContextData.cpp b/Source/bindings/v8/V8PerContextData.cpp
index ff9ce8e..bd1f190 100644
--- a/Source/bindings/v8/V8PerContextData.cpp
+++ b/Source/bindings/v8/V8PerContextData.cpp
@@ -48,6 +48,74 @@
map->clear();
}
+class V8PerContextDataHolder {
+ WTF_MAKE_NONCOPYABLE(V8PerContextDataHolder);
+public:
+ static void install(v8::Handle<v8::Context> context, PassRefPtr<DOMWrapperWorld> world)
+ {
+ new V8PerContextDataHolder(context, world);
+ }
+
+ static V8PerContextDataHolder* from(v8::Handle<v8::Context> context)
+ {
+ V8PerContextDataHolder* holder = static_cast<V8PerContextDataHolder*>(context->GetAlignedPointerFromEmbedderData(v8ContextPerContextDataIndex));
+ // V8PerContextDataHolder::from() must not be called for a context that does not have
+ // valid embedder data in the embedder field.
+ RELEASE_ASSERT_WITH_SECURITY_IMPLICATION(holder);
+ RELEASE_ASSERT_WITH_SECURITY_IMPLICATION(holder->context() == context);
+ return holder;
+ }
+
+ V8PerContextData* perContextData() const { return m_perContextData; }
+ void setPerContextData(V8PerContextData* data) { m_perContextData = data; }
+ DOMWrapperWorld* world() const { return m_world.get(); }
+ v8::Handle<v8::Context> context() const { return m_context.newLocal(m_isolate); }
+
+private:
+ V8PerContextDataHolder(v8::Handle<v8::Context> context, PassRefPtr<DOMWrapperWorld> world)
+ : m_isolate(context->GetIsolate())
+ , m_context(m_isolate, context)
+ , m_perContextData(0)
+ , m_world(world)
+ {
+ m_context.setWeak(this, &V8PerContextDataHolder::weakCallback);
+ context->SetAlignedPointerInEmbedderData(v8ContextPerContextDataIndex, this);
+ }
+
+ ~V8PerContextDataHolder() { }
+
+ static void weakCallback(const v8::WeakCallbackData<v8::Context, V8PerContextDataHolder>& data)
+ {
+ data.GetValue()->SetAlignedPointerInEmbedderData(v8ContextPerContextDataIndex, 0);
+ delete data.GetParameter();
+ }
+
+ v8::Isolate* m_isolate;
+ ScopedPersistent<v8::Context> m_context;
+ V8PerContextData* m_perContextData;
+ RefPtr<DOMWrapperWorld> m_world;
+};
+
+V8PerContextData::V8PerContextData(v8::Handle<v8::Context> context, PassRefPtr<DOMWrapperWorld> world)
+ : m_activityLogger(0)
+ , m_isolate(context->GetIsolate())
+ , m_contextHolder(adoptPtr(new gin::ContextHolder(context->GetIsolate())))
+ , m_context(m_isolate, context)
+ , m_customElementBindings(adoptPtr(new CustomElementBindingMap()))
+{
+ m_contextHolder->SetContext(context);
+ V8PerContextDataHolder::install(context, world);
+ V8PerContextDataHolder::from(context)->setPerContextData(this);
+
+ v8::Context::Scope contextScope(context);
+ ASSERT(m_errorPrototype.isEmpty());
+ v8::Handle<v8::Object> object = v8::Handle<v8::Object>::Cast(context->Global()->Get(v8AtomicString(m_isolate, "Error")));
+ ASSERT(!object.IsEmpty());
+ v8::Handle<v8::Value> prototypeValue = object->Get(v8AtomicString(m_isolate, "prototype"));
+ ASSERT(!prototypeValue.IsEmpty());
+ m_errorPrototype.set(m_isolate, prototypeValue);
+}
+
V8PerContextData::~V8PerContextData()
{
v8::HandleScope handleScope(m_isolate);
@@ -55,45 +123,25 @@
disposeMapWithUnsafePersistentValues(&m_wrapperBoilerplates);
disposeMapWithUnsafePersistentValues(&m_constructorMap);
- m_customElementBindings.clear();
}
-#define V8_STORE_PRIMORDIAL(name, Name) \
-{ \
- ASSERT(m_##name##Prototype.isEmpty()); \
- v8::Handle<v8::String> symbol = v8AtomicString(m_isolate, #Name); \
- if (symbol.IsEmpty()) \
- return false; \
- v8::Handle<v8::Object> object = v8::Handle<v8::Object>::Cast(m_context.newLocal(m_isolate)->Global()->Get(symbol)); \
- if (object.IsEmpty()) \
- return false; \
- v8::Handle<v8::Value> prototypeValue = object->Get(prototypeString); \
- if (prototypeValue.IsEmpty()) \
- return false; \
- m_##name##Prototype.set(m_isolate, prototypeValue); \
-}
-
-bool V8PerContextData::init()
+V8PerContextData* V8PerContextData::from(v8::Handle<v8::Context> context)
{
- v8::Handle<v8::Context> context = m_context.newLocal(m_isolate);
- V8PerContextDataHolder::from(context)->setPerContextData(this);
-
- v8::Handle<v8::String> prototypeString = v8AtomicString(m_isolate, "prototype");
- if (prototypeString.IsEmpty())
- return false;
-
- V8_STORE_PRIMORDIAL(error, Error);
-
- return true;
+ return V8PerContextDataHolder::from(context)->perContextData();
}
-#undef V8_STORE_PRIMORDIAL
+DOMWrapperWorld* V8PerContextData::world(v8::Handle<v8::Context> context)
+{
+ DOMWrapperWorld* world = V8PerContextDataHolder::from(context)->world();
+ ASSERT(world);
+ return world;
+}
v8::Local<v8::Object> V8PerContextData::createWrapperFromCacheSlowCase(const WrapperTypeInfo* type)
{
ASSERT(!m_errorPrototype.isEmpty());
- v8::Context::Scope scope(m_context.newLocal(m_isolate));
+ v8::Context::Scope scope(context());
v8::Local<v8::Function> function = constructorForType(type);
v8::Local<v8::Object> instanceTemplate = V8ObjectConstructor::newInstance(function);
if (!instanceTemplate.IsEmpty()) {
@@ -107,8 +155,8 @@
{
ASSERT(!m_errorPrototype.isEmpty());
- v8::Context::Scope scope(m_context.newLocal(m_isolate));
- v8::Handle<v8::FunctionTemplate> functionTemplate = type->domTemplate(m_isolate, worldType(m_isolate));
+ v8::Context::Scope scope(context());
+ v8::Handle<v8::FunctionTemplate> functionTemplate = type->domTemplate(m_isolate);
// Getting the function might fail if we're running out of stack or memory.
v8::TryCatch tryCatch;
v8::Local<v8::Function> function = functionTemplate->GetFunction();
diff --git a/Source/bindings/v8/V8PerContextData.h b/Source/bindings/v8/V8PerContextData.h
index 2c62b73..ad46ce5 100644
--- a/Source/bindings/v8/V8PerContextData.h
+++ b/Source/bindings/v8/V8PerContextData.h
@@ -59,65 +59,19 @@
v8ContextPerContextDataIndex = static_cast<int>(gin::kPerContextDataStartIndex + gin::kEmbedderBlink),
};
-class V8PerContextDataHolder {
- WTF_MAKE_NONCOPYABLE(V8PerContextDataHolder);
-public:
- static void install(v8::Handle<v8::Context> context, DOMWrapperWorld* world)
- {
- new V8PerContextDataHolder(context, world);
- }
-
- static V8PerContextDataHolder* from(v8::Handle<v8::Context> context)
- {
- return static_cast<V8PerContextDataHolder*>(context->GetAlignedPointerFromEmbedderData(v8ContextPerContextDataIndex));
- }
-
- V8PerContextData* perContextData() const { return m_perContextData; }
- void setPerContextData(V8PerContextData* data) { m_perContextData = data; }
-
- DOMWrapperWorld* world() const { return m_world; }
-
-private:
- V8PerContextDataHolder(v8::Handle<v8::Context> context, DOMWrapperWorld* world)
- : m_context(v8::Isolate::GetCurrent(), context)
- , m_perContextData(0)
- , m_world(world)
- {
- m_context.setWeak(this, &V8PerContextDataHolder::weakCallback);
- context->SetAlignedPointerInEmbedderData(v8ContextPerContextDataIndex, this);
- }
-
- ~V8PerContextDataHolder() {}
-
- static void weakCallback(const v8::WeakCallbackData<v8::Context, V8PerContextDataHolder>& data)
- {
- data.GetValue()->SetAlignedPointerInEmbedderData(v8ContextPerContextDataIndex, 0);
- delete data.GetParameter();
- }
-
- ScopedPersistent<v8::Context> m_context;
- V8PerContextData* m_perContextData;
- // This should not be a RefPtr. Otherwise, it creates a cycle:
- // V8PerContextData => DOMWrapperWorld => DOMDataStore => global objects
- // => Window or WorkerGlobalScope => V8PerContextData.
- DOMWrapperWorld* m_world;
-};
-
class V8PerContextData {
public:
- static PassOwnPtr<V8PerContextData> create(v8::Handle<v8::Context> context)
+ static PassOwnPtr<V8PerContextData> create(v8::Handle<v8::Context> context, PassRefPtr<DOMWrapperWorld> world)
{
- return adoptPtr(new V8PerContextData(context));
+ return adoptPtr(new V8PerContextData(context, world));
}
+ static V8PerContextData* from(v8::Handle<v8::Context>);
+ static DOMWrapperWorld* world(v8::Handle<v8::Context>);
+
~V8PerContextData();
- bool init();
-
- static V8PerContextData* from(v8::Handle<v8::Context> context)
- {
- return V8PerContextDataHolder::from(context)->perContextData();
- }
+ v8::Handle<v8::Context> context() { return m_context.newLocal(m_isolate); }
// To create JS Wrapper objects, we create a cache of a 'boiler plate'
// object, and then simply Clone that object each time we need a new one.
@@ -138,33 +92,16 @@
v8::Local<v8::Object> prototypeForType(const WrapperTypeInfo*);
- V8NPObjectMap* v8NPObjectMap()
- {
- return &m_v8NPObjectMap;
- }
-
- V8DOMActivityLogger* activityLogger()
- {
- return m_activityLogger;
- }
-
- void setActivityLogger(V8DOMActivityLogger* logger)
- {
- m_activityLogger = logger;
- }
+ V8NPObjectMap* v8NPObjectMap() { return &m_v8NPObjectMap; }
+ V8DOMActivityLogger* activityLogger() { return m_activityLogger; }
+ void setActivityLogger(V8DOMActivityLogger* logger) { m_activityLogger = logger; }
void addCustomElementBinding(CustomElementDefinition*, PassOwnPtr<CustomElementBinding>);
void clearCustomElementBinding(CustomElementDefinition*);
CustomElementBinding* customElementBinding(CustomElementDefinition*);
private:
- explicit V8PerContextData(v8::Handle<v8::Context> context)
- : m_activityLogger(0)
- , m_isolate(v8::Isolate::GetCurrent())
- , m_context(m_isolate, context)
- , m_customElementBindings(adoptPtr(new CustomElementBindingMap()))
- {
- }
+ V8PerContextData(v8::Handle<v8::Context>, PassRefPtr<DOMWrapperWorld>);
v8::Local<v8::Object> createWrapperFromCacheSlowCase(const WrapperTypeInfo*);
v8::Local<v8::Function> constructorForTypeSlowCase(const WrapperTypeInfo*);
@@ -182,7 +119,10 @@
// corresponding to this context. The ownership of the pointer is retained
// by the DOMActivityLoggerMap in DOMWrapperWorld.
V8DOMActivityLogger* m_activityLogger;
+
v8::Isolate* m_isolate;
+ OwnPtr<gin::ContextHolder> m_contextHolder;
+
ScopedPersistent<v8::Context> m_context;
ScopedPersistent<v8::Value> m_errorPrototype;
diff --git a/Source/bindings/v8/V8PerIsolateData.cpp b/Source/bindings/v8/V8PerIsolateData.cpp
index 2d1da28..f1d1f27 100644
--- a/Source/bindings/v8/V8PerIsolateData.cpp
+++ b/Source/bindings/v8/V8PerIsolateData.cpp
@@ -30,45 +30,44 @@
#include "bindings/v8/ScriptGCEvent.h"
#include "bindings/v8/ScriptProfiler.h"
#include "bindings/v8/V8Binding.h"
+#include "bindings/v8/V8HiddenValue.h"
#include "bindings/v8/V8ObjectConstructor.h"
+#include "bindings/v8/V8PerContextData.h"
#include "bindings/v8/V8ScriptRunner.h"
-#include "gin/public/isolate_holder.h"
#include "wtf/MainThread.h"
namespace WebCore {
-static gin::IsolateHolder* mainIsolateHolder = 0;
+static V8PerIsolateData* mainThreadPerIsolateData = 0;
V8PerIsolateData::V8PerIsolateData(v8::Isolate* isolate)
: m_isolate(isolate)
- , m_isMainThread(WTF::isMainThread())
+ , m_isolateHolder(adoptPtr(new gin::IsolateHolder(m_isolate, v8ArrayBufferAllocator())))
, m_stringCache(adoptPtr(new StringCache()))
+ , m_hiddenValue(adoptPtr(new V8HiddenValue()))
, m_constructorMode(ConstructorMode::CreateNewObject)
, m_recursionLevel(0)
#ifndef NDEBUG
, m_internalScriptRecursionLevel(0)
#endif
, m_gcEventData(adoptPtr(new GCEventData()))
- , m_shouldCollectGarbageSoon(false)
, m_performingMicrotaskCheckpoint(false)
{
- if (m_isMainThread)
- mainIsolateHolder = new gin::IsolateHolder(m_isolate);
+ if (isMainThread())
+ mainThreadPerIsolateData = this;
}
V8PerIsolateData::~V8PerIsolateData()
{
- if (m_isMainThread) {
- delete mainIsolateHolder;
- mainIsolateHolder = 0;
- }
+ if (isMainThread())
+ mainThreadPerIsolateData = 0;
}
v8::Isolate* V8PerIsolateData::mainThreadIsolate()
{
- ASSERT(WTF::isMainThread());
- ASSERT(mainIsolateHolder);
- return mainIsolateHolder->isolate();
+ ASSERT(isMainThread());
+ ASSERT(mainThreadPerIsolateData);
+ return mainThreadPerIsolateData->isolate();
}
void V8PerIsolateData::ensureInitialized(v8::Isolate* isolate)
@@ -94,67 +93,80 @@
isolate->SetData(gin::kEmbedderBlink, 0);
}
-v8::Handle<v8::FunctionTemplate> V8PerIsolateData::toStringTemplate()
+V8PerIsolateData::DOMTemplateMap& V8PerIsolateData::currentDOMTemplateMap()
{
- if (m_toStringTemplate.isEmpty())
- m_toStringTemplate.set(m_isolate, v8::FunctionTemplate::New(m_isolate, constructorOfToString));
- return m_toStringTemplate.newLocal(m_isolate);
+ if (DOMWrapperWorld::current(m_isolate)->isMainWorld())
+ return m_domTemplateMapForMainWorld;
+ return m_domTemplateMapForNonMainWorld;
}
-v8::Handle<v8::FunctionTemplate> V8PerIsolateData::privateTemplate(WrapperWorldType currentWorldType, void* privatePointer, v8::FunctionCallback callback, v8::Handle<v8::Value> data, v8::Handle<v8::Signature> signature, int length)
+v8::Handle<v8::FunctionTemplate> V8PerIsolateData::domTemplate(void* domTemplateKey, v8::FunctionCallback callback, v8::Handle<v8::Value> data, v8::Handle<v8::Signature> signature, int length)
{
- TemplateMap& templates = templateMap(currentWorldType);
- TemplateMap::iterator result = templates.find(privatePointer);
- if (result != templates.end())
+ DOMTemplateMap& domTemplateMap = currentDOMTemplateMap();
+ DOMTemplateMap::iterator result = domTemplateMap.find(domTemplateKey);
+ if (result != domTemplateMap.end())
return result->value.newLocal(m_isolate);
v8::Local<v8::FunctionTemplate> templ = v8::FunctionTemplate::New(m_isolate, callback, data, signature, length);
- templates.add(privatePointer, UnsafePersistent<v8::FunctionTemplate>(m_isolate, templ));
+ domTemplateMap.add(domTemplateKey, UnsafePersistent<v8::FunctionTemplate>(m_isolate, templ));
return templ;
}
-v8::Handle<v8::FunctionTemplate> V8PerIsolateData::privateTemplateIfExists(WrapperWorldType currentWorldType, void* privatePointer)
+v8::Handle<v8::FunctionTemplate> V8PerIsolateData::existingDOMTemplate(void* domTemplateKey)
{
- TemplateMap& templates = templateMap(currentWorldType);
- TemplateMap::iterator result = templates.find(privatePointer);
- if (result != templates.end())
+ DOMTemplateMap& domTemplateMap = currentDOMTemplateMap();
+ DOMTemplateMap::iterator result = domTemplateMap.find(domTemplateKey);
+ if (result != domTemplateMap.end())
return result->value.newLocal(m_isolate);
return v8::Local<v8::FunctionTemplate>();
}
-void V8PerIsolateData::setPrivateTemplate(WrapperWorldType currentWorldType, void* privatePointer, v8::Handle<v8::FunctionTemplate> templ)
+void V8PerIsolateData::setDOMTemplate(void* domTemplateKey, v8::Handle<v8::FunctionTemplate> templ)
{
- templateMap(currentWorldType).add(privatePointer, UnsafePersistent<v8::FunctionTemplate>(m_isolate, templ));
+ currentDOMTemplateMap().add(domTemplateKey, UnsafePersistent<v8::FunctionTemplate>(m_isolate, templ));
}
v8::Local<v8::Context> V8PerIsolateData::ensureRegexContext()
{
- if (m_regexContext.isEmpty()) {
- v8::HandleScope handleScope(m_isolate);
- m_regexContext.set(m_isolate, v8::Context::New(m_isolate));
- }
- return m_regexContext.newLocal(m_isolate);
+ if (!m_perContextDataForRegex)
+ m_perContextDataForRegex = V8PerContextData::create(v8::Context::New(m_isolate), DOMWrapperWorld::create());
+ return m_perContextDataForRegex->context();
}
-bool V8PerIsolateData::hasInstanceInMainWorld(const WrapperTypeInfo* info, v8::Handle<v8::Value> value)
+bool V8PerIsolateData::hasInstance(const WrapperTypeInfo* info, v8::Handle<v8::Value> value)
{
- return hasInstance(info, value, m_templatesForMainWorld);
+ return hasInstance(info, value, m_domTemplateMapForMainWorld)
+ || hasInstance(info, value, m_domTemplateMapForNonMainWorld);
}
-bool V8PerIsolateData::hasInstanceInNonMainWorld(const WrapperTypeInfo* info, v8::Handle<v8::Value> value)
+bool V8PerIsolateData::hasInstance(const WrapperTypeInfo* info, v8::Handle<v8::Value> value, DOMTemplateMap& domTemplateMap)
{
- return hasInstance(info, value, m_templatesForNonMainWorld);
-}
-
-bool V8PerIsolateData::hasInstance(const WrapperTypeInfo* info, v8::Handle<v8::Value> value, TemplateMap& templates)
-{
- TemplateMap::iterator result = templates.find(info);
- if (result == templates.end())
+ DOMTemplateMap::iterator result = domTemplateMap.find(info);
+ if (result == domTemplateMap.end())
return false;
- v8::HandleScope handleScope(m_isolate);
- return result->value.newLocal(m_isolate)->HasInstance(value);
+ v8::Handle<v8::FunctionTemplate> templ = result->value.newLocal(m_isolate);
+ return templ->HasInstance(value);
}
-void V8PerIsolateData::constructorOfToString(const v8::FunctionCallbackInfo<v8::Value>& info)
+v8::Handle<v8::Object> V8PerIsolateData::findInstanceInPrototypeChain(const WrapperTypeInfo* info, v8::Handle<v8::Value> value)
+{
+ v8::Handle<v8::Object> wrapper = findInstanceInPrototypeChain(info, value, m_domTemplateMapForMainWorld);
+ if (!wrapper.IsEmpty())
+ return wrapper;
+ return findInstanceInPrototypeChain(info, value, m_domTemplateMapForNonMainWorld);
+}
+
+v8::Handle<v8::Object> V8PerIsolateData::findInstanceInPrototypeChain(const WrapperTypeInfo* info, v8::Handle<v8::Value> value, DOMTemplateMap& domTemplateMap)
+{
+ if (value.IsEmpty() || !value->IsObject())
+ return v8::Handle<v8::Object>();
+ DOMTemplateMap::iterator result = domTemplateMap.find(info);
+ if (result == domTemplateMap.end())
+ return v8::Handle<v8::Object>();
+ v8::Handle<v8::FunctionTemplate> templ = result->value.newLocal(m_isolate);
+ return v8::Handle<v8::Object>::Cast(value)->FindInstanceInPrototypeChain(templ);
+}
+
+static void constructorOfToString(const v8::FunctionCallbackInfo<v8::Value>& info)
{
// The DOM constructors' toString functions grab the current toString
// for Functions by taking the toString function of itself and then
@@ -172,4 +184,11 @@
v8SetReturnValue(info, V8ScriptRunner::callInternalFunction(v8::Handle<v8::Function>::Cast(value), info.This(), 0, 0, v8::Isolate::GetCurrent()));
}
+v8::Handle<v8::FunctionTemplate> V8PerIsolateData::toStringTemplate()
+{
+ if (m_toStringTemplate.isEmpty())
+ m_toStringTemplate.set(m_isolate, v8::FunctionTemplate::New(m_isolate, constructorOfToString));
+ return m_toStringTemplate.newLocal(m_isolate);
+}
+
} // namespace WebCore
diff --git a/Source/bindings/v8/V8PerIsolateData.h b/Source/bindings/v8/V8PerIsolateData.h
index 3d71809..3e9dbca 100644
--- a/Source/bindings/v8/V8PerIsolateData.h
+++ b/Source/bindings/v8/V8PerIsolateData.h
@@ -28,8 +28,10 @@
#include "bindings/v8/ScopedPersistent.h"
#include "bindings/v8/UnsafePersistent.h"
+#include "bindings/v8/V8HiddenValue.h"
#include "bindings/v8/WrapperTypeInfo.h"
#include "gin/public/gin_embedders.h"
+#include "gin/public/isolate_holder.h"
#include <v8.h>
#include "wtf/Forward.h"
#include "wtf/HashMap.h"
@@ -41,6 +43,7 @@
class DOMDataStore;
class GCEventData;
class StringCache;
+class V8PerContextData;
struct WrapperTypeInfo;
class ExternalStringVisitor;
@@ -63,16 +66,7 @@
static void dispose(v8::Isolate*);
static v8::Isolate* mainThreadIsolate();
- bool isMainThread() { return m_isMainThread; };
-
- typedef HashMap<const void*, UnsafePersistent<v8::FunctionTemplate> > TemplateMap;
-
- TemplateMap& templateMap(WrapperWorldType worldType)
- {
- if (worldType == MainWorld)
- return m_templatesForMainWorld;
- return m_templatesForNonMainWorld;
- }
+ v8::Isolate* isolate() { return m_isolate; }
v8::Handle<v8::FunctionTemplate> toStringTemplate();
@@ -80,20 +74,6 @@
v8::Persistent<v8::Value>& ensureLiveRoot();
- DOMDataStoreList& allStores() { return m_domDataStoreList; }
-
- void registerDOMDataStore(DOMDataStore* domDataStore)
- {
- ASSERT(m_domDataStoreList.find(domDataStore) == kNotFound);
- m_domDataStoreList.append(domDataStore);
- }
-
- void unregisterDOMDataStore(DOMDataStore* domDataStore)
- {
- ASSERT(m_domDataStoreList.find(domDataStore) != kNotFound);
- m_domDataStoreList.remove(m_domDataStoreList.find(domDataStore));
- }
-
int recursionLevel() const { return m_recursionLevel; }
int incrementRecursionLevel() { return ++m_recursionLevel; }
int decrementRecursionLevel() { return --m_recursionLevel; }
@@ -108,21 +88,14 @@
#endif
GCEventData* gcEventData() { return m_gcEventData.get(); }
+ V8HiddenValue* hiddenValue() { return m_hiddenValue.get(); }
- // Gives the system a hint that we should request garbage collection
- // upon the next close or navigation event, because some expensive
- // objects have been allocated that we want to take every opportunity
- // to collect.
- void setShouldCollectGarbageSoon() { m_shouldCollectGarbageSoon = true; }
- void clearShouldCollectGarbageSoon() { m_shouldCollectGarbageSoon = false; }
- bool shouldCollectGarbageSoon() const { return m_shouldCollectGarbageSoon; }
+ v8::Handle<v8::FunctionTemplate> domTemplate(void* domTemplateKey, v8::FunctionCallback = 0, v8::Handle<v8::Value> data = v8::Handle<v8::Value>(), v8::Handle<v8::Signature> = v8::Handle<v8::Signature>(), int length = 0);
+ v8::Handle<v8::FunctionTemplate> existingDOMTemplate(void* domTemplateKey);
+ void setDOMTemplate(void* domTemplateKey, v8::Handle<v8::FunctionTemplate>);
- v8::Handle<v8::FunctionTemplate> privateTemplate(WrapperWorldType, void* privatePointer, v8::FunctionCallback = 0, v8::Handle<v8::Value> data = v8::Handle<v8::Value>(), v8::Handle<v8::Signature> = v8::Handle<v8::Signature>(), int length = 0);
- v8::Handle<v8::FunctionTemplate> privateTemplateIfExists(WrapperWorldType, void* privatePointer);
- void setPrivateTemplate(WrapperWorldType, void* privatePointer, v8::Handle<v8::FunctionTemplate>);
-
- bool hasInstanceInMainWorld(const WrapperTypeInfo*, v8::Handle<v8::Value>);
- bool hasInstanceInNonMainWorld(const WrapperTypeInfo*, v8::Handle<v8::Value>);
+ bool hasInstance(const WrapperTypeInfo*, v8::Handle<v8::Value>);
+ v8::Handle<v8::Object> findInstanceInPrototypeChain(const WrapperTypeInfo*, v8::Handle<v8::Value>);
v8::Local<v8::Context> ensureRegexContext();
@@ -132,20 +105,21 @@
private:
explicit V8PerIsolateData(v8::Isolate*);
~V8PerIsolateData();
- bool hasInstance(const WrapperTypeInfo*, v8::Handle<v8::Value>, TemplateMap&);
- static void constructorOfToString(const v8::FunctionCallbackInfo<v8::Value>&);
+
+ typedef HashMap<const void*, UnsafePersistent<v8::FunctionTemplate> > DOMTemplateMap;
+ DOMTemplateMap& currentDOMTemplateMap();
+ bool hasInstance(const WrapperTypeInfo*, v8::Handle<v8::Value>, DOMTemplateMap&);
+ v8::Handle<v8::Object> findInstanceInPrototypeChain(const WrapperTypeInfo*, v8::Handle<v8::Value>, DOMTemplateMap&);
v8::Isolate* m_isolate;
- bool m_isMainThread; // Caches the result of isMainThread() for performance.
- TemplateMap m_templatesForMainWorld;
- TemplateMap m_templatesForNonMainWorld;
+ OwnPtr<gin::IsolateHolder> m_isolateHolder;
+ DOMTemplateMap m_domTemplateMapForMainWorld;
+ DOMTemplateMap m_domTemplateMapForNonMainWorld;
ScopedPersistent<v8::FunctionTemplate> m_toStringTemplate;
OwnPtr<StringCache> m_stringCache;
-
- Vector<DOMDataStore*> m_domDataStoreList;
-
+ OwnPtr<V8HiddenValue> m_hiddenValue;
ScopedPersistent<v8::Value> m_liveRoot;
- ScopedPersistent<v8::Context> m_regexContext;
+ OwnPtr<V8PerContextData> m_perContextDataForRegex;
const char* m_previousSamplingState;
@@ -158,7 +132,6 @@
int m_internalScriptRecursionLevel;
#endif
OwnPtr<GCEventData> m_gcEventData;
- bool m_shouldCollectGarbageSoon;
bool m_performingMicrotaskCheckpoint;
};
diff --git a/Source/bindings/v8/V8ScriptRunner.cpp b/Source/bindings/v8/V8ScriptRunner.cpp
index a6d8fc2..099d358 100644
--- a/Source/bindings/v8/V8ScriptRunner.cpp
+++ b/Source/bindings/v8/V8ScriptRunner.cpp
@@ -85,9 +85,6 @@
if (V8RecursionScope::recursionLevel() >= kMaxRecursionDepth)
return handleMaxRecursionDepthExceeded(isolate);
- if (handleOutOfMemory())
- return v8::Local<v8::Value>();
-
RELEASE_ASSERT(!context->isIteratingOverObservers());
// Run the script and keep track of the current recursion depth.
@@ -97,9 +94,6 @@
result = script->Run();
}
- if (handleOutOfMemory())
- ASSERT(result.IsEmpty());
-
if (result.IsEmpty())
return v8::Local<v8::Value>();
@@ -121,7 +115,7 @@
return result;
}
-v8::Local<v8::Value> V8ScriptRunner::callFunction(v8::Handle<v8::Function> function, ExecutionContext* context, v8::Handle<v8::Value> receiver, int argc, v8::Handle<v8::Value> info[], 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", "V8Execution");
@@ -132,39 +126,39 @@
RELEASE_ASSERT(!context->isIteratingOverObservers());
V8RecursionScope recursionScope(context);
- v8::Local<v8::Value> result = function->Call(receiver, argc, info);
+ 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::Value> receiver, int argc, v8::Handle<v8::Value> info[], 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", "V8Execution");
V8RecursionScope::MicrotaskSuppression recursionScope;
- v8::Local<v8::Value> result = function->Call(receiver, argc, info);
+ v8::Local<v8::Value> result = function->Call(receiver, argc, args);
crashIfV8IsDead();
return result;
}
-v8::Local<v8::Value> V8ScriptRunner::callAsFunction(v8::Handle<v8::Object> object, v8::Handle<v8::Value> receiver, int argc, v8::Handle<v8::Value> info[])
+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", "V8Execution");
V8RecursionScope::MicrotaskSuppression recursionScope;
- v8::Local<v8::Value> result = object->CallAsFunction(receiver, argc, info);
+ v8::Local<v8::Value> result = object->CallAsFunction(receiver, argc, args);
crashIfV8IsDead();
return result;
}
-v8::Local<v8::Value> V8ScriptRunner::callAsConstructor(v8::Handle<v8::Object> object, int argc, v8::Handle<v8::Value> info[])
+v8::Local<v8::Value> V8ScriptRunner::callAsConstructor(v8::Handle<v8::Object> object, int argc, v8::Handle<v8::Value> args[])
{
TRACE_EVENT0("v8", "v8.callFunction");
TRACE_EVENT_SCOPED_SAMPLING_STATE("V8", "V8Execution");
V8RecursionScope::MicrotaskSuppression recursionScope;
- v8::Local<v8::Value> result = object->CallAsConstructor(argc, info);
+ v8::Local<v8::Value> result = object->CallAsConstructor(argc, args);
crashIfV8IsDead();
return result;
}
diff --git a/Source/bindings/v8/V8ThrowException.h b/Source/bindings/v8/V8ThrowException.h
index 7a4d20f..26addf0 100644
--- a/Source/bindings/v8/V8ThrowException.h
+++ b/Source/bindings/v8/V8ThrowException.h
@@ -47,10 +47,6 @@
}
static v8::Handle<v8::Value> createDOMException(int, const String& sanitizedMessage, const String& unsanitizedMessage, const v8::Handle<v8::Object>& creationContext, v8::Isolate*);
- static v8::Handle<v8::Value> throwDOMException(int ec, const v8::Handle<v8::Object>& creationContext, v8::Isolate* isolate)
- {
- return throwDOMException(ec, String(), creationContext, isolate);
- }
static v8::Handle<v8::Value> throwDOMException(int ec, const String& message, const v8::Handle<v8::Object>& creationContext, v8::Isolate* isolate)
{
return throwDOMException(ec, message, String(), creationContext, isolate);
diff --git a/Source/bindings/v8/V8Utilities.cpp b/Source/bindings/v8/V8Utilities.cpp
deleted file mode 100644
index 74dcb7b..0000000
--- a/Source/bindings/v8/V8Utilities.cpp
+++ /dev/null
@@ -1,104 +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/V8Utilities.h"
-
-#include "V8MessagePort.h"
-#include "bindings/v8/ExceptionMessages.h"
-#include "bindings/v8/ScriptState.h"
-#include "bindings/v8/V8AbstractEventListener.h"
-#include "bindings/v8/V8Binding.h"
-#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/frame/Frame.h"
-#include "core/workers/WorkerGlobalScope.h"
-#include "wtf/ArrayBuffer.h"
-#include "wtf/text/WTFString.h"
-#include <v8.h>
-
-
-namespace WebCore {
-
-bool extractTransferables(v8::Local<v8::Value> value, int argumentIndex, MessagePortArray& ports, ArrayBufferArray& arrayBuffers, ExceptionState& exceptionState, v8::Isolate* isolate)
-{
- if (isUndefinedOrNull(value)) {
- ports.resize(0);
- arrayBuffers.resize(0);
- return true;
- }
-
- uint32_t length = 0;
- if (value->IsArray()) {
- v8::Local<v8::Array> array = v8::Local<v8::Array>::Cast(value);
- length = array->Length();
- } else if (toV8Sequence(value, length, isolate).IsEmpty()) {
- exceptionState.throwTypeError(ExceptionMessages::notAnArrayTypeArgumentOrValue(argumentIndex + 1));
- return false;
- }
-
- v8::Local<v8::Object> transferrables = v8::Local<v8::Object>::Cast(value);
-
- // Validate the passed array of transferrables.
- for (unsigned int i = 0; i < length; ++i) {
- v8::Local<v8::Value> transferrable = transferrables->Get(i);
- // Validation of non-null objects, per HTML5 spec 10.3.3.
- if (isUndefinedOrNull(transferrable)) {
- exceptionState.throwDOMException(DataCloneError, "Value at index " + String::number(i) + " is an untransferable " + (transferrable->IsUndefined() ? "'undefined'" : "'null'") + " value.");
- return false;
- }
- // Validation of Objects implementing an interface, per WebIDL spec 4.1.15.
- if (V8MessagePort::hasInstance(transferrable, isolate)) {
- RefPtr<MessagePort> port = V8MessagePort::toNative(v8::Handle<v8::Object>::Cast(transferrable));
- // Check for duplicate MessagePorts.
- if (ports.contains(port)) {
- exceptionState.throwDOMException(DataCloneError, "Message port at index " + String::number(i) + " is a duplicate of an earlier port.");
- return false;
- }
- ports.append(port.release());
- } else if (V8ArrayBuffer::hasInstance(transferrable, isolate)) {
- RefPtr<ArrayBuffer> arrayBuffer = V8ArrayBuffer::toNative(v8::Handle<v8::Object>::Cast(transferrable));
- if (arrayBuffers.contains(arrayBuffer)) {
- exceptionState.throwDOMException(DataCloneError, "ArrayBuffer at index " + String::number(i) + " is a duplicate of an earlier ArrayBuffer.");
- return false;
- }
- arrayBuffers.append(arrayBuffer.release());
- } else {
- exceptionState.throwDOMException(DataCloneError, "Value at index " + String::number(i) + " does not have a transferable type.");
- return false;
- }
- }
- return true;
-}
-
-} // namespace WebCore
diff --git a/Source/bindings/v8/V8ValueCache.cpp b/Source/bindings/v8/V8ValueCache.cpp
index 0681d0c..3da29d6 100644
--- a/Source/bindings/v8/V8ValueCache.cpp
+++ b/Source/bindings/v8/V8ValueCache.cpp
@@ -27,7 +27,6 @@
#include "bindings/v8/V8ValueCache.h"
#include "bindings/v8/V8Binding.h"
-#include "bindings/v8/V8Utilities.h"
#include "wtf/text/StringHash.h"
namespace WebCore {
@@ -106,7 +105,7 @@
void StringCache::setWeakCallback(const v8::WeakCallbackData<v8::String, StringImpl>& data)
{
StringCache* stringCache = V8PerIsolateData::from(data.GetIsolate())->stringCache();
- stringCache->m_lastStringImpl = 0;
+ stringCache->m_lastStringImpl = nullptr;
stringCache->m_lastV8String.clear();
ASSERT(stringCache->m_stringCache.contains(data.GetParameter()));
stringCache->m_stringCache.get(data.GetParameter()).dispose();
diff --git a/Source/bindings/v8/V8WindowShell.cpp b/Source/bindings/v8/V8WindowShell.cpp
index 84de31b..f5013a3 100644
--- a/Source/bindings/v8/V8WindowShell.cpp
+++ b/Source/bindings/v8/V8WindowShell.cpp
@@ -40,6 +40,7 @@
#include "bindings/v8/ScriptController.h"
#include "bindings/v8/V8Binding.h"
#include "bindings/v8/V8GCForContextDispose.h"
+#include "bindings/v8/V8HiddenValue.h"
#include "bindings/v8/V8Initializer.h"
#include "bindings/v8/V8ObjectConstructor.h"
#include "bindings/v8/V8PerContextData.h"
@@ -49,8 +50,8 @@
#include "core/loader/DocumentLoader.h"
#include "core/loader/FrameLoader.h"
#include "core/loader/FrameLoaderClient.h"
-#include "core/frame/ContentSecurityPolicy.h"
-#include "core/frame/Frame.h"
+#include "core/frame/LocalFrame.h"
+#include "core/frame/csp/ContentSecurityPolicy.h"
#include "platform/TraceEvent.h"
#include "platform/weborigin/SecurityOrigin.h"
#include "public/platform/Platform.h"
@@ -65,8 +66,6 @@
namespace WebCore {
-static bool contextBeingInitialized = false;
-
static void checkDocumentWrapper(v8::Handle<v8::Object> wrapper, Document* document)
{
ASSERT(V8Document::toNative(wrapper) == document);
@@ -78,12 +77,12 @@
V8PerContextDebugData::setContextDebugData(targetContext, "injected", debugId);
}
-PassOwnPtr<V8WindowShell> V8WindowShell::create(Frame* frame, PassRefPtr<DOMWrapperWorld> world, v8::Isolate* isolate)
+PassOwnPtr<V8WindowShell> V8WindowShell::create(LocalFrame* frame, PassRefPtr<DOMWrapperWorld> world, v8::Isolate* isolate)
{
return adoptPtr(new V8WindowShell(frame, world, isolate));
}
-V8WindowShell::V8WindowShell(Frame* frame, PassRefPtr<DOMWrapperWorld> world, v8::Isolate* isolate)
+V8WindowShell::V8WindowShell(LocalFrame* frame, PassRefPtr<DOMWrapperWorld> world, v8::Isolate* isolate)
: m_frame(frame)
, m_world(world)
, m_isolate(isolate)
@@ -92,19 +91,17 @@
void V8WindowShell::disposeContext(GlobalDetachmentBehavior behavior)
{
- m_perContextData.clear();
-
- if (!m_contextHolder)
+ if (!m_perContextData)
return;
v8::HandleScope handleScope(m_isolate);
- v8::Handle<v8::Context> context = m_contextHolder->context();
+ v8::Handle<v8::Context> context = m_perContextData->context();
m_frame->loader().client()->willReleaseScriptContext(context, m_world->worldId());
if (behavior == DetachGlobal)
context->DetachGlobal();
- m_contextHolder.clear();
+ m_perContextData.clear();
// It's likely that disposing the context has created a lot of
// garbage. Notify V8 about this so it'll have a chance of cleaning
@@ -112,12 +109,9 @@
V8GCForContextDispose::instanceTemplate().notifyContextDisposed(m_frame->isMainFrame());
}
-void V8WindowShell::clearForClose(bool destroyGlobal)
+void V8WindowShell::clearForClose()
{
- if (destroyGlobal)
- m_global.clear();
-
- if (!m_contextHolder)
+ if (!m_perContextData)
return;
m_document.clear();
@@ -126,13 +120,13 @@
void V8WindowShell::clearForNavigation()
{
- if (!m_contextHolder)
+ if (!m_perContextData)
return;
v8::HandleScope handleScope(m_isolate);
m_document.clear();
- v8::Handle<v8::Context> context = m_contextHolder->context();
+ v8::Handle<v8::Context> context = m_perContextData->context();
v8::Context::Scope contextScope(context);
// Clear the document wrapper cache before turning on access checks on
@@ -140,7 +134,7 @@
// will be protected by the security checks on the DOMWindow wrapper.
clearDocumentProperty();
- v8::Handle<v8::Object> windowWrapper = m_global.newLocal(m_isolate)->FindInstanceInPrototypeChain(V8Window::domTemplate(m_isolate, worldTypeInMainThread(m_isolate)));
+ v8::Handle<v8::Object> windowWrapper = V8Window::findInstanceInPrototypeChain(m_global.newLocal(m_isolate), m_isolate);
ASSERT(!windowWrapper.IsEmpty());
windowWrapper->TurnOnAccessCheck();
disposeContext(DetachGlobal);
@@ -170,7 +164,7 @@
// global object of the context. A variable declared in the global
// scope is a property of the inner window.
//
-// The outer window sticks to a Frame, it is exposed to JavaScript
+// The outer window sticks to a LocalFrame, it is exposed to JavaScript
// via window.window, window.self, window.parent, etc. The outer window
// has a security token which is the domain. The outer window cannot
// have its own properties. window.foo = 'x' is delegated to the
@@ -183,13 +177,12 @@
// it won't be able to reach the outer window via its global object.
bool V8WindowShell::initializeIfNeeded()
{
- if (m_contextHolder)
+ if (m_perContextData)
return true;
- ASSERT(!contextBeingInitialized);
- contextBeingInitialized = true;
+ DOMWrapperWorld::setWorldOfInitializingWindow(m_world.get());
bool result = initialize();
- contextBeingInitialized = false;
+ DOMWrapperWorld::setWorldOfInitializingWindow(0);
return result;
}
@@ -202,14 +195,10 @@
createContext();
- if (!m_contextHolder)
+ if (!m_perContextData)
return false;
- v8::Handle<v8::Context> context = m_contextHolder->context();
-
- V8PerContextDataHolder::install(context, m_world.get());
- bool isMainWorld = m_world->isMainWorld();
-
+ v8::Handle<v8::Context> context = m_perContextData->context();
v8::Context::Scope contextScope(context);
if (m_global.isEmpty()) {
@@ -220,29 +209,24 @@
}
}
- if (!isMainWorld) {
+ if (!m_world->isMainWorld()) {
V8WindowShell* mainWindow = m_frame->script().existingWindowShell(DOMWrapperWorld::mainWorld());
if (mainWindow && !mainWindow->context().IsEmpty())
setInjectedScriptContextDebugId(context, m_frame->script().contextDebugId(mainWindow->context()));
}
- m_perContextData = V8PerContextData::create(context);
- if (!m_perContextData->init()) {
- disposeContext(DoNotDetachGlobal);
- return false;
- }
- m_perContextData->setActivityLogger(DOMWrapperWorld::activityLogger(m_world->worldId()));
+ m_perContextData->setActivityLogger(V8DOMActivityLogger::activityLogger(m_world->worldId()));
if (!installDOMWindow()) {
disposeContext(DoNotDetachGlobal);
return false;
}
- if (isMainWorld) {
+ if (m_world->isMainWorld()) {
updateDocument();
if (m_frame->document()) {
setSecurityToken(m_frame->document()->securityOrigin());
ContentSecurityPolicy* csp = m_frame->document()->contentSecurityPolicy();
- context->AllowCodeGenerationFromStrings(csp->allowScriptEval(0, ContentSecurityPolicy::SuppressReport));
+ context->AllowCodeGenerationFromStrings(csp->allowEval(0, ContentSecurityPolicy::SuppressReport));
context->SetErrorMessageForCodeGenerationFromStrings(v8String(m_isolate, csp->evalDisabledErrorMessage()));
}
} else {
@@ -273,7 +257,7 @@
// Create a new environment using an empty template for the shadow
// object. Reuse the global object if one has been created earlier.
- v8::Handle<v8::ObjectTemplate> globalTemplate = V8Window::getShadowObjectTemplate(m_isolate, m_world->isMainWorld() ? MainWorld : IsolatedWorld);
+ v8::Handle<v8::ObjectTemplate> globalTemplate = V8Window::getShadowObjectTemplate(m_isolate);
if (globalTemplate.IsEmpty())
return;
@@ -294,10 +278,9 @@
v8::ExtensionConfiguration extensionConfiguration(index, extensionNames.get());
v8::Handle<v8::Context> context = v8::Context::New(m_isolate, &extensionConfiguration, globalTemplate, m_global.newLocal(m_isolate));
- if (!context.IsEmpty()) {
- m_contextHolder = adoptPtr(new gin::ContextHolder(m_isolate));
- m_contextHolder->SetContext(context);
- }
+ if (context.IsEmpty())
+ return;
+ m_perContextData = V8PerContextData::create(context, m_world);
double contextCreationDurationInMilliseconds = (currentTime() - contextCreationStartInSeconds) * 1000;
const char* histogramName = "WebCore.V8WindowShell.createContext.MainWorld";
@@ -314,7 +297,7 @@
bool V8WindowShell::installDOMWindow()
{
DOMWindow* window = m_frame->domWindow();
- v8::Local<v8::Object> windowWrapper = V8ObjectConstructor::newInstance(V8PerContextData::from(m_contextHolder->context())->constructorForType(&V8Window::wrapperTypeInfo));
+ v8::Local<v8::Object> windowWrapper = V8ObjectConstructor::newInstance(V8PerContextData::from(m_perContextData->context())->constructorForType(&V8Window::wrapperTypeInfo));
if (windowWrapper.IsEmpty())
return false;
@@ -335,7 +318,7 @@
// outer, inner, and DOMWindow instance all appear to be the same
// JavaScript object.
//
- v8::Handle<v8::Object> innerGlobalObject = toInnerGlobalObject(m_contextHolder->context());
+ v8::Handle<v8::Object> innerGlobalObject = toInnerGlobalObject(m_perContextData->context());
V8DOMWrapper::setNativeInfo(innerGlobalObject, &V8Window::wrapperTypeInfo, window);
innerGlobalObject->SetPrototype(windowWrapper);
V8DOMWrapper::associateObjectWithWrapper<V8Window>(PassRefPtr<DOMWindow>(window), &V8Window::wrapperTypeInfo, windowWrapper, m_isolate, WrapperConfiguration::Dependent);
@@ -354,7 +337,7 @@
return;
v8::HandleScope handleScope(m_isolate);
- v8::Handle<v8::Context> context = m_contextHolder->context();
+ v8::Handle<v8::Context> context = m_perContextData->context();
v8::Context::Scope contextScope(context);
v8::Handle<v8::Value> documentWrapper = toV8(m_frame->document(), v8::Handle<v8::Object>(), context->GetIsolate());
@@ -375,16 +358,16 @@
// We also stash a reference to the document on the inner global object so that
// DOMWindow objects we obtain from JavaScript references are guaranteed to have
// live Document objects.
- setHiddenValue(m_isolate, toInnerGlobalObject(context), "document", documentWrapper);
+ V8HiddenValue::setHiddenValue(m_isolate, toInnerGlobalObject(context), V8HiddenValue::document(m_isolate), documentWrapper);
}
void V8WindowShell::clearDocumentProperty()
{
- ASSERT(m_contextHolder);
+ ASSERT(m_perContextData);
if (!m_world->isMainWorld())
return;
v8::HandleScope handleScope(m_isolate);
- m_contextHolder->context()->Global()->ForceDelete(v8AtomicString(m_isolate, "document"));
+ m_perContextData->context()->Global()->ForceDelete(v8AtomicString(m_isolate, "document"));
}
void V8WindowShell::setSecurityToken(SecurityOrigin* origin)
@@ -408,7 +391,7 @@
// case, we use the global object as the security token to avoid
// calling canAccess when a script accesses its own objects.
v8::HandleScope handleScope(m_isolate);
- v8::Handle<v8::Context> context = m_contextHolder->context();
+ v8::Handle<v8::Context> context = m_perContextData->context();
if (token.isEmpty() || token == "null") {
context->UseDefaultSecurityToken();
return;
@@ -425,7 +408,7 @@
ASSERT(m_world->isMainWorld());
if (m_global.isEmpty())
return;
- if (!m_contextHolder)
+ if (!m_perContextData)
return;
updateDocumentProperty();
updateSecurityOrigin(m_frame->document()->securityOrigin());
@@ -442,8 +425,9 @@
if (items->hasExactlyOneItem()) {
Element* element = items->item(0);
- Frame* frame = 0;
- if (element->hasTagName(HTMLNames::iframeTag) && (frame = toHTMLIFrameElement(element)->contentFrame()))
+ ASSERT(element);
+ LocalFrame* frame = 0;
+ if (isHTMLIFrameElement(*element) && (frame = toHTMLIFrameElement(*element).contentFrame()))
return toV8(frame->domWindow(), creationContext, isolate);
return toV8(element, creationContext, isolate);
}
@@ -472,11 +456,11 @@
{
ASSERT(m_world->isMainWorld());
- if (!m_contextHolder)
+ if (!m_perContextData)
return;
v8::HandleScope handleScope(m_isolate);
- v8::Context::Scope contextScope(m_contextHolder->context());
+ v8::Context::Scope contextScope(m_perContextData->context());
ASSERT(!m_document.isEmpty());
v8::Handle<v8::Object> documentHandle = m_document.newLocal(m_isolate);
@@ -488,14 +472,14 @@
{
ASSERT(m_world->isMainWorld());
- if (!m_contextHolder)
+ if (!m_perContextData)
return;
if (document->hasNamedItem(name) || document->hasExtraNamedItem(name))
return;
v8::HandleScope handleScope(m_isolate);
- v8::Context::Scope contextScope(m_contextHolder->context());
+ v8::Context::Scope contextScope(m_perContextData->context());
ASSERT(!m_document.isEmpty());
v8::Handle<v8::Object> documentHandle = m_document.newLocal(m_isolate);
@@ -506,21 +490,10 @@
void V8WindowShell::updateSecurityOrigin(SecurityOrigin* origin)
{
ASSERT(m_world->isMainWorld());
- if (!m_contextHolder)
+ if (!m_perContextData)
return;
v8::HandleScope handleScope(m_isolate);
setSecurityToken(origin);
}
-bool V8WindowShell::contextHasCorrectPrototype(v8::Handle<v8::Context> context)
-{
- if (!isMainThread())
- return true;
- // We're initializing the context, so it is not yet in a status where we can
- // validate the context.
- if (contextBeingInitialized)
- return true;
- return !!toDOMWindow(context);
-}
-
} // WebCore
diff --git a/Source/bindings/v8/V8WindowShell.h b/Source/bindings/v8/V8WindowShell.h
index 7b762d0..2ee6309 100644
--- a/Source/bindings/v8/V8WindowShell.h
+++ b/Source/bindings/v8/V8WindowShell.h
@@ -35,7 +35,6 @@
#include "bindings/v8/ScopedPersistent.h"
#include "bindings/v8/V8PerContextData.h"
#include "bindings/v8/WrapperTypeInfo.h"
-#include "gin/public/context_holder.h"
#include "platform/weborigin/SecurityOrigin.h"
#include "wtf/Forward.h"
#include "wtf/HashMap.h"
@@ -48,17 +47,17 @@
namespace WebCore {
class DOMWindow;
-class Frame;
+class LocalFrame;
class HTMLDocument;
class SecurityOrigin;
-// V8WindowShell represents all the per-global object state for a Frame that
+// V8WindowShell represents all the per-global object state for a LocalFrame that
// persist between navigations.
class V8WindowShell {
public:
- static PassOwnPtr<V8WindowShell> create(Frame*, PassRefPtr<DOMWrapperWorld>, v8::Isolate*);
+ static PassOwnPtr<V8WindowShell> create(LocalFrame*, PassRefPtr<DOMWrapperWorld>, v8::Isolate*);
- v8::Local<v8::Context> context() const { return m_contextHolder ? m_contextHolder->context() : v8::Local<v8::Context>(); }
+ v8::Local<v8::Context> context() const { return m_perContextData ? m_perContextData->context() : v8::Local<v8::Context>(); }
// Update document object of the frame.
void updateDocument();
@@ -70,20 +69,19 @@
// (e.g., after setting docoument.domain).
void updateSecurityOrigin(SecurityOrigin*);
- bool isContextInitialized() { return m_contextHolder; }
+ bool isContextInitialized() { return m_perContextData; }
bool isGlobalInitialized() { return !m_global.isEmpty(); }
bool initializeIfNeeded();
void updateDocumentWrapper(v8::Handle<v8::Object> wrapper);
void clearForNavigation();
- void clearForClose(bool destroyGlobal);
+ void clearForClose();
DOMWrapperWorld* world() { return m_world.get(); }
- static bool contextHasCorrectPrototype(v8::Handle<v8::Context>);
private:
- V8WindowShell(Frame*, PassRefPtr<DOMWrapperWorld>, v8::Isolate*);
+ V8WindowShell(LocalFrame*, PassRefPtr<DOMWrapperWorld>, v8::Isolate*);
bool initialize();
enum GlobalDetachmentBehavior {
@@ -106,13 +104,10 @@
static V8WindowShell* enteredIsolatedWorldContext();
- Frame* m_frame;
+ LocalFrame* m_frame;
RefPtr<DOMWrapperWorld> m_world;
v8::Isolate* m_isolate;
-
OwnPtr<V8PerContextData> m_perContextData;
-
- OwnPtr<gin::ContextHolder> m_contextHolder;
ScopedPersistent<v8::Object> m_global;
ScopedPersistent<v8::Object> m_document;
};
diff --git a/Source/bindings/v8/WorkerScriptController.cpp b/Source/bindings/v8/WorkerScriptController.cpp
index f220863..c26d085 100644
--- a/Source/bindings/v8/WorkerScriptController.cpp
+++ b/Source/bindings/v8/WorkerScriptController.cpp
@@ -59,18 +59,17 @@
namespace WebCore {
WorkerScriptController::WorkerScriptController(WorkerGlobalScope& workerGlobalScope)
- : m_workerGlobalScope(workerGlobalScope)
+ : m_isolate(v8::Isolate::New())
+ , m_workerGlobalScope(workerGlobalScope)
, m_executionForbidden(false)
, m_executionScheduledToTerminate(false)
{
- v8::Isolate* isolate = v8::Isolate::New();
- isolate->Enter();
- V8Initializer::initializeWorker(isolate);
+ m_isolate->Enter();
+ V8Initializer::initializeWorker(m_isolate);
v8::V8::Initialize();
- m_isolateHolder = adoptPtr(new gin::IsolateHolder(isolate));
- V8PerIsolateData::ensureInitialized(isolate);
- m_world = DOMWrapperWorld::create(WorkerWorldId, -1);
- m_interruptor = adoptPtr(new V8IsolateInterruptor(isolate));
+ V8PerIsolateData::ensureInitialized(m_isolate);
+ m_world = DOMWrapperWorld::create(WorkerWorldId);
+ m_interruptor = adoptPtr(new V8IsolateInterruptor(m_isolate));
ThreadState::current()->addInterruptor(m_interruptor.get());
}
@@ -79,33 +78,29 @@
// are destroyed.
class IsolateCleanupTask : public ThreadState::CleanupTask {
public:
- static PassOwnPtr<IsolateCleanupTask> create(PassOwnPtr<gin::IsolateHolder> isolateHolder)
+ static PassOwnPtr<IsolateCleanupTask> create(v8::Isolate* isolate)
{
- return adoptPtr(new IsolateCleanupTask(isolateHolder));
+ return adoptPtr(new IsolateCleanupTask(isolate));
}
virtual void postCleanup()
{
- v8::Isolate* isolate = m_isolateHolder->isolate();
- V8PerIsolateData::dispose(isolate);
- isolate->Exit();
- m_isolateHolder.clear();
- isolate->Dispose();
+ V8PerIsolateData::dispose(m_isolate);
+ m_isolate->Exit();
+ m_isolate->Dispose();
}
private:
- explicit IsolateCleanupTask(PassOwnPtr<gin::IsolateHolder> isolateHolder) : m_isolateHolder(isolateHolder) { }
+ explicit IsolateCleanupTask(v8::Isolate* isolate) : m_isolate(isolate) { }
- OwnPtr<gin::IsolateHolder> m_isolateHolder;
+ v8::Isolate* m_isolate;
};
WorkerScriptController::~WorkerScriptController()
{
ThreadState::current()->removeInterruptor(m_interruptor.get());
- RELEASE_ASSERT(m_world->hasOneRef());
- // ~DOMWrapperWorld() must be called before disposing the isolate.
- m_world = 0;
+ m_world->dispose();
// The corresponding call to didStartWorkerRunLoop is in
// WorkerThread::workerThread().
@@ -114,39 +109,29 @@
disposeContext();
- ThreadState::current()->addCleanupTask(IsolateCleanupTask::create(m_isolateHolder.release()));
+ ThreadState::current()->addCleanupTask(IsolateCleanupTask::create(m_isolate));
}
void WorkerScriptController::disposeContext()
{
m_perContextData.clear();
- m_contextHolder.clear();
}
bool WorkerScriptController::initializeContextIfNeeded()
{
- if (m_contextHolder)
+ if (m_perContextData)
return true;
- v8::Handle<v8::Context> context = v8::Context::New(isolate());
+ v8::Handle<v8::Context> context = v8::Context::New(m_isolate);
if (context.IsEmpty())
return false;
- m_contextHolder = adoptPtr(new gin::ContextHolder(isolate()));
- m_contextHolder->SetContext(context);
+ m_perContextData = V8PerContextData::create(context, m_world);
v8::Context::Scope scope(context);
- V8PerContextDataHolder::install(context, m_world.get());
-
- m_perContextData = V8PerContextData::create(context);
- if (!m_perContextData->init()) {
- disposeContext();
- return false;
- }
-
// Set DebugId for the new context.
- context->SetEmbedderData(0, v8AtomicString(isolate(), "worker"));
+ context->SetEmbedderData(0, v8AtomicString(m_isolate, "worker"));
// Create a new JS object and use it as the prototype for the shadow global object.
const WrapperTypeInfo* contextType = &V8DedicatedWorkerGlobalScope::wrapperTypeInfo;
@@ -161,10 +146,10 @@
return false;
}
- V8DOMWrapper::associateObjectWithWrapper<V8WorkerGlobalScope>(PassRefPtr<WorkerGlobalScope>(m_workerGlobalScope), contextType, jsWorkerGlobalScope, isolate(), WrapperConfiguration::Dependent);
+ V8DOMWrapper::associateObjectWithWrapper<V8WorkerGlobalScope>(PassRefPtrWillBeRawPtr<WorkerGlobalScope>(&m_workerGlobalScope), contextType, jsWorkerGlobalScope, m_isolate, WrapperConfiguration::Dependent);
// Insert the object instance as the prototype of the shadow object.
- v8::Handle<v8::Object> globalObject = v8::Handle<v8::Object>::Cast(m_contextHolder->context()->Global()->GetPrototype());
+ v8::Handle<v8::Object> globalObject = v8::Handle<v8::Object>::Cast(m_perContextData->context()->Global()->GetPrototype());
globalObject->SetPrototype(jsWorkerGlobalScope);
return true;
@@ -172,15 +157,15 @@
ScriptValue WorkerScriptController::evaluate(const String& script, const String& fileName, const TextPosition& scriptStartPosition, WorkerGlobalScopeExecutionState* state)
{
- v8::HandleScope handleScope(isolate());
+ v8::HandleScope handleScope(m_isolate);
if (!initializeContextIfNeeded())
return ScriptValue();
- v8::Handle<v8::Context> context = m_contextHolder->context();
+ v8::Handle<v8::Context> context = m_perContextData->context();
if (!m_disableEvalPending.isEmpty()) {
context->AllowCodeGenerationFromStrings(false);
- context->SetErrorMessageForCodeGenerationFromStrings(v8String(isolate(), m_disableEvalPending));
+ context->SetErrorMessageForCodeGenerationFromStrings(v8String(m_isolate, m_disableEvalPending));
m_disableEvalPending = String();
}
@@ -188,9 +173,9 @@
v8::TryCatch block;
- v8::Handle<v8::String> scriptString = v8String(isolate(), script);
- v8::Handle<v8::Script> compiledScript = V8ScriptRunner::compileScript(scriptString, fileName, scriptStartPosition, 0, isolate());
- v8::Local<v8::Value> result = V8ScriptRunner::runCompiledScript(compiledScript, &m_workerGlobalScope, isolate());
+ v8::Handle<v8::String> scriptString = v8String(m_isolate, script);
+ v8::Handle<v8::Script> compiledScript = V8ScriptRunner::compileScript(scriptString, fileName, scriptStartPosition, 0, m_isolate);
+ v8::Local<v8::Value> result = V8ScriptRunner::runCompiledScript(compiledScript, &m_workerGlobalScope, m_isolate);
if (!block.CanContinue()) {
m_workerGlobalScope.script()->forbidExecution();
@@ -205,7 +190,7 @@
state->columnNumber = message->GetStartColumn() + 1;
V8TRYCATCH_FOR_V8STRINGRESOURCE_RETURN(V8StringResource<>, sourceURL, message->GetScriptResourceName(), ScriptValue());
state->sourceURL = sourceURL;
- state->exception = ScriptValue(block.Exception(), isolate());
+ state->exception = ScriptValue(block.Exception(), m_isolate);
block.Reset();
} else
state->hadException = false;
@@ -213,7 +198,7 @@
if (result.IsEmpty() || result->IsUndefined())
return ScriptValue();
- return ScriptValue(result, isolate());
+ return ScriptValue(result, m_isolate);
}
void WorkerScriptController::evaluate(const ScriptSourceCode& sourceCode, RefPtr<ErrorEvent>* errorEvent)
@@ -227,11 +212,11 @@
if (errorEvent) {
*errorEvent = m_workerGlobalScope.shouldSanitizeScriptError(state.sourceURL, NotSharableCrossOrigin) ?
ErrorEvent::createSanitizedError(0) : ErrorEvent::create(state.errorMessage, state.sourceURL, state.lineNumber, state.columnNumber, 0);
- V8ErrorHandler::storeExceptionOnErrorEventWrapper(errorEvent->get(), state.exception.v8Value(), isolate());
+ V8ErrorHandler::storeExceptionOnErrorEventWrapper(errorEvent->get(), state.exception.v8Value(), m_isolate);
} else {
ASSERT(!m_workerGlobalScope.shouldSanitizeScriptError(state.sourceURL, NotSharableCrossOrigin));
RefPtr<ErrorEvent> event = m_errorEventFromImportedScript ? m_errorEventFromImportedScript.release() : ErrorEvent::create(state.errorMessage, state.sourceURL, state.lineNumber, state.columnNumber, 0);
- m_workerGlobalScope.reportException(event, 0, NotSharableCrossOrigin);
+ m_workerGlobalScope.reportException(event, nullptr, NotSharableCrossOrigin);
}
}
}
@@ -245,7 +230,7 @@
MutexLocker locker(m_scheduledTerminationMutex);
m_executionScheduledToTerminate = true;
}
- v8::V8::TerminateExecution(isolate());
+ v8::V8::TerminateExecution(m_isolate);
}
bool WorkerScriptController::isExecutionTerminating() const
@@ -275,22 +260,7 @@
void WorkerScriptController::rethrowExceptionFromImportedScript(PassRefPtr<ErrorEvent> errorEvent)
{
m_errorEventFromImportedScript = errorEvent;
- throwError(V8ThrowException::createError(v8GeneralError, m_errorEventFromImportedScript->message(), isolate()), isolate());
-}
-
-WorkerScriptController* WorkerScriptController::controllerForContext(v8::Isolate* isolate)
-{
- // Happens on frame destruction, check otherwise GetCurrent() will crash.
- if (!isolate || !isolate->InContext())
- return 0;
- v8::Handle<v8::Context> context = isolate->GetCurrentContext();
- v8::Handle<v8::Object> global = context->Global();
- global = global->FindInstanceInPrototypeChain(V8WorkerGlobalScope::domTemplate(isolate, WorkerWorld));
- // Return 0 if the current executing context is not the worker context.
- if (global.IsEmpty())
- return 0;
- WorkerGlobalScope* workerGlobalScope = V8WorkerGlobalScope::toNative(global);
- return workerGlobalScope->script();
+ throwError(V8ThrowException::createError(v8GeneralError, m_errorEventFromImportedScript->message(), m_isolate), m_isolate);
}
} // namespace WebCore
diff --git a/Source/bindings/v8/WorkerScriptController.h b/Source/bindings/v8/WorkerScriptController.h
index 5c66c12..cd452e3 100644
--- a/Source/bindings/v8/WorkerScriptController.h
+++ b/Source/bindings/v8/WorkerScriptController.h
@@ -34,17 +34,11 @@
#include "bindings/v8/ScriptValue.h"
#include "bindings/v8/V8Binding.h"
#include "core/events/ErrorEvent.h"
-#include "gin/public/context_holder.h"
-#include "gin/public/isolate_holder.h"
#include "wtf/OwnPtr.h"
#include "wtf/ThreadingPrimitives.h"
#include "wtf/text/TextPosition.h"
#include <v8.h>
-namespace gin {
-class IsolateHolder;
-}
-
namespace WebCore {
class ScriptSourceCode;
@@ -93,29 +87,24 @@
void disableEval(const String&);
- // Returns WorkerScriptController for the currently executing context. 0 will be returned if the current executing context is not the worker context.
- static WorkerScriptController* controllerForContext(v8::Isolate*);
-
// Evaluate a script file in the current execution environment.
ScriptValue evaluate(const String& script, const String& fileName, const TextPosition& scriptStartPosition, WorkerGlobalScopeExecutionState*);
- // Returns a local handle of the context.
- v8::Local<v8::Context> context() { return m_contextHolder ? m_contextHolder->context() : v8::Local<v8::Context>(); }
+ v8::Isolate* isolate() const { return m_isolate; }
+ DOMWrapperWorld* world() const { return m_world.get(); }
+ v8::Local<v8::Context> context() { return m_perContextData ? m_perContextData->context() : v8::Local<v8::Context>(); }
// Send a notification about current thread is going to be idle.
// Returns true if the embedder should stop calling idleNotification
// until real work has been done.
bool idleNotification() { return v8::V8::IdleNotification(); }
- v8::Isolate* isolate() const { return m_isolateHolder->isolate(); }
-
private:
bool initializeContextIfNeeded();
void disposeContext();
+ v8::Isolate* m_isolate;
WorkerGlobalScope& m_workerGlobalScope;
- OwnPtr<gin::IsolateHolder> m_isolateHolder;
- OwnPtr<gin::ContextHolder> m_contextHolder;
OwnPtr<V8PerContextData> m_perContextData;
String m_disableEvalPending;
RefPtr<DOMWrapperWorld> m_world;
diff --git a/Source/bindings/v8/WorkerScriptDebugServer.cpp b/Source/bindings/v8/WorkerScriptDebugServer.cpp
index 45f88c5..171c60f 100644
--- a/Source/bindings/v8/WorkerScriptDebugServer.cpp
+++ b/Source/bindings/v8/WorkerScriptDebugServer.cpp
@@ -42,11 +42,10 @@
namespace WebCore {
-WorkerScriptDebugServer::WorkerScriptDebugServer(WorkerGlobalScope* workerGlobalScope, const String& mode)
+WorkerScriptDebugServer::WorkerScriptDebugServer(WorkerGlobalScope* workerGlobalScope)
: ScriptDebugServer(v8::Isolate::GetCurrent())
, m_listener(0)
, m_workerGlobalScope(workerGlobalScope)
- , m_debuggerTaskMode(mode)
{
ASSERT(m_isolate);
}
@@ -98,7 +97,7 @@
{
MessageQueueWaitResult result;
do {
- result = m_workerGlobalScope->thread()->runLoop().runInMode(m_workerGlobalScope, m_debuggerTaskMode);
+ result = m_workerGlobalScope->thread()->runLoop().runDebuggerTask();
// Keep waiting until execution is resumed.
} while (result == MessageQueueMessageReceived && isPaused());
diff --git a/Source/bindings/v8/WorkerScriptDebugServer.h b/Source/bindings/v8/WorkerScriptDebugServer.h
index ba17627..443ba93 100644
--- a/Source/bindings/v8/WorkerScriptDebugServer.h
+++ b/Source/bindings/v8/WorkerScriptDebugServer.h
@@ -45,7 +45,7 @@
class WorkerScriptDebugServer FINAL : public ScriptDebugServer {
WTF_MAKE_NONCOPYABLE(WorkerScriptDebugServer);
public:
- WorkerScriptDebugServer(WorkerGlobalScope*, const String&);
+ WorkerScriptDebugServer(WorkerGlobalScope*);
virtual ~WorkerScriptDebugServer() { }
void addListener(ScriptDebugListener*);
@@ -61,7 +61,6 @@
typedef HashMap<WorkerGlobalScope*, ScriptDebugListener*> ListenersMap;
ScriptDebugListener* m_listener;
WorkerGlobalScope* m_workerGlobalScope;
- String m_debuggerTaskMode;
};
} // namespace WebCore
diff --git a/Source/bindings/v8/WrapperTypeInfo.h b/Source/bindings/v8/WrapperTypeInfo.h
index 2813aa6..ca2a583 100644
--- a/Source/bindings/v8/WrapperTypeInfo.h
+++ b/Source/bindings/v8/WrapperTypeInfo.h
@@ -51,13 +51,7 @@
static const uint16_t v8DOMNodeClassId = 1;
static const uint16_t v8DOMObjectClassId = 2;
- enum WrapperWorldType {
- MainWorld,
- IsolatedWorld,
- WorkerWorld
- };
-
- typedef v8::Handle<v8::FunctionTemplate> (*DomTemplateFunction)(v8::Isolate*, WrapperWorldType);
+ typedef v8::Handle<v8::FunctionTemplate> (*DomTemplateFunction)(v8::Isolate*);
typedef void (*DerefObjectFunction)(void*);
typedef ActiveDOMObject* (*ToActiveDOMObjectFunction)(v8::Handle<v8::Object>);
typedef EventTarget* (*ToEventTargetFunction)(v8::Handle<v8::Object>);
@@ -100,7 +94,10 @@
return false;
}
- v8::Handle<v8::FunctionTemplate> domTemplate(v8::Isolate* isolate, WrapperWorldType worldType) const { return domTemplateFunction(isolate, worldType); }
+ v8::Handle<v8::FunctionTemplate> domTemplate(v8::Isolate* isolate) const
+ {
+ return domTemplateFunction(isolate);
+ }
void installPerContextEnabledMethods(v8::Handle<v8::Object> prototypeTemplate, v8::Isolate* isolate) const
{
@@ -235,11 +232,6 @@
WrapperConfiguration configuration = {v8DOMNodeClassId, lifetime};
return configuration;
}
-
- template<class ElementType>
- class WrapperTypeTraits {
- // specialized classes have thier own functions, which are generated by binding generator.
- };
}
#endif // WrapperTypeInfo_h
diff --git a/Source/bindings/v8/custom/V8ArrayBufferCustom.cpp b/Source/bindings/v8/custom/V8ArrayBufferCustom.cpp
index 497caec..bc02218 100644
--- a/Source/bindings/v8/custom/V8ArrayBufferCustom.cpp
+++ b/Source/bindings/v8/custom/V8ArrayBufferCustom.cpp
@@ -76,12 +76,11 @@
ArrayBuffer* V8ArrayBuffer::toNative(v8::Handle<v8::Object> object)
{
ASSERT(object->IsArrayBuffer());
- void* arraybufferPtr = object->GetAlignedPointerFromInternalField(v8DOMWrapperObjectIndex);
- if (arraybufferPtr)
- return reinterpret_cast<ArrayBuffer*>(arraybufferPtr);
-
v8::Local<v8::ArrayBuffer> v8buffer = object.As<v8::ArrayBuffer>();
- ASSERT(!v8buffer->IsExternal());
+ if (v8buffer->IsExternal()) {
+ RELEASE_ASSERT(toWrapperTypeInfo(object)->ginEmbedder == gin::kEmbedderBlink);
+ return reinterpret_cast<ArrayBuffer*>(WebCore::toNative(object));
+ }
v8::ArrayBuffer::Contents v8Contents = v8buffer->Externalize();
ArrayBufferContents contents(v8Contents.Data(), v8Contents.ByteLength(),
@@ -89,9 +88,12 @@
RefPtr<ArrayBuffer> buffer = ArrayBuffer::create(contents);
V8DOMWrapper::associateObjectWithWrapper<V8ArrayBuffer>(buffer.release(), &wrapperTypeInfo, object, v8::Isolate::GetCurrent(), WrapperConfiguration::Dependent);
- arraybufferPtr = object->GetAlignedPointerFromInternalField(v8DOMWrapperObjectIndex);
- ASSERT(arraybufferPtr);
- return reinterpret_cast<ArrayBuffer*>(arraybufferPtr);
+ return reinterpret_cast<ArrayBuffer*>(WebCore::toNative(object));
+}
+
+ArrayBuffer* V8ArrayBuffer::toNativeWithTypeCheck(v8::Isolate* isolate, v8::Handle<v8::Value> value)
+{
+ return V8ArrayBuffer::hasInstance(value, isolate) ? V8ArrayBuffer::toNative(v8::Handle<v8::Object>::Cast(value)) : 0;
}
template<>
diff --git a/Source/bindings/v8/custom/V8ArrayBufferCustom.h b/Source/bindings/v8/custom/V8ArrayBufferCustom.h
index d0efbcf..c90760a 100644
--- a/Source/bindings/v8/custom/V8ArrayBufferCustom.h
+++ b/Source/bindings/v8/custom/V8ArrayBufferCustom.h
@@ -53,6 +53,7 @@
public:
static bool hasInstance(v8::Handle<v8::Value>, v8::Isolate*);
static ArrayBuffer* toNative(v8::Handle<v8::Object>);
+ static ArrayBuffer* toNativeWithTypeCheck(v8::Isolate*, v8::Handle<v8::Value>);
static void derefObject(void*);
static const WrapperTypeInfo wrapperTypeInfo;
static const int internalFieldCount = v8DefaultWrapperInternalFieldCount;
@@ -74,13 +75,6 @@
static v8::Handle<v8::Object> createWrapper(PassRefPtr<ArrayBuffer>, v8::Handle<v8::Object> creationContext, v8::Isolate*);
};
-template<>
-class WrapperTypeTraits<ArrayBuffer > {
-public:
- static const WrapperTypeInfo* wrapperTypeInfo() { return &V8ArrayBuffer::wrapperTypeInfo; }
-};
-
-
inline v8::Handle<v8::Object> wrap(ArrayBuffer* impl, v8::Handle<v8::Object> creationContext, v8::Isolate* isolate)
{
ASSERT(impl);
@@ -114,7 +108,7 @@
template<class CallbackInfo>
inline void v8SetReturnValueForMainWorld(const CallbackInfo& info, ArrayBuffer* impl)
{
- ASSERT(worldType(info.GetIsolate()) == MainWorld);
+ ASSERT(DOMWrapperWorld::current(info.GetIsolate())->isMainWorld());
if (UNLIKELY(!impl)) {
v8SetReturnValueNull(info);
return;
diff --git a/Source/bindings/v8/custom/V8ArrayBufferViewCustom.cpp b/Source/bindings/v8/custom/V8ArrayBufferViewCustom.cpp
index 4f00d0d..5ee873d 100644
--- a/Source/bindings/v8/custom/V8ArrayBufferViewCustom.cpp
+++ b/Source/bindings/v8/custom/V8ArrayBufferViewCustom.cpp
@@ -82,5 +82,9 @@
return 0;
}
+ArrayBufferView* V8ArrayBufferView::toNativeWithTypeCheck(v8::Isolate* isolate, v8::Handle<v8::Value> value)
+{
+ return V8ArrayBufferView::hasInstance(value, isolate) ? V8ArrayBufferView::toNative(v8::Handle<v8::Object>::Cast(value)) : 0;
+}
} // namespace WebCore
diff --git a/Source/bindings/v8/custom/V8ArrayBufferViewCustom.h b/Source/bindings/v8/custom/V8ArrayBufferViewCustom.h
index 90af106..7ff95bf 100644
--- a/Source/bindings/v8/custom/V8ArrayBufferViewCustom.h
+++ b/Source/bindings/v8/custom/V8ArrayBufferViewCustom.h
@@ -48,6 +48,7 @@
return value->IsArrayBufferView();
}
static ArrayBufferView* toNative(v8::Handle<v8::Object>);
+ static ArrayBufferView* toNativeWithTypeCheck(v8::Isolate*, v8::Handle<v8::Value>);
static inline void* toInternalPointer(ArrayBufferView* impl)
{
diff --git a/Source/bindings/v8/custom/V8BlobCustom.cpp b/Source/bindings/v8/custom/V8BlobCustom.cpp
index 94a4ff4..d4bc1c2 100644
--- a/Source/bindings/v8/custom/V8BlobCustom.cpp
+++ b/Source/bindings/v8/custom/V8BlobCustom.cpp
@@ -40,7 +40,7 @@
{
ExceptionState exceptionState(ExceptionState::ConstructionContext, "Blob", info.Holder(), info.GetIsolate());
if (!info.Length()) {
- RefPtr<Blob> blob = Blob::create();
+ RefPtrWillBeRawPtr<Blob> blob = Blob::create();
v8SetReturnValue(info, blob.release());
return;
}
@@ -78,7 +78,7 @@
return;
long long blobSize = blobData->length();
- RefPtr<Blob> blob = Blob::create(BlobDataHandle::create(blobData.release(), blobSize));
+ RefPtrWillBeRawPtr<Blob> blob = Blob::create(BlobDataHandle::create(blobData.release(), blobSize));
v8SetReturnValue(info, blob.release());
}
diff --git a/Source/bindings/v8/custom/V8BlobCustomHelpers.cpp b/Source/bindings/v8/custom/V8BlobCustomHelpers.cpp
index c7d381b..10c4693 100644
--- a/Source/bindings/v8/custom/V8BlobCustomHelpers.cpp
+++ b/Source/bindings/v8/custom/V8BlobCustomHelpers.cpp
@@ -35,7 +35,6 @@
#include "bindings/v8/Dictionary.h"
#include "bindings/v8/ExceptionState.h"
#include "bindings/v8/V8Binding.h"
-#include "bindings/v8/V8Utilities.h"
#include "bindings/v8/custom/V8ArrayBufferCustom.h"
#include "bindings/v8/custom/V8ArrayBufferViewCustom.h"
#include "wtf/DateMath.h"
diff --git a/Source/bindings/v8/custom/V8CSSStyleDeclarationCustom.cpp b/Source/bindings/v8/custom/V8CSSStyleDeclarationCustom.cpp
index 6dd83c4..170a373 100644
--- a/Source/bindings/v8/custom/V8CSSStyleDeclarationCustom.cpp
+++ b/Source/bindings/v8/custom/V8CSSStyleDeclarationCustom.cpp
@@ -40,7 +40,6 @@
#include "core/css/CSSValue.h"
#include "core/css/RuntimeCSSEnabled.h"
#include "core/events/EventTarget.h"
-#include "core/frame/UseCounter.h"
#include "wtf/ASCIICType.h"
#include "wtf/PassRefPtr.h"
#include "wtf/RefPtr.h"
@@ -82,19 +81,9 @@
}
struct CSSPropertyInfo {
- unsigned propID: 30; // CSSPropertyID
- unsigned nameWithDash: 1;
- unsigned nameWithCssPrefix: 1;
+ CSSPropertyID propID;
};
-static inline void countCssPropertyInfoUsage(v8::Isolate* isolate, const CSSPropertyInfo& propInfo)
-{
- if (propInfo.nameWithDash)
- UseCounter::count(activeExecutionContext(isolate), UseCounter::CSSStyleDeclarationPropertyName);
- if (propInfo.propID == CSSPropertyFloat && !propInfo.nameWithCssPrefix)
- UseCounter::count(activeExecutionContext(isolate), UseCounter::CSSStyleDeclarationFloatPropertyName);
-}
-
// When getting properties on CSSStyleDeclarations, the name used from
// Javascript and the actual name of the property are not the same, so
// we have to do the following translation. The translation turns upper
@@ -120,16 +109,13 @@
unsigned i = 0;
bool hasSeenDash = false;
- bool hasSeenCssPrefix = false;
- if (hasCSSPropertyNamePrefix(propertyName, "css")) {
- hasSeenCssPrefix = true;
+ if (hasCSSPropertyNamePrefix(propertyName, "css"))
i += 3;
- } else if (hasCSSPropertyNamePrefix(propertyName, "webkit")) {
+ else if (hasCSSPropertyNamePrefix(propertyName, "webkit"))
builder.append('-');
- } else if (isASCIIUpper(propertyName[0])) {
+ else if (isASCIIUpper(propertyName[0]))
return 0;
- }
bool hasSeenUpper = isASCIIUpper(propertyName[i]);
@@ -158,8 +144,6 @@
if (propertyID && RuntimeCSSEnabled::isCSSPropertyEnabled(propertyID)) {
propInfo = new CSSPropertyInfo();
propInfo->propID = propertyID;
- propInfo->nameWithDash = hasSeenDash;
- propInfo->nameWithCssPrefix = hasSeenCssPrefix;
map.add(propertyName, propInfo);
}
}
@@ -196,8 +180,7 @@
{
// NOTE: cssPropertyInfo lookups incur several mallocs.
// Successful lookups have the same cost the first time, but are cached.
- if (CSSPropertyInfo* propInfo = cssPropertyInfo(v8Name)) {
- countCssPropertyInfoUsage(info.GetIsolate(), *propInfo);
+ if (cssPropertyInfo(v8Name)) {
v8SetReturnValueInt(info, 0);
return;
}
@@ -216,9 +199,8 @@
if (!propInfo)
return;
- countCssPropertyInfoUsage(info.GetIsolate(), *propInfo);
CSSStyleDeclaration* imp = V8CSSStyleDeclaration::toNative(info.Holder());
- RefPtr<CSSValue> cssValue = imp->getPropertyCSSValueInternal(static_cast<CSSPropertyID>(propInfo->propID));
+ RefPtrWillBeRawPtr<CSSValue> cssValue = imp->getPropertyCSSValueInternal(static_cast<CSSPropertyID>(propInfo->propID));
if (cssValue) {
v8SetReturnValueStringOrNull(info, cssValue->cssText(), info.GetIsolate());
return;
@@ -238,7 +220,6 @@
if (!propInfo)
return;
- countCssPropertyInfoUsage(info.GetIsolate(), *propInfo);
V8TRYCATCH_FOR_V8STRINGRESOURCE_VOID(V8StringResource<WithNullCheck>, propertyValue, value);
ExceptionState exceptionState(ExceptionState::SetterContext, getPropertyName(static_cast<CSSPropertyID>(propInfo->propID)), "CSSStyleDeclaration", info.Holder(), info.GetIsolate());
imp->setPropertyInternal(static_cast<CSSPropertyID>(propInfo->propID), propertyValue, false, exceptionState);
diff --git a/Source/bindings/v8/custom/V8CanvasRenderingContext2DCustom.cpp b/Source/bindings/v8/custom/V8CanvasRenderingContext2DCustom.cpp
index 3ceda56..0351c80 100644
--- a/Source/bindings/v8/custom/V8CanvasRenderingContext2DCustom.cpp
+++ b/Source/bindings/v8/custom/V8CanvasRenderingContext2DCustom.cpp
@@ -59,13 +59,10 @@
static PassRefPtr<CanvasStyle> toCanvasStyle(v8::Handle<v8::Value> value, v8::Isolate* isolate)
{
- if (V8CanvasGradient::hasInstance(value, isolate))
- return CanvasStyle::createFromGradient(V8CanvasGradient::toNative(v8::Handle<v8::Object>::Cast(value)));
-
- if (V8CanvasPattern::hasInstance(value, isolate))
- return CanvasStyle::createFromPattern(V8CanvasPattern::toNative(v8::Handle<v8::Object>::Cast(value)));
-
- return 0;
+ RefPtr<CanvasStyle> canvasStyle = CanvasStyle::createFromGradient(V8CanvasGradient::toNativeWithTypeCheck(isolate, value));
+ if (canvasStyle)
+ return canvasStyle;
+ return CanvasStyle::createFromPattern(V8CanvasPattern::toNativeWithTypeCheck(isolate, value));
}
void V8CanvasRenderingContext2D::strokeStyleAttributeGetterCustom(const v8::PropertyCallbackInfo<v8::Value>& info)
diff --git a/Source/bindings/v8/custom/V8CanvasRenderingContextCustom.cpp b/Source/bindings/v8/custom/V8CanvasRenderingContextCustom.cpp
deleted file mode 100644
index 66a73c4..0000000
--- a/Source/bindings/v8/custom/V8CanvasRenderingContextCustom.cpp
+++ /dev/null
@@ -1,51 +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 "V8CanvasRenderingContext.h"
-
-#include "V8CanvasRenderingContext2D.h"
-#include "V8WebGLRenderingContext.h"
-#include "core/html/canvas/CanvasRenderingContext.h"
-
-namespace WebCore {
-
-v8::Handle<v8::Object> wrap(CanvasRenderingContext* impl, v8::Handle<v8::Object> creationContext, v8::Isolate* isolate)
-{
- ASSERT(impl);
- if (impl->is2d())
- return wrap(toCanvasRenderingContext2D(impl), creationContext, isolate);
- if (impl->is3d())
- return wrap(toWebGLRenderingContext(impl), creationContext, isolate);
- ASSERT_NOT_REACHED();
- return v8::Handle<v8::Object>();
-}
-
-} // namespace WebCore
diff --git a/Source/bindings/v8/custom/V8CryptoCustom.cpp b/Source/bindings/v8/custom/V8CryptoCustom.cpp
index ea17e68..f43b552 100644
--- a/Source/bindings/v8/custom/V8CryptoCustom.cpp
+++ b/Source/bindings/v8/custom/V8CryptoCustom.cpp
@@ -28,7 +28,6 @@
#include "bindings/v8/ExceptionMessages.h"
#include "bindings/v8/ExceptionState.h"
#include "bindings/v8/V8Binding.h"
-#include "bindings/v8/V8Utilities.h"
#include "bindings/v8/custom/V8ArrayBufferViewCustom.h"
#include "core/dom/ExceptionCode.h"
#include "modules/crypto/Crypto.h"
diff --git a/Source/bindings/v8/custom/V8CustomEventCustom.cpp b/Source/bindings/v8/custom/V8CustomEventCustom.cpp
index 2fad03d..7241ffc 100644
--- a/Source/bindings/v8/custom/V8CustomEventCustom.cpp
+++ b/Source/bindings/v8/custom/V8CustomEventCustom.cpp
@@ -38,13 +38,14 @@
#include "bindings/v8/SerializedScriptValue.h"
#include "bindings/v8/V8Binding.h"
#include "bindings/v8/V8DOMWrapper.h"
+#include "bindings/v8/V8HiddenValue.h"
#include "core/dom/ContextFeatures.h"
namespace WebCore {
static v8::Handle<v8::Value> cacheState(v8::Handle<v8::Object> customEvent, v8::Handle<v8::Value> detail, v8::Isolate* isolate)
{
- setHiddenValue(isolate, customEvent, "detail", detail);
+ V8HiddenValue::setHiddenValue(isolate, customEvent, V8HiddenValue::detail(isolate), detail);
return detail;
}
@@ -53,7 +54,7 @@
{
CustomEvent* event = V8CustomEvent::toNative(info.Holder());
- v8::Handle<v8::Value> result = getHiddenValue(info.GetIsolate(), info.Holder(), "detail");
+ v8::Handle<v8::Value> result = V8HiddenValue::getHiddenValue(info.GetIsolate(), info.Holder(), V8HiddenValue::detail(info.GetIsolate()));
if (!result.IsEmpty()) {
v8SetReturnValue(info, result);
@@ -63,7 +64,7 @@
if (!event->serializedDetail()) {
// If we're in an isolated world and the event was created in the main world,
// we need to find the 'detail' property on the main world wrapper and clone it.
- v8::Local<v8::Value> mainWorldDetail = getHiddenValueFromMainWorldWrapper(info.GetIsolate(), event, "detail");
+ v8::Local<v8::Value> mainWorldDetail = V8HiddenValue::getHiddenValueFromMainWorldWrapper(info.GetIsolate(), event, V8HiddenValue::detail(info.GetIsolate()));
if (!mainWorldDetail.IsEmpty())
event->setSerializedDetail(SerializedScriptValue::createAndSwallowExceptions(mainWorldDetail, info.GetIsolate()));
}
@@ -90,7 +91,7 @@
event->initEvent(typeArg, canBubbleArg, cancelableArg);
if (!detailsArg.IsEmpty()) {
- setHiddenValue(info.GetIsolate(), info.Holder(), "detail", detailsArg);
+ V8HiddenValue::setHiddenValue(info.GetIsolate(), info.Holder(), V8HiddenValue::detail(info.GetIsolate()), detailsArg);
if (DOMWrapperWorld::current(info.GetIsolate())->isIsolatedWorld())
event->setSerializedDetail(SerializedScriptValue::createAndSwallowExceptions(detailsArg, info.GetIsolate()));
}
diff --git a/Source/bindings/v8/custom/V8CustomXPathNSResolver.cpp b/Source/bindings/v8/custom/V8CustomXPathNSResolver.cpp
index d1659b2..79a5aa3 100644
--- a/Source/bindings/v8/custom/V8CustomXPathNSResolver.cpp
+++ b/Source/bindings/v8/custom/V8CustomXPathNSResolver.cpp
@@ -32,20 +32,19 @@
#include "bindings/v8/ScriptController.h"
#include "bindings/v8/V8Binding.h"
-#include "bindings/v8/V8Utilities.h"
#include "core/dom/ExecutionContext.h"
-#include "core/inspector/ScriptCallStack.h"
#include "core/frame/DOMWindow.h"
-#include "core/frame/Frame.h"
#include "core/frame/FrameHost.h"
+#include "core/frame/LocalFrame.h"
#include "core/frame/PageConsole.h"
+#include "core/inspector/ScriptCallStack.h"
#include "wtf/text/WTFString.h"
namespace WebCore {
-PassRefPtr<V8CustomXPathNSResolver> V8CustomXPathNSResolver::create(v8::Handle<v8::Object> resolver, v8::Isolate* isolate)
+PassRefPtrWillBeRawPtr<V8CustomXPathNSResolver> V8CustomXPathNSResolver::create(v8::Handle<v8::Object> resolver, v8::Isolate* isolate)
{
- return adoptRef(new V8CustomXPathNSResolver(resolver, isolate));
+ return adoptRefWillBeNoop(new V8CustomXPathNSResolver(resolver, isolate));
}
V8CustomXPathNSResolver::V8CustomXPathNSResolver(v8::Handle<v8::Object> resolver, v8::Isolate* isolate)
@@ -71,7 +70,7 @@
}
if (lookupNamespaceURIFunc.IsEmpty() && !m_resolver->IsFunction()) {
- Frame* frame = activeDOMWindow(m_isolate)->frame();
+ LocalFrame* frame = callingDOMWindow(m_isolate)->frame();
if (frame && frame->host())
frame->host()->console().addMessage(JSMessageSource, ErrorMessageLevel, "XPathNSResolver does not have a lookupNamespaceURI method.");
return nullAtom;
@@ -85,7 +84,7 @@
v8::Handle<v8::Value> argv[argc] = { v8String(m_isolate, prefix) };
v8::Handle<v8::Function> function = lookupNamespaceURIFunc.IsEmpty() ? v8::Handle<v8::Function>::Cast(m_resolver) : lookupNamespaceURIFunc;
- v8::Handle<v8::Value> retval = ScriptController::callFunction(activeExecutionContext(m_isolate), function, m_resolver, argc, argv, m_isolate);
+ v8::Handle<v8::Value> retval = ScriptController::callFunction(callingExecutionContext(m_isolate), 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())
@@ -95,4 +94,9 @@
return returnString;
}
+void V8CustomXPathNSResolver::trace(Visitor* visitor)
+{
+ XPathNSResolver::trace(visitor);
+}
+
} // namespace WebCore
diff --git a/Source/bindings/v8/custom/V8CustomXPathNSResolver.h b/Source/bindings/v8/custom/V8CustomXPathNSResolver.h
index c97bf08..4c6712b 100644
--- a/Source/bindings/v8/custom/V8CustomXPathNSResolver.h
+++ b/Source/bindings/v8/custom/V8CustomXPathNSResolver.h
@@ -44,11 +44,13 @@
// must not exceed the lifetime of the passed handle.
class V8CustomXPathNSResolver FINAL : public XPathNSResolver {
public:
- static PassRefPtr<V8CustomXPathNSResolver> create(v8::Handle<v8::Object> resolver, v8::Isolate*);
+ static PassRefPtrWillBeRawPtr<V8CustomXPathNSResolver> create(v8::Handle<v8::Object> resolver, v8::Isolate*);
virtual ~V8CustomXPathNSResolver();
virtual AtomicString lookupNamespaceURI(const String& prefix) OVERRIDE;
+ virtual void trace(Visitor*) OVERRIDE;
+
private:
V8CustomXPathNSResolver(v8::Handle<v8::Object> resolver, v8::Isolate*);
diff --git a/Source/bindings/v8/custom/V8DataViewCustom.h b/Source/bindings/v8/custom/V8DataViewCustom.h
index 502c010..6459cbd 100644
--- a/Source/bindings/v8/custom/V8DataViewCustom.h
+++ b/Source/bindings/v8/custom/V8DataViewCustom.h
@@ -59,10 +59,6 @@
typedef V8TypedArray<DataView> V8DataView;
-template<>
-class WrapperTypeTraits<DataView> : public TypedArrayWrapperTraits<DataView> { };
-
-
inline v8::Handle<v8::Object> wrap(DataView* impl, v8::Handle<v8::Object> creationContext, v8::Isolate* isolate)
{
return V8TypedArray<DataView>::wrap(impl, creationContext, isolate);
diff --git a/Source/bindings/v8/custom/V8DedicatedWorkerGlobalScopeCustom.cpp b/Source/bindings/v8/custom/V8DedicatedWorkerGlobalScopeCustom.cpp
index 480ae11..9e21d7b 100644
--- a/Source/bindings/v8/custom/V8DedicatedWorkerGlobalScopeCustom.cpp
+++ b/Source/bindings/v8/custom/V8DedicatedWorkerGlobalScopeCustom.cpp
@@ -35,7 +35,6 @@
#include "bindings/v8/ExceptionState.h"
#include "bindings/v8/SerializedScriptValue.h"
#include "bindings/v8/V8Binding.h"
-#include "bindings/v8/V8Utilities.h"
#include "bindings/v8/V8WorkerGlobalScopeEventListener.h"
#include "core/workers/DedicatedWorkerGlobalScope.h"
#include "wtf/ArrayBuffer.h"
@@ -50,7 +49,7 @@
ArrayBufferArray arrayBuffers;
if (info.Length() > 1) {
const int transferablesArgIndex = 1;
- if (!extractTransferables(info[transferablesArgIndex], transferablesArgIndex, ports, arrayBuffers, exceptionState, info.GetIsolate())) {
+ if (!SerializedScriptValue::extractTransferables(info[transferablesArgIndex], transferablesArgIndex, ports, arrayBuffers, exceptionState, info.GetIsolate())) {
exceptionState.throwIfNeeded();
return;
}
diff --git a/Source/bindings/v8/custom/V8DeviceMotionEventCustom.cpp b/Source/bindings/v8/custom/V8DeviceMotionEventCustom.cpp
index e4a011c..611a9ed 100644
--- a/Source/bindings/v8/custom/V8DeviceMotionEventCustom.cpp
+++ b/Source/bindings/v8/custom/V8DeviceMotionEventCustom.cpp
@@ -37,31 +37,31 @@
PassRefPtrWillBeRawPtr<DeviceMotionData::Acceleration> readAccelerationArgument(v8::Local<v8::Value> value, v8::Isolate* isolate)
{
if (isUndefinedOrNull(value))
- return 0;
+ return nullptr;
// Given the test above, this will always yield an object.
v8::Local<v8::Object> object = value->ToObject();
v8::Local<v8::Value> xValue = object->Get(v8AtomicString(isolate, "x"));
if (xValue.IsEmpty())
- return 0;
+ return nullptr;
bool canProvideX = !isUndefinedOrNull(xValue);
double x = xValue->NumberValue();
v8::Local<v8::Value> yValue = object->Get(v8AtomicString(isolate, "y"));
if (yValue.IsEmpty())
- return 0;
+ return nullptr;
bool canProvideY = !isUndefinedOrNull(yValue);
double y = yValue->NumberValue();
v8::Local<v8::Value> zValue = object->Get(v8AtomicString(isolate, "z"));
if (zValue.IsEmpty())
- return 0;
+ return nullptr;
bool canProvideZ = !isUndefinedOrNull(zValue);
double z = zValue->NumberValue();
if (!canProvideX && !canProvideY && !canProvideZ)
- return 0;
+ return nullptr;
return DeviceMotionData::Acceleration::create(canProvideX, x, canProvideY, y, canProvideZ, z);
}
@@ -69,31 +69,31 @@
PassRefPtrWillBeRawPtr<DeviceMotionData::RotationRate> readRotationRateArgument(v8::Local<v8::Value> value, v8::Isolate* isolate)
{
if (isUndefinedOrNull(value))
- return 0;
+ return nullptr;
// Given the test above, this will always yield an object.
v8::Local<v8::Object> object = value->ToObject();
v8::Local<v8::Value> alphaValue = object->Get(v8AtomicString(isolate, "alpha"));
if (alphaValue.IsEmpty())
- return 0;
+ return nullptr;
bool canProvideAlpha = !isUndefinedOrNull(alphaValue);
double alpha = alphaValue->NumberValue();
v8::Local<v8::Value> betaValue = object->Get(v8AtomicString(isolate, "beta"));
if (betaValue.IsEmpty())
- return 0;
+ return nullptr;
bool canProvideBeta = !isUndefinedOrNull(betaValue);
double beta = betaValue->NumberValue();
v8::Local<v8::Value> gammaValue = object->Get(v8AtomicString(isolate, "gamma"));
if (gammaValue.IsEmpty())
- return 0;
+ return nullptr;
bool canProvideGamma = !isUndefinedOrNull(gammaValue);
double gamma = gammaValue->NumberValue();
if (!canProvideAlpha && !canProvideBeta && !canProvideGamma)
- return 0;
+ return nullptr;
return DeviceMotionData::RotationRate::create(canProvideAlpha, alpha, canProvideBeta, beta, canProvideGamma, gamma);
}
diff --git a/Source/bindings/v8/custom/V8DocumentCustom.cpp b/Source/bindings/v8/custom/V8DocumentCustom.cpp
index b12884c..4f4df1a 100644
--- a/Source/bindings/v8/custom/V8DocumentCustom.cpp
+++ b/Source/bindings/v8/custom/V8DocumentCustom.cpp
@@ -49,8 +49,8 @@
#include "core/dom/ExceptionCode.h"
#include "core/dom/Node.h"
#include "core/dom/TouchList.h"
+#include "core/frame/LocalFrame.h"
#include "core/html/canvas/CanvasRenderingContext.h"
-#include "core/frame/Frame.h"
#include "core/xml/DocumentXPathEvaluator.h"
#include "core/xml/XPathNSResolver.h"
#include "core/xml/XPathResult.h"
@@ -61,26 +61,22 @@
void V8Document::evaluateMethodCustom(const v8::FunctionCallbackInfo<v8::Value>& info)
{
RefPtr<Document> document = V8Document::toNative(info.Holder());
+ ASSERT(document);
ExceptionState exceptionState(ExceptionState::ExecutionContext, "evaluate", "Document", info.Holder(), info.GetIsolate());
V8TRYCATCH_FOR_V8STRINGRESOURCE_VOID(V8StringResource<>, expression, info[0]);
- RefPtr<Node> contextNode;
- if (V8Node::hasInstance(info[1], info.GetIsolate()))
- contextNode = V8Node::toNative(v8::Handle<v8::Object>::Cast(info[1]));
+ RefPtr<Node> contextNode = V8Node::toNativeWithTypeCheck(info.GetIsolate(), info[1]);
const int resolverArgumentIndex = 2;
- RefPtr<XPathNSResolver> resolver = toXPathNSResolver(info[resolverArgumentIndex], info.GetIsolate());
+ RefPtrWillBeRawPtr<XPathNSResolver> resolver = toXPathNSResolver(info[resolverArgumentIndex], info.GetIsolate());
if (!resolver && !isUndefinedOrNull(info[resolverArgumentIndex])) {
- exceptionState.throwTypeError(ExceptionMessages::incorrectArgumentType(resolverArgumentIndex + 1, "is not a resolver function."));
+ exceptionState.throwTypeError(ExceptionMessages::argumentNullOrIncorrectType(resolverArgumentIndex + 1, "XPathNSResolver"));
exceptionState.throwIfNeeded();
return;
}
int type = toInt32(info[3]);
- RefPtr<XPathResult> inResult;
- if (V8XPathResult::hasInstance(info[4], info.GetIsolate()))
- inResult = V8XPathResult::toNative(v8::Handle<v8::Object>::Cast(info[4]));
-
- V8TRYCATCH_VOID(RefPtr<XPathResult>, result, DocumentXPathEvaluator::evaluate(document.get(), expression, contextNode.get(), resolver.release(), type, inResult.get(), exceptionState));
+ RefPtrWillBeRawPtr<XPathResult> inResult = V8XPathResult::toNativeWithTypeCheck(info.GetIsolate(), info[4]);
+ V8TRYCATCH_VOID(RefPtrWillBeRawPtr<XPathResult>, result, DocumentXPathEvaluator::evaluate(*document, expression, contextNode.get(), resolver.release(), type, inResult.get(), exceptionState));
if (exceptionState.throwIfNeeded())
return;
diff --git a/Source/bindings/v8/custom/V8ErrorEventCustom.cpp b/Source/bindings/v8/custom/V8ErrorEventCustom.cpp
index 558bb79..56b48cd 100644
--- a/Source/bindings/v8/custom/V8ErrorEventCustom.cpp
+++ b/Source/bindings/v8/custom/V8ErrorEventCustom.cpp
@@ -39,13 +39,14 @@
#include "bindings/v8/SerializedScriptValue.h"
#include "bindings/v8/V8Binding.h"
#include "bindings/v8/V8DOMWrapper.h"
+#include "bindings/v8/V8HiddenValue.h"
#include "core/dom/ContextFeatures.h"
namespace WebCore {
void V8ErrorEvent::errorAttributeGetterCustom(const v8::PropertyCallbackInfo<v8::Value>& info)
{
- v8::Handle<v8::Value> error = getHiddenValue(info.GetIsolate(), info.Holder(), "error");
+ v8::Handle<v8::Value> error = V8HiddenValue::getHiddenValue(info.GetIsolate(), info.Holder(), V8HiddenValue::error(info.GetIsolate()));
if (!error.IsEmpty()) {
v8SetReturnValue(info, error);
return;
diff --git a/Source/bindings/v8/custom/V8EventCustom.cpp b/Source/bindings/v8/custom/V8EventCustom.cpp
index 7324f1d..37fff58 100644
--- a/Source/bindings/v8/custom/V8EventCustom.cpp
+++ b/Source/bindings/v8/custom/V8EventCustom.cpp
@@ -33,7 +33,7 @@
#include "EventHeaders.h"
#include "EventInterfaces.h"
-#include "V8Clipboard.h"
+#include "V8DataTransfer.h"
#include "bindings/v8/V8Binding.h"
#include "core/clipboard/Clipboard.h"
#include "core/events/ClipboardEvent.h"
diff --git a/Source/bindings/v8/custom/V8FileCustom.cpp b/Source/bindings/v8/custom/V8FileCustom.cpp
index a89aa58..1848c64 100644
--- a/Source/bindings/v8/custom/V8FileCustom.cpp
+++ b/Source/bindings/v8/custom/V8FileCustom.cpp
@@ -90,7 +90,7 @@
return;
long long fileSize = blobData->length();
- RefPtr<File> file = File::create(fileName, properties.lastModified(), BlobDataHandle::create(blobData.release(), fileSize));
+ RefPtrWillBeRawPtr<File> file = File::create(fileName, properties.lastModified(), BlobDataHandle::create(blobData.release(), fileSize));
v8SetReturnValue(info, file.release());
}
diff --git a/Source/bindings/v8/custom/V8Float32ArrayCustom.h b/Source/bindings/v8/custom/V8Float32ArrayCustom.h
index 17ef971..3caa7d1 100644
--- a/Source/bindings/v8/custom/V8Float32ArrayCustom.h
+++ b/Source/bindings/v8/custom/V8Float32ArrayCustom.h
@@ -59,10 +59,6 @@
typedef V8TypedArray<Float32Array> V8Float32Array;
-template<>
-class WrapperTypeTraits<Float32Array> : public TypedArrayWrapperTraits<Float32Array> { };
-
-
inline v8::Handle<v8::Object> wrap(Float32Array* impl, v8::Handle<v8::Object> creationContext, v8::Isolate* isolate)
{
return V8TypedArray<Float32Array>::wrap(impl, creationContext, isolate);
diff --git a/Source/bindings/v8/custom/V8Float64ArrayCustom.h b/Source/bindings/v8/custom/V8Float64ArrayCustom.h
index 30ec270..0e793b6 100644
--- a/Source/bindings/v8/custom/V8Float64ArrayCustom.h
+++ b/Source/bindings/v8/custom/V8Float64ArrayCustom.h
@@ -59,10 +59,6 @@
typedef V8TypedArray<Float64Array> V8Float64Array;
-template<>
-class WrapperTypeTraits<Float64Array> : public TypedArrayWrapperTraits<Float64Array> { };
-
-
inline v8::Handle<v8::Object> wrap(Float64Array* impl, v8::Handle<v8::Object> creationContext, v8::Isolate* isolate)
{
return V8TypedArray<Float64Array>::wrap(impl, creationContext, isolate);
diff --git a/Source/bindings/v8/custom/V8FormDataCustom.cpp b/Source/bindings/v8/custom/V8FormDataCustom.cpp
index 48a96bc..26ec0d9 100644
--- a/Source/bindings/v8/custom/V8FormDataCustom.cpp
+++ b/Source/bindings/v8/custom/V8FormDataCustom.cpp
@@ -34,7 +34,6 @@
#include "V8Blob.h"
#include "V8HTMLFormElement.h"
#include "bindings/v8/V8Binding.h"
-#include "bindings/v8/V8Utilities.h"
#include "core/html/DOMFormData.h"
namespace WebCore {
diff --git a/Source/bindings/v8/custom/V8GeolocationCustom.cpp b/Source/bindings/v8/custom/V8GeolocationCustom.cpp
index 8c82b78..33a433b 100644
--- a/Source/bindings/v8/custom/V8GeolocationCustom.cpp
+++ b/Source/bindings/v8/custom/V8GeolocationCustom.cpp
@@ -30,7 +30,6 @@
#include "V8PositionErrorCallback.h"
#include "bindings/v8/V8Binding.h"
#include "bindings/v8/V8Callback.h"
-#include "bindings/v8/V8Utilities.h"
#include "modules/geolocation/Geolocation.h"
using namespace std;
@@ -61,13 +60,13 @@
v8::Local<v8::Value> enableHighAccuracyValue = object->Get(v8AtomicString(isolate, "enableHighAccuracy"));
if (enableHighAccuracyValue.IsEmpty()) {
succeeded = false;
- return 0;
+ return nullptr;
}
if (!enableHighAccuracyValue->IsUndefined()) {
v8::Local<v8::Boolean> enableHighAccuracyBoolean = enableHighAccuracyValue->ToBoolean();
if (enableHighAccuracyBoolean.IsEmpty()) {
succeeded = false;
- return 0;
+ return nullptr;
}
options->setEnableHighAccuracy(enableHighAccuracyBoolean->Value());
}
@@ -75,13 +74,13 @@
v8::Local<v8::Value> timeoutValue = object->Get(v8AtomicString(isolate, "timeout"));
if (timeoutValue.IsEmpty()) {
succeeded = false;
- return 0;
+ return nullptr;
}
if (!timeoutValue->IsUndefined()) {
v8::Local<v8::Number> timeoutNumber = timeoutValue->ToNumber();
if (timeoutNumber.IsEmpty()) {
succeeded = false;
- return 0;
+ return nullptr;
}
double timeoutDouble = timeoutNumber->Value();
// If the value is positive infinity, there's nothing to do.
@@ -89,7 +88,7 @@
v8::Local<v8::Int32> timeoutInt32 = timeoutValue->ToInt32();
if (timeoutInt32.IsEmpty()) {
succeeded = false;
- return 0;
+ return nullptr;
}
// Wrap to int32 and force non-negative to match behavior of window.setTimeout.
options->setTimeout(max(0, timeoutInt32->Value()));
@@ -99,13 +98,13 @@
v8::Local<v8::Value> maximumAgeValue = object->Get(v8AtomicString(isolate, "maximumAge"));
if (maximumAgeValue.IsEmpty()) {
succeeded = false;
- return 0;
+ return nullptr;
}
if (!maximumAgeValue->IsUndefined()) {
v8::Local<v8::Number> maximumAgeNumber = maximumAgeValue->ToNumber();
if (maximumAgeNumber.IsEmpty()) {
succeeded = false;
- return 0;
+ return nullptr;
}
double maximumAgeDouble = maximumAgeNumber->Value();
if (std::isinf(maximumAgeDouble) && maximumAgeDouble > 0) {
@@ -115,7 +114,7 @@
v8::Local<v8::Int32> maximumAgeInt32 = maximumAgeValue->ToInt32();
if (maximumAgeInt32.IsEmpty()) {
succeeded = false;
- return 0;
+ return nullptr;
}
// Wrap to int32 and force non-negative to match behavior of window.setTimeout.
options->setMaximumAge(max(0, maximumAgeInt32->Value()));
@@ -129,13 +128,15 @@
{
bool succeeded = false;
- OwnPtr<PositionCallback> positionCallback = createFunctionOnlyCallback<V8PositionCallback>(info[0], succeeded, info.GetIsolate());
+ ExceptionState exceptionState(ExceptionState::ExecutionContext, "getCurrentPosition", "Geolocation", info.Holder(), info.GetIsolate());
+
+ OwnPtr<PositionCallback> positionCallback = createFunctionOnlyCallback<V8PositionCallback>(info[0], 1, succeeded, info.GetIsolate(), exceptionState);
if (!succeeded)
return;
ASSERT(positionCallback);
// Argument is optional (hence undefined is allowed), and null is allowed.
- OwnPtr<PositionErrorCallback> positionErrorCallback = createFunctionOnlyCallback<V8PositionErrorCallback>(info[1], succeeded, info.GetIsolate(), CallbackAllowUndefined | CallbackAllowNull);
+ OwnPtr<PositionErrorCallback> positionErrorCallback = createFunctionOnlyCallback<V8PositionErrorCallback>(info[1], 2, succeeded, info.GetIsolate(), exceptionState, CallbackAllowUndefined | CallbackAllowNull);
if (!succeeded)
return;
@@ -152,13 +153,15 @@
{
bool succeeded = false;
- OwnPtr<PositionCallback> positionCallback = createFunctionOnlyCallback<V8PositionCallback>(info[0], succeeded, info.GetIsolate());
+ ExceptionState exceptionState(ExceptionState::ExecutionContext, "watchCurrentPosition", "Geolocation", info.Holder(), info.GetIsolate());
+
+ OwnPtr<PositionCallback> positionCallback = createFunctionOnlyCallback<V8PositionCallback>(info[0], 1, succeeded, info.GetIsolate(), exceptionState);
if (!succeeded)
return;
ASSERT(positionCallback);
// Argument is optional (hence undefined is allowed), and null is allowed.
- OwnPtr<PositionErrorCallback> positionErrorCallback = createFunctionOnlyCallback<V8PositionErrorCallback>(info[1], succeeded, info.GetIsolate(), CallbackAllowUndefined | CallbackAllowNull);
+ OwnPtr<PositionErrorCallback> positionErrorCallback = createFunctionOnlyCallback<V8PositionErrorCallback>(info[1], 2, succeeded, info.GetIsolate(), exceptionState, CallbackAllowUndefined | CallbackAllowNull);
if (!succeeded)
return;
diff --git a/Source/bindings/v8/custom/V8HTMLAllCollectionCustom.cpp b/Source/bindings/v8/custom/V8HTMLAllCollectionCustom.cpp
index 759ada1..9d73a3f 100644
--- a/Source/bindings/v8/custom/V8HTMLAllCollectionCustom.cpp
+++ b/Source/bindings/v8/custom/V8HTMLAllCollectionCustom.cpp
@@ -87,10 +87,9 @@
return;
HTMLAllCollection* imp = V8HTMLAllCollection::toNative(info.Holder());
- Node* ownerNode = imp->ownerNode();
- ASSERT(ownerNode);
+ Node& ownerNode = imp->ownerNode();
- UseCounter::count(ownerNode->document(), UseCounter::DocumentAllLegacyCall);
+ UseCounter::count(ownerNode.document(), UseCounter::DocumentAllLegacyCall);
if (info.Length() == 1) {
v8SetReturnValue(info, getItem(imp, info[0], info));
diff --git a/Source/bindings/v8/custom/V8HTMLDocumentCustom.cpp b/Source/bindings/v8/custom/V8HTMLDocumentCustom.cpp
index 061ce14..ee57784 100644
--- a/Source/bindings/v8/custom/V8HTMLDocumentCustom.cpp
+++ b/Source/bindings/v8/custom/V8HTMLDocumentCustom.cpp
@@ -38,11 +38,11 @@
#include "V8Window.h"
#include "bindings/v8/ScriptController.h"
#include "bindings/v8/V8Binding.h"
+#include "core/frame/LocalFrame.h"
#include "core/html/HTMLAllCollection.h"
#include "core/html/HTMLCollection.h"
#include "core/html/HTMLDocument.h"
#include "core/html/HTMLIFrameElement.h"
-#include "core/frame/Frame.h"
#include "wtf/OwnPtr.h"
#include "wtf/RefPtr.h"
#include "wtf/StdLibExtras.h"
@@ -56,7 +56,7 @@
HTMLDocument* htmlDocument = V8HTMLDocument::toNative(info.Holder());
if (info.Length() > 2) {
- if (RefPtr<Frame> frame = htmlDocument->frame()) {
+ if (RefPtr<LocalFrame> frame = htmlDocument->frame()) {
// Fetch the global object for the frame.
v8::Local<v8::Context> context = toV8Context(info.GetIsolate(), frame.get(), DOMWrapperWorld::current(info.GetIsolate()));
// Bail out if we cannot get the context.
@@ -80,7 +80,7 @@
}
}
- htmlDocument->open(activeDOMWindow(info.GetIsolate())->document());
+ htmlDocument->open(callingDOMWindow(info.GetIsolate())->document());
v8SetReturnValue(info, info.Holder());
}
diff --git a/Source/bindings/v8/custom/V8HistoryCustom.cpp b/Source/bindings/v8/custom/V8HistoryCustom.cpp
index 759f52c..c29cdbc 100644
--- a/Source/bindings/v8/custom/V8HistoryCustom.cpp
+++ b/Source/bindings/v8/custom/V8HistoryCustom.cpp
@@ -35,6 +35,7 @@
#include "bindings/v8/ExceptionState.h"
#include "bindings/v8/SerializedScriptValue.h"
#include "bindings/v8/V8Binding.h"
+#include "bindings/v8/V8HiddenValue.h"
#include "core/dom/ExceptionCode.h"
#include "core/frame/History.h"
@@ -44,7 +45,7 @@
{
History* history = V8History::toNative(info.Holder());
- v8::Handle<v8::Value> value = getHiddenValue(info.GetIsolate(), info.Holder(), "state");
+ v8::Handle<v8::Value> value = V8HiddenValue::getHiddenValue(info.GetIsolate(), info.Holder(), V8HiddenValue::state(info.GetIsolate()));
if (!value.IsEmpty() && !history->stateChanged()) {
v8SetReturnValue(info, value);
@@ -53,7 +54,7 @@
RefPtr<SerializedScriptValue> serialized = history->state();
value = serialized ? serialized->deserialize(info.GetIsolate()) : v8::Handle<v8::Value>(v8::Null(info.GetIsolate()));
- setHiddenValue(info.GetIsolate(), info.Holder(), "state", value);
+ V8HiddenValue::setHiddenValue(info.GetIsolate(), info.Holder(), V8HiddenValue::state(info.GetIsolate()), value);
v8SetReturnValue(info, value);
}
@@ -70,7 +71,7 @@
History* history = V8History::toNative(info.Holder());
history->stateObjectAdded(historyState.release(), title, url, UpdateBackForwardList, exceptionState);
- deleteHiddenValue(info.GetIsolate(), info.Holder(), "state");
+ V8HiddenValue::deleteHiddenValue(info.GetIsolate(), info.Holder(), V8HiddenValue::state(info.GetIsolate()));
exceptionState.throwIfNeeded();
}
@@ -86,7 +87,7 @@
History* history = V8History::toNative(info.Holder());
history->stateObjectAdded(historyState.release(), title, url, DoNotUpdateBackForwardList, exceptionState);
- deleteHiddenValue(info.GetIsolate(), info.Holder(), "state");
+ V8HiddenValue::deleteHiddenValue(info.GetIsolate(), info.Holder(), V8HiddenValue::state(info.GetIsolate()));
exceptionState.throwIfNeeded();
}
diff --git a/Source/bindings/v8/custom/V8InjectedScriptHostCustom.cpp b/Source/bindings/v8/custom/V8InjectedScriptHostCustom.cpp
index b19d116..2d287a5 100644
--- a/Source/bindings/v8/custom/V8InjectedScriptHostCustom.cpp
+++ b/Source/bindings/v8/custom/V8InjectedScriptHostCustom.cpp
@@ -79,7 +79,7 @@
v8::Local<v8::Context> context = state->context();
v8::Context::Scope contextScope(context);
- ExceptionState exceptionState(v8::Handle<v8::Object>(), isolate);
+ ExceptionState exceptionState(ExceptionState::ExecutionContext, "nodeAsScriptValue", "InjectedScriptHost", v8::Handle<v8::Object>(), isolate);
if (!BindingSecurity::shouldAllowAccessToNode(isolate, node, exceptionState))
return ScriptValue(v8::Null(isolate), isolate);
return ScriptValue(toV8(node, v8::Handle<v8::Object>(), isolate), isolate);
@@ -279,11 +279,9 @@
if (info.Length() < 1)
return;
- EventTarget* target = 0;
- v8::Local<v8::Value> value = info[0];
- if (V8EventTarget::hasInstance(value, info.GetIsolate()))
- target = V8EventTarget::toNative(value->ToObject());
+ v8::Local<v8::Value> value = info[0];
+ EventTarget* target = V8EventTarget::toNativeWithTypeCheck(info.GetIsolate(), value);
// We need to handle a DOMWindow specially, because a DOMWindow wrapper exists on a prototype chain.
if (!target)
@@ -427,4 +425,25 @@
host->unmonitorFunction(scriptId, lineNumber, columnNumber);
}
+void V8InjectedScriptHost::suppressWarningsAndCallMethodCustom(const v8::FunctionCallbackInfo<v8::Value>& info)
+{
+ if (info.Length() < 2 || !info[0]->IsObject() || !info[1]->IsFunction())
+ return;
+
+ InjectedScriptHost* host = V8InjectedScriptHost::toNative(info.Holder());
+ ScriptDebugServer& debugServer = host->scriptDebugServer();
+ debugServer.muteWarningsAndDeprecations();
+
+ v8::Handle<v8::Object> receiver = v8::Handle<v8::Object>::Cast(info[0]);
+ v8::Handle<v8::Function> function = v8::Handle<v8::Function>::Cast(info[1]);
+ size_t argc = info.Length() - 2;
+ OwnPtr<v8::Handle<v8::Value>[]> argv = adoptArrayPtr(new v8::Handle<v8::Value>[argc]);
+ for (size_t i = 0; i < argc; ++i)
+ argv[i] = info[i + 2];
+
+ v8::Local<v8::Value> result = function->Call(receiver, argc, argv.get());
+ debugServer.unmuteWarningsAndDeprecations();
+ v8SetReturnValue(info, result);
+}
+
} // namespace WebCore
diff --git a/Source/bindings/v8/custom/V8InjectedScriptManager.cpp b/Source/bindings/v8/custom/V8InjectedScriptManager.cpp
index 35063d7..473515e 100644
--- a/Source/bindings/v8/custom/V8InjectedScriptManager.cpp
+++ b/Source/bindings/v8/custom/V8InjectedScriptManager.cpp
@@ -53,7 +53,7 @@
static v8::Local<v8::Object> createInjectedScriptHostV8Wrapper(InjectedScriptHost* host, v8::Isolate* isolate)
{
- v8::Local<v8::Function> function = V8InjectedScriptHost::domTemplate(isolate, MainWorld)->GetFunction();
+ v8::Local<v8::Function> function = V8InjectedScriptHost::domTemplate(isolate)->GetFunction();
if (function.IsEmpty()) {
// Return if allocation failed.
return v8::Local<v8::Object>();
@@ -111,12 +111,10 @@
v8::Local<v8::Object> global = context->Global();
if (global.IsEmpty())
return false;
- v8::Handle<v8::Object> holder = global->FindInstanceInPrototypeChain(V8Window::domTemplate(context->GetIsolate(), MainWorld));
- if (holder.IsEmpty())
- holder = global->FindInstanceInPrototypeChain(V8Window::domTemplate(context->GetIsolate(), IsolatedWorld));
+ v8::Handle<v8::Object> holder = V8Window::findInstanceInPrototypeChain(global, context->GetIsolate());
if (holder.IsEmpty())
return false;
- Frame* frame = V8Window::toNative(holder)->frame();
+ LocalFrame* frame = V8Window::toNative(holder)->frame();
v8::Context::Scope contextScope(context);
return BindingSecurity::shouldAllowAccessToFrame(scriptState->isolate(), frame, DoNotReportSecurityError);
diff --git a/Source/bindings/v8/custom/V8InspectorFrontendHostCustom.cpp b/Source/bindings/v8/custom/V8InspectorFrontendHostCustom.cpp
index 6fef29e..6657d86 100644
--- a/Source/bindings/v8/custom/V8InspectorFrontendHostCustom.cpp
+++ b/Source/bindings/v8/custom/V8InspectorFrontendHostCustom.cpp
@@ -143,10 +143,5 @@
histogramEnumeration("DevTools.PanelShown", info, 20);
}
-void V8InspectorFrontendHost::recordSettingChangedMethodCustom(const v8::FunctionCallbackInfo<v8::Value>& info)
-{
- histogramEnumeration("DevTools.SettingChanged", info, 100);
-}
-
} // namespace WebCore
diff --git a/Source/bindings/v8/custom/V8Int16ArrayCustom.h b/Source/bindings/v8/custom/V8Int16ArrayCustom.h
index 30f5f58..58aab8b 100644
--- a/Source/bindings/v8/custom/V8Int16ArrayCustom.h
+++ b/Source/bindings/v8/custom/V8Int16ArrayCustom.h
@@ -59,10 +59,6 @@
typedef V8TypedArray<Int16Array> V8Int16Array;
-template<>
-class WrapperTypeTraits<Int16Array> : public TypedArrayWrapperTraits<Int16Array> { };
-
-
inline v8::Handle<v8::Object> wrap(Int16Array* impl, v8::Handle<v8::Object> creationContext, v8::Isolate* isolate)
{
return V8TypedArray<Int16Array>::wrap(impl, creationContext, isolate);
diff --git a/Source/bindings/v8/custom/V8Int32ArrayCustom.h b/Source/bindings/v8/custom/V8Int32ArrayCustom.h
index bbb4aaf..6c29dca 100644
--- a/Source/bindings/v8/custom/V8Int32ArrayCustom.h
+++ b/Source/bindings/v8/custom/V8Int32ArrayCustom.h
@@ -59,10 +59,6 @@
typedef V8TypedArray<Int32Array> V8Int32Array;
-template<>
-class WrapperTypeTraits<Int32Array> : public TypedArrayWrapperTraits<Int32Array> { };
-
-
inline v8::Handle<v8::Object> wrap(Int32Array* impl, v8::Handle<v8::Object> creationContext, v8::Isolate* isolate)
{
return V8TypedArray<Int32Array>::wrap(impl, creationContext, isolate);
diff --git a/Source/bindings/v8/custom/V8Int8ArrayCustom.h b/Source/bindings/v8/custom/V8Int8ArrayCustom.h
index 31a9e35..e878317 100644
--- a/Source/bindings/v8/custom/V8Int8ArrayCustom.h
+++ b/Source/bindings/v8/custom/V8Int8ArrayCustom.h
@@ -59,10 +59,6 @@
typedef V8TypedArray<Int8Array> V8Int8Array;
-template<>
-class WrapperTypeTraits<Int8Array> : public TypedArrayWrapperTraits<Int8Array> { };
-
-
inline v8::Handle<v8::Object> wrap(Int8Array* impl, v8::Handle<v8::Object> creationContext, v8::Isolate* isolate)
{
return V8TypedArray<Int8Array>::wrap(impl, creationContext, isolate);
diff --git a/Source/bindings/v8/custom/V8MessageChannelCustom.cpp b/Source/bindings/v8/custom/V8MessageChannelCustom.cpp
index 0ca1c80..3826c93 100644
--- a/Source/bindings/v8/custom/V8MessageChannelCustom.cpp
+++ b/Source/bindings/v8/custom/V8MessageChannelCustom.cpp
@@ -33,7 +33,7 @@
#include "V8MessagePort.h"
#include "bindings/v8/V8Binding.h"
-#include "bindings/v8/V8Utilities.h"
+#include "bindings/v8/V8HiddenValue.h"
#include "core/dom/MessageChannel.h"
#include "core/workers/WorkerGlobalScope.h"
#include "wtf/RefPtr.h"
@@ -51,8 +51,8 @@
// Create references from the MessageChannel wrapper to the two
// MessagePort wrappers to make sure that the MessagePort wrappers
// stay alive as long as the MessageChannel wrapper is around.
- setHiddenValue(info.GetIsolate(), wrapper, "port1", toV8(obj->port1(), info.Holder(), info.GetIsolate()));
- setHiddenValue(info.GetIsolate(), wrapper, "port2", toV8(obj->port2(), info.Holder(), info.GetIsolate()));
+ V8HiddenValue::setHiddenValue(info.GetIsolate(), wrapper, V8HiddenValue::port1(info.GetIsolate()), toV8(obj->port1(), info.Holder(), info.GetIsolate()));
+ V8HiddenValue::setHiddenValue(info.GetIsolate(), wrapper, V8HiddenValue::port2(info.GetIsolate()), toV8(obj->port2(), info.Holder(), info.GetIsolate()));
V8DOMWrapper::associateObjectWithWrapper<V8MessageChannel>(obj.release(), &wrapperTypeInfo, wrapper, info.GetIsolate(), WrapperConfiguration::Dependent);
info.GetReturnValue().Set(wrapper);
diff --git a/Source/bindings/v8/custom/V8MessageEventCustom.cpp b/Source/bindings/v8/custom/V8MessageEventCustom.cpp
index 38670f7..c41449b 100644
--- a/Source/bindings/v8/custom/V8MessageEventCustom.cpp
+++ b/Source/bindings/v8/custom/V8MessageEventCustom.cpp
@@ -36,18 +36,12 @@
#include "V8Window.h"
#include "bindings/v8/SerializedScriptValue.h"
#include "bindings/v8/V8Binding.h"
+#include "bindings/v8/V8HiddenValue.h"
#include "bindings/v8/custom/V8ArrayBufferCustom.h"
#include "core/events/MessageEvent.h"
namespace WebCore {
-// "data" hidden value may be set by the generated constructor code (See
-// InitializedByEventConstructor directive in the IDL file).
-static const char dataHiddenValueKey[] = "data";
-
-static const char arrayBufferHiddenValueKey[] = "arrayBufferData";
-static const char stringHiddenValueKey[] = "stringData";
-
// Ensures a wrapper is created for the data to return now so that V8 knows how
// much memory is used via the wrapper. To keep the wrapper alive, it's set to
// the wrapper of the MessageEvent as a hidden value.
@@ -59,13 +53,13 @@
break;
case MessageEvent::DataTypeString: {
String stringValue = eventImpl->dataAsString();
- setHiddenValue(isolate, eventWrapper, stringHiddenValueKey, v8String(isolate, stringValue));
+ V8HiddenValue::setHiddenValue(isolate, eventWrapper, V8HiddenValue::stringData(isolate), v8String(isolate, stringValue));
break;
}
case MessageEvent::DataTypeBlob:
break;
case MessageEvent::DataTypeArrayBuffer:
- setHiddenValue(isolate, eventWrapper, arrayBufferHiddenValueKey, toV8(eventImpl->dataAsArrayBuffer(), eventWrapper, isolate));
+ V8HiddenValue::setHiddenValue(isolate, eventWrapper, V8HiddenValue::arrayBufferData(isolate), toV8(eventImpl->dataAsArrayBuffer(), eventWrapper, isolate));
break;
}
}
@@ -86,12 +80,12 @@
v8::Handle<v8::Value> result;
switch (event->dataType()) {
case MessageEvent::DataTypeScriptValue: {
- result = getHiddenValue(info.GetIsolate(), info.Holder(), dataHiddenValueKey);
+ result = V8HiddenValue::getHiddenValue(info.GetIsolate(), info.Holder(), V8HiddenValue::data(info.GetIsolate()));
if (result.IsEmpty()) {
if (!event->dataAsSerializedScriptValue()) {
// If we're in an isolated world and the event was created in the main world,
// we need to find the 'data' property on the main world wrapper and clone it.
- v8::Local<v8::Value> mainWorldData = getHiddenValueFromMainWorldWrapper(info.GetIsolate(), event, dataHiddenValueKey);
+ v8::Local<v8::Value> mainWorldData = V8HiddenValue::getHiddenValueFromMainWorldWrapper(info.GetIsolate(), event, V8HiddenValue::data(info.GetIsolate()));
if (!mainWorldData.IsEmpty())
event->setSerializedData(SerializedScriptValue::createAndSwallowExceptions(mainWorldData, info.GetIsolate()));
}
@@ -113,7 +107,7 @@
break;
case MessageEvent::DataTypeString: {
- result = getHiddenValue(info.GetIsolate(), info.Holder(), stringHiddenValueKey);
+ result = V8HiddenValue::getHiddenValue(info.GetIsolate(), info.Holder(), V8HiddenValue::stringData(info.GetIsolate()));
if (result.IsEmpty()) {
String stringValue = event->dataAsString();
result = v8String(info.GetIsolate(), stringValue);
@@ -126,7 +120,7 @@
break;
case MessageEvent::DataTypeArrayBuffer:
- result = getHiddenValue(info.GetIsolate(), info.Holder(), arrayBufferHiddenValueKey);
+ result = V8HiddenValue::getHiddenValue(info.GetIsolate(), info.Holder(), V8HiddenValue::arrayBufferData(info.GetIsolate()));
if (result.IsEmpty())
result = toV8(event->dataAsArrayBuffer(), info.Holder(), info.GetIsolate());
break;
@@ -161,7 +155,7 @@
event->initMessageEvent(typeArg, canBubbleArg, cancelableArg, originArg, lastEventIdArg, sourceArg, portArray.release());
if (!dataArg.IsEmpty()) {
- setHiddenValue(info.GetIsolate(), info.Holder(), dataHiddenValueKey, dataArg);
+ V8HiddenValue::setHiddenValue(info.GetIsolate(), info.Holder(), V8HiddenValue::data(info.GetIsolate()), dataArg);
if (DOMWrapperWorld::current(info.GetIsolate())->isIsolatedWorld())
event->setSerializedData(SerializedScriptValue::createAndSwallowExceptions(dataArg, info.GetIsolate()));
}
diff --git a/Source/bindings/v8/custom/V8MessagePortCustom.cpp b/Source/bindings/v8/custom/V8MessagePortCustom.cpp
index d9d2a33..6ffc759 100644
--- a/Source/bindings/v8/custom/V8MessagePortCustom.cpp
+++ b/Source/bindings/v8/custom/V8MessagePortCustom.cpp
@@ -35,7 +35,6 @@
#include "bindings/v8/ExceptionState.h"
#include "bindings/v8/SerializedScriptValue.h"
#include "bindings/v8/V8Binding.h"
-#include "bindings/v8/V8Utilities.h"
#include "core/dom/MessagePort.h"
#include "wtf/ArrayBuffer.h"
@@ -49,7 +48,7 @@
ArrayBufferArray arrayBufferArray;
if (info.Length() > 1) {
const int transferablesArgIndex = 1;
- if (!extractTransferables(info[transferablesArgIndex], transferablesArgIndex, portArray, arrayBufferArray, exceptionState, info.GetIsolate())) {
+ if (!SerializedScriptValue::extractTransferables(info[transferablesArgIndex], transferablesArgIndex, portArray, arrayBufferArray, exceptionState, info.GetIsolate())) {
exceptionState.throwIfNeeded();
return;
}
diff --git a/Source/bindings/v8/custom/V8MutationObserverCustom.cpp b/Source/bindings/v8/custom/V8MutationObserverCustom.cpp
index 7acb5a2..1840879 100644
--- a/Source/bindings/v8/custom/V8MutationObserverCustom.cpp
+++ b/Source/bindings/v8/custom/V8MutationObserverCustom.cpp
@@ -37,7 +37,6 @@
#include "bindings/v8/V8DOMWrapper.h"
#include "bindings/v8/V8GCController.h"
#include "bindings/v8/V8MutationCallback.h"
-#include "bindings/v8/V8Utilities.h"
#include "core/dom/MutationObserver.h"
namespace WebCore {
diff --git a/Source/bindings/v8/custom/V8NodeCustom.cpp b/Source/bindings/v8/custom/V8NodeCustom.cpp
index 0e74ef1..bde8861 100644
--- a/Source/bindings/v8/custom/V8NodeCustom.cpp
+++ b/Source/bindings/v8/custom/V8NodeCustom.cpp
@@ -66,8 +66,8 @@
CustomElementCallbackDispatcher::CallbackDeliveryScope deliveryScope;
ExceptionState exceptionState(ExceptionState::ExecutionContext, "insertBefore", "Node", info.Holder(), info.GetIsolate());
- Node* newChild = V8Node::hasInstance(info[0], info.GetIsolate()) ? V8Node::toNative(v8::Handle<v8::Object>::Cast(info[0])) : 0;
- Node* refChild = V8Node::hasInstance(info[1], info.GetIsolate()) ? V8Node::toNative(v8::Handle<v8::Object>::Cast(info[1])) : 0;
+ Node* newChild = V8Node::toNativeWithTypeCheck(info.GetIsolate(), info[0]);
+ Node* refChild = V8Node::toNativeWithTypeCheck(info.GetIsolate(), info[1]);
imp->insertBefore(newChild, refChild, exceptionState);
if (exceptionState.throwIfNeeded())
return;
@@ -82,8 +82,8 @@
CustomElementCallbackDispatcher::CallbackDeliveryScope deliveryScope;
ExceptionState exceptionState(ExceptionState::ExecutionContext, "replaceChild", "Node", info.Holder(), info.GetIsolate());
- Node* newChild = V8Node::hasInstance(info[0], info.GetIsolate()) ? V8Node::toNative(v8::Handle<v8::Object>::Cast(info[0])) : 0;
- Node* oldChild = V8Node::hasInstance(info[1], info.GetIsolate()) ? V8Node::toNative(v8::Handle<v8::Object>::Cast(info[1])) : 0;
+ Node* newChild = V8Node::toNativeWithTypeCheck(info.GetIsolate(), info[0]);
+ Node* oldChild = V8Node::toNativeWithTypeCheck(info.GetIsolate(), info[1]);
imp->replaceChild(newChild, oldChild, exceptionState);
if (exceptionState.throwIfNeeded())
return;
@@ -98,7 +98,7 @@
CustomElementCallbackDispatcher::CallbackDeliveryScope deliveryScope;
ExceptionState exceptionState(ExceptionState::ExecutionContext, "removeChild", "Node", info.Holder(), info.GetIsolate());
- Node* oldChild = V8Node::hasInstance(info[0], info.GetIsolate()) ? V8Node::toNative(v8::Handle<v8::Object>::Cast(info[0])) : 0;
+ Node* oldChild = V8Node::toNativeWithTypeCheck(info.GetIsolate(), info[0]);
imp->removeChild(oldChild, exceptionState);
if (exceptionState.throwIfNeeded())
return;
@@ -113,7 +113,7 @@
CustomElementCallbackDispatcher::CallbackDeliveryScope deliveryScope;
ExceptionState exceptionState(ExceptionState::ExecutionContext, "appendChild", "Node", info.Holder(), info.GetIsolate());
- Node* newChild = V8Node::hasInstance(info[0], info.GetIsolate()) ? V8Node::toNative(v8::Handle<v8::Object>::Cast(info[0])) : 0;
+ Node* newChild = V8Node::toNativeWithTypeCheck(info.GetIsolate(), info[0]);
imp->appendChild(newChild, exceptionState);
if (exceptionState.throwIfNeeded())
return;
diff --git a/Source/bindings/v8/custom/V8PannerNodeCustom.cpp b/Source/bindings/v8/custom/V8PannerNodeCustom.cpp
index e6a14af..f4d32e1 100644
--- a/Source/bindings/v8/custom/V8PannerNodeCustom.cpp
+++ b/Source/bindings/v8/custom/V8PannerNodeCustom.cpp
@@ -50,7 +50,7 @@
if (value->IsString()) {
String model = toCoreString(value.As<v8::String>());
- if (model == "equalpower" || model == "HRTF" || model == "soundfield") {
+ if (model == "equalpower" || model == "HRTF") {
imp->setPanningModel(model);
return;
}
diff --git a/Source/bindings/v8/custom/V8PopStateEventCustom.cpp b/Source/bindings/v8/custom/V8PopStateEventCustom.cpp
index e9aa933..8af7132 100644
--- a/Source/bindings/v8/custom/V8PopStateEventCustom.cpp
+++ b/Source/bindings/v8/custom/V8PopStateEventCustom.cpp
@@ -33,6 +33,7 @@
#include "V8History.h"
#include "bindings/v8/SerializedScriptValue.h"
+#include "bindings/v8/V8HiddenValue.h"
#include "core/events/PopStateEvent.h"
#include "core/frame/History.h"
@@ -41,13 +42,13 @@
// Save the state value to a hidden attribute in the V8PopStateEvent, and return it, for convenience.
static v8::Handle<v8::Value> cacheState(v8::Handle<v8::Object> popStateEvent, v8::Handle<v8::Value> state, v8::Isolate* isolate)
{
- setHiddenValue(isolate, popStateEvent, "state", state);
+ V8HiddenValue::setHiddenValue(isolate, popStateEvent, V8HiddenValue::state(isolate), state);
return state;
}
void V8PopStateEvent::stateAttributeGetterCustom(const v8::PropertyCallbackInfo<v8::Value>& info)
{
- v8::Handle<v8::Value> result = getHiddenValue(info.GetIsolate(), info.Holder(), "state");
+ v8::Handle<v8::Value> result = V8HiddenValue::getHiddenValue(info.GetIsolate(), info.Holder(), V8HiddenValue::state(info.GetIsolate()));
if (!result.IsEmpty()) {
v8SetReturnValue(info, result);
@@ -60,7 +61,7 @@
if (!event->serializedState()) {
// If we're in an isolated world and the event was created in the main world,
// we need to find the 'state' property on the main world wrapper and clone it.
- v8::Local<v8::Value> mainWorldState = getHiddenValueFromMainWorldWrapper(info.GetIsolate(), event, "state");
+ v8::Local<v8::Value> mainWorldState = V8HiddenValue::getHiddenValueFromMainWorldWrapper(info.GetIsolate(), event, V8HiddenValue::state(info.GetIsolate()));
if (!mainWorldState.IsEmpty())
event->setSerializedState(SerializedScriptValue::createAndSwallowExceptions(mainWorldState, info.GetIsolate()));
}
@@ -83,14 +84,14 @@
if (isSameState) {
v8::Handle<v8::Object> v8History = toV8(history, info.Holder(), info.GetIsolate()).As<v8::Object>();
if (!history->stateChanged()) {
- result = getHiddenValue(info.GetIsolate(), v8History, "state");
+ result = V8HiddenValue::getHiddenValue(info.GetIsolate(), v8History, V8HiddenValue::state(info.GetIsolate()));
if (!result.IsEmpty()) {
v8SetReturnValue(info, cacheState(info.Holder(), result, info.GetIsolate()));
return;
}
}
result = event->serializedState()->deserialize(info.GetIsolate());
- setHiddenValue(info.GetIsolate(), v8History, "state", result);
+ V8HiddenValue::setHiddenValue(info.GetIsolate(), v8History, V8HiddenValue::state(info.GetIsolate()), result);
} else {
result = event->serializedState()->deserialize(info.GetIsolate());
}
diff --git a/Source/bindings/v8/custom/V8PromiseCustom.cpp b/Source/bindings/v8/custom/V8PromiseCustom.cpp
index 21f923d..e1eabac 100644
--- a/Source/bindings/v8/custom/V8PromiseCustom.cpp
+++ b/Source/bindings/v8/custom/V8PromiseCustom.cpp
@@ -31,13 +31,13 @@
#include "config.h"
#include "bindings/v8/custom/V8PromiseCustom.h"
-#include <v8.h>
#include "V8Promise.h"
#include "bindings/v8/DOMRequestState.h"
#include "bindings/v8/ScopedPersistent.h"
#include "bindings/v8/ScriptFunctionCall.h"
#include "bindings/v8/ScriptState.h"
#include "bindings/v8/V8Binding.h"
+#include "bindings/v8/V8HiddenValue.h"
#include "bindings/v8/V8PerIsolateData.h"
#include "bindings/v8/V8ScriptRunner.h"
#include "bindings/v8/WrapperTypeInfo.h"
@@ -45,52 +45,59 @@
#include "core/dom/ExecutionContextTask.h"
#include "core/frame/DOMWindow.h"
#include "core/frame/UseCounter.h"
-#include "core/inspector/InspectorInstrumentation.h"
+#include "core/inspector/InspectorPromiseInstrumentation.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>
+
+#define V8TRYCATCH_VOID_EMPTY(type, var, value) \
+ type var; \
+ { \
+ v8::TryCatch block; \
+ var = (value); \
+ if (UNLIKELY(block.HasCaught())) { \
+ return; \
+ } \
+ }
namespace WebCore {
namespace {
-v8::Local<v8::ObjectTemplate> cachedObjectTemplate(void* privateTemplateUniqueKey, int internalFieldCount, v8::Isolate* isolate)
+v8::Local<v8::ObjectTemplate> cachedObjectTemplate(void* domTemplateKey, int internalFieldCount, v8::Isolate* isolate)
{
V8PerIsolateData* data = V8PerIsolateData::from(isolate);
- WrapperWorldType currentWorldType = worldType(isolate);
- v8::Handle<v8::FunctionTemplate> functionDescriptor = data->privateTemplateIfExists(currentWorldType, privateTemplateUniqueKey);
+ v8::Handle<v8::FunctionTemplate> functionDescriptor = data->existingDOMTemplate(domTemplateKey);
if (!functionDescriptor.IsEmpty())
return functionDescriptor->InstanceTemplate();
functionDescriptor = v8::FunctionTemplate::New(isolate);
v8::Local<v8::ObjectTemplate> instanceTemplate = functionDescriptor->InstanceTemplate();
instanceTemplate->SetInternalFieldCount(internalFieldCount);
- data->setPrivateTemplate(currentWorldType, privateTemplateUniqueKey, functionDescriptor);
+ data->setDOMTemplate(domTemplateKey, functionDescriptor);
return instanceTemplate;
}
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;
- return cachedObjectTemplate(&privateTemplateUniqueKey, V8PromiseCustom::PromiseAllEnvironmentFieldCount, isolate);
+ static int domTemplateKey; // This address is used for a key to look up the dom template.
+ return cachedObjectTemplate(&domTemplateKey, V8PromiseCustom::PromiseAllEnvironmentFieldCount, isolate);
}
v8::Local<v8::ObjectTemplate> primitiveWrapperObjectTemplate(v8::Isolate* isolate)
{
- // This is only for getting a unique pointer which we can pass to privateTemplate.
- static int privateTemplateUniqueKey;
- return cachedObjectTemplate(&privateTemplateUniqueKey, V8PromiseCustom::PrimitiveWrapperFieldCount, isolate);
+ static int domTemplateKey; // This address is used for a key to look up the dom template.
+ return cachedObjectTemplate(&domTemplateKey, V8PromiseCustom::PrimitiveWrapperFieldCount, isolate);
}
v8::Local<v8::ObjectTemplate> internalObjectTemplate(v8::Isolate* isolate)
{
- // This is only for getting a unique pointer which we can pass to privateTemplate.
- static int privateTemplateUniqueKey;
- return cachedObjectTemplate(&privateTemplateUniqueKey, V8PromiseCustom::InternalFieldCount, isolate);
+ static int domTemplateKey; // This address is used for a key to look up the dom template.
+ return cachedObjectTemplate(&domTemplateKey, V8PromiseCustom::InternalFieldCount, isolate);
}
void promiseResolveCallback(const v8::FunctionCallbackInfo<v8::Value>& info)
@@ -144,6 +151,8 @@
{
v8::Local<v8::ObjectTemplate> objectTemplate = promiseAllEnvironmentObjectTemplate(isolate);
v8::Local<v8::Object> environment = objectTemplate->NewInstance();
+ if (environment.IsEmpty())
+ return v8::Local<v8::Object>();
environment->SetInternalField(V8PromiseCustom::PromiseAllEnvironmentPromiseIndex, promise);
environment->SetInternalField(V8PromiseCustom::PromiseAllEnvironmentCountdownIndex, countdownWrapper);
@@ -191,6 +200,20 @@
ASSERT(fulfillCallbacks->Length() == rejectCallbacks->Length() && rejectCallbacks->Length() == derivedPromises->Length());
}
+// Set a |promise|'s state and result that correspond to the state.
+// |promise| must be a Promise instance.
+void setStateForPromise(v8::Handle<v8::Object> promise, V8PromiseCustom::PromiseState state, v8::Handle<v8::Value> value, v8::Isolate* isolate)
+{
+ ASSERT(!value.IsEmpty());
+ ASSERT(state == V8PromiseCustom::Pending || state == V8PromiseCustom::Fulfilled || state == V8PromiseCustom::Rejected || state == V8PromiseCustom::Following);
+ v8::Local<v8::Object> internal = V8PromiseCustom::getInternal(promise);
+ internal->SetInternalField(V8PromiseCustom::InternalStateIndex, v8::Integer::New(isolate, state));
+ internal->SetInternalField(V8PromiseCustom::InternalResultIndex, value);
+ ExecutionContext* context = currentExecutionContext(isolate);
+ if (InspectorInstrumentation::isPromiseTrackerEnabled(context))
+ InspectorInstrumentation::didUpdatePromiseState(context, ScriptObject(ScriptState::forContext(isolate->GetCurrentContext()), promise), state, ScriptValue(value, isolate));
+}
+
class TaskPerformScopeForInstrumentation {
public:
TaskPerformScopeForInstrumentation(ExecutionContext* context, ExecutionContextTask* task)
@@ -287,7 +310,7 @@
DOMRequestState::Scope scope(m_requestState);
v8::Isolate* isolate = m_requestState.isolate();
v8::Local<v8::Object> originatorValueObject = m_originatorValueObject.newLocal(isolate);
- v8::Local<v8::Value> coercedAlready = getHiddenValue(isolate, originatorValueObject, "thenableHiddenPromise");
+ v8::Local<v8::Value> coercedAlready = V8HiddenValue::getHiddenValue(isolate, originatorValueObject, V8HiddenValue::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);
@@ -306,6 +329,9 @@
if (then->IsFunction()) {
ASSERT(then->IsObject());
v8::Local<v8::Object> coerced = V8PromiseCustom::coerceThenable(originatorValueObject, then.As<v8::Function>(), isolate);
+ // If the stack is exhausted coerced can be empty, but it is impossible
+ // because this function is executed on a fresh stack.
+ ASSERT(!coerced.IsEmpty());
V8PromiseCustom::updateDerivedFromPromise(m_promise.newLocal(isolate), m_onFulfilled.newLocal(isolate), m_onRejected.newLocal(isolate), coerced, isolate);
return;
}
@@ -388,17 +414,15 @@
void PromisePropagator::setValue(v8::Handle<v8::Object> promise, v8::Handle<v8::Value> value, v8::Isolate* isolate)
{
- v8::Local<v8::Object> internal = V8PromiseCustom::getInternal(promise);
- ASSERT(V8PromiseCustom::getState(internal) != V8PromiseCustom::Fulfilled && V8PromiseCustom::getState(internal) != V8PromiseCustom::Rejected);
- V8PromiseCustom::setState(internal, V8PromiseCustom::Fulfilled, value, isolate);
+ ASSERT(V8PromiseCustom::getState(V8PromiseCustom::getInternal(promise)) != V8PromiseCustom::Fulfilled && V8PromiseCustom::getState(V8PromiseCustom::getInternal(promise)) != V8PromiseCustom::Rejected);
+ setStateForPromise(promise, V8PromiseCustom::Fulfilled, value, isolate);
propagateToDerived(promise, isolate);
}
void PromisePropagator::setReason(v8::Handle<v8::Object> promise, v8::Handle<v8::Value> reason, v8::Isolate* isolate)
{
- v8::Local<v8::Object> internal = V8PromiseCustom::getInternal(promise);
- ASSERT(V8PromiseCustom::getState(internal) != V8PromiseCustom::Fulfilled && V8PromiseCustom::getState(internal) != V8PromiseCustom::Rejected);
- V8PromiseCustom::setState(internal, V8PromiseCustom::Rejected, reason, isolate);
+ ASSERT(V8PromiseCustom::getState(V8PromiseCustom::getInternal(promise)) != V8PromiseCustom::Fulfilled && V8PromiseCustom::getState(V8PromiseCustom::getInternal(promise)) != V8PromiseCustom::Rejected);
+ setStateForPromise(promise, V8PromiseCustom::Rejected, reason, isolate);
propagateToDerived(promise, isolate);
}
@@ -479,6 +503,11 @@
} else {
addToDerived(internal, derivedPromise, onFulfilled, onRejected, isolate);
}
+ ExecutionContext* context = currentExecutionContext(isolate);
+ if (InspectorInstrumentation::isPromiseTrackerEnabled(context)) {
+ ScriptState* scriptState = ScriptState::forContext(isolate->GetCurrentContext());
+ InspectorInstrumentation::didUpdatePromiseParent(context, ScriptObject(scriptState, derivedPromise), ScriptObject(scriptState, promise));
+ }
}
} // namespace
@@ -487,18 +516,17 @@
{
v8SetReturnValue(info, v8::Local<v8::Value>());
v8::Isolate* isolate = info.GetIsolate();
- ExecutionContext* executionContext = activeExecutionContext(isolate);
+ ExecutionContext* executionContext = callingExecutionContext(isolate);
UseCounter::count(executionContext, UseCounter::PromiseConstructor);
if (!info.Length() || !info[0]->IsFunction()) {
throwTypeError("Promise constructor takes a function argument", isolate);
return;
}
v8::Local<v8::Function> init = info[0].As<v8::Function>();
- v8::Local<v8::Object> promise = V8PromiseCustom::createPromise(info.Holder(), isolate);
- v8::Handle<v8::Value> argv[] = {
- createClosure(promiseResolveCallback, promise, isolate),
- createClosure(promiseRejectCallback, promise, isolate)
- };
+ V8TRYCATCH_VOID_EMPTY(v8::Local<v8::Object>, promise, V8PromiseCustom::createPromise(info.Holder(), isolate));
+ V8TRYCATCH_VOID_EMPTY(v8::Handle<v8::Value>, resolve, createClosure(promiseResolveCallback, promise, isolate));
+ V8TRYCATCH_VOID_EMPTY(v8::Handle<v8::Value>, reject, createClosure(promiseRejectCallback, promise, isolate));
+ v8::Handle<v8::Value> argv[] = { resolve, reject };
v8::TryCatch trycatch;
if (V8ScriptRunner::callFunction(init, currentExecutionContext(isolate), v8::Undefined(isolate), WTF_ARRAY_LENGTH(argv), argv, isolate).IsEmpty()) {
// An exception is thrown. Reject the promise if its resolved flag is unset.
@@ -516,19 +544,21 @@
onFulfilled = info[0].As<v8::Function>();
if (info.Length() > 1 && info[1]->IsFunction())
onRejected = info[1].As<v8::Function>();
- v8SetReturnValue(info, V8PromiseCustom::then(info.Holder(), onFulfilled, onRejected, isolate));
+ V8TRYCATCH_VOID_EMPTY(v8::Local<v8::Value>, newPromise, V8PromiseCustom::then(info.Holder(), onFulfilled, onRejected, isolate));
+ v8SetReturnValue(info, newPromise);
}
void V8Promise::castMethodCustom(const v8::FunctionCallbackInfo<v8::Value>& info)
{
v8::Isolate* isolate = info.GetIsolate();
- ExecutionContext* executionContext = activeExecutionContext(isolate);
+ ExecutionContext* executionContext = callingExecutionContext(isolate);
UseCounter::count(executionContext, UseCounter::PromiseCast);
v8::Local<v8::Value> result = v8::Undefined(isolate);
if (info.Length() > 0)
result = info[0];
- v8SetReturnValue(info, V8PromiseCustom::toPromise(result, isolate));
+ V8TRYCATCH_VOID_EMPTY(v8::Local<v8::Value>, cast, V8PromiseCustom::toPromise(result, isolate));
+ v8SetReturnValue(info, cast);
}
void V8Promise::catchMethodCustom(const v8::FunctionCallbackInfo<v8::Value>& info)
@@ -543,19 +573,20 @@
}
onRejected = info[0].As<v8::Function>();
}
- v8SetReturnValue(info, V8PromiseCustom::then(info.Holder(), onFulfilled, onRejected, isolate));
+ V8TRYCATCH_VOID_EMPTY(v8::Local<v8::Value>, newPromise, V8PromiseCustom::then(info.Holder(), onFulfilled, onRejected, isolate));
+ v8SetReturnValue(info, newPromise);
}
void V8Promise::resolveMethodCustom(const v8::FunctionCallbackInfo<v8::Value>& info)
{
v8::Isolate* isolate = info.GetIsolate();
- ExecutionContext* executionContext = activeExecutionContext(isolate);
+ ExecutionContext* executionContext = callingExecutionContext(isolate);
UseCounter::count(executionContext, UseCounter::PromiseResolve);
v8::Local<v8::Value> result = v8::Undefined(isolate);
if (info.Length() > 0)
result = info[0];
- v8::Local<v8::Object> promise = V8PromiseCustom::createPromise(info.Holder(), isolate);
+ V8TRYCATCH_VOID_EMPTY(v8::Local<v8::Object>, promise, V8PromiseCustom::createPromise(info.Holder(), isolate));
V8PromiseCustom::resolve(promise, result, isolate);
v8SetReturnValue(info, promise);
}
@@ -563,13 +594,13 @@
void V8Promise::rejectMethodCustom(const v8::FunctionCallbackInfo<v8::Value>& info)
{
v8::Isolate* isolate = info.GetIsolate();
- ExecutionContext* executionContext = activeExecutionContext(isolate);
+ ExecutionContext* executionContext = callingExecutionContext(isolate);
UseCounter::count(executionContext, UseCounter::PromiseReject);
v8::Local<v8::Value> result = v8::Undefined(isolate);
if (info.Length() > 0)
result = info[0];
- v8::Local<v8::Object> promise = V8PromiseCustom::createPromise(info.Holder(), isolate);
+ V8TRYCATCH_VOID_EMPTY(v8::Local<v8::Object>, promise, V8PromiseCustom::createPromise(info.Holder(), isolate));
V8PromiseCustom::reject(promise, result, isolate);
v8SetReturnValue(info, promise);
}
@@ -577,7 +608,7 @@
void V8Promise::raceMethodCustom(const v8::FunctionCallbackInfo<v8::Value>& info)
{
v8::Isolate* isolate = info.GetIsolate();
- v8::Local<v8::Object> promise = V8PromiseCustom::createPromise(info.Holder(), isolate);
+ V8TRYCATCH_VOID_EMPTY(v8::Local<v8::Object>, promise, V8PromiseCustom::createPromise(info.Holder(), isolate));
if (!info.Length() || !info[0]->IsArray()) {
v8SetReturnValue(info, promise);
@@ -586,14 +617,14 @@
// FIXME: Now we limit the iterable type to the Array type.
v8::Local<v8::Array> iterable = info[0].As<v8::Array>();
- v8::Local<v8::Function> onFulfilled = createClosure(promiseResolveCallback, promise, isolate);
- v8::Local<v8::Function> onRejected = createClosure(promiseRejectCallback, promise, isolate);
+ V8TRYCATCH_VOID_EMPTY(v8::Local<v8::Function>, onFulfilled, createClosure(promiseResolveCallback, promise, isolate));
+ V8TRYCATCH_VOID_EMPTY(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.
- 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);
+ V8TRYCATCH_VOID_EMPTY(v8::Local<v8::Value>, nextValue, iterable->Get(i));
+ V8TRYCATCH_VOID_EMPTY(v8::Local<v8::Object>, nextPromise, V8PromiseCustom::toPromise(nextValue, isolate));
+ V8TRYCATCH_VOID_EMPTY(v8::Local<v8::Value>, unused, V8PromiseCustom::then(nextPromise, onFulfilled, onRejected, isolate));
}
v8SetReturnValue(info, promise);
}
@@ -601,7 +632,7 @@
void V8Promise::allMethodCustom(const v8::FunctionCallbackInfo<v8::Value>& info)
{
v8::Isolate* isolate = info.GetIsolate();
- v8::Local<v8::Object> promise = V8PromiseCustom::createPromise(info.Holder(), isolate);
+ V8TRYCATCH_VOID_EMPTY(v8::Local<v8::Object>, promise, V8PromiseCustom::createPromise(info.Holder(), isolate));
v8::Local<v8::Array> results = v8::Array::New(info.GetIsolate());
if (!info.Length() || !info[0]->IsArray()) {
@@ -620,17 +651,17 @@
}
v8::Local<v8::ObjectTemplate> objectTemplate = primitiveWrapperObjectTemplate(isolate);
- v8::Local<v8::Object> countdownWrapper = objectTemplate->NewInstance();
+ V8TRYCATCH_VOID_EMPTY(v8::Local<v8::Object>, countdownWrapper, objectTemplate->NewInstance());
countdownWrapper->SetInternalField(V8PromiseCustom::PrimitiveWrapperPrimitiveIndex, v8::Integer::New(isolate, iterable->Length()));
- v8::Local<v8::Function> onRejected = createClosure(promiseRejectCallback, promise, isolate);
+ V8TRYCATCH_VOID_EMPTY(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);
+ V8TRYCATCH_VOID_EMPTY(v8::Local<v8::Object>, environment, promiseAllEnvironment(promise, countdownWrapper, i, results, isolate));
+ V8TRYCATCH_VOID_EMPTY(v8::Local<v8::Function>, onFulfilled, createClosure(promiseAllFulfillCallback, environment, isolate));
+ V8TRYCATCH_VOID_EMPTY(v8::Local<v8::Value>, nextValue, iterable->Get(i));
+ V8TRYCATCH_VOID_EMPTY(v8::Local<v8::Object>, nextPromise, V8PromiseCustom::toPromise(nextValue, isolate));
+ V8TRYCATCH_VOID_EMPTY(v8::Local<v8::Value>, unused, V8PromiseCustom::then(nextPromise, onFulfilled, onRejected, isolate));
}
v8SetReturnValue(info, promise);
}
@@ -641,12 +672,18 @@
{
v8::Local<v8::ObjectTemplate> internalTemplate = internalObjectTemplate(isolate);
v8::Local<v8::Object> internal = internalTemplate->NewInstance();
+ if (internal.IsEmpty())
+ return v8::Local<v8::Object>();
v8::Local<v8::Object> promise = V8DOMWrapper::createWrapper(creationContext, &V8Promise::wrapperTypeInfo, 0, isolate);
clearDerived(internal, isolate);
- setState(internal, Pending, v8::Undefined(isolate), isolate);
-
promise->SetInternalField(v8DOMWrapperObjectIndex, internal);
+
+ ExecutionContext* context = currentExecutionContext(isolate);
+ if (InspectorInstrumentation::isPromiseTrackerEnabled(context))
+ InspectorInstrumentation::didCreatePromise(context, ScriptObject(ScriptState::forContext(isolate->GetCurrentContext()), promise));
+
+ setStateForPromise(promise, Pending, v8::Undefined(isolate), isolate);
return promise;
}
@@ -664,18 +701,9 @@
return static_cast<PromiseState>(number);
}
-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(InternalStateIndex, v8::Integer::New(isolate, state));
- internal->SetInternalField(InternalResultIndex, value);
-}
-
bool V8PromiseCustom::isPromise(v8::Handle<v8::Value> maybePromise, v8::Isolate* isolate)
{
- WrapperWorldType currentWorldType = worldType(isolate);
- return V8Promise::domTemplate(isolate, currentWorldType)->HasInstance(maybePromise);
+ return V8Promise::domTemplate(isolate)->HasInstance(maybePromise);
}
v8::Local<v8::Object> V8PromiseCustom::toPromise(v8::Handle<v8::Value> maybePromise, v8::Isolate* isolate)
@@ -687,6 +715,8 @@
return maybePromise.As<v8::Object>();
v8::Local<v8::Object> promise = createPromise(v8::Handle<v8::Object>(), isolate);
+ if (promise.IsEmpty())
+ return v8::Local<v8::Object>();
resolve(promise, maybePromise, isolate);
return promise;
}
@@ -708,7 +738,7 @@
setReason(promise, reason, isolate);
} else if (valueState == Following) {
v8::Local<v8::Object> valuePromiseFollowing = valueInternal->GetInternalField(InternalResultIndex).As<v8::Object>();
- setState(internal, Following, valuePromiseFollowing, isolate);
+ setStateForPromise(promise, 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);
@@ -716,7 +746,7 @@
setReason(promise, valueInternal->GetInternalField(InternalResultIndex), isolate);
} else {
ASSERT(valueState == Pending);
- setState(internal, Following, valuePromise, isolate);
+ setStateForPromise(promise, Following, valuePromise, isolate);
addToDerived(valueInternal, promise, v8::Handle<v8::Function>(), v8::Handle<v8::Function>(), isolate);
}
} else {
@@ -744,6 +774,8 @@
// the creation of the promise objects only from the Blink Promise
// constructor.
v8::Local<v8::Object> derivedPromise = createPromise(v8::Handle<v8::Object>(), isolate);
+ if (derivedPromise.IsEmpty())
+ return v8::Local<v8::Object>();
updateDerivedFromPromise(derivedPromise, onFulfilled, onRejected, promise, isolate);
return derivedPromise;
}
@@ -802,15 +834,21 @@
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)
- };
+ if (promise.IsEmpty())
+ return v8::Local<v8::Object>();
+ v8::Handle<v8::Value> onFulfilled = createClosure(promiseResolveCallback, promise, isolate);
+ if (onFulfilled.IsEmpty())
+ return v8::Local<v8::Object>();
+ v8::Handle<v8::Value> onRejected = createClosure(promiseRejectCallback, promise, isolate);
+ if (onRejected.IsEmpty())
+ return v8::Local<v8::Object>();
+ v8::Handle<v8::Value> argv[] = { onFulfilled, onRejected };
+
v8::TryCatch trycatch;
if (V8ScriptRunner::callFunction(then, currentExecutionContext(isolate), thenable, WTF_ARRAY_LENGTH(argv), argv, isolate).IsEmpty()) {
reject(promise, trycatch.Exception(), isolate);
}
- setHiddenValue(isolate, thenable, "thenableHiddenPromise", promise);
+ V8HiddenValue::setHiddenValue(isolate, thenable, V8HiddenValue::thenableHiddenPromise(isolate), promise);
return promise;
}
diff --git a/Source/bindings/v8/custom/V8PromiseCustom.h b/Source/bindings/v8/custom/V8PromiseCustom.h
index b6ba31c..17d7128 100644
--- a/Source/bindings/v8/custom/V8PromiseCustom.h
+++ b/Source/bindings/v8/custom/V8PromiseCustom.h
@@ -70,10 +70,6 @@
// |internal| must be a Promise internal object.
static PromiseState getState(v8::Handle<v8::Object> internal);
- // |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*);
diff --git a/Source/bindings/v8/custom/V8SQLResultSetRowListCustom.cpp b/Source/bindings/v8/custom/V8SQLResultSetRowListCustom.cpp
index b2343b8..c3f90de 100644
--- a/Source/bindings/v8/custom/V8SQLResultSetRowListCustom.cpp
+++ b/Source/bindings/v8/custom/V8SQLResultSetRowListCustom.cpp
@@ -31,20 +31,26 @@
#include "config.h"
#include "V8SQLResultSetRowList.h"
+#include "bindings/v8/ExceptionMessages.h"
+#include "bindings/v8/ExceptionState.h"
#include "bindings/v8/V8Binding.h"
+#include "core/dom/ExceptionCode.h"
#include "modules/webdatabase/SQLResultSetRowList.h"
namespace WebCore {
void V8SQLResultSetRowList::itemMethodCustom(const v8::FunctionCallbackInfo<v8::Value>& info)
{
+ ExceptionState exceptionState(ExceptionState::ExecutionContext, "item", "SQLResultSetRowList", info.Holder(), info.GetIsolate());
if (!info.Length()) {
- throwError(v8SyntaxError, "Item index is required.", info.GetIsolate());
+ exceptionState.throwDOMException(SyntaxError, ExceptionMessages::notEnoughArguments(1, 0));
+ exceptionState.throwIfNeeded();
return;
}
if (!info[0]->IsNumber()) {
- throwTypeError("Item index must be a number.", info.GetIsolate());
+ exceptionState.throwTypeError("The index provided is not a number.");
+ exceptionState.throwIfNeeded();
return;
}
@@ -52,7 +58,8 @@
unsigned long index = info[0]->IntegerValue();
if (index >= rowList->length()) {
- throwError(v8RangeError, "Item index is out of range.", info.GetIsolate());
+ exceptionState.throwDOMException(IndexSizeError, ExceptionMessages::indexExceedsMaximumBound<unsigned>("index", index, rowList->length()));
+ exceptionState.throwIfNeeded();
return;
}
diff --git a/Source/bindings/v8/custom/V8SQLTransactionSyncCustom.cpp b/Source/bindings/v8/custom/V8SQLTransactionSyncCustom.cpp
index b1b0c78..6721efc 100644
--- a/Source/bindings/v8/custom/V8SQLTransactionSyncCustom.cpp
+++ b/Source/bindings/v8/custom/V8SQLTransactionSyncCustom.cpp
@@ -46,8 +46,10 @@
void V8SQLTransactionSync::executeSqlMethodCustom(const v8::FunctionCallbackInfo<v8::Value>& info)
{
+ ExceptionState exceptionState(ExceptionState::ExecutionContext, "executeSql", "SQLTransactionSync", info.Holder(), info.GetIsolate());
if (!info.Length()) {
- setDOMException(SyntaxError, info.GetIsolate());
+ exceptionState.throwDOMException(SyntaxError, ExceptionMessages::notEnoughArguments(1, 0));
+ exceptionState.throwIfNeeded();
return;
}
@@ -57,7 +59,8 @@
if (info.Length() > 1 && !isUndefinedOrNull(info[1])) {
if (!info[1]->IsObject()) {
- setDOMException(TypeMismatchError, info.GetIsolate());
+ exceptionState.throwDOMException(TypeMismatchError, ExceptionMessages::argumentNullOrIncorrectType(1, "DOMString"));
+ exceptionState.throwIfNeeded();
return;
}
@@ -88,7 +91,6 @@
SQLTransactionSync* transaction = V8SQLTransactionSync::toNative(info.Holder());
- ExceptionState exceptionState(ExceptionState::ExecutionContext, "executeSql", "SQLTransactionSync", info.Holder(), info.GetIsolate());
v8::Handle<v8::Value> result = toV8(transaction->executeSQL(statement, sqlValues, exceptionState), info.Holder(), info.GetIsolate());
if (exceptionState.throwIfNeeded())
return;
diff --git a/Source/bindings/v8/custom/V8TextTrackCueCustom.cpp b/Source/bindings/v8/custom/V8TextTrackCueCustom.cpp
index 4f33bc9..20d7dd0 100644
--- a/Source/bindings/v8/custom/V8TextTrackCueCustom.cpp
+++ b/Source/bindings/v8/custom/V8TextTrackCueCustom.cpp
@@ -32,10 +32,6 @@
#include "V8VTTCue.h"
-#include "bindings/v8/ExceptionMessages.h"
-#include "bindings/v8/ExceptionState.h"
-#include "core/frame/UseCounter.h"
-
namespace WebCore {
v8::Handle<v8::Value> toV8(TextTrackCue* impl, v8::Handle<v8::Object> creationContext, v8::Isolate* isolate)
@@ -43,27 +39,4 @@
return toV8(toVTTCue(impl), creationContext, isolate);
}
-// Custom constructor to make new TextTrackCue(...) return a VTTCue. This is legacy
-// compat, not per spec, and should be removed at the earliest opportunity.
-void V8TextTrackCue::constructorCustom(const v8::FunctionCallbackInfo<v8::Value>& info)
-{
- ExceptionState exceptionState(ExceptionState::ConstructionContext, "TextTrackCue", info.Holder(), info.GetIsolate());
- if (UNLIKELY(info.Length() < 3)) {
- exceptionState.throwTypeError(ExceptionMessages::notEnoughArguments(3, info.Length()));
- exceptionState.throwIfNeeded();
- return;
- }
- V8TRYCATCH_VOID(double, startTime, static_cast<double>(info[0]->NumberValue()));
- V8TRYCATCH_VOID(double, endTime, static_cast<double>(info[1]->NumberValue()));
- V8TRYCATCH_FOR_V8STRINGRESOURCE_VOID(V8StringResource<>, text, info[2]);
-
- Document& document = *toDocument(currentExecutionContext(info.GetIsolate()));
- UseCounter::countDeprecation(document, UseCounter::TextTrackCueConstructor);
-
- RefPtr<VTTCue> impl = VTTCue::create(document, startTime, endTime, text);
- v8::Handle<v8::Object> wrapper = wrap(impl.get(), info.Holder(), info.GetIsolate());
-
- v8SetReturnValue(info, wrapper);
-}
-
} // namespace WebCore
diff --git a/Source/bindings/v8/custom/V8TypedArrayCustom.h b/Source/bindings/v8/custom/V8TypedArrayCustom.h
index 081e03e..d268d6d 100644
--- a/Source/bindings/v8/custom/V8TypedArrayCustom.h
+++ b/Source/bindings/v8/custom/V8TypedArrayCustom.h
@@ -53,6 +53,7 @@
}
static TypedArray* toNative(v8::Handle<v8::Object>);
+ static TypedArray* toNativeWithTypeCheck(v8::Isolate*, v8::Handle<v8::Value>);
static void derefObject(void*);
static const WrapperTypeInfo wrapperTypeInfo;
static const int internalFieldCount = v8DefaultWrapperInternalFieldCount;
@@ -90,7 +91,7 @@
template<typename CallbackInfo>
static void v8SetReturnValueForMainWorld(const CallbackInfo& info, TypedArray* impl)
{
- ASSERT(worldType(info.GetIsolate()) == MainWorld);
+ ASSERT(DOMWrapperWorld::current(info.GetIsolate())->isMainWorld());
if (UNLIKELY(!impl)) {
v8SetReturnValueNull(info);
return;
@@ -169,6 +170,11 @@
return reinterpret_cast<TypedArray*>(typedarrayPtr);
}
+template <typename TypedArray>
+TypedArray* V8TypedArray<TypedArray>::toNativeWithTypeCheck(v8::Isolate* isolate, v8::Handle<v8::Value> value)
+{
+ return V8TypedArray<TypedArray>::hasInstance(value, isolate) ? V8TypedArray<TypedArray>::toNative(v8::Handle<v8::Object>::Cast(value)) : 0;
+}
template <typename TypedArray>
const WrapperTypeInfo V8TypedArray<TypedArray>::wrapperTypeInfo = {
diff --git a/Source/bindings/v8/custom/V8Uint16ArrayCustom.h b/Source/bindings/v8/custom/V8Uint16ArrayCustom.h
index e692a9c..d819d22 100644
--- a/Source/bindings/v8/custom/V8Uint16ArrayCustom.h
+++ b/Source/bindings/v8/custom/V8Uint16ArrayCustom.h
@@ -59,10 +59,6 @@
typedef V8TypedArray<Uint16Array> V8Uint16Array;
-template<>
-class WrapperTypeTraits<Uint16Array> : public TypedArrayWrapperTraits<Uint16Array> { };
-
-
inline v8::Handle<v8::Object> wrap(Uint16Array* impl, v8::Handle<v8::Object> creationContext, v8::Isolate* isolate)
{
return V8TypedArray<Uint16Array>::wrap(impl, creationContext, isolate);
diff --git a/Source/bindings/v8/custom/V8Uint32ArrayCustom.h b/Source/bindings/v8/custom/V8Uint32ArrayCustom.h
index 09ee5e9..9218135 100644
--- a/Source/bindings/v8/custom/V8Uint32ArrayCustom.h
+++ b/Source/bindings/v8/custom/V8Uint32ArrayCustom.h
@@ -59,10 +59,6 @@
typedef V8TypedArray<Uint32Array> V8Uint32Array;
-template<>
-class WrapperTypeTraits<Uint32Array> : public TypedArrayWrapperTraits<Uint32Array> { };
-
-
inline v8::Handle<v8::Object> wrap(Uint32Array* impl, v8::Handle<v8::Object> creationContext, v8::Isolate* isolate)
{
return V8TypedArray<Uint32Array>::wrap(impl, creationContext, isolate);
diff --git a/Source/bindings/v8/custom/V8Uint8ArrayCustom.h b/Source/bindings/v8/custom/V8Uint8ArrayCustom.h
index 5bcf004..7a37501 100644
--- a/Source/bindings/v8/custom/V8Uint8ArrayCustom.h
+++ b/Source/bindings/v8/custom/V8Uint8ArrayCustom.h
@@ -59,10 +59,6 @@
typedef V8TypedArray<Uint8Array> V8Uint8Array;
-template<>
-class WrapperTypeTraits<Uint8Array> : public TypedArrayWrapperTraits<Uint8Array> { };
-
-
inline v8::Handle<v8::Object> wrap(Uint8Array* impl, v8::Handle<v8::Object> creationContext, v8::Isolate* isolate)
{
return V8TypedArray<Uint8Array>::wrap(impl, creationContext, isolate);
diff --git a/Source/bindings/v8/custom/V8Uint8ClampedArrayCustom.h b/Source/bindings/v8/custom/V8Uint8ClampedArrayCustom.h
index 53d938a..7f93666 100644
--- a/Source/bindings/v8/custom/V8Uint8ClampedArrayCustom.h
+++ b/Source/bindings/v8/custom/V8Uint8ClampedArrayCustom.h
@@ -59,10 +59,6 @@
typedef V8TypedArray<Uint8ClampedArray> V8Uint8ClampedArray;
-template<>
-class WrapperTypeTraits<Uint8ClampedArray> : public TypedArrayWrapperTraits<Uint8ClampedArray> { };
-
-
inline v8::Handle<v8::Object> wrap(Uint8ClampedArray* impl, v8::Handle<v8::Object> creationContext, v8::Isolate* isolate)
{
return V8TypedArray<Uint8ClampedArray>::wrap(impl, creationContext, isolate);
diff --git a/Source/bindings/v8/custom/V8WebGLRenderingContextCustom.cpp b/Source/bindings/v8/custom/V8WebGLRenderingContextBaseCustom.cpp
similarity index 76%
rename from Source/bindings/v8/custom/V8WebGLRenderingContextCustom.cpp
rename to Source/bindings/v8/custom/V8WebGLRenderingContextBaseCustom.cpp
index 23106af..e84f94b 100644
--- a/Source/bindings/v8/custom/V8WebGLRenderingContextCustom.cpp
+++ b/Source/bindings/v8/custom/V8WebGLRenderingContextBaseCustom.cpp
@@ -29,7 +29,7 @@
*/
#include "config.h"
-#include "V8WebGLRenderingContext.h"
+#include "V8WebGLRenderingContextBase.h"
#include "V8ANGLEInstancedArrays.h"
#include "V8EXTFragDepth.h"
@@ -63,6 +63,7 @@
#include "V8WebGLVertexArrayObjectOES.h"
#include "bindings/v8/ExceptionMessages.h"
#include "bindings/v8/V8Binding.h"
+#include "bindings/v8/V8HiddenValue.h"
#include "bindings/v8/custom/V8ArrayBufferViewCustom.h"
#include "bindings/v8/custom/V8Float32ArrayCustom.h"
#include "bindings/v8/custom/V8Int16ArrayCustom.h"
@@ -72,7 +73,7 @@
#include "bindings/v8/custom/V8Uint32ArrayCustom.h"
#include "bindings/v8/custom/V8Uint8ArrayCustom.h"
#include "core/dom/ExceptionCode.h"
-#include "core/html/canvas/WebGLRenderingContext.h"
+#include "core/html/canvas/WebGLRenderingContextBase.h"
#include "platform/NotImplemented.h"
#include "wtf/FastMalloc.h"
#include <limits>
@@ -80,7 +81,7 @@
namespace WebCore {
// Allocates new storage via fastMalloc.
-// Returns NULL if array failed to convert for any reason.
+// Returns 0 if array failed to convert for any reason.
static float* jsArrayToFloatArray(v8::Handle<v8::Array> array, uint32_t len, ExceptionState& exceptionState)
{
// Convert the data element-by-element.
@@ -103,7 +104,7 @@
}
// Allocates new storage via fastMalloc.
-// Returns NULL if array failed to convert for any reason.
+// Returns 0 if array failed to convert for any reason.
static int* jsArrayToIntArray(v8::Handle<v8::Array> array, uint32_t len, ExceptionState& exceptionState)
{
// Convert the data element-by-element.
@@ -182,81 +183,84 @@
v8::Handle<v8::Value> extensionObject;
const char* referenceName = 0;
switch (extension->name()) {
- case WebGLExtension::ANGLEInstancedArraysName:
+ case ANGLEInstancedArraysName:
extensionObject = toV8(static_cast<ANGLEInstancedArrays*>(extension), contextObject, isolate);
referenceName = "angleInstancedArraysName";
break;
- case WebGLExtension::EXTFragDepthName:
+ case EXTFragDepthName:
extensionObject = toV8(static_cast<EXTFragDepth*>(extension), contextObject, isolate);
referenceName = "extFragDepthName";
break;
- case WebGLExtension::EXTTextureFilterAnisotropicName:
+ case EXTTextureFilterAnisotropicName:
extensionObject = toV8(static_cast<EXTTextureFilterAnisotropic*>(extension), contextObject, isolate);
referenceName = "extTextureFilterAnisotropicName";
break;
- case WebGLExtension::OESElementIndexUintName:
+ case OESElementIndexUintName:
extensionObject = toV8(static_cast<OESElementIndexUint*>(extension), contextObject, isolate);
referenceName = "oesElementIndexUintName";
break;
- case WebGLExtension::OESStandardDerivativesName:
+ case OESStandardDerivativesName:
extensionObject = toV8(static_cast<OESStandardDerivatives*>(extension), contextObject, isolate);
referenceName = "oesStandardDerivativesName";
break;
- case WebGLExtension::OESTextureFloatName:
+ case OESTextureFloatName:
extensionObject = toV8(static_cast<OESTextureFloat*>(extension), contextObject, isolate);
referenceName = "oesTextureFloatName";
break;
- case WebGLExtension::OESTextureFloatLinearName:
+ case OESTextureFloatLinearName:
extensionObject = toV8(static_cast<OESTextureFloatLinear*>(extension), contextObject, isolate);
referenceName = "oesTextureFloatLinearName";
break;
- case WebGLExtension::OESTextureHalfFloatName:
+ case OESTextureHalfFloatName:
extensionObject = toV8(static_cast<OESTextureHalfFloat*>(extension), contextObject, isolate);
referenceName = "oesTextureHalfFloatName";
break;
- case WebGLExtension::OESTextureHalfFloatLinearName:
+ case OESTextureHalfFloatLinearName:
extensionObject = toV8(static_cast<OESTextureHalfFloatLinear*>(extension), contextObject, isolate);
referenceName = "oesTextureHalfFloatLinearName";
break;
- case WebGLExtension::OESVertexArrayObjectName:
+ case OESVertexArrayObjectName:
extensionObject = toV8(static_cast<OESVertexArrayObject*>(extension), contextObject, isolate);
referenceName = "oesVertexArrayObjectName";
break;
- case WebGLExtension::WebGLCompressedTextureATCName:
+ case WebGLCompressedTextureATCName:
extensionObject = toV8(static_cast<WebGLCompressedTextureATC*>(extension), contextObject, isolate);
referenceName = "webGLCompressedTextureATCName";
break;
- case WebGLExtension::WebGLCompressedTexturePVRTCName:
+ case WebGLCompressedTexturePVRTCName:
extensionObject = toV8(static_cast<WebGLCompressedTexturePVRTC*>(extension), contextObject, isolate);
referenceName = "webGLCompressedTexturePVRTCName";
break;
- case WebGLExtension::WebGLCompressedTextureS3TCName:
+ case WebGLCompressedTextureS3TCName:
extensionObject = toV8(static_cast<WebGLCompressedTextureS3TC*>(extension), contextObject, isolate);
referenceName = "webGLCompressedTextureS3TCName";
break;
- case WebGLExtension::WebGLDebugRendererInfoName:
+ case WebGLDebugRendererInfoName:
extensionObject = toV8(static_cast<WebGLDebugRendererInfo*>(extension), contextObject, isolate);
referenceName = "webGLDebugRendererInfoName";
break;
- case WebGLExtension::WebGLDebugShadersName:
+ case WebGLDebugShadersName:
extensionObject = toV8(static_cast<WebGLDebugShaders*>(extension), contextObject, isolate);
referenceName = "webGLDebugShadersName";
break;
- case WebGLExtension::WebGLDepthTextureName:
+ case WebGLDepthTextureName:
extensionObject = toV8(static_cast<WebGLDepthTexture*>(extension), contextObject, isolate);
referenceName = "webGLDepthTextureName";
break;
- case WebGLExtension::WebGLDrawBuffersName:
+ case WebGLDrawBuffersName:
extensionObject = toV8(static_cast<WebGLDrawBuffers*>(extension), contextObject, isolate);
referenceName = "webGLDrawBuffersName";
break;
- case WebGLExtension::WebGLLoseContextName:
+ case WebGLLoseContextName:
extensionObject = toV8(static_cast<WebGLLoseContext*>(extension), contextObject, isolate);
referenceName = "webGLLoseContextName";
break;
+ case WebGLExtensionNameCount:
+ notImplemented();
+ return v8::Undefined(isolate);
}
ASSERT(!extensionObject.IsEmpty());
- setHiddenValue(isolate, contextObject, referenceName, extensionObject);
+ V8HiddenValue::setHiddenValue(isolate, contextObject, v8AtomicString(isolate, referenceName), extensionObject);
return extensionObject;
}
@@ -272,7 +276,7 @@
return;
}
- WebGLRenderingContext* context = V8WebGLRenderingContext::toNative(info.Holder());
+ WebGLRenderingContextBase* context = V8WebGLRenderingContextBase::toNative(info.Holder());
unsigned target = toInt32(info[0], exceptionState);
if (exceptionState.throwIfNeeded())
return;
@@ -303,18 +307,16 @@
static WebGLUniformLocation* toWebGLUniformLocation(v8::Handle<v8::Value> value, v8::Isolate* isolate)
{
- if (!V8WebGLUniformLocation::hasInstance(value, isolate))
- return 0;
- return V8WebGLUniformLocation::toNative(value->ToObject());
+ return V8WebGLUniformLocation::toNativeWithTypeCheck(isolate, value);
}
enum WhichProgramCall {
kProgramParameter, kUniform
};
-void V8WebGLRenderingContext::getAttachedShadersMethodCustom(const v8::FunctionCallbackInfo<v8::Value>& info)
+void V8WebGLRenderingContextBase::getAttachedShadersMethodCustom(const v8::FunctionCallbackInfo<v8::Value>& info)
{
- ExceptionState exceptionState(ExceptionState::ExecutionContext, "getAttachedShaders", "WebGLRenderingContext", info.Holder(), info.GetIsolate());
+ ExceptionState exceptionState(ExceptionState::ExecutionContext, "getAttachedShaders", "WebGLRenderingContextBase", info.Holder(), info.GetIsolate());
if (info.Length() < 1) {
exceptionState.throwTypeError(ExceptionMessages::notEnoughArguments(1, info.Length()));
exceptionState.throwIfNeeded();
@@ -322,13 +324,13 @@
}
const int programArgumentIndex = 0;
- WebGLRenderingContext* context = V8WebGLRenderingContext::toNative(info.Holder());
+ WebGLRenderingContextBase* context = V8WebGLRenderingContextBase::toNative(info.Holder());
if (info.Length() > 0 && !isUndefinedOrNull(info[programArgumentIndex]) && !V8WebGLProgram::hasInstance(info[programArgumentIndex], info.GetIsolate())) {
- exceptionState.throwTypeError(ExceptionMessages::incorrectArgumentType(programArgumentIndex + 1, "is not a WebGLProgram object."));
+ exceptionState.throwTypeError(ExceptionMessages::argumentNullOrIncorrectType(programArgumentIndex + 1, "WebGLProgram"));
exceptionState.throwIfNeeded();
return;
}
- WebGLProgram* program = V8WebGLProgram::hasInstance(info[0], info.GetIsolate()) ? V8WebGLProgram::toNative(v8::Handle<v8::Object>::Cast(info[0])) : 0;
+ WebGLProgram* program = V8WebGLProgram::toNativeWithTypeCheck(info.GetIsolate(), info[programArgumentIndex]);
Vector<RefPtr<WebGLShader> > shaders;
bool succeed = context->getAttachedShaders(program, shaders);
if (!succeed) {
@@ -341,16 +343,16 @@
v8SetReturnValue(info, array);
}
-void V8WebGLRenderingContext::getBufferParameterMethodCustom(const v8::FunctionCallbackInfo<v8::Value>& info)
+void V8WebGLRenderingContextBase::getBufferParameterMethodCustom(const v8::FunctionCallbackInfo<v8::Value>& info)
{
- ExceptionState exceptionState(ExceptionState::ExecutionContext, "getBufferParameter", "WebGLRenderingContext", info.Holder(), info.GetIsolate());
+ ExceptionState exceptionState(ExceptionState::ExecutionContext, "getBufferParameter", "WebGLRenderingContextBase", info.Holder(), info.GetIsolate());
getObjectParameter(info, kBuffer, exceptionState);
}
-void V8WebGLRenderingContext::getExtensionMethodCustom(const v8::FunctionCallbackInfo<v8::Value>& info)
+void V8WebGLRenderingContextBase::getExtensionMethodCustom(const v8::FunctionCallbackInfo<v8::Value>& info)
{
- ExceptionState exceptionState(ExceptionState::ExecutionContext, "getExtension", "WebGLRenderingContext", info.Holder(), info.GetIsolate());
- WebGLRenderingContext* imp = V8WebGLRenderingContext::toNative(info.Holder());
+ ExceptionState exceptionState(ExceptionState::ExecutionContext, "getExtension", "WebGLRenderingContextBase", info.Holder(), info.GetIsolate());
+ WebGLRenderingContextBase* imp = V8WebGLRenderingContextBase::toNative(info.Holder());
if (info.Length() < 1) {
exceptionState.throwTypeError(ExceptionMessages::notEnoughArguments(1, info.Length()));
exceptionState.throwIfNeeded();
@@ -361,16 +363,16 @@
v8SetReturnValue(info, toV8Object(extension.get(), info.Holder(), info.GetIsolate()));
}
-void V8WebGLRenderingContext::getFramebufferAttachmentParameterMethodCustom(const v8::FunctionCallbackInfo<v8::Value>& info)
+void V8WebGLRenderingContextBase::getFramebufferAttachmentParameterMethodCustom(const v8::FunctionCallbackInfo<v8::Value>& info)
{
- ExceptionState exceptionState(ExceptionState::ExecutionContext, "getFramebufferAttachmentParameter", "WebGLRenderingContext", info.Holder(), info.GetIsolate());
+ ExceptionState exceptionState(ExceptionState::ExecutionContext, "getFramebufferAttachmentParameter", "WebGLRenderingContextBase", info.Holder(), info.GetIsolate());
if (info.Length() != 3) {
exceptionState.throwTypeError(ExceptionMessages::notEnoughArguments(3, info.Length()));
exceptionState.throwIfNeeded();
return;
}
- WebGLRenderingContext* context = V8WebGLRenderingContext::toNative(info.Holder());
+ WebGLRenderingContextBase* context = V8WebGLRenderingContextBase::toNative(info.Holder());
unsigned target = toInt32(info[0]);
unsigned attachment = toInt32(info[1], exceptionState);
if (exceptionState.throwIfNeeded())
@@ -382,16 +384,16 @@
v8SetReturnValue(info, toV8Object(args, info.Holder(), info.GetIsolate()));
}
-void V8WebGLRenderingContext::getParameterMethodCustom(const v8::FunctionCallbackInfo<v8::Value>& info)
+void V8WebGLRenderingContextBase::getParameterMethodCustom(const v8::FunctionCallbackInfo<v8::Value>& info)
{
- ExceptionState exceptionState(ExceptionState::ExecutionContext, "getParameter", "WebGLRenderingContext", info.Holder(), info.GetIsolate());
+ ExceptionState exceptionState(ExceptionState::ExecutionContext, "getParameter", "WebGLRenderingContextBase", info.Holder(), info.GetIsolate());
if (info.Length() != 1) {
exceptionState.throwTypeError(ExceptionMessages::notEnoughArguments(1, info.Length()));
exceptionState.throwIfNeeded();
return;
}
- WebGLRenderingContext* context = V8WebGLRenderingContext::toNative(info.Holder());
+ WebGLRenderingContextBase* context = V8WebGLRenderingContextBase::toNative(info.Holder());
unsigned pname = toInt32(info[0], exceptionState);
if (exceptionState.throwIfNeeded())
return;
@@ -399,9 +401,9 @@
v8SetReturnValue(info, toV8Object(args, info.Holder(), info.GetIsolate()));
}
-void V8WebGLRenderingContext::getProgramParameterMethodCustom(const v8::FunctionCallbackInfo<v8::Value>& info)
+void V8WebGLRenderingContextBase::getProgramParameterMethodCustom(const v8::FunctionCallbackInfo<v8::Value>& info)
{
- ExceptionState exceptionState(ExceptionState::ExecutionContext, "getProgramParameter", "WebGLRenderingContext", info.Holder(), info.GetIsolate());
+ ExceptionState exceptionState(ExceptionState::ExecutionContext, "getProgramParameter", "WebGLRenderingContextBase", info.Holder(), info.GetIsolate());
if (info.Length() != 2) {
exceptionState.throwTypeError(ExceptionMessages::notEnoughArguments(2, info.Length()));
exceptionState.throwIfNeeded();
@@ -409,13 +411,13 @@
}
const int programArgumentIndex = 0;
- WebGLRenderingContext* context = V8WebGLRenderingContext::toNative(info.Holder());
+ WebGLRenderingContextBase* context = V8WebGLRenderingContextBase::toNative(info.Holder());
if (info.Length() > 0 && !isUndefinedOrNull(info[programArgumentIndex]) && !V8WebGLProgram::hasInstance(info[programArgumentIndex], info.GetIsolate())) {
- exceptionState.throwTypeError(ExceptionMessages::incorrectArgumentType(programArgumentIndex + 1, "is not a WebGLProgram object."));
+ exceptionState.throwTypeError(ExceptionMessages::argumentNullOrIncorrectType(programArgumentIndex + 1, "WebGLProgram"));
exceptionState.throwIfNeeded();
return;
}
- WebGLProgram* program = V8WebGLProgram::hasInstance(info[0], info.GetIsolate()) ? V8WebGLProgram::toNative(v8::Handle<v8::Object>::Cast(info[0])) : 0;
+ WebGLProgram* program = V8WebGLProgram::toNativeWithTypeCheck(info.GetIsolate(), info[programArgumentIndex]);
unsigned pname = toInt32(info[1], exceptionState);
if (exceptionState.throwIfNeeded())
return;
@@ -423,15 +425,15 @@
v8SetReturnValue(info, toV8Object(args, info.Holder(), info.GetIsolate()));
}
-void V8WebGLRenderingContext::getRenderbufferParameterMethodCustom(const v8::FunctionCallbackInfo<v8::Value>& info)
+void V8WebGLRenderingContextBase::getRenderbufferParameterMethodCustom(const v8::FunctionCallbackInfo<v8::Value>& info)
{
- ExceptionState exceptionState(ExceptionState::ExecutionContext, "getRenderbufferParameter", "WebGLRenderingContext", info.Holder(), info.GetIsolate());
+ ExceptionState exceptionState(ExceptionState::ExecutionContext, "getRenderbufferParameter", "WebGLRenderingContextBase", info.Holder(), info.GetIsolate());
getObjectParameter(info, kRenderbuffer, exceptionState);
}
-void V8WebGLRenderingContext::getShaderParameterMethodCustom(const v8::FunctionCallbackInfo<v8::Value>& info)
+void V8WebGLRenderingContextBase::getShaderParameterMethodCustom(const v8::FunctionCallbackInfo<v8::Value>& info)
{
- ExceptionState exceptionState(ExceptionState::ExecutionContext, "getShaderParameter", "WebGLRenderingContext", info.Holder(), info.GetIsolate());
+ ExceptionState exceptionState(ExceptionState::ExecutionContext, "getShaderParameter", "WebGLRenderingContextBase", info.Holder(), info.GetIsolate());
if (info.Length() != 2) {
exceptionState.throwTypeError(ExceptionMessages::notEnoughArguments(2, info.Length()));
exceptionState.throwIfNeeded();
@@ -439,13 +441,13 @@
}
const int shaderArgumentIndex = 0;
- WebGLRenderingContext* context = V8WebGLRenderingContext::toNative(info.Holder());
+ WebGLRenderingContextBase* context = V8WebGLRenderingContextBase::toNative(info.Holder());
if (info.Length() > 0 && !isUndefinedOrNull(info[shaderArgumentIndex]) && !V8WebGLShader::hasInstance(info[shaderArgumentIndex], info.GetIsolate())) {
- exceptionState.throwTypeError(ExceptionMessages::incorrectArgumentType(shaderArgumentIndex + 1, "is not a WebGLShader object."));
+ exceptionState.throwTypeError(ExceptionMessages::argumentNullOrIncorrectType(shaderArgumentIndex + 1, "WebGLShader"));
exceptionState.throwIfNeeded();
return;
}
- WebGLShader* shader = V8WebGLShader::hasInstance(info[shaderArgumentIndex], info.GetIsolate()) ? V8WebGLShader::toNative(v8::Handle<v8::Object>::Cast(info[0])) : 0;
+ WebGLShader* shader = V8WebGLShader::toNativeWithTypeCheck(info.GetIsolate(), info[shaderArgumentIndex]);
unsigned pname = toInt32(info[1], exceptionState);
if (exceptionState.throwIfNeeded())
return;
@@ -453,9 +455,9 @@
v8SetReturnValue(info, toV8Object(args, info.Holder(), info.GetIsolate()));
}
-void V8WebGLRenderingContext::getSupportedExtensionsMethodCustom(const v8::FunctionCallbackInfo<v8::Value>& info)
+void V8WebGLRenderingContextBase::getSupportedExtensionsMethodCustom(const v8::FunctionCallbackInfo<v8::Value>& info)
{
- WebGLRenderingContext* imp = V8WebGLRenderingContext::toNative(info.Holder());
+ WebGLRenderingContextBase* imp = V8WebGLRenderingContextBase::toNative(info.Holder());
if (imp->isContextLost()) {
v8SetReturnValueNull(info);
return;
@@ -468,15 +470,15 @@
v8SetReturnValue(info, array);
}
-void V8WebGLRenderingContext::getTexParameterMethodCustom(const v8::FunctionCallbackInfo<v8::Value>& info)
+void V8WebGLRenderingContextBase::getTexParameterMethodCustom(const v8::FunctionCallbackInfo<v8::Value>& info)
{
- ExceptionState exceptionState(ExceptionState::ExecutionContext, "getTexParameter", "WebGLRenderingContext", info.Holder(), info.GetIsolate());
+ ExceptionState exceptionState(ExceptionState::ExecutionContext, "getTexParameter", "WebGLRenderingContextBase", info.Holder(), info.GetIsolate());
getObjectParameter(info, kTexture, exceptionState);
}
-void V8WebGLRenderingContext::getUniformMethodCustom(const v8::FunctionCallbackInfo<v8::Value>& info)
+void V8WebGLRenderingContextBase::getUniformMethodCustom(const v8::FunctionCallbackInfo<v8::Value>& info)
{
- ExceptionState exceptionState(ExceptionState::ExecutionContext, "getUniform", "WebGLRenderingContext", info.Holder(), info.GetIsolate());
+ ExceptionState exceptionState(ExceptionState::ExecutionContext, "getUniform", "WebGLRenderingContextBase", info.Holder(), info.GetIsolate());
if (info.Length() != 2) {
exceptionState.throwTypeError(ExceptionMessages::notEnoughArguments(2, info.Length()));
exceptionState.throwIfNeeded();
@@ -484,17 +486,17 @@
}
const int programArgumentIndex = 0;
- WebGLRenderingContext* context = V8WebGLRenderingContext::toNative(info.Holder());
+ WebGLRenderingContextBase* context = V8WebGLRenderingContextBase::toNative(info.Holder());
if (info.Length() > 0 && !isUndefinedOrNull(info[programArgumentIndex]) && !V8WebGLProgram::hasInstance(info[programArgumentIndex], info.GetIsolate())) {
- exceptionState.throwTypeError(ExceptionMessages::incorrectArgumentType(programArgumentIndex + 1, "is not a WebGLProgram object."));
+ exceptionState.throwTypeError(ExceptionMessages::argumentNullOrIncorrectType(programArgumentIndex + 1, "WebGLProgram"));
exceptionState.throwIfNeeded();
return;
}
- WebGLProgram* program = V8WebGLProgram::hasInstance(info[programArgumentIndex], info.GetIsolate()) ? V8WebGLProgram::toNative(v8::Handle<v8::Object>::Cast(info[0])) : 0;
+ WebGLProgram* program = V8WebGLProgram::toNativeWithTypeCheck(info.GetIsolate(), info[programArgumentIndex]);
const int uniformArgumentIndex = 1;
if (info.Length() > 1 && !isUndefinedOrNull(info[uniformArgumentIndex]) && !V8WebGLUniformLocation::hasInstance(info[uniformArgumentIndex], info.GetIsolate())) {
- exceptionState.throwTypeError(ExceptionMessages::incorrectArgumentType(uniformArgumentIndex + 1, "is not a WebGLUniformLocation object."));
+ exceptionState.throwTypeError(ExceptionMessages::argumentNullOrIncorrectType(uniformArgumentIndex + 1, "WebGLUniformLocation"));
exceptionState.throwIfNeeded();
return;
}
@@ -505,9 +507,9 @@
v8SetReturnValue(info, toV8Object(args, info.Holder(), info.GetIsolate()));
}
-void V8WebGLRenderingContext::getVertexAttribMethodCustom(const v8::FunctionCallbackInfo<v8::Value>& info)
+void V8WebGLRenderingContextBase::getVertexAttribMethodCustom(const v8::FunctionCallbackInfo<v8::Value>& info)
{
- ExceptionState exceptionState(ExceptionState::ExecutionContext, "getVertexAttrib", "WebGLRenderingContext", info.Holder(), info.GetIsolate());
+ ExceptionState exceptionState(ExceptionState::ExecutionContext, "getVertexAttrib", "WebGLRenderingContextBase", info.Holder(), info.GetIsolate());
getObjectParameter(info, kVertexAttrib, exceptionState);
}
@@ -566,19 +568,19 @@
} else {
const int uniformLocationArgumentIndex = 0;
if (info.Length() > 0 && !isUndefinedOrNull(info[uniformLocationArgumentIndex]) && !V8WebGLUniformLocation::hasInstance(info[uniformLocationArgumentIndex], info.GetIsolate())) {
- exceptionState.throwTypeError(ExceptionMessages::incorrectArgumentType(uniformLocationArgumentIndex + 1, "is not a WebGLUniformLocation object."));
+ exceptionState.throwTypeError(ExceptionMessages::argumentNullOrIncorrectType(uniformLocationArgumentIndex + 1, "WebGLUniformLocation"));
exceptionState.throwIfNeeded();
return;
}
location = toWebGLUniformLocation(info[uniformLocationArgumentIndex], info.GetIsolate());
}
- WebGLRenderingContext* context = V8WebGLRenderingContext::toNative(info.Holder());
+ WebGLRenderingContextBase* context = V8WebGLRenderingContextBase::toNative(info.Holder());
const int indexArrayArgument = 1;
if (V8Float32Array::hasInstance(info[indexArrayArgument], info.GetIsolate())) {
Float32Array* array = V8Float32Array::toNative(info[indexArrayArgument]->ToObject());
- ASSERT(array != NULL);
+ ASSERT(array);
switch (functionToCall) {
case kUniform1v: context->uniform1fv(location, array); break;
case kUniform2v: context->uniform2fv(location, array); break;
@@ -594,7 +596,7 @@
}
if (info[indexArrayArgument].IsEmpty() || !info[indexArrayArgument]->IsArray()) {
- exceptionState.throwTypeError(ExceptionMessages::incorrectArgumentType(indexArrayArgument + 1, "is not an Array."));
+ exceptionState.throwTypeError(ExceptionMessages::argumentNullOrIncorrectType(indexArrayArgument + 1, "Array"));
exceptionState.throwIfNeeded();
return;
}
@@ -642,9 +644,9 @@
}
const int uniformLocationArgumentIndex = 0;
- WebGLRenderingContext* context = V8WebGLRenderingContext::toNative(info.Holder());
+ WebGLRenderingContextBase* context = V8WebGLRenderingContextBase::toNative(info.Holder());
if (info.Length() > 0 && !isUndefinedOrNull(info[uniformLocationArgumentIndex]) && !V8WebGLUniformLocation::hasInstance(info[uniformLocationArgumentIndex], info.GetIsolate())) {
- exceptionState.throwTypeError(ExceptionMessages::incorrectArgumentType(uniformLocationArgumentIndex + 1, "is not a WebGLUniformLocation object."));
+ exceptionState.throwTypeError(ExceptionMessages::argumentNullOrIncorrectType(uniformLocationArgumentIndex + 1, "WebGLUniformLocation"));
exceptionState.throwIfNeeded();
return;
}
@@ -653,7 +655,7 @@
const int indexArrayArgumentIndex = 1;
if (V8Int32Array::hasInstance(info[indexArrayArgumentIndex], info.GetIsolate())) {
Int32Array* array = V8Int32Array::toNative(info[indexArrayArgumentIndex]->ToObject());
- ASSERT(array != NULL);
+ ASSERT(array);
switch (functionToCall) {
case kUniform1v: context->uniform1iv(location, array); break;
case kUniform2v: context->uniform2iv(location, array); break;
@@ -665,7 +667,7 @@
}
if (info[indexArrayArgumentIndex].IsEmpty() || !info[indexArrayArgumentIndex]->IsArray()) {
- exceptionState.throwTypeError(ExceptionMessages::incorrectArgumentType(indexArrayArgumentIndex + 1, "is not an Array."));
+ exceptionState.throwTypeError(ExceptionMessages::argumentNullOrIncorrectType(indexArrayArgumentIndex + 1, "Array"));
exceptionState.throwIfNeeded();
return;
}
@@ -690,51 +692,51 @@
fastFree(data);
}
-void V8WebGLRenderingContext::uniform1fvMethodCustom(const v8::FunctionCallbackInfo<v8::Value>& info)
+void V8WebGLRenderingContextBase::uniform1fvMethodCustom(const v8::FunctionCallbackInfo<v8::Value>& info)
{
- ExceptionState exceptionState(ExceptionState::ExecutionContext, "uniform1fv", "WebGLRenderingContext", info.Holder(), info.GetIsolate());
+ ExceptionState exceptionState(ExceptionState::ExecutionContext, "uniform1fv", "WebGLRenderingContextBase", info.Holder(), info.GetIsolate());
vertexAttribAndUniformHelperf(info, kUniform1v, exceptionState);
}
-void V8WebGLRenderingContext::uniform1ivMethodCustom(const v8::FunctionCallbackInfo<v8::Value>& info)
+void V8WebGLRenderingContextBase::uniform1ivMethodCustom(const v8::FunctionCallbackInfo<v8::Value>& info)
{
- ExceptionState exceptionState(ExceptionState::ExecutionContext, "uniform1iv", "WebGLRenderingContext", info.Holder(), info.GetIsolate());
+ ExceptionState exceptionState(ExceptionState::ExecutionContext, "uniform1iv", "WebGLRenderingContextBase", info.Holder(), info.GetIsolate());
uniformHelperi(info, kUniform1v, exceptionState);
}
-void V8WebGLRenderingContext::uniform2fvMethodCustom(const v8::FunctionCallbackInfo<v8::Value>& info)
+void V8WebGLRenderingContextBase::uniform2fvMethodCustom(const v8::FunctionCallbackInfo<v8::Value>& info)
{
- ExceptionState exceptionState(ExceptionState::ExecutionContext, "uniform2fv", "WebGLRenderingContext", info.Holder(), info.GetIsolate());
+ ExceptionState exceptionState(ExceptionState::ExecutionContext, "uniform2fv", "WebGLRenderingContextBase", info.Holder(), info.GetIsolate());
vertexAttribAndUniformHelperf(info, kUniform2v, exceptionState);
}
-void V8WebGLRenderingContext::uniform2ivMethodCustom(const v8::FunctionCallbackInfo<v8::Value>& info)
+void V8WebGLRenderingContextBase::uniform2ivMethodCustom(const v8::FunctionCallbackInfo<v8::Value>& info)
{
- ExceptionState exceptionState(ExceptionState::ExecutionContext, "uniform2iv", "WebGLRenderingContext", info.Holder(), info.GetIsolate());
+ ExceptionState exceptionState(ExceptionState::ExecutionContext, "uniform2iv", "WebGLRenderingContextBase", info.Holder(), info.GetIsolate());
uniformHelperi(info, kUniform2v, exceptionState);
}
-void V8WebGLRenderingContext::uniform3fvMethodCustom(const v8::FunctionCallbackInfo<v8::Value>& info)
+void V8WebGLRenderingContextBase::uniform3fvMethodCustom(const v8::FunctionCallbackInfo<v8::Value>& info)
{
- ExceptionState exceptionState(ExceptionState::ExecutionContext, "uniform3fv", "WebGLRenderingContext", info.Holder(), info.GetIsolate());
+ ExceptionState exceptionState(ExceptionState::ExecutionContext, "uniform3fv", "WebGLRenderingContextBase", info.Holder(), info.GetIsolate());
vertexAttribAndUniformHelperf(info, kUniform3v, exceptionState);
}
-void V8WebGLRenderingContext::uniform3ivMethodCustom(const v8::FunctionCallbackInfo<v8::Value>& info)
+void V8WebGLRenderingContextBase::uniform3ivMethodCustom(const v8::FunctionCallbackInfo<v8::Value>& info)
{
- ExceptionState exceptionState(ExceptionState::ExecutionContext, "uniform3iv", "WebGLRenderingContext", info.Holder(), info.GetIsolate());
+ ExceptionState exceptionState(ExceptionState::ExecutionContext, "uniform3iv", "WebGLRenderingContextBase", info.Holder(), info.GetIsolate());
uniformHelperi(info, kUniform3v, exceptionState);
}
-void V8WebGLRenderingContext::uniform4fvMethodCustom(const v8::FunctionCallbackInfo<v8::Value>& info)
+void V8WebGLRenderingContextBase::uniform4fvMethodCustom(const v8::FunctionCallbackInfo<v8::Value>& info)
{
- ExceptionState exceptionState(ExceptionState::ExecutionContext, "uniform4fv", "WebGLRenderingContext", info.Holder(), info.GetIsolate());
+ ExceptionState exceptionState(ExceptionState::ExecutionContext, "uniform4fv", "WebGLRenderingContextBase", info.Holder(), info.GetIsolate());
vertexAttribAndUniformHelperf(info, kUniform4v, exceptionState);
}
-void V8WebGLRenderingContext::uniform4ivMethodCustom(const v8::FunctionCallbackInfo<v8::Value>& info)
+void V8WebGLRenderingContextBase::uniform4ivMethodCustom(const v8::FunctionCallbackInfo<v8::Value>& info)
{
- ExceptionState exceptionState(ExceptionState::ExecutionContext, "uniform4iv", "WebGLRenderingContext", info.Holder(), info.GetIsolate());
+ ExceptionState exceptionState(ExceptionState::ExecutionContext, "uniform4iv", "WebGLRenderingContextBase", info.Holder(), info.GetIsolate());
uniformHelperi(info, kUniform4v, exceptionState);
}
@@ -755,11 +757,11 @@
return;
}
- WebGLRenderingContext* context = V8WebGLRenderingContext::toNative(info.Holder());
+ WebGLRenderingContextBase* context = V8WebGLRenderingContextBase::toNative(info.Holder());
const int uniformLocationArgumentIndex = 0;
if (info.Length() > 0 && !isUndefinedOrNull(info[uniformLocationArgumentIndex]) && !V8WebGLUniformLocation::hasInstance(info[uniformLocationArgumentIndex], info.GetIsolate())) {
- exceptionState.throwTypeError(ExceptionMessages::incorrectArgumentType(uniformLocationArgumentIndex + 1, "is not a WebGLUniformLocation object."));
+ exceptionState.throwTypeError(ExceptionMessages::argumentNullOrIncorrectType(uniformLocationArgumentIndex + 1, "WebGLUniformLocation"));
exceptionState.throwIfNeeded();
return;
}
@@ -769,7 +771,7 @@
const int arrayArgumentIndex = 2;
if (V8Float32Array::hasInstance(info[arrayArgumentIndex], info.GetIsolate())) {
Float32Array* array = V8Float32Array::toNative(info[arrayArgumentIndex]->ToObject());
- ASSERT(array != NULL);
+ ASSERT(array);
switch (matrixSize) {
case 2: context->uniformMatrix2fv(location, transpose, array); break;
case 3: context->uniformMatrix3fv(location, transpose, array); break;
@@ -780,7 +782,7 @@
}
if (info[arrayArgumentIndex].IsEmpty() || !info[arrayArgumentIndex]->IsArray()) {
- exceptionState.throwTypeError(ExceptionMessages::incorrectArgumentType(arrayArgumentIndex + 1, "is not an Array."));
+ exceptionState.throwTypeError(ExceptionMessages::argumentNullOrIncorrectType(arrayArgumentIndex + 1, "Array"));
exceptionState.throwIfNeeded();
return;
}
@@ -804,45 +806,45 @@
fastFree(data);
}
-void V8WebGLRenderingContext::uniformMatrix2fvMethodCustom(const v8::FunctionCallbackInfo<v8::Value>& info)
+void V8WebGLRenderingContextBase::uniformMatrix2fvMethodCustom(const v8::FunctionCallbackInfo<v8::Value>& info)
{
- ExceptionState exceptionState(ExceptionState::ExecutionContext, "uniformMatrix2fv", "WebGLRenderingContext", info.Holder(), info.GetIsolate());
+ ExceptionState exceptionState(ExceptionState::ExecutionContext, "uniformMatrix2fv", "WebGLRenderingContextBase", info.Holder(), info.GetIsolate());
uniformMatrixHelper(info, 2, exceptionState);
}
-void V8WebGLRenderingContext::uniformMatrix3fvMethodCustom(const v8::FunctionCallbackInfo<v8::Value>& info)
+void V8WebGLRenderingContextBase::uniformMatrix3fvMethodCustom(const v8::FunctionCallbackInfo<v8::Value>& info)
{
- ExceptionState exceptionState(ExceptionState::ExecutionContext, "uniformMatrix3fv", "WebGLRenderingContext", info.Holder(), info.GetIsolate());
+ ExceptionState exceptionState(ExceptionState::ExecutionContext, "uniformMatrix3fv", "WebGLRenderingContextBase", info.Holder(), info.GetIsolate());
uniformMatrixHelper(info, 3, exceptionState);
}
-void V8WebGLRenderingContext::uniformMatrix4fvMethodCustom(const v8::FunctionCallbackInfo<v8::Value>& info)
+void V8WebGLRenderingContextBase::uniformMatrix4fvMethodCustom(const v8::FunctionCallbackInfo<v8::Value>& info)
{
- ExceptionState exceptionState(ExceptionState::ExecutionContext, "uniformMatrix4fv", "WebGLRenderingContext", info.Holder(), info.GetIsolate());
+ ExceptionState exceptionState(ExceptionState::ExecutionContext, "uniformMatrix4fv", "WebGLRenderingContextBase", info.Holder(), info.GetIsolate());
uniformMatrixHelper(info, 4, exceptionState);
}
-void V8WebGLRenderingContext::vertexAttrib1fvMethodCustom(const v8::FunctionCallbackInfo<v8::Value>& info)
+void V8WebGLRenderingContextBase::vertexAttrib1fvMethodCustom(const v8::FunctionCallbackInfo<v8::Value>& info)
{
- ExceptionState exceptionState(ExceptionState::ExecutionContext, "vertexAttrib1fv", "WebGLRenderingContext", info.Holder(), info.GetIsolate());
+ ExceptionState exceptionState(ExceptionState::ExecutionContext, "vertexAttrib1fv", "WebGLRenderingContextBase", info.Holder(), info.GetIsolate());
vertexAttribAndUniformHelperf(info, kVertexAttrib1v, exceptionState);
}
-void V8WebGLRenderingContext::vertexAttrib2fvMethodCustom(const v8::FunctionCallbackInfo<v8::Value>& info)
+void V8WebGLRenderingContextBase::vertexAttrib2fvMethodCustom(const v8::FunctionCallbackInfo<v8::Value>& info)
{
- ExceptionState exceptionState(ExceptionState::ExecutionContext, "vertexAttrib2fv", "WebGLRenderingContext", info.Holder(), info.GetIsolate());
+ ExceptionState exceptionState(ExceptionState::ExecutionContext, "vertexAttrib2fv", "WebGLRenderingContextBase", info.Holder(), info.GetIsolate());
vertexAttribAndUniformHelperf(info, kVertexAttrib2v, exceptionState);
}
-void V8WebGLRenderingContext::vertexAttrib3fvMethodCustom(const v8::FunctionCallbackInfo<v8::Value>& info)
+void V8WebGLRenderingContextBase::vertexAttrib3fvMethodCustom(const v8::FunctionCallbackInfo<v8::Value>& info)
{
- ExceptionState exceptionState(ExceptionState::ExecutionContext, "vertexAttrib3fv", "WebGLRenderingContext", info.Holder(), info.GetIsolate());
+ ExceptionState exceptionState(ExceptionState::ExecutionContext, "vertexAttrib3fv", "WebGLRenderingContextBase", info.Holder(), info.GetIsolate());
vertexAttribAndUniformHelperf(info, kVertexAttrib3v, exceptionState);
}
-void V8WebGLRenderingContext::vertexAttrib4fvMethodCustom(const v8::FunctionCallbackInfo<v8::Value>& info)
+void V8WebGLRenderingContextBase::vertexAttrib4fvMethodCustom(const v8::FunctionCallbackInfo<v8::Value>& info)
{
- ExceptionState exceptionState(ExceptionState::ExecutionContext, "vertexAttrib4fv", "WebGLRenderingContext", info.Holder(), info.GetIsolate());
+ ExceptionState exceptionState(ExceptionState::ExecutionContext, "vertexAttrib4fv", "WebGLRenderingContextBase", info.Holder(), info.GetIsolate());
vertexAttribAndUniformHelperf(info, kVertexAttrib4v, exceptionState);
}
diff --git a/Source/bindings/v8/custom/V8WindowCustom.cpp b/Source/bindings/v8/custom/V8WindowCustom.cpp
index 49ed622..72f79b4 100644
--- a/Source/bindings/v8/custom/V8WindowCustom.cpp
+++ b/Source/bindings/v8/custom/V8WindowCustom.cpp
@@ -44,7 +44,7 @@
#include "bindings/v8/V8EventListener.h"
#include "bindings/v8/V8EventListenerList.h"
#include "bindings/v8/V8GCForContextDispose.h"
-#include "bindings/v8/V8Utilities.h"
+#include "bindings/v8/V8HiddenValue.h"
#include "core/dom/ExceptionCode.h"
#include "core/dom/MessagePort.h"
#include "core/html/HTMLCollection.h"
@@ -52,13 +52,13 @@
#include "core/inspector/ScriptCallStack.h"
#include "core/loader/FrameLoadRequest.h"
#include "core/loader/FrameLoader.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/LocalFrame.h"
#include "core/frame/Settings.h"
+#include "core/frame/csp/ContentSecurityPolicy.h"
#include "core/storage/Storage.h"
#include "platform/PlatformScreen.h"
#include "platform/graphics/media/MediaPlayer.h"
@@ -128,7 +128,7 @@
ASSERT(imp->frame());
action = adoptPtr(new ScheduledAction(context, v8::Handle<v8::Function>::Cast(function), paramCount, params.get(), info.GetIsolate()));
} else {
- if (imp->document() && !imp->document()->contentSecurityPolicy()->allowScriptEval()) {
+ if (imp->document() && !imp->document()->contentSecurityPolicy()->allowEval()) {
v8SetReturnValue(info, 0);
return;
}
@@ -139,9 +139,9 @@
int32_t timeout = argumentCount >= 2 ? info[1]->Int32Value() : 0;
int timerId;
if (singleShot)
- timerId = DOMWindowTimers::setTimeout(imp, action.release(), timeout);
+ timerId = DOMWindowTimers::setTimeout(*imp, action.release(), timeout);
else
- timerId = DOMWindowTimers::setInterval(imp, action.release(), timeout);
+ timerId = DOMWindowTimers::setInterval(*imp, action.release(), timeout);
// Try to do the idle notification before the timeout expires to get better
// use of any idle time. Aim for the middle of the interval for simplicity.
@@ -155,7 +155,7 @@
void V8Window::eventAttributeGetterCustom(const v8::PropertyCallbackInfo<v8::Value>& info)
{
- Frame* frame = V8Window::toNative(info.Holder())->frame();
+ LocalFrame* frame = V8Window::toNative(info.Holder())->frame();
ExceptionState exceptionState(ExceptionState::GetterContext, "event", "Window", info.Holder(), info.GetIsolate());
if (!BindingSecurity::shouldAllowAccessToFrame(info.GetIsolate(), frame, exceptionState)) {
exceptionState.throwIfNeeded();
@@ -167,7 +167,7 @@
if (context.IsEmpty())
return;
- v8::Handle<v8::Value> jsEvent = getHiddenValue(info.GetIsolate(), context->Global(), "event");
+ v8::Handle<v8::Value> jsEvent = V8HiddenValue::getHiddenValue(info.GetIsolate(), context->Global(), V8HiddenValue::event(info.GetIsolate()));
if (jsEvent.IsEmpty())
return;
v8SetReturnValue(info, jsEvent);
@@ -175,7 +175,7 @@
void V8Window::eventAttributeSetterCustom(v8::Local<v8::Value> value, const v8::PropertyCallbackInfo<void>& info)
{
- Frame* frame = V8Window::toNative(info.Holder())->frame();
+ LocalFrame* frame = V8Window::toNative(info.Holder())->frame();
ExceptionState exceptionState(ExceptionState::SetterContext, "event", "Window", info.Holder(), info.GetIsolate());
if (!BindingSecurity::shouldAllowAccessToFrame(info.GetIsolate(), frame, exceptionState)) {
exceptionState.throwIfNeeded();
@@ -187,7 +187,7 @@
if (context.IsEmpty())
return;
- setHiddenValue(info.GetIsolate(), context->Global(), "event", value);
+ V8HiddenValue::setHiddenValue(info.GetIsolate(), context->Global(), V8HiddenValue::event(info.GetIsolate()), value);
}
void V8Window::frameElementAttributeGetterCustom(const v8::PropertyCallbackInfo<v8::Value>& info)
@@ -247,7 +247,7 @@
// None of these need to be RefPtr because info and context are guaranteed
// to hold on to them.
DOMWindow* window = V8Window::toNative(info.Holder());
- DOMWindow* source = activeDOMWindow(info.GetIsolate());
+ DOMWindow* source = callingDOMWindow(info.GetIsolate());
ExceptionState exceptionState(ExceptionState::ExecutionContext, "postMessage", "Window", info.Holder(), info.GetIsolate());
@@ -273,7 +273,7 @@
targetOriginArgIndex = 2;
transferablesArgIndex = 1;
}
- if (!extractTransferables(info[transferablesArgIndex], transferablesArgIndex, portArray, arrayBufferArray, exceptionState, info.GetIsolate())) {
+ if (!SerializedScriptValue::extractTransferables(info[transferablesArgIndex], transferablesArgIndex, portArray, arrayBufferArray, exceptionState, info.GetIsolate())) {
exceptionState.throwIfNeeded();
return;
}
@@ -294,7 +294,7 @@
// switching context of receiver. I consider it is dangerous.
void V8Window::toStringMethodCustom(const v8::FunctionCallbackInfo<v8::Value>& info)
{
- v8::Handle<v8::Object> domWrapper = info.This()->FindInstanceInPrototypeChain(V8Window::domTemplate(info.GetIsolate(), worldTypeInMainThread(info.GetIsolate())));
+ v8::Handle<v8::Object> domWrapper = V8Window::findInstanceInPrototypeChain(info.This(), info.GetIsolate());
if (domWrapper.IsEmpty()) {
v8SetReturnValue(info, info.This()->ObjectProtoToString());
return;
@@ -359,7 +359,7 @@
DialogHandler handler(info[1]);
V8TRYCATCH_FOR_V8STRINGRESOURCE_VOID(V8StringResource<WithUndefinedOrNullCheck>, dialogFeaturesString, info[2]);
- impl->showModalDialog(urlString, dialogFeaturesString, activeDOMWindow(info.GetIsolate()), firstDOMWindow(info.GetIsolate()), setUpDialog, &handler);
+ impl->showModalDialog(urlString, dialogFeaturesString, callingDOMWindow(info.GetIsolate()), enteredDOMWindow(info.GetIsolate()), setUpDialog, &handler);
v8SetReturnValue(info, handler.returnValue(info.GetIsolate()));
}
@@ -383,7 +383,7 @@
}
V8TRYCATCH_FOR_V8STRINGRESOURCE_VOID(V8StringResource<WithUndefinedOrNullCheck>, windowFeaturesString, info[2]);
- RefPtr<DOMWindow> openedWindow = impl->open(urlString, frameName, windowFeaturesString, activeDOMWindow(info.GetIsolate()), firstDOMWindow(info.GetIsolate()));
+ RefPtr<DOMWindow> openedWindow = impl->open(urlString, frameName, windowFeaturesString, callingDOMWindow(info.GetIsolate()), enteredDOMWindow(info.GetIsolate()));
if (!openedWindow)
return;
@@ -397,14 +397,14 @@
if (!window)
return;
- Frame* frame = window->frame();
+ LocalFrame* frame = window->frame();
// window is detached from a frame.
if (!frame)
return;
// Search sub-frames.
AtomicString propName = toCoreAtomicString(name);
- Frame* child = frame->tree().scopedChild(propName);
+ LocalFrame* child = frame->tree().scopedChild(propName);
if (child) {
v8SetReturnValueFast(info, child->domWindow(), window);
return;
@@ -451,7 +451,7 @@
bool V8Window::namedSecurityCheckCustom(v8::Local<v8::Object> host, v8::Local<v8::Value> key, v8::AccessType type, v8::Local<v8::Value>)
{
v8::Isolate* isolate = v8::Isolate::GetCurrent();
- v8::Handle<v8::Object> window = host->FindInstanceInPrototypeChain(V8Window::domTemplate(isolate, worldTypeInMainThread(isolate)));
+ v8::Handle<v8::Object> window = V8Window::findInstanceInPrototypeChain(host, isolate);
if (window.IsEmpty())
return false; // the frame is gone.
@@ -459,7 +459,7 @@
ASSERT(targetWindow);
- Frame* target = targetWindow->frame();
+ LocalFrame* target = targetWindow->frame();
if (!target)
return false;
@@ -471,7 +471,7 @@
DEFINE_STATIC_LOCAL(const AtomicString, nameOfProtoProperty, ("__proto__", AtomicString::ConstructFromLiteral));
AtomicString name = toCoreAtomicString(key.As<v8::String>());
- Frame* childFrame = target->tree().scopedChild(name);
+ LocalFrame* childFrame = target->tree().scopedChild(name);
// Notice that we can't call HasRealNamedProperty for ACCESS_HAS
// because that would generate infinite recursion.
if (type == v8::ACCESS_HAS && childFrame)
@@ -494,7 +494,7 @@
bool V8Window::indexedSecurityCheckCustom(v8::Local<v8::Object> host, uint32_t index, v8::AccessType type, v8::Local<v8::Value>)
{
v8::Isolate* isolate = v8::Isolate::GetCurrent();
- v8::Handle<v8::Object> window = host->FindInstanceInPrototypeChain(V8Window::domTemplate(isolate, worldTypeInMainThread(isolate)));
+ v8::Handle<v8::Object> window = V8Window::findInstanceInPrototypeChain(host, isolate);
if (window.IsEmpty())
return false;
@@ -502,7 +502,7 @@
ASSERT(targetWindow);
- Frame* target = targetWindow->frame();
+ LocalFrame* target = targetWindow->frame();
if (!target)
return false;
@@ -510,7 +510,7 @@
if (target->loader().stateMachine()->isDisplayingInitialEmptyDocument())
target->loader().didAccessInitialDocument();
- Frame* childFrame = target->tree().scopedChild(index);
+ LocalFrame* childFrame = target->tree().scopedChild(index);
// Notice that we can't call HasRealNamedProperty for ACCESS_HAS
// because that would generate infinite recursion.
@@ -533,7 +533,7 @@
return v8::Null(isolate);
// Initializes environment of a frame, and return the global object
// of the frame.
- Frame* frame = window->frame();
+ LocalFrame* frame = window->frame();
if (!frame)
return v8Undefined();
@@ -542,9 +542,8 @@
// code running in one of those contexts accesses the window object, we
// want to return the global object associated with that context, not
// necessarily the first global object associated with that DOMWindow.
- v8::Handle<v8::Context> currentContext = isolate->GetCurrentContext();
- v8::Handle<v8::Object> currentGlobal = currentContext->Global();
- v8::Handle<v8::Object> windowWrapper = currentGlobal->FindInstanceInPrototypeChain(V8Window::domTemplate(isolate, worldTypeInMainThread(isolate)));
+ v8::Handle<v8::Object> currentGlobal = isolate->GetCurrentContext()->Global();
+ v8::Handle<v8::Object> windowWrapper = V8Window::findInstanceInPrototypeChain(currentGlobal, isolate);
if (!windowWrapper.IsEmpty()) {
if (V8Window::toNative(windowWrapper) == window)
return currentGlobal;
diff --git a/Source/bindings/v8/custom/V8WorkerCustom.cpp b/Source/bindings/v8/custom/V8WorkerCustom.cpp
index 6c09af4..0d84bbf 100644
--- a/Source/bindings/v8/custom/V8WorkerCustom.cpp
+++ b/Source/bindings/v8/custom/V8WorkerCustom.cpp
@@ -35,7 +35,6 @@
#include "bindings/v8/ExceptionState.h"
#include "bindings/v8/SerializedScriptValue.h"
#include "bindings/v8/V8Binding.h"
-#include "bindings/v8/V8Utilities.h"
#include "core/workers/Worker.h"
#include "core/workers/WorkerGlobalScope.h"
#include "wtf/ArrayBuffer.h"
@@ -50,7 +49,7 @@
ArrayBufferArray arrayBuffers;
if (info.Length() > 1) {
const int transferablesArgIndex = 1;
- if (!extractTransferables(info[transferablesArgIndex], transferablesArgIndex, ports, arrayBuffers, exceptionState, info.GetIsolate())) {
+ if (!SerializedScriptValue::extractTransferables(info[transferablesArgIndex], transferablesArgIndex, ports, arrayBuffers, exceptionState, info.GetIsolate())) {
exceptionState.throwIfNeeded();
return;
}
diff --git a/Source/bindings/v8/custom/V8WorkerGlobalScopeCustom.cpp b/Source/bindings/v8/custom/V8WorkerGlobalScopeCustom.cpp
index 7f55216..8324e01 100644
--- a/Source/bindings/v8/custom/V8WorkerGlobalScopeCustom.cpp
+++ b/Source/bindings/v8/custom/V8WorkerGlobalScopeCustom.cpp
@@ -34,13 +34,12 @@
#include "bindings/v8/ExceptionState.h"
#include "bindings/v8/ScheduledAction.h"
#include "bindings/v8/V8Binding.h"
-#include "bindings/v8/V8Utilities.h"
#include "bindings/v8/V8WorkerGlobalScopeEventListener.h"
#include "bindings/v8/WorkerScriptController.h"
#include "core/inspector/ScriptCallStack.h"
-#include "core/frame/ContentSecurityPolicy.h"
#include "core/frame/DOMTimer.h"
#include "core/frame/DOMWindowTimers.h"
+#include "core/frame/csp/ContentSecurityPolicy.h"
#include "core/workers/WorkerGlobalScope.h"
#include "modules/websockets/WebSocket.h"
#include "wtf/OwnPtr.h"
@@ -50,6 +49,7 @@
void SetTimeoutOrInterval(const v8::FunctionCallbackInfo<v8::Value>& info, bool singleShot)
{
WorkerGlobalScope* workerGlobalScope = V8WorkerGlobalScope::toNative(info.Holder());
+ ASSERT(workerGlobalScope);
int argumentCount = info.Length();
if (argumentCount < 1)
@@ -65,7 +65,7 @@
v8::Handle<v8::Context> v8Context = script->context();
if (function->IsString()) {
if (ContentSecurityPolicy* policy = workerGlobalScope->contentSecurityPolicy()) {
- if (!policy->allowScriptEval()) {
+ if (!policy->allowEval()) {
v8SetReturnValue(info, 0);
return;
}
@@ -87,9 +87,9 @@
int32_t timeout = argumentCount >= 2 ? info[1]->Int32Value() : 0;
int timerId;
if (singleShot)
- timerId = DOMWindowTimers::setTimeout(workerGlobalScope, action.release(), timeout);
+ timerId = DOMWindowTimers::setTimeout(*workerGlobalScope, action.release(), timeout);
else
- timerId = DOMWindowTimers::setInterval(workerGlobalScope, action.release(), timeout);
+ timerId = DOMWindowTimers::setInterval(*workerGlobalScope, action.release(), timeout);
v8SetReturnValue(info, timerId);
}
diff --git a/Source/bindings/v8/custom/V8XMLHttpRequestCustom.cpp b/Source/bindings/v8/custom/V8XMLHttpRequestCustom.cpp
index 9fab4af..c2422ef 100644
--- a/Source/bindings/v8/custom/V8XMLHttpRequestCustom.cpp
+++ b/Source/bindings/v8/custom/V8XMLHttpRequestCustom.cpp
@@ -39,7 +39,6 @@
#include "bindings/v8/ExceptionMessages.h"
#include "bindings/v8/ExceptionState.h"
#include "bindings/v8/V8Binding.h"
-#include "bindings/v8/V8Utilities.h"
#include "bindings/v8/custom/V8ArrayBufferCustom.h"
#include "bindings/v8/custom/V8ArrayBufferViewCustom.h"
#include "core/dom/Document.h"
@@ -63,7 +62,7 @@
securityOrigin = world->isolatedWorldSecurityOrigin();
}
- RefPtr<XMLHttpRequest> xmlHttpRequest = XMLHttpRequest::create(context, securityOrigin);
+ RefPtrWillBeRawPtr<XMLHttpRequest> xmlHttpRequest = XMLHttpRequest::create(context, securityOrigin);
v8::Handle<v8::Object> wrapper = info.Holder();
V8DOMWrapper::associateObjectWithWrapper<V8XMLHttpRequest>(xmlHttpRequest.release(), &wrapperTypeInfo, wrapper, info.GetIsolate(), WrapperConfiguration::Dependent);
diff --git a/Source/bindings/v8/npruntime.cpp b/Source/bindings/v8/npruntime.cpp
index d3e1755..831864f 100644
--- a/Source/bindings/v8/npruntime.cpp
+++ b/Source/bindings/v8/npruntime.cpp
@@ -352,7 +352,7 @@
// The rootObjectMap is a hash table of root objects to a set of
// objects that should be deactivated in sync with the root. A
// root is defined as a top-level owner object. This is used on
-// Frame teardown to deactivate all objects associated
+// LocalFrame teardown to deactivate all objects associated
// with a particular plugin.
typedef WTF::HashSet<NPObject*> NPObjectSet;