diff options
-rw-r--r-- | webkit/build/V8Bindings/SConscript | 3 | ||||
-rw-r--r-- | webkit/build/V8Bindings/V8Bindings.vcproj | 16 | ||||
-rw-r--r-- | webkit/port/bindings/v8/V8XMLHttpRequestConstructor.cpp | 63 | ||||
-rw-r--r-- | webkit/port/bindings/v8/V8XMLHttpRequestCustom.cpp | 341 | ||||
-rw-r--r-- | webkit/port/bindings/v8/V8XMLHttpRequestUploadCustom.cpp | 292 | ||||
-rw-r--r-- | webkit/port/bindings/v8/V8XMLHttpRequestUtilities.cpp | 76 | ||||
-rw-r--r-- | webkit/port/bindings/v8/V8XMLHttpRequestUtilities.h | 45 | ||||
-rw-r--r-- | webkit/webkit.gyp | 4 |
8 files changed, 515 insertions, 325 deletions
diff --git a/webkit/build/V8Bindings/SConscript b/webkit/build/V8Bindings/SConscript index ed95005..4752377 100644 --- a/webkit/build/V8Bindings/SConscript +++ b/webkit/build/V8Bindings/SConscript @@ -350,7 +350,10 @@ inputs = [ '$PORT_DIR/bindings/v8/V8MessagePortCustom.cpp', '$PORT_DIR/bindings/v8/V8WorkerContextCustom.cpp', '$PORT_DIR/bindings/v8/V8WorkerCustom.cpp', + '$PORT_DIR/bindings/v8/V8XMLHttpRequestConstructor.cpp', '$PORT_DIR/bindings/v8/V8XMLHttpRequestCustom.cpp', + '$PORT_DIR/bindings/v8/V8XMLHttpRequestUploadCustom.cpp', + '$PORT_DIR/bindings/v8/V8XMLHttpRequestUtilities.cpp', '$PORT_DIR/bindings/v8/WorkerContextExecutionProxy.cpp', '$PORT_DIR/bindings/v8/WorkerScriptController.cpp', diff --git a/webkit/build/V8Bindings/V8Bindings.vcproj b/webkit/build/V8Bindings/V8Bindings.vcproj index 4aab599..cc6ee6b 100644 --- a/webkit/build/V8Bindings/V8Bindings.vcproj +++ b/webkit/build/V8Bindings/V8Bindings.vcproj @@ -2929,10 +2929,26 @@ > </File> <File + RelativePath="..\..\port\bindings\v8\V8XMLHttpRequestConstructor.cpp" + > + </File> + <File RelativePath="..\..\port\bindings\v8\V8XMLHttpRequestCustom.cpp" > </File> <File + RelativePath="..\..\port\bindings\v8\V8XMLHttpRequestUploadCustom.cpp" + > + </File> + <File + RelativePath="..\..\port\bindings\v8\V8XMLHttpRequestUtilities.cpp" + > + </File> + <File + RelativePath="..\..\port\bindings\v8\V8XMLHttpRequestUtilities.h" + > + </File> + <File RelativePath="..\..\port\bindings\v8\WorkerContextExecutionProxy.cpp" > </File> diff --git a/webkit/port/bindings/v8/V8XMLHttpRequestConstructor.cpp b/webkit/port/bindings/v8/V8XMLHttpRequestConstructor.cpp new file mode 100644 index 0000000..1c3796e --- /dev/null +++ b/webkit/port/bindings/v8/V8XMLHttpRequestConstructor.cpp @@ -0,0 +1,63 @@ +/* + * Copyright (C) 2008, 2009 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 + * met: + * + * * Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * * Redistributions in binary form must reproduce the above + * copyright notice, this list of conditions and the following disclaimer + * in the documentation and/or other materials provided with the + * distribution. + * * Neither the name of Google Inc. nor the names of its + * contributors may be used to endorse or promote products derived from + * this software without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS + * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT + * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR + * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT + * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, + * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT + * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, + * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY + * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE + * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + */ + +#include "config.h" + +#include "Frame.h" +#include "V8Binding.h" +#include "V8CustomBinding.h" +#include "V8ObjectEventListener.h" +#include "V8Proxy.h" +#include "XMLHttpRequest.h" + +namespace WebCore { + +CALLBACK_FUNC_DECL(XMLHttpRequestConstructor) +{ + INC_STATS("DOM.XMLHttpRequest.Constructor"); + + if (!args.IsConstructCall()) { + V8Proxy::ThrowError(V8Proxy::TYPE_ERROR, "DOM object constructor cannot be called as a function."); + return v8::Undefined(); + } + + // Expect no parameters. + // Allocate a XMLHttpRequest object as its internal field. + Document* doc = V8Proxy::retrieveFrame()->document(); + RefPtr<XMLHttpRequest> xmlHttpRequest = XMLHttpRequest::create(doc); + V8Proxy::SetDOMWrapper(args.Holder(), V8ClassIndex::ToInt(V8ClassIndex::XMLHTTPREQUEST), xmlHttpRequest.get()); + + // Add object to the wrapper map. + xmlHttpRequest->ref(); + V8Proxy::SetJSWrapperForActiveDOMObject(xmlHttpRequest.get(), v8::Persistent<v8::Object>::New(args.Holder())); + return args.Holder(); +} + +} // namespace WebCore diff --git a/webkit/port/bindings/v8/V8XMLHttpRequestCustom.cpp b/webkit/port/bindings/v8/V8XMLHttpRequestCustom.cpp index b709ea0..9896264 100644 --- a/webkit/port/bindings/v8/V8XMLHttpRequestCustom.cpp +++ b/webkit/port/bindings/v8/V8XMLHttpRequestCustom.cpp @@ -29,8 +29,8 @@ */ #include "config.h" +#include "XMLHttpRequest.h" -#include "ExceptionCode.h" #include "Frame.h" #include "V8Binding.h" #include "V8Document.h" @@ -38,70 +38,10 @@ #include "V8HTMLDocument.h" #include "V8ObjectEventListener.h" #include "V8Proxy.h" -#include "XMLHttpRequest.h" -#include "XMLHttpRequestUpload.h" - -#include <wtf/Assertions.h> +#include "V8XMLHttpRequestUtilities.h" namespace WebCore { -CALLBACK_FUNC_DECL(XMLHttpRequestConstructor) -{ - INC_STATS("DOM.XMLHttpRequest.Constructor"); - - if (!args.IsConstructCall()) { - V8Proxy::ThrowError(V8Proxy::TYPE_ERROR, "DOM object constructor cannot be called as a function."); - return v8::Undefined(); - } - - // Expect no parameters. - // Allocate a XMLHttpRequest object as its internal field. - Document* doc = V8Proxy::retrieveFrame()->document(); - RefPtr<XMLHttpRequest> xmlHttpRequest = XMLHttpRequest::create(doc); - V8Proxy::SetDOMWrapper(args.Holder(), V8ClassIndex::ToInt(V8ClassIndex::XMLHTTPREQUEST), xmlHttpRequest.get()); - - // Add object to the wrapper map. - xmlHttpRequest->ref(); - V8Proxy::SetJSWrapperForActiveDOMObject(xmlHttpRequest.get(), v8::Persistent<v8::Object>::New(args.Holder())); - return args.Holder(); -} - -// XMLHttpRequest -------------------------------------------------------------- - -// Use an array to hold dependents. It works like a ref-counted scheme. -// A value can be added more than once to the xmlHttpRequest object. -static void CreateHiddenXHRDependency(v8::Local<v8::Object> xmlHttpRequest, v8::Local<v8::Value> value) -{ - ASSERT(V8Proxy::GetDOMWrapperType(xmlHttpRequest) == V8ClassIndex::XMLHTTPREQUEST || V8Proxy::GetDOMWrapperType(xmlHttpRequest) == V8ClassIndex::XMLHTTPREQUESTUPLOAD); - v8::Local<v8::Value> cache = xmlHttpRequest->GetInternalField(V8Custom::kXMLHttpRequestCacheIndex); - if (cache->IsNull() || cache->IsUndefined()) { - cache = v8::Array::New(); - xmlHttpRequest->SetInternalField(V8Custom::kXMLHttpRequestCacheIndex, cache); - } - - v8::Local<v8::Array> cacheArray = v8::Local<v8::Array>::Cast(cache); - cacheArray->Set(v8::Integer::New(cacheArray->Length()), value); -} - -static void RemoveHiddenXHRDependency(v8::Local<v8::Object> xmlHttpRequest, v8::Local<v8::Value> value) -{ - ASSERT(V8Proxy::GetDOMWrapperType(xmlHttpRequest) == V8ClassIndex::XMLHTTPREQUEST || V8Proxy::GetDOMWrapperType(xmlHttpRequest) == V8ClassIndex::XMLHTTPREQUESTUPLOAD); - v8::Local<v8::Value> cache = xmlHttpRequest->GetInternalField(V8Custom::kXMLHttpRequestCacheIndex); - ASSERT(cache->IsArray()); - v8::Local<v8::Array> cacheArray = v8::Local<v8::Array>::Cast(cache); - for (int i = cacheArray->Length() - 1; i >= 0; i--) { - v8::Local<v8::Value> cached = cacheArray->Get(v8::Integer::New(i)); - if (cached->StrictEquals(value)) { - cacheArray->Delete(i); - return; - } - } - - // We should only get here if we try to remove an event listener that was - // never added. - ASSERT_NOT_REACHED(); -} - ACCESSOR_GETTER(XMLHttpRequestOnabort) { INC_STATS("DOM.XMLHttpRequest.onabort._get"); @@ -122,7 +62,7 @@ ACCESSOR_SETTER(XMLHttpRequestOnabort) if (xmlHttpRequest->onabort()) { V8ObjectEventListener* listener = static_cast<V8ObjectEventListener*>(xmlHttpRequest->onabort()); v8::Local<v8::Object> v8Listener = listener->getListenerObject(); - RemoveHiddenXHRDependency(info.Holder(), v8Listener); + removeHiddenXHRDependency(info.Holder(), v8Listener); } // Clear the listener. @@ -135,7 +75,7 @@ ACCESSOR_SETTER(XMLHttpRequestOnabort) RefPtr<EventListener> listener = proxy->FindOrCreateObjectEventListener(value, false); if (listener) { xmlHttpRequest->setOnabort(listener); - CreateHiddenXHRDependency(info.Holder(), value); + createHiddenXHRDependency(info.Holder(), value); } } } @@ -160,7 +100,7 @@ ACCESSOR_SETTER(XMLHttpRequestOnerror) if (xmlHttpRequest->onerror()) { V8ObjectEventListener* listener = static_cast<V8ObjectEventListener*>(xmlHttpRequest->onerror()); v8::Local<v8::Object> v8Listener = listener->getListenerObject(); - RemoveHiddenXHRDependency(info.Holder(), v8Listener); + removeHiddenXHRDependency(info.Holder(), v8Listener); } // Clear the listener. @@ -173,7 +113,7 @@ ACCESSOR_SETTER(XMLHttpRequestOnerror) RefPtr<EventListener> listener = proxy->FindOrCreateObjectEventListener(value, false); if (listener) { xmlHttpRequest->setOnerror(listener); - CreateHiddenXHRDependency(info.Holder(), value); + createHiddenXHRDependency(info.Holder(), value); } } } @@ -198,7 +138,7 @@ ACCESSOR_SETTER(XMLHttpRequestOnload) if (xmlHttpRequest->onload()) { V8ObjectEventListener* listener = static_cast<V8ObjectEventListener*>(xmlHttpRequest->onload()); v8::Local<v8::Object> v8Listener = listener->getListenerObject(); - RemoveHiddenXHRDependency(info.Holder(), v8Listener); + removeHiddenXHRDependency(info.Holder(), v8Listener); } xmlHttpRequest->setOnload(0); @@ -211,7 +151,7 @@ ACCESSOR_SETTER(XMLHttpRequestOnload) RefPtr<EventListener> listener = proxy->FindOrCreateObjectEventListener(value, false); if (listener) { xmlHttpRequest->setOnload(listener.get()); - CreateHiddenXHRDependency(info.Holder(), value); + createHiddenXHRDependency(info.Holder(), value); } } } @@ -236,7 +176,7 @@ ACCESSOR_SETTER(XMLHttpRequestOnloadstart) if (xmlHttpRequest->onloadstart()) { V8ObjectEventListener* listener = static_cast<V8ObjectEventListener*>(xmlHttpRequest->onloadstart()); v8::Local<v8::Object> v8Listener = listener->getListenerObject(); - RemoveHiddenXHRDependency(info.Holder(), v8Listener); + removeHiddenXHRDependency(info.Holder(), v8Listener); } // Clear the listener. @@ -249,7 +189,7 @@ ACCESSOR_SETTER(XMLHttpRequestOnloadstart) RefPtr<EventListener> listener = proxy->FindOrCreateObjectEventListener(value, false); if (listener) { xmlHttpRequest->setOnloadstart(listener); - CreateHiddenXHRDependency(info.Holder(), value); + createHiddenXHRDependency(info.Holder(), value); } } } @@ -274,7 +214,7 @@ ACCESSOR_SETTER(XMLHttpRequestOnprogress) if (xmlHttpRequest->onprogress()) { V8ObjectEventListener* listener = static_cast<V8ObjectEventListener*>(xmlHttpRequest->onprogress()); v8::Local<v8::Object> v8Listener = listener->getListenerObject(); - RemoveHiddenXHRDependency(info.Holder(), v8Listener); + removeHiddenXHRDependency(info.Holder(), v8Listener); } // Clear the listener. @@ -287,7 +227,7 @@ ACCESSOR_SETTER(XMLHttpRequestOnprogress) RefPtr<EventListener> listener = proxy->FindOrCreateObjectEventListener(value, false); if (listener) { xmlHttpRequest->setOnprogress(listener); - CreateHiddenXHRDependency(info.Holder(), value); + createHiddenXHRDependency(info.Holder(), value); } } } @@ -312,7 +252,7 @@ ACCESSOR_SETTER(XMLHttpRequestOnreadystatechange) if (xmlHttpRequest->onreadystatechange()) { V8ObjectEventListener* listener = static_cast<V8ObjectEventListener*>(xmlHttpRequest->onreadystatechange()); v8::Local<v8::Object> v8Listener = listener->getListenerObject(); - RemoveHiddenXHRDependency(info.Holder(), v8Listener); + removeHiddenXHRDependency(info.Holder(), v8Listener); } // Clear the listener. @@ -325,7 +265,7 @@ ACCESSOR_SETTER(XMLHttpRequestOnreadystatechange) RefPtr<EventListener> listener = proxy->FindOrCreateObjectEventListener(value, false); if (listener) { xmlHttpRequest->setOnreadystatechange(listener.get()); - CreateHiddenXHRDependency(info.Holder(), value); + createHiddenXHRDependency(info.Holder(), value); } } } @@ -354,7 +294,7 @@ CALLBACK_FUNC_DECL(XMLHttpRequestAddEventListener) bool useCapture = args[2]->BooleanValue(); xmlHttpRequest->addEventListener(type, listener, useCapture); - CreateHiddenXHRDependency(args.Holder(), args[1]); + createHiddenXHRDependency(args.Holder(), args[1]); } return v8::Undefined(); } @@ -375,7 +315,7 @@ CALLBACK_FUNC_DECL(XMLHttpRequestRemoveEventListener) bool useCapture = args[2]->BooleanValue(); xmlHttpRequest->removeEventListener(type, listener.get(), useCapture); - RemoveHiddenXHRDependency(args.Holder(), args[1]); + removeHiddenXHRDependency(args.Holder(), args[1]); } return v8::Undefined(); @@ -517,253 +457,4 @@ CALLBACK_FUNC_DECL(XMLHttpRequestDispatchEvent) return v8::Undefined(); } - -// XMLHttpRequestUpload -------------------------------------------------------- - -ACCESSOR_GETTER(XMLHttpRequestUploadOnabort) -{ - INC_STATS("DOM.XMLHttpRequestUpload.onabort._get"); - XMLHttpRequestUpload* xmlHttpRequestUpload = V8Proxy::ToNativeObject<XMLHttpRequestUpload>(V8ClassIndex::XMLHTTPREQUESTUPLOAD, info.Holder()); - if (xmlHttpRequestUpload->onabort()) { - V8ObjectEventListener* listener = static_cast<V8ObjectEventListener*>(xmlHttpRequestUpload->onabort()); - v8::Local<v8::Object> v8Listener = listener->getListenerObject(); - return v8Listener; - } - return v8::Undefined(); -} - -ACCESSOR_SETTER(XMLHttpRequestUploadOnabort) -{ - INC_STATS("DOM.XMLHttpRequestUpload.onabort._set"); - XMLHttpRequestUpload* xmlHttpRequestUpload = V8Proxy::ToNativeObject<XMLHttpRequestUpload>(V8ClassIndex::XMLHTTPREQUESTUPLOAD, info.Holder()); - if (value->IsNull()) { - if (xmlHttpRequestUpload->onabort()) { - V8ObjectEventListener* listener = static_cast<V8ObjectEventListener*>(xmlHttpRequestUpload->onabort()); - v8::Local<v8::Object> v8Listener = listener->getListenerObject(); - RemoveHiddenXHRDependency(info.Holder(), v8Listener); - } - - // Clear the listener. - xmlHttpRequestUpload->setOnabort(0); - } else { - XMLHttpRequest* xmlHttpRequest = xmlHttpRequestUpload->associatedXMLHttpRequest(); - V8Proxy* proxy = V8Proxy::retrieve(xmlHttpRequest->scriptExecutionContext()); - if (!proxy) - return; - - RefPtr<EventListener> listener = proxy->FindOrCreateObjectEventListener(value, false); - if (listener) { - xmlHttpRequestUpload->setOnabort(listener); - CreateHiddenXHRDependency(info.Holder(), value); - } - } -} - -ACCESSOR_GETTER(XMLHttpRequestUploadOnerror) -{ - INC_STATS("DOM.XMLHttpRequestUpload.onerror._get"); - XMLHttpRequestUpload* xmlHttpRequestUpload = V8Proxy::ToNativeObject<XMLHttpRequestUpload>(V8ClassIndex::XMLHTTPREQUESTUPLOAD, info.Holder()); - if (xmlHttpRequestUpload->onerror()) { - V8ObjectEventListener* listener = static_cast<V8ObjectEventListener*>(xmlHttpRequestUpload->onerror()); - v8::Local<v8::Object> v8Listener = listener->getListenerObject(); - return v8Listener; - } - return v8::Undefined(); -} - -ACCESSOR_SETTER(XMLHttpRequestUploadOnerror) -{ - INC_STATS("DOM.XMLHttpRequestUpload.onerror._set"); - XMLHttpRequestUpload* xmlHttpRequestUpload = V8Proxy::ToNativeObject<XMLHttpRequestUpload>(V8ClassIndex::XMLHTTPREQUESTUPLOAD, info.Holder()); - if (value->IsNull()) { - if (xmlHttpRequestUpload->onerror()) { - V8ObjectEventListener* listener = static_cast<V8ObjectEventListener*>(xmlHttpRequestUpload->onerror()); - v8::Local<v8::Object> v8Listener = listener->getListenerObject(); - RemoveHiddenXHRDependency(info.Holder(), v8Listener); - } - - // Clear the listener. - xmlHttpRequestUpload->setOnerror(0); - } else { - XMLHttpRequest* xmlHttpRequest = xmlHttpRequestUpload->associatedXMLHttpRequest(); - V8Proxy* proxy = V8Proxy::retrieve(xmlHttpRequest->scriptExecutionContext()); - if (!proxy) - return; - - RefPtr<EventListener> listener = proxy->FindOrCreateObjectEventListener(value, false); - if (listener) { - xmlHttpRequestUpload->setOnerror(listener); - CreateHiddenXHRDependency(info.Holder(), value); - } - } -} - -ACCESSOR_GETTER(XMLHttpRequestUploadOnload) -{ - INC_STATS("DOM.XMLHttpRequestUpload.onload._get"); - XMLHttpRequestUpload* xmlHttpRequestUpload = V8Proxy::ToNativeObject<XMLHttpRequestUpload>(V8ClassIndex::XMLHTTPREQUESTUPLOAD, info.Holder()); - if (xmlHttpRequestUpload->onload()) { - V8ObjectEventListener* listener = static_cast<V8ObjectEventListener*>(xmlHttpRequestUpload->onload()); - v8::Local<v8::Object> v8Listener = listener->getListenerObject(); - return v8Listener; - } - return v8::Undefined(); -} - -ACCESSOR_SETTER(XMLHttpRequestUploadOnload) -{ - INC_STATS("DOM.XMLHttpRequestUpload.onload._set"); - XMLHttpRequestUpload* xmlHttpRequestUpload = V8Proxy::ToNativeObject<XMLHttpRequestUpload>(V8ClassIndex::XMLHTTPREQUESTUPLOAD, info.Holder()); - if (value->IsNull()) { - if (xmlHttpRequestUpload->onload()) { - V8ObjectEventListener* listener = static_cast<V8ObjectEventListener*>(xmlHttpRequestUpload->onload()); - v8::Local<v8::Object> v8Listener = listener->getListenerObject(); - RemoveHiddenXHRDependency(info.Holder(), v8Listener); - } - - // Clear the listener. - xmlHttpRequestUpload->setOnload(0); - } else { - XMLHttpRequest* xmlHttpRequest = xmlHttpRequestUpload->associatedXMLHttpRequest(); - V8Proxy* proxy = V8Proxy::retrieve(xmlHttpRequest->scriptExecutionContext()); - if (!proxy) - return; - - RefPtr<EventListener> listener = proxy->FindOrCreateObjectEventListener(value, false); - if (listener) { - xmlHttpRequestUpload->setOnload(listener); - CreateHiddenXHRDependency(info.Holder(), value); - } - } -} - -ACCESSOR_GETTER(XMLHttpRequestUploadOnloadstart) -{ - INC_STATS("DOM.XMLHttpRequestUpload.onloadstart._get"); - XMLHttpRequestUpload* xmlHttpRequestUpload = V8Proxy::ToNativeObject<XMLHttpRequestUpload>(V8ClassIndex::XMLHTTPREQUESTUPLOAD, info.Holder()); - if (xmlHttpRequestUpload->onloadstart()) { - V8ObjectEventListener* listener = static_cast<V8ObjectEventListener*>(xmlHttpRequestUpload->onloadstart()); - v8::Local<v8::Object> v8Listener = listener->getListenerObject(); - return v8Listener; - } - return v8::Undefined(); -} - -ACCESSOR_SETTER(XMLHttpRequestUploadOnloadstart) -{ - INC_STATS("DOM.XMLHttpRequestUpload.onloadstart._set"); - XMLHttpRequestUpload* xmlHttpRequestUpload = V8Proxy::ToNativeObject<XMLHttpRequestUpload>(V8ClassIndex::XMLHTTPREQUESTUPLOAD, info.Holder()); - if (value->IsNull()) { - if (xmlHttpRequestUpload->onloadstart()) { - V8ObjectEventListener* listener = static_cast<V8ObjectEventListener*>(xmlHttpRequestUpload->onloadstart()); - v8::Local<v8::Object> v8Listener = listener->getListenerObject(); - RemoveHiddenXHRDependency(info.Holder(), v8Listener); - } - - // Clear the listener. - xmlHttpRequestUpload->setOnloadstart(0); - } else { - XMLHttpRequest* xmlHttpRequest = xmlHttpRequestUpload->associatedXMLHttpRequest(); - V8Proxy* proxy = V8Proxy::retrieve(xmlHttpRequest->scriptExecutionContext()); - if (!proxy) - return; - - RefPtr<EventListener> listener = proxy->FindOrCreateObjectEventListener(value, false); - if (listener) { - xmlHttpRequestUpload->setOnloadstart(listener); - CreateHiddenXHRDependency(info.Holder(), value); - } - } -} - -ACCESSOR_GETTER(XMLHttpRequestUploadOnprogress) -{ - INC_STATS("DOM.XMLHttpRequestUpload.onprogress._get"); - XMLHttpRequestUpload* xmlHttpRequestUpload = V8Proxy::ToNativeObject<XMLHttpRequestUpload>(V8ClassIndex::XMLHTTPREQUESTUPLOAD, info.Holder()); - if (xmlHttpRequestUpload->onprogress()) { - V8ObjectEventListener* listener = static_cast<V8ObjectEventListener*>(xmlHttpRequestUpload->onprogress()); - v8::Local<v8::Object> v8Listener = listener->getListenerObject(); - return v8Listener; - } - return v8::Undefined(); -} - -ACCESSOR_SETTER(XMLHttpRequestUploadOnprogress) -{ - INC_STATS("DOM.XMLHttpRequestUpload.onprogress._set"); - XMLHttpRequestUpload* xmlHttpRequestUpload = V8Proxy::ToNativeObject<XMLHttpRequestUpload>(V8ClassIndex::XMLHTTPREQUESTUPLOAD, info.Holder()); - if (value->IsNull()) { - if (xmlHttpRequestUpload->onprogress()) { - V8ObjectEventListener* listener = static_cast<V8ObjectEventListener*>(xmlHttpRequestUpload->onprogress()); - v8::Local<v8::Object> v8Listener = listener->getListenerObject(); - RemoveHiddenXHRDependency(info.Holder(), v8Listener); - } - - // Clear the listener. - xmlHttpRequestUpload->setOnprogress(0); - } else { - XMLHttpRequest* xmlHttpRequest = xmlHttpRequestUpload->associatedXMLHttpRequest(); - V8Proxy* proxy = V8Proxy::retrieve(xmlHttpRequest->scriptExecutionContext()); - if (!proxy) - return; - - RefPtr<EventListener> listener = proxy->FindOrCreateObjectEventListener(value, false); - if (listener) { - xmlHttpRequestUpload->setOnprogress(listener); - CreateHiddenXHRDependency(info.Holder(), value); - } - } -} - -CALLBACK_FUNC_DECL(XMLHttpRequestUploadAddEventListener) -{ - INC_STATS("DOM.XMLHttpRequestUpload.addEventListener()"); - XMLHttpRequestUpload* xmlHttpRequestUpload = V8Proxy::ToNativeObject<XMLHttpRequestUpload>(V8ClassIndex::XMLHTTPREQUESTUPLOAD, args.Holder()); - - XMLHttpRequest* xmlHttpRequest = xmlHttpRequestUpload->associatedXMLHttpRequest(); - V8Proxy* proxy = V8Proxy::retrieve(xmlHttpRequest->scriptExecutionContext()); - if (!proxy) - return v8::Undefined(); - - RefPtr<EventListener> listener = proxy->FindOrCreateObjectEventListener(args[1], false); - if (listener) { - String type = toWebCoreString(args[0]); - bool useCapture = args[2]->BooleanValue(); - xmlHttpRequestUpload->addEventListener(type, listener, useCapture); - - CreateHiddenXHRDependency(args.Holder(), args[1]); - } - return v8::Undefined(); -} - -CALLBACK_FUNC_DECL(XMLHttpRequestUploadRemoveEventListener) -{ - INC_STATS("DOM.XMLHttpRequestUpload.removeEventListener()"); - XMLHttpRequestUpload* xmlHttpRequestUpload = V8Proxy::ToNativeObject<XMLHttpRequestUpload>(V8ClassIndex::XMLHTTPREQUESTUPLOAD, args.Holder()); - - XMLHttpRequest* xmlHttpRequest = xmlHttpRequestUpload->associatedXMLHttpRequest(); - V8Proxy* proxy = V8Proxy::retrieve(xmlHttpRequest->scriptExecutionContext()); - if (!proxy) - return v8::Undefined(); // Probably leaked. - - RefPtr<EventListener> listener = proxy->FindObjectEventListener(args[1], false); - - if (listener) { - String type = toWebCoreString(args[0]); - bool useCapture = args[2]->BooleanValue(); - xmlHttpRequestUpload->removeEventListener(type, listener.get(), useCapture); - - RemoveHiddenXHRDependency(args.Holder(), args[1]); - } - - return v8::Undefined(); -} - -CALLBACK_FUNC_DECL(XMLHttpRequestUploadDispatchEvent) -{ - INC_STATS("DOM.XMLHttpRequestUpload.dispatchEvent()"); - V8Proxy::SetDOMException(NOT_SUPPORTED_ERR); - return v8::Undefined(); -} - } // namespace WebCore diff --git a/webkit/port/bindings/v8/V8XMLHttpRequestUploadCustom.cpp b/webkit/port/bindings/v8/V8XMLHttpRequestUploadCustom.cpp new file mode 100644 index 0000000..a4bcd62 --- /dev/null +++ b/webkit/port/bindings/v8/V8XMLHttpRequestUploadCustom.cpp @@ -0,0 +1,292 @@ +/* + * Copyright (C) 2008, 2009 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 + * met: + * + * * Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * * Redistributions in binary form must reproduce the above + * copyright notice, this list of conditions and the following disclaimer + * in the documentation and/or other materials provided with the + * distribution. + * * Neither the name of Google Inc. nor the names of its + * contributors may be used to endorse or promote products derived from + * this software without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS + * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT + * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR + * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT + * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, + * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT + * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, + * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY + * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE + * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + */ + +#include "config.h" +#include "XMLHttpRequestUpload.h" + +#include "ExceptionCode.h" +#include "V8Binding.h" +#include "V8CustomBinding.h" +#include "V8ObjectEventListener.h" +#include "V8Proxy.h" +#include "V8XMLHttpRequestUtilities.h" +#include "XMLHttpRequest.h" + +#include <wtf/Assertions.h> + +namespace WebCore { + +ACCESSOR_GETTER(XMLHttpRequestUploadOnabort) +{ + INC_STATS("DOM.XMLHttpRequestUpload.onabort._get"); + XMLHttpRequestUpload* xmlHttpRequestUpload = V8Proxy::ToNativeObject<XMLHttpRequestUpload>(V8ClassIndex::XMLHTTPREQUESTUPLOAD, info.Holder()); + if (xmlHttpRequestUpload->onabort()) { + V8ObjectEventListener* listener = static_cast<V8ObjectEventListener*>(xmlHttpRequestUpload->onabort()); + v8::Local<v8::Object> v8Listener = listener->getListenerObject(); + return v8Listener; + } + return v8::Undefined(); +} + +ACCESSOR_SETTER(XMLHttpRequestUploadOnabort) +{ + INC_STATS("DOM.XMLHttpRequestUpload.onabort._set"); + XMLHttpRequestUpload* xmlHttpRequestUpload = V8Proxy::ToNativeObject<XMLHttpRequestUpload>(V8ClassIndex::XMLHTTPREQUESTUPLOAD, info.Holder()); + if (value->IsNull()) { + if (xmlHttpRequestUpload->onabort()) { + V8ObjectEventListener* listener = static_cast<V8ObjectEventListener*>(xmlHttpRequestUpload->onabort()); + v8::Local<v8::Object> v8Listener = listener->getListenerObject(); + removeHiddenXHRDependency(info.Holder(), v8Listener); + } + + // Clear the listener. + xmlHttpRequestUpload->setOnabort(0); + } else { + XMLHttpRequest* xmlHttpRequest = xmlHttpRequestUpload->associatedXMLHttpRequest(); + V8Proxy* proxy = V8Proxy::retrieve(xmlHttpRequest->scriptExecutionContext()); + if (!proxy) + return; + + RefPtr<EventListener> listener = proxy->FindOrCreateObjectEventListener(value, false); + if (listener) { + xmlHttpRequestUpload->setOnabort(listener); + createHiddenXHRDependency(info.Holder(), value); + } + } +} + +ACCESSOR_GETTER(XMLHttpRequestUploadOnerror) +{ + INC_STATS("DOM.XMLHttpRequestUpload.onerror._get"); + XMLHttpRequestUpload* xmlHttpRequestUpload = V8Proxy::ToNativeObject<XMLHttpRequestUpload>(V8ClassIndex::XMLHTTPREQUESTUPLOAD, info.Holder()); + if (xmlHttpRequestUpload->onerror()) { + V8ObjectEventListener* listener = static_cast<V8ObjectEventListener*>(xmlHttpRequestUpload->onerror()); + v8::Local<v8::Object> v8Listener = listener->getListenerObject(); + return v8Listener; + } + return v8::Undefined(); +} + +ACCESSOR_SETTER(XMLHttpRequestUploadOnerror) +{ + INC_STATS("DOM.XMLHttpRequestUpload.onerror._set"); + XMLHttpRequestUpload* xmlHttpRequestUpload = V8Proxy::ToNativeObject<XMLHttpRequestUpload>(V8ClassIndex::XMLHTTPREQUESTUPLOAD, info.Holder()); + if (value->IsNull()) { + if (xmlHttpRequestUpload->onerror()) { + V8ObjectEventListener* listener = static_cast<V8ObjectEventListener*>(xmlHttpRequestUpload->onerror()); + v8::Local<v8::Object> v8Listener = listener->getListenerObject(); + removeHiddenXHRDependency(info.Holder(), v8Listener); + } + + // Clear the listener. + xmlHttpRequestUpload->setOnerror(0); + } else { + XMLHttpRequest* xmlHttpRequest = xmlHttpRequestUpload->associatedXMLHttpRequest(); + V8Proxy* proxy = V8Proxy::retrieve(xmlHttpRequest->scriptExecutionContext()); + if (!proxy) + return; + + RefPtr<EventListener> listener = proxy->FindOrCreateObjectEventListener(value, false); + if (listener) { + xmlHttpRequestUpload->setOnerror(listener); + createHiddenXHRDependency(info.Holder(), value); + } + } +} + +ACCESSOR_GETTER(XMLHttpRequestUploadOnload) +{ + INC_STATS("DOM.XMLHttpRequestUpload.onload._get"); + XMLHttpRequestUpload* xmlHttpRequestUpload = V8Proxy::ToNativeObject<XMLHttpRequestUpload>(V8ClassIndex::XMLHTTPREQUESTUPLOAD, info.Holder()); + if (xmlHttpRequestUpload->onload()) { + V8ObjectEventListener* listener = static_cast<V8ObjectEventListener*>(xmlHttpRequestUpload->onload()); + v8::Local<v8::Object> v8Listener = listener->getListenerObject(); + return v8Listener; + } + return v8::Undefined(); +} + +ACCESSOR_SETTER(XMLHttpRequestUploadOnload) +{ + INC_STATS("DOM.XMLHttpRequestUpload.onload._set"); + XMLHttpRequestUpload* xmlHttpRequestUpload = V8Proxy::ToNativeObject<XMLHttpRequestUpload>(V8ClassIndex::XMLHTTPREQUESTUPLOAD, info.Holder()); + if (value->IsNull()) { + if (xmlHttpRequestUpload->onload()) { + V8ObjectEventListener* listener = static_cast<V8ObjectEventListener*>(xmlHttpRequestUpload->onload()); + v8::Local<v8::Object> v8Listener = listener->getListenerObject(); + removeHiddenXHRDependency(info.Holder(), v8Listener); + } + + // Clear the listener. + xmlHttpRequestUpload->setOnload(0); + } else { + XMLHttpRequest* xmlHttpRequest = xmlHttpRequestUpload->associatedXMLHttpRequest(); + V8Proxy* proxy = V8Proxy::retrieve(xmlHttpRequest->scriptExecutionContext()); + if (!proxy) + return; + + RefPtr<EventListener> listener = proxy->FindOrCreateObjectEventListener(value, false); + if (listener) { + xmlHttpRequestUpload->setOnload(listener); + createHiddenXHRDependency(info.Holder(), value); + } + } +} + +ACCESSOR_GETTER(XMLHttpRequestUploadOnloadstart) +{ + INC_STATS("DOM.XMLHttpRequestUpload.onloadstart._get"); + XMLHttpRequestUpload* xmlHttpRequestUpload = V8Proxy::ToNativeObject<XMLHttpRequestUpload>(V8ClassIndex::XMLHTTPREQUESTUPLOAD, info.Holder()); + if (xmlHttpRequestUpload->onloadstart()) { + V8ObjectEventListener* listener = static_cast<V8ObjectEventListener*>(xmlHttpRequestUpload->onloadstart()); + v8::Local<v8::Object> v8Listener = listener->getListenerObject(); + return v8Listener; + } + return v8::Undefined(); +} + +ACCESSOR_SETTER(XMLHttpRequestUploadOnloadstart) +{ + INC_STATS("DOM.XMLHttpRequestUpload.onloadstart._set"); + XMLHttpRequestUpload* xmlHttpRequestUpload = V8Proxy::ToNativeObject<XMLHttpRequestUpload>(V8ClassIndex::XMLHTTPREQUESTUPLOAD, info.Holder()); + if (value->IsNull()) { + if (xmlHttpRequestUpload->onloadstart()) { + V8ObjectEventListener* listener = static_cast<V8ObjectEventListener*>(xmlHttpRequestUpload->onloadstart()); + v8::Local<v8::Object> v8Listener = listener->getListenerObject(); + removeHiddenXHRDependency(info.Holder(), v8Listener); + } + + // Clear the listener. + xmlHttpRequestUpload->setOnloadstart(0); + } else { + XMLHttpRequest* xmlHttpRequest = xmlHttpRequestUpload->associatedXMLHttpRequest(); + V8Proxy* proxy = V8Proxy::retrieve(xmlHttpRequest->scriptExecutionContext()); + if (!proxy) + return; + + RefPtr<EventListener> listener = proxy->FindOrCreateObjectEventListener(value, false); + if (listener) { + xmlHttpRequestUpload->setOnloadstart(listener); + createHiddenXHRDependency(info.Holder(), value); + } + } +} + +ACCESSOR_GETTER(XMLHttpRequestUploadOnprogress) +{ + INC_STATS("DOM.XMLHttpRequestUpload.onprogress._get"); + XMLHttpRequestUpload* xmlHttpRequestUpload = V8Proxy::ToNativeObject<XMLHttpRequestUpload>(V8ClassIndex::XMLHTTPREQUESTUPLOAD, info.Holder()); + if (xmlHttpRequestUpload->onprogress()) { + V8ObjectEventListener* listener = static_cast<V8ObjectEventListener*>(xmlHttpRequestUpload->onprogress()); + v8::Local<v8::Object> v8Listener = listener->getListenerObject(); + return v8Listener; + } + return v8::Undefined(); +} + +ACCESSOR_SETTER(XMLHttpRequestUploadOnprogress) +{ + INC_STATS("DOM.XMLHttpRequestUpload.onprogress._set"); + XMLHttpRequestUpload* xmlHttpRequestUpload = V8Proxy::ToNativeObject<XMLHttpRequestUpload>(V8ClassIndex::XMLHTTPREQUESTUPLOAD, info.Holder()); + if (value->IsNull()) { + if (xmlHttpRequestUpload->onprogress()) { + V8ObjectEventListener* listener = static_cast<V8ObjectEventListener*>(xmlHttpRequestUpload->onprogress()); + v8::Local<v8::Object> v8Listener = listener->getListenerObject(); + removeHiddenXHRDependency(info.Holder(), v8Listener); + } + + // Clear the listener. + xmlHttpRequestUpload->setOnprogress(0); + } else { + XMLHttpRequest* xmlHttpRequest = xmlHttpRequestUpload->associatedXMLHttpRequest(); + V8Proxy* proxy = V8Proxy::retrieve(xmlHttpRequest->scriptExecutionContext()); + if (!proxy) + return; + + RefPtr<EventListener> listener = proxy->FindOrCreateObjectEventListener(value, false); + if (listener) { + xmlHttpRequestUpload->setOnprogress(listener); + createHiddenXHRDependency(info.Holder(), value); + } + } +} + +CALLBACK_FUNC_DECL(XMLHttpRequestUploadAddEventListener) +{ + INC_STATS("DOM.XMLHttpRequestUpload.addEventListener()"); + XMLHttpRequestUpload* xmlHttpRequestUpload = V8Proxy::ToNativeObject<XMLHttpRequestUpload>(V8ClassIndex::XMLHTTPREQUESTUPLOAD, args.Holder()); + + XMLHttpRequest* xmlHttpRequest = xmlHttpRequestUpload->associatedXMLHttpRequest(); + V8Proxy* proxy = V8Proxy::retrieve(xmlHttpRequest->scriptExecutionContext()); + if (!proxy) + return v8::Undefined(); + + RefPtr<EventListener> listener = proxy->FindOrCreateObjectEventListener(args[1], false); + if (listener) { + String type = toWebCoreString(args[0]); + bool useCapture = args[2]->BooleanValue(); + xmlHttpRequestUpload->addEventListener(type, listener, useCapture); + + createHiddenXHRDependency(args.Holder(), args[1]); + } + return v8::Undefined(); +} + +CALLBACK_FUNC_DECL(XMLHttpRequestUploadRemoveEventListener) +{ + INC_STATS("DOM.XMLHttpRequestUpload.removeEventListener()"); + XMLHttpRequestUpload* xmlHttpRequestUpload = V8Proxy::ToNativeObject<XMLHttpRequestUpload>(V8ClassIndex::XMLHTTPREQUESTUPLOAD, args.Holder()); + + XMLHttpRequest* xmlHttpRequest = xmlHttpRequestUpload->associatedXMLHttpRequest(); + V8Proxy* proxy = V8Proxy::retrieve(xmlHttpRequest->scriptExecutionContext()); + if (!proxy) + return v8::Undefined(); // Probably leaked. + + RefPtr<EventListener> listener = proxy->FindObjectEventListener(args[1], false); + + if (listener) { + String type = toWebCoreString(args[0]); + bool useCapture = args[2]->BooleanValue(); + xmlHttpRequestUpload->removeEventListener(type, listener.get(), useCapture); + + removeHiddenXHRDependency(args.Holder(), args[1]); + } + + return v8::Undefined(); +} + +CALLBACK_FUNC_DECL(XMLHttpRequestUploadDispatchEvent) +{ + INC_STATS("DOM.XMLHttpRequestUpload.dispatchEvent()"); + V8Proxy::SetDOMException(NOT_SUPPORTED_ERR); + return v8::Undefined(); +} + +} // namespace WebCore diff --git a/webkit/port/bindings/v8/V8XMLHttpRequestUtilities.cpp b/webkit/port/bindings/v8/V8XMLHttpRequestUtilities.cpp new file mode 100644 index 0000000..dfd5e45 --- /dev/null +++ b/webkit/port/bindings/v8/V8XMLHttpRequestUtilities.cpp @@ -0,0 +1,76 @@ +/* + * Copyright (C) 2008, 2009 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 + * met: + * + * * Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * * Redistributions in binary form must reproduce the above + * copyright notice, this list of conditions and the following disclaimer + * in the documentation and/or other materials provided with the + * distribution. + * * Neither the name of Google Inc. nor the names of its + * contributors may be used to endorse or promote products derived from + * this software without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS + * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT + * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR + * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT + * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, + * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT + * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, + * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY + * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE + * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + */ + +#include "config.h" +#include "V8XMLHttpRequestUtilities.h" + +#include <v8.h> + +#include "V8CustomBinding.h" +#include "V8Proxy.h" + +#include <wtf/Assertions.h> + +namespace WebCore { + +// Use an array to hold dependents. It works like a ref-counted scheme. +// A value can be added more than once to the xmlHttpRequest object. +void createHiddenXHRDependency(v8::Local<v8::Object> xmlHttpRequest, v8::Local<v8::Value> value) +{ + ASSERT(V8Proxy::GetDOMWrapperType(xmlHttpRequest) == V8ClassIndex::XMLHTTPREQUEST || V8Proxy::GetDOMWrapperType(xmlHttpRequest) == V8ClassIndex::XMLHTTPREQUESTUPLOAD); + v8::Local<v8::Value> cache = xmlHttpRequest->GetInternalField(V8Custom::kXMLHttpRequestCacheIndex); + if (cache->IsNull() || cache->IsUndefined()) { + cache = v8::Array::New(); + xmlHttpRequest->SetInternalField(V8Custom::kXMLHttpRequestCacheIndex, cache); + } + + v8::Local<v8::Array> cacheArray = v8::Local<v8::Array>::Cast(cache); + cacheArray->Set(v8::Integer::New(cacheArray->Length()), value); +} + +void removeHiddenXHRDependency(v8::Local<v8::Object> xmlHttpRequest, v8::Local<v8::Value> value) +{ + ASSERT(V8Proxy::GetDOMWrapperType(xmlHttpRequest) == V8ClassIndex::XMLHTTPREQUEST || V8Proxy::GetDOMWrapperType(xmlHttpRequest) == V8ClassIndex::XMLHTTPREQUESTUPLOAD); + v8::Local<v8::Value> cache = xmlHttpRequest->GetInternalField(V8Custom::kXMLHttpRequestCacheIndex); + ASSERT(cache->IsArray()); + v8::Local<v8::Array> cacheArray = v8::Local<v8::Array>::Cast(cache); + for (int i = cacheArray->Length() - 1; i >= 0; --i) { + v8::Local<v8::Value> cached = cacheArray->Get(v8::Integer::New(i)); + if (cached->StrictEquals(value)) { + cacheArray->Delete(i); + return; + } + } + + // We should only get here if we try to remove an event listener that was never added. + ASSERT_NOT_REACHED(); +} + +} // namespace WebCore diff --git a/webkit/port/bindings/v8/V8XMLHttpRequestUtilities.h b/webkit/port/bindings/v8/V8XMLHttpRequestUtilities.h new file mode 100644 index 0000000..5a55974 --- /dev/null +++ b/webkit/port/bindings/v8/V8XMLHttpRequestUtilities.h @@ -0,0 +1,45 @@ +/* + * Copyright (C) 2008, 2009 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 + * met: + * + * * Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * * Redistributions in binary form must reproduce the above + * copyright notice, this list of conditions and the following disclaimer + * in the documentation and/or other materials provided with the + * distribution. + * * Neither the name of Google Inc. nor the names of its + * contributors may be used to endorse or promote products derived from + * this software without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS + * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT + * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR + * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT + * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, + * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT + * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, + * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY + * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE + * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + */ + +#ifndef V8XMLHttpRequestUtilities_h +#define V8XMLHttpRequestUtilities_h + +#include <v8.h> + +namespace WebCore { + +// Use an array to hold dependents. It works like a ref-counted scheme. +// A value can be added more than once to the xmlHttpRequest object. +void createHiddenXHRDependency(v8::Local<v8::Object> xmlHttpRequest, v8::Local<v8::Value>); +void removeHiddenXHRDependency(v8::Local<v8::Object> xmlHttpRequest, v8::Local<v8::Value>); + +} // namespace WebCore + +#endif // V8XMLHttpRequestUtilities_h diff --git a/webkit/webkit.gyp b/webkit/webkit.gyp index ca247be..0415266 100644 --- a/webkit/webkit.gyp +++ b/webkit/webkit.gyp @@ -1064,7 +1064,11 @@ 'port/bindings/v8/V8SVGPODTypeWrapper.h', 'port/bindings/v8/V8WorkerContextCustom.cpp', 'port/bindings/v8/V8WorkerCustom.cpp', + 'port/bindings/v8/V8XMLHttpRequestConstructor.cpp', 'port/bindings/v8/V8XMLHttpRequestCustom.cpp', + 'port/bindings/v8/V8XMLHttpRequestUploadCustom.cpp', + 'port/bindings/v8/V8XMLHttpRequestUtilities.cpp', + 'port/bindings/v8/V8XMLHttpRequestUtilities.h', 'port/bindings/v8/WorkerContextExecutionProxy.cpp', 'port/bindings/v8/WorkerContextExecutionProxy.h', 'port/bindings/v8/WorkerScriptController.cpp', |