diff options
Diffstat (limited to 'WebCore/bindings/v8/custom/V8XMLHttpRequestCustom.cpp')
-rw-r--r-- | WebCore/bindings/v8/custom/V8XMLHttpRequestCustom.cpp | 54 |
1 files changed, 28 insertions, 26 deletions
diff --git a/WebCore/bindings/v8/custom/V8XMLHttpRequestCustom.cpp b/WebCore/bindings/v8/custom/V8XMLHttpRequestCustom.cpp index c3e4645..d7cdcd1 100644 --- a/WebCore/bindings/v8/custom/V8XMLHttpRequestCustom.cpp +++ b/WebCore/bindings/v8/custom/V8XMLHttpRequestCustom.cpp @@ -29,32 +29,33 @@ */ #include "config.h" -#include "XMLHttpRequest.h" +#include "V8XMLHttpRequest.h" #include "Frame.h" #include "V8Binding.h" +#include "V8Blob.h" #include "V8CustomBinding.h" #include "V8Document.h" -#include "V8File.h" #include "V8HTMLDocument.h" #include "V8Proxy.h" #include "V8Utilities.h" #include "WorkerContext.h" #include "WorkerContextExecutionProxy.h" +#include "XMLHttpRequest.h" namespace WebCore { -ACCESSOR_GETTER(XMLHttpRequestResponseText) +v8::Handle<v8::Value> V8XMLHttpRequest::responseTextAccessorGetter(v8::Local<v8::String> name, const v8::AccessorInfo& info) { INC_STATS("DOM.XMLHttpRequest.responsetext._get"); - XMLHttpRequest* xmlHttpRequest = V8DOMWrapper::convertToNativeObject<XMLHttpRequest>(V8ClassIndex::XMLHTTPREQUEST, info.Holder()); + XMLHttpRequest* xmlHttpRequest = V8XMLHttpRequest::toNative(info.Holder()); return xmlHttpRequest->responseText().v8StringOrNull(); } -CALLBACK_FUNC_DECL(XMLHttpRequestAddEventListener) +v8::Handle<v8::Value> V8XMLHttpRequest::addEventListenerCallback(const v8::Arguments& args) { INC_STATS("DOM.XMLHttpRequest.addEventListener()"); - XMLHttpRequest* xmlHttpRequest = V8DOMWrapper::convertToNativeObject<XMLHttpRequest>(V8ClassIndex::XMLHTTPREQUEST, args.Holder()); + XMLHttpRequest* xmlHttpRequest = V8XMLHttpRequest::toNative(args.Holder()); RefPtr<EventListener> listener = V8DOMWrapper::getEventListener(xmlHttpRequest, args[1], false, ListenerFindOrCreate); if (listener) { @@ -62,15 +63,15 @@ CALLBACK_FUNC_DECL(XMLHttpRequestAddEventListener) bool useCapture = args[2]->BooleanValue(); xmlHttpRequest->addEventListener(type, listener, useCapture); - createHiddenDependency(args.Holder(), args[1], V8Custom::kXMLHttpRequestCacheIndex); + createHiddenDependency(args.Holder(), args[1], cacheIndex); } return v8::Undefined(); } -CALLBACK_FUNC_DECL(XMLHttpRequestRemoveEventListener) +v8::Handle<v8::Value> V8XMLHttpRequest::removeEventListenerCallback(const v8::Arguments& args) { INC_STATS("DOM.XMLHttpRequest.removeEventListener()"); - XMLHttpRequest* xmlHttpRequest = V8DOMWrapper::convertToNativeObject<XMLHttpRequest>(V8ClassIndex::XMLHTTPREQUEST, args.Holder()); + XMLHttpRequest* xmlHttpRequest = V8XMLHttpRequest::toNative(args.Holder()); RefPtr<EventListener> listener = V8DOMWrapper::getEventListener(xmlHttpRequest, args[1], false, ListenerFindOnly); if (listener) { @@ -78,13 +79,13 @@ CALLBACK_FUNC_DECL(XMLHttpRequestRemoveEventListener) bool useCapture = args[2]->BooleanValue(); xmlHttpRequest->removeEventListener(type, listener.get(), useCapture); - removeHiddenDependency(args.Holder(), args[1], V8Custom::kXMLHttpRequestCacheIndex); + removeHiddenDependency(args.Holder(), args[1], cacheIndex); } return v8::Undefined(); } -CALLBACK_FUNC_DECL(XMLHttpRequestOpen) +v8::Handle<v8::Value> V8XMLHttpRequest::openCallback(const v8::Arguments& args) { INC_STATS("DOM.XMLHttpRequest.open()"); // Four cases: @@ -96,7 +97,7 @@ CALLBACK_FUNC_DECL(XMLHttpRequestOpen) if (args.Length() < 2) return throwError("Not enough arguments", V8Proxy::SyntaxError); - XMLHttpRequest* xmlHttpRequest = V8DOMWrapper::convertToNativeObject<XMLHttpRequest>(V8ClassIndex::XMLHTTPREQUEST, args.Holder()); + XMLHttpRequest* xmlHttpRequest = V8XMLHttpRequest::toNative(args.Holder()); String method = toWebCoreString(args[0]); String urlstring = toWebCoreString(args[1]); @@ -133,10 +134,10 @@ static bool IsDocumentType(v8::Handle<v8::Value> value) return V8Document::HasInstance(value) || V8HTMLDocument::HasInstance(value); } -CALLBACK_FUNC_DECL(XMLHttpRequestSend) +v8::Handle<v8::Value> V8XMLHttpRequest::sendCallback(const v8::Arguments& args) { INC_STATS("DOM.XMLHttpRequest.send()"); - XMLHttpRequest* xmlHttpRequest = V8DOMWrapper::convertToNativeObject<XMLHttpRequest>(V8ClassIndex::XMLHTTPREQUEST, args.Holder()); + XMLHttpRequest* xmlHttpRequest = V8XMLHttpRequest::toNative(args.Holder()); ExceptionCode ec = 0; if (args.Length() < 1) @@ -145,14 +146,14 @@ CALLBACK_FUNC_DECL(XMLHttpRequestSend) v8::Handle<v8::Value> arg = args[0]; if (IsDocumentType(arg)) { v8::Handle<v8::Object> object = v8::Handle<v8::Object>::Cast(arg); - Document* document = V8DOMWrapper::convertDOMWrapperToNode<Document>(object); + Document* document = V8Document::toNative(object); ASSERT(document); xmlHttpRequest->send(document, ec); - } else if (V8File::HasInstance(arg)) { + } else if (V8Blob::HasInstance(arg)) { v8::Handle<v8::Object> object = v8::Handle<v8::Object>::Cast(arg); - File* file = V8DOMWrapper::convertDOMWrapperToNative<File>(object); - ASSERT(file); - xmlHttpRequest->send(file, ec); + Blob* blob = V8Blob::toNative(object); + ASSERT(blob); + xmlHttpRequest->send(blob, ec); } else xmlHttpRequest->send(toWebCoreStringWithNullCheck(arg), ec); } @@ -163,12 +164,13 @@ CALLBACK_FUNC_DECL(XMLHttpRequestSend) return v8::Undefined(); } -CALLBACK_FUNC_DECL(XMLHttpRequestSetRequestHeader) { +v8::Handle<v8::Value> V8XMLHttpRequest::setRequestHeaderCallback(const v8::Arguments& args) +{ INC_STATS("DOM.XMLHttpRequest.setRequestHeader()"); if (args.Length() < 2) return throwError("Not enough arguments", V8Proxy::SyntaxError); - XMLHttpRequest* xmlHttpRequest = V8DOMWrapper::convertToNativeObject<XMLHttpRequest>(V8ClassIndex::XMLHTTPREQUEST, args.Holder()); + XMLHttpRequest* xmlHttpRequest = V8XMLHttpRequest::toNative(args.Holder()); ExceptionCode ec = 0; String header = toWebCoreString(args[0]); String value = toWebCoreString(args[1]); @@ -178,13 +180,13 @@ CALLBACK_FUNC_DECL(XMLHttpRequestSetRequestHeader) { return v8::Undefined(); } -CALLBACK_FUNC_DECL(XMLHttpRequestGetResponseHeader) +v8::Handle<v8::Value> V8XMLHttpRequest::getResponseHeaderCallback(const v8::Arguments& args) { INC_STATS("DOM.XMLHttpRequest.getResponseHeader()"); if (args.Length() < 1) return throwError("Not enough arguments", V8Proxy::SyntaxError); - XMLHttpRequest* xmlHttpRequest = V8DOMWrapper::convertToNativeObject<XMLHttpRequest>(V8ClassIndex::XMLHTTPREQUEST, args.Holder()); + XMLHttpRequest* xmlHttpRequest = V8XMLHttpRequest::toNative(args.Holder()); ExceptionCode ec = 0; String header = toWebCoreString(args[0]); String result = xmlHttpRequest->getResponseHeader(header, ec); @@ -193,19 +195,19 @@ CALLBACK_FUNC_DECL(XMLHttpRequestGetResponseHeader) return v8StringOrNull(result); } -CALLBACK_FUNC_DECL(XMLHttpRequestOverrideMimeType) +v8::Handle<v8::Value> V8XMLHttpRequest::overrideMimeTypeCallback(const v8::Arguments& args) { INC_STATS("DOM.XMLHttpRequest.overrideMimeType()"); if (args.Length() < 1) return throwError("Not enough arguments", V8Proxy::SyntaxError); - XMLHttpRequest* xmlHttpRequest = V8DOMWrapper::convertToNativeObject<XMLHttpRequest>(V8ClassIndex::XMLHTTPREQUEST, args.Holder()); + XMLHttpRequest* xmlHttpRequest = V8XMLHttpRequest::toNative(args.Holder()); String value = toWebCoreString(args[0]); xmlHttpRequest->overrideMimeType(value); return v8::Undefined(); } -CALLBACK_FUNC_DECL(XMLHttpRequestDispatchEvent) +v8::Handle<v8::Value> V8XMLHttpRequest::dispatchEventCallback(const v8::Arguments& args) { INC_STATS("DOM.XMLHttpRequest.dispatchEvent()"); return v8::Undefined(); |