Generate XMLHttpRequest constructor for JSC by [Constructor] IDL
authorharaken@chromium.org <haraken@chromium.org@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Mon, 17 Oct 2011 03:13:53 +0000 (03:13 +0000)
committerharaken@chromium.org <haraken@chromium.org@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Mon, 17 Oct 2011 03:13:53 +0000 (03:13 +0000)
https://bugs.webkit.org/show_bug.cgi?id=70208

Reviewed by Adam Barth.

This patch generates an XMLHttpRequest constructor for JSC by [Constructor] IDL,
but V8 is still using a custom constructor since the V8 constructor requires a special logic.

Tests: fast/dom/global-constructors.html
       fast/dom/XMLHttpRequest-constants.html
       fast/dom/xmlhttprequest-constructor-in-detached-document.html
       http/tests/security/cookies/xmlhttprequest.html

* bindings/js/JSXMLHttpRequestCustom.cpp: Removed an XMLHttpRequest custom constructor.
* bindings/scripts/CodeGeneratorV8.pm: Currently, CodeGeneratorV8.pm generates constructor code whenever [Constructor] is specified, even if [V8CustomConstructor] is specified. This is wrong. This patch fixes the condition where the constructor code is generated.
* bindings/scripts/test/V8/V8TestObj.cpp: Updated a run-binding-tests result.
* xml/XMLHttpRequest.h: Added a necessary header.
* xml/XMLHttpRequest.idl: V8 is still using a custom constructor.

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

Source/WebCore/ChangeLog
Source/WebCore/bindings/js/JSXMLHttpRequestCustom.cpp
Source/WebCore/bindings/scripts/CodeGeneratorV8.pm
Source/WebCore/bindings/scripts/test/V8/V8TestObj.cpp
Source/WebCore/xml/XMLHttpRequest.h
Source/WebCore/xml/XMLHttpRequest.idl

index affb152..5ca612f 100644 (file)
@@ -1,5 +1,26 @@
 2011-10-16  Kentaro Hara  <haraken@chromium.org>
 
+        Generate XMLHttpRequest constructor for JSC by [Constructor] IDL
+        https://bugs.webkit.org/show_bug.cgi?id=70208
+
+        Reviewed by Adam Barth.
+
+        This patch generates an XMLHttpRequest constructor for JSC by [Constructor] IDL,
+        but V8 is still using a custom constructor since the V8 constructor requires a special logic.
+
+        Tests: fast/dom/global-constructors.html
+               fast/dom/XMLHttpRequest-constants.html
+               fast/dom/xmlhttprequest-constructor-in-detached-document.html
+               http/tests/security/cookies/xmlhttprequest.html
+
+        * bindings/js/JSXMLHttpRequestCustom.cpp: Removed an XMLHttpRequest custom constructor.
+        * bindings/scripts/CodeGeneratorV8.pm: Currently, CodeGeneratorV8.pm generates constructor code whenever [Constructor] is specified, even if [V8CustomConstructor] is specified. This is wrong. This patch fixes the condition where the constructor code is generated.
+        * bindings/scripts/test/V8/V8TestObj.cpp: Updated a run-binding-tests result.
+        * xml/XMLHttpRequest.h: Added a necessary header.
+        * xml/XMLHttpRequest.idl: V8 is still using a custom constructor.
+
+2011-10-16  Kentaro Hara  <haraken@chromium.org>
+
         Generate XSLTProcessor constructor for JSC by [Constructor] IDL.
         https://bugs.webkit.org/show_bug.cgi?id=70206
 
index 62f6169..078b4b5 100644 (file)
@@ -203,15 +203,4 @@ JSValue JSXMLHttpRequest::response(ExecState* exec) const
     return jsUndefined();
 }
 
-EncodedJSValue JSC_HOST_CALL JSXMLHttpRequestConstructor::constructJSXMLHttpRequest(ExecState* exec)
-{
-    JSXMLHttpRequestConstructor* jsConstructor = static_cast<JSXMLHttpRequestConstructor*>(exec->callee());
-    ScriptExecutionContext* context = jsConstructor->scriptExecutionContext();
-    if (!context)
-        return throwVMError(exec, createReferenceError(exec, "XMLHttpRequest constructor associated document is unavailable"));
-
-    RefPtr<XMLHttpRequest> xmlHttpRequest = XMLHttpRequest::create(context);
-    return JSValue::encode(CREATE_DOM_WRAPPER(exec, jsConstructor->globalObject(), XMLHttpRequest, xmlHttpRequest.get()));
-}
-
 } // namespace WebCore
index 71ace6f..030ce55 100644 (file)
@@ -2153,9 +2153,7 @@ v8::Handle<v8::Value> ${className}::constructorCallback(const v8::Arguments& arg
 }
 
 END
-    }
-
-    if ($dataNode->extendedAttributes->{"Constructor"}) {
+    } elsif ($dataNode->extendedAttributes->{"CanBeConstructed"} && !($dataNode->extendedAttributes->{"V8CustomConstructor"} || $dataNode->extendedAttributes->{"CustomConstructor"})) {
         GenerateConstructorCallback($dataNode->constructor, $dataNode, $interfaceName);
     }
 
index b442a1e..0a8db34 100644 (file)
@@ -1386,24 +1386,6 @@ COMPILE_ASSERT(0x01 == TestObj::CONST_VALUE_12, TestObjEnumCONST_VALUE_12IsWrong
 COMPILE_ASSERT(0X20 == TestObj::CONST_VALUE_13, TestObjEnumCONST_VALUE_13IsWrongUseDontCheckEnums);
 COMPILE_ASSERT(0x1abc == TestObj::CONST_VALUE_14, TestObjEnumCONST_VALUE_14IsWrongUseDontCheckEnums);
 
-v8::Handle<v8::Value> V8TestObj::constructorCallback(const v8::Arguments& args)
-{
-    INC_STATS("DOM.TestObj.Constructor");
-
-    if (!args.IsConstructCall())
-        return throwError("DOM object constructor cannot be called as a function.", V8Proxy::TypeError);
-
-    if (AllowAllocation::current())
-        return args.Holder();
-
-    RefPtr<TestObj> obj = TestObj::create();
-
-    V8DOMWrapper::setDOMWrapper(args.Holder(), &info, obj.get());
-    obj->ref();
-    V8DOMWrapper::setJSWrapperForDOMObject(obj.get(), v8::Persistent<v8::Object>::New(args.Holder()));
-    return args.Holder();
-}
-
 static v8::Persistent<v8::FunctionTemplate> ConfigureV8TestObjTemplate(v8::Persistent<v8::FunctionTemplate> desc)
 {
     desc->ReadOnlyPrototype();
index ae50b48..ca76353 100644 (file)
@@ -27,6 +27,7 @@
 #include "EventTarget.h"
 #include "FormData.h"
 #include "ResourceResponse.h"
+#include "SecurityOrigin.h"
 #include "ThreadableLoaderClient.h"
 #include "XMLHttpRequestProgressEventThrottle.h"
 #include <wtf/OwnPtr.h>
index d4d06c8..54fdf61 100644 (file)
@@ -31,7 +31,9 @@ module xml {
     interface [
         ActiveDOMObject,
         CanBeConstructed,
-        CustomConstructor,
+        Constructor,
+        CallWith=ScriptExecutionContext,
+        V8CustomConstructor,
         CustomMarkFunction,
         EventTarget,
         NoStaticTables