Title: [113442] trunk/Source/WebCore
Revision
113442
Author
[email protected]
Date
2012-04-06 08:45:48 -0700 (Fri, 06 Apr 2012)

Log Message

Add CodeGenerator support for sequence<> in callbacks.
https://bugs.webkit.org/show_bug.cgi?id=83233

Patch by Vineet Chaudhary <[email protected]> on 2012-04-06
Reviewed by Kentaro Hara.

Tests: TestCallback.idl and fast/mutation/callback-arguments.html should pass even after
the changes.

* GNUmakefile.list.am: Removed unsued custom files V8MutationCallbackCustom.cpp
  and JSMutationCallbackCustom.cpp from builds.
* Target.pri: Ditto.
* UseJSC.cmake: Ditto.
* UseV8.cmake: Ditto.
* WebCore.gypi: Ditto.
* WebCore.vcproj/WebCore.vcproj: Ditto.
* WebCore.xcodeproj/project.pbxproj: Ditto.
* bindings/js/JSMutationCallbackCustom.cpp: Removed.
* bindings/scripts/CodeGeneratorJS.pm:
(AddIncludesForTypeInImpl): Add proper header type.
(GenerateCallbackHeader): Generate declaration for the callback with sequence<T> argument.
(GenerateCallbackImplementation): Generate implementation for the callback with sequence<T> argument.
* bindings/scripts/CodeGeneratorV8.pm:
(GenerateCallbackHeader): Generate declaration for the callback with sequence<T> argument.
(GenerateCallbackImplementation): Generate implementation for the callback with sequence<T> argument.
* bindings/scripts/test/JS/JSTestCallback.cpp: Modified test results of run-bindings-tests.
(WebCore):
(WebCore::JSTestCallback::handleEvent):
* bindings/scripts/test/JS/JSTestCallback.h: Modified test results of run-bindings-tests.
(JSTestCallback):
* bindings/scripts/test/TestCallback.idl: Added test callback with sequence<> argument.
* bindings/scripts/test/V8/V8TestCallback.cpp: Modified test results of run-bindings-tests.
(WebCore):
(WebCore::V8TestCallback::handleEvent):
* bindings/scripts/test/V8/V8TestCallback.h: Modified test results of run-bindings-tests.
(V8TestCallback):
* bindings/v8/custom/V8MutationCallbackCustom.cpp: Removed.
* dom/MutationCallback.idl: Removed custom bindings using sequence<T>.

Modified Paths

Removed Paths

Diff

Modified: trunk/Source/WebCore/ChangeLog (113441 => 113442)


--- trunk/Source/WebCore/ChangeLog	2012-04-06 15:33:56 UTC (rev 113441)
+++ trunk/Source/WebCore/ChangeLog	2012-04-06 15:45:48 UTC (rev 113442)
@@ -1,3 +1,43 @@
+2012-04-06  Vineet Chaudhary  <[email protected]>
+
+        Add CodeGenerator support for sequence<> in callbacks.
+        https://bugs.webkit.org/show_bug.cgi?id=83233
+
+        Reviewed by Kentaro Hara.
+
+        Tests: TestCallback.idl and fast/mutation/callback-arguments.html should pass even after
+        the changes.
+
+        * GNUmakefile.list.am: Removed unsued custom files V8MutationCallbackCustom.cpp 
+          and JSMutationCallbackCustom.cpp from builds.
+        * Target.pri: Ditto.
+        * UseJSC.cmake: Ditto.
+        * UseV8.cmake: Ditto.
+        * WebCore.gypi: Ditto.
+        * WebCore.vcproj/WebCore.vcproj: Ditto.
+        * WebCore.xcodeproj/project.pbxproj: Ditto.
+        * bindings/js/JSMutationCallbackCustom.cpp: Removed.
+        * bindings/scripts/CodeGeneratorJS.pm:
+        (AddIncludesForTypeInImpl): Add proper header type.
+        (GenerateCallbackHeader): Generate declaration for the callback with sequence<T> argument.
+        (GenerateCallbackImplementation): Generate implementation for the callback with sequence<T> argument.
+        * bindings/scripts/CodeGeneratorV8.pm:
+        (GenerateCallbackHeader): Generate declaration for the callback with sequence<T> argument.
+        (GenerateCallbackImplementation): Generate implementation for the callback with sequence<T> argument.
+        * bindings/scripts/test/JS/JSTestCallback.cpp: Modified test results of run-bindings-tests.
+        (WebCore):
+        (WebCore::JSTestCallback::handleEvent):
+        * bindings/scripts/test/JS/JSTestCallback.h: Modified test results of run-bindings-tests.
+        (JSTestCallback):
+        * bindings/scripts/test/TestCallback.idl: Added test callback with sequence<> argument.
+        * bindings/scripts/test/V8/V8TestCallback.cpp: Modified test results of run-bindings-tests.
+        (WebCore):
+        (WebCore::V8TestCallback::handleEvent):
+        * bindings/scripts/test/V8/V8TestCallback.h: Modified test results of run-bindings-tests.
+        (V8TestCallback):
+        * bindings/v8/custom/V8MutationCallbackCustom.cpp: Removed.
+        * dom/MutationCallback.idl: Removed custom bindings using sequence<T>.
+
 2012-04-06  Sheriff Bot  <[email protected]>
 
         Unreviewed, rolling out r113431.

Modified: trunk/Source/WebCore/GNUmakefile.list.am (113441 => 113442)


--- trunk/Source/WebCore/GNUmakefile.list.am	2012-04-06 15:33:56 UTC (rev 113441)
+++ trunk/Source/WebCore/GNUmakefile.list.am	2012-04-06 15:45:48 UTC (rev 113442)
@@ -1413,7 +1413,6 @@
 	Source/WebCore/bindings/js/JSMessageEventCustom.cpp \
 	Source/WebCore/bindings/js/JSMessagePortCustom.cpp \
 	Source/WebCore/bindings/js/JSMessagePortCustom.h \
-	Source/WebCore/bindings/js/JSMutationCallbackCustom.cpp \
 	Source/WebCore/bindings/js/JSNamedNodeMapCustom.cpp \
 	Source/WebCore/bindings/js/JSNodeCustom.cpp \
 	Source/WebCore/bindings/js/JSNodeCustom.h \

Modified: trunk/Source/WebCore/Target.pri (113441 => 113442)


--- trunk/Source/WebCore/Target.pri	2012-04-06 15:33:56 UTC (rev 113441)
+++ trunk/Source/WebCore/Target.pri	2012-04-06 15:45:48 UTC (rev 113442)
@@ -205,7 +205,6 @@
         bindings/v8/custom/V8MessageChannelConstructor.cpp \
         bindings/v8/custom/V8MessagePortCustom.cpp \
         bindings/v8/custom/V8MessageEventCustom.cpp \
-        bindings/v8/custom/V8MutationCallbackCustom.cpp \
         bindings/v8/custom/V8NamedNodeMapCustom.cpp \
         bindings/v8/custom/V8NamedNodesCollection.cpp \
         bindings/v8/custom/V8NodeCustom.cpp \
@@ -333,7 +332,6 @@
         bindings/js/JSMessageEventCustom.cpp \
         bindings/js/JSMessagePortCustom.cpp \
         bindings/js/JSMessagePortCustom.h \
-        bindings/js/JSMutationCallbackCustom.cpp \
         bindings/js/JSNamedNodeMapCustom.cpp \
         bindings/js/JSNodeCustom.cpp \
         bindings/js/JSNodeFilterCondition.cpp \

Modified: trunk/Source/WebCore/UseJSC.cmake (113441 => 113442)


--- trunk/Source/WebCore/UseJSC.cmake	2012-04-06 15:33:56 UTC (rev 113441)
+++ trunk/Source/WebCore/UseJSC.cmake	2012-04-06 15:45:48 UTC (rev 113442)
@@ -112,7 +112,6 @@
     bindings/js/JSMessageChannelCustom.cpp
     bindings/js/JSMessageEventCustom.cpp
     bindings/js/JSMessagePortCustom.cpp
-    bindings/js/JSMutationCallbackCustom.cpp
     bindings/js/JSNamedNodeMapCustom.cpp
     bindings/js/JSNodeCustom.cpp
     bindings/js/JSNodeFilterCondition.cpp

Modified: trunk/Source/WebCore/UseV8.cmake (113441 => 113442)


--- trunk/Source/WebCore/UseV8.cmake	2012-04-06 15:33:56 UTC (rev 113441)
+++ trunk/Source/WebCore/UseV8.cmake	2012-04-06 15:45:48 UTC (rev 113442)
@@ -132,7 +132,6 @@
     bindings/v8/custom/V8MessageChannelConstructor.cpp
     bindings/v8/custom/V8MessageEventCustom.cpp
     bindings/v8/custom/V8MessagePortCustom.cpp
-    bindings/v8/custom/V8MutationCallbackCustom.cpp
     bindings/v8/custom/V8NamedNodeMapCustom.cpp
     bindings/v8/custom/V8NamedNodesCollection.cpp
     bindings/v8/custom/V8NodeCustom.cpp

Modified: trunk/Source/WebCore/WebCore.gypi (113441 => 113442)


--- trunk/Source/WebCore/WebCore.gypi	2012-04-06 15:33:56 UTC (rev 113441)
+++ trunk/Source/WebCore/WebCore.gypi	2012-04-06 15:45:48 UTC (rev 113442)
@@ -1954,7 +1954,6 @@
             'bindings/js/JSMessageEventCustom.cpp',
             'bindings/js/JSMessagePortCustom.cpp',
             'bindings/js/JSMessagePortCustom.h',
-            'bindings/js/JSMutationCallbackCustom.cpp',
             'bindings/js/JSNamedNodeMapCustom.cpp',
             'bindings/js/JSNodeCustom.cpp',
             'bindings/js/JSNodeFilterCondition.cpp',
@@ -2265,7 +2264,6 @@
             'bindings/v8/custom/V8MessageChannelConstructor.cpp',
             'bindings/v8/custom/V8MessageEventCustom.cpp',
             'bindings/v8/custom/V8MessagePortCustom.cpp',
-            'bindings/v8/custom/V8MutationCallbackCustom.cpp',
             'bindings/v8/custom/V8NamedNodeMapCustom.cpp',
             'bindings/v8/custom/V8NamedNodesCollection.cpp',
             'bindings/v8/custom/V8NamedNodesCollection.h',

Modified: trunk/Source/WebCore/WebCore.vcproj/WebCore.vcproj (113441 => 113442)


--- trunk/Source/WebCore/WebCore.vcproj/WebCore.vcproj	2012-04-06 15:33:56 UTC (rev 113441)
+++ trunk/Source/WebCore/WebCore.vcproj/WebCore.vcproj	2012-04-06 15:45:48 UTC (rev 113442)
@@ -67173,58 +67173,6 @@
 					>
 				</File>
 				<File
-					RelativePath="..\bindings\js\JSMutationCallbackCustom.cpp"
-					>
-					<FileConfiguration
-						Name="Debug|Win32"
-						ExcludedFromBuild="true"
-						>
-						<Tool
-							Name="VCCLCompilerTool"
-						/>
-					</FileConfiguration>
-					<FileConfiguration
-						Name="Release|Win32"
-						ExcludedFromBuild="true"
-						>
-						<Tool
-							Name="VCCLCompilerTool"
-						/>
-					</FileConfiguration>
-					<FileConfiguration
-						Name="Debug_Cairo_CFLite|Win32"
-						ExcludedFromBuild="true"
-						>
-						<Tool
-							Name="VCCLCompilerTool"
-						/>
-					</FileConfiguration>
-					<FileConfiguration
-						Name="Release_Cairo_CFLite|Win32"
-						ExcludedFromBuild="true"
-						>
-						<Tool
-							Name="VCCLCompilerTool"
-						/>
-					</FileConfiguration>
-					<FileConfiguration
-						Name="Debug_All|Win32"
-						ExcludedFromBuild="true"
-						>
-						<Tool
-							Name="VCCLCompilerTool"
-						/>
-					</FileConfiguration>
-					<FileConfiguration
-						Name="Production|Win32"
-						ExcludedFromBuild="true"
-						>
-						<Tool
-							Name="VCCLCompilerTool"
-						/>
-					</FileConfiguration>
-				</File>
-				<File
 					RelativePath="..\bindings\js\JSNamedNodeMapCustom.cpp"
 					>
 					<FileConfiguration

Modified: trunk/Source/WebCore/WebCore.xcodeproj/project.pbxproj (113441 => 113442)


--- trunk/Source/WebCore/WebCore.xcodeproj/project.pbxproj	2012-04-06 15:33:56 UTC (rev 113441)
+++ trunk/Source/WebCore/WebCore.xcodeproj/project.pbxproj	2012-04-06 15:45:48 UTC (rev 113442)
@@ -5703,7 +5703,6 @@
 		C6F0902C14327D4F00685849 /* JSWebKitMutationObserver.cpp in Sources */ = {isa = PBXBuildFile; fileRef = C6F0902414327D4F00685849 /* JSWebKitMutationObserver.cpp */; };
 		C6F0902D14327D4F00685849 /* JSWebKitMutationObserver.h in Headers */ = {isa = PBXBuildFile; fileRef = C6F0902514327D4F00685849 /* JSWebKitMutationObserver.h */; };
 		C6F0917F143A2BB900685849 /* JSWebKitMutationObserverCustom.cpp in Sources */ = {isa = PBXBuildFile; fileRef = C6F0917E143A2BB900685849 /* JSWebKitMutationObserverCustom.cpp */; };
-		C6F09185143A6C3B00685849 /* JSMutationCallbackCustom.cpp in Sources */ = {isa = PBXBuildFile; fileRef = C6F09184143A6C3B00685849 /* JSMutationCallbackCustom.cpp */; };
 		C6F41047130C6E8900393DE4 /* EntryBase.cpp in Sources */ = {isa = PBXBuildFile; fileRef = C6F41046130C6E8900393DE4 /* EntryBase.cpp */; };
 		CA3BF67C10D99BAE00E6CE53 /* ScrollAnimator.cpp in Sources */ = {isa = PBXBuildFile; fileRef = CA3BF67B10D99BAE00E6CE53 /* ScrollAnimator.cpp */; };
 		CA3BF67E10D99BAE00E6CE53 /* ScrollAnimator.h in Headers */ = {isa = PBXBuildFile; fileRef = CA3BF67D10D99BAE00E6CE53 /* ScrollAnimator.h */; settings = {ATTRIBUTES = (Private, ); }; };
@@ -12797,7 +12796,6 @@
 		C6F0902414327D4F00685849 /* JSWebKitMutationObserver.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = JSWebKitMutationObserver.cpp; sourceTree = "<group>"; };
 		C6F0902514327D4F00685849 /* JSWebKitMutationObserver.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = JSWebKitMutationObserver.h; sourceTree = "<group>"; };
 		C6F0917E143A2BB900685849 /* JSWebKitMutationObserverCustom.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = JSWebKitMutationObserverCustom.cpp; sourceTree = "<group>"; };
-		C6F09184143A6C3B00685849 /* JSMutationCallbackCustom.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = JSMutationCallbackCustom.cpp; sourceTree = "<group>"; };
 		C6F41046130C6E8900393DE4 /* EntryBase.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; name = EntryBase.cpp; path = Modules/filesystem/EntryBase.cpp; sourceTree = "<group>"; };
 		CA3BF67B10D99BAE00E6CE53 /* ScrollAnimator.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = ScrollAnimator.cpp; sourceTree = "<group>"; };
 		CA3BF67D10D99BAE00E6CE53 /* ScrollAnimator.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = ScrollAnimator.h; sourceTree = "<group>"; };
@@ -19784,7 +19782,6 @@
 				410B7E711045FAB000D8224F /* JSMessageEventCustom.cpp */,
 				E1ADED460E76B8DD004A1A5E /* JSMessagePortCustom.cpp */,
 				41F584C6104652CB009CAA64 /* JSMessagePortCustom.h */,
-				C6F09184143A6C3B00685849 /* JSMutationCallbackCustom.cpp */,
 				BCD9C25F0C17AA67005C90A2 /* JSNamedNodeMapCustom.cpp */,
 				BCD9C2600C17AA67005C90A2 /* JSNodeCustom.cpp */,
 				BC9439C2116CF4940048C750 /* JSNodeCustom.h */,
@@ -26470,7 +26467,6 @@
 				898785B8122CA2A7003AABDA /* JSMetadataCallback.cpp in Sources */,
 				A86629D209DA2B48009633A5 /* JSMouseEvent.cpp in Sources */,
 				C6F0902814327D4F00685849 /* JSMutationCallback.cpp in Sources */,
-				C6F09185143A6C3B00685849 /* JSMutationCallbackCustom.cpp in Sources */,
 				65DF31FB09D1CC60000BE325 /* JSMutationEvent.cpp in Sources */,
 				C6F08FC91431000D00685849 /* JSMutationRecord.cpp in Sources */,
 				BCD9C2C00C17B69E005C90A2 /* JSNamedNodeMap.cpp in Sources */,

Deleted: trunk/Source/WebCore/bindings/js/JSMutationCallbackCustom.cpp (113441 => 113442)


--- trunk/Source/WebCore/bindings/js/JSMutationCallbackCustom.cpp	2012-04-06 15:33:56 UTC (rev 113441)
+++ trunk/Source/WebCore/bindings/js/JSMutationCallbackCustom.cpp	2012-04-06 15:45:48 UTC (rev 113442)
@@ -1,74 +0,0 @@
-/*
- * Copyright (C) 2011 Google Inc. All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions are
- * met:
- *
- *     * 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"
-
-#if ENABLE(MUTATION_OBSERVERS)
-
-#include "JSMutationCallback.h"
-
-#include "JSMutationRecord.h"
-#include "JSWebKitMutationObserver.h"
-#include "ScriptExecutionContext.h"
-#include <runtime/JSLock.h>
-
-using namespace JSC;
-
-namespace WebCore {
-
-bool JSMutationCallback::handleEvent(MutationRecordArray* mutations, WebKitMutationObserver* observer)
-{
-    if (!canInvokeCallback())
-        return true;
-
-    RefPtr<JSMutationCallback> protect(this);
-
-    JSLock lock(SilenceAssertionsOnly);
-
-    ExecState* exec = m_data->globalObject()->globalExec();
-
-    MarkedArgumentBuffer mutationList;
-    for (size_t i = 0; i < mutations->size(); ++i)
-        mutationList.append(toJS(exec, m_data->globalObject(), mutations->at(i).get()));
-
-    JSValue jsObserver = toJS(exec, m_data->globalObject(), observer);
-
-    MarkedArgumentBuffer args;
-    args.append(constructArray(exec, m_data->globalObject(), mutationList));
-    args.append(jsObserver);
-
-    bool raisedException = false;
-    m_data->invokeCallback(jsObserver, args, &raisedException);
-    return !raisedException;
-}
-
-} // namespace WebCore
-
-#endif // ENABLE(MUTATION_OBSERVERS)

Modified: trunk/Source/WebCore/bindings/scripts/CodeGenerator.pm (113441 => 113442)


--- trunk/Source/WebCore/bindings/scripts/CodeGenerator.pm	2012-04-06 15:33:56 UTC (rev 113441)
+++ trunk/Source/WebCore/bindings/scripts/CodeGenerator.pm	2012-04-06 15:45:48 UTC (rev 113442)
@@ -454,6 +454,17 @@
     return "";
 }
 
+sub IsCallbackWithArrayType
+{
+    my ($generator, $dataNode, @mparams) = @_;
+    if ($dataNode->extendedAttributes->{"Callback"}) {
+        foreach my $param (@mparams) {
+            return 1 if $generator->GetArrayType($param->type);
+        }
+    }
+    return 0;
+}
+
 # Uppercase the first letter while respecting WebKit style guidelines.
 # E.g., xmlEncoding becomes XMLEncoding, but xmlllang becomes Xmllang.
 sub WK_ucfirst

Modified: trunk/Source/WebCore/bindings/scripts/CodeGeneratorJS.pm (113441 => 113442)


--- trunk/Source/WebCore/bindings/scripts/CodeGeneratorJS.pm	2012-04-06 15:33:56 UTC (rev 113441)
+++ trunk/Source/WebCore/bindings/scripts/CodeGeneratorJS.pm	2012-04-06 15:45:48 UTC (rev 113442)
@@ -209,9 +209,9 @@
 {
     my $type = $codeGenerator->StripModule(shift);
     my $isCallback = @_ ? shift : 0;
-    
+
     AddIncludesForType($type, $isCallback, \%implIncludes);
-    
+
     # additional includes (things needed to compile the bindings but not the header)
     if ($type eq "CanvasRenderingContext2D") {
         $implIncludes{"CanvasGradient.h"} = 1;
@@ -2607,7 +2607,12 @@
 
             my @args = ();
             foreach my $param (@params) {
-                push(@args, GetNativeType($param->type) . " " . $param->name);
+                my $arrayType = $codeGenerator->GetArrayType($param->type);
+                if ($arrayType) {
+                    push(@args, GetNativeType("${arrayType}Array") . " " . $param->name);
+                } else {
+                    push(@args, GetNativeType($param->type) . " " . $param->name);
+                }
             }
             push(@headerContent, join(", ", @args));
 
@@ -2682,17 +2687,32 @@
             }
 
             AddIncludesForTypeInImpl($function->signature->type);
-            push(@implContent, "\n" . GetNativeType($function->signature->type) . " ${className}::" . $function->signature->name . "(");
 
             my @args = ();
+            my @argsCheck;
             foreach my $param (@params) {
-                AddIncludesForTypeInImpl($param->type, 1);
-                push(@args, GetNativeType($param->type) . " " . $param->name);
+                my $arrayType = $codeGenerator->GetArrayType($param->type);
+                if ($arrayType) {
+                    my $paramName = $param->name;
+                    push(@implContent, "typedef Vector<RefPtr<${arrayType}> > ${arrayType}Array;\n");
+                    AddIncludesForTypeInImpl($arrayType, 1);
+                    push(@args, GetNativeType("${arrayType}Array") . " " . $paramName);
+                    push(@argsCheck, <<END);
+    ASSERT(${paramName});
+    if (!${paramName})
+        return true;
+END
+                } else {
+                    AddIncludesForTypeInImpl($param->type, 1);
+                    push(@args, GetNativeType($param->type) . " " . $param->name);
+                }
             }
+            push(@implContent, "\n" . GetNativeType($function->signature->type) . " ${className}::" . $function->signature->name . "(");
             push(@implContent, join(", ", @args));
             push(@implContent, ")\n");
 
             push(@implContent, "{\n");
+            push(@implContent, "@argsCheck\n") if @argsCheck;
             push(@implContent, "    if (!canInvokeCallback())\n");
             push(@implContent, "        return true;\n\n");
             push(@implContent, "    RefPtr<$className> protect(this);\n\n");
@@ -2706,13 +2726,29 @@
                     push(@implContent, "    args.append(jsString(exec, ${paramName}));\n");
                 } elsif ($param->type eq "boolean") {
                     push(@implContent, "    args.append(jsBoolean(${paramName}));\n");
+                } elsif ($codeGenerator->GetArrayType($param->type)) {
+                    push(@implContent, <<END);
+    MarkedArgumentBuffer list;
+    for (size_t i = 0; i < ${paramName}->size(); ++i)
+        list.append(toJS(exec, m_data->globalObject(), ${paramName}->at(i).get()));
+
+    args.append(constructArray(exec, m_data->globalObject(), list));
+END
                 } else {
                     push(@implContent, "    args.append(toJS(exec, m_data->globalObject(), ${paramName}));\n");
                 }
             }
 
             push(@implContent, "\n    bool raisedException = false;\n");
-            push(@implContent, "    m_data->invokeCallback(args, &raisedException);\n");
+            if ($codeGenerator->IsCallbackWithArrayType($dataNode, @params)) {
+                push(@implContent, <<END);
+    JSValue jsObserver = toJS(exec, m_data->globalObject(), observer);
+    m_data->invokeCallback(jsObserver, args, &raisedException);
+
+END
+            } else {
+                    push(@implContent, "    m_data->invokeCallback(args, &raisedException);\n");
+            }
             push(@implContent, "    return !raisedException;\n");
             push(@implContent, "}\n");
         }

Modified: trunk/Source/WebCore/bindings/scripts/CodeGeneratorV8.pm (113441 => 113442)


--- trunk/Source/WebCore/bindings/scripts/CodeGeneratorV8.pm	2012-04-06 15:33:56 UTC (rev 113441)
+++ trunk/Source/WebCore/bindings/scripts/CodeGeneratorV8.pm	2012-04-06 15:45:48 UTC (rev 113442)
@@ -2967,7 +2967,12 @@
 
             my @args = ();
             foreach my $param (@params) {
-                push(@args, GetNativeTypeForCallbacks($param->type) . " " . $param->name);
+                my $arrayType = $codeGenerator->GetArrayType($param->type);
+                if ($arrayType) {
+                    push(@args, GetNativeTypeForCallbacks("${arrayType}Array") . " " . $param->name);
+                } else {
+                    push(@args, GetNativeTypeForCallbacks($param->type) . " " . $param->name);
+                }
             }
             push(@headerContent, join(", ", @args));
             push(@headerContent, ");\n");
@@ -3035,18 +3040,33 @@
                 next;
             }
 
-            AddIncludesForType($function->signature->type);
-            push(@implContent, "\n" . GetNativeTypeForCallbacks($function->signature->type) . " ${className}::" . $function->signature->name . "(");
+            AddIncludesForType($function->signature->type); 
 
             my @args = ();
+            my @argsCheck;
             foreach my $param (@params) {
-                AddIncludesForType($param->type);
-                push(@args, GetNativeTypeForCallbacks($param->type) . " " . $param->name);
+                my $arrayType = $codeGenerator->GetArrayType($param->type);
+                if ($arrayType) {
+                    AddIncludesForType($arrayType);
+                    my $paramName = $param->name;
+                    push(@implContent, "typedef Vector<RefPtr<${arrayType}> > ${arrayType}Array;\n");
+                    push(@args, GetNativeTypeForCallbacks("${arrayType}Array") . " " . $paramName);
+                    push(@argsCheck, <<END);
+    ASSERT(${paramName});
+    if (!${paramName})
+        return true;
+END
+                } else {
+                    AddIncludesForType($param->type);
+                    push(@args, GetNativeTypeForCallbacks($param->type) . " " . $param->name);
+                }
             }
+            push(@implContent, "\n" . GetNativeTypeForCallbacks($function->signature->type) . " ${className}::" . $function->signature->name . "(");
             push(@implContent, join(", ", @args));
 
             push(@implContent, ")\n");
             push(@implContent, "{\n");
+            push(@implContent, "@argsCheck\n") if @argsCheck;
             push(@implContent, "    if (!canInvokeCallback())\n");
             push(@implContent, "        return true;\n\n");
             push(@implContent, "    v8::HandleScope handleScope;\n\n");
@@ -3058,6 +3078,17 @@
             @args = ();
             foreach my $param (@params) {
                 my $paramName = $param->name;
+                my @GenerateEventListenerImpl = ();
+                if ($codeGenerator->GetArrayType($param->type)) {
+                    push(@implContent, <<END);
+    v8::Local<v8::Array> ${paramName}Array = v8::Array::New(${paramName}->size());
+    for (size_t i = 0; i < ${paramName}->size(); ++i)
+        ${paramName}Array->Set(v8::Uint32::New(i), toV8(${paramName}->at(i).get()));
+
+END
+                    push(@args, "        ${paramName}Array");
+                    next;
+                }
                 push(@implContent, "    v8::Handle<v8::Value> ${paramName}Handle = " . NativeToJSValue($param, $paramName) . ";\n");
                 push(@implContent, "    if (${paramName}Handle.IsEmpty()) {\n");
                 push(@implContent, "        if (!isScriptControllerTerminating())\n");
@@ -3075,7 +3106,11 @@
                 push(@implContent, "\n    v8::Handle<v8::Value> *argv = 0;\n\n");
             }
             push(@implContent, "    bool callbackReturnValue = false;\n");
-            push(@implContent, "    return !invokeCallback(m_callback, " . scalar(@params) . ", argv, callbackReturnValue, scriptExecutionContext());\n");
+            if ($codeGenerator->IsCallbackWithArrayType($dataNode, @params)) {
+                push(@implContent, "    return !invokeCallback(m_callback, v8::Handle<v8::Object>::Cast(observerHandle), " . scalar(@params) . ", argv, callbackReturnValue, scriptExecutionContext());\n");
+            } else {
+                push(@implContent, "    return !invokeCallback(m_callback, " . scalar(@params) . ", argv, callbackReturnValue, scriptExecutionContext());\n");
+            }
             push(@implContent, "}\n");
         }
     }

Modified: trunk/Source/WebCore/bindings/scripts/test/JS/JSTestCallback.cpp (113441 => 113442)


--- trunk/Source/WebCore/bindings/scripts/test/JS/JSTestCallback.cpp	2012-04-06 15:33:56 UTC (rev 113441)
+++ trunk/Source/WebCore/bindings/scripts/test/JS/JSTestCallback.cpp	2012-04-06 15:45:48 UTC (rev 113442)
@@ -27,6 +27,8 @@
 #include "JSClass1.h"
 #include "JSClass2.h"
 #include "JSDOMStringList.h"
+#include "JSMutationRecord.h"
+#include "JSWebKitMutationObserver.h"
 #include "ScriptExecutionContext.h"
 #include <runtime/JSLock.h>
 
@@ -145,7 +147,37 @@
     m_data->invokeCallback(args, &raisedException);
     return !raisedException;
 }
+typedef Vector<RefPtr<MutationRecord> > MutationRecordArray;
 
+bool JSTestCallback::handleEvent(MutationRecordArray* mutations, WebKitMutationObserver* observer)
+{
+    ASSERT(mutations);
+    if (!mutations)
+        return true;
+
+    if (!canInvokeCallback())
+        return true;
+
+    RefPtr<JSTestCallback> protect(this);
+
+    JSLock lock(SilenceAssertionsOnly);
+
+    ExecState* exec = m_data->globalObject()->globalExec();
+    MarkedArgumentBuffer args;
+    MarkedArgumentBuffer list;
+    for (size_t i = 0; i < mutations->size(); ++i)
+        list.append(toJS(exec, m_data->globalObject(), mutations->at(i).get()));
+
+    args.append(constructArray(exec, m_data->globalObject(), list));
+    args.append(toJS(exec, m_data->globalObject(), observer));
+
+    bool raisedException = false;
+    JSValue jsObserver = toJS(exec, m_data->globalObject(), observer);
+    m_data->invokeCallback(jsObserver, args, &raisedException);
+
+    return !raisedException;
 }
 
+}
+
 #endif // ENABLE(SQL_DATABASE)

Modified: trunk/Source/WebCore/bindings/scripts/test/JS/JSTestCallback.h (113441 => 113442)


--- trunk/Source/WebCore/bindings/scripts/test/JS/JSTestCallback.h	2012-04-06 15:33:56 UTC (rev 113441)
+++ trunk/Source/WebCore/bindings/scripts/test/JS/JSTestCallback.h	2012-04-06 15:45:48 UTC (rev 113442)
@@ -47,6 +47,7 @@
     virtual int customCallback(Class5* class5Param, Class6* class6Param);
     virtual bool callbackWithStringList(DOMStringList* listParam);
     virtual bool callbackWithBoolean(bool boolParam);
+    virtual bool handleEvent(MutationRecordArray* mutations, WebKitMutationObserver* observer);
 
 private:
     JSTestCallback(JSC::JSObject* callback, JSDOMGlobalObject*);

Modified: trunk/Source/WebCore/bindings/scripts/test/TestCallback.idl (113441 => 113442)


--- trunk/Source/WebCore/bindings/scripts/test/TestCallback.idl	2012-04-06 15:33:56 UTC (rev 113441)
+++ trunk/Source/WebCore/bindings/scripts/test/TestCallback.idl	2012-04-06 15:45:48 UTC (rev 113442)
@@ -40,5 +40,6 @@
       [Custom] long customCallback(in Class5 class5Param, in Class6 class6Param);
       boolean callbackWithStringList(in DOMStringList listParam);
       boolean callbackWithBoolean(in boolean boolParam);
+      boolean handleEvent(in sequence<MutationRecord> mutations, in WebKitMutationObserver observer);
     };
 }

Modified: trunk/Source/WebCore/bindings/scripts/test/V8/V8TestCallback.cpp (113441 => 113442)


--- trunk/Source/WebCore/bindings/scripts/test/V8/V8TestCallback.cpp	2012-04-06 15:33:56 UTC (rev 113441)
+++ trunk/Source/WebCore/bindings/scripts/test/V8/V8TestCallback.cpp	2012-04-06 15:45:48 UTC (rev 113442)
@@ -29,7 +29,9 @@
 #include "V8Class2.h"
 #include "V8CustomVoidCallback.h"
 #include "V8DOMStringList.h"
+#include "V8MutationRecord.h"
 #include "V8Proxy.h"
+#include "V8WebKitMutationObserver.h"
 #include <wtf/GetPtr.h>
 #include <wtf/RefCounted.h>
 #include <wtf/RefPtr.h>
@@ -190,7 +192,45 @@
     bool callbackReturnValue = false;
     return !invokeCallback(m_callback, 1, argv, callbackReturnValue, scriptExecutionContext());
 }
+typedef Vector<RefPtr<MutationRecord> > MutationRecordArray;
 
+bool V8TestCallback::handleEvent(MutationRecordArray* mutations, WebKitMutationObserver* observer)
+{
+    ASSERT(mutations);
+    if (!mutations)
+        return true;
+
+    if (!canInvokeCallback())
+        return true;
+
+    v8::HandleScope handleScope;
+
+    v8::Handle<v8::Context> v8Context = toV8Context(scriptExecutionContext(), m_worldContext);
+    if (v8Context.IsEmpty())
+        return true;
+
+    v8::Context::Scope scope(v8Context);
+
+    v8::Local<v8::Array> mutationsArray = v8::Array::New(mutations->size());
+    for (size_t i = 0; i < mutations->size(); ++i)
+        mutationsArray->Set(v8::Uint32::New(i), toV8(mutations->at(i).get()));
+
+    v8::Handle<v8::Value> observerHandle = toV8(observer);
+    if (observerHandle.IsEmpty()) {
+        if (!isScriptControllerTerminating())
+            CRASH();
+        return true;
+    }
+
+    v8::Handle<v8::Value> argv[] = {
+        mutationsArray,
+        observerHandle
+    };
+
+    bool callbackReturnValue = false;
+    return !invokeCallback(m_callback, v8::Handle<v8::Object>::Cast(observerHandle), 2, argv, callbackReturnValue, scriptExecutionContext());
+}
+
 } // namespace WebCore
 
 #endif // ENABLE(SQL_DATABASE)

Modified: trunk/Source/WebCore/bindings/scripts/test/V8/V8TestCallback.h (113441 => 113442)


--- trunk/Source/WebCore/bindings/scripts/test/V8/V8TestCallback.h	2012-04-06 15:33:56 UTC (rev 113441)
+++ trunk/Source/WebCore/bindings/scripts/test/V8/V8TestCallback.h	2012-04-06 15:45:48 UTC (rev 113442)
@@ -52,6 +52,7 @@
     virtual int customCallback(Class5* class5Param, Class6* class6Param);
     virtual bool callbackWithStringList(RefPtr<DOMStringList> listParam);
     virtual bool callbackWithBoolean(bool boolParam);
+    virtual bool handleEvent(MutationRecordArray* mutations, WebKitMutationObserver* observer);
 
 private:
     V8TestCallback(v8::Local<v8::Object>, ScriptExecutionContext*);

Deleted: trunk/Source/WebCore/bindings/v8/custom/V8MutationCallbackCustom.cpp (113441 => 113442)


--- trunk/Source/WebCore/bindings/v8/custom/V8MutationCallbackCustom.cpp	2012-04-06 15:33:56 UTC (rev 113441)
+++ trunk/Source/WebCore/bindings/v8/custom/V8MutationCallbackCustom.cpp	2012-04-06 15:45:48 UTC (rev 113442)
@@ -1,92 +0,0 @@
-/*
- * Copyright (C) 2010, 2012 Google Inc. All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions are
- * met:
- *
- *     * Redistributions of source code must retain the above copyright
- * notice, this list of conditions and the following disclaimer.
- *     * Redistributions in binary form must reproduce the above
- * copyright notice, this list of conditions and the following disclaimer
- * in the documentation and/or other materials provided with the
- * distribution.
- *     * Neither the name of Google Inc. nor the names of its
- * contributors may be used to endorse or promote products derived from
- * this software without specific prior written permission.
- *
- * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
- * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
- * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
- * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
- * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
- * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
- * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
- * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
- * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
- * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
- * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
- */
-
-#include "config.h"
-
-#if ENABLE(MUTATION_OBSERVERS)
-
-#include "V8MutationCallback.h"
-
-#include "ScriptExecutionContext.h"
-#include "V8Binding.h"
-#include "V8CustomVoidCallback.h"
-#include "V8MutationRecord.h"
-#include "V8Proxy.h"
-#include "V8WebKitMutationObserver.h"
-#include <wtf/Assertions.h>
-#include <wtf/GetPtr.h>
-#include <wtf/RefCounted.h>
-#include <wtf/RefPtr.h>
-
-namespace WebCore {
-
-bool V8MutationCallback::handleEvent(MutationRecordArray* mutations, WebKitMutationObserver* observer)
-{
-    ASSERT(mutations);
-    if (!mutations)
-        return true;
-
-    if (!canInvokeCallback())
-        return true;
-
-    v8::HandleScope handleScope;
-
-    v8::Handle<v8::Context> v8Context = toV8Context(scriptExecutionContext(), m_worldContext);
-    if (v8Context.IsEmpty())
-        return true;
-
-    v8::Context::Scope scope(v8Context);
-
-    v8::Local<v8::Array> mutationsArray = v8::Array::New(mutations->size());
-    for (size_t i = 0; i < mutations->size(); ++i)
-        mutationsArray->Set(v8::Integer::New(i), toV8(mutations->at(i).get()));
-
-    v8::Handle<v8::Value> observerHandle = toV8(observer);
-    if (observerHandle.IsEmpty()) {
-        if (!isScriptControllerTerminating())
-            CRASH();
-        return true;
-    }
-
-    if (!observerHandle->IsObject())
-        return true;
-
-    v8::Handle<v8::Value> argv[] = {
-        mutationsArray,
-        observerHandle
-    };
-
-    bool callbackReturnValue = false;
-    return !invokeCallback(m_callback, v8::Handle<v8::Object>::Cast(observerHandle), 2, argv, callbackReturnValue, scriptExecutionContext());
-}
-
-} // namespace WebCore
-
-#endif // ENABLE(MUTATION_OBSERVERS)

Modified: trunk/Source/WebCore/dom/MutationCallback.idl (113441 => 113442)


--- trunk/Source/WebCore/dom/MutationCallback.idl	2012-04-06 15:33:56 UTC (rev 113441)
+++ trunk/Source/WebCore/dom/MutationCallback.idl	2012-04-06 15:45:48 UTC (rev 113442)
@@ -33,6 +33,6 @@
         Conditional=MUTATION_OBSERVERS,
         Callback
     ] MutationCallback {
-        [Custom] boolean handleEvent(in MutationRecordArray mutations, in WebKitMutationObserver observer);
+        boolean handleEvent(in sequence<MutationRecord> mutations, in WebKitMutationObserver observer);
     };
 }
_______________________________________________
webkit-changes mailing list
[email protected]
http://lists.webkit.org/mailman/listinfo.cgi/webkit-changes

Reply via email to