• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /*
2  *  Copyright (C) 2004, 2007, 2008 Apple Inc. All rights reserved.
3  *  Copyright (C) 2005, 2006 Alexey Proskuryakov <ap@nypop.com>
4  *
5  *  This library is free software; you can redistribute it and/or
6  *  modify it under the terms of the GNU Lesser General Public
7  *  License as published by the Free Software Foundation; either
8  *  version 2 of the License, or (at your option) any later version.
9  *
10  *  This library is distributed in the hope that it will be useful,
11  *  but WITHOUT ANY WARRANTY; without even the implied warranty of
12  *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
13  *  Lesser General Public License for more details.
14  *
15  *  You should have received a copy of the GNU Lesser General Public
16  *  License along with this library; if not, write to the Free Software
17  *  Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301  USA
18  */
19 
20 #include "config.h"
21 #include "JSXMLHttpRequestConstructor.h"
22 
23 #include "JSXMLHttpRequest.h"
24 #include "ScriptExecutionContext.h"
25 #include "XMLHttpRequest.h"
26 
27 using namespace JSC;
28 
29 namespace WebCore {
30 
31 ASSERT_CLASS_FITS_IN_CELL(JSXMLHttpRequestConstructor);
32 
33 const ClassInfo JSXMLHttpRequestConstructor::s_info = { "XMLHttpRequestConstructor", 0, 0, 0 };
34 
JSXMLHttpRequestConstructor(ExecState * exec,JSDOMGlobalObject * globalObject)35 JSXMLHttpRequestConstructor::JSXMLHttpRequestConstructor(ExecState* exec, JSDOMGlobalObject* globalObject)
36     : DOMConstructorObject(JSXMLHttpRequestConstructor::createStructure(globalObject->objectPrototype()), globalObject)
37 {
38     putDirect(exec->propertyNames().prototype, JSXMLHttpRequestPrototype::self(exec, globalObject), None);
39 }
40 
constructXMLHttpRequest(ExecState * exec,JSObject * constructor,const ArgList &)41 static JSObject* constructXMLHttpRequest(ExecState* exec, JSObject* constructor, const ArgList&)
42 {
43     JSXMLHttpRequestConstructor* jsConstructor = static_cast<JSXMLHttpRequestConstructor*>(constructor);
44     ScriptExecutionContext* context = jsConstructor->scriptExecutionContext();
45     if (!context)
46         return throwError(exec, ReferenceError, "XMLHttpRequest constructor associated document is unavailable");
47 
48     RefPtr<XMLHttpRequest> xmlHttpRequest = XMLHttpRequest::create(context);
49     return CREATE_DOM_OBJECT_WRAPPER(exec, jsConstructor->globalObject(), XMLHttpRequest, xmlHttpRequest.get());
50 }
51 
getConstructData(ConstructData & constructData)52 ConstructType JSXMLHttpRequestConstructor::getConstructData(ConstructData& constructData)
53 {
54     constructData.native.function = constructXMLHttpRequest;
55     return ConstructTypeHost;
56 }
57 
58 } // namespace WebCore
59