[V8] Implement V8Binding::v8Null(isolate) and use it in CodeGeneratorV8.pm
authorharaken@chromium.org <haraken@chromium.org@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Tue, 29 May 2012 06:42:08 +0000 (06:42 +0000)
committerharaken@chromium.org <haraken@chromium.org@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Tue, 29 May 2012 06:42:08 +0000 (06:42 +0000)
https://bugs.webkit.org/show_bug.cgi?id=87692

Reviewed by Adam Barth.

Since v8::Null(isolate) crashes if we pass a NULL isolate, we are planning
to pass Isolate to v8::Null() in the following steps:

[1] Implement V8Bindings::v8Null(isolate). v8Null(isolate) does the NULL check.
If isolate is NULL, v8Null(isolate) calls v8::Null(). Otherwise,
v8Null(isolate) calls v8::Null(isolate).

[2] In V8 bindings, we replace v8::Null() with v8::Null(isolate) for a non-optional
'isolate' parameter. (e.g. void foo(..., Isolate* isolate) { v8::Null(); } )

[3] In V8 bindings, we replace v8::Null() with v8Null(isolate) for an optional
'isolate' parameter. (e.g. void foo(..., Isolate* isolate = 0) { v8::Null(); } )

This bug fixes [1] by implementing V8Binding::v8Null(isolate). Also this patch uses
V8Binding::v8Null(isolate) in bindings/v8/*.{h,cpp}.

No tests. No behavior change.

* bindings/scripts/CodeGeneratorV8.pm:
(GenerateHeader):
(NativeToJSValue):
* bindings/scripts/test/V8/V8Float64Array.h:
* bindings/scripts/test/V8/V8TestActiveDOMObject.h:
(WebCore::toV8):
* bindings/scripts/test/V8/V8TestCustomNamedGetter.h:
(WebCore::toV8):
* bindings/scripts/test/V8/V8TestEventConstructor.h:
(WebCore::toV8):
* bindings/scripts/test/V8/V8TestEventTarget.h:
(WebCore::toV8):
* bindings/scripts/test/V8/V8TestException.h:
(WebCore::toV8):
* bindings/scripts/test/V8/V8TestInterface.h:
(WebCore::toV8):
* bindings/scripts/test/V8/V8TestMediaQueryListListener.h:
(WebCore::toV8):
* bindings/scripts/test/V8/V8TestNamedConstructor.h:
(WebCore::toV8):
* bindings/scripts/test/V8/V8TestNode.h:
(WebCore::toV8):
* bindings/scripts/test/V8/V8TestObj.h:
(WebCore::toV8):
* bindings/scripts/test/V8/V8TestSerializedScriptValueInterface.cpp:
(WebCore::TestSerializedScriptValueInterfaceV8Internal::valueAttrGetter):
(WebCore::TestSerializedScriptValueInterfaceV8Internal::readonlyValueAttrGetter):
* bindings/scripts/test/V8/V8TestSerializedScriptValueInterface.h:
(WebCore::toV8):
* bindings/v8/V8Binding.h:
(WebCore::v8Null):
(WebCore):
(WebCore::v8DateOrNull):
* bindings/v8/V8DOMWrapper.cpp:
* bindings/v8/V8DOMWrapper.h:
(WebCore):

git-svn-id: https://svn.webkit.org/repository/webkit/trunk@118726 268f45cc-cd09-0410-ab3c-d52691b4dbfc

18 files changed:
Source/WebCore/ChangeLog
Source/WebCore/bindings/scripts/CodeGeneratorV8.pm
Source/WebCore/bindings/scripts/test/V8/V8Float64Array.h
Source/WebCore/bindings/scripts/test/V8/V8TestActiveDOMObject.h
Source/WebCore/bindings/scripts/test/V8/V8TestCustomNamedGetter.h
Source/WebCore/bindings/scripts/test/V8/V8TestEventConstructor.h
Source/WebCore/bindings/scripts/test/V8/V8TestEventTarget.h
Source/WebCore/bindings/scripts/test/V8/V8TestException.h
Source/WebCore/bindings/scripts/test/V8/V8TestInterface.h
Source/WebCore/bindings/scripts/test/V8/V8TestMediaQueryListListener.h
Source/WebCore/bindings/scripts/test/V8/V8TestNamedConstructor.h
Source/WebCore/bindings/scripts/test/V8/V8TestNode.h
Source/WebCore/bindings/scripts/test/V8/V8TestObj.h
Source/WebCore/bindings/scripts/test/V8/V8TestSerializedScriptValueInterface.cpp
Source/WebCore/bindings/scripts/test/V8/V8TestSerializedScriptValueInterface.h
Source/WebCore/bindings/v8/V8Binding.h
Source/WebCore/bindings/v8/V8DOMWrapper.cpp
Source/WebCore/bindings/v8/V8DOMWrapper.h

index 5551b2e..17e9739 100644 (file)
@@ -1,3 +1,65 @@
+2012-05-28  Kentaro Hara  <haraken@chromium.org>
+
+        [V8] Implement V8Binding::v8Null(isolate) and use it in CodeGeneratorV8.pm
+        https://bugs.webkit.org/show_bug.cgi?id=87692
+
+        Reviewed by Adam Barth.
+
+        Since v8::Null(isolate) crashes if we pass a NULL isolate, we are planning
+        to pass Isolate to v8::Null() in the following steps:
+
+        [1] Implement V8Bindings::v8Null(isolate). v8Null(isolate) does the NULL check.
+        If isolate is NULL, v8Null(isolate) calls v8::Null(). Otherwise,
+        v8Null(isolate) calls v8::Null(isolate).
+
+        [2] In V8 bindings, we replace v8::Null() with v8::Null(isolate) for a non-optional
+        'isolate' parameter. (e.g. void foo(..., Isolate* isolate) { v8::Null(); } )
+
+        [3] In V8 bindings, we replace v8::Null() with v8Null(isolate) for an optional
+        'isolate' parameter. (e.g. void foo(..., Isolate* isolate = 0) { v8::Null(); } )
+
+        This bug fixes [1] by implementing V8Binding::v8Null(isolate). Also this patch uses
+        V8Binding::v8Null(isolate) in bindings/v8/*.{h,cpp}.
+
+        No tests. No behavior change.
+
+        * bindings/scripts/CodeGeneratorV8.pm:
+        (GenerateHeader):
+        (NativeToJSValue):
+        * bindings/scripts/test/V8/V8Float64Array.h:
+        * bindings/scripts/test/V8/V8TestActiveDOMObject.h:
+        (WebCore::toV8):
+        * bindings/scripts/test/V8/V8TestCustomNamedGetter.h:
+        (WebCore::toV8):
+        * bindings/scripts/test/V8/V8TestEventConstructor.h:
+        (WebCore::toV8):
+        * bindings/scripts/test/V8/V8TestEventTarget.h:
+        (WebCore::toV8):
+        * bindings/scripts/test/V8/V8TestException.h:
+        (WebCore::toV8):
+        * bindings/scripts/test/V8/V8TestInterface.h:
+        (WebCore::toV8):
+        * bindings/scripts/test/V8/V8TestMediaQueryListListener.h:
+        (WebCore::toV8):
+        * bindings/scripts/test/V8/V8TestNamedConstructor.h:
+        (WebCore::toV8):
+        * bindings/scripts/test/V8/V8TestNode.h:
+        (WebCore::toV8):
+        * bindings/scripts/test/V8/V8TestObj.h:
+        (WebCore::toV8):
+        * bindings/scripts/test/V8/V8TestSerializedScriptValueInterface.cpp:
+        (WebCore::TestSerializedScriptValueInterfaceV8Internal::valueAttrGetter):
+        (WebCore::TestSerializedScriptValueInterfaceV8Internal::readonlyValueAttrGetter):
+        * bindings/scripts/test/V8/V8TestSerializedScriptValueInterface.h:
+        (WebCore::toV8):
+        * bindings/v8/V8Binding.h:
+        (WebCore::v8Null):
+        (WebCore):
+        (WebCore::v8DateOrNull):
+        * bindings/v8/V8DOMWrapper.cpp:
+        * bindings/v8/V8DOMWrapper.h:
+        (WebCore):
+
 2012-05-28  Kent Tamura  <tkent@chromium.org>
 
         Fix a crash in HTMLFormControlElement::disabled().
index f641504..bfcc98e 100644 (file)
@@ -249,6 +249,7 @@ sub GenerateHeader
 
     $headerIncludes{"wtf/text/StringHash.h"} = 1;
     $headerIncludes{"WrapperTypeInfo.h"} = 1;
+    $headerIncludes{"V8Binding.h"} = 1;
     $headerIncludes{"V8DOMWrapper.h"} = 1;
     $headerIncludes{"wtf/HashMap.h"} = 1;
     $headerIncludes{"v8.h"} = 1;
@@ -455,7 +456,7 @@ END
 inline v8::Handle<v8::Value> toV8(${nativeType}* impl, v8::Isolate* isolate = 0${forceNewObjectParameter})
 {
     if (!impl)
-        return v8::Null();
+        return v8Null(isolate);
     return ${className}::wrap(impl, isolate${forceNewObjectCall});
 }
 END
@@ -472,7 +473,7 @@ v8::Handle<v8::Value> toV8Slow(Node*, v8::Isolate*, bool);
 inline v8::Handle<v8::Value> toV8(Node* impl, v8::Isolate* isolate = 0, bool forceNewObject = false)
 {
     if (UNLIKELY(!impl))
-        return v8::Null();
+        return v8Null(isolate);
     if (UNLIKELY(forceNewObject))
         return toV8Slow(impl, isolate, forceNewObject);
     v8::Handle<v8::Value> wrapper = V8DOMWrapper::getCachedWrapper(impl);
@@ -3798,7 +3799,7 @@ sub NativeToJSValue
     my $signature = shift;
     my $value = shift;
     my $getIsolate = shift;
-    $getIsolate = $getIsolate ? ", $getIsolate" : "";
+    my $getIsolateArg = $getIsolate ? ", $getIsolate" : "";
     my $type = GetTypeFromSignature($signature);
 
     return "v8Boolean($value)" if $type eq "boolean";
@@ -3818,7 +3819,7 @@ sub NativeToJSValue
     return "v8::Integer::New($value)" if $nativeType eq "int";
     return "v8::Integer::NewFromUnsigned($value)" if $nativeType eq "unsigned";
 
-    return "v8DateOrNull($value)" if $type eq "Date";
+    return "v8DateOrNull($value$getIsolateArg)" if $type eq "Date";
     # long long and unsigned long long are not representable in ECMAScript.
     return "v8::Number::New(static_cast<double>($value))" if $type eq "long long" or $type eq "unsigned long long" or $type eq "DOMTimeStamp";
     return "v8::Number::New($value)" if $codeGenerator->IsPrimitiveType($type);
@@ -3830,13 +3831,13 @@ sub NativeToJSValue
     if ($codeGenerator->IsStringType($type)) {
         my $conv = $signature->extendedAttributes->{"TreatReturnedNullStringAs"};
         if (defined $conv) {
-            return "v8StringOrNull($value$getIsolate)" if $conv eq "Null";
-            return "v8StringOrUndefined($value$getIsolate)" if $conv eq "Undefined";
-            return "v8StringOrFalse($value$getIsolate)" if $conv eq "False";
+            return "v8StringOrNull($value$getIsolateArg)" if $conv eq "Null";
+            return "v8StringOrUndefined($value$getIsolateArg)" if $conv eq "Undefined";
+            return "v8StringOrFalse($value$getIsolateArg)" if $conv eq "False";
 
             die "Unknown value for TreatReturnedNullStringAs extended attribute";
         }
-        return "v8String($value$getIsolate)";
+        return "v8String($value$getIsolateArg)";
     }
 
     my $arrayType = $codeGenerator->GetArrayType($type);
@@ -3845,35 +3846,35 @@ sub NativeToJSValue
             AddToImplIncludes("V8$arrayType.h");
             AddToImplIncludes("$arrayType.h");
         }
-        return "v8Array($value$getIsolate)";
+        return "v8Array($value$getIsolateArg)";
     }
 
     AddIncludesForType($type);
 
     # special case for non-DOM node interfaces
     if (IsDOMNodeType($type)) {
-        return "toV8(${value}" . ($signature->extendedAttributes->{"ReturnNewObject"} ? "$getIsolate, true)" : "$getIsolate)");
+        return "toV8(${value}" . ($signature->extendedAttributes->{"ReturnNewObject"} ? "$getIsolateArg, true)" : "$getIsolateArg)");
     }
 
     if ($type eq "EventTarget") {
-        return "V8DOMWrapper::convertEventTargetToV8Object($value$getIsolate)";
+        return "V8DOMWrapper::convertEventTargetToV8Object($value$getIsolateArg)";
     }
 
     if ($type eq "EventListener") {
         AddToImplIncludes("V8AbstractEventListener.h");
-        return "${value} ? v8::Handle<v8::Value>(static_cast<V8AbstractEventListener*>(${value})->getListenerObject(imp->scriptExecutionContext())) : v8::Handle<v8::Value>(v8::Null())";
+        return "${value} ? v8::Handle<v8::Value>(static_cast<V8AbstractEventListener*>(${value})->getListenerObject(imp->scriptExecutionContext())) : v8::Handle<v8::Value>(" . ($getIsolate ? "v8::Null($getIsolate)" : "v8::Null()") . ")";
     }
 
     if ($type eq "SerializedScriptValue") {
         AddToImplIncludes("$type.h");
-        return "$value ? $value->deserialize() : v8::Handle<v8::Value>(v8::Null())";
+        return "$value ? $value->deserialize() : v8::Handle<v8::Value>(" . ($getIsolate ? "v8::Null($getIsolate)" : "v8::Null()") . ")";
     }
 
     AddToImplIncludes("wtf/RefCounted.h");
     AddToImplIncludes("wtf/RefPtr.h");
     AddToImplIncludes("wtf/GetPtr.h");
 
-    return "toV8($value$getIsolate)";
+    return "toV8($value$getIsolateArg)";
 }
 
 sub ReturnNativeToJSValue
index 368fceb..b0dfd55 100644 (file)
@@ -22,6 +22,7 @@
 #define V8Float64Array_h
 
 #include "V8ArrayBufferView.h"
+#include "V8Binding.h"
 #include "V8DOMWrapper.h"
 #include "WrapperTypeInfo.h"
 #include <v8.h>
index c552028..4d8bf65 100644 (file)
@@ -22,6 +22,7 @@
 #define V8TestActiveDOMObject_h
 
 #include "TestActiveDOMObject.h"
+#include "V8Binding.h"
 #include "V8DOMWrapper.h"
 #include "WrapperTypeInfo.h"
 #include <v8.h>
@@ -61,7 +62,7 @@ v8::Handle<v8::Object> V8TestActiveDOMObject::wrap(TestActiveDOMObject* impl, v8
 inline v8::Handle<v8::Value> toV8(TestActiveDOMObject* impl, v8::Isolate* isolate = 0)
 {
     if (!impl)
-        return v8::Null();
+        return v8Null(isolate);
     return V8TestActiveDOMObject::wrap(impl, isolate);
 }
 inline v8::Handle<v8::Value> toV8(PassRefPtr< TestActiveDOMObject > impl, v8::Isolate* isolate = 0)
index 99472b7..7774a4d 100644 (file)
@@ -22,6 +22,7 @@
 #define V8TestCustomNamedGetter_h
 
 #include "TestCustomNamedGetter.h"
+#include "V8Binding.h"
 #include "V8DOMWrapper.h"
 #include "WrapperTypeInfo.h"
 #include <v8.h>
@@ -60,7 +61,7 @@ v8::Handle<v8::Object> V8TestCustomNamedGetter::wrap(TestCustomNamedGetter* impl
 inline v8::Handle<v8::Value> toV8(TestCustomNamedGetter* impl, v8::Isolate* isolate = 0)
 {
     if (!impl)
-        return v8::Null();
+        return v8Null(isolate);
     return V8TestCustomNamedGetter::wrap(impl, isolate);
 }
 inline v8::Handle<v8::Value> toV8(PassRefPtr< TestCustomNamedGetter > impl, v8::Isolate* isolate = 0)
index 119310b..89f8568 100644 (file)
@@ -22,6 +22,7 @@
 #define V8TestEventConstructor_h
 
 #include "TestEventConstructor.h"
+#include "V8Binding.h"
 #include "V8DOMWrapper.h"
 #include "WrapperTypeInfo.h"
 #include <v8.h>
@@ -61,7 +62,7 @@ v8::Handle<v8::Object> V8TestEventConstructor::wrap(TestEventConstructor* impl,
 inline v8::Handle<v8::Value> toV8(TestEventConstructor* impl, v8::Isolate* isolate = 0)
 {
     if (!impl)
-        return v8::Null();
+        return v8Null(isolate);
     return V8TestEventConstructor::wrap(impl, isolate);
 }
 inline v8::Handle<v8::Value> toV8(PassRefPtr< TestEventConstructor > impl, v8::Isolate* isolate = 0)
index d577c98..556421f 100644 (file)
@@ -22,6 +22,7 @@
 #define V8TestEventTarget_h
 
 #include "TestEventTarget.h"
+#include "V8Binding.h"
 #include "V8DOMWrapper.h"
 #include "WrapperTypeInfo.h"
 #include <v8.h>
@@ -62,7 +63,7 @@ v8::Handle<v8::Object> V8TestEventTarget::wrap(TestEventTarget* impl, v8::Isolat
 inline v8::Handle<v8::Value> toV8(TestEventTarget* impl, v8::Isolate* isolate = 0)
 {
     if (!impl)
-        return v8::Null();
+        return v8Null(isolate);
     return V8TestEventTarget::wrap(impl, isolate);
 }
 inline v8::Handle<v8::Value> toV8(PassRefPtr< TestEventTarget > impl, v8::Isolate* isolate = 0)
index 7a2f584..fa6a69e 100644 (file)
@@ -22,6 +22,7 @@
 #define V8TestException_h
 
 #include "TestException.h"
+#include "V8Binding.h"
 #include "V8DOMWrapper.h"
 #include "WrapperTypeInfo.h"
 #include <v8.h>
@@ -59,7 +60,7 @@ v8::Handle<v8::Object> V8TestException::wrap(TestException* impl, v8::Isolate* i
 inline v8::Handle<v8::Value> toV8(TestException* impl, v8::Isolate* isolate = 0)
 {
     if (!impl)
-        return v8::Null();
+        return v8Null(isolate);
     return V8TestException::wrap(impl, isolate);
 }
 inline v8::Handle<v8::Value> toV8(PassRefPtr< TestException > impl, v8::Isolate* isolate = 0)
index 8206415..7a9adfc 100644 (file)
@@ -24,6 +24,7 @@
 #define V8TestInterface_h
 
 #include "TestInterface.h"
+#include "V8Binding.h"
 #include "V8DOMWrapper.h"
 #include "WrapperTypeInfo.h"
 #include <v8.h>
@@ -64,7 +65,7 @@ v8::Handle<v8::Object> V8TestInterface::wrap(TestInterface* impl, v8::Isolate* i
 inline v8::Handle<v8::Value> toV8(TestInterface* impl, v8::Isolate* isolate = 0)
 {
     if (!impl)
-        return v8::Null();
+        return v8Null(isolate);
     return V8TestInterface::wrap(impl, isolate);
 }
 inline v8::Handle<v8::Value> toV8(PassRefPtr< TestInterface > impl, v8::Isolate* isolate = 0)
index 0fe7179..4f84d6d 100644 (file)
@@ -22,6 +22,7 @@
 #define V8TestMediaQueryListListener_h
 
 #include "TestMediaQueryListListener.h"
+#include "V8Binding.h"
 #include "V8DOMWrapper.h"
 #include "WrapperTypeInfo.h"
 #include <v8.h>
@@ -59,7 +60,7 @@ v8::Handle<v8::Object> V8TestMediaQueryListListener::wrap(TestMediaQueryListList
 inline v8::Handle<v8::Value> toV8(TestMediaQueryListListener* impl, v8::Isolate* isolate = 0)
 {
     if (!impl)
-        return v8::Null();
+        return v8Null(isolate);
     return V8TestMediaQueryListListener::wrap(impl, isolate);
 }
 inline v8::Handle<v8::Value> toV8(PassRefPtr< TestMediaQueryListListener > impl, v8::Isolate* isolate = 0)
index c6e2625..d8441c0 100644 (file)
@@ -22,6 +22,7 @@
 #define V8TestNamedConstructor_h
 
 #include "TestNamedConstructor.h"
+#include "V8Binding.h"
 #include "V8DOMWrapper.h"
 #include "WrapperTypeInfo.h"
 #include <v8.h>
@@ -66,7 +67,7 @@ v8::Handle<v8::Object> V8TestNamedConstructor::wrap(TestNamedConstructor* impl,
 inline v8::Handle<v8::Value> toV8(TestNamedConstructor* impl, v8::Isolate* isolate = 0)
 {
     if (!impl)
-        return v8::Null();
+        return v8Null(isolate);
     return V8TestNamedConstructor::wrap(impl, isolate);
 }
 inline v8::Handle<v8::Value> toV8(PassRefPtr< TestNamedConstructor > impl, v8::Isolate* isolate = 0)
index 57e5026..d21f1c6 100644 (file)
@@ -22,6 +22,7 @@
 #define V8TestNode_h
 
 #include "TestNode.h"
+#include "V8Binding.h"
 #include "V8DOMWrapper.h"
 #include "WrapperTypeInfo.h"
 #include <v8.h>
@@ -60,7 +61,7 @@ v8::Handle<v8::Object> V8TestNode::wrap(TestNode* impl, v8::Isolate* isolate)
 inline v8::Handle<v8::Value> toV8(TestNode* impl, v8::Isolate* isolate = 0)
 {
     if (!impl)
-        return v8::Null();
+        return v8Null(isolate);
     return V8TestNode::wrap(impl, isolate);
 }
 inline v8::Handle<v8::Value> toV8(PassRefPtr< TestNode > impl, v8::Isolate* isolate = 0)
index e1bb813..5230753 100644 (file)
@@ -22,6 +22,7 @@
 #define V8TestObj_h
 
 #include "TestObj.h"
+#include "V8Binding.h"
 #include "V8DOMWrapper.h"
 #include "WrapperTypeInfo.h"
 #include <v8.h>
@@ -66,7 +67,7 @@ v8::Handle<v8::Object> V8TestObj::wrap(TestObj* impl, v8::Isolate* isolate)
 inline v8::Handle<v8::Value> toV8(TestObj* impl, v8::Isolate* isolate = 0)
 {
     if (!impl)
-        return v8::Null();
+        return v8Null(isolate);
     return V8TestObj::wrap(impl, isolate);
 }
 inline v8::Handle<v8::Value> toV8(PassRefPtr< TestObj > impl, v8::Isolate* isolate = 0)
index 452ba37..4dd4c3c 100644 (file)
@@ -50,7 +50,7 @@ static v8::Handle<v8::Value> valueAttrGetter(v8::Local<v8::String> name, const v
 {
     INC_STATS("DOM.TestSerializedScriptValueInterface.value._get");
     TestSerializedScriptValueInterface* imp = V8TestSerializedScriptValueInterface::toNative(info.Holder());
-    return imp->value() ? imp->value()->deserialize() : v8::Handle<v8::Value>(v8::Null());
+    return imp->value() ? imp->value()->deserialize() : v8::Handle<v8::Value>(v8::Null(info.GetIsolate()));
 }
 
 static void valueAttrSetter(v8::Local<v8::String> name, v8::Local<v8::Value> value, const v8::AccessorInfo& info)
@@ -66,7 +66,7 @@ static v8::Handle<v8::Value> readonlyValueAttrGetter(v8::Local<v8::String> name,
 {
     INC_STATS("DOM.TestSerializedScriptValueInterface.readonlyValue._get");
     TestSerializedScriptValueInterface* imp = V8TestSerializedScriptValueInterface::toNative(info.Holder());
-    return imp->readonlyValue() ? imp->readonlyValue()->deserialize() : v8::Handle<v8::Value>(v8::Null());
+    return imp->readonlyValue() ? imp->readonlyValue()->deserialize() : v8::Handle<v8::Value>(v8::Null(info.GetIsolate()));
 }
 
 static v8::Handle<v8::Value> cachedValueAttrGetter(v8::Local<v8::String> name, const v8::AccessorInfo& info)
index bd6d9e6..e175d14 100644 (file)
@@ -24,6 +24,7 @@
 #define V8TestSerializedScriptValueInterface_h
 
 #include "TestSerializedScriptValueInterface.h"
+#include "V8Binding.h"
 #include "V8DOMWrapper.h"
 #include "WrapperTypeInfo.h"
 #include <v8.h>
@@ -62,7 +63,7 @@ v8::Handle<v8::Object> V8TestSerializedScriptValueInterface::wrap(TestSerialized
 inline v8::Handle<v8::Value> toV8(TestSerializedScriptValueInterface* impl, v8::Isolate* isolate = 0)
 {
     if (!impl)
-        return v8::Null();
+        return v8Null(isolate);
     return V8TestSerializedScriptValueInterface::wrap(impl, isolate);
 }
 inline v8::Handle<v8::Value> toV8(PassRefPtr< TestSerializedScriptValueInterface > impl, v8::Isolate* isolate = 0)
index 3ee692d..14d6532 100644 (file)
@@ -247,6 +247,15 @@ namespace WebCore {
     template <typename StringType>
     StringType v8StringToWebCoreString(v8::Handle<v8::String> v8String, ExternalMode external);
 
+    // Since v8::Null(isolate) crashes if we pass a null isolate,
+    // we need to instead use v8Null(isolate).
+    //
+    // FIXME: Remove all null isolates from V8 bindings, and remove v8Null(isolate).
+    inline v8::Handle<v8::Value> v8Null(v8::Isolate* isolate)
+    {
+        return isolate ? v8::Null(isolate) : v8::Null();
+    }
+
     // Convert v8 types 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.
@@ -448,9 +457,9 @@ namespace WebCore {
         return (object->IsDate() || object->IsNumber()) ? object->NumberValue() : std::numeric_limits<double>::quiet_NaN();
     }
 
-    inline v8::Handle<v8::Value> v8DateOrNull(double value)
+    inline v8::Handle<v8::Value> v8DateOrNull(double value, v8::Isolate* isolate = 0)
     {
-        return isfinite(value) ? v8::Date::New(value) : v8::Handle<v8::Value>(v8::Null());
+        return isfinite(value) ? v8::Date::New(value) : v8Null(isolate);
     }
 
     v8::Persistent<v8::FunctionTemplate> createRawTemplate();
index 2c4b9ff..3bc0614 100644 (file)
 #include "V8Proxy.h"
 #include "V8StyleSheet.h"
 #include "V8WorkerContextEventListener.h"
+#include "V8XPathNSResolver.h"
 #include "WebGLContextAttributes.h"
 #include "WebGLUniformLocation.h"
 #include "WorkerContextExecutionProxy.h"
 #include "WrapperTypeInfo.h"
+#include "XPathNSResolver.h"
 #include <algorithm>
 #include <utility>
 #include <v8-debug.h>
index 7059f51..d0048c4 100644 (file)
 #include "PlatformString.h"
 #include "V8CustomXPathNSResolver.h"
 #include "V8DOMMap.h"
-#include "V8Event.h"
 #include "V8IsolatedContext.h"
 #include "V8Utilities.h"
-#include "V8XPathNSResolver.h"
 #include "WrapperTypeInfo.h"
-#include "XPathNSResolver.h"
 #include <v8.h>
 #include <wtf/MainThread.h>
 #include <wtf/PassRefPtr.h>
@@ -58,6 +55,7 @@ namespace WebCore {
     class V8BindingPerContextData;
     class V8Proxy;
     class WorkerContext;
+    class XPathResolver;
 
     enum ListenerLookupType {
         ListenerFindOnly,