Title: [150283] trunk/Source/WebCore
Revision
150283
Author
ch.du...@sisa.samsung.com
Date
2013-05-17 12:17:06 -0700 (Fri, 17 May 2013)

Log Message

Get rid of [CustomGetter] for global named constructors
https://bugs.webkit.org/show_bug.cgi?id=116116

Reviewed by Geoffrey Garen.

Improve the JSC bindings generator so that global named constructors no longer
require a [CustomGetter] IDL extended attribute. As a consequence, attributes
on the global window object can now be automatically generated for interfaces
that have a [NamedConstructor], namely HTMLOptionElement.

The HTMLAudioElement global constructors are still manually defined because it
requires custom code at the moment to check if the media player is available.

No new tests, no behavior change.

* bindings/js/JSDOMWindowCustom.cpp:
* bindings/scripts/CodeGeneratorJS.pm:
* bindings/scripts/preprocess-idls.pl:
* bindings/scripts/test/JS/JSTestNamedConstructor.cpp:
* bindings/scripts/test/JS/JSTestNamedConstructor.h:
* html/HTMLOptionElement.idl:
* page/DOMWindow.idl:

Modified Paths

Diff

Modified: trunk/Source/WebCore/ChangeLog (150282 => 150283)


--- trunk/Source/WebCore/ChangeLog	2013-05-17 19:15:45 UTC (rev 150282)
+++ trunk/Source/WebCore/ChangeLog	2013-05-17 19:17:06 UTC (rev 150283)
@@ -1,3 +1,28 @@
+2013-05-17  Christophe Dumez  <ch.du...@sisa.samsung.com>
+
+        Get rid of [CustomGetter] for global named constructors
+        https://bugs.webkit.org/show_bug.cgi?id=116116
+
+        Reviewed by Geoffrey Garen.
+
+        Improve the JSC bindings generator so that global named constructors no longer
+        require a [CustomGetter] IDL extended attribute. As a consequence, attributes
+        on the global window object can now be automatically generated for interfaces
+        that have a [NamedConstructor], namely HTMLOptionElement.
+
+        The HTMLAudioElement global constructors are still manually defined because it
+        requires custom code at the moment to check if the media player is available.
+
+        No new tests, no behavior change.
+
+        * bindings/js/JSDOMWindowCustom.cpp:
+        * bindings/scripts/CodeGeneratorJS.pm:
+        * bindings/scripts/preprocess-idls.pl:
+        * bindings/scripts/test/JS/JSTestNamedConstructor.cpp:
+        * bindings/scripts/test/JS/JSTestNamedConstructor.h:
+        * html/HTMLOptionElement.idl:
+        * page/DOMWindow.idl:
+
 2013-05-17  Joseph Pecoraro  <pecor...@apple.com>
 
         Web Inspector: SyntaxError evaluating "1+1; //@ sourceURL=test" in console

Modified: trunk/Source/WebCore/bindings/js/JSDOMWindowCustom.cpp (150282 => 150283)


--- trunk/Source/WebCore/bindings/js/JSDOMWindowCustom.cpp	2013-05-17 19:15:45 UTC (rev 150282)
+++ trunk/Source/WebCore/bindings/js/JSDOMWindowCustom.cpp	2013-05-17 19:17:06 UTC (rev 150283)
@@ -533,11 +533,6 @@
     return getDOMConstructor<JSImageConstructor>(exec, this);
 }
 
-JSValue JSDOMWindow::option(ExecState* exec) const
-{
-    return getDOMConstructor<JSHTMLOptionElementNamedConstructor>(exec, this);
-}
-
 #if ENABLE(VIDEO)
 JSValue JSDOMWindow::audio(ExecState* exec) const
 {

Modified: trunk/Source/WebCore/bindings/scripts/CodeGeneratorJS.pm (150282 => 150283)


--- trunk/Source/WebCore/bindings/scripts/CodeGeneratorJS.pm	2013-05-17 19:15:45 UTC (rev 150282)
+++ trunk/Source/WebCore/bindings/scripts/CodeGeneratorJS.pm	2013-05-17 19:17:06 UTC (rev 150283)
@@ -851,7 +851,10 @@
     }
 
     # Constructor object getter
-    push(@headerContent, "    static JSC::JSValue getConstructor(JSC::ExecState*, JSC::JSGlobalObject*);\n") if !$interface->extendedAttributes->{"OmitConstructor"};
+    unless ($interface->extendedAttributes->{"OmitConstructor"}) {
+        push(@headerContent, "    static JSC::JSValue getConstructor(JSC::ExecState*, JSC::JSGlobalObject*);\n");
+        push(@headerContent, "    static JSC::JSValue getNamedConstructor(JSC::ExecState*, JSC::JSGlobalObject*);\n") if $interface->extendedAttributes->{"NamedConstructor"};
+    }
 
     my $numCustomFunctions = 0;
     my $numCustomAttributes = 0;
@@ -2031,7 +2034,9 @@
                     # When Constructor attribute is used by DOMWindow.idl, it's correct to pass castedThis as the global object
                     # When JSDOMWrappers have a back-pointer to the globalObject we can pass castedThis->globalObject()
                     if ($interfaceName eq "DOMWindow") {
-                        push(@implContent, "    return JS" . $constructorType . "::getConstructor(exec, castedThis);\n");
+                        my $named = ($constructorType =~ /Named$/) ? "Named" : "";
+                        $constructorType =~ s/Named$//;
+                        push(@implContent, "    return JS" . $constructorType . "::get${named}Constructor(exec, castedThis);\n");
                     } else {
                        AddToImplIncludes("JS" . $constructorType . ".h", $attribute->signature->extendedAttributes->{"Conditional"});
                        push(@implContent, "    return JS" . $constructorType . "::getConstructor(exec, castedThis->globalObject());\n");
@@ -2257,7 +2262,7 @@
                                 # $constructorType ~= /Constructor$/ indicates that it is NamedConstructor.
                                 # We do not generate the header file for NamedConstructor of class XXXX,
                                 # since we generate the NamedConstructor declaration into the header file of class XXXX.
-                                if ($constructorType ne "any" and $constructorType !~ /Constructor$/) {
+                                if ($constructorType ne "any" and $constructorType !~ /Named$/) {
                                     AddToImplIncludes("JS" . $constructorType . ".h", $attribute->signature->extendedAttributes->{"Conditional"});
                                 }
                                 push(@implContent, "    // Shadowing a built-in constructor\n");
@@ -2406,6 +2411,11 @@
         push(@implContent, "JSValue ${className}::getConstructor(ExecState* exec, JSGlobalObject* globalObject)\n{\n");
         push(@implContent, "    return getDOMConstructor<${className}Constructor>(exec, jsCast<JSDOMGlobalObject*>(globalObject));\n");
         push(@implContent, "}\n\n");
+        if ($interface->extendedAttributes->{"NamedConstructor"}) {
+            push(@implContent, "JSValue ${className}::getNamedConstructor(ExecState* exec, JSGlobalObject* globalObject)\n{\n");
+            push(@implContent, "    return getDOMConstructor<${className}NamedConstructor>(exec, jsCast<JSDOMGlobalObject*>(globalObject));\n");
+            push(@implContent, "}\n\n");
+        }
     }
 
     # Functions

Modified: trunk/Source/WebCore/bindings/scripts/preprocess-idls.pl (150282 => 150283)


--- trunk/Source/WebCore/bindings/scripts/preprocess-idls.pl	2013-05-17 19:15:45 UTC (rev 150282)
+++ trunk/Source/WebCore/bindings/scripts/preprocess-idls.pl	2013-05-17 19:17:06 UTC (rev 150283)
@@ -158,7 +158,7 @@
         $constructorName =~ s/\(.*//g; # Extract function name.
         $code .= "    ";
         $code .= "[" . join(', ', @extendedAttributesList) . "] " if @extendedAttributesList;
-        $code .= "attribute " . $originalInterfaceName . "ConstructorConstructor $constructorName;\n";
+        $code .= "attribute " . $originalInterfaceName . "NamedConstructor $constructorName;\n";
     }
     return $code;
 }

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


--- trunk/Source/WebCore/bindings/scripts/test/JS/JSTestNamedConstructor.cpp	2013-05-17 19:15:45 UTC (rev 150282)
+++ trunk/Source/WebCore/bindings/scripts/test/JS/JSTestNamedConstructor.cpp	2013-05-17 19:17:06 UTC (rev 150283)
@@ -187,6 +187,11 @@
     return getDOMConstructor<JSTestNamedConstructorConstructor>(exec, jsCast<JSDOMGlobalObject*>(globalObject));
 }
 
+JSValue JSTestNamedConstructor::getNamedConstructor(ExecState* exec, JSGlobalObject* globalObject)
+{
+    return getDOMConstructor<JSTestNamedConstructorNamedConstructor>(exec, jsCast<JSDOMGlobalObject*>(globalObject));
+}
+
 static inline bool isObservable(JSTestNamedConstructor* jsTestNamedConstructor)
 {
     if (jsTestNamedConstructor->hasCustomProperties())

Modified: trunk/Source/WebCore/bindings/scripts/test/JS/JSTestNamedConstructor.h (150282 => 150283)


--- trunk/Source/WebCore/bindings/scripts/test/JS/JSTestNamedConstructor.h	2013-05-17 19:15:45 UTC (rev 150282)
+++ trunk/Source/WebCore/bindings/scripts/test/JS/JSTestNamedConstructor.h	2013-05-17 19:17:06 UTC (rev 150283)
@@ -52,6 +52,7 @@
     }
 
     static JSC::JSValue getConstructor(JSC::ExecState*, JSC::JSGlobalObject*);
+    static JSC::JSValue getNamedConstructor(JSC::ExecState*, JSC::JSGlobalObject*);
     TestNamedConstructor* impl() const { return m_impl; }
     void releaseImpl() { m_impl->deref(); m_impl = 0; }
 

Modified: trunk/Source/WebCore/html/HTMLOptionElement.idl (150282 => 150283)


--- trunk/Source/WebCore/html/HTMLOptionElement.idl	2013-05-17 19:15:45 UTC (rev 150282)
+++ trunk/Source/WebCore/html/HTMLOptionElement.idl	2013-05-17 19:17:06 UTC (rev 150283)
@@ -19,7 +19,6 @@
  */
 
 [
-    NoInterfaceObject,
     JSGenerateToNativeObject,
     NamedConstructor=Option([Default=NullString] optional DOMString data, [Default=NullString] optional DOMString value, [Default=Undefined] optional boolean defaultSelected, [Default=Undefined] optional boolean selected),
     ConstructorRaisesException

Modified: trunk/Source/WebCore/page/DOMWindow.idl (150282 => 150283)


--- trunk/Source/WebCore/page/DOMWindow.idl	2013-05-17 19:15:45 UTC (rev 150282)
+++ trunk/Source/WebCore/page/DOMWindow.idl	2013-05-17 19:17:06 UTC (rev 150283)
@@ -321,10 +321,8 @@
 
 #if defined(LANGUAGE_JAVASCRIPT) && LANGUAGE_JAVASCRIPT
     // Additional constructors.
-    [CustomGetter, CustomConstructor] attribute HTMLImageElementConstructorConstructor Image; // Usable with new operator
-    [CustomGetter] attribute HTMLOptionElementConstructorConstructor Option; // Usable with new operator
-    attribute HTMLOptionElementConstructor HTMLOptionElement;
-    [CustomGetter, Conditional=VIDEO] attribute HTMLAudioElementConstructorConstructor Audio; // Usable with the new operator
+    [CustomGetter, CustomConstructor] attribute HTMLImageElementNamedConstructor Image; // Usable with new operator
+    [CustomGetter, Conditional=VIDEO] attribute HTMLAudioElementNamedConstructor Audio; // Usable with the new operator
     [Conditional=VIDEO] attribute HTMLAudioElementConstructor HTMLAudioElement;
     // Mozilla has a separate XMLDocument object for XML documents.
     // We just use Document for this.
_______________________________________________
webkit-changes mailing list
webkit-changes@lists.webkit.org
https://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to