summaryrefslogtreecommitdiffstats
path: root/webkit/port/bindings/v8
diff options
context:
space:
mode:
Diffstat (limited to 'webkit/port/bindings/v8')
-rw-r--r--webkit/port/bindings/v8/JSNSResolver.cpp99
-rw-r--r--webkit/port/bindings/v8/JSNSResolver.h58
-rw-r--r--webkit/port/bindings/v8/ScriptController.h1
-rw-r--r--webkit/port/bindings/v8/V8MessagePortCustom.cpp232
-rw-r--r--webkit/port/bindings/v8/V8XMLHttpRequestCustom.cpp192
-rw-r--r--webkit/port/bindings/v8/v8_custom.cpp347
-rw-r--r--webkit/port/bindings/v8/v8_custom.h22
-rw-r--r--webkit/port/bindings/v8/v8_events.cpp26
-rw-r--r--webkit/port/bindings/v8/v8_events.h16
-rw-r--r--webkit/port/bindings/v8/v8_index.cpp4
-rw-r--r--webkit/port/bindings/v8/v8_index.h4
-rw-r--r--webkit/port/bindings/v8/v8_proxy.cpp73
-rw-r--r--webkit/port/bindings/v8/v8_proxy.h8
-rw-r--r--webkit/port/bindings/v8/v8_utility.h3
-rw-r--r--webkit/port/bindings/v8/v8_vectornodelist.cpp1
15 files changed, 564 insertions, 522 deletions
diff --git a/webkit/port/bindings/v8/JSNSResolver.cpp b/webkit/port/bindings/v8/JSNSResolver.cpp
deleted file mode 100644
index 5251a35..0000000
--- a/webkit/port/bindings/v8/JSNSResolver.cpp
+++ /dev/null
@@ -1,99 +0,0 @@
-// 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.
-
-#include "config.h"
-#include "JSNSResolver.h"
-
-#include "v8_proxy.h"
-#include "v8_binding.h"
-#include "ExceptionContext.h"
-#include "PlatformString.h"
-
-namespace WebCore {
-
-JSNSResolver::JSNSResolver(v8::Handle<v8::Object> resolver)
- : m_resolver(resolver)
-{
-}
-
-JSNSResolver::~JSNSResolver()
-{
-}
-
-String JSNSResolver::lookupNamespaceURI(ExceptionContext* exceptionContext,
- const String& prefix)
-{
- v8::Handle<v8::Function> lookupNamespaceURIFunc;
- v8::Handle<v8::String> lookupNamespaceURIName =
- v8::String::New("lookupNamespaceURI");
-
- // Check if the resolver has a function property named lookupNamespaceURI.
- if (m_resolver->Has(lookupNamespaceURIName)) {
- // In case the property is a getter that throws an error,
- // see LayoutTests/fast/dom/SelectorAPI/NSResolver-exceptions.xhtml
- ExceptionCatcher exceptionCatcher(exceptionContext);
- v8::Handle<v8::Value> lookupNamespaceURI = m_resolver->Get(
- lookupNamespaceURIName);
- if (exceptionContext->hadException())
- return String();
- if (lookupNamespaceURI->IsFunction()) {
- lookupNamespaceURIFunc = v8::Handle<v8::Function>::Cast(
- lookupNamespaceURI);
- }
- }
-
- if (lookupNamespaceURIFunc.IsEmpty() && !m_resolver->IsFunction()) {
- Frame* frame = ScriptController::retrieveActiveFrame();
- log_info(frame, "NSResolver does not have a lookupNamespaceURI method.",
- String());
- return String();
- }
-
- // Catch exceptions from calling the namespace resolver.
- ExceptionCatcher exceptionCatcher(exceptionContext);
-
- const int argc = 1;
- v8::Handle<v8::Value> argv[argc] = { v8String(prefix) };
- v8::Handle<v8::Function> function = lookupNamespaceURIFunc.IsEmpty()
- ? v8::Handle<v8::Function>::Cast(m_resolver)
- : lookupNamespaceURIFunc;
-
- V8Proxy* proxy = V8Proxy::retrieve();
- v8::Handle<v8::Value> retval = proxy->CallFunction(function, m_resolver,
- argc, argv);
-
- // Eat exceptions from namespace resolver and return an empty string. This
- // will cause NAMESPACE_ERR.
- if (exceptionContext->hadException())
- return String();
-
- return valueToStringWithNullOrUndefinedCheck(retval);
-}
-
-}
diff --git a/webkit/port/bindings/v8/JSNSResolver.h b/webkit/port/bindings/v8/JSNSResolver.h
deleted file mode 100644
index 84bd072..0000000
--- a/webkit/port/bindings/v8/JSNSResolver.h
+++ /dev/null
@@ -1,58 +0,0 @@
-// 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.
-
-
-// The wrapper for a JS object that implements NSResolver interface.
-
-#ifndef JSNSResolver_h
-#define JSNSResolver_h
-
-#include <v8.h>
-#include <wtf/RefCounted.h>
-#include "NSResolver.h"
-
-namespace WebCore {
-
-class ExceptionContext;
-class String;
-
-class JSNSResolver : public NSResolver {
-public:
- JSNSResolver(v8::Handle<v8::Object>);
- virtual ~JSNSResolver();
-
- virtual String lookupNamespaceURI(ExceptionContext*, const String&);
-
-private:
- v8::Handle<v8::Object> m_resolver; // Handle to resolver object.
-};
-
-}
-
-#endif // !defined(JSNSResolver_h)
diff --git a/webkit/port/bindings/v8/ScriptController.h b/webkit/port/bindings/v8/ScriptController.h
index aa4a46b..d23ca65 100644
--- a/webkit/port/bindings/v8/ScriptController.h
+++ b/webkit/port/bindings/v8/ScriptController.h
@@ -34,6 +34,7 @@
#define ScriptController_h
#include "HashMap.h"
+#include "SecurityOrigin.h"
#include "bindings/npruntime.h"
diff --git a/webkit/port/bindings/v8/V8MessagePortCustom.cpp b/webkit/port/bindings/v8/V8MessagePortCustom.cpp
new file mode 100644
index 0000000..8e4c3a9
--- /dev/null
+++ b/webkit/port/bindings/v8/V8MessagePortCustom.cpp
@@ -0,0 +1,232 @@
+// 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.
+
+#include "config.h"
+
+#include "v8_binding.h"
+#include "v8_custom.h"
+#include "v8_events.h"
+#include "v8_proxy.h"
+
+#include "V8Document.h"
+#include "V8HTMLDocument.h"
+
+#include "ExceptionCode.h"
+#include "MessagePort.h"
+
+namespace WebCore {
+
+// TODO(mbelshe) - merge these with XHR's CreateHiddenXHRDependency
+
+// 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 CreateHiddenDependency(v8::Local<v8::Object> object,
+ v8::Local<v8::Value> value) {
+ ASSERT(V8Proxy::GetDOMWrapperType(object) ==
+ V8ClassIndex::MESSAGEPORT);
+ v8::Local<v8::Value> cache =
+ object->GetInternalField(V8Custom::kMessagePortRequestCacheIndex);
+ if (cache->IsNull() || cache->IsUndefined()) {
+ cache = v8::Array::New();
+ object->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 RemoveHiddenDependency(v8::Local<v8::Object> object,
+ v8::Local<v8::Value> value) {
+ ASSERT(V8Proxy::GetDOMWrapperType(object) == V8ClassIndex::MESSAGEPORT);
+ v8::Local<v8::Value> cache =
+ object->GetInternalField(V8Custom::kMessagePortRequestCacheIndex);
+ 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(MessagePortOnmessage) {
+ INC_STATS(L"DOM.MessagePort.onmessage._get");
+ MessagePort* imp = V8Proxy::ToNativeObject<MessagePort>(
+ V8ClassIndex::MESSAGEPORT, info.Holder());
+ if (imp->onmessage()) {
+ V8ObjectEventListener* listener =
+ static_cast<V8ObjectEventListener*>(imp->onmessage());
+ v8::Local<v8::Object> v8_listener = listener->GetListenerObject();
+ return v8_listener;
+ }
+ return v8::Undefined();
+}
+
+ACCESSOR_SETTER(MessagePortOnmessage) {
+ INC_STATS(L"DOM.MessagePort.onmessage._set");
+ MessagePort* imp = V8Proxy::ToNativeObject<MessagePort>(
+ V8ClassIndex::MESSAGEPORT, info.Holder());
+ if (value->IsNull()) {
+ if (imp->onmessage()) {
+ V8ObjectEventListener* listener =
+ static_cast<V8ObjectEventListener*>(imp->onmessage());
+ v8::Local<v8::Object> v8_listener = listener->GetListenerObject();
+ RemoveHiddenDependency(info.Holder(), v8_listener);
+ }
+
+ // Clear the listener
+ imp->setOnmessage(0);
+
+ } else {
+ V8Proxy* proxy = V8Proxy::retrieve(imp->document()->frame());
+ if (!proxy)
+ return;
+
+ RefPtr<EventListener> listener =
+ proxy->FindOrCreateObjectEventListener(value, false);
+ if (listener) {
+ imp->setOnmessage(listener);
+ CreateHiddenDependency(info.Holder(), value);
+ }
+ }
+}
+
+ACCESSOR_GETTER(MessagePortOnclose) {
+ INC_STATS(L"DOM.MessagePort.onclose._get");
+ MessagePort* imp = V8Proxy::ToNativeObject<MessagePort>(
+ V8ClassIndex::MESSAGEPORT, info.Holder());
+ if (imp->onclose()) {
+ V8ObjectEventListener* listener =
+ static_cast<V8ObjectEventListener*>(imp->onclose());
+ v8::Local<v8::Object> v8_listener = listener->GetListenerObject();
+ return v8_listener;
+ }
+ return v8::Undefined();
+}
+
+ACCESSOR_SETTER(MessagePortOnclose) {
+ INC_STATS(L"DOM.MessagePort.onclose._set");
+ MessagePort* imp = V8Proxy::ToNativeObject<MessagePort>(
+ V8ClassIndex::MESSAGEPORT, info.Holder());
+ if (value->IsNull()) {
+ if (imp->onclose()) {
+ V8ObjectEventListener* listener =
+ static_cast<V8ObjectEventListener*>(imp->onclose());
+ v8::Local<v8::Object> v8_listener = listener->GetListenerObject();
+ RemoveHiddenDependency(info.Holder(), v8_listener);
+ }
+
+ // Clear the listener
+ imp->setOnclose(0);
+ } else {
+ V8Proxy* proxy = V8Proxy::retrieve(imp->document()->frame());
+ if (!proxy)
+ return;
+
+ RefPtr<EventListener> listener =
+ proxy->FindOrCreateObjectEventListener(value, false);
+ if (listener) {
+ imp->setOnclose(listener);
+ CreateHiddenDependency(info.Holder(), value);
+ }
+ }
+}
+
+CALLBACK_FUNC_DECL(MessagePortStartConversation) {
+ INC_STATS(L"DOM.MessagePort.StartConversation()");
+ if (args.Length() < 1) {
+ V8Proxy::ThrowError(V8Proxy::SYNTAX_ERROR, "Not enough arguments");
+ return v8::Undefined();
+ }
+
+ MessagePort* imp = V8Proxy::ToNativeObject<MessagePort>(
+ V8ClassIndex::MESSAGEPORT, args.Holder());
+
+ V8Proxy* proxy = V8Proxy::retrieve(imp->document()->frame());
+ if (!proxy)
+ return v8::Undefined();
+
+ RefPtr<MessagePort> port = imp->startConversation(imp->document(),
+ ToWebCoreString(args[0]));
+ v8::Handle<v8::Value> wrapper =
+ V8Proxy::ToV8Object(V8ClassIndex::MESSAGEPORT, port.get());
+ return wrapper;
+}
+
+CALLBACK_FUNC_DECL(MessagePortAddEventListener) {
+ INC_STATS(L"DOM.MessagePort.AddEventListener()");
+ MessagePort* imp = V8Proxy::ToNativeObject<MessagePort>(
+ V8ClassIndex::MESSAGEPORT, args.Holder());
+
+ V8Proxy* proxy = V8Proxy::retrieve(imp->document()->frame());
+ 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);
+
+ CreateHiddenDependency(args.Holder(), args[1]);
+ }
+ return v8::Undefined();
+}
+
+CALLBACK_FUNC_DECL(MessagePortRemoveEventListener) {
+ INC_STATS(L"DOM.MessagePort.RemoveEventListener()");
+ MessagePort* imp = V8Proxy::ToNativeObject<MessagePort>(
+ V8ClassIndex::MESSAGEPORT, args.Holder());
+
+ V8Proxy* proxy = V8Proxy::retrieve(imp->document()->frame());
+ 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();
+ imp->removeEventListener(type, listener.get(), useCapture);
+
+ RemoveHiddenDependency(args.Holder(), args[1]);
+ }
+
+ return v8::Undefined();
+}
+
+
+} // namespace WebCore
diff --git a/webkit/port/bindings/v8/V8XMLHttpRequestCustom.cpp b/webkit/port/bindings/v8/V8XMLHttpRequestCustom.cpp
index ce4c84d..d61a8c32 100644
--- a/webkit/port/bindings/v8/V8XMLHttpRequestCustom.cpp
+++ b/webkit/port/bindings/v8/V8XMLHttpRequestCustom.cpp
@@ -107,9 +107,9 @@ ACCESSOR_GETTER(XMLHttpRequestOnabort) {
INC_STATS(L"DOM.XMLHttpRequest.onabort._get");
XMLHttpRequest* imp = V8Proxy::ToNativeObject<XMLHttpRequest>(
V8ClassIndex::XMLHTTPREQUEST, info.Holder());
- if (imp->onAbortListener()) {
- V8XHREventListener* listener =
- static_cast<V8XHREventListener*>(imp->onAbortListener());
+ if (imp->onabort()) {
+ V8ObjectEventListener* listener =
+ static_cast<V8ObjectEventListener*>(imp->onabort());
v8::Local<v8::Object> v8_listener = listener->GetListenerObject();
return v8_listener;
}
@@ -121,24 +121,24 @@ ACCESSOR_SETTER(XMLHttpRequestOnabort) {
XMLHttpRequest* imp = V8Proxy::ToNativeObject<XMLHttpRequest>(
V8ClassIndex::XMLHTTPREQUEST, info.Holder());
if (value->IsNull()) {
- if (imp->onAbortListener()) {
- V8XHREventListener* listener =
- static_cast<V8XHREventListener*>(imp->onAbortListener());
+ 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->setOnAbortListener(0);
+ imp->setOnabort(0);
} else {
V8Proxy* proxy = V8Proxy::retrieve(imp->document()->frame());
if (!proxy)
return;
RefPtr<EventListener> listener =
- proxy->FindOrCreateXHREventListener(value, false);
+ proxy->FindOrCreateObjectEventListener(value, false);
if (listener) {
- imp->setOnAbortListener(listener);
+ imp->setOnabort(listener);
CreateHiddenXHRDependency(info.Holder(), value);
}
}
@@ -148,9 +148,9 @@ ACCESSOR_GETTER(XMLHttpRequestOnerror) {
INC_STATS(L"DOM.XMLHttpRequest.onerror._get");
XMLHttpRequest* imp = V8Proxy::ToNativeObject<XMLHttpRequest>(
V8ClassIndex::XMLHTTPREQUEST, info.Holder());
- if (imp->onErrorListener()) {
- RefPtr<V8XHREventListener> listener =
- static_cast<V8XHREventListener*>(imp->onErrorListener());
+ if (imp->onerror()) {
+ RefPtr<V8ObjectEventListener> listener =
+ static_cast<V8ObjectEventListener*>(imp->onerror());
v8::Local<v8::Object> v8_listener = listener->GetListenerObject();
return v8_listener;
}
@@ -162,24 +162,24 @@ ACCESSOR_SETTER(XMLHttpRequestOnerror) {
XMLHttpRequest* imp = V8Proxy::ToNativeObject<XMLHttpRequest>(
V8ClassIndex::XMLHTTPREQUEST, info.Holder());
if (value->IsNull()) {
- if (imp->onErrorListener()) {
- V8XHREventListener* listener =
- static_cast<V8XHREventListener*>(imp->onErrorListener());
+ 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->setOnErrorListener(0);
+ imp->setOnerror(0);
} else {
V8Proxy* proxy = V8Proxy::retrieve(imp->document()->frame());
if (!proxy)
return;
RefPtr<EventListener> listener =
- proxy->FindOrCreateXHREventListener(value, false);
+ proxy->FindOrCreateObjectEventListener(value, false);
if (listener) {
- imp->setOnErrorListener(listener);
+ imp->setOnerror(listener);
CreateHiddenXHRDependency(info.Holder(), value);
}
}
@@ -189,9 +189,9 @@ ACCESSOR_GETTER(XMLHttpRequestOnload) {
INC_STATS(L"DOM.XMLHttpRequest.onload._get");
XMLHttpRequest* imp = V8Proxy::ToNativeObject<XMLHttpRequest>(
V8ClassIndex::XMLHTTPREQUEST, info.Holder());
- if (imp->onLoadListener()) {
- V8XHREventListener* listener =
- static_cast<V8XHREventListener*>(imp->onLoadListener());
+ if (imp->onload()) {
+ V8ObjectEventListener* listener =
+ static_cast<V8ObjectEventListener*>(imp->onload());
v8::Local<v8::Object> v8_listener = listener->GetListenerObject();
return v8_listener;
}
@@ -205,7 +205,7 @@ ACCESSOR_SETTER(XMLHttpRequestOnload)
V8ClassIndex::XMLHTTPREQUEST, info.Holder());
if (value->IsNull()) {
if (imp->onload()) {
- V8XHREventListener* listener = static_cast<V8XHREventListener*>(imp->onload());
+ V8ObjectEventListener* listener = static_cast<V8ObjectEventListener*>(imp->onload());
v8::Local<v8::Object> v8_listener = listener->GetListenerObject();
RemoveHiddenXHRDependency(info.Holder(), v8_listener);
}
@@ -218,7 +218,7 @@ ACCESSOR_SETTER(XMLHttpRequestOnload)
return;
RefPtr<EventListener> listener =
- proxy->FindOrCreateXHREventListener(value, false);
+ proxy->FindOrCreateObjectEventListener(value, false);
if (listener) {
imp->setOnload(listener.get());
CreateHiddenXHRDependency(info.Holder(), value);
@@ -230,9 +230,9 @@ ACCESSOR_GETTER(XMLHttpRequestOnloadstart) {
INC_STATS(L"DOM.XMLHttpRequest.onloadstart._get");
XMLHttpRequest* imp = V8Proxy::ToNativeObject<XMLHttpRequest>(
V8ClassIndex::XMLHTTPREQUEST, info.Holder());
- if (imp->onLoadStartListener()) {
- V8XHREventListener* listener =
- static_cast<V8XHREventListener*>(imp->onLoadStartListener());
+ if (imp->onloadstart()) {
+ V8ObjectEventListener* listener =
+ static_cast<V8ObjectEventListener*>(imp->onloadstart());
v8::Local<v8::Object> v8_listener = listener->GetListenerObject();
return v8_listener;
}
@@ -244,24 +244,24 @@ ACCESSOR_SETTER(XMLHttpRequestOnloadstart) {
XMLHttpRequest* imp = V8Proxy::ToNativeObject<XMLHttpRequest>(
V8ClassIndex::XMLHTTPREQUEST, info.Holder());
if (value->IsNull()) {
- if (imp->onLoadStartListener()) {
- V8XHREventListener* listener =
- static_cast<V8XHREventListener*>(imp->onLoadStartListener());
+ 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->setOnLoadStartListener(0);
+ imp->setOnloadstart(0);
} else {
V8Proxy* proxy = V8Proxy::retrieve(imp->document()->frame());
if (!proxy)
return;
RefPtr<EventListener> listener =
- proxy->FindOrCreateXHREventListener(value, false);
+ proxy->FindOrCreateObjectEventListener(value, false);
if (listener) {
- imp->setOnLoadStartListener(listener);
+ imp->setOnloadstart(listener);
CreateHiddenXHRDependency(info.Holder(), value);
}
}
@@ -271,9 +271,9 @@ ACCESSOR_GETTER(XMLHttpRequestOnprogress) {
INC_STATS(L"DOM.XMLHttpRequest.onprogress._get");
XMLHttpRequest* imp = V8Proxy::ToNativeObject<XMLHttpRequest>(
V8ClassIndex::XMLHTTPREQUEST, info.Holder());
- if (imp->onProgressListener()) {
- V8XHREventListener* listener =
- static_cast<V8XHREventListener*>(imp->onProgressListener());
+ if (imp->onprogress()) {
+ V8ObjectEventListener* listener =
+ static_cast<V8ObjectEventListener*>(imp->onprogress());
v8::Local<v8::Object> v8_listener = listener->GetListenerObject();
return v8_listener;
}
@@ -285,24 +285,24 @@ ACCESSOR_SETTER(XMLHttpRequestOnprogress) {
XMLHttpRequest* imp = V8Proxy::ToNativeObject<XMLHttpRequest>(
V8ClassIndex::XMLHTTPREQUEST, info.Holder());
if (value->IsNull()) {
- if (imp->onProgressListener()) {
- V8XHREventListener* listener =
- static_cast<V8XHREventListener*>(imp->onProgressListener());
+ 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->setOnProgressListener(0);
+ imp->setOnprogress(0);
} else {
V8Proxy* proxy = V8Proxy::retrieve(imp->document()->frame());
if (!proxy)
return;
RefPtr<EventListener> listener =
- proxy->FindOrCreateXHREventListener(value, false);
+ proxy->FindOrCreateObjectEventListener(value, false);
if (listener) {
- imp->setOnProgressListener(listener);
+ imp->setOnprogress(listener);
CreateHiddenXHRDependency(info.Holder(), value);
}
}
@@ -312,9 +312,9 @@ ACCESSOR_GETTER(XMLHttpRequestOnreadystatechange) {
INC_STATS(L"DOM.XMLHttpRequest.onreadystatechange._get");
XMLHttpRequest* imp = V8Proxy::ToNativeObject<XMLHttpRequest>(
V8ClassIndex::XMLHTTPREQUEST, info.Holder());
- if (imp->onReadyStateChangeListener()) {
- V8XHREventListener* listener =
- static_cast<V8XHREventListener*>(imp->onReadyStateChangeListener());
+ if (imp->onreadystatechange()) {
+ V8ObjectEventListener* listener =
+ static_cast<V8ObjectEventListener*>(imp->onreadystatechange());
v8::Local<v8::Object> v8_listener = listener->GetListenerObject();
return v8_listener;
}
@@ -328,8 +328,8 @@ ACCESSOR_SETTER(XMLHttpRequestOnreadystatechange)
V8ClassIndex::XMLHTTPREQUEST, info.Holder());
if (value->IsNull()) {
if (imp->onreadystatechange()) {
- V8XHREventListener* listener =
- static_cast<V8XHREventListener*>(imp->onreadystatechange());
+ V8ObjectEventListener* listener =
+ static_cast<V8ObjectEventListener*>(imp->onreadystatechange());
v8::Local<v8::Object> v8_listener = listener->GetListenerObject();
RemoveHiddenXHRDependency(info.Holder(), v8_listener);
}
@@ -342,7 +342,7 @@ ACCESSOR_SETTER(XMLHttpRequestOnreadystatechange)
return;
RefPtr<EventListener> listener =
- proxy->FindOrCreateXHREventListener(value, false);
+ proxy->FindOrCreateObjectEventListener(value, false);
if (listener) {
imp->setOnreadystatechange(listener.get());
CreateHiddenXHRDependency(info.Holder(), value);
@@ -361,7 +361,7 @@ CALLBACK_FUNC_DECL(XMLHttpRequestAddEventListener)
return v8::Undefined();
RefPtr<EventListener> listener =
- proxy->FindOrCreateXHREventListener(args[1], false);
+ proxy->FindOrCreateObjectEventListener(args[1], false);
if (listener) {
String type = ToWebCoreString(args[0]);
bool useCapture = args[2]->BooleanValue();
@@ -382,7 +382,7 @@ CALLBACK_FUNC_DECL(XMLHttpRequestRemoveEventListener) {
return v8::Undefined(); // probably leaked
RefPtr<EventListener> listener =
- proxy->FindXHREventListener(args[1], false);
+ proxy->FindObjectEventListener(args[1], false);
if (listener) {
String type = ToWebCoreString(args[0]);
@@ -544,9 +544,9 @@ ACCESSOR_GETTER(XMLHttpRequestUploadOnabort) {
INC_STATS(L"DOM.XMLHttpRequestUpload.onabort._get");
XMLHttpRequestUpload* imp = V8Proxy::ToNativeObject<XMLHttpRequestUpload>(
V8ClassIndex::XMLHTTPREQUESTUPLOAD, info.Holder());
- if (imp->onAbortListener()) {
- V8XHREventListener* listener =
- static_cast<V8XHREventListener*>(imp->onAbortListener());
+ if (imp->onabort()) {
+ V8ObjectEventListener* listener =
+ static_cast<V8ObjectEventListener*>(imp->onabort());
v8::Local<v8::Object> v8_listener = listener->GetListenerObject();
return v8_listener;
}
@@ -558,15 +558,15 @@ ACCESSOR_SETTER(XMLHttpRequestUploadOnabort) {
XMLHttpRequestUpload* imp = V8Proxy::ToNativeObject<XMLHttpRequestUpload>(
V8ClassIndex::XMLHTTPREQUESTUPLOAD, info.Holder());
if (value->IsNull()) {
- if (imp->onAbortListener()) {
- V8XHREventListener* listener =
- static_cast<V8XHREventListener*>(imp->onAbortListener());
+ 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->setOnAbortListener(0);
+ imp->setOnabort(0);
} else {
XMLHttpRequest* xmlhttprequest = imp->associatedXMLHttpRequest();
V8Proxy* proxy = V8Proxy::retrieve(xmlhttprequest->document()->frame());
@@ -574,9 +574,9 @@ ACCESSOR_SETTER(XMLHttpRequestUploadOnabort) {
return;
RefPtr<EventListener> listener =
- proxy->FindOrCreateXHREventListener(value, false);
+ proxy->FindOrCreateObjectEventListener(value, false);
if (listener) {
- imp->setOnAbortListener(listener);
+ imp->setOnabort(listener);
CreateHiddenXHRDependency(info.Holder(), value);
}
}
@@ -586,9 +586,9 @@ ACCESSOR_GETTER(XMLHttpRequestUploadOnerror) {
INC_STATS(L"DOM.XMLHttpRequestUpload.onerror._get");
XMLHttpRequestUpload* imp = V8Proxy::ToNativeObject<XMLHttpRequestUpload>(
V8ClassIndex::XMLHTTPREQUESTUPLOAD, info.Holder());
- if (imp->onErrorListener()) {
- V8XHREventListener* listener =
- static_cast<V8XHREventListener*>(imp->onErrorListener());
+ if (imp->onerror()) {
+ V8ObjectEventListener* listener =
+ static_cast<V8ObjectEventListener*>(imp->onerror());
v8::Local<v8::Object> v8_listener = listener->GetListenerObject();
return v8_listener;
}
@@ -600,15 +600,15 @@ ACCESSOR_SETTER(XMLHttpRequestUploadOnerror) {
XMLHttpRequestUpload* imp = V8Proxy::ToNativeObject<XMLHttpRequestUpload>(
V8ClassIndex::XMLHTTPREQUESTUPLOAD, info.Holder());
if (value->IsNull()) {
- if (imp->onErrorListener()) {
- V8XHREventListener* listener =
- static_cast<V8XHREventListener*>(imp->onErrorListener());
+ 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->setOnErrorListener(0);
+ imp->setOnerror(0);
} else {
XMLHttpRequest* xmlhttprequest = imp->associatedXMLHttpRequest();
V8Proxy* proxy = V8Proxy::retrieve(xmlhttprequest->document()->frame());
@@ -616,9 +616,9 @@ ACCESSOR_SETTER(XMLHttpRequestUploadOnerror) {
return;
RefPtr<EventListener> listener =
- proxy->FindOrCreateXHREventListener(value, false);
+ proxy->FindOrCreateObjectEventListener(value, false);
if (listener) {
- imp->setOnErrorListener(listener);
+ imp->setOnerror(listener);
CreateHiddenXHRDependency(info.Holder(), value);
}
}
@@ -628,9 +628,9 @@ ACCESSOR_GETTER(XMLHttpRequestUploadOnload) {
INC_STATS(L"DOM.XMLHttpRequestUpload.onload._get");
XMLHttpRequestUpload* imp = V8Proxy::ToNativeObject<XMLHttpRequestUpload>(
V8ClassIndex::XMLHTTPREQUESTUPLOAD, info.Holder());
- if (imp->onLoadListener()) {
- V8XHREventListener* listener =
- static_cast<V8XHREventListener*>(imp->onLoadListener());
+ if (imp->onload()) {
+ V8ObjectEventListener* listener =
+ static_cast<V8ObjectEventListener*>(imp->onload());
v8::Local<v8::Object> v8_listener = listener->GetListenerObject();
return v8_listener;
}
@@ -642,15 +642,15 @@ ACCESSOR_SETTER(XMLHttpRequestUploadOnload) {
XMLHttpRequestUpload* imp = V8Proxy::ToNativeObject<XMLHttpRequestUpload>(
V8ClassIndex::XMLHTTPREQUESTUPLOAD, info.Holder());
if (value->IsNull()) {
- if (imp->onLoadListener()) {
- V8XHREventListener* listener =
- static_cast<V8XHREventListener*>(imp->onLoadListener());
+ 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->setOnLoadListener(0);
+ imp->setOnload(0);
} else {
XMLHttpRequest* xmlhttprequest = imp->associatedXMLHttpRequest();
V8Proxy* proxy = V8Proxy::retrieve(xmlhttprequest->document()->frame());
@@ -658,9 +658,9 @@ ACCESSOR_SETTER(XMLHttpRequestUploadOnload) {
return;
RefPtr<EventListener> listener =
- proxy->FindOrCreateXHREventListener(value, false);
+ proxy->FindOrCreateObjectEventListener(value, false);
if (listener) {
- imp->setOnLoadListener(listener);
+ imp->setOnload(listener);
CreateHiddenXHRDependency(info.Holder(), value);
}
}
@@ -670,9 +670,9 @@ ACCESSOR_GETTER(XMLHttpRequestUploadOnloadstart) {
INC_STATS(L"DOM.XMLHttpRequestUpload.onloadstart._get");
XMLHttpRequestUpload* imp = V8Proxy::ToNativeObject<XMLHttpRequestUpload>(
V8ClassIndex::XMLHTTPREQUESTUPLOAD, info.Holder());
- if (imp->onLoadStartListener()) {
- V8XHREventListener* listener =
- static_cast<V8XHREventListener*>(imp->onLoadStartListener());
+ if (imp->onloadstart()) {
+ V8ObjectEventListener* listener =
+ static_cast<V8ObjectEventListener*>(imp->onloadstart());
v8::Local<v8::Object> v8_listener = listener->GetListenerObject();
return v8_listener;
}
@@ -684,15 +684,15 @@ ACCESSOR_SETTER(XMLHttpRequestUploadOnloadstart) {
XMLHttpRequestUpload* imp = V8Proxy::ToNativeObject<XMLHttpRequestUpload>(
V8ClassIndex::XMLHTTPREQUESTUPLOAD, info.Holder());
if (value->IsNull()) {
- if (imp->onLoadStartListener()) {
- V8XHREventListener* listener =
- static_cast<V8XHREventListener*>(imp->onLoadStartListener());
+ 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->setOnLoadStartListener(0);
+ imp->setOnloadstart(0);
} else {
XMLHttpRequest* xmlhttprequest = imp->associatedXMLHttpRequest();
V8Proxy* proxy = V8Proxy::retrieve(xmlhttprequest->document()->frame());
@@ -700,9 +700,9 @@ ACCESSOR_SETTER(XMLHttpRequestUploadOnloadstart) {
return;
RefPtr<EventListener> listener =
- proxy->FindOrCreateXHREventListener(value, false);
+ proxy->FindOrCreateObjectEventListener(value, false);
if (listener) {
- imp->setOnLoadStartListener(listener);
+ imp->setOnloadstart(listener);
CreateHiddenXHRDependency(info.Holder(), value);
}
}
@@ -712,9 +712,9 @@ ACCESSOR_GETTER(XMLHttpRequestUploadOnprogress) {
INC_STATS(L"DOM.XMLHttpRequestUpload.onprogress._get");
XMLHttpRequestUpload* imp = V8Proxy::ToNativeObject<XMLHttpRequestUpload>(
V8ClassIndex::XMLHTTPREQUESTUPLOAD, info.Holder());
- if (imp->onProgressListener()) {
- V8XHREventListener* listener =
- static_cast<V8XHREventListener*>(imp->onProgressListener());
+ if (imp->onprogress()) {
+ V8ObjectEventListener* listener =
+ static_cast<V8ObjectEventListener*>(imp->onprogress());
v8::Local<v8::Object> v8_listener = listener->GetListenerObject();
return v8_listener;
}
@@ -726,15 +726,15 @@ ACCESSOR_SETTER(XMLHttpRequestUploadOnprogress) {
XMLHttpRequestUpload* imp = V8Proxy::ToNativeObject<XMLHttpRequestUpload>(
V8ClassIndex::XMLHTTPREQUESTUPLOAD, info.Holder());
if (value->IsNull()) {
- if (imp->onProgressListener()) {
- V8XHREventListener* listener =
- static_cast<V8XHREventListener*>(imp->onProgressListener());
+ 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->setOnProgressListener(0);
+ imp->setOnprogress(0);
} else {
XMLHttpRequest* xmlhttprequest = imp->associatedXMLHttpRequest();
V8Proxy* proxy = V8Proxy::retrieve(xmlhttprequest->document()->frame());
@@ -742,9 +742,9 @@ ACCESSOR_SETTER(XMLHttpRequestUploadOnprogress) {
return;
RefPtr<EventListener> listener =
- proxy->FindOrCreateXHREventListener(value, false);
+ proxy->FindOrCreateObjectEventListener(value, false);
if (listener) {
- imp->setOnProgressListener(listener);
+ imp->setOnprogress(listener);
CreateHiddenXHRDependency(info.Holder(), value);
}
}
@@ -761,7 +761,7 @@ CALLBACK_FUNC_DECL(XMLHttpRequestUploadAddEventListener) {
return v8::Undefined();
RefPtr<EventListener> listener =
- proxy->FindOrCreateXHREventListener(args[1], false);
+ proxy->FindOrCreateObjectEventListener(args[1], false);
if (listener) {
String type = ToWebCoreString(args[0]);
bool useCapture = args[2]->BooleanValue();
@@ -783,7 +783,7 @@ CALLBACK_FUNC_DECL(XMLHttpRequestUploadRemoveEventListener) {
return v8::Undefined(); // probably leaked
RefPtr<EventListener> listener =
- proxy->FindXHREventListener(args[1], false);
+ proxy->FindObjectEventListener(args[1], false);
if (listener) {
String type = ToWebCoreString(args[0]);
diff --git a/webkit/port/bindings/v8/v8_custom.cpp b/webkit/port/bindings/v8/v8_custom.cpp
index 827323a..9bb904d 100644
--- a/webkit/port/bindings/v8/v8_custom.cpp
+++ b/webkit/port/bindings/v8/v8_custom.cpp
@@ -43,7 +43,6 @@
#include "V8HTMLImageElement.h"
#include "V8HTMLOptionElement.h"
#include "V8Node.h"
-#include "V8NSResolver.h"
#include "V8XPathNSResolver.h"
#include "V8XPathResult.h"
@@ -80,15 +79,17 @@
#include "HTMLFrameSetElement.h"
#include "HTMLIFrameElement.h"
#include "HTMLImageElement.h"
+#include "HTMLInputElement.h"
#include "HTMLNames.h"
#include "HTMLOptionElement.h"
#include "HTMLOptionsCollection.h"
#include "HTMLSelectElement.h"
#include "History.h"
-#include "JSNSResolver.h"
#include "JSXPathNSResolver.h"
#include "KURL.h"
#include "Location.h"
+#include "MessageChannel.h"
+#include "MessagePort.h"
#include "MouseEvent.h"
#include "NodeIterator.h"
#include "Page.h"
@@ -110,6 +111,7 @@
#if ENABLE(SVG)
#include "V8SVGPODTypeWrapper.h"
+#include "SVGElementInstance.h"
#include "SVGException.h"
#include "SVGPathSeg.h"
#endif
@@ -260,6 +262,33 @@ CALLBACK_FUNC_DECL(DOMParserConstructor) {
DOMParser>(args);
}
+// TODO(mbelshe): merge this with the XHR Constructor.
+// The only difference is that this one takes an argument to its
+// create call, the XHR does not.
+CALLBACK_FUNC_DECL(MessageChannelConstructor) {
+ INC_STATS(L"DOM.MessageChannel.Constructor");
+ if (!args.IsConstructCall()) {
+ V8Proxy::ThrowError(V8Proxy::TYPE_ERROR,
+ "DOM object constructor cannot be called as a function.");
+ return v8::Undefined();
+ }
+
+ // Get the document.
+ Frame* frame = V8Proxy::retrieveFrame();
+ if (!frame)
+ return v8::Undefined();
+ Document* document = frame->document();
+
+ // Note: it's OK to let this RefPtr go out of scope because we also call
+ // SetDOMWrapper(), which effectively holds a reference to obj.
+ RefPtr<MessageChannel> obj = MessageChannel::create(document);
+ V8Proxy::SetDOMWrapper(args.Holder(), V8ClassIndex::MESSAGECHANNEL,
+ obj.get());
+ V8Proxy::SetJSWrapperForDOMObject(
+ obj.get(), v8::Persistent<v8::Object>::New(args.Holder()));
+ return args.Holder();
+}
+
CALLBACK_FUNC_DECL(XMLSerializerConstructor) {
INC_STATS(L"DOM.XMLSerializer.Constructor");
@@ -859,19 +888,31 @@ CALLBACK_FUNC_DECL(DOMWindowPostMessage) {
v8::TryCatch try_catch;
String message = ToWebCoreString(args[0]);
- String domain = ToWebCoreString(args[1]);
+ MessagePort* port = NULL;
+ String domain;
+
+ // This function has variable arguments and can either be:
+ // postMessage(message, port, domain);
+ // or
+ // postMessage(message, domain);
+ if (args.Length() > 2) {
+ port = V8Proxy::ToNativeObject<MessagePort>(
+ V8ClassIndex::MESSAGEPORT, args[1]);
+ domain = valueToStringWithNullOrUndefinedCheck(args[2]);
+ } else {
+ domain = valueToStringWithNullOrUndefinedCheck(args[1]);
+ }
if (try_catch.HasCaught()) return v8::Undefined();
- ExceptionCode ec;
- window->postMessage(message, domain, source, ec);
+ ExceptionCode ec = 0;
+ window->postMessage(message, port, domain, source, ec);
if (ec)
V8Proxy::SetDOMException(ec);
return v8::Undefined();
}
-
static bool canShowModalDialogNow(const Frame* frame) {
// A frame can out live its page. See bug 1219613.
if (!frame || !frame->page())
@@ -2324,6 +2365,18 @@ CALLBACK_FUNC_DECL(ConsoleWarn) {
return v8::Undefined();
}
+CALLBACK_FUNC_DECL(ConsoleDirxml) {
+ INC_STATS(L"DOM.Console.dirxml()");
+ V8Proxy::SetDOMException(NOT_SUPPORTED_ERR);
+ return v8::Undefined();
+}
+
+CALLBACK_FUNC_DECL(ConsoleTrace) {
+ INC_STATS(L"DOM.Console.trace()");
+ V8Proxy::SetDOMException(NOT_SUPPORTED_ERR);
+ return v8::Undefined();
+}
+
// Clipboard -------------------------------------------------------------------
@@ -2488,69 +2541,6 @@ static bool AllowSettingFrameSrcToJavascriptUrl(HTMLFrameElementBase* frame,
// Element ---------------------------------------------------------------------
-CALLBACK_FUNC_DECL(ElementQuerySelector) {
- INC_STATS(L"DOM.Element.querySelector()");
- Element* element = V8Proxy::DOMWrapperToNode<Element>(args.Holder());
-
- ExceptionCode ec = 0;
-
- String selectors = valueToStringWithNullOrUndefinedCheck(args[0]);
-
- NSResolver* resolver = 0;
- if (V8NSResolver::HasInstance(args[1])) {
- resolver = V8Proxy::ToNativeObject<NSResolver>(
- V8ClassIndex::NSRESOLVER, args[1]);
- } else if (args[1]->IsObject()) {
- resolver = new JSNSResolver(args[1]->ToObject());
- } else if (!args[1]->IsNull() && !args[1]->IsUndefined()) {
- V8Proxy::SetDOMException(TYPE_MISMATCH_ERR);
- return v8::Handle<v8::Value>();
- }
- OwnPtr<ExceptionContext> context(new ExceptionContext());
- RefPtr<Element> result = WTF::getPtr(
- element->querySelector(selectors, resolver, ec, context.get()));
- if (ec != 0) {
- V8Proxy::SetDOMException(ec);
- return v8::Handle<v8::Value>();
- }
- if (context->hadException()) {
- v8::ThrowException(context->exception());
- return v8::Undefined();
- }
- return V8Proxy::ToV8Object(V8ClassIndex::NODE, WTF::getPtr(result));
-}
-
-CALLBACK_FUNC_DECL(ElementQuerySelectorAll) {
- INC_STATS(L"DOM.Element.querySelectorAll()");
- Element* element = V8Proxy::DOMWrapperToNode<Element>(args.Holder());
- ExceptionCode ec = 0;
-
- String selectors = valueToStringWithNullOrUndefinedCheck(args[0]);
-
- NSResolver* resolver = 0;
- if (V8NSResolver::HasInstance(args[1])) {
- resolver = V8Proxy::ToNativeObject<NSResolver>(
- V8ClassIndex::NSRESOLVER, args[1]);
- } else if (args[1]->IsObject()) {
- resolver = new JSNSResolver(args[1]->ToObject());
- } else if (!args[1]->IsNull() && !args[1]->IsUndefined()) {
- V8Proxy::SetDOMException(TYPE_MISMATCH_ERR);
- return v8::Handle<v8::Value>();
- }
- OwnPtr<ExceptionContext> context(new ExceptionContext());
- RefPtr<NodeList> result = WTF::getPtr(
- element->querySelectorAll(selectors, resolver, ec, context.get()));
- if (ec != 0) {
- V8Proxy::SetDOMException(ec);
- return v8::Handle<v8::Value>();
- }
- if (context->hadException()) {
- v8::ThrowException(context->exception());
- return v8::Undefined();
- }
- return V8Proxy::ToV8Object(V8ClassIndex::NODELIST, WTF::getPtr(result));
-}
-
CALLBACK_FUNC_DECL(ElementSetAttribute) {
INC_STATS(L"DOM.Element.setAttribute()");
Element* imp = V8Proxy::DOMWrapperToNode<Element>(args.Holder());
@@ -2857,142 +2847,19 @@ CALLBACK_FUNC_DECL(DocumentEvaluate) {
inResult = V8Proxy::ToNativeObject<XPathResult>(
V8ClassIndex::XPATHRESULT, args[4]);
}
+
+ v8::TryCatch try_catch;
RefPtr<XPathResult> result =
imp->evaluate(expression, contextNode, resolver, type, inResult, ec);
- if (ec != 0) {
- V8Proxy::SetDOMException(ec);
+ if (try_catch.HasCaught() || ec != 0) {
+ if (!try_catch.HasCaught())
+ V8Proxy::SetDOMException(ec);
return v8::Handle<v8::Value>();
}
return V8Proxy::ToV8Object(V8ClassIndex::XPATHRESULT,
static_cast<Peerable*>(result.get()));
}
-CALLBACK_FUNC_DECL(DocumentQuerySelector) {
- INC_STATS(L"DOM.Document.querySelector()");
- Document* document = V8Proxy::DOMWrapperToNode<Document>(args.Holder());
- ExceptionCode ec = 0;
-
- String selectors = valueToStringWithNullOrUndefinedCheck(args[0]);
-
- NSResolver* resolver = 0;
- if (V8NSResolver::HasInstance(args[1])) {
- resolver = V8Proxy::ToNativeObject<NSResolver>(
- V8ClassIndex::NSRESOLVER, args[1]);
- } else if (args[1]->IsObject()) {
- resolver = new JSNSResolver(args[1]->ToObject());
- } else if (!args[1]->IsNull() && !args[1]->IsUndefined()) {
- V8Proxy::SetDOMException(TYPE_MISMATCH_ERR);
- return v8::Handle<v8::Value>();
- }
- OwnPtr<ExceptionContext> context(new ExceptionContext());
- RefPtr<Element> result = WTF::getPtr(
- document->querySelector(selectors, resolver, ec, context.get()));
- if (ec != 0) {
- V8Proxy::SetDOMException(ec);
- return v8::Handle<v8::Value>();
- }
- if (context->hadException()) {
- v8::ThrowException(context->exception());
- return v8::Undefined();
- }
- return V8Proxy::ToV8Object(V8ClassIndex::NODE, WTF::getPtr(result));
-}
-
-CALLBACK_FUNC_DECL(DocumentQuerySelectorAll) {
- INC_STATS(L"DOM.Document.querySelectorAll()");
- Document* document = V8Proxy::DOMWrapperToNode<Document>(args.Holder());
- ExceptionCode ec = 0;
-
- String selectors = valueToStringWithNullOrUndefinedCheck(args[0]);
-
- NSResolver* resolver = 0;
- if (V8NSResolver::HasInstance(args[1])) {
- resolver = V8Proxy::ToNativeObject<NSResolver>(
- V8ClassIndex::NSRESOLVER, args[1]);
- } else if (args[1]->IsObject()) {
- resolver = new JSNSResolver(args[1]->ToObject());
- } else if (!args[1]->IsNull() && !args[1]->IsUndefined()) {
- V8Proxy::SetDOMException(TYPE_MISMATCH_ERR);
- return v8::Handle<v8::Value>();
- }
- OwnPtr<ExceptionContext> context(new ExceptionContext());
- RefPtr<NodeList> result = WTF::getPtr(
- document->querySelectorAll(selectors, resolver, ec, context.get()));
- if (ec != 0) {
- V8Proxy::SetDOMException(ec);
- return v8::Handle<v8::Value>();
- }
- if (context->hadException()) {
- v8::ThrowException(context->exception());
- return v8::Undefined();
- }
- return V8Proxy::ToV8Object(V8ClassIndex::NODELIST, WTF::getPtr(result));
-}
-
-CALLBACK_FUNC_DECL(DocumentFragmentQuerySelector) {
- INC_STATS(L"DOM.DocumentFragment.querySelector()");
- DocumentFragment* fragment =
- V8Proxy::DOMWrapperToNode<DocumentFragment>(args.Holder());
- ExceptionCode ec = 0;
-
- String selectors = valueToStringWithNullOrUndefinedCheck(args[0]);
-
- NSResolver* resolver = 0;
- if (V8NSResolver::HasInstance(args[1])) {
- resolver = V8Proxy::ToNativeObject<NSResolver>(
- V8ClassIndex::NSRESOLVER, args[1]);
- } else if (args[1]->IsObject()) {
- resolver = new JSNSResolver(args[1]->ToObject());
- } else if (!args[1]->IsNull() && !args[1]->IsUndefined()) {
- V8Proxy::SetDOMException(TYPE_MISMATCH_ERR);
- return v8::Handle<v8::Value>();
- }
- OwnPtr<ExceptionContext> context(new ExceptionContext());
- RefPtr<Element> result = WTF::getPtr(
- fragment->querySelector(selectors, resolver, ec, context.get()));
- if (ec != 0) {
- V8Proxy::SetDOMException(ec);
- return v8::Handle<v8::Value>();
- }
- if (context->hadException()) {
- v8::ThrowException(context->exception());
- return v8::Undefined();
- }
- return V8Proxy::ToV8Object(V8ClassIndex::NODE, WTF::getPtr(result));
-}
-
-CALLBACK_FUNC_DECL(DocumentFragmentQuerySelectorAll) {
- INC_STATS(L"DOM.DocumentFragment.querySelectorAll()");
- DocumentFragment* fragment =
- V8Proxy::DOMWrapperToNode<DocumentFragment>(args.Holder());
- ExceptionCode ec = 0;
-
- String selectors = valueToStringWithNullOrUndefinedCheck(args[0]);
-
- NSResolver* resolver = 0;
- if (V8NSResolver::HasInstance(args[1])) {
- resolver = V8Proxy::ToNativeObject<NSResolver>(
- V8ClassIndex::NSRESOLVER, args[1]);
- } else if (args[1]->IsObject()) {
- resolver = new JSNSResolver(args[1]->ToObject());
- } else if (!args[1]->IsNull() && !args[1]->IsUndefined()) {
- V8Proxy::SetDOMException(TYPE_MISMATCH_ERR);
- return v8::Handle<v8::Value>();
- }
- OwnPtr<ExceptionContext> context(new ExceptionContext());
- RefPtr<NodeList> result = WTF::getPtr(
- fragment->querySelectorAll(selectors, resolver, ec, context.get()));
- if (ec != 0) {
- V8Proxy::SetDOMException(ec);
- return v8::Handle<v8::Value>();
- }
- if (context->hadException()) {
- v8::ThrowException(context->exception());
- return v8::Undefined();
- }
- return V8Proxy::ToV8Object(V8ClassIndex::NODELIST, WTF::getPtr(result));
-}
-
// DOMWindow -------------------------------------------------------------------
static bool IsAscii(const String& str) {
@@ -3291,14 +3158,6 @@ CALLBACK_FUNC_DECL(NodeFilterAcceptNode) {
return v8::Undefined();
}
-// NSResolver
-CALLBACK_FUNC_DECL(NSResolverLookupNamespaceURI) {
- INC_STATS(L"DOM.NSResolver.lookupNamespaceURI()");
- V8Proxy::SetDOMException(NOT_SUPPORTED_ERR);
- return v8::Undefined();
-}
-
-
static String EventNameFromAttributeName(const String& name) {
ASSERT(name.startsWith("on"));
String event_type = name.substring(2);
@@ -3345,7 +3204,7 @@ ACCESSOR_SETTER(DOMWindowEventHandler) {
if (value->IsNull()) {
// Clear the event listener
- doc->removeHTMLWindowEventListener(event_type);
+ doc->removeWindowEventListenerForType(event_type);
} else {
V8Proxy* proxy = V8Proxy::retrieve(imp->frame());
if (!proxy)
@@ -3354,7 +3213,7 @@ ACCESSOR_SETTER(DOMWindowEventHandler) {
RefPtr<EventListener> listener =
proxy->FindOrCreateV8EventListener(value, true);
if (listener) {
- doc->setHTMLWindowEventListener(event_type, listener);
+ doc->setWindowEventListenerForType(event_type, listener);
}
}
}
@@ -3378,7 +3237,7 @@ ACCESSOR_GETTER(DOMWindowEventHandler) {
String key = ToWebCoreString(name);
String event_type = EventNameFromAttributeName(key);
- EventListener* listener = doc->getHTMLWindowEventListener(event_type);
+ EventListener* listener = doc->windowEventListenerForType(event_type);
return V8Proxy::EventListenerToV8Object(listener);
}
@@ -3406,10 +3265,10 @@ ACCESSOR_SETTER(ElementEventHandler) {
RefPtr<EventListener> listener =
proxy->FindOrCreateV8EventListener(value, true);
if (listener) {
- node->setHTMLEventListener(event_type, listener);
+ node->setEventListenerForType(event_type, listener);
}
} else {
- node->removeHTMLEventListener(event_type);
+ node->removeEventListenerForType(event_type);
}
}
@@ -3423,7 +3282,7 @@ ACCESSOR_GETTER(ElementEventHandler) {
ASSERT(key.startsWith("on"));
String event_type = key.substring(2);
- EventListener* listener = node->getHTMLEventListener(event_type);
+ EventListener* listener = node->eventListenerForType(event_type);
return V8Proxy::EventListenerToV8Object(listener);
}
@@ -3448,6 +3307,30 @@ ACCESSOR_SETTER(HTMLOptionsCollectionLength) {
V8Proxy::SetDOMException(ec);
}
+ACCESSOR_GETTER(HTMLInputElementSelectionStart) {
+ INC_STATS(L"DOM.HTMLInputElement.selectionStart._get");
+ v8::Handle<v8::Object> holder = info.Holder();
+ HTMLInputElement* imp = V8Proxy::DOMWrapperToNode<HTMLInputElement>(holder);
+
+ if (!imp->canHaveSelection())
+ return v8::Undefined();
+
+ int v = imp->selectionStart();
+ return v8::Integer::New(v);
+}
+
+ACCESSOR_GETTER(HTMLInputElementSelectionEnd) {
+ INC_STATS(L"DOM.HTMLInputElement.selectionEnd._get");
+ v8::Handle<v8::Object> holder = info.Holder();
+ HTMLInputElement* imp = V8Proxy::DOMWrapperToNode<HTMLInputElement>(holder);
+
+ if (!imp->canHaveSelection())
+ return v8::Undefined();
+
+ int v = imp->selectionEnd();
+ return v8::Integer::New(v);
+}
+
#if ENABLE(SVG)
ACCESSOR_GETTER(SVGLengthValue) {
@@ -3510,6 +3393,48 @@ CALLBACK_FUNC_DECL(SVGMatrixRotateFromVector) {
return V8Proxy::ToV8Object(V8ClassIndex::SVGMATRIX, peer);
}
+CALLBACK_FUNC_DECL(SVGElementInstanceAddEventListener) {
+ INC_STATS(L"DOM.SVGElementInstance.AddEventListener()");
+ SVGElementInstance* instance =
+ V8Proxy::DOMWrapperToNative<SVGElementInstance>(args.Holder());
+
+ V8Proxy* proxy = V8Proxy::retrieve(instance->associatedFrame());
+ if (!proxy)
+ return v8::Undefined();
+
+ RefPtr<EventListener> listener =
+ proxy->FindOrCreateV8EventListener(args[1], false);
+ if (listener) {
+ String type = ToWebCoreString(args[0]);
+ bool useCapture = args[2]->BooleanValue();
+ instance->addEventListener(type, listener, useCapture);
+ }
+ return v8::Undefined();
+}
+
+CALLBACK_FUNC_DECL(SVGElementInstanceRemoveEventListener) {
+ INC_STATS(L"DOM.SVGElementInstance.RemoveEventListener()");
+ SVGElementInstance* instance =
+ V8Proxy::DOMWrapperToNative<SVGElementInstance>(args.Holder());
+
+ V8Proxy* proxy = V8Proxy::retrieve(instance->associatedFrame());
+ // It is possbile that the owner document of the node is detached
+ // from the frame, return immediately in this case.
+ // See issue 878909
+ if (!proxy)
+ return v8::Undefined();
+
+ RefPtr<EventListener> listener =
+ proxy->FindV8EventListener(args[1], false);
+ if (listener) {
+ String type = ToWebCoreString(args[0]);
+ bool useCapture = args[2]->BooleanValue();
+ instance->removeEventListener(type, listener.get(), useCapture);
+ }
+
+ return v8::Undefined();
+}
+
#endif // ENABLE(SVG)
// --------------- Security Checks -------------------------
diff --git a/webkit/port/bindings/v8/v8_custom.h b/webkit/port/bindings/v8/v8_custom.h
index 302b80a..ef2fb4d 100644
--- a/webkit/port/bindings/v8/v8_custom.h
+++ b/webkit/port/bindings/v8/v8_custom.h
@@ -54,6 +54,11 @@ class V8Custom {
static const int kXMLHttpRequestInternalFieldCount =
kDefaultWrapperInternalFieldCount + 1;
+ static const int kMessagePortRequestCacheIndex =
+ kDefaultWrapperInternalFieldCount + 0;
+ static const int kMessagePortInternalFieldCount =
+ kDefaultWrapperInternalFieldCount + 1;
+
static const int kDOMWindowLocationIndex =
kDefaultWrapperInternalFieldCount + 0;
static const int kDOMWindowNavigatorIndex =
@@ -172,6 +177,10 @@ DECLARE_PROPERTY_ACCESSOR_SETTER(AttrValue)
// Customized setter of HTMLOptionsCollection length
DECLARE_PROPERTY_ACCESSOR_SETTER(HTMLOptionsCollectionLength)
+// Customized accessors for HTMLInputElement
+DECLARE_PROPERTY_ACCESSOR_GETTER(HTMLInputElementSelectionStart)
+DECLARE_PROPERTY_ACCESSOR_GETTER(HTMLInputElementSelectionEnd)
+
DECLARE_NAMED_ACCESS_CHECK(Location)
DECLARE_INDEXED_ACCESS_CHECK(History)
@@ -217,6 +226,7 @@ DECLARE_CALLBACK(DOMWindowShowModalDialog)
DECLARE_CALLBACK(DOMWindowOpen)
DECLARE_CALLBACK(DOMParserConstructor)
+DECLARE_CALLBACK(MessageChannelConstructor)
DECLARE_CALLBACK(XMLHttpRequestConstructor)
DECLARE_CALLBACK(XMLSerializerConstructor)
DECLARE_CALLBACK(XPathEvaluatorConstructor)
@@ -258,6 +268,8 @@ DECLARE_CALLBACK(ConsoleProfile)
DECLARE_CALLBACK(ConsoleProfileEnd)
DECLARE_CALLBACK(ConsoleTimeEnd)
DECLARE_CALLBACK(ConsoleWarn)
+DECLARE_CALLBACK(ConsoleDirxml)
+DECLARE_CALLBACK(ConsoleTrace)
// Implementation of Clipboard attributes and methods.
DECLARE_PROPERTY_ACCESSOR_GETTER(ClipboardTypes)
@@ -360,8 +372,12 @@ DECLARE_NAMED_PROPERTY_GETTER(HTMLCollection)
DECLARE_INDEXED_PROPERTY_GETTER(CanvasPixelArray)
DECLARE_INDEXED_PROPERTY_SETTER(CanvasPixelArray)
-// NSResolver
-DECLARE_CALLBACK(NSResolverLookupNamespaceURI)
+// MessagePort
+DECLARE_PROPERTY_ACCESSOR(MessagePortOnmessage)
+DECLARE_PROPERTY_ACCESSOR(MessagePortOnclose)
+DECLARE_CALLBACK(MessagePortStartConversation)
+DECLARE_CALLBACK(MessagePortAddEventListener)
+DECLARE_CALLBACK(MessagePortRemoveEventListener)
// SVG custom properties and callbacks
#if ENABLE(SVG)
@@ -369,6 +385,8 @@ DECLARE_PROPERTY_ACCESSOR_GETTER(SVGLengthValue)
DECLARE_CALLBACK(SVGLengthConvertToSpecifiedUnits)
DECLARE_CALLBACK(SVGMatrixInverse)
DECLARE_CALLBACK(SVGMatrixRotateFromVector)
+DECLARE_CALLBACK(SVGElementInstanceAddEventListener)
+DECLARE_CALLBACK(SVGElementInstanceRemoveEventListener)
#endif
#undef DECLARE_INDEXED_ACCESS_CHECK
diff --git a/webkit/port/bindings/v8/v8_events.cpp b/webkit/port/bindings/v8/v8_events.cpp
index dd11bb2..bdd7e8a 100644
--- a/webkit/port/bindings/v8/v8_events.cpp
+++ b/webkit/port/bindings/v8/v8_events.cpp
@@ -61,8 +61,8 @@ V8AbstractEventListener::V8AbstractEventListener(Frame* frame, bool html)
void V8AbstractEventListener::handleEvent(Event* event, bool isWindowEvent) {
// EventListener could be disconnected from the frame.
- ASSERT(m_frame);
- if (!m_frame) return;
+ if (!m_frame)
+ return;
// The callback function on XMLHttpRequest can clear the event listener
// and destroys 'this' object. Keep a local reference of it.
@@ -72,7 +72,8 @@ void V8AbstractEventListener::handleEvent(Event* event, bool isWindowEvent) {
v8::HandleScope handle_scope;
v8::Handle<v8::Context> context = V8Proxy::GetContext(m_frame);
- if (context.IsEmpty()) return;
+ if (context.IsEmpty())
+ return;
v8::Context::Scope scope(context);
// m_frame can removed by the callback function,
@@ -227,6 +228,11 @@ v8::Local<v8::Object> V8EventListener::GetThisObject(Event* event,
v8::Handle<v8::Value> value = V8Proxy::ToV8Object(
V8ClassIndex::XMLHTTPREQUESTUPLOAD, target->toXMLHttpRequestUpload());
return v8::Local<v8::Object>::New(v8::Handle<v8::Object>::Cast(value));
+
+ } else if (target->toMessagePort()) {
+ v8::Handle<v8::Value> value = V8Proxy::ToV8Object(
+ V8ClassIndex::MESSAGEPORT, target->toMessagePort());
+ return v8::Local<v8::Object>::New(v8::Handle<v8::Object>::Cast(value));
} else {
ASSERT(false);
@@ -237,16 +243,16 @@ v8::Local<v8::Object> V8EventListener::GetThisObject(Event* event,
// ------- V 8 X H R E v e n t L i s t e n e r -----------------
-static void WeakXHRListenerCallback(v8::Persistent<v8::Value> obj,
+static void WeakObjectEventListenerCallback(v8::Persistent<v8::Value> obj,
void* para) {
- V8XHREventListener* listener = static_cast<V8XHREventListener*>(para);
+ V8ObjectEventListener* listener = static_cast<V8ObjectEventListener*>(para);
// Remove the wrapper
Frame* frame = listener->frame();
if (frame) {
V8Proxy* proxy = V8Proxy::retrieve(frame);
if (proxy)
- proxy->RemoveXHREventListener(listener);
+ proxy->RemoveObjectEventListener(listener);
// Because the listener is no longer in the list, it must
// be disconnected from the frame to avoid dangling frame pointer
@@ -259,21 +265,21 @@ static void WeakXHRListenerCallback(v8::Persistent<v8::Value> obj,
}
-V8XHREventListener::V8XHREventListener(Frame* frame,
+V8ObjectEventListener::V8ObjectEventListener(Frame* frame,
v8::Local<v8::Object> listener,
bool html)
: V8EventListener(frame, listener, html) {
// make m_listener weak.
- m_listener.MakeWeak(this, WeakXHRListenerCallback);
+ m_listener.MakeWeak(this, WeakObjectEventListenerCallback);
}
-V8XHREventListener::~V8XHREventListener() {
+V8ObjectEventListener::~V8ObjectEventListener() {
if (m_frame) {
ASSERT(!m_listener.IsEmpty());
V8Proxy* proxy = V8Proxy::retrieve(m_frame);
if (proxy)
- proxy->RemoveXHREventListener(this);
+ proxy->RemoveObjectEventListener(this);
}
DisposeListenerObject();
diff --git a/webkit/port/bindings/v8/v8_events.h b/webkit/port/bindings/v8/v8_events.h
index 72e077a..5ff5e96 100644
--- a/webkit/port/bindings/v8/v8_events.h
+++ b/webkit/port/bindings/v8/v8_events.h
@@ -72,7 +72,7 @@ class V8AbstractEventListener : public EventListener {
int m_columnNumber;
friend class V8EventListener;
- friend class V8XHREventListener;
+ friend class V8ObjectEventListener;
friend class V8LazyEventListener;
};
@@ -102,16 +102,16 @@ class V8EventListener : public V8AbstractEventListener {
};
-// V8XHREventListener is a special listener wrapper for XMLHttpRequest object.
-// It keeps JS listener week.
-class V8XHREventListener : public V8EventListener {
+// V8ObjectEventListener is a special listener wrapper for objects not
+// in the DOM. It keeps the JS listener as a weak pointer.
+class V8ObjectEventListener : public V8EventListener {
public:
- static PassRefPtr<V8XHREventListener> create(Frame* frame,
+ static PassRefPtr<V8ObjectEventListener> create(Frame* frame,
v8::Local<v8::Object> listener, bool html) {
- return adoptRef(new V8XHREventListener(frame, listener, html));
+ return adoptRef(new V8ObjectEventListener(frame, listener, html));
}
- V8XHREventListener(Frame* frame, v8::Local<v8::Object> listener, bool html);
- virtual ~V8XHREventListener();
+ V8ObjectEventListener(Frame* frame, v8::Local<v8::Object> listener, bool html);
+ virtual ~V8ObjectEventListener();
};
diff --git a/webkit/port/bindings/v8/v8_index.cpp b/webkit/port/bindings/v8/v8_index.cpp
index 902ebfb..d785d73 100644
--- a/webkit/port/bindings/v8/v8_index.cpp
+++ b/webkit/port/bindings/v8/v8_index.cpp
@@ -102,7 +102,6 @@
#include "V8HTMLIFrameElement.h"
#include "V8HTMLImageElement.h"
#include "V8HTMLInputElement.h"
-#include "V8HTMLSelectionInputElement.h"
#include "V8HTMLIsIndexElement.h"
#include "V8HTMLLabelElement.h"
#include "V8HTMLLegendElement.h"
@@ -135,13 +134,14 @@
#include "V8ImageData.h"
#include "V8InspectorController.h"
#include "V8MediaList.h"
+#include "V8MessageChannel.h"
#include "V8MessageEvent.h"
+#include "V8MessagePort.h"
#include "V8NamedNodeMap.h"
#include "V8Node.h"
#include "V8NodeList.h"
#include "V8NodeFilter.h"
#include "V8Notation.h"
-#include "V8NSResolver.h"
#include "V8ProcessingInstruction.h"
#include "V8ProgressEvent.h"
#include "V8StyleSheet.h"
diff --git a/webkit/port/bindings/v8/v8_index.h b/webkit/port/bindings/v8/v8_index.h
index 109f702..5ba923d 100644
--- a/webkit/port/bindings/v8/v8_index.h
+++ b/webkit/port/bindings/v8/v8_index.h
@@ -61,7 +61,6 @@ typedef v8::Persistent<v8::FunctionTemplate> (*FunctionTemplateFactory)();
V(HTMLIFRAMEELEMENT, HTMLIFrameElement) \
V(HTMLIMAGEELEMENT, HTMLImageElement) \
V(HTMLINPUTELEMENT, HTMLInputElement) \
- V(HTMLSELECTIONINPUTELEMENT, HTMLSelectionInputElement) \
V(HTMLISINDEXELEMENT, HTMLIsIndexElement) \
V(HTMLLABELELEMENT, HTMLLabelElement) \
V(HTMLLEGENDELEMENT, HTMLLegendElement) \
@@ -251,7 +250,9 @@ typedef v8::Persistent<v8::FunctionTemplate> (*FunctionTemplateFactory)();
V(KEYBOARDEVENT, KeyboardEvent) \
V(LOCATION, Location) \
V(MEDIALIST, MediaList) \
+ V(MESSAGECHANNEL, MessageChannel) \
V(MESSAGEEVENT, MessageEvent) \
+ V(MESSAGEPORT, MessagePort) \
V(MIMETYPE, MimeType) \
V(MIMETYPEARRAY, MimeTypeArray) \
V(MOUSEEVENT, MouseEvent) \
@@ -261,7 +262,6 @@ typedef v8::Persistent<v8::FunctionTemplate> (*FunctionTemplateFactory)();
V(NODEFILTER, NodeFilter) \
V(NODEITERATOR, NodeIterator) \
V(NODELIST, NodeList) \
- V(NSRESOLVER, NSResolver) \
V(OVERFLOWEVENT, OverflowEvent) \
V(PLUGIN, Plugin) \
V(PLUGINARRAY, PluginArray) \
diff --git a/webkit/port/bindings/v8/v8_proxy.cpp b/webkit/port/bindings/v8/v8_proxy.cpp
index f21197b..4e84ae1 100644
--- a/webkit/port/bindings/v8/v8_proxy.cpp
+++ b/webkit/port/bindings/v8/v8_proxy.cpp
@@ -903,44 +903,48 @@ PassRefPtr<V8EventListener> V8Proxy::FindOrCreateV8EventListener(v8::Local<v8::V
}
-// XMLHttpRequest(XHR) event listeners are different from listeners
-// on DOM nodes. A XHR event listener wrapper only hold a weak reference
-// to the JS function. A strong reference can create a cycle.
+// Object event listeners (such as XmlHttpRequest and MessagePort) are
+// different from listeners on DOM nodes. An object event listener wrapper
+// only holds a weak reference to the JS function. A strong reference can
+// create a cycle.
//
-// The lifetime of a XHR object is bounded by the life time of its JS_XHR
-// object. So we can create a hidden reference from JS_XHR to JS function.
+// The lifetime of these objects is bounded by the life time of its JS
+// wrapper. So we can create a hidden reference from the JS wrapper to
+// to its JS function.
//
// (peer)
-// XHR <---------- JS_XHR
+// XHR <---------- JS_wrapper
// | (hidden) : ^
// V V : (may reachable by closure)
// V8_listener --------> JS_function
// (weak) <-- may create a cycle if it is strong
//
// The persistent reference is made weak in the constructor
-// of V8XHREventListener.
+// of V8ObjectEventListener.
-PassRefPtr<V8EventListener> V8Proxy::FindXHREventListener(
+PassRefPtr<V8EventListener> V8Proxy::FindObjectEventListener(
v8::Local<v8::Value> listener, bool html)
{
return FindEventListenerInList(m_xhr_listeners, listener, html);
}
-PassRefPtr<V8EventListener> V8Proxy::FindOrCreateXHREventListener(
+PassRefPtr<V8EventListener> V8Proxy::FindOrCreateObjectEventListener(
v8::Local<v8::Value> obj, bool html)
{
ASSERT(v8::Context::InContext());
- if (!obj->IsObject()) return 0;
+ if (!obj->IsObject())
+ return 0;
V8EventListener* wrapper =
FindEventListenerInList(m_xhr_listeners, obj, html);
- if (wrapper) return wrapper;
+ if (wrapper)
+ return wrapper;
// Create a new one, and add to cache.
RefPtr<V8EventListener> new_listener =
- V8XHREventListener::create(m_frame, v8::Local<v8::Object>::Cast(obj), html);
+ V8ObjectEventListener::create(m_frame, v8::Local<v8::Object>::Cast(obj), html);
m_xhr_listeners.push_back(new_listener.get());
return new_listener.release();
@@ -967,7 +971,7 @@ void V8Proxy::RemoveV8EventListener(V8EventListener* listener)
}
-void V8Proxy::RemoveXHREventListener(V8XHREventListener* listener)
+void V8Proxy::RemoveObjectEventListener(V8ObjectEventListener* listener)
{
RemoveEventListenerFromList(m_xhr_listeners, listener);
}
@@ -1120,7 +1124,8 @@ v8::Local<v8::Value> V8Proxy::CallFunction(v8::Handle<v8::Function> function,
// of recursion that stems from calling functions. This is in
// contrast to the script evaluations.
v8::Local<v8::Value> result;
- { ConsoleMessageScope scope;
+ {
+ ConsoleMessageScope scope;
// Evaluating the JavaScript could cause the frame to be deallocated,
// so we start the keep alive timer here.
@@ -1145,7 +1150,8 @@ v8::Persistent<v8::FunctionTemplate> V8Proxy::GetTemplate(
{
v8::Persistent<v8::FunctionTemplate>* cache_cell =
V8ClassIndex::GetCache(type);
- if (!(*cache_cell).IsEmpty()) return *cache_cell;
+ if (!(*cache_cell).IsEmpty())
+ return *cache_cell;
// not found
FunctionTemplateFactory factory = V8ClassIndex::GetFactory(type);
@@ -1377,6 +1383,18 @@ v8::Persistent<v8::FunctionTemplate> V8Proxy::GetTemplate(
break;
}
+ case V8ClassIndex::MESSAGECHANNEL:
+ desc->SetCallHandler(USE_CALLBACK(MessageChannelConstructor));
+ break;
+ case V8ClassIndex::MESSAGEPORT: {
+ // Reserve one more internal field for keeping event listeners.
+ v8::Local<v8::ObjectTemplate> instance_template =
+ desc->InstanceTemplate();
+ instance_template->SetInternalFieldCount(
+ V8Custom::kMessagePortInternalFieldCount);
+ break;
+ }
+
// DOMParser, XMLSerializer, and XMLHttpRequest objects are created from
// JS world, but we setup the constructor function lazily in
// WindowNamedPropertyHandler::get.
@@ -1388,12 +1406,12 @@ v8::Persistent<v8::FunctionTemplate> V8Proxy::GetTemplate(
break;
case V8ClassIndex::XMLHTTPREQUEST: {
// Reserve one more internal field for keeping event listeners.
- v8::Local<v8::ObjectTemplate> instance_template =
- desc->InstanceTemplate();
- instance_template->SetInternalFieldCount(
- V8Custom::kXMLHttpRequestInternalFieldCount);
- desc->SetCallHandler(USE_CALLBACK(XMLHttpRequestConstructor));
- break;
+ v8::Local<v8::ObjectTemplate> instance_template =
+ desc->InstanceTemplate();
+ instance_template->SetInternalFieldCount(
+ V8Custom::kXMLHttpRequestInternalFieldCount);
+ desc->SetCallHandler(USE_CALLBACK(XMLHttpRequestConstructor));
+ break;
}
case V8ClassIndex::XMLHTTPREQUESTUPLOAD: {
// Reserve one more internal field for keeping event listeners.
@@ -1702,7 +1720,11 @@ static void GenerateSecurityToken(v8::Local<v8::Context> context)
// Ask the document's SecurityOrigin to generate a security token.
// If two tokens are equal, then the SecurityOrigins canAccess each other.
// If two tokens are not equal, then we have to call canAccess.
- String token = document->securityOrigin()->securityToken();
+ // Note: we can't use the HTTPOrigin if it was set from the DOM.
+ SecurityOrigin* origin = document->securityOrigin();
+ String token;
+ if (!origin->domainWasSetInDOM())
+ token = document->securityOrigin()->toString();
// An empty token means we always have to call canAccess. In this case, we
// use the global object as the security token to avoid calling canAccess
@@ -2120,13 +2142,6 @@ v8::Local<v8::Object> V8Proxy::InstantiateV8Object(
desc_type = V8ClassIndex::UNDETECTABLEHTMLCOLLECTION;
}
- // Special case for HTMLInputElements that support selection.
- if (desc_type == V8ClassIndex::HTMLINPUTELEMENT) {
- HTMLInputElement* element = static_cast<HTMLInputElement*>(imp);
- if (element->canHaveSelection())
- desc_type = V8ClassIndex::HTMLSELECTIONINPUTELEMENT;
- }
-
v8::Persistent<v8::FunctionTemplate> desc = GetTemplate(desc_type);
v8::Local<v8::Function> function = desc->GetFunction();
v8::Local<v8::Object> instance = SafeAllocation::NewInstance(function);
diff --git a/webkit/port/bindings/v8/v8_proxy.h b/webkit/port/bindings/v8/v8_proxy.h
index f1b558f..5c2c246 100644
--- a/webkit/port/bindings/v8/v8_proxy.h
+++ b/webkit/port/bindings/v8/v8_proxy.h
@@ -70,7 +70,7 @@ class SVGElementInstance;
#endif
class V8EventListener;
-class V8XHREventListener;
+class V8ObjectEventListener;
typedef std::list<V8EventListener*> V8EventListenerList;
// TODO(fqian): use standard logging facilities in WebCore.
@@ -197,13 +197,13 @@ class V8Proxy {
PassRefPtr<V8EventListener> FindOrCreateV8EventListener(v8::Local<v8::Value> listener,
bool html);
- PassRefPtr<V8EventListener> FindXHREventListener(v8::Local<v8::Value> listener,
+ PassRefPtr<V8EventListener> FindObjectEventListener(v8::Local<v8::Value> listener,
bool html);
- PassRefPtr<V8EventListener> FindOrCreateXHREventListener(v8::Local<v8::Value> listener,
+ PassRefPtr<V8EventListener> FindOrCreateObjectEventListener(v8::Local<v8::Value> listener,
bool html);
void RemoveV8EventListener(V8EventListener* listener);
- void RemoveXHREventListener(V8XHREventListener* listener);
+ void RemoveObjectEventListener(V8ObjectEventListener* listener);
// Protect/Unprotect JS wrappers of a DOM object.
static void GCProtect(Peerable* dom_object);
diff --git a/webkit/port/bindings/v8/v8_utility.h b/webkit/port/bindings/v8/v8_utility.h
index 5e7df97..2dd52bf 100644
--- a/webkit/port/bindings/v8/v8_utility.h
+++ b/webkit/port/bindings/v8/v8_utility.h
@@ -33,7 +33,8 @@ class SafeAllocation {
v8::Local<v8::Object> SafeAllocation::NewInstance(
v8::Handle<v8::Function> fun) {
- if (fun.IsEmpty()) return v8::Local<v8::Object>();
+ if (fun.IsEmpty())
+ return v8::Local<v8::Object>();
AllowAllocation allow;
return fun->NewInstance();
}
diff --git a/webkit/port/bindings/v8/v8_vectornodelist.cpp b/webkit/port/bindings/v8/v8_vectornodelist.cpp
index 7e19cf8..f9341aa 100644
--- a/webkit/port/bindings/v8/v8_vectornodelist.cpp
+++ b/webkit/port/bindings/v8/v8_vectornodelist.cpp
@@ -30,6 +30,7 @@
#include "config.h"
#include "v8_vectornodelist.h"
+#include "Element.h"
#include "NamedAttrMap.h" // Node::attributes
namespace WebCore {