Commit 21f88447 authored by dimich@chromium.org's avatar dimich@chromium.org

2009-04-18 Jian Li <jianli@chromium.org>

        Reviewed by Dimitri Glazkov.

        https://bugs.webkit.org/post_bug.cg://bugs.webkit.org/show_bug.cgi?id=25167
        Change createHiddenXHRDependency and removeHiddenXHRDependency so that they can be used by other custom code in V8 bindings.

        * bindings/v8/V8Utilities.cpp: Renamed from WebCore/bindings/v8/V8XMLHttpRequestUtilities.cpp.
        (WebCore::createHiddenDependency):
        (WebCore::removeHiddenDependency):
        * bindings/v8/V8Utilities.h: Renamed from WebCore/bindings/v8/V8XMLHttpRequestUtilities.h.
        * bindings/v8/custom/V8XMLHttpRequestCustom.cpp:
        (WebCore::ACCESSOR_SETTER):
        (WebCore::CALLBACK_FUNC_DECL):
        * bindings/v8/custom/V8XMLHttpRequestUploadCustom.cpp:
        (WebCore::ACCESSOR_SETTER):
        (WebCore::CALLBACK_FUNC_DECL):

git-svn-id: svn://svn.chromium.org/blink/trunk@42647 bbb929c8-8fbe-4397-9dbb-9b2b20218538
parent 80b63307
2009-04-18 Jian Li <jianli@chromium.org>
Reviewed by Dimitri Glazkov.
https://bugs.webkit.org/post_bug.cg://bugs.webkit.org/show_bug.cgi?id=25167
Change createHiddenXHRDependency and removeHiddenXHRDependency so that they can be used by other custom code in V8 bindings.
* bindings/v8/V8Utilities.cpp: Renamed from WebCore/bindings/v8/V8XMLHttpRequestUtilities.cpp.
(WebCore::createHiddenDependency):
(WebCore::removeHiddenDependency):
* bindings/v8/V8Utilities.h: Renamed from WebCore/bindings/v8/V8XMLHttpRequestUtilities.h.
* bindings/v8/custom/V8XMLHttpRequestCustom.cpp:
(WebCore::ACCESSOR_SETTER):
(WebCore::CALLBACK_FUNC_DECL):
* bindings/v8/custom/V8XMLHttpRequestUploadCustom.cpp:
(WebCore::ACCESSOR_SETTER):
(WebCore::CALLBACK_FUNC_DECL):
2009-04-18 Drew Wilson <amw@apple.com>
<rdar://problem/6781407> VisiblePosition.characterAfter should return UChar32
......@@ -29,7 +29,7 @@
*/
#include "config.h"
#include "V8XMLHttpRequestUtilities.h"
#include "V8Utilities.h"
#include <v8.h>
......@@ -41,24 +41,22 @@
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)
// A value can be added more than once to the DOM object.
void createHiddenDependency(v8::Local<v8::Object> object, v8::Local<v8::Value> value, int cacheIndex)
{
ASSERT(V8Proxy::GetDOMWrapperType(xmlHttpRequest) == V8ClassIndex::XMLHTTPREQUEST || V8Proxy::GetDOMWrapperType(xmlHttpRequest) == V8ClassIndex::XMLHTTPREQUESTUPLOAD);
v8::Local<v8::Value> cache = xmlHttpRequest->GetInternalField(V8Custom::kXMLHttpRequestCacheIndex);
v8::Local<v8::Value> cache = object->GetInternalField(cacheIndex);
if (cache->IsNull() || cache->IsUndefined()) {
cache = v8::Array::New();
xmlHttpRequest->SetInternalField(V8Custom::kXMLHttpRequestCacheIndex, cache);
object->SetInternalField(cacheIndex, 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)
void removeHiddenDependency(v8::Local<v8::Object> object, v8::Local<v8::Value> value, int cacheIndex)
{
ASSERT(V8Proxy::GetDOMWrapperType(xmlHttpRequest) == V8ClassIndex::XMLHTTPREQUEST || V8Proxy::GetDOMWrapperType(xmlHttpRequest) == V8ClassIndex::XMLHTTPREQUESTUPLOAD);
v8::Local<v8::Value> cache = xmlHttpRequest->GetInternalField(V8Custom::kXMLHttpRequestCacheIndex);
v8::Local<v8::Value> cache = object->GetInternalField(cacheIndex);
ASSERT(cache->IsArray());
v8::Local<v8::Array> cacheArray = v8::Local<v8::Array>::Cast(cache);
for (int i = cacheArray->Length() - 1; i >= 0; --i) {
......
......@@ -28,18 +28,18 @@
* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
#ifndef V8XMLHttpRequestUtilities_h
#define V8XMLHttpRequestUtilities_h
#ifndef V8Utilities_h
#define V8Utilities_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>);
// A value can be added more than once to the DOM object.
void createHiddenDependency(v8::Local<v8::Object>, v8::Local<v8::Value>, int cacheIndex);
void removeHiddenDependency(v8::Local<v8::Object>, v8::Local<v8::Value>, int cacheIndex);
} // namespace WebCore
#endif // V8XMLHttpRequestUtilities_h
#endif // V8Utilities_h
......@@ -38,7 +38,7 @@
#include "V8HTMLDocument.h"
#include "V8ObjectEventListener.h"
#include "V8Proxy.h"
#include "V8XMLHttpRequestUtilities.h"
#include "V8Utilities.h"
#include "WorkerContext.h"
#include "WorkerContextExecutionProxy.h"
......@@ -79,7 +79,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);
removeHiddenDependency(info.Holder(), v8Listener, V8Custom::kXMLHttpRequestCacheIndex);
}
// Clear the listener.
......@@ -88,7 +88,7 @@ ACCESSOR_SETTER(XMLHttpRequestOnabort)
RefPtr<EventListener> listener = getEventListener(xmlHttpRequest, value, false);
if (listener) {
xmlHttpRequest->setOnabort(listener);
createHiddenXHRDependency(info.Holder(), value);
createHiddenDependency(info.Holder(), value, V8Custom::kXMLHttpRequestCacheIndex);
}
}
}
......@@ -113,7 +113,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);
removeHiddenDependency(info.Holder(), v8Listener, V8Custom::kXMLHttpRequestCacheIndex);
}
// Clear the listener.
......@@ -122,7 +122,7 @@ ACCESSOR_SETTER(XMLHttpRequestOnerror)
RefPtr<EventListener> listener = getEventListener(xmlHttpRequest, value, false);
if (listener) {
xmlHttpRequest->setOnerror(listener);
createHiddenXHRDependency(info.Holder(), value);
createHiddenDependency(info.Holder(), value, V8Custom::kXMLHttpRequestCacheIndex);
}
}
}
......@@ -147,7 +147,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);
removeHiddenDependency(info.Holder(), v8Listener, V8Custom::kXMLHttpRequestCacheIndex);
}
xmlHttpRequest->setOnload(0);
......@@ -156,7 +156,7 @@ ACCESSOR_SETTER(XMLHttpRequestOnload)
RefPtr<EventListener> listener = getEventListener(xmlHttpRequest, value, false);
if (listener) {
xmlHttpRequest->setOnload(listener.get());
createHiddenXHRDependency(info.Holder(), value);
createHiddenDependency(info.Holder(), value, V8Custom::kXMLHttpRequestCacheIndex);
}
}
}
......@@ -181,7 +181,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);
removeHiddenDependency(info.Holder(), v8Listener, V8Custom::kXMLHttpRequestCacheIndex);
}
// Clear the listener.
......@@ -190,7 +190,7 @@ ACCESSOR_SETTER(XMLHttpRequestOnloadstart)
RefPtr<EventListener> listener = getEventListener(xmlHttpRequest, value, false);
if (listener) {
xmlHttpRequest->setOnloadstart(listener);
createHiddenXHRDependency(info.Holder(), value);
createHiddenDependency(info.Holder(), value, V8Custom::kXMLHttpRequestCacheIndex);
}
}
}
......@@ -215,7 +215,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);
removeHiddenDependency(info.Holder(), v8Listener, V8Custom::kXMLHttpRequestCacheIndex);
}
// Clear the listener.
......@@ -224,7 +224,7 @@ ACCESSOR_SETTER(XMLHttpRequestOnprogress)
RefPtr<EventListener> listener = getEventListener(xmlHttpRequest, value, false);
if (listener) {
xmlHttpRequest->setOnprogress(listener);
createHiddenXHRDependency(info.Holder(), value);
createHiddenDependency(info.Holder(), value, V8Custom::kXMLHttpRequestCacheIndex);
}
}
}
......@@ -249,7 +249,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);
removeHiddenDependency(info.Holder(), v8Listener, V8Custom::kXMLHttpRequestCacheIndex);
}
// Clear the listener.
......@@ -258,7 +258,7 @@ ACCESSOR_SETTER(XMLHttpRequestOnreadystatechange)
RefPtr<EventListener> listener = getEventListener(xmlHttpRequest, value, false);
if (listener) {
xmlHttpRequest->setOnreadystatechange(listener.get());
createHiddenXHRDependency(info.Holder(), value);
createHiddenDependency(info.Holder(), value, V8Custom::kXMLHttpRequestCacheIndex);
}
}
}
......@@ -283,7 +283,7 @@ CALLBACK_FUNC_DECL(XMLHttpRequestAddEventListener)
bool useCapture = args[2]->BooleanValue();
xmlHttpRequest->addEventListener(type, listener, useCapture);
createHiddenXHRDependency(args.Holder(), args[1]);
createHiddenDependency(args.Holder(), args[1], V8Custom::kXMLHttpRequestCacheIndex);
}
return v8::Undefined();
}
......@@ -299,7 +299,7 @@ CALLBACK_FUNC_DECL(XMLHttpRequestRemoveEventListener)
bool useCapture = args[2]->BooleanValue();
xmlHttpRequest->removeEventListener(type, listener.get(), useCapture);
removeHiddenXHRDependency(args.Holder(), args[1]);
removeHiddenDependency(args.Holder(), args[1], V8Custom::kXMLHttpRequestCacheIndex);
}
return v8::Undefined();
......
......@@ -36,7 +36,7 @@
#include "V8CustomBinding.h"
#include "V8ObjectEventListener.h"
#include "V8Proxy.h"
#include "V8XMLHttpRequestUtilities.h"
#include "V8Utilities.h"
#include "XMLHttpRequest.h"
#include <wtf/Assertions.h>
......@@ -63,7 +63,7 @@ ACCESSOR_SETTER(XMLHttpRequestUploadOnabort)
if (xmlHttpRequestUpload->onabort()) {
V8ObjectEventListener* listener = static_cast<V8ObjectEventListener*>(xmlHttpRequestUpload->onabort());
v8::Local<v8::Object> v8Listener = listener->getListenerObject();
removeHiddenXHRDependency(info.Holder(), v8Listener);
removeHiddenDependency(info.Holder(), v8Listener, V8Custom::kXMLHttpRequestCacheIndex);
}
// Clear the listener.
......@@ -77,7 +77,7 @@ ACCESSOR_SETTER(XMLHttpRequestUploadOnabort)
RefPtr<EventListener> listener = proxy->FindOrCreateObjectEventListener(value, false);
if (listener) {
xmlHttpRequestUpload->setOnabort(listener);
createHiddenXHRDependency(info.Holder(), value);
createHiddenDependency(info.Holder(), value, V8Custom::kXMLHttpRequestCacheIndex);
}
}
}
......@@ -102,7 +102,7 @@ ACCESSOR_SETTER(XMLHttpRequestUploadOnerror)
if (xmlHttpRequestUpload->onerror()) {
V8ObjectEventListener* listener = static_cast<V8ObjectEventListener*>(xmlHttpRequestUpload->onerror());
v8::Local<v8::Object> v8Listener = listener->getListenerObject();
removeHiddenXHRDependency(info.Holder(), v8Listener);
removeHiddenDependency(info.Holder(), v8Listener, V8Custom::kXMLHttpRequestCacheIndex);
}
// Clear the listener.
......@@ -116,7 +116,7 @@ ACCESSOR_SETTER(XMLHttpRequestUploadOnerror)
RefPtr<EventListener> listener = proxy->FindOrCreateObjectEventListener(value, false);
if (listener) {
xmlHttpRequestUpload->setOnerror(listener);
createHiddenXHRDependency(info.Holder(), value);
createHiddenDependency(info.Holder(), value, V8Custom::kXMLHttpRequestCacheIndex);
}
}
}
......@@ -141,7 +141,7 @@ ACCESSOR_SETTER(XMLHttpRequestUploadOnload)
if (xmlHttpRequestUpload->onload()) {
V8ObjectEventListener* listener = static_cast<V8ObjectEventListener*>(xmlHttpRequestUpload->onload());
v8::Local<v8::Object> v8Listener = listener->getListenerObject();
removeHiddenXHRDependency(info.Holder(), v8Listener);
removeHiddenDependency(info.Holder(), v8Listener, V8Custom::kXMLHttpRequestCacheIndex);
}
// Clear the listener.
......@@ -155,7 +155,7 @@ ACCESSOR_SETTER(XMLHttpRequestUploadOnload)
RefPtr<EventListener> listener = proxy->FindOrCreateObjectEventListener(value, false);
if (listener) {
xmlHttpRequestUpload->setOnload(listener);
createHiddenXHRDependency(info.Holder(), value);
createHiddenDependency(info.Holder(), value, V8Custom::kXMLHttpRequestCacheIndex);
}
}
}
......@@ -180,7 +180,7 @@ ACCESSOR_SETTER(XMLHttpRequestUploadOnloadstart)
if (xmlHttpRequestUpload->onloadstart()) {
V8ObjectEventListener* listener = static_cast<V8ObjectEventListener*>(xmlHttpRequestUpload->onloadstart());
v8::Local<v8::Object> v8Listener = listener->getListenerObject();
removeHiddenXHRDependency(info.Holder(), v8Listener);
removeHiddenDependency(info.Holder(), v8Listener, V8Custom::kXMLHttpRequestCacheIndex);
}
// Clear the listener.
......@@ -194,7 +194,7 @@ ACCESSOR_SETTER(XMLHttpRequestUploadOnloadstart)
RefPtr<EventListener> listener = proxy->FindOrCreateObjectEventListener(value, false);
if (listener) {
xmlHttpRequestUpload->setOnloadstart(listener);
createHiddenXHRDependency(info.Holder(), value);
createHiddenDependency(info.Holder(), value, V8Custom::kXMLHttpRequestCacheIndex);
}
}
}
......@@ -219,7 +219,7 @@ ACCESSOR_SETTER(XMLHttpRequestUploadOnprogress)
if (xmlHttpRequestUpload->onprogress()) {
V8ObjectEventListener* listener = static_cast<V8ObjectEventListener*>(xmlHttpRequestUpload->onprogress());
v8::Local<v8::Object> v8Listener = listener->getListenerObject();
removeHiddenXHRDependency(info.Holder(), v8Listener);
removeHiddenDependency(info.Holder(), v8Listener, V8Custom::kXMLHttpRequestCacheIndex);
}
// Clear the listener.
......@@ -233,7 +233,7 @@ ACCESSOR_SETTER(XMLHttpRequestUploadOnprogress)
RefPtr<EventListener> listener = proxy->FindOrCreateObjectEventListener(value, false);
if (listener) {
xmlHttpRequestUpload->setOnprogress(listener);
createHiddenXHRDependency(info.Holder(), value);
createHiddenDependency(info.Holder(), value, V8Custom::kXMLHttpRequestCacheIndex);
}
}
}
......@@ -254,7 +254,7 @@ CALLBACK_FUNC_DECL(XMLHttpRequestUploadAddEventListener)
bool useCapture = args[2]->BooleanValue();
xmlHttpRequestUpload->addEventListener(type, listener, useCapture);
createHiddenXHRDependency(args.Holder(), args[1]);
createHiddenDependency(args.Holder(), args[1], V8Custom::kXMLHttpRequestCacheIndex);
}
return v8::Undefined();
}
......@@ -276,7 +276,7 @@ CALLBACK_FUNC_DECL(XMLHttpRequestUploadRemoveEventListener)
bool useCapture = args[2]->BooleanValue();
xmlHttpRequestUpload->removeEventListener(type, listener.get(), useCapture);
removeHiddenXHRDependency(args.Holder(), args[1]);
removeHiddenDependency(args.Holder(), args[1], V8Custom::kXMLHttpRequestCacheIndex);
}
return v8::Undefined();
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment