Title: [101627] trunk/Source/WebCore
Revision
101627
Author
[email protected]
Date
2011-12-01 00:00:49 -0800 (Thu, 01 Dec 2011)

Log Message

[JSC] When XXXX has a NamedConstructor, window.XXXX should be XXXXConstructor
https://bugs.webkit.org/show_bug.cgi?id=73521

Reviewed by Adam Barth.

This is a regression caused by a patch of bug 73307.
If we replaced a custom constructor of window.XXXX (e.g. XXXX is Audio or Option)
with the [NamedConstructor] IDL, fast/js/global-constructors.html,
fast/dom/Window/window-properties.html and fast/dom/call-a-constructor-as-a-function.html
start to fail in JSC.

Before a patch of bug 73007: (correct behavior)
    window.Audio => AudioConstructor
    window.Option => OptionConstructor
    window.HTMLAudioElement => HTMLAudioElementConstructor
    window.HTMLOptionElement => HTMLOptionElementConstructor

After a patch of bug 73007: (wrong behavior)
    window.Audio => HTMLAudioElementConstructor
    window.Option => HTMLOptionElementConstructor
    window.HTMLAudioElement => HTMLAudioElementConstructor
    window.HTMLOptionElement => HTMLOptionElementConstructor

This patch fixes the above behavior.

Tests: bindings/scripts/test/TestNamedConstructor.idl

* bindings/scripts/CodeGeneratorJS.pm:
(GenerateImplementation):
* bindings/scripts/IDLParser.pm:
(parseExtendedAttributes):
(ParseInterface):
* bindings/scripts/test/TestNamedConstructor.idl: The test IDL was wrong. NamedConstructor=XXXX(arguments) is a correct format.
* bindings/scripts/test/JS/JSTestNamedConstructor.cpp: Updated a run-bindings-tests result.

Modified Paths

Diff

Modified: trunk/Source/WebCore/ChangeLog (101626 => 101627)


--- trunk/Source/WebCore/ChangeLog	2011-12-01 07:59:13 UTC (rev 101626)
+++ trunk/Source/WebCore/ChangeLog	2011-12-01 08:00:49 UTC (rev 101627)
@@ -1,3 +1,40 @@
+2011-12-01  Kentaro Hara  <[email protected]>
+
+        [JSC] When XXXX has a NamedConstructor, window.XXXX should be XXXXConstructor
+        https://bugs.webkit.org/show_bug.cgi?id=73521
+
+        Reviewed by Adam Barth.
+
+        This is a regression caused by a patch of bug 73307.
+        If we replaced a custom constructor of window.XXXX (e.g. XXXX is Audio or Option)
+        with the [NamedConstructor] IDL, fast/js/global-constructors.html,
+        fast/dom/Window/window-properties.html and fast/dom/call-a-constructor-as-a-function.html
+        start to fail in JSC.
+
+        Before a patch of bug 73007: (correct behavior)
+            window.Audio => AudioConstructor
+            window.Option => OptionConstructor
+            window.HTMLAudioElement => HTMLAudioElementConstructor
+            window.HTMLOptionElement => HTMLOptionElementConstructor
+
+        After a patch of bug 73007: (wrong behavior)
+            window.Audio => HTMLAudioElementConstructor
+            window.Option => HTMLOptionElementConstructor
+            window.HTMLAudioElement => HTMLAudioElementConstructor
+            window.HTMLOptionElement => HTMLOptionElementConstructor
+
+        This patch fixes the above behavior.
+
+        Tests: bindings/scripts/test/TestNamedConstructor.idl
+
+        * bindings/scripts/CodeGeneratorJS.pm:
+        (GenerateImplementation):
+        * bindings/scripts/IDLParser.pm:
+        (parseExtendedAttributes):
+        (ParseInterface):
+        * bindings/scripts/test/TestNamedConstructor.idl: The test IDL was wrong. NamedConstructor=XXXX(arguments) is a correct format.
+        * bindings/scripts/test/JS/JSTestNamedConstructor.cpp: Updated a run-bindings-tests result.
+
 2011-11-30  David Grogan  <[email protected]>
 
         Move data in IDBPendingTransactionMonitor from static to

Modified: trunk/Source/WebCore/bindings/scripts/CodeGeneratorJS.pm (101626 => 101627)


--- trunk/Source/WebCore/bindings/scripts/CodeGeneratorJS.pm	2011-12-01 07:59:13 UTC (rev 101626)
+++ trunk/Source/WebCore/bindings/scripts/CodeGeneratorJS.pm	2011-12-01 08:00:49 UTC (rev 101627)
@@ -1437,7 +1437,7 @@
         my $protoClassName = "${className}Prototype";
         GenerateConstructorDefinition(\@implContent, $className, $protoClassName, $interfaceName, $visibleClassName, $dataNode);
         if ($dataNode->extendedAttributes->{"NamedConstructor"}) {
-            GenerateConstructorDefinition(\@implContent, $className, $protoClassName, $interfaceName, $visibleClassName, $dataNode, "GeneratingNamedConstructor");
+            GenerateConstructorDefinition(\@implContent, $className, $protoClassName, $interfaceName, $dataNode->extendedAttributes->{"NamedConstructor"}, $dataNode, "GeneratingNamedConstructor");
         }
     }
 

Modified: trunk/Source/WebCore/bindings/scripts/IDLParser.pm (101626 => 101627)


--- trunk/Source/WebCore/bindings/scripts/IDLParser.pm	2011-12-01 07:59:13 UTC (rev 101626)
+++ trunk/Source/WebCore/bindings/scripts/IDLParser.pm	2011-12-01 08:00:49 UTC (rev 101627)
@@ -166,22 +166,26 @@
             $str =~ s/^\s*=//;
             if ($name eq "NamedConstructor") {
                 # Parse '=' name '(' arguments ')' ','?
+                my $constructorName;
                 if ($str =~ /^\s*([\w\d]+)/) {
-                    # For now ignore the name, since the name is managed by DOMWindow.idl.
+                    $constructorName = $1;
                     $str =~ s/^\s*([\w\d]+)//;
+                } else {
+                    die("Invalid extended attribute: '$str'\n");
                 }
                 if ($str =~ /^\s*\(/) {
                     # Parse '(' arguments ')' ','?
                     $str =~ s/^\s*\(//;
                     if ($str =~ /^([^)]*)\),?/) {
-                        $attrs{$name} = $1;
-                        $attrs{$name} =~ s/^(.*?)\s*$/$1/;
+                        my $signature = $1;
+                        $signature =~ s/^(.*?)\s*$/$1/;
+                        $attrs{$name} = {"ConstructorName" => $constructorName, "Signature" => $signature};
                         $str =~ s/^([^)]*)\),?//;
                     } else {
                         die("Invalid extended attribute: '$str'\n");
                     }
                 } elsif ($str =~ /^\s*,?/) {
-                    $attrs{$name} = "";
+                    $attrs{$name} = {"ConstructorName" => $constructorName, "Signature" => ""};
                     $str =~ s/^\s*,?//;
                 } else {
                     die("Invalid extended attribute: '$str'\n");
@@ -300,8 +304,8 @@
             $newDataNode->signature(new domSignature());
             $newDataNode->signature->name("NamedConstructor");
             $newDataNode->signature->extendedAttributes($extendedAttributes);
-            parseParameters($newDataNode, $extendedAttributes->{"NamedConstructor"});
-            $extendedAttributes->{"NamedConstructor"} = 1;
+            parseParameters($newDataNode, $extendedAttributes->{"NamedConstructor"}->{"Signature"});
+            $extendedAttributes->{"NamedConstructor"} = $extendedAttributes->{"NamedConstructor"}{"ConstructorName"};
             $dataNode->constructor($newDataNode);
         }
         $dataNode->extendedAttributes($extendedAttributes);

Modified: trunk/Source/WebCore/bindings/scripts/test/JS/JSTestNamedConstructor.cpp (101626 => 101627)


--- trunk/Source/WebCore/bindings/scripts/test/JS/JSTestNamedConstructor.cpp	2011-12-01 07:59:13 UTC (rev 101626)
+++ trunk/Source/WebCore/bindings/scripts/test/JS/JSTestNamedConstructor.cpp	2011-12-01 08:00:49 UTC (rev 101627)
@@ -96,7 +96,7 @@
     return getStaticValueDescriptor<JSTestNamedConstructorConstructor, JSDOMWrapper>(exec, &JSTestNamedConstructorConstructorTable, static_cast<JSTestNamedConstructorConstructor*>(object), propertyName, descriptor);
 }
 
-const ClassInfo JSTestNamedConstructorNamedConstructor::s_info = { "TestNamedConstructorConstructor", &DOMConstructorObject::s_info, 0, 0, CREATE_METHOD_TABLE(JSTestNamedConstructorNamedConstructor) };
+const ClassInfo JSTestNamedConstructorNamedConstructor::s_info = { "AudioConstructor", &DOMConstructorObject::s_info, 0, 0, CREATE_METHOD_TABLE(JSTestNamedConstructorNamedConstructor) };
 
 JSTestNamedConstructorNamedConstructor::JSTestNamedConstructorNamedConstructor(Structure* structure, JSDOMGlobalObject* globalObject)
     : DOMConstructorWithDocument(structure, globalObject)

Modified: trunk/Source/WebCore/bindings/scripts/test/TestNamedConstructor.idl (101626 => 101627)


--- trunk/Source/WebCore/bindings/scripts/test/TestNamedConstructor.idl	2011-12-01 07:59:13 UTC (rev 101626)
+++ trunk/Source/WebCore/bindings/scripts/test/TestNamedConstructor.idl	2011-12-01 08:00:49 UTC (rev 101627)
@@ -31,7 +31,7 @@
 module test {
     interface [
         ActiveDOMObject,
-        NamedConstructor(in DOMString str1, in [Optional=CallWithDefaultValue] DOMString str2, in [Optional=CallWithNullValue] DOMString str3),
+        NamedConstructor=Audio(in DOMString str1, in [Optional=CallWithDefaultValue] DOMString str2, in [Optional=CallWithNullValue] DOMString str3),
         ConstructorRaisesException
     ] TestNamedConstructor {
     };
_______________________________________________
webkit-changes mailing list
[email protected]
http://lists.webkit.org/mailman/listinfo.cgi/webkit-changes

Reply via email to