summaryrefslogtreecommitdiffstats
path: root/webkit/port
diff options
context:
space:
mode:
authorlevin@chromium.org <levin@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2009-03-19 23:01:12 +0000
committerlevin@chromium.org <levin@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2009-03-19 23:01:12 +0000
commitde95e59c2b53a315e2c9864ae2dbe1f2cfd4a415 (patch)
tree1a2db28886b4cfa60585265162bf6fe8d135694c /webkit/port
parent8f9ea958d1b9a2d2c3330b19f7658ecf7ad5796e (diff)
downloadchromium_src-de95e59c2b53a315e2c9864ae2dbe1f2cfd4a415.zip
chromium_src-de95e59c2b53a315e2c9864ae2dbe1f2cfd4a415.tar.gz
chromium_src-de95e59c2b53a315e2c9864ae2dbe1f2cfd4a415.tar.bz2
Pre-upstreaming style changes to match webkit style.
Review URL: http://codereview.chromium.org/48169 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@12169 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'webkit/port')
-rw-r--r--webkit/port/bindings/v8/V8XMLHttpRequestCustom.cpp1314
-rw-r--r--webkit/port/bindings/v8/v8_nodefilter.cpp121
-rw-r--r--webkit/port/bindings/v8/v8_nodefilter.h69
3 files changed, 743 insertions, 761 deletions
diff --git a/webkit/port/bindings/v8/V8XMLHttpRequestCustom.cpp b/webkit/port/bindings/v8/V8XMLHttpRequestCustom.cpp
index c613dee..b709ea0 100644
--- a/webkit/port/bindings/v8/V8XMLHttpRequestCustom.cpp
+++ b/webkit/port/bindings/v8/V8XMLHttpRequestCustom.cpp
@@ -1,483 +1,454 @@
-// Copyright (c) 2008, 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.
+/*
+ * 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 "v8_binding.h"
-#include "v8_custom.h"
-#include "v8_proxy.h"
-
+#include "ExceptionCode.h"
+#include "Frame.h"
+#include "V8Binding.h"
#include "V8Document.h"
+#include "V8CustomBinding.h"
#include "V8HTMLDocument.h"
#include "V8ObjectEventListener.h"
-
-#include "ExceptionCode.h"
-#include "Frame.h"
+#include "V8Proxy.h"
#include "XMLHttpRequest.h"
#include "XMLHttpRequestUpload.h"
+#include <wtf/Assertions.h>
+
namespace WebCore {
-CALLBACK_FUNC_DECL(XMLHttpRequestConstructor) {
- INC_STATS("DOM.XMLHttpRequest.Constructor");
+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> xhr = XMLHttpRequest::create(doc);
- V8Proxy::SetDOMWrapper(args.Holder(),
- V8ClassIndex::ToInt(V8ClassIndex::XMLHTTPREQUEST), xhr.get());
- // Add object to the wrapper map.
- xhr->ref();
- V8Proxy::SetJSWrapperForActiveDOMObject(xhr.get(),
- v8::Persistent<v8::Object>::New(args.Holder()));
- return args.Holder();
+ 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 xhr object.
-static void CreateHiddenXHRDependency(v8::Local<v8::Object> xhr,
- v8::Local<v8::Value> value) {
- ASSERT(V8Proxy::GetDOMWrapperType(xhr) == V8ClassIndex::XMLHTTPREQUEST ||
- V8Proxy::GetDOMWrapperType(xhr) == V8ClassIndex::XMLHTTPREQUESTUPLOAD);
- v8::Local<v8::Value> cache =
- xhr->GetInternalField(V8Custom::kXMLHttpRequestCacheIndex);
- if (cache->IsNull() || cache->IsUndefined()) {
- cache = v8::Array::New();
- xhr->SetInternalField(V8Custom::kXMLHttpRequestCacheIndex, cache);
- }
-
- v8::Local<v8::Array> cache_array = v8::Local<v8::Array>::Cast(cache);
- cache_array->Set(v8::Integer::New(cache_array->Length()), value);
-}
-
-static void RemoveHiddenXHRDependency(v8::Local<v8::Object> xhr,
- v8::Local<v8::Value> value) {
- ASSERT(V8Proxy::GetDOMWrapperType(xhr) == V8ClassIndex::XMLHTTPREQUEST ||
- V8Proxy::GetDOMWrapperType(xhr) == V8ClassIndex::XMLHTTPREQUESTUPLOAD);
- v8::Local<v8::Value> cache =
- xhr->GetInternalField(V8Custom::kXMLHttpRequestCacheIndex);
- ASSERT(cache->IsArray());
- v8::Local<v8::Array> cache_array = v8::Local<v8::Array>::Cast(cache);
- for (int i = cache_array->Length() - 1; i >= 0; i--) {
- v8::Local<v8::Value> cached = cache_array->Get(v8::Integer::New(i));
- if (cached->StrictEquals(value)) {
- cache_array->Delete(i);
- return;
- }
- }
-
- // We should only get here if we try to remove an event listener that was
- // never added.
-}
-
-ACCESSOR_GETTER(XMLHttpRequestOnabort) {
- INC_STATS("DOM.XMLHttpRequest.onabort._get");
- XMLHttpRequest* imp = V8Proxy::ToNativeObject<XMLHttpRequest>(
- V8ClassIndex::XMLHTTPREQUEST, info.Holder());
- if (imp->onabort()) {
- V8ObjectEventListener* listener =
- static_cast<V8ObjectEventListener*>(imp->onabort());
- v8::Local<v8::Object> v8_listener = listener->getListenerObject();
- return v8_listener;
- }
- return v8::Undefined();
-}
-
-ACCESSOR_SETTER(XMLHttpRequestOnabort) {
- INC_STATS("DOM.XMLHttpRequest.onabort._set");
- XMLHttpRequest* imp = V8Proxy::ToNativeObject<XMLHttpRequest>(
- V8ClassIndex::XMLHTTPREQUEST, info.Holder());
- if (value->IsNull()) {
- if (imp->onabort()) {
- V8ObjectEventListener* listener =
- static_cast<V8ObjectEventListener*>(imp->onabort());
- v8::Local<v8::Object> v8_listener = listener->getListenerObject();
- RemoveHiddenXHRDependency(info.Holder(), v8_listener);
- }
-
- // Clear the listener
- imp->setOnabort(0);
- } else {
- V8Proxy* proxy = V8Proxy::retrieve(imp->scriptExecutionContext());
- if (!proxy)
- return;
+// 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);
+ }
- RefPtr<EventListener> listener =
- proxy->FindOrCreateObjectEventListener(value, false);
- if (listener) {
- imp->setOnabort(listener);
- CreateHiddenXHRDependency(info.Holder(), value);
- }
- }
-}
-
-ACCESSOR_GETTER(XMLHttpRequestOnerror) {
- INC_STATS("DOM.XMLHttpRequest.onerror._get");
- XMLHttpRequest* imp = V8Proxy::ToNativeObject<XMLHttpRequest>(
- V8ClassIndex::XMLHTTPREQUEST, info.Holder());
- if (imp->onerror()) {
- RefPtr<V8ObjectEventListener> listener =
- static_cast<V8ObjectEventListener*>(imp->onerror());
- v8::Local<v8::Object> v8_listener = listener->getListenerObject();
- return v8_listener;
- }
- return v8::Undefined();
-}
-
-ACCESSOR_SETTER(XMLHttpRequestOnerror) {
- INC_STATS("DOM.XMLHttpRequest.onerror._set");
- XMLHttpRequest* imp = V8Proxy::ToNativeObject<XMLHttpRequest>(
- V8ClassIndex::XMLHTTPREQUEST, info.Holder());
- if (value->IsNull()) {
- if (imp->onerror()) {
- V8ObjectEventListener* listener =
- static_cast<V8ObjectEventListener*>(imp->onerror());
- v8::Local<v8::Object> v8_listener = listener->getListenerObject();
- RemoveHiddenXHRDependency(info.Holder(), v8_listener);
- }
-
- // Clear the listener
- imp->setOnerror(0);
- } else {
- V8Proxy* proxy = V8Proxy::retrieve(imp->scriptExecutionContext());
- if (!proxy)
- return;
+ v8::Local<v8::Array> cacheArray = v8::Local<v8::Array>::Cast(cache);
+ cacheArray->Set(v8::Integer::New(cacheArray->Length()), value);
+}
- RefPtr<EventListener> listener =
- proxy->FindOrCreateObjectEventListener(value, false);
- if (listener) {
- imp->setOnerror(listener);
- CreateHiddenXHRDependency(info.Holder(), 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(XMLHttpRequestOnload) {
- INC_STATS("DOM.XMLHttpRequest.onload._get");
- XMLHttpRequest* imp = V8Proxy::ToNativeObject<XMLHttpRequest>(
- V8ClassIndex::XMLHTTPREQUEST, info.Holder());
- if (imp->onload()) {
- V8ObjectEventListener* listener =
- static_cast<V8ObjectEventListener*>(imp->onload());
- v8::Local<v8::Object> v8_listener = listener->getListenerObject();
- return v8_listener;
- }
- return v8::Undefined();
+ACCESSOR_GETTER(XMLHttpRequestOnabort)
+{
+ INC_STATS("DOM.XMLHttpRequest.onabort._get");
+ XMLHttpRequest* xmlHttpRequest = V8Proxy::ToNativeObject<XMLHttpRequest>(V8ClassIndex::XMLHTTPREQUEST, info.Holder());
+ if (xmlHttpRequest->onabort()) {
+ V8ObjectEventListener* listener = static_cast<V8ObjectEventListener*>(xmlHttpRequest->onabort());
+ v8::Local<v8::Object> v8Listener = listener->getListenerObject();
+ return v8Listener;
+ }
+ return v8::Undefined();
}
-ACCESSOR_SETTER(XMLHttpRequestOnload)
+ACCESSOR_SETTER(XMLHttpRequestOnabort)
{
- INC_STATS("DOM.XMLHttpRequest.onload._set");
- XMLHttpRequest* imp = V8Proxy::ToNativeObject<XMLHttpRequest>(
- V8ClassIndex::XMLHTTPREQUEST, info.Holder());
- if (value->IsNull()) {
- if (imp->onload()) {
- V8ObjectEventListener* listener = static_cast<V8ObjectEventListener*>(imp->onload());
- v8::Local<v8::Object> v8_listener = listener->getListenerObject();
- RemoveHiddenXHRDependency(info.Holder(), v8_listener);
+ INC_STATS("DOM.XMLHttpRequest.onabort._set");
+ XMLHttpRequest* xmlHttpRequest = V8Proxy::ToNativeObject<XMLHttpRequest>(V8ClassIndex::XMLHTTPREQUEST, info.Holder());
+ if (value->IsNull()) {
+ if (xmlHttpRequest->onabort()) {
+ V8ObjectEventListener* listener = static_cast<V8ObjectEventListener*>(xmlHttpRequest->onabort());
+ v8::Local<v8::Object> v8Listener = listener->getListenerObject();
+ RemoveHiddenXHRDependency(info.Holder(), v8Listener);
+ }
+
+ // Clear the listener.
+ xmlHttpRequest->setOnabort(0);
+ } else {
+ V8Proxy* proxy = V8Proxy::retrieve(xmlHttpRequest->scriptExecutionContext());
+ if (!proxy)
+ return;
+
+ RefPtr<EventListener> listener = proxy->FindOrCreateObjectEventListener(value, false);
+ if (listener) {
+ xmlHttpRequest->setOnabort(listener);
+ CreateHiddenXHRDependency(info.Holder(), value);
+ }
}
+}
- imp->setOnload(0);
+ACCESSOR_GETTER(XMLHttpRequestOnerror)
+{
+ INC_STATS("DOM.XMLHttpRequest.onerror._get");
+ XMLHttpRequest* xmlHttpRequest = V8Proxy::ToNativeObject<XMLHttpRequest>(V8ClassIndex::XMLHTTPREQUEST, info.Holder());
+ if (xmlHttpRequest->onerror()) {
+ RefPtr<V8ObjectEventListener> listener = static_cast<V8ObjectEventListener*>(xmlHttpRequest->onerror());
+ v8::Local<v8::Object> v8Listener = listener->getListenerObject();
+ return v8Listener;
+ }
+ return v8::Undefined();
+}
- } else {
- V8Proxy* proxy = V8Proxy::retrieve(imp->scriptExecutionContext());
- if (!proxy)
- return;
+ACCESSOR_SETTER(XMLHttpRequestOnerror)
+{
+ INC_STATS("DOM.XMLHttpRequest.onerror._set");
+ XMLHttpRequest* xmlHttpRequest = V8Proxy::ToNativeObject<XMLHttpRequest>(V8ClassIndex::XMLHTTPREQUEST, info.Holder());
+ if (value->IsNull()) {
+ if (xmlHttpRequest->onerror()) {
+ V8ObjectEventListener* listener = static_cast<V8ObjectEventListener*>(xmlHttpRequest->onerror());
+ v8::Local<v8::Object> v8Listener = listener->getListenerObject();
+ RemoveHiddenXHRDependency(info.Holder(), v8Listener);
+ }
+
+ // Clear the listener.
+ xmlHttpRequest->setOnerror(0);
+ } else {
+ V8Proxy* proxy = V8Proxy::retrieve(xmlHttpRequest->scriptExecutionContext());
+ if (!proxy)
+ return;
+
+ RefPtr<EventListener> listener = proxy->FindOrCreateObjectEventListener(value, false);
+ if (listener) {
+ xmlHttpRequest->setOnerror(listener);
+ CreateHiddenXHRDependency(info.Holder(), value);
+ }
+ }
+}
- RefPtr<EventListener> listener =
- proxy->FindOrCreateObjectEventListener(value, false);
- if (listener) {
- imp->setOnload(listener.get());
- CreateHiddenXHRDependency(info.Holder(), value);
- }
- }
-}
-
-ACCESSOR_GETTER(XMLHttpRequestOnloadstart) {
- INC_STATS("DOM.XMLHttpRequest.onloadstart._get");
- XMLHttpRequest* imp = V8Proxy::ToNativeObject<XMLHttpRequest>(
- V8ClassIndex::XMLHTTPREQUEST, info.Holder());
- if (imp->onloadstart()) {
- V8ObjectEventListener* listener =
- static_cast<V8ObjectEventListener*>(imp->onloadstart());
- v8::Local<v8::Object> v8_listener = listener->getListenerObject();
- return v8_listener;
- }
- return v8::Undefined();
-}
-
-ACCESSOR_SETTER(XMLHttpRequestOnloadstart) {
- INC_STATS("DOM.XMLHttpRequest.onloadstart._set");
- XMLHttpRequest* imp = V8Proxy::ToNativeObject<XMLHttpRequest>(
- V8ClassIndex::XMLHTTPREQUEST, info.Holder());
- if (value->IsNull()) {
- if (imp->onloadstart()) {
- V8ObjectEventListener* listener =
- static_cast<V8ObjectEventListener*>(imp->onloadstart());
- v8::Local<v8::Object> v8_listener = listener->getListenerObject();
- RemoveHiddenXHRDependency(info.Holder(), v8_listener);
- }
-
- // Clear the listener
- imp->setOnloadstart(0);
- } else {
- V8Proxy* proxy = V8Proxy::retrieve(imp->scriptExecutionContext());
- if (!proxy)
- return;
+ACCESSOR_GETTER(XMLHttpRequestOnload)
+{
+ INC_STATS("DOM.XMLHttpRequest.onload._get");
+ XMLHttpRequest* xmlHttpRequest = V8Proxy::ToNativeObject<XMLHttpRequest>(V8ClassIndex::XMLHTTPREQUEST, info.Holder());
+ if (xmlHttpRequest->onload()) {
+ V8ObjectEventListener* listener = static_cast<V8ObjectEventListener*>(xmlHttpRequest->onload());
+ v8::Local<v8::Object> v8Listener = listener->getListenerObject();
+ return v8Listener;
+ }
+ return v8::Undefined();
+}
- RefPtr<EventListener> listener =
- proxy->FindOrCreateObjectEventListener(value, false);
- if (listener) {
- imp->setOnloadstart(listener);
- CreateHiddenXHRDependency(info.Holder(), value);
- }
- }
-}
-
-ACCESSOR_GETTER(XMLHttpRequestOnprogress) {
- INC_STATS("DOM.XMLHttpRequest.onprogress._get");
- XMLHttpRequest* imp = V8Proxy::ToNativeObject<XMLHttpRequest>(
- V8ClassIndex::XMLHTTPREQUEST, info.Holder());
- if (imp->onprogress()) {
- V8ObjectEventListener* listener =
- static_cast<V8ObjectEventListener*>(imp->onprogress());
- v8::Local<v8::Object> v8_listener = listener->getListenerObject();
- return v8_listener;
- }
- return v8::Undefined();
-}
-
-ACCESSOR_SETTER(XMLHttpRequestOnprogress) {
- INC_STATS("DOM.XMLHttpRequest.onprogress._set");
- XMLHttpRequest* imp = V8Proxy::ToNativeObject<XMLHttpRequest>(
- V8ClassIndex::XMLHTTPREQUEST, info.Holder());
- if (value->IsNull()) {
- if (imp->onprogress()) {
- V8ObjectEventListener* listener =
- static_cast<V8ObjectEventListener*>(imp->onprogress());
- v8::Local<v8::Object> v8_listener = listener->getListenerObject();
- RemoveHiddenXHRDependency(info.Holder(), v8_listener);
- }
-
- // Clear the listener
- imp->setOnprogress(0);
- } else {
- V8Proxy* proxy = V8Proxy::retrieve(imp->scriptExecutionContext());
- if (!proxy)
- return;
+ACCESSOR_SETTER(XMLHttpRequestOnload)
+{
+ INC_STATS("DOM.XMLHttpRequest.onload._set");
+ XMLHttpRequest* xmlHttpRequest = V8Proxy::ToNativeObject<XMLHttpRequest>(V8ClassIndex::XMLHTTPREQUEST, info.Holder());
+ if (value->IsNull()) {
+ if (xmlHttpRequest->onload()) {
+ V8ObjectEventListener* listener = static_cast<V8ObjectEventListener*>(xmlHttpRequest->onload());
+ v8::Local<v8::Object> v8Listener = listener->getListenerObject();
+ RemoveHiddenXHRDependency(info.Holder(), v8Listener);
+ }
+
+ xmlHttpRequest->setOnload(0);
+
+ } else {
+ V8Proxy* proxy = V8Proxy::retrieve(xmlHttpRequest->scriptExecutionContext());
+ if (!proxy)
+ return;
+
+ RefPtr<EventListener> listener = proxy->FindOrCreateObjectEventListener(value, false);
+ if (listener) {
+ xmlHttpRequest->setOnload(listener.get());
+ CreateHiddenXHRDependency(info.Holder(), value);
+ }
+ }
+}
- RefPtr<EventListener> listener =
- proxy->FindOrCreateObjectEventListener(value, false);
- if (listener) {
- imp->setOnprogress(listener);
- CreateHiddenXHRDependency(info.Holder(), value);
+ACCESSOR_GETTER(XMLHttpRequestOnloadstart)
+{
+ INC_STATS("DOM.XMLHttpRequest.onloadstart._get");
+ XMLHttpRequest* xmlHttpRequest = V8Proxy::ToNativeObject<XMLHttpRequest>(V8ClassIndex::XMLHTTPREQUEST, info.Holder());
+ if (xmlHttpRequest->onloadstart()) {
+ V8ObjectEventListener* listener = static_cast<V8ObjectEventListener*>(xmlHttpRequest->onloadstart());
+ v8::Local<v8::Object> v8Listener = listener->getListenerObject();
+ return v8Listener;
}
- }
+ return v8::Undefined();
}
-ACCESSOR_GETTER(XMLHttpRequestOnreadystatechange) {
- INC_STATS("DOM.XMLHttpRequest.onreadystatechange._get");
- XMLHttpRequest* imp = V8Proxy::ToNativeObject<XMLHttpRequest>(
- V8ClassIndex::XMLHTTPREQUEST, info.Holder());
- if (imp->onreadystatechange()) {
- V8ObjectEventListener* listener =
- static_cast<V8ObjectEventListener*>(imp->onreadystatechange());
- v8::Local<v8::Object> v8_listener = listener->getListenerObject();
- return v8_listener;
- }
- return v8::Undefined();
+ACCESSOR_SETTER(XMLHttpRequestOnloadstart)
+{
+ INC_STATS("DOM.XMLHttpRequest.onloadstart._set");
+ XMLHttpRequest* xmlHttpRequest = V8Proxy::ToNativeObject<XMLHttpRequest>(V8ClassIndex::XMLHTTPREQUEST, info.Holder());
+ if (value->IsNull()) {
+ if (xmlHttpRequest->onloadstart()) {
+ V8ObjectEventListener* listener = static_cast<V8ObjectEventListener*>(xmlHttpRequest->onloadstart());
+ v8::Local<v8::Object> v8Listener = listener->getListenerObject();
+ RemoveHiddenXHRDependency(info.Holder(), v8Listener);
+ }
+
+ // Clear the listener.
+ xmlHttpRequest->setOnloadstart(0);
+ } else {
+ V8Proxy* proxy = V8Proxy::retrieve(xmlHttpRequest->scriptExecutionContext());
+ if (!proxy)
+ return;
+
+ RefPtr<EventListener> listener = proxy->FindOrCreateObjectEventListener(value, false);
+ if (listener) {
+ xmlHttpRequest->setOnloadstart(listener);
+ CreateHiddenXHRDependency(info.Holder(), value);
+ }
+ }
}
-ACCESSOR_SETTER(XMLHttpRequestOnreadystatechange)
+ACCESSOR_GETTER(XMLHttpRequestOnprogress)
{
- INC_STATS("DOM.XMLHttpRequest.onreadystatechange._set");
- XMLHttpRequest* imp = V8Proxy::ToNativeObject<XMLHttpRequest>(
- V8ClassIndex::XMLHTTPREQUEST, info.Holder());
- if (value->IsNull()) {
- if (imp->onreadystatechange()) {
- V8ObjectEventListener* listener =
- static_cast<V8ObjectEventListener*>(imp->onreadystatechange());
- v8::Local<v8::Object> v8_listener = listener->getListenerObject();
- RemoveHiddenXHRDependency(info.Holder(), v8_listener);
- }
-
- // Clear the listener
- imp->setOnreadystatechange(0);
- } else {
- V8Proxy* proxy = V8Proxy::retrieve(imp->scriptExecutionContext());
- if (!proxy)
- return;
+ INC_STATS("DOM.XMLHttpRequest.onprogress._get");
+ XMLHttpRequest* xmlHttpRequest = V8Proxy::ToNativeObject<XMLHttpRequest>(V8ClassIndex::XMLHTTPREQUEST, info.Holder());
+ if (xmlHttpRequest->onprogress()) {
+ V8ObjectEventListener* listener = static_cast<V8ObjectEventListener*>(xmlHttpRequest->onprogress());
+ v8::Local<v8::Object> v8Listener = listener->getListenerObject();
+ return v8Listener;
+ }
+ return v8::Undefined();
+}
- RefPtr<EventListener> listener =
- proxy->FindOrCreateObjectEventListener(value, false);
- if (listener) {
- imp->setOnreadystatechange(listener.get());
- CreateHiddenXHRDependency(info.Holder(), value);
+ACCESSOR_SETTER(XMLHttpRequestOnprogress)
+{
+ INC_STATS("DOM.XMLHttpRequest.onprogress._set");
+ XMLHttpRequest* xmlHttpRequest = V8Proxy::ToNativeObject<XMLHttpRequest>(V8ClassIndex::XMLHTTPREQUEST, info.Holder());
+ if (value->IsNull()) {
+ if (xmlHttpRequest->onprogress()) {
+ V8ObjectEventListener* listener = static_cast<V8ObjectEventListener*>(xmlHttpRequest->onprogress());
+ v8::Local<v8::Object> v8Listener = listener->getListenerObject();
+ RemoveHiddenXHRDependency(info.Holder(), v8Listener);
+ }
+
+ // Clear the listener.
+ xmlHttpRequest->setOnprogress(0);
+ } else {
+ V8Proxy* proxy = V8Proxy::retrieve(xmlHttpRequest->scriptExecutionContext());
+ if (!proxy)
+ return;
+
+ RefPtr<EventListener> listener = proxy->FindOrCreateObjectEventListener(value, false);
+ if (listener) {
+ xmlHttpRequest->setOnprogress(listener);
+ CreateHiddenXHRDependency(info.Holder(), value);
+ }
+ }
+}
+
+ACCESSOR_GETTER(XMLHttpRequestOnreadystatechange)
+{
+ INC_STATS("DOM.XMLHttpRequest.onreadystatechange._get");
+ XMLHttpRequest* xmlHttpRequest = V8Proxy::ToNativeObject<XMLHttpRequest>(V8ClassIndex::XMLHTTPREQUEST, info.Holder());
+ if (xmlHttpRequest->onreadystatechange()) {
+ V8ObjectEventListener* listener = static_cast<V8ObjectEventListener*>(xmlHttpRequest->onreadystatechange());
+ v8::Local<v8::Object> v8Listener = listener->getListenerObject();
+ return v8Listener;
+ }
+ return v8::Undefined();
+}
+
+ACCESSOR_SETTER(XMLHttpRequestOnreadystatechange)
+{
+ INC_STATS("DOM.XMLHttpRequest.onreadystatechange._set");
+ XMLHttpRequest* xmlHttpRequest = V8Proxy::ToNativeObject<XMLHttpRequest>(V8ClassIndex::XMLHTTPREQUEST, info.Holder());
+ if (value->IsNull()) {
+ if (xmlHttpRequest->onreadystatechange()) {
+ V8ObjectEventListener* listener = static_cast<V8ObjectEventListener*>(xmlHttpRequest->onreadystatechange());
+ v8::Local<v8::Object> v8Listener = listener->getListenerObject();
+ RemoveHiddenXHRDependency(info.Holder(), v8Listener);
+ }
+
+ // Clear the listener.
+ xmlHttpRequest->setOnreadystatechange(0);
+ } else {
+ V8Proxy* proxy = V8Proxy::retrieve(xmlHttpRequest->scriptExecutionContext());
+ if (!proxy)
+ return;
+
+ RefPtr<EventListener> listener = proxy->FindOrCreateObjectEventListener(value, false);
+ if (listener) {
+ xmlHttpRequest->setOnreadystatechange(listener.get());
+ CreateHiddenXHRDependency(info.Holder(), value);
+ }
}
- }
}
ACCESSOR_GETTER(XMLHttpRequestResponseText)
{
- // 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* imp = V8Proxy::ToNativeObject<XMLHttpRequest>(
- V8ClassIndex::XMLHTTPREQUEST, info.Holder());
- return v8StringOrNull(imp->responseText());
+ // 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());
+ return v8StringOrNull(xmlHttpRequest->responseText());
}
CALLBACK_FUNC_DECL(XMLHttpRequestAddEventListener)
{
- INC_STATS("DOM.XMLHttpRequest.addEventListener()");
- XMLHttpRequest* imp = V8Proxy::ToNativeObject<XMLHttpRequest>(
- V8ClassIndex::XMLHTTPREQUEST, args.Holder());
+ INC_STATS("DOM.XMLHttpRequest.addEventListener()");
+ XMLHttpRequest* xmlHttpRequest = V8Proxy::ToNativeObject<XMLHttpRequest>(V8ClassIndex::XMLHTTPREQUEST, args.Holder());
- V8Proxy* proxy = V8Proxy::retrieve(imp->scriptExecutionContext());
- if (!proxy)
- return v8::Undefined();
+ 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();
- imp->addEventListener(type, listener, useCapture);
+ RefPtr<EventListener> listener = proxy->FindOrCreateObjectEventListener(args[1], false);
+ if (listener) {
+ String type = toWebCoreString(args[0]);
+ bool useCapture = args[2]->BooleanValue();
+ xmlHttpRequest->addEventListener(type, listener, useCapture);
- CreateHiddenXHRDependency(args.Holder(), args[1]);
- }
- return v8::Undefined();
+ CreateHiddenXHRDependency(args.Holder(), args[1]);
+ }
+ return v8::Undefined();
}
-CALLBACK_FUNC_DECL(XMLHttpRequestRemoveEventListener) {
- INC_STATS("DOM.XMLHttpRequest.removeEventListener()");
- XMLHttpRequest* imp = V8Proxy::ToNativeObject<XMLHttpRequest>(
- V8ClassIndex::XMLHTTPREQUEST, args.Holder());
+CALLBACK_FUNC_DECL(XMLHttpRequestRemoveEventListener)
+{
+ INC_STATS("DOM.XMLHttpRequest.removeEventListener()");
+ XMLHttpRequest* xmlHttpRequest = V8Proxy::ToNativeObject<XMLHttpRequest>(V8ClassIndex::XMLHTTPREQUEST, args.Holder());
- V8Proxy* proxy = V8Proxy::retrieve(imp->scriptExecutionContext());
- if (!proxy)
- return v8::Undefined(); // probably leaked
+ V8Proxy* proxy = V8Proxy::retrieve(xmlHttpRequest->scriptExecutionContext());
+ if (!proxy)
+ return v8::Undefined(); // Probably leaked.
- RefPtr<EventListener> listener =
- proxy->FindObjectEventListener(args[1], false);
+ RefPtr<EventListener> listener = proxy->FindObjectEventListener(args[1], false);
- if (listener) {
- String type = ToWebCoreString(args[0]);
- bool useCapture = args[2]->BooleanValue();
- imp->removeEventListener(type, listener.get(), useCapture);
+ if (listener) {
+ String type = toWebCoreString(args[0]);
+ bool useCapture = args[2]->BooleanValue();
+ xmlHttpRequest->removeEventListener(type, listener.get(), useCapture);
- RemoveHiddenXHRDependency(args.Holder(), args[1]);
- }
+ RemoveHiddenXHRDependency(args.Holder(), args[1]);
+ }
- return v8::Undefined();
+ return v8::Undefined();
}
CALLBACK_FUNC_DECL(XMLHttpRequestOpen)
{
- INC_STATS("DOM.XMLHttpRequest.open()");
- // Four cases:
- // open(method, url)
- // open(method, url, async)
- // open(method, url, async, user)
- // open(method, url, async, user, passwd)
-
- if (args.Length() < 2) {
- V8Proxy::ThrowError(V8Proxy::SYNTAX_ERROR, "Not enough arguments");
- return v8::Undefined();
- }
+ INC_STATS("DOM.XMLHttpRequest.open()");
+ // Four cases:
+ // open(method, url)
+ // open(method, url, async)
+ // open(method, url, async, user)
+ // open(method, url, async, user, passwd)
+
+ if (args.Length() < 2) {
+ V8Proxy::ThrowError(V8Proxy::SYNTAX_ERROR, "Not enough arguments");
+ return v8::Undefined();
+ }
- // get the implementation
- XMLHttpRequest* xhr = V8Proxy::ToNativeObject<XMLHttpRequest>(
- V8ClassIndex::XMLHTTPREQUEST, args.Holder());
+ XMLHttpRequest* xmlHttpRequest = V8Proxy::ToNativeObject<XMLHttpRequest>(V8ClassIndex::XMLHTTPREQUEST, args.Holder());
- // retrieve parameters
- String method = ToWebCoreString(args[0]);
- String urlstring = ToWebCoreString(args[1]);
- V8Proxy* proxy = V8Proxy::retrieve();
- KURL url = proxy->frame()->document()->completeURL(urlstring);
+ String method = toWebCoreString(args[0]);
+ String urlstring = toWebCoreString(args[1]);
+ V8Proxy* proxy = V8Proxy::retrieve();
+ KURL url = proxy->frame()->document()->completeURL(urlstring);
- bool async = (args.Length() < 3) ? true : args[2]->BooleanValue();
+ bool async = (args.Length() < 3) ? true : args[2]->BooleanValue();
- ExceptionCode ec = 0;
- String user, passwd;
- if (args.Length() >= 4 && !args[3]->IsUndefined()) {
- user = valueToStringWithNullCheck(args[3]);
+ ExceptionCode ec = 0;
+ String user, passwd;
+ if (args.Length() >= 4 && !args[3]->IsUndefined()) {
+ user = valueToStringWithNullCheck(args[3]);
- if (args.Length() >= 5 && !args[4]->IsUndefined()) {
- passwd = valueToStringWithNullCheck(args[4]);
- xhr->open(method, url, async, user, passwd, ec);
+ if (args.Length() >= 5 && !args[4]->IsUndefined()) {
+ passwd = valueToStringWithNullCheck(args[4]);
+ xmlHttpRequest->open(method, url, async, user, passwd, ec);
+ } else
+ xmlHttpRequest->open(method, url, async, user, ec);
} else
- xhr->open(method, url, async, user, ec);
- } else
- xhr->open(method, url, async, ec);
+ xmlHttpRequest->open(method, url, async, ec);
- if (ec != 0) {
- V8Proxy::SetDOMException(ec);
- return v8::Handle<v8::Value>();
- }
+ if (ec) {
+ V8Proxy::SetDOMException(ec);
+ return v8::Handle<v8::Value>();
+ }
- return v8::Undefined();
+ return v8::Undefined();
}
static bool IsDocumentType(v8::Handle<v8::Value> value)
{
- // TODO(fqian): add other document types.
+ // FIXME: add other document types.
return V8Document::HasInstance(value) || V8HTMLDocument::HasInstance(value);
}
CALLBACK_FUNC_DECL(XMLHttpRequestSend)
{
INC_STATS("DOM.XMLHttpRequest.send()");
- XMLHttpRequest* xhr = V8Proxy::ToNativeObject<XMLHttpRequest>(
- V8ClassIndex::XMLHTTPREQUEST, args.Holder());
+ XMLHttpRequest* xmlHttpRequest = V8Proxy::ToNativeObject<XMLHttpRequest>(V8ClassIndex::XMLHTTPREQUEST, args.Holder());
ExceptionCode ec = 0;
if (args.Length() < 1)
- xhr->send(ec);
+ xmlHttpRequest->send(ec);
else {
v8::Handle<v8::Value> arg = args[0];
- // TODO(eseidel): upstream handles "File" objects too
+ // FIXME: upstream handles "File" objects too.
if (IsDocumentType(arg)) {
- v8::Handle<v8::Object> obj = v8::Handle<v8::Object>::Cast(arg);
- Document* doc = V8Proxy::DOMWrapperToNode<Document>(obj);
- ASSERT(doc);
- xhr->send(doc, ec);
+ v8::Handle<v8::Object> object = v8::Handle<v8::Object>::Cast(arg);
+ Document* document = V8Proxy::DOMWrapperToNode<Document>(object);
+ ASSERT(document);
+ xmlHttpRequest->send(document, ec);
} else
- xhr->send(valueToStringWithNullCheck(arg), ec);
+ xmlHttpRequest->send(valueToStringWithNullCheck(arg), ec);
}
if (ec) {
@@ -489,329 +460,310 @@ CALLBACK_FUNC_DECL(XMLHttpRequestSend)
}
CALLBACK_FUNC_DECL(XMLHttpRequestSetRequestHeader) {
- INC_STATS("DOM.XMLHttpRequest.setRequestHeader()");
- if (args.Length() < 2) {
- V8Proxy::ThrowError(V8Proxy::SYNTAX_ERROR, "Not enough arguments");
- return v8::Undefined();
- }
-
- XMLHttpRequest* imp = V8Proxy::ToNativeObject<XMLHttpRequest>(
- V8ClassIndex::XMLHTTPREQUEST, args.Holder());
- ExceptionCode ec = 0;
- String header = ToWebCoreString(args[0]);
- String value = ToWebCoreString(args[1]);
- imp->setRequestHeader(header, value, ec);
- if (ec != 0) {
- V8Proxy::SetDOMException(ec);
- return v8::Handle<v8::Value>();
- }
- return v8::Undefined();
-}
-
-CALLBACK_FUNC_DECL(XMLHttpRequestGetResponseHeader) {
- INC_STATS("DOM.XMLHttpRequest.getResponseHeader()");
- if (args.Length() < 1) {
- V8Proxy::ThrowError(V8Proxy::SYNTAX_ERROR, "Not enough arguments");
+ INC_STATS("DOM.XMLHttpRequest.setRequestHeader()");
+ if (args.Length() < 2) {
+ V8Proxy::ThrowError(V8Proxy::SYNTAX_ERROR, "Not enough arguments");
+ return v8::Undefined();
+ }
+
+ XMLHttpRequest* xmlHttpRequest = V8Proxy::ToNativeObject<XMLHttpRequest>(V8ClassIndex::XMLHTTPREQUEST, args.Holder());
+ ExceptionCode ec = 0;
+ String header = toWebCoreString(args[0]);
+ String value = toWebCoreString(args[1]);
+ xmlHttpRequest->setRequestHeader(header, value, ec);
+ if (ec) {
+ V8Proxy::SetDOMException(ec);
+ return v8::Handle<v8::Value>();
+ }
return v8::Undefined();
- }
+}
+
+CALLBACK_FUNC_DECL(XMLHttpRequestGetResponseHeader)
+{
+ INC_STATS("DOM.XMLHttpRequest.getResponseHeader()");
+ if (args.Length() < 1) {
+ V8Proxy::ThrowError(V8Proxy::SYNTAX_ERROR, "Not enough arguments");
+ return v8::Undefined();
+ }
- XMLHttpRequest* imp = V8Proxy::ToNativeObject<XMLHttpRequest>(
- V8ClassIndex::XMLHTTPREQUEST, args.Holder());
- ExceptionCode ec = 0;
- String header = ToWebCoreString(args[0]);
- String result = imp->getResponseHeader(header, ec);
- if (ec != 0) {
- V8Proxy::SetDOMException(ec);
- return v8::Handle<v8::Value>();
- }
- return v8StringOrNull(result);
+ XMLHttpRequest* xmlHttpRequest = V8Proxy::ToNativeObject<XMLHttpRequest>(V8ClassIndex::XMLHTTPREQUEST, args.Holder());
+ ExceptionCode ec = 0;
+ String header = toWebCoreString(args[0]);
+ String result = xmlHttpRequest->getResponseHeader(header, ec);
+ if (ec) {
+ V8Proxy::SetDOMException(ec);
+ return v8::Handle<v8::Value>();
+ }
+ return v8StringOrNull(result);
}
CALLBACK_FUNC_DECL(XMLHttpRequestOverrideMimeType)
{
- INC_STATS("DOM.XMLHttpRequest.overrideMimeType()");
- if (args.Length() < 1) {
- V8Proxy::ThrowError(V8Proxy::SYNTAX_ERROR, "Not enough arguments");
- return v8::Undefined();
- }
+ INC_STATS("DOM.XMLHttpRequest.overrideMimeType()");
+ if (args.Length() < 1) {
+ V8Proxy::ThrowError(V8Proxy::SYNTAX_ERROR, "Not enough arguments");
+ return v8::Undefined();
+ }
- XMLHttpRequest* imp = V8Proxy::ToNativeObject<XMLHttpRequest>(
- V8ClassIndex::XMLHTTPREQUEST, args.Holder());
- String value = ToWebCoreString(args[0]);
- imp->overrideMimeType(value);
- return v8::Undefined();
+ XMLHttpRequest* xmlHttpRequest = V8Proxy::ToNativeObject<XMLHttpRequest>(V8ClassIndex::XMLHTTPREQUEST, args.Holder());
+ String value = toWebCoreString(args[0]);
+ xmlHttpRequest->overrideMimeType(value);
+ return v8::Undefined();
}
CALLBACK_FUNC_DECL(XMLHttpRequestDispatchEvent)
{
- INC_STATS("DOM.XMLHttpRequest.dispatchEvent()");
- return v8::Undefined();
+ INC_STATS("DOM.XMLHttpRequest.dispatchEvent()");
+ return v8::Undefined();
}
// XMLHttpRequestUpload --------------------------------------------------------
-ACCESSOR_GETTER(XMLHttpRequestUploadOnabort) {
- INC_STATS("DOM.XMLHttpRequestUpload.onabort._get");
- XMLHttpRequestUpload* imp = V8Proxy::ToNativeObject<XMLHttpRequestUpload>(
- V8ClassIndex::XMLHTTPREQUESTUPLOAD, info.Holder());
- if (imp->onabort()) {
- V8ObjectEventListener* listener =
- static_cast<V8ObjectEventListener*>(imp->onabort());
- v8::Local<v8::Object> v8_listener = listener->getListenerObject();
- return v8_listener;
- }
- return v8::Undefined();
-}
-
-ACCESSOR_SETTER(XMLHttpRequestUploadOnabort) {
- INC_STATS("DOM.XMLHttpRequestUpload.onabort._set");
- XMLHttpRequestUpload* imp = V8Proxy::ToNativeObject<XMLHttpRequestUpload>(
- V8ClassIndex::XMLHTTPREQUESTUPLOAD, info.Holder());
- if (value->IsNull()) {
- if (imp->onabort()) {
- V8ObjectEventListener* listener =
- static_cast<V8ObjectEventListener*>(imp->onabort());
- v8::Local<v8::Object> v8_listener = listener->getListenerObject();
- RemoveHiddenXHRDependency(info.Holder(), v8_listener);
- }
-
- // Clear the listener
- imp->setOnabort(0);
- } else {
- XMLHttpRequest* xmlhttprequest = imp->associatedXMLHttpRequest();
- V8Proxy* proxy =
- V8Proxy::retrieve(xmlhttprequest->scriptExecutionContext());
- if (!proxy)
- return;
+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();
+}
- RefPtr<EventListener> listener =
- proxy->FindOrCreateObjectEventListener(value, false);
- if (listener) {
- imp->setOnabort(listener);
- CreateHiddenXHRDependency(info.Holder(), value);
- }
- }
-}
-
-ACCESSOR_GETTER(XMLHttpRequestUploadOnerror) {
- INC_STATS("DOM.XMLHttpRequestUpload.onerror._get");
- XMLHttpRequestUpload* imp = V8Proxy::ToNativeObject<XMLHttpRequestUpload>(
- V8ClassIndex::XMLHTTPREQUESTUPLOAD, info.Holder());
- if (imp->onerror()) {
- V8ObjectEventListener* listener =
- static_cast<V8ObjectEventListener*>(imp->onerror());
- v8::Local<v8::Object> v8_listener = listener->getListenerObject();
- return v8_listener;
- }
- return v8::Undefined();
-}
-
-ACCESSOR_SETTER(XMLHttpRequestUploadOnerror) {
- INC_STATS("DOM.XMLHttpRequestUpload.onerror._set");
- XMLHttpRequestUpload* imp = V8Proxy::ToNativeObject<XMLHttpRequestUpload>(
- V8ClassIndex::XMLHTTPREQUESTUPLOAD, info.Holder());
- if (value->IsNull()) {
- if (imp->onerror()) {
- V8ObjectEventListener* listener =
- static_cast<V8ObjectEventListener*>(imp->onerror());
- v8::Local<v8::Object> v8_listener = listener->getListenerObject();
- RemoveHiddenXHRDependency(info.Holder(), v8_listener);
- }
-
- // Clear the listener
- imp->setOnerror(0);
- } else {
- XMLHttpRequest* xmlhttprequest = imp->associatedXMLHttpRequest();
- V8Proxy* proxy = V8Proxy::retrieve(xmlhttprequest->scriptExecutionContext());
- if (!proxy)
- return;
+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);
+ }
+ }
+}
- RefPtr<EventListener> listener =
- proxy->FindOrCreateObjectEventListener(value, false);
- if (listener) {
- imp->setOnerror(listener);
- CreateHiddenXHRDependency(info.Holder(), value);
- }
- }
-}
-
-ACCESSOR_GETTER(XMLHttpRequestUploadOnload) {
- INC_STATS("DOM.XMLHttpRequestUpload.onload._get");
- XMLHttpRequestUpload* imp = V8Proxy::ToNativeObject<XMLHttpRequestUpload>(
- V8ClassIndex::XMLHTTPREQUESTUPLOAD, info.Holder());
- if (imp->onload()) {
- V8ObjectEventListener* listener =
- static_cast<V8ObjectEventListener*>(imp->onload());
- v8::Local<v8::Object> v8_listener = listener->getListenerObject();
- return v8_listener;
- }
- return v8::Undefined();
-}
-
-ACCESSOR_SETTER(XMLHttpRequestUploadOnload) {
- INC_STATS("DOM.XMLHttpRequestUpload.onload._set");
- XMLHttpRequestUpload* imp = V8Proxy::ToNativeObject<XMLHttpRequestUpload>(
- V8ClassIndex::XMLHTTPREQUESTUPLOAD, info.Holder());
- if (value->IsNull()) {
- if (imp->onload()) {
- V8ObjectEventListener* listener =
- static_cast<V8ObjectEventListener*>(imp->onload());
- v8::Local<v8::Object> v8_listener = listener->getListenerObject();
- RemoveHiddenXHRDependency(info.Holder(), v8_listener);
- }
-
- // Clear the listener
- imp->setOnload(0);
- } else {
- XMLHttpRequest* xmlhttprequest = imp->associatedXMLHttpRequest();
- V8Proxy* proxy = V8Proxy::retrieve(xmlhttprequest->scriptExecutionContext());
- if (!proxy)
- return;
+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();
+}
- RefPtr<EventListener> listener =
- proxy->FindOrCreateObjectEventListener(value, false);
- if (listener) {
- imp->setOnload(listener);
- CreateHiddenXHRDependency(info.Holder(), value);
- }
- }
-}
-
-ACCESSOR_GETTER(XMLHttpRequestUploadOnloadstart) {
- INC_STATS("DOM.XMLHttpRequestUpload.onloadstart._get");
- XMLHttpRequestUpload* imp = V8Proxy::ToNativeObject<XMLHttpRequestUpload>(
- V8ClassIndex::XMLHTTPREQUESTUPLOAD, info.Holder());
- if (imp->onloadstart()) {
- V8ObjectEventListener* listener =
- static_cast<V8ObjectEventListener*>(imp->onloadstart());
- v8::Local<v8::Object> v8_listener = listener->getListenerObject();
- return v8_listener;
- }
- return v8::Undefined();
-}
-
-ACCESSOR_SETTER(XMLHttpRequestUploadOnloadstart) {
- INC_STATS("DOM.XMLHttpRequestUpload.onloadstart._set");
- XMLHttpRequestUpload* imp = V8Proxy::ToNativeObject<XMLHttpRequestUpload>(
- V8ClassIndex::XMLHTTPREQUESTUPLOAD, info.Holder());
- if (value->IsNull()) {
- if (imp->onloadstart()) {
- V8ObjectEventListener* listener =
- static_cast<V8ObjectEventListener*>(imp->onloadstart());
- v8::Local<v8::Object> v8_listener = listener->getListenerObject();
- RemoveHiddenXHRDependency(info.Holder(), v8_listener);
- }
-
- // Clear the listener
- imp->setOnloadstart(0);
- } else {
- XMLHttpRequest* xmlhttprequest = imp->associatedXMLHttpRequest();
- V8Proxy* proxy = V8Proxy::retrieve(xmlhttprequest->scriptExecutionContext());
- if (!proxy)
- return;
+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);
+ }
+ }
+}
- RefPtr<EventListener> listener =
- proxy->FindOrCreateObjectEventListener(value, false);
- if (listener) {
- imp->setOnloadstart(listener);
- CreateHiddenXHRDependency(info.Holder(), value);
- }
- }
-}
-
-ACCESSOR_GETTER(XMLHttpRequestUploadOnprogress) {
- INC_STATS("DOM.XMLHttpRequestUpload.onprogress._get");
- XMLHttpRequestUpload* imp = V8Proxy::ToNativeObject<XMLHttpRequestUpload>(
- V8ClassIndex::XMLHTTPREQUESTUPLOAD, info.Holder());
- if (imp->onprogress()) {
- V8ObjectEventListener* listener =
- static_cast<V8ObjectEventListener*>(imp->onprogress());
- v8::Local<v8::Object> v8_listener = listener->getListenerObject();
- return v8_listener;
- }
- return v8::Undefined();
-}
-
-ACCESSOR_SETTER(XMLHttpRequestUploadOnprogress) {
- INC_STATS("DOM.XMLHttpRequestUpload.onprogress._set");
- XMLHttpRequestUpload* imp = V8Proxy::ToNativeObject<XMLHttpRequestUpload>(
- V8ClassIndex::XMLHTTPREQUESTUPLOAD, info.Holder());
- if (value->IsNull()) {
- if (imp->onprogress()) {
- V8ObjectEventListener* listener =
- static_cast<V8ObjectEventListener*>(imp->onprogress());
- v8::Local<v8::Object> v8_listener = listener->getListenerObject();
- RemoveHiddenXHRDependency(info.Holder(), v8_listener);
- }
-
- // Clear the listener
- imp->setOnprogress(0);
- } else {
- XMLHttpRequest* xmlhttprequest = imp->associatedXMLHttpRequest();
- V8Proxy* proxy = V8Proxy::retrieve(xmlhttprequest->scriptExecutionContext());
- if (!proxy)
- return;
+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();
+}
- RefPtr<EventListener> listener =
- proxy->FindOrCreateObjectEventListener(value, false);
- if (listener) {
- imp->setOnprogress(listener);
- CreateHiddenXHRDependency(info.Holder(), value);
+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();
}
-CALLBACK_FUNC_DECL(XMLHttpRequestUploadAddEventListener) {
- INC_STATS("DOM.XMLHttpRequestUpload.addEventListener()");
- XMLHttpRequestUpload* imp = V8Proxy::ToNativeObject<XMLHttpRequestUpload>(
- V8ClassIndex::XMLHTTPREQUESTUPLOAD, args.Holder());
+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);
+ }
+ }
+}
- XMLHttpRequest* xmlhttprequest = imp->associatedXMLHttpRequest();
- V8Proxy* proxy = V8Proxy::retrieve(xmlhttprequest->scriptExecutionContext());
- if (!proxy)
+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();
- imp->addEventListener(type, listener, useCapture);
+ 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();
+ CreateHiddenXHRDependency(args.Holder(), args[1]);
+ }
+ return v8::Undefined();
}
-CALLBACK_FUNC_DECL(XMLHttpRequestUploadRemoveEventListener) {
- INC_STATS("DOM.XMLHttpRequestUpload.removeEventListener()");
- XMLHttpRequestUpload* imp = V8Proxy::ToNativeObject<XMLHttpRequestUpload>(
- V8ClassIndex::XMLHTTPREQUESTUPLOAD, args.Holder());
+CALLBACK_FUNC_DECL(XMLHttpRequestUploadRemoveEventListener)
+{
+ INC_STATS("DOM.XMLHttpRequestUpload.removeEventListener()");
+ XMLHttpRequestUpload* xmlHttpRequestUpload = V8Proxy::ToNativeObject<XMLHttpRequestUpload>(V8ClassIndex::XMLHTTPREQUESTUPLOAD, args.Holder());
- XMLHttpRequest* xmlhttprequest = imp->associatedXMLHttpRequest();
- V8Proxy* proxy = V8Proxy::retrieve(xmlhttprequest->scriptExecutionContext());
- if (!proxy)
- return v8::Undefined(); // probably leaked
+ 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);
+ RefPtr<EventListener> listener = proxy->FindObjectEventListener(args[1], false);
- if (listener) {
- String type = ToWebCoreString(args[0]);
- bool useCapture = args[2]->BooleanValue();
- imp->removeEventListener(type, listener.get(), useCapture);
+ if (listener) {
+ String type = toWebCoreString(args[0]);
+ bool useCapture = args[2]->BooleanValue();
+ xmlHttpRequestUpload->removeEventListener(type, listener.get(), useCapture);
- RemoveHiddenXHRDependency(args.Holder(), args[1]);
- }
+ RemoveHiddenXHRDependency(args.Holder(), args[1]);
+ }
- return v8::Undefined();
+ return v8::Undefined();
}
-CALLBACK_FUNC_DECL(XMLHttpRequestUploadDispatchEvent) {
- INC_STATS("DOM.XMLHttpRequestUpload.dispatchEvent()");
- V8Proxy::SetDOMException(NOT_SUPPORTED_ERR);
- return v8::Undefined();
+CALLBACK_FUNC_DECL(XMLHttpRequestUploadDispatchEvent)
+{
+ INC_STATS("DOM.XMLHttpRequestUpload.dispatchEvent()");
+ V8Proxy::SetDOMException(NOT_SUPPORTED_ERR);
+ return v8::Undefined();
}
-} // namespace WebCore
+} // namespace WebCore
diff --git a/webkit/port/bindings/v8/v8_nodefilter.cpp b/webkit/port/bindings/v8/v8_nodefilter.cpp
index 34d17c1..e9014e0 100644
--- a/webkit/port/bindings/v8/v8_nodefilter.cpp
+++ b/webkit/port/bindings/v8/v8_nodefilter.cpp
@@ -1,86 +1,89 @@
-// Copyright (c) 2008, 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.
+/*
+ * 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 "v8_nodefilter.h"
-#include "v8_proxy.h"
+
#include "NodeFilter.h"
#include "Node.h"
#include "ScriptState.h"
+#include "V8Proxy.h"
+
+#include <wtf/OwnArrayPtr.h>
namespace WebCore {
-V8NodeFilterCondition::V8NodeFilterCondition(v8::Handle<v8::Value> filter) {
- m_filter = v8::Persistent<v8::Value>::New(filter);
+V8NodeFilterCondition::V8NodeFilterCondition(v8::Handle<v8::Value> filter)
+ : m_filter(v8::Persistent<v8::Value>::New(filter))
+{
#ifndef NDEBUG
- V8Proxy::RegisterGlobalHandle(NODE_FILTER, this, m_filter);
+ V8Proxy::RegisterGlobalHandle(NODE_FILTER, this, m_filter);
#endif
}
-V8NodeFilterCondition::~V8NodeFilterCondition() {
+V8NodeFilterCondition::~V8NodeFilterCondition()
+{
#ifndef NDEBUG
- V8Proxy::UnregisterGlobalHandle(this, m_filter);
+ V8Proxy::UnregisterGlobalHandle(this, m_filter);
#endif
- m_filter.Dispose();
- m_filter.Clear();
+ m_filter.Dispose();
+ m_filter.Clear();
}
-short V8NodeFilterCondition::acceptNode(ScriptState* state,
- Node* node) const {
- ASSERT(v8::Context::InContext());
+short V8NodeFilterCondition::acceptNode(ScriptState* state, Node* node) const
+{
+ ASSERT(v8::Context::InContext());
- if (!m_filter->IsFunction()) return NodeFilter::FILTER_ACCEPT;
+ if (!m_filter->IsFunction())
+ return NodeFilter::FILTER_ACCEPT;
- v8::TryCatch exception_catcher;
+ v8::TryCatch exceptionCatcher;
- v8::Handle<v8::Object> this_obj = v8::Context::GetCurrent()->Global();
- v8::Handle<v8::Function> callback =
- v8::Handle<v8::Function>::Cast(m_filter);
- v8::Handle<v8::Value>* args = new v8::Handle<v8::Value>[1];
- args[0] = V8Proxy::ToV8Object(V8ClassIndex::NODE, node);
+ v8::Handle<v8::Object> object = v8::Context::GetCurrent()->Global();
+ v8::Handle<v8::Function> callback = v8::Handle<v8::Function>::Cast(m_filter);
+ OwnArrayPtr<v8::Handle<v8::Value> > args(new v8::Handle<v8::Value>[1]);
+ args[0] = V8Proxy::ToV8Object(V8ClassIndex::NODE, node);
- V8Proxy* proxy = V8Proxy::retrieve();
- ASSERT(proxy);
+ V8Proxy* proxy = V8Proxy::retrieve();
+ ASSERT(proxy);
- v8::Handle<v8::Value> result =
- proxy->CallFunction(callback, this_obj, 1, args);
- delete[] args;
+ v8::Handle<v8::Value> result = proxy->CallFunction(callback, object, 1, args.get());
- if (exception_catcher.HasCaught()) {
- state->setException(exception_catcher.Exception());
- return NodeFilter::FILTER_REJECT;
- }
+ if (exceptionCatcher.HasCaught()) {
+ state->setException(exceptionCatcher.Exception());
+ return NodeFilter::FILTER_REJECT;
+ }
- ASSERT(!result.IsEmpty());
+ ASSERT(!result.IsEmpty());
- return result->Int32Value();
+ return result->Int32Value();
}
-} // namespace WebCore
+} // namespace WebCore
diff --git a/webkit/port/bindings/v8/v8_nodefilter.h b/webkit/port/bindings/v8/v8_nodefilter.h
index a2bde31..3f4f804 100644
--- a/webkit/port/bindings/v8/v8_nodefilter.h
+++ b/webkit/port/bindings/v8/v8_nodefilter.h
@@ -1,30 +1,57 @@
-// Copyright (c) 2006-2008 The Chromium Authors. All rights reserved.
-// Use of this source code is governed by a BSD-style license that can be
-// found in the LICENSE file.
+/*
+ * Copyright (C) 2006, 2007, 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 V8_NODEFILTER_H__
-#define V8_NODEFILTER_H__
+#ifndef V8NodeFilter_h
+#define V8NodeFilter_h
-#include <v8.h>
#include "NodeFilterCondition.h"
+#include <v8.h>
-// NodeFilter is a JavaScript function that takes a Node as parameter
-// and returns a short (ACCEPT, SKIP, REJECT) as the result.
+// NodeFilter is a JavaScript function that takes a Node as parameter and returns a short (ACCEPT, SKIP, REJECT) as the result.
namespace WebCore {
-class Node;
-class ScriptState;
-// NodeFilterCondition is a wrapper around a NodeFilter JS function.
-class V8NodeFilterCondition : public NodeFilterCondition {
- public:
- explicit V8NodeFilterCondition(v8::Handle<v8::Value> filter);
- virtual ~V8NodeFilterCondition();
+ class Node;
+ class ScriptState;
+
+ // NodeFilterCondition is a wrapper around a NodeFilter JS function.
+ class V8NodeFilterCondition : public NodeFilterCondition {
+ public:
+ explicit V8NodeFilterCondition(v8::Handle<v8::Value> filter);
+ virtual ~V8NodeFilterCondition();
+
+ virtual short acceptNode(ScriptState*, Node*) const;
- virtual short acceptNode(ScriptState*, Node*) const;
+ private:
+ mutable v8::Persistent<v8::Value> m_filter;
+ };
- private:
- mutable v8::Persistent<v8::Value> m_filter;
-};
+} // namespace WebCore
-} // namesapce WebCore
-#endif // V8_NODEFILTER_H__
+#endif // V8NodeFilter_h