summaryrefslogtreecommitdiffstats
path: root/WebCore/bindings/v8/custom/V8XMLHttpRequestCustom.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'WebCore/bindings/v8/custom/V8XMLHttpRequestCustom.cpp')
-rw-r--r--WebCore/bindings/v8/custom/V8XMLHttpRequestCustom.cpp64
1 files changed, 33 insertions, 31 deletions
diff --git a/WebCore/bindings/v8/custom/V8XMLHttpRequestCustom.cpp b/WebCore/bindings/v8/custom/V8XMLHttpRequestCustom.cpp
index cb80a4f..7204a61 100644
--- a/WebCore/bindings/v8/custom/V8XMLHttpRequestCustom.cpp
+++ b/WebCore/bindings/v8/custom/V8XMLHttpRequestCustom.cpp
@@ -44,7 +44,7 @@
namespace WebCore {
-PassRefPtr<EventListener> getEventListener(XMLHttpRequest* xmlHttpRequest, v8::Local<v8::Value> value, bool findOnly)
+static PassRefPtr<EventListener> getEventListener(XMLHttpRequest* xmlHttpRequest, v8::Local<v8::Value> value, bool findOnly)
{
#if ENABLE(WORKERS)
WorkerContextExecutionProxy* workerContextProxy = WorkerContextExecutionProxy::retrieve();
@@ -53,8 +53,10 @@ PassRefPtr<EventListener> getEventListener(XMLHttpRequest* xmlHttpRequest, v8::L
#endif
V8Proxy* proxy = V8Proxy::retrieve(xmlHttpRequest->scriptExecutionContext());
- if (proxy)
- return findOnly ? proxy->FindObjectEventListener(value, false) : proxy->FindOrCreateObjectEventListener(value, false);
+ if (proxy) {
+ V8EventListenerList* list = proxy->objectListeners();
+ return findOnly ? list->findWrapper(value, false) : list->findOrCreateWrapper<V8ObjectEventListener>(proxy->frame(), value, false);
+ }
return PassRefPtr<EventListener>();
}
@@ -62,7 +64,7 @@ PassRefPtr<EventListener> getEventListener(XMLHttpRequest* xmlHttpRequest, v8::L
ACCESSOR_GETTER(XMLHttpRequestOnabort)
{
INC_STATS("DOM.XMLHttpRequest.onabort._get");
- XMLHttpRequest* xmlHttpRequest = V8Proxy::ToNativeObject<XMLHttpRequest>(V8ClassIndex::XMLHTTPREQUEST, info.Holder());
+ XMLHttpRequest* xmlHttpRequest = V8DOMWrapper::convertToNativeObject<XMLHttpRequest>(V8ClassIndex::XMLHTTPREQUEST, info.Holder());
if (xmlHttpRequest->onabort()) {
V8ObjectEventListener* listener = static_cast<V8ObjectEventListener*>(xmlHttpRequest->onabort());
v8::Local<v8::Object> v8Listener = listener->getListenerObject();
@@ -74,7 +76,7 @@ ACCESSOR_GETTER(XMLHttpRequestOnabort)
ACCESSOR_SETTER(XMLHttpRequestOnabort)
{
INC_STATS("DOM.XMLHttpRequest.onabort._set");
- XMLHttpRequest* xmlHttpRequest = V8Proxy::ToNativeObject<XMLHttpRequest>(V8ClassIndex::XMLHTTPREQUEST, info.Holder());
+ XMLHttpRequest* xmlHttpRequest = V8DOMWrapper::convertToNativeObject<XMLHttpRequest>(V8ClassIndex::XMLHTTPREQUEST, info.Holder());
if (value->IsNull()) {
if (xmlHttpRequest->onabort()) {
V8ObjectEventListener* listener = static_cast<V8ObjectEventListener*>(xmlHttpRequest->onabort());
@@ -96,7 +98,7 @@ ACCESSOR_SETTER(XMLHttpRequestOnabort)
ACCESSOR_GETTER(XMLHttpRequestOnerror)
{
INC_STATS("DOM.XMLHttpRequest.onerror._get");
- XMLHttpRequest* xmlHttpRequest = V8Proxy::ToNativeObject<XMLHttpRequest>(V8ClassIndex::XMLHTTPREQUEST, info.Holder());
+ XMLHttpRequest* xmlHttpRequest = V8DOMWrapper::convertToNativeObject<XMLHttpRequest>(V8ClassIndex::XMLHTTPREQUEST, info.Holder());
if (xmlHttpRequest->onerror()) {
RefPtr<V8ObjectEventListener> listener = static_cast<V8ObjectEventListener*>(xmlHttpRequest->onerror());
v8::Local<v8::Object> v8Listener = listener->getListenerObject();
@@ -108,7 +110,7 @@ ACCESSOR_GETTER(XMLHttpRequestOnerror)
ACCESSOR_SETTER(XMLHttpRequestOnerror)
{
INC_STATS("DOM.XMLHttpRequest.onerror._set");
- XMLHttpRequest* xmlHttpRequest = V8Proxy::ToNativeObject<XMLHttpRequest>(V8ClassIndex::XMLHTTPREQUEST, info.Holder());
+ XMLHttpRequest* xmlHttpRequest = V8DOMWrapper::convertToNativeObject<XMLHttpRequest>(V8ClassIndex::XMLHTTPREQUEST, info.Holder());
if (value->IsNull()) {
if (xmlHttpRequest->onerror()) {
V8ObjectEventListener* listener = static_cast<V8ObjectEventListener*>(xmlHttpRequest->onerror());
@@ -130,7 +132,7 @@ ACCESSOR_SETTER(XMLHttpRequestOnerror)
ACCESSOR_GETTER(XMLHttpRequestOnload)
{
INC_STATS("DOM.XMLHttpRequest.onload._get");
- XMLHttpRequest* xmlHttpRequest = V8Proxy::ToNativeObject<XMLHttpRequest>(V8ClassIndex::XMLHTTPREQUEST, info.Holder());
+ XMLHttpRequest* xmlHttpRequest = V8DOMWrapper::convertToNativeObject<XMLHttpRequest>(V8ClassIndex::XMLHTTPREQUEST, info.Holder());
if (xmlHttpRequest->onload()) {
V8ObjectEventListener* listener = static_cast<V8ObjectEventListener*>(xmlHttpRequest->onload());
v8::Local<v8::Object> v8Listener = listener->getListenerObject();
@@ -142,7 +144,7 @@ ACCESSOR_GETTER(XMLHttpRequestOnload)
ACCESSOR_SETTER(XMLHttpRequestOnload)
{
INC_STATS("DOM.XMLHttpRequest.onload._set");
- XMLHttpRequest* xmlHttpRequest = V8Proxy::ToNativeObject<XMLHttpRequest>(V8ClassIndex::XMLHTTPREQUEST, info.Holder());
+ XMLHttpRequest* xmlHttpRequest = V8DOMWrapper::convertToNativeObject<XMLHttpRequest>(V8ClassIndex::XMLHTTPREQUEST, info.Holder());
if (value->IsNull()) {
if (xmlHttpRequest->onload()) {
V8ObjectEventListener* listener = static_cast<V8ObjectEventListener*>(xmlHttpRequest->onload());
@@ -164,7 +166,7 @@ ACCESSOR_SETTER(XMLHttpRequestOnload)
ACCESSOR_GETTER(XMLHttpRequestOnloadstart)
{
INC_STATS("DOM.XMLHttpRequest.onloadstart._get");
- XMLHttpRequest* xmlHttpRequest = V8Proxy::ToNativeObject<XMLHttpRequest>(V8ClassIndex::XMLHTTPREQUEST, info.Holder());
+ XMLHttpRequest* xmlHttpRequest = V8DOMWrapper::convertToNativeObject<XMLHttpRequest>(V8ClassIndex::XMLHTTPREQUEST, info.Holder());
if (xmlHttpRequest->onloadstart()) {
V8ObjectEventListener* listener = static_cast<V8ObjectEventListener*>(xmlHttpRequest->onloadstart());
v8::Local<v8::Object> v8Listener = listener->getListenerObject();
@@ -176,7 +178,7 @@ ACCESSOR_GETTER(XMLHttpRequestOnloadstart)
ACCESSOR_SETTER(XMLHttpRequestOnloadstart)
{
INC_STATS("DOM.XMLHttpRequest.onloadstart._set");
- XMLHttpRequest* xmlHttpRequest = V8Proxy::ToNativeObject<XMLHttpRequest>(V8ClassIndex::XMLHTTPREQUEST, info.Holder());
+ XMLHttpRequest* xmlHttpRequest = V8DOMWrapper::convertToNativeObject<XMLHttpRequest>(V8ClassIndex::XMLHTTPREQUEST, info.Holder());
if (value->IsNull()) {
if (xmlHttpRequest->onloadstart()) {
V8ObjectEventListener* listener = static_cast<V8ObjectEventListener*>(xmlHttpRequest->onloadstart());
@@ -198,7 +200,7 @@ ACCESSOR_SETTER(XMLHttpRequestOnloadstart)
ACCESSOR_GETTER(XMLHttpRequestOnprogress)
{
INC_STATS("DOM.XMLHttpRequest.onprogress._get");
- XMLHttpRequest* xmlHttpRequest = V8Proxy::ToNativeObject<XMLHttpRequest>(V8ClassIndex::XMLHTTPREQUEST, info.Holder());
+ XMLHttpRequest* xmlHttpRequest = V8DOMWrapper::convertToNativeObject<XMLHttpRequest>(V8ClassIndex::XMLHTTPREQUEST, info.Holder());
if (xmlHttpRequest->onprogress()) {
V8ObjectEventListener* listener = static_cast<V8ObjectEventListener*>(xmlHttpRequest->onprogress());
v8::Local<v8::Object> v8Listener = listener->getListenerObject();
@@ -210,7 +212,7 @@ ACCESSOR_GETTER(XMLHttpRequestOnprogress)
ACCESSOR_SETTER(XMLHttpRequestOnprogress)
{
INC_STATS("DOM.XMLHttpRequest.onprogress._set");
- XMLHttpRequest* xmlHttpRequest = V8Proxy::ToNativeObject<XMLHttpRequest>(V8ClassIndex::XMLHTTPREQUEST, info.Holder());
+ XMLHttpRequest* xmlHttpRequest = V8DOMWrapper::convertToNativeObject<XMLHttpRequest>(V8ClassIndex::XMLHTTPREQUEST, info.Holder());
if (value->IsNull()) {
if (xmlHttpRequest->onprogress()) {
V8ObjectEventListener* listener = static_cast<V8ObjectEventListener*>(xmlHttpRequest->onprogress());
@@ -232,7 +234,7 @@ ACCESSOR_SETTER(XMLHttpRequestOnprogress)
ACCESSOR_GETTER(XMLHttpRequestOnreadystatechange)
{
INC_STATS("DOM.XMLHttpRequest.onreadystatechange._get");
- XMLHttpRequest* xmlHttpRequest = V8Proxy::ToNativeObject<XMLHttpRequest>(V8ClassIndex::XMLHTTPREQUEST, info.Holder());
+ XMLHttpRequest* xmlHttpRequest = V8DOMWrapper::convertToNativeObject<XMLHttpRequest>(V8ClassIndex::XMLHTTPREQUEST, info.Holder());
if (xmlHttpRequest->onreadystatechange()) {
V8ObjectEventListener* listener = static_cast<V8ObjectEventListener*>(xmlHttpRequest->onreadystatechange());
v8::Local<v8::Object> v8Listener = listener->getListenerObject();
@@ -244,7 +246,7 @@ ACCESSOR_GETTER(XMLHttpRequestOnreadystatechange)
ACCESSOR_SETTER(XMLHttpRequestOnreadystatechange)
{
INC_STATS("DOM.XMLHttpRequest.onreadystatechange._set");
- XMLHttpRequest* xmlHttpRequest = V8Proxy::ToNativeObject<XMLHttpRequest>(V8ClassIndex::XMLHTTPREQUEST, info.Holder());
+ XMLHttpRequest* xmlHttpRequest = V8DOMWrapper::convertToNativeObject<XMLHttpRequest>(V8ClassIndex::XMLHTTPREQUEST, info.Holder());
if (value->IsNull()) {
if (xmlHttpRequest->onreadystatechange()) {
V8ObjectEventListener* listener = static_cast<V8ObjectEventListener*>(xmlHttpRequest->onreadystatechange());
@@ -268,14 +270,14 @@ ACCESSOR_GETTER(XMLHttpRequestResponseText)
// FIXME: This is only needed because webkit set this getter as custom.
// So we need a custom method to avoid forking the IDL file.
INC_STATS("DOM.XMLHttpRequest.responsetext._get");
- XMLHttpRequest* xmlHttpRequest = V8Proxy::ToNativeObject<XMLHttpRequest>(V8ClassIndex::XMLHTTPREQUEST, info.Holder());
+ XMLHttpRequest* xmlHttpRequest = V8DOMWrapper::convertToNativeObject<XMLHttpRequest>(V8ClassIndex::XMLHTTPREQUEST, info.Holder());
return v8StringOrNull(xmlHttpRequest->responseText());
}
CALLBACK_FUNC_DECL(XMLHttpRequestAddEventListener)
{
INC_STATS("DOM.XMLHttpRequest.addEventListener()");
- XMLHttpRequest* xmlHttpRequest = V8Proxy::ToNativeObject<XMLHttpRequest>(V8ClassIndex::XMLHTTPREQUEST, args.Holder());
+ XMLHttpRequest* xmlHttpRequest = V8DOMWrapper::convertToNativeObject<XMLHttpRequest>(V8ClassIndex::XMLHTTPREQUEST, args.Holder());
RefPtr<EventListener> listener = getEventListener(xmlHttpRequest, args[1], false);
if (listener) {
@@ -291,7 +293,7 @@ CALLBACK_FUNC_DECL(XMLHttpRequestAddEventListener)
CALLBACK_FUNC_DECL(XMLHttpRequestRemoveEventListener)
{
INC_STATS("DOM.XMLHttpRequest.removeEventListener()");
- XMLHttpRequest* xmlHttpRequest = V8Proxy::ToNativeObject<XMLHttpRequest>(V8ClassIndex::XMLHTTPREQUEST, args.Holder());
+ XMLHttpRequest* xmlHttpRequest = V8DOMWrapper::convertToNativeObject<XMLHttpRequest>(V8ClassIndex::XMLHTTPREQUEST, args.Holder());
RefPtr<EventListener> listener = getEventListener(xmlHttpRequest, args[1], true);
if (listener) {
@@ -315,9 +317,9 @@ CALLBACK_FUNC_DECL(XMLHttpRequestOpen)
// open(method, url, async, user, passwd)
if (args.Length() < 2)
- return throwError("Not enough arguments", V8Proxy::SYNTAX_ERROR);
+ return throwError("Not enough arguments", V8Proxy::SyntaxError);
- XMLHttpRequest* xmlHttpRequest = V8Proxy::ToNativeObject<XMLHttpRequest>(V8ClassIndex::XMLHTTPREQUEST, args.Holder());
+ XMLHttpRequest* xmlHttpRequest = V8DOMWrapper::convertToNativeObject<XMLHttpRequest>(V8ClassIndex::XMLHTTPREQUEST, args.Holder());
String method = toWebCoreString(args[0]);
String urlstring = toWebCoreString(args[1]);
@@ -345,10 +347,10 @@ CALLBACK_FUNC_DECL(XMLHttpRequestOpen)
ExceptionCode ec = 0;
String user, passwd;
if (args.Length() >= 4 && !args[3]->IsUndefined()) {
- user = valueToStringWithNullCheck(args[3]);
+ user = toWebCoreStringWithNullCheck(args[3]);
if (args.Length() >= 5 && !args[4]->IsUndefined()) {
- passwd = valueToStringWithNullCheck(args[4]);
+ passwd = toWebCoreStringWithNullCheck(args[4]);
xmlHttpRequest->open(method, url, async, user, passwd, ec);
} else
xmlHttpRequest->open(method, url, async, user, ec);
@@ -370,7 +372,7 @@ static bool IsDocumentType(v8::Handle<v8::Value> value)
CALLBACK_FUNC_DECL(XMLHttpRequestSend)
{
INC_STATS("DOM.XMLHttpRequest.send()");
- XMLHttpRequest* xmlHttpRequest = V8Proxy::ToNativeObject<XMLHttpRequest>(V8ClassIndex::XMLHTTPREQUEST, args.Holder());
+ XMLHttpRequest* xmlHttpRequest = V8DOMWrapper::convertToNativeObject<XMLHttpRequest>(V8ClassIndex::XMLHTTPREQUEST, args.Holder());
ExceptionCode ec = 0;
if (args.Length() < 1)
@@ -380,11 +382,11 @@ CALLBACK_FUNC_DECL(XMLHttpRequestSend)
// FIXME: upstream handles "File" objects too.
if (IsDocumentType(arg)) {
v8::Handle<v8::Object> object = v8::Handle<v8::Object>::Cast(arg);
- Document* document = V8Proxy::DOMWrapperToNode<Document>(object);
+ Document* document = V8DOMWrapper::convertDOMWrapperToNode<Document>(object);
ASSERT(document);
xmlHttpRequest->send(document, ec);
} else
- xmlHttpRequest->send(valueToStringWithNullCheck(arg), ec);
+ xmlHttpRequest->send(toWebCoreStringWithNullCheck(arg), ec);
}
if (ec)
@@ -396,9 +398,9 @@ CALLBACK_FUNC_DECL(XMLHttpRequestSend)
CALLBACK_FUNC_DECL(XMLHttpRequestSetRequestHeader) {
INC_STATS("DOM.XMLHttpRequest.setRequestHeader()");
if (args.Length() < 2)
- return throwError("Not enough arguments", V8Proxy::SYNTAX_ERROR);
+ return throwError("Not enough arguments", V8Proxy::SyntaxError);
- XMLHttpRequest* xmlHttpRequest = V8Proxy::ToNativeObject<XMLHttpRequest>(V8ClassIndex::XMLHTTPREQUEST, args.Holder());
+ XMLHttpRequest* xmlHttpRequest = V8DOMWrapper::convertToNativeObject<XMLHttpRequest>(V8ClassIndex::XMLHTTPREQUEST, args.Holder());
ExceptionCode ec = 0;
String header = toWebCoreString(args[0]);
String value = toWebCoreString(args[1]);
@@ -412,9 +414,9 @@ CALLBACK_FUNC_DECL(XMLHttpRequestGetResponseHeader)
{
INC_STATS("DOM.XMLHttpRequest.getResponseHeader()");
if (args.Length() < 1)
- return throwError("Not enough arguments", V8Proxy::SYNTAX_ERROR);
+ return throwError("Not enough arguments", V8Proxy::SyntaxError);
- XMLHttpRequest* xmlHttpRequest = V8Proxy::ToNativeObject<XMLHttpRequest>(V8ClassIndex::XMLHTTPREQUEST, args.Holder());
+ XMLHttpRequest* xmlHttpRequest = V8DOMWrapper::convertToNativeObject<XMLHttpRequest>(V8ClassIndex::XMLHTTPREQUEST, args.Holder());
ExceptionCode ec = 0;
String header = toWebCoreString(args[0]);
String result = xmlHttpRequest->getResponseHeader(header, ec);
@@ -427,9 +429,9 @@ CALLBACK_FUNC_DECL(XMLHttpRequestOverrideMimeType)
{
INC_STATS("DOM.XMLHttpRequest.overrideMimeType()");
if (args.Length() < 1)
- return throwError("Not enough arguments", V8Proxy::SYNTAX_ERROR);
+ return throwError("Not enough arguments", V8Proxy::SyntaxError);
- XMLHttpRequest* xmlHttpRequest = V8Proxy::ToNativeObject<XMLHttpRequest>(V8ClassIndex::XMLHTTPREQUEST, args.Holder());
+ XMLHttpRequest* xmlHttpRequest = V8DOMWrapper::convertToNativeObject<XMLHttpRequest>(V8ClassIndex::XMLHTTPREQUEST, args.Holder());
String value = toWebCoreString(args[0]);
xmlHttpRequest->overrideMimeType(value);
return v8::Undefined();