diff options
Diffstat (limited to 'WebCore/bindings/v8/custom/V8XMLHttpRequestCustom.cpp')
-rw-r--r-- | WebCore/bindings/v8/custom/V8XMLHttpRequestCustom.cpp | 76 |
1 files changed, 24 insertions, 52 deletions
diff --git a/WebCore/bindings/v8/custom/V8XMLHttpRequestCustom.cpp b/WebCore/bindings/v8/custom/V8XMLHttpRequestCustom.cpp index d10c418..4e9c715 100644 --- a/WebCore/bindings/v8/custom/V8XMLHttpRequestCustom.cpp +++ b/WebCore/bindings/v8/custom/V8XMLHttpRequestCustom.cpp @@ -1,5 +1,5 @@ /* - * Copyright (C) 2008, 2009 Google Inc. All rights reserved. + * Copyright (C) 2008, 2009, 2010 Google Inc. All rights reserved. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions are @@ -34,6 +34,7 @@ #include "Frame.h" #include "V8Binding.h" #include "V8Blob.h" +#include "V8DOMFormData.h" #include "V8Document.h" #include "V8HTMLDocument.h" #include "V8Proxy.h" @@ -51,39 +52,6 @@ v8::Handle<v8::Value> V8XMLHttpRequest::responseTextAccessorGetter(v8::Local<v8: return xmlHttpRequest->responseText().v8StringOrNull(); } -v8::Handle<v8::Value> V8XMLHttpRequest::addEventListenerCallback(const v8::Arguments& args) -{ - INC_STATS("DOM.XMLHttpRequest.addEventListener()"); - XMLHttpRequest* xmlHttpRequest = V8XMLHttpRequest::toNative(args.Holder()); - - RefPtr<EventListener> listener = V8DOMWrapper::getEventListener(xmlHttpRequest, args[1], false, ListenerFindOrCreate); - if (listener) { - String type = toWebCoreString(args[0]); - bool useCapture = args[2]->BooleanValue(); - xmlHttpRequest->addEventListener(type, listener, useCapture); - - createHiddenDependency(args.Holder(), args[1], cacheIndex); - } - return v8::Undefined(); -} - -v8::Handle<v8::Value> V8XMLHttpRequest::removeEventListenerCallback(const v8::Arguments& args) -{ - INC_STATS("DOM.XMLHttpRequest.removeEventListener()"); - XMLHttpRequest* xmlHttpRequest = V8XMLHttpRequest::toNative(args.Holder()); - - RefPtr<EventListener> listener = V8DOMWrapper::getEventListener(xmlHttpRequest, args[1], false, ListenerFindOnly); - if (listener) { - String type = toWebCoreString(args[0]); - bool useCapture = args[2]->BooleanValue(); - xmlHttpRequest->removeEventListener(type, listener.get(), useCapture); - - removeHiddenDependency(args.Holder(), args[1], cacheIndex); - } - - return v8::Undefined(); -} - v8::Handle<v8::Value> V8XMLHttpRequest::openCallback(const v8::Arguments& args) { INC_STATS("DOM.XMLHttpRequest.open()"); @@ -106,20 +74,23 @@ v8::Handle<v8::Value> V8XMLHttpRequest::openCallback(const v8::Arguments& args) KURL url = context->completeURL(urlstring); - bool async = (args.Length() < 3) ? true : args[2]->BooleanValue(); - ExceptionCode ec = 0; - String user, passwd; - if (args.Length() >= 4 && !args[3]->IsUndefined()) { - user = toWebCoreStringWithNullCheck(args[3]); - if (args.Length() >= 5 && !args[4]->IsUndefined()) { - passwd = toWebCoreStringWithNullCheck(args[4]); - xmlHttpRequest->open(method, url, async, user, passwd, ec); + if (args.Length() >= 3) { + bool async = args[2]->BooleanValue(); + + if (args.Length() >= 4 && !args[3]->IsUndefined()) { + String user = toWebCoreStringWithNullCheck(args[3]); + + if (args.Length() >= 5 && !args[4]->IsUndefined()) { + String passwd = toWebCoreStringWithNullCheck(args[4]); + xmlHttpRequest->open(method, url, async, user, passwd, ec); + } else + xmlHttpRequest->open(method, url, async, user, ec); } else - xmlHttpRequest->open(method, url, async, user, ec); + xmlHttpRequest->open(method, url, async, ec); } else - xmlHttpRequest->open(method, url, async, ec); + xmlHttpRequest->open(method, url, ec); if (ec) return throwError(ec); @@ -127,7 +98,7 @@ v8::Handle<v8::Value> V8XMLHttpRequest::openCallback(const v8::Arguments& args) return v8::Undefined(); } -static bool IsDocumentType(v8::Handle<v8::Value> value) +static bool isDocumentType(v8::Handle<v8::Value> value) { // FIXME: add other document types. return V8Document::HasInstance(value) || V8HTMLDocument::HasInstance(value); @@ -143,7 +114,9 @@ v8::Handle<v8::Value> V8XMLHttpRequest::sendCallback(const v8::Arguments& args) xmlHttpRequest->send(ec); else { v8::Handle<v8::Value> arg = args[0]; - if (IsDocumentType(arg)) { + if (isUndefinedOrNull(arg)) + xmlHttpRequest->send(ec); + else if (isDocumentType(arg)) { v8::Handle<v8::Object> object = v8::Handle<v8::Object>::Cast(arg); Document* document = V8Document::toNative(object); ASSERT(document); @@ -153,6 +126,11 @@ v8::Handle<v8::Value> V8XMLHttpRequest::sendCallback(const v8::Arguments& args) Blob* blob = V8Blob::toNative(object); ASSERT(blob); xmlHttpRequest->send(blob, ec); + } else if (V8DOMFormData::HasInstance(arg)) { + v8::Handle<v8::Object> object = v8::Handle<v8::Object>::Cast(arg); + DOMFormData* domFormData = V8DOMFormData::toNative(object); + ASSERT(domFormData); + xmlHttpRequest->send(domFormData, ec); } else xmlHttpRequest->send(toWebCoreStringWithNullCheck(arg), ec); } @@ -206,10 +184,4 @@ v8::Handle<v8::Value> V8XMLHttpRequest::overrideMimeTypeCallback(const v8::Argum return v8::Undefined(); } -v8::Handle<v8::Value> V8XMLHttpRequest::dispatchEventCallback(const v8::Arguments& args) -{ - INC_STATS("DOM.XMLHttpRequest.dispatchEvent()"); - return v8::Undefined(); -} - } // namespace WebCore |