Diff
Modified: trunk/LayoutTests/ChangeLog (135345 => 135346)
--- trunk/LayoutTests/ChangeLog 2012-11-21 04:54:44 UTC (rev 135345)
+++ trunk/LayoutTests/ChangeLog 2012-11-21 05:02:55 UTC (rev 135346)
@@ -1,3 +1,14 @@
+2012-11-20 Kentaro Hara <hara...@chromium.org>
+
+ [V8] Introduce constructorCallbackCustom()
+ https://bugs.webkit.org/show_bug.cgi?id=102763
+
+ Reviewed by Adam Barth.
+
+ Updated a test result.
+
+ * platform/chromium/fast/dom/call-a-constructor-as-a-function-expected.txt:
+
2012-11-20 Adam Klein <ad...@chromium.org>
[JSC] MutationObserver wrapper should not be collected while still observing
Modified: trunk/LayoutTests/platform/chromium/fast/dom/call-a-constructor-as-a-function-expected.txt (135345 => 135346)
--- trunk/LayoutTests/platform/chromium/fast/dom/call-a-constructor-as-a-function-expected.txt 2012-11-21 04:54:44 UTC (rev 135345)
+++ trunk/LayoutTests/platform/chromium/fast/dom/call-a-constructor-as-a-function-expected.txt 2012-11-21 05:02:55 UTC (rev 135346)
@@ -6,7 +6,7 @@
PASS ArrayBuffer() threw exception TypeError: DOM object constructor cannot be called as a function..
SKIP AudioContext is not implemented.
PASS FormData() threw exception TypeError: DOM object constructor cannot be called as a function..
-PASS DataView() threw exception TypeError: DOM object constructor cannot be called as a function.
+PASS DataView() threw exception TypeError: DOM object constructor cannot be called as a function..
PASS EventSource() threw exception TypeError: DOM object constructor cannot be called as a function..
PASS FileReader() threw exception TypeError: DOM object constructor cannot be called as a function..
PASS Float32Array() threw exception TypeError: DOM object constructor cannot be called as a function..
Modified: trunk/Source/WebCore/ChangeLog (135345 => 135346)
--- trunk/Source/WebCore/ChangeLog 2012-11-21 04:54:44 UTC (rev 135345)
+++ trunk/Source/WebCore/ChangeLog 2012-11-21 05:02:55 UTC (rev 135346)
@@ -1,3 +1,76 @@
+2012-11-20 Kentaro Hara <hara...@chromium.org>
+
+ [V8] Introduce constructorCallbackCustom()
+ https://bugs.webkit.org/show_bug.cgi?id=102763
+
+ Reviewed by Adam Barth.
+
+ Currently custom constructors have the following code:
+
+ v8::Handle<v8::Value> V8XXX::constructorCallback(const v8::Arguments& args) {
+ INC_STATS("DOM.XXX.Constructor");
+ if (!args.IsConstructCall())
+ return throwTypeError("DOM object constructor cannot be called as a function.", args.GetIsolate());
+ if (ConstructorMode::current() == ConstructorMode::WrapExistingObject)
+ return args.Holder();
+
+ /* body of the constructor */;
+ }
+
+ To avoid duplicating the same logic in all custom constructors,
+ this patch changes the generated code as follows:
+
+ // Generated automatically
+ v8::Handle<v8::Value> V8XXX::constructorCallback(const v8::Arguments& args) {
+ INC_STATS("DOM.XXX.Constructor");
+ ${maybeObserveFeature} // Newly supported for custom constructors.
+ if (!args.IsConstructCall())
+ return throwTypeError("DOM object constructor cannot be called as a function.", args.GetIsolate());
+ if (ConstructorMode::current() == ConstructorMode::WrapExistingObject)
+ return args.Holder();
+
+ V8XXX::constructorCallbackCustom(args);
+ }
+
+ // Written manually
+ v8::Handle<v8::Value> V8XXX::constructorCallback(const v8::Arguments& args) {
+ /* body of the constructor */;
+ }
+
+ No tests. No change in behavior.
+
+ * bindings/scripts/CodeGeneratorV8.pm:
+ (GenerateHeader):
+ (HasCustomConstructor):
+ (GenerateCustomConstructorCallback):
+ (GenerateImplementation):
+ * bindings/scripts/test/V8/V8TestEventConstructor.cpp:
+ (WebCore::V8TestEventConstructor::constructorCallback):
+ * bindings/scripts/test/V8/V8TestNamedConstructor.cpp:
+ (WebCore::V8TestNamedConstructorConstructorCallback):
+ * bindings/scripts/test/V8/V8TestOverloadedConstructors.cpp:
+ (WebCore::V8TestOverloadedConstructors::constructorCallback):
+ * bindings/v8/custom/V8ArrayBufferCustom.cpp:
+ (WebCore::V8ArrayBuffer::constructorCallbackCustom):
+ * bindings/v8/custom/V8AudioContextCustom.cpp:
+ (WebCore::V8AudioContext::constructorCallbackCustom):
+ * bindings/v8/custom/V8BlobCustom.cpp:
+ (WebCore::V8Blob::constructorCallbackCustom):
+ * bindings/v8/custom/V8DOMFormDataCustom.cpp:
+ (WebCore::V8DOMFormData::constructorCallbackCustom):
+ * bindings/v8/custom/V8DataViewCustom.cpp:
+ (WebCore::V8DataView::constructorCallbackCustom):
+ * bindings/v8/custom/V8IntentConstructor.cpp:
+ (WebCore::V8Intent::constructorCallbackCustom):
+ * bindings/v8/custom/V8MessageChannelConstructor.cpp:
+ (WebCore::V8MessageChannel::constructorCallbackCustom):
+ * bindings/v8/custom/V8MutationObserverCustom.cpp:
+ (WebCore::V8MutationObserver::constructorCallbackCustom):
+ * bindings/v8/custom/V8WebKitPointConstructor.cpp:
+ (WebCore::V8WebKitPoint::constructorCallbackCustom):
+ * bindings/v8/custom/V8XMLHttpRequestConstructor.cpp:
+ (WebCore::V8XMLHttpRequest::constructorCallbackCustom):
+
2012-11-20 Kunihiko Sakamoto <ksakam...@chromium.org>
REGRESSION(r135263): Fix a wrong argument for udat_close
Modified: trunk/Source/WebCore/bindings/scripts/CodeGeneratorV8.pm (135345 => 135346)
--- trunk/Source/WebCore/bindings/scripts/CodeGeneratorV8.pm 2012-11-21 04:54:44 UTC (rev 135345)
+++ trunk/Source/WebCore/bindings/scripts/CodeGeneratorV8.pm 2012-11-21 05:02:55 UTC (rev 135346)
@@ -410,6 +410,11 @@
static v8::Handle<v8::Value> constructorCallback(const v8::Arguments&);
END
}
+ if (HasCustomConstructor($interface)) {
+ push(@headerContent, <<END);
+ static v8::Handle<v8::Value> constructorCallbackCustom(const v8::Arguments&);
+END
+ }
my @enabledPerContextAttributes;
foreach my $attribute (@{$interface->attributes}) {
@@ -755,6 +760,13 @@
return $interface->extendedAttributes->{"CustomConstructor"} || $interface->extendedAttributes->{"V8CustomConstructor"} || $interface->extendedAttributes->{"Constructor"} || $interface->extendedAttributes->{"ConstructorTemplate"};
}
+sub HasCustomConstructor
+{
+ my $interface = shift;
+
+ return $interface->extendedAttributes->{"CustomConstructor"} || $interface->extendedAttributes->{"V8CustomConstructor"};
+}
+
sub IsReadonly
{
my $attribute = shift;
@@ -1964,6 +1976,27 @@
push(@implContent, "\n");
}
+sub GenerateCustomConstructorCallback
+{
+ my $interface = shift;
+
+ my $interfaceName = $interface->name;
+ my $maybeObserveFeature = GenerateFeatureObservation($interface->extendedAttributes->{"V8MeasureAs"});
+ push(@implContent, <<END);
+v8::Handle<v8::Value> V8${interfaceName}::constructorCallback(const v8::Arguments& args)
+{
+ INC_STATS("DOM.${interfaceName}.Constructor");
+ ${maybeObserveFeature}
+END
+ push(@implContent, GenerateConstructorHeader());
+ push(@implContent, <<END);
+
+ return V8${interfaceName}::constructorCallbackCustom(args);
+}
+
+END
+}
+
sub GenerateConstructorCallback
{
my $interface = shift;
@@ -2846,9 +2879,11 @@
push(@implContentDecls, "} // namespace ${interfaceName}V8Internal\n\n");
- if ($interface->extendedAttributes->{"NamedConstructor"} && !($interface->extendedAttributes->{"V8CustomConstructor"} || $interface->extendedAttributes->{"CustomConstructor"})) {
+ if (HasCustomConstructor($interface)) {
+ GenerateCustomConstructorCallback($interface);
+ } elsif ($interface->extendedAttributes->{"NamedConstructor"}) {
GenerateNamedConstructorCallback(@{$interface->constructors}[0], $interface);
- } elsif ($interface->extendedAttributes->{"Constructor"} && !($interface->extendedAttributes->{"V8CustomConstructor"} || $interface->extendedAttributes->{"CustomConstructor"})) {
+ } elsif ($interface->extendedAttributes->{"Constructor"}) {
GenerateConstructorCallback($interface);
} elsif ($codeGenerator->IsConstructorTemplate($interface, "Event")) {
GenerateEventConstructorCallback($interface);
Modified: trunk/Source/WebCore/bindings/v8/custom/V8ArrayBufferCustom.cpp (135345 => 135346)
--- trunk/Source/WebCore/bindings/v8/custom/V8ArrayBufferCustom.cpp 2012-11-21 04:54:44 UTC (rev 135345)
+++ trunk/Source/WebCore/bindings/v8/custom/V8ArrayBufferCustom.cpp 2012-11-21 05:02:55 UTC (rev 135346)
@@ -47,16 +47,8 @@
}
-v8::Handle<v8::Value> V8ArrayBuffer::constructorCallback(const v8::Arguments& args)
+v8::Handle<v8::Value> V8ArrayBuffer::constructorCallbackCustom(const v8::Arguments& args)
{
- INC_STATS("DOM.ArrayBuffer.Constructor");
-
- if (!args.IsConstructCall())
- return throwTypeError("DOM object constructor cannot be called as a function.", args.GetIsolate());
-
- if (ConstructorMode::current() == ConstructorMode::WrapExistingObject)
- return args.Holder();
-
// If we return a previously constructed ArrayBuffer,
// e.g. from the call to ArrayBufferView.buffer, this code is called
// with a zero-length argument list. The V8DOMWrapper will then
Modified: trunk/Source/WebCore/bindings/v8/custom/V8AudioContextCustom.cpp (135345 => 135346)
--- trunk/Source/WebCore/bindings/v8/custom/V8AudioContextCustom.cpp 2012-11-21 04:54:44 UTC (rev 135345)
+++ trunk/Source/WebCore/bindings/v8/custom/V8AudioContextCustom.cpp 2012-11-21 05:02:55 UTC (rev 135346)
@@ -39,16 +39,8 @@
namespace WebCore {
-v8::Handle<v8::Value> V8AudioContext::constructorCallback(const v8::Arguments& args)
+v8::Handle<v8::Value> V8AudioContext::constructorCallbackCustom(const v8::Arguments& args)
{
- INC_STATS("DOM.AudioContext.Contructor");
-
- if (!args.IsConstructCall())
- return throwTypeError("AudioContext constructor cannot be called as a function.", args.GetIsolate());
-
- if (ConstructorMode::current() == ConstructorMode::WrapExistingObject)
- return args.Holder();
-
Document* document = currentDocument(BindingState::instance());
RefPtr<AudioContext> audioContext;
Modified: trunk/Source/WebCore/bindings/v8/custom/V8BlobCustom.cpp (135345 => 135346)
--- trunk/Source/WebCore/bindings/v8/custom/V8BlobCustom.cpp 2012-11-21 04:54:44 UTC (rev 135345)
+++ trunk/Source/WebCore/bindings/v8/custom/V8BlobCustom.cpp 2012-11-21 05:02:55 UTC (rev 135346)
@@ -51,16 +51,8 @@
return V8Blob::createWrapper(impl, creationContext, isolate);
}
-v8::Handle<v8::Value> V8Blob::constructorCallback(const v8::Arguments& args)
+v8::Handle<v8::Value> V8Blob::constructorCallbackCustom(const v8::Arguments& args)
{
- INC_STATS("DOM.Blob.Constructor");
-
- if (!args.IsConstructCall())
- return throwTypeError("DOM object constructor cannot be called as a function.", args.GetIsolate());
-
- if (ConstructorMode::current() == ConstructorMode::WrapExistingObject)
- return args.Holder();
-
ScriptExecutionContext* context = getScriptExecutionContext();
if (!args.Length()) {
Modified: trunk/Source/WebCore/bindings/v8/custom/V8DOMFormDataCustom.cpp (135345 => 135346)
--- trunk/Source/WebCore/bindings/v8/custom/V8DOMFormDataCustom.cpp 2012-11-21 04:54:44 UTC (rev 135345)
+++ trunk/Source/WebCore/bindings/v8/custom/V8DOMFormDataCustom.cpp 2012-11-21 05:02:55 UTC (rev 135346)
@@ -39,16 +39,8 @@
namespace WebCore {
-v8::Handle<v8::Value> V8DOMFormData::constructorCallback(const v8::Arguments& args)
+v8::Handle<v8::Value> V8DOMFormData::constructorCallbackCustom(const v8::Arguments& args)
{
- INC_STATS("DOM.FormData.Constructor");
-
- if (!args.IsConstructCall())
- return throwTypeError("DOM object constructor cannot be called as a function.", args.GetIsolate());
-
- if (ConstructorMode::current() == ConstructorMode::WrapExistingObject)
- return args.Holder();
-
HTMLFormElement* form = 0;
if (args.Length() > 0 && V8HTMLFormElement::HasInstance(args[0]))
form = V8HTMLFormElement::toNative(args[0]->ToObject());
Modified: trunk/Source/WebCore/bindings/v8/custom/V8DataViewCustom.cpp (135345 => 135346)
--- trunk/Source/WebCore/bindings/v8/custom/V8DataViewCustom.cpp 2012-11-21 04:54:44 UTC (rev 135345)
+++ trunk/Source/WebCore/bindings/v8/custom/V8DataViewCustom.cpp 2012-11-21 05:02:55 UTC (rev 135346)
@@ -32,16 +32,8 @@
namespace WebCore {
-v8::Handle<v8::Value> V8DataView::constructorCallback(const v8::Arguments& args)
+v8::Handle<v8::Value> V8DataView::constructorCallbackCustom(const v8::Arguments& args)
{
- INC_STATS("DOM.DataView.Constructor");
-
- if (!args.IsConstructCall())
- return throwTypeError("DOM object constructor cannot be called as a function", args.GetIsolate());
-
- if (ConstructorMode::current() == ConstructorMode::WrapExistingObject)
- return args.Holder();
-
if (!args.Length()) {
// see constructWebGLArray -- we don't seem to be able to distingish between
// 'new DataView()' and the call used to construct the cached DataView object.
Modified: trunk/Source/WebCore/bindings/v8/custom/V8IntentConstructor.cpp (135345 => 135346)
--- trunk/Source/WebCore/bindings/v8/custom/V8IntentConstructor.cpp 2012-11-21 04:54:44 UTC (rev 135345)
+++ trunk/Source/WebCore/bindings/v8/custom/V8IntentConstructor.cpp 2012-11-21 05:02:55 UTC (rev 135346)
@@ -41,15 +41,8 @@
namespace WebCore {
-v8::Handle<v8::Value> V8Intent::constructorCallback(const v8::Arguments& args)
+v8::Handle<v8::Value> V8Intent::constructorCallbackCustom(const v8::Arguments& args)
{
- INC_STATS("DOM.Intent.Constructor");
-
- if (!args.IsConstructCall())
- return throwTypeError("DOM object constructor cannot be called as a function.", args.GetIsolate());
-
- if (ConstructorMode::current() == ConstructorMode::WrapExistingObject)
- return args.Holder();
if (args.Length() < 1)
return throwNotEnoughArgumentsError(args.GetIsolate());
if (args.Length() == 1) {
Modified: trunk/Source/WebCore/bindings/v8/custom/V8MessageChannelConstructor.cpp (135345 => 135346)
--- trunk/Source/WebCore/bindings/v8/custom/V8MessageChannelConstructor.cpp 2012-11-21 04:54:44 UTC (rev 135345)
+++ trunk/Source/WebCore/bindings/v8/custom/V8MessageChannelConstructor.cpp 2012-11-21 05:02:55 UTC (rev 135346)
@@ -44,16 +44,8 @@
namespace WebCore {
-v8::Handle<v8::Value> V8MessageChannel::constructorCallback(const v8::Arguments& args)
+v8::Handle<v8::Value> V8MessageChannel::constructorCallbackCustom(const v8::Arguments& args)
{
- INC_STATS("DOM.MessageChannel.Constructor");
-
- if (!args.IsConstructCall())
- return throwTypeError("DOM object constructor cannot be called as a function.", args.GetIsolate());
-
- if (ConstructorMode::current() == ConstructorMode::WrapExistingObject)
- return args.Holder();
-
ScriptExecutionContext* context = getScriptExecutionContext();
RefPtr<MessageChannel> obj = MessageChannel::create(context);
Modified: trunk/Source/WebCore/bindings/v8/custom/V8MutationObserverCustom.cpp (135345 => 135346)
--- trunk/Source/WebCore/bindings/v8/custom/V8MutationObserverCustom.cpp 2012-11-21 04:54:44 UTC (rev 135345)
+++ trunk/Source/WebCore/bindings/v8/custom/V8MutationObserverCustom.cpp 2012-11-21 05:02:55 UTC (rev 135346)
@@ -43,16 +43,8 @@
namespace WebCore {
-v8::Handle<v8::Value> V8MutationObserver::constructorCallback(const v8::Arguments& args)
+v8::Handle<v8::Value> V8MutationObserver::constructorCallbackCustom(const v8::Arguments& args)
{
- INC_STATS("DOM.MutationObserver.Constructor");
-
- if (!args.IsConstructCall())
- return throwTypeError("DOM object constructor cannot be called as a function.", args.GetIsolate());
-
- if (ConstructorMode::current() == ConstructorMode::WrapExistingObject)
- return args.Holder();
-
if (args.Length() < 1)
return throwNotEnoughArgumentsError(args.GetIsolate());
Modified: trunk/Source/WebCore/bindings/v8/custom/V8WebKitPointConstructor.cpp (135345 => 135346)
--- trunk/Source/WebCore/bindings/v8/custom/V8WebKitPointConstructor.cpp 2012-11-21 04:54:44 UTC (rev 135345)
+++ trunk/Source/WebCore/bindings/v8/custom/V8WebKitPointConstructor.cpp 2012-11-21 05:02:55 UTC (rev 135346)
@@ -39,16 +39,8 @@
namespace WebCore {
-v8::Handle<v8::Value> V8WebKitPoint::constructorCallback(const v8::Arguments& args)
+v8::Handle<v8::Value> V8WebKitPoint::constructorCallbackCustom(const v8::Arguments& args)
{
- INC_STATS("DOM.WebKitPoint.Constructor");
-
- if (!args.IsConstructCall())
- return throwTypeError("DOM object constructor cannot be called as a function.", args.GetIsolate());
-
- if (ConstructorMode::current() == ConstructorMode::WrapExistingObject)
- return args.Holder();
-
float x = 0;
float y = 0;
if (args.Length() > 1) {
Modified: trunk/Source/WebCore/bindings/v8/custom/V8XMLHttpRequestConstructor.cpp (135345 => 135346)
--- trunk/Source/WebCore/bindings/v8/custom/V8XMLHttpRequestConstructor.cpp 2012-11-21 04:54:44 UTC (rev 135345)
+++ trunk/Source/WebCore/bindings/v8/custom/V8XMLHttpRequestConstructor.cpp 2012-11-21 05:02:55 UTC (rev 135346)
@@ -42,16 +42,8 @@
namespace WebCore {
-v8::Handle<v8::Value> V8XMLHttpRequest::constructorCallback(const v8::Arguments& args)
+v8::Handle<v8::Value> V8XMLHttpRequest::constructorCallbackCustom(const v8::Arguments& args)
{
- INC_STATS("DOM.XMLHttpRequest.Constructor");
-
- if (!args.IsConstructCall())
- return throwTypeError("DOM object constructor cannot be called as a function.", args.GetIsolate());
-
- if (ConstructorMode::current() == ConstructorMode::WrapExistingObject)
- return args.Holder();
-
ScriptExecutionContext* context = getScriptExecutionContext();
RefPtr<SecurityOrigin> securityOrigin;