summaryrefslogtreecommitdiffstats
path: root/Source/WebCore/bindings/cpp
diff options
context:
space:
mode:
authorSteve Block <steveblock@google.com>2011-05-06 11:45:16 +0100
committerSteve Block <steveblock@google.com>2011-05-12 13:44:10 +0100
commitcad810f21b803229eb11403f9209855525a25d57 (patch)
tree29a6fd0279be608e0fe9ffe9841f722f0f4e4269 /Source/WebCore/bindings/cpp
parent121b0cf4517156d0ac5111caf9830c51b69bae8f (diff)
downloadexternal_webkit-cad810f21b803229eb11403f9209855525a25d57.zip
external_webkit-cad810f21b803229eb11403f9209855525a25d57.tar.gz
external_webkit-cad810f21b803229eb11403f9209855525a25d57.tar.bz2
Merge WebKit at r75315: Initial merge by git.
Change-Id: I570314b346ce101c935ed22a626b48c2af266b84
Diffstat (limited to 'Source/WebCore/bindings/cpp')
-rw-r--r--Source/WebCore/bindings/cpp/WebDOMCString.cpp113
-rw-r--r--Source/WebCore/bindings/cpp/WebDOMCString.h86
-rw-r--r--Source/WebCore/bindings/cpp/WebDOMCustomVoidCallback.cpp48
-rw-r--r--Source/WebCore/bindings/cpp/WebDOMCustomVoidCallback.h55
-rw-r--r--Source/WebCore/bindings/cpp/WebDOMDOMWindowCustom.cpp43
-rw-r--r--Source/WebCore/bindings/cpp/WebDOMEventListenerCustom.cpp39
-rw-r--r--Source/WebCore/bindings/cpp/WebDOMEventTarget.cpp206
-rw-r--r--Source/WebCore/bindings/cpp/WebDOMEventTarget.h76
-rw-r--r--Source/WebCore/bindings/cpp/WebDOMHTMLCollectionCustom.cpp42
-rw-r--r--Source/WebCore/bindings/cpp/WebDOMHTMLDocumentCustom.cpp52
-rw-r--r--Source/WebCore/bindings/cpp/WebDOMHTMLOptionsCollectionCustom.cpp42
-rw-r--r--Source/WebCore/bindings/cpp/WebDOMNodeCustom.cpp96
-rw-r--r--Source/WebCore/bindings/cpp/WebDOMNodeFilterCustom.cpp44
-rw-r--r--Source/WebCore/bindings/cpp/WebDOMObject.h32
-rw-r--r--Source/WebCore/bindings/cpp/WebDOMString.cpp124
-rw-r--r--Source/WebCore/bindings/cpp/WebDOMString.h95
-rw-r--r--Source/WebCore/bindings/cpp/WebExceptionHandler.cpp41
-rw-r--r--Source/WebCore/bindings/cpp/WebExceptionHandler.h40
-rw-r--r--Source/WebCore/bindings/cpp/WebNativeEventListener.cpp53
-rw-r--r--Source/WebCore/bindings/cpp/WebNativeEventListener.h54
-rw-r--r--Source/WebCore/bindings/cpp/WebNativeNodeFilterCondition.cpp40
-rw-r--r--Source/WebCore/bindings/cpp/WebNativeNodeFilterCondition.h43
22 files changed, 1464 insertions, 0 deletions
diff --git a/Source/WebCore/bindings/cpp/WebDOMCString.cpp b/Source/WebCore/bindings/cpp/WebDOMCString.cpp
new file mode 100644
index 0000000..ab87ac8
--- /dev/null
+++ b/Source/WebCore/bindings/cpp/WebDOMCString.cpp
@@ -0,0 +1,113 @@
+/*
+ * Copyright (C) Research In Motion Limited 2010. All rights reserved.
+ * Copyright (C) 2009 Google Inc. All rights reserved.
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Library General Public
+ * License as published by the Free Software Foundation; either
+ * version 2 of the License, or (at your option) any later version.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Library General Public License for more details.
+ *
+ * You should have received a copy of the GNU Library General Public License
+ * along with this library; see the file COPYING.LIB. If not, write to
+ * the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
+ * Boston, MA 02110-1301, USA.
+ */
+
+#include "config.h"
+#include "WebDOMCString.h"
+
+#include "TextEncoding.h"
+#include "WebDOMString.h"
+#include <wtf/text/CString.h>
+
+class WebDOMCStringPrivate : public WTF::CStringBuffer {
+};
+
+void WebDOMCString::reset()
+{
+ if (m_private) {
+ m_private->deref();
+ m_private = 0;
+ }
+}
+
+void WebDOMCString::assign(const WebDOMCString& other)
+{
+ assign(const_cast<WebDOMCStringPrivate*>(other.m_private));
+}
+
+void WebDOMCString::assign(const char* data, size_t length)
+{
+ char* newData;
+ RefPtr<WTF::CStringBuffer> buffer =
+ WTF::CString::newUninitialized(length, newData).buffer();
+ memcpy(newData, data, length);
+ assign(static_cast<WebDOMCStringPrivate*>(buffer.get()));
+}
+
+size_t WebDOMCString::length() const
+{
+ if (!m_private)
+ return 0;
+ // NOTE: The buffer's length includes the null byte.
+ return const_cast<WebDOMCStringPrivate*>(m_private)->length() - 1;
+}
+
+const char* WebDOMCString::data() const
+{
+ if (!m_private)
+ return 0;
+ return const_cast<WebDOMCStringPrivate*>(m_private)->data();
+}
+
+WebDOMString WebDOMCString::utf16() const
+{
+ return WebCore::UTF8Encoding().decode(data(), length());
+}
+
+WebDOMCString WebDOMCString::fromUTF16(const WebUChar* data, size_t length)
+{
+ return WebCore::UTF8Encoding().encode(
+ data, length, WebCore::QuestionMarksForUnencodables);
+}
+
+WebDOMCString WebDOMCString::fromUTF16(const WebUChar* data)
+{
+ size_t len = 0;
+ while (data[len] != WebUChar(0))
+ len++;
+ return fromUTF16(data, len);
+}
+
+WebDOMCString::WebDOMCString(const WTF::CString& s)
+ : m_private(static_cast<WebDOMCStringPrivate*>(s.buffer()))
+{
+ if (m_private)
+ m_private->ref();
+}
+
+WebDOMCString& WebDOMCString::operator=(const WTF::CString& s)
+{
+ assign(static_cast<WebDOMCStringPrivate*>(s.buffer()));
+ return *this;
+}
+
+WebDOMCString::operator WTF::CString() const
+{
+ return m_private;
+}
+
+void WebDOMCString::assign(WebDOMCStringPrivate* p)
+{
+ // Take care to handle the case where m_private == p
+ if (p)
+ p->ref();
+ if (m_private)
+ m_private->deref();
+ m_private = p;
+}
diff --git a/Source/WebCore/bindings/cpp/WebDOMCString.h b/Source/WebCore/bindings/cpp/WebDOMCString.h
new file mode 100644
index 0000000..c921895
--- /dev/null
+++ b/Source/WebCore/bindings/cpp/WebDOMCString.h
@@ -0,0 +1,86 @@
+/*
+ * Copyright (C) Research In Motion Limited 2010. All rights reserved.
+ * Copyright (C) 2009 Google Inc. All rights reserved.
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Library General Public
+ * License as published by the Free Software Foundation; either
+ * version 2 of the License, or (at your option) any later version.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Library General Public License for more details.
+ *
+ * You should have received a copy of the GNU Library General Public License
+ * along with this library; see the file COPYING.LIB. If not, write to
+ * the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
+ * Boston, MA 02110-1301, USA.
+ */
+
+#ifndef WebDOMCString_h
+#define WebDOMCString_h
+
+#include <WebDOMObject.h>
+#include <wtf/Forward.h>
+#include <stddef.h> // For size_t
+
+// UTF-16 character type
+#if defined(WIN32)
+typedef wchar_t WebUChar;
+#else
+typedef unsigned short WebUChar;
+#endif
+
+class WebDOMCStringPrivate;
+class WebDOMString;
+
+// A single-byte string container with unspecified encoding. It is
+// inexpensive to copy a WebDOMCString object.
+//
+// WARNING: It is not safe to pass a WebDOMCString across threads!!!
+//
+class WebDOMCString {
+public:
+ ~WebDOMCString() { reset(); }
+
+ WebDOMCString() : m_private(0) { }
+
+ WebDOMCString(const char* data, size_t len) : m_private(0)
+ {
+ assign(data, len);
+ }
+
+ WebDOMCString(const WebDOMCString& s) : m_private(0) { assign(s); }
+
+ WebDOMCString& operator=(const WebDOMCString& s)
+ {
+ assign(s);
+ return *this;
+ }
+
+ void reset();
+ void assign(const WebDOMCString&);
+ void assign(const char* data, size_t len);
+
+ size_t length() const;
+ const char* data() const;
+
+ bool isEmpty() const { return !length(); }
+ bool isNull() const { return !m_private; }
+
+ WebDOMString utf16() const;
+
+ static WebDOMCString fromUTF16(const WebUChar* data, size_t length);
+ static WebDOMCString fromUTF16(const WebUChar* data);
+
+ WebDOMCString(const WTF::CString&);
+ WebDOMCString& operator=(const WTF::CString&);
+ operator WTF::CString() const;
+
+private:
+ void assign(WebDOMCStringPrivate*);
+ WebDOMCStringPrivate* m_private;
+};
+
+#endif
diff --git a/Source/WebCore/bindings/cpp/WebDOMCustomVoidCallback.cpp b/Source/WebCore/bindings/cpp/WebDOMCustomVoidCallback.cpp
new file mode 100644
index 0000000..d79eaae
--- /dev/null
+++ b/Source/WebCore/bindings/cpp/WebDOMCustomVoidCallback.cpp
@@ -0,0 +1,48 @@
+/*
+ * Copyright (C) 2010 Kevin Ollivier <kevino@theolliviers.com>. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ *
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * 2. 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.
+ * 3. Neither the name of Apple Computer, Inc. ("Apple") 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 APPLE AND ITS 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 APPLE OR ITS 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 "WebDOMCustomVoidCallback.h"
+
+WebDOMCustomVoidCallback::WebDOMCustomVoidCallback()
+{
+}
+
+WebDOMCustomVoidCallback::~WebDOMCustomVoidCallback()
+{
+}
+
+void WebDOMCustomVoidCallback::handleEvent()
+{
+
+}
+
+WebCore::VoidCallback* toWebCore(const WebDOMCustomVoidCallback& callback)
+{
+ return const_cast<WebCore::VoidCallback*>((WebCore::VoidCallback*)&callback);
+} \ No newline at end of file
diff --git a/Source/WebCore/bindings/cpp/WebDOMCustomVoidCallback.h b/Source/WebCore/bindings/cpp/WebDOMCustomVoidCallback.h
new file mode 100644
index 0000000..0fd8f96
--- /dev/null
+++ b/Source/WebCore/bindings/cpp/WebDOMCustomVoidCallback.h
@@ -0,0 +1,55 @@
+/*
+ * Copyright (C) Kevin Ollivier <kevino@theolliviers.com>. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ *
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * 2. 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.
+ * 3. Neither the name of Apple Computer, Inc. ("Apple") 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 APPLE AND ITS 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 APPLE OR ITS 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 WebDOMCustomVoidCallback_h
+#define WebDOMCustomVoidCallback_h
+
+#include "VoidCallback.h"
+#include <wtf/PassRefPtr.h>
+
+// FIXME: This is just a stub to keep compilation working. We need to revisit
+// this when we add support for these callbacks to the WebDOM bindings.
+
+class WebDOMCustomVoidCallback : public WebCore::VoidCallback {
+public:
+ static PassRefPtr<WebDOMCustomVoidCallback> create()
+ {
+ return adoptRef(new WebDOMCustomVoidCallback());
+ }
+
+ virtual ~WebDOMCustomVoidCallback();
+
+ virtual void handleEvent();
+
+private:
+ WebDOMCustomVoidCallback();
+};
+
+WebCore::VoidCallback* toWebCore(const WebDOMCustomVoidCallback&);
+
+#endif // WebDOMCustomVoidCallback_h
diff --git a/Source/WebCore/bindings/cpp/WebDOMDOMWindowCustom.cpp b/Source/WebCore/bindings/cpp/WebDOMDOMWindowCustom.cpp
new file mode 100644
index 0000000..5dd9ec4
--- /dev/null
+++ b/Source/WebCore/bindings/cpp/WebDOMDOMWindowCustom.cpp
@@ -0,0 +1,43 @@
+/*
+ * Copyright (C) Research In Motion Limited 2010. All rights reserved.
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Library General Public
+ * License as published by the Free Software Foundation; either
+ * version 2 of the License, or (at your option) any later version.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Library General Public License for more details.
+ *
+ * You should have received a copy of the GNU Library General Public License
+ * along with this library; see the file COPYING.LIB. If not, write to
+ * the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
+ * Boston, MA 02110-1301, USA.
+ */
+
+#include "config.h"
+#include "WebDOMDOMWindow.h"
+
+#include "DOMWindow.h"
+#include "WebDOMEventListener.h"
+#include "WebNativeEventListener.h"
+
+void WebDOMDOMWindow::addEventListener(const WebDOMString& type, const WebDOMEventListener& listener, bool useCapture)
+{
+ if (!impl())
+ return;
+
+ if (toWebCore(listener))
+ impl()->addEventListener(type, toWebCore(listener), useCapture);
+}
+
+void WebDOMDOMWindow::removeEventListener(const WebDOMString& type, const WebDOMEventListener& listener, bool useCapture)
+{
+ if (!impl())
+ return;
+
+ if (toWebCore(listener))
+ impl()->removeEventListener(type, toWebCore(listener), useCapture);
+}
diff --git a/Source/WebCore/bindings/cpp/WebDOMEventListenerCustom.cpp b/Source/WebCore/bindings/cpp/WebDOMEventListenerCustom.cpp
new file mode 100644
index 0000000..db31b71
--- /dev/null
+++ b/Source/WebCore/bindings/cpp/WebDOMEventListenerCustom.cpp
@@ -0,0 +1,39 @@
+/*
+ * Copyright (C) Research In Motion Limited 2010. All rights reserved.
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Library General Public
+ * License as published by the Free Software Foundation; either
+ * version 2 of the License, or (at your option) any later version.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Library General Public License for more details.
+ *
+ * You should have received a copy of the GNU Library General Public License
+ * along with this library; see the file COPYING.LIB. If not, write to
+ * the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
+ * Boston, MA 02110-1301, USA.
+ */
+
+#include "config.h"
+#include "WebDOMEventListener.h"
+
+#include "WebDOMEvent.h"
+#include "WebNativeEventListener.h"
+#include <wtf/RefPtr.h>
+
+void WebDOMEventListener::handleEvent(const WebDOMEvent& evt)
+{
+ if (!impl())
+ return;
+
+ impl()->handleEvent(0, toWebCore(evt));
+}
+
+WebDOMEventListener toWebKit(WebUserEventListener* value)
+{
+ RefPtr<WebNativeEventListener> listener = WebNativeEventListener::create(value);
+ return WebDOMEventListener(listener.get());
+}
diff --git a/Source/WebCore/bindings/cpp/WebDOMEventTarget.cpp b/Source/WebCore/bindings/cpp/WebDOMEventTarget.cpp
new file mode 100644
index 0000000..7dee138
--- /dev/null
+++ b/Source/WebCore/bindings/cpp/WebDOMEventTarget.cpp
@@ -0,0 +1,206 @@
+/*
+ * Copyright (C) Research In Motion Limited 2010. All rights reserved.
+ * Copyright (C) 2008 Apple Inc. All Rights Reserved.
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Library General Public
+ * License as published by the Free Software Foundation; either
+ * version 2 of the License, or (at your option) any later version.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Library General Public License for more details.
+ *
+ * You should have received a copy of the GNU Library General Public License
+ * along with this library; see the file COPYING.LIB. If not, write to
+ * the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
+ * Boston, MA 02110-1301, USA.
+ */
+
+#include "config.h"
+#include "WebDOMEventTarget.h"
+
+#include "DOMApplicationCache.h"
+#include "DOMWindow.h"
+#include "DedicatedWorkerContext.h"
+#include "EventSource.h"
+#include "MessagePort.h"
+#include "Node.h"
+#include "Notification.h"
+#include "SharedWorker.h"
+#include "SharedWorkerContext.h"
+#include "ThreadCheck.h"
+#include "WebDOMDOMApplicationCache.h"
+#include "WebDOMDOMWindow.h"
+#include "WebDOMDedicatedWorkerContext.h"
+#include "WebDOMEventSource.h"
+#include "WebDOMMessagePort.h"
+#include "WebDOMNode.h"
+#include "WebDOMNotification.h"
+#include "WebDOMSharedWorker.h"
+#include "WebDOMSharedWorkerContext.h"
+#include "WebDOMWebSocket.h"
+#include "WebDOMWorker.h"
+#include "WebDOMXMLHttpRequest.h"
+#include "WebDOMXMLHttpRequestUpload.h"
+#include "WebExceptionHandler.h"
+#include "WebSocket.h"
+#include "Worker.h"
+#include "XMLHttpRequest.h"
+#include "XMLHttpRequestUpload.h"
+
+#include <wtf/RefPtr.h>
+
+struct WebDOMEventTarget::WebDOMEventTargetPrivate {
+ WebDOMEventTargetPrivate(WebCore::EventTarget* object = 0)
+ : impl(object)
+ {
+ }
+
+ RefPtr<WebCore::EventTarget> impl;
+};
+
+WebDOMEventTarget::WebDOMEventTarget()
+ : WebDOMObject()
+ , m_impl(0)
+{
+}
+
+WebDOMEventTarget::WebDOMEventTarget(WebCore::EventTarget* impl)
+ : WebDOMObject()
+ , m_impl(new WebDOMEventTargetPrivate(impl))
+{
+}
+
+WebDOMEventTarget::WebDOMEventTarget(const WebDOMEventTarget& copy)
+ : WebDOMObject()
+{
+ m_impl = copy.impl() ? new WebDOMEventTargetPrivate(copy.impl()) : 0;
+}
+
+WebDOMEventTarget::~WebDOMEventTarget()
+{
+ delete m_impl;
+ m_impl = 0;
+}
+
+WebCore::EventTarget* WebDOMEventTarget::impl() const
+{
+ return m_impl ? m_impl->impl.get() : 0;
+}
+
+#define ConvertTo(type) \
+WebDOM##type WebDOMEventTarget::to##type() \
+{ \
+ WebCore::EventTarget* target = impl(); \
+ return WebDOM##type(target ? target->to##type() : 0); \
+}
+
+ConvertTo(Node)
+ConvertTo(DOMWindow)
+ConvertTo(XMLHttpRequest)
+ConvertTo(XMLHttpRequestUpload)
+ConvertTo(MessagePort)
+
+#if ENABLE(EVENTSOURCE)
+ConvertTo(EventSource)
+#endif
+
+#if ENABLE(OFFLINE_WEB_APPLICATIONS)
+ConvertTo(DOMApplicationCache)
+#endif
+
+#if ENABLE(WORKERS)
+ConvertTo(Worker)
+ConvertTo(DedicatedWorkerContext)
+#endif
+
+#if ENABLE(SHARED_WORKERS)
+ConvertTo(SharedWorker)
+ConvertTo(SharedWorkerContext)
+#endif
+
+#if ENABLE(NOTIFICATIONS)
+ConvertTo(Notification)
+#endif
+
+#if ENABLE(WEB_SOCKETS)
+ConvertTo(WebSocket)
+#endif
+
+WebCore::EventTarget* toWebCore(const WebDOMEventTarget& wrapper)
+{
+ return wrapper.impl();
+}
+
+WebDOMEventTarget toWebKit(WebCore::EventTarget* value)
+{
+ if (WebCore::Node* node = value->toNode())
+ return toWebKit(node);
+
+ if (WebCore::DOMWindow* window = value->toDOMWindow())
+ return toWebKit(window);
+
+ if (WebCore::XMLHttpRequest* xhr = value->toXMLHttpRequest())
+ return toWebKit(xhr);
+
+ if (WebCore::XMLHttpRequestUpload* upload = value->toXMLHttpRequestUpload())
+ return toWebKit(upload);
+
+ if (WebCore::MessagePort* messagePort = value->toMessagePort())
+ return toWebKit(messagePort);
+
+#if ENABLE(EVENTSOURCE)
+ if (WebCore::EventSource* eventSource = value->toEventSource())
+ return toWebKit(eventSource);
+#endif
+
+#if ENABLE(SVG) && 0
+ // FIXME: Enable once SVG bindings are generated.
+ // SVGElementInstance supports both toSVGElementInstance and toNode since so much mouse handling code depends on toNode returning a valid node.
+ if (WebCore::SVGElementInstance* instance = value->toSVGElementInstance())
+ return toWebKit(instance);
+#endif
+
+#if ENABLE(OFFLINE_WEB_APPLICATIONS)
+ if (WebCore::DOMApplicationCache* cache = value->toDOMApplicationCache())
+ return toWebKit(cache);
+#endif
+
+#if ENABLE(WORKERS)
+ if (WebCore::Worker* worker = value->toWorker())
+ return toWebKit(worker);
+
+ if (WebCore::DedicatedWorkerContext* workerContext = value->toDedicatedWorkerContext())
+ return toWebKit(workerContext);
+#endif
+
+#if ENABLE(SHARED_WORKERS)
+ if (WebCore::SharedWorker* sharedWorker = value->toSharedWorker())
+ return toWebKit(sharedWorker);
+
+ if (WebCore::SharedWorkerContext* workerContext = value->toSharedWorkerContext())
+ return toWebKit(workerContext);
+#endif
+
+#if ENABLE(NOTIFICATIONS)
+ if (WebCore::Notification* notification = value->toNotification())
+ return toWebKit(notification);
+#endif
+
+#if ENABLE(WEB_SOCKETS)
+ if (WebCore::WebSocket* webSocket = value->toWebSocket())
+ return toWebKit(webSocket);
+#endif
+
+ ASSERT_NOT_REACHED();
+ return WebDOMEventTarget();
+}
+
+WebDOMEventTarget& WebDOMEventTarget::operator=(const WebDOMEventTarget& copy)
+{
+ delete m_impl;
+ m_impl = copy.impl() ? new WebDOMEventTargetPrivate(copy.impl()) : 0;
+ return *this;
+}
diff --git a/Source/WebCore/bindings/cpp/WebDOMEventTarget.h b/Source/WebCore/bindings/cpp/WebDOMEventTarget.h
new file mode 100644
index 0000000..4548a8b
--- /dev/null
+++ b/Source/WebCore/bindings/cpp/WebDOMEventTarget.h
@@ -0,0 +1,76 @@
+/*
+ * Copyright (C) Research In Motion Limited 2010. All rights reserved.
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Library General Public
+ * License as published by the Free Software Foundation; either
+ * version 2 of the License, or (at your option) any later version.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Library General Public License for more details.
+ *
+ * You should have received a copy of the GNU Library General Public License
+ * along with this library; see the file COPYING.LIB. If not, write to
+ * the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
+ * Boston, MA 02110-1301, USA.
+ */
+
+#ifndef WebDOMEventTarget_h
+#define WebDOMEventTarget_h
+
+#include <WebDOMObject.h>
+
+namespace WebCore {
+class EventTarget;
+};
+
+class WebDOMDedicatedWorkerContext;
+class WebDOMDOMApplicationCache;
+class WebDOMDOMWindow;
+class WebDOMEventSource;
+class WebDOMMessagePort;
+class WebDOMNode;
+class WebDOMNotification;
+class WebDOMSharedWorker;
+class WebDOMSharedWorkerContext;
+class WebDOMWebSocket;
+class WebDOMWorker;
+class WebDOMXMLHttpRequest;
+class WebDOMXMLHttpRequestUpload;
+
+class WebDOMEventTarget : public WebDOMObject {
+public:
+ WebDOMEventTarget();
+ explicit WebDOMEventTarget(WebCore::EventTarget*);
+ WebDOMEventTarget(const WebDOMEventTarget&);
+ ~WebDOMEventTarget();
+
+ WebCore::EventTarget* impl() const;
+
+ WebDOMNode toNode();
+ WebDOMDOMWindow toDOMWindow();
+ WebDOMXMLHttpRequest toXMLHttpRequest();
+ WebDOMXMLHttpRequestUpload toXMLHttpRequestUpload();
+ WebDOMMessagePort toMessagePort();
+
+ WebDOMEventSource toEventSource();
+ WebDOMDOMApplicationCache toDOMApplicationCache();
+ WebDOMWorker toWorker();
+ WebDOMDedicatedWorkerContext toDedicatedWorkerContext();
+ WebDOMSharedWorker toSharedWorker();
+ WebDOMSharedWorkerContext toSharedWorkerContext();
+ WebDOMNotification toNotification();
+ WebDOMWebSocket toWebSocket();
+
+ WebDOMEventTarget& operator=(const WebDOMEventTarget&);
+protected:
+ struct WebDOMEventTargetPrivate;
+ WebDOMEventTargetPrivate* m_impl;
+};
+
+WebCore::EventTarget* toWebCore(const WebDOMEventTarget&);
+WebDOMEventTarget toWebKit(WebCore::EventTarget*);
+
+#endif
diff --git a/Source/WebCore/bindings/cpp/WebDOMHTMLCollectionCustom.cpp b/Source/WebCore/bindings/cpp/WebDOMHTMLCollectionCustom.cpp
new file mode 100644
index 0000000..a16a329
--- /dev/null
+++ b/Source/WebCore/bindings/cpp/WebDOMHTMLCollectionCustom.cpp
@@ -0,0 +1,42 @@
+/*
+ * Copyright (C) Research In Motion Limited 2010. All rights reserved.
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Library General Public
+ * License as published by the Free Software Foundation; either
+ * version 2 of the License, or (at your option) any later version.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Library General Public License for more details.
+ *
+ * You should have received a copy of the GNU Library General Public License
+ * along with this library; see the file COPYING.LIB. If not, write to
+ * the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
+ * Boston, MA 02110-1301, USA.
+ */
+
+#include "config.h"
+#include "WebDOMHTMLCollection.h"
+
+#include "HTMLCollection.h"
+#include "WebDOMNode.h"
+#include <wtf/GetPtr.h>
+#include <wtf/text/AtomicString.h>
+
+WebDOMNode WebDOMHTMLCollection::item(unsigned index)
+{
+ if (!impl())
+ return WebDOMNode();
+
+ return toWebKit(WTF::getPtr(impl()->item(index)));
+}
+
+WebDOMNode WebDOMHTMLCollection::namedItem(const WebDOMString& name)
+{
+ if (!impl())
+ return WebDOMNode();
+
+ return toWebKit(WTF::getPtr(impl()->namedItem(name)));
+}
diff --git a/Source/WebCore/bindings/cpp/WebDOMHTMLDocumentCustom.cpp b/Source/WebCore/bindings/cpp/WebDOMHTMLDocumentCustom.cpp
new file mode 100644
index 0000000..d608b0f
--- /dev/null
+++ b/Source/WebCore/bindings/cpp/WebDOMHTMLDocumentCustom.cpp
@@ -0,0 +1,52 @@
+/*
+ * Copyright (C) Research In Motion Limited 2010. All rights reserved.
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Library General Public
+ * License as published by the Free Software Foundation; either
+ * version 2 of the License, or (at your option) any later version.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Library General Public License for more details.
+ *
+ * You should have received a copy of the GNU Library General Public License
+ * along with this library; see the file COPYING.LIB. If not, write to
+ * the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
+ * Boston, MA 02110-1301, USA.
+ */
+
+#include "config.h"
+#include "WebDOMHTMLDocument.h"
+
+#include "CharacterNames.h"
+#include "HTMLDocument.h"
+#include "SegmentedString.h"
+#include "WebExceptionHandler.h"
+
+#include <wtf/Forward.h>
+
+static inline void documentWrite(const WebDOMString& text, WebCore::HTMLDocument* document, bool addNewline)
+{
+ WebCore::SegmentedString segmentedString = WTF::String(text);
+ if (addNewline)
+ segmentedString.append(WebCore::SegmentedString(WTF::String(&WebCore::newlineCharacter)));
+ document->write(segmentedString);
+}
+
+void WebDOMHTMLDocument::write(const WebDOMString& text)
+{
+ if (!impl())
+ return;
+
+ documentWrite(text, impl(), false);
+}
+
+void WebDOMHTMLDocument::writeln(const WebDOMString& text)
+{
+ if (!impl())
+ return;
+
+ documentWrite(text, impl(), true);
+}
diff --git a/Source/WebCore/bindings/cpp/WebDOMHTMLOptionsCollectionCustom.cpp b/Source/WebCore/bindings/cpp/WebDOMHTMLOptionsCollectionCustom.cpp
new file mode 100644
index 0000000..7e2eb25
--- /dev/null
+++ b/Source/WebCore/bindings/cpp/WebDOMHTMLOptionsCollectionCustom.cpp
@@ -0,0 +1,42 @@
+/*
+ * Copyright (C) Research In Motion Limited 2010. All rights reserved.
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Library General Public
+ * License as published by the Free Software Foundation; either
+ * version 2 of the License, or (at your option) any later version.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Library General Public License for more details.
+ *
+ * You should have received a copy of the GNU Library General Public License
+ * along with this library; see the file COPYING.LIB. If not, write to
+ * the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
+ * Boston, MA 02110-1301, USA.
+ */
+
+#include "config.h"
+#include "WebDOMHTMLOptionsCollection.h"
+
+#include "HTMLOptionsCollection.h"
+#include "WebExceptionHandler.h"
+
+unsigned WebDOMHTMLOptionsCollection::length() const
+{
+ if (!impl())
+ return 0;
+
+ return impl()->length();
+}
+
+void WebDOMHTMLOptionsCollection::setLength(unsigned length)
+{
+ if (!impl())
+ return;
+
+ WebCore::ExceptionCode ec = 0;
+ impl()->setLength(length, ec);
+ webDOMRaiseError(static_cast<WebDOMExceptionCode>(ec));
+}
diff --git a/Source/WebCore/bindings/cpp/WebDOMNodeCustom.cpp b/Source/WebCore/bindings/cpp/WebDOMNodeCustom.cpp
new file mode 100644
index 0000000..41abb0c
--- /dev/null
+++ b/Source/WebCore/bindings/cpp/WebDOMNodeCustom.cpp
@@ -0,0 +1,96 @@
+/*
+ * Copyright (C) Research In Motion Limited 2010. All rights reserved.
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Library General Public
+ * License as published by the Free Software Foundation; either
+ * version 2 of the License, or (at your option) any later version.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Library General Public License for more details.
+ *
+ * You should have received a copy of the GNU Library General Public License
+ * along with this library; see the file COPYING.LIB. If not, write to
+ * the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
+ * Boston, MA 02110-1301, USA.
+ */
+
+#include "config.h"
+#include "WebDOMNode.h"
+
+#include "Node.h"
+#include "WebDOMEventListener.h"
+#include "WebExceptionHandler.h"
+#include "WebNativeEventListener.h"
+
+WebDOMNode WebDOMNode::insertBefore(const WebDOMNode& newChild, const WebDOMNode& refChild)
+{
+ if (!impl())
+ return WebDOMNode();
+
+ WebCore::ExceptionCode ec = 0;
+ if (impl()->insertBefore(toWebCore(newChild), toWebCore(refChild), ec, true))
+ return newChild;
+
+ webDOMRaiseError(static_cast<WebDOMExceptionCode>(ec));
+ return WebDOMNode();
+}
+
+WebDOMNode WebDOMNode::replaceChild(const WebDOMNode& newChild, const WebDOMNode& oldChild)
+{
+ if (!impl())
+ return WebDOMNode();
+
+ WebCore::ExceptionCode ec = 0;
+ if (impl()->replaceChild(toWebCore(newChild), toWebCore(oldChild), ec, true))
+ return oldChild;
+
+ webDOMRaiseError(static_cast<WebDOMExceptionCode>(ec));
+ return WebDOMNode();
+}
+
+WebDOMNode WebDOMNode::removeChild(const WebDOMNode& oldChild)
+{
+ if (!impl())
+ return WebDOMNode();
+
+ WebCore::ExceptionCode ec = 0;
+ if (impl()->removeChild(toWebCore(oldChild), ec))
+ return oldChild;
+
+ webDOMRaiseError(static_cast<WebDOMExceptionCode>(ec));
+ return WebDOMNode();
+}
+
+WebDOMNode WebDOMNode::appendChild(const WebDOMNode& newChild)
+{
+ if (!impl())
+ return WebDOMNode();
+
+ WebCore::ExceptionCode ec = 0;
+ if (impl()->appendChild(toWebCore(newChild), ec, true))
+ return newChild;
+
+ webDOMRaiseError(static_cast<WebDOMExceptionCode>(ec));
+ return WebDOMNode();
+}
+
+void WebDOMNode::addEventListener(const WebDOMString& type, const WebDOMEventListener& listener, bool useCapture)
+{
+ if (!impl())
+ return;
+
+ if (toWebCore(listener))
+ impl()->addEventListener(type, toWebCore(listener), useCapture);
+}
+
+void WebDOMNode::removeEventListener(const WebDOMString& type, const WebDOMEventListener& listener, bool useCapture)
+{
+ if (!impl())
+ return;
+
+ if (toWebCore(listener))
+ impl()->removeEventListener(type, toWebCore(listener), useCapture);
+}
diff --git a/Source/WebCore/bindings/cpp/WebDOMNodeFilterCustom.cpp b/Source/WebCore/bindings/cpp/WebDOMNodeFilterCustom.cpp
new file mode 100644
index 0000000..565fa61
--- /dev/null
+++ b/Source/WebCore/bindings/cpp/WebDOMNodeFilterCustom.cpp
@@ -0,0 +1,44 @@
+/*
+ * Copyright (C) Research In Motion Limited 2010. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * 2. 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.
+ *
+ * THIS SOFTWARE IS PROVIDED BY APPLE COMPUTER, INC. ``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 APPLE COMPUTER, INC. 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 "WebDOMNodeFilter.h"
+
+#include "WebDOMNode.h"
+#include "WebNativeNodeFilterCondition.h"
+
+short WebDOMNodeFilter::acceptNode(const WebDOMNode& n)
+{
+ if (!impl())
+ return 0;
+
+ return impl()->acceptNode(0, toWebCore(n));
+}
+
+WebDOMNodeFilter toWebKit(WebUserNodeFilter* value)
+{
+ RefPtr<WebCore::NodeFilter> listener = WebCore::NodeFilter::create(WebNativeNodeFilterCondition::create(value));
+ return WebDOMNodeFilter(listener.get());
+}
diff --git a/Source/WebCore/bindings/cpp/WebDOMObject.h b/Source/WebCore/bindings/cpp/WebDOMObject.h
new file mode 100644
index 0000000..4d1830b
--- /dev/null
+++ b/Source/WebCore/bindings/cpp/WebDOMObject.h
@@ -0,0 +1,32 @@
+/*
+ * Copyright (C) Research In Motion Limited 2010. All rights reserved.
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Library General Public
+ * License as published by the Free Software Foundation; either
+ * version 2 of the License, or (at your option) any later version.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Library General Public License for more details.
+ *
+ * You should have received a copy of the GNU Library General Public License
+ * along with this library; see the file COPYING.LIB. If not, write to
+ * the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
+ * Boston, MA 02110-1301, USA.
+ */
+
+#ifndef WebDOMObject_h
+#define WebDOMObject_h
+
+class WebDOMObject {
+protected:
+ WebDOMObject() { }
+ ~WebDOMObject() { }
+};
+
+// Looks akward, though we prefix all classes with WebDOM
+typedef unsigned long long WebDOMDOMTimeStamp;
+
+#endif
diff --git a/Source/WebCore/bindings/cpp/WebDOMString.cpp b/Source/WebCore/bindings/cpp/WebDOMString.cpp
new file mode 100644
index 0000000..debd4f4
--- /dev/null
+++ b/Source/WebCore/bindings/cpp/WebDOMString.cpp
@@ -0,0 +1,124 @@
+/*
+ * Copyright (C) Research In Motion Limited 2010. All rights reserved.
+ * Copyright (C) 2009 Google Inc. All rights reserved.
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Library General Public
+ * License as published by the Free Software Foundation; either
+ * version 2 of the License, or (at your option) any later version.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Library General Public License for more details.
+ *
+ * You should have received a copy of the GNU Library General Public License
+ * along with this library; see the file COPYING.LIB. If not, write to
+ * the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
+ * Boston, MA 02110-1301, USA.
+ */
+
+#include "config.h"
+#include "WebDOMString.h"
+
+#include "WebDOMCString.h"
+#include <wtf/text/AtomicString.h>
+#include <wtf/text/CString.h>
+#include <wtf/text/WTFString.h>
+
+class WebDOMStringPrivate : public WTF::StringImpl {
+};
+
+void WebDOMString::reset()
+{
+ if (m_private) {
+ m_private->deref();
+ m_private = 0;
+ }
+}
+
+void WebDOMString::assign(const WebDOMString& other)
+{
+ assign(const_cast<WebDOMStringPrivate*>(other.m_private));
+}
+
+void WebDOMString::assign(const WebUChar* data, size_t length)
+{
+ assign(static_cast<WebDOMStringPrivate*>(
+ WTF::StringImpl::create(data, length).get()));
+}
+
+size_t WebDOMString::length() const
+{
+ return m_private ? const_cast<WebDOMStringPrivate*>(m_private)->length() : 0;
+}
+
+const WebUChar* WebDOMString::data() const
+{
+ return m_private ? const_cast<WebDOMStringPrivate*>(m_private)->characters() : 0;
+}
+
+WebDOMCString WebDOMString::utf8() const
+{
+ return WTF::String(m_private).utf8();
+}
+
+WebDOMString WebDOMString::fromUTF8(const char* data, size_t length)
+{
+ return WTF::String::fromUTF8(data, length);
+}
+
+WebDOMString WebDOMString::fromUTF8(const char* data)
+{
+ return WTF::String::fromUTF8(data);
+}
+
+WebDOMString::WebDOMString(const WTF::String& s)
+ : m_private(static_cast<WebDOMStringPrivate*>(s.impl()))
+{
+ if (m_private)
+ m_private->ref();
+}
+
+WebDOMString& WebDOMString::operator=(const WTF::String& s)
+{
+ assign(static_cast<WebDOMStringPrivate*>(s.impl()));
+ return *this;
+}
+
+WebDOMString::operator WTF::String() const
+{
+ return m_private;
+}
+
+WebDOMString::WebDOMString(const WTF::AtomicString& s)
+ : m_private(0)
+{
+ assign(s.string());
+}
+
+WebDOMString& WebDOMString::operator=(const WTF::AtomicString& s)
+{
+ assign(s.string());
+ return *this;
+}
+
+WebDOMString::operator WTF::AtomicString() const
+{
+ return WTF::AtomicString(static_cast<WTF::StringImpl *>(m_private));
+}
+
+bool WebDOMString::equals(const char* string) const
+{
+ return WTF::equal(m_private, string);
+}
+
+void WebDOMString::assign(WebDOMStringPrivate* p)
+{
+ // Take care to handle the case where m_private == p
+ if (p)
+ p->ref();
+ if (m_private)
+ m_private->deref();
+ m_private = p;
+}
diff --git a/Source/WebCore/bindings/cpp/WebDOMString.h b/Source/WebCore/bindings/cpp/WebDOMString.h
new file mode 100644
index 0000000..0eea1ae
--- /dev/null
+++ b/Source/WebCore/bindings/cpp/WebDOMString.h
@@ -0,0 +1,95 @@
+/*
+ * Copyright (C) Research In Motion Limited 2010. All rights reserved.
+ * Copyright (C) 2009 Google Inc. All rights reserved.
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Library General Public
+ * License as published by the Free Software Foundation; either
+ * version 2 of the License, or (at your option) any later version.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Library General Public License for more details.
+ *
+ * You should have received a copy of the GNU Library General Public License
+ * along with this library; see the file COPYING.LIB. If not, write to
+ * the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
+ * Boston, MA 02110-1301, USA.
+ */
+
+#ifndef WebDOMString_h
+#define WebDOMString_h
+
+#include <WebDOMCString.h>
+#include <wtf/Forward.h>
+
+class WebDOMStringPrivate;
+
+// A UTF-16 string container. It is inexpensive to copy a WebDOMString
+// object.
+//
+// WARNING: It is not safe to pass a WebDOMString across threads!!!
+//
+class WebDOMString {
+public:
+ ~WebDOMString() { reset(); }
+
+ WebDOMString() : m_private(0) { }
+
+ WebDOMString(const WebUChar* data, size_t len) : m_private(0)
+ {
+ assign(data, len);
+ }
+
+ WebDOMString(const WebDOMString& s) : m_private(0) { assign(s); }
+
+ WebDOMString& operator=(const WebDOMString& s)
+ {
+ assign(s);
+ return *this;
+ }
+
+ void reset();
+ void assign(const WebDOMString&);
+ void assign(const WebUChar* data, size_t len);
+
+ size_t length() const;
+ const WebUChar* data() const;
+
+ bool isEmpty() const { return !length(); }
+ bool isNull() const { return !m_private; }
+
+ WebDOMCString utf8() const;
+
+ static WebDOMString fromUTF8(const char* data, size_t length);
+ static WebDOMString fromUTF8(const char* data);
+
+ template <int N> WebDOMString(const char (&data)[N])
+ : m_private(0)
+ {
+ assign(fromUTF8(data, N - 1));
+ }
+
+ template <int N> WebDOMString& operator=(const char (&data)[N])
+ {
+ assign(fromUTF8(data, N - 1));
+ return *this;
+ }
+
+ WebDOMString(const WTF::String&);
+ WebDOMString& operator=(const WTF::String&);
+ operator WTF::String() const;
+
+ WebDOMString(const WTF::AtomicString&);
+ WebDOMString& operator=(const WTF::AtomicString&);
+ operator WTF::AtomicString() const;
+
+ bool equals(const char* string) const;
+
+private:
+ void assign(WebDOMStringPrivate*);
+ WebDOMStringPrivate* m_private;
+};
+
+#endif
diff --git a/Source/WebCore/bindings/cpp/WebExceptionHandler.cpp b/Source/WebCore/bindings/cpp/WebExceptionHandler.cpp
new file mode 100644
index 0000000..f285525
--- /dev/null
+++ b/Source/WebCore/bindings/cpp/WebExceptionHandler.cpp
@@ -0,0 +1,41 @@
+/*
+ * Copyright (C) Research In Motion Limited 2010. All rights reserved.
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Library General Public
+ * License as published by the Free Software Foundation; either
+ * version 2 of the License, or (at your option) any later version.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Library General Public License for more details.
+ *
+ * You should have received a copy of the GNU Library General Public License
+ * along with this library; see the file COPYING.LIB. If not, write to
+ * the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
+ * Boston, MA 02110-1301, USA.
+ */
+
+#include "config.h"
+#include "WebExceptionHandler.h"
+
+// To avoid a global static symbol, we declare it in a function
+static inline WebExceptionHandler& globalExceptionHandler()
+{
+ static WebExceptionHandler s_globalExceptionHandler;
+ return s_globalExceptionHandler;
+}
+
+void webInstallExceptionHandler(WebExceptionHandler handler)
+{
+ ASSERT(handler);
+ globalExceptionHandler() = handler;
+}
+
+void webRaiseDOMException(WebDOMExceptionCode ec)
+{
+ ASSERT(ec);
+ if (WebExceptionHandler& handler = globalExceptionHandler())
+ (*handler)(ec);
+}
diff --git a/Source/WebCore/bindings/cpp/WebExceptionHandler.h b/Source/WebCore/bindings/cpp/WebExceptionHandler.h
new file mode 100644
index 0000000..e679254
--- /dev/null
+++ b/Source/WebCore/bindings/cpp/WebExceptionHandler.h
@@ -0,0 +1,40 @@
+/*
+ * Copyright (C) Research In Motion Limited 2010. All rights reserved.
+ * Copyright (C) 2004, 2005, 2006, 2007 Apple Inc. All rights reserved.
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Library General Public
+ * License as published by the Free Software Foundation; either
+ * version 2 of the License, or (at your option) any later version.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Library General Public License for more details.
+ *
+ * You should have received a copy of the GNU Library General Public License
+ * along with this library; see the file COPYING.LIB. If not, write to
+ * the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
+ * Boston, MA 02110-1301, USA.
+ */
+
+#ifndef WebExceptionHandler_h
+#define WebExceptionHandler_h
+
+typedef int WebDOMExceptionCode;
+typedef void (*WebExceptionHandler)(WebDOMExceptionCode);
+
+// Used from the outside to register a callback that gets fired whenever an exception is raised
+void webInstallExceptionHandler(WebExceptionHandler);
+
+// Never used by the bindings, only indirectly by webDOMRaiseError
+void webRaiseDOMException(WebDOMExceptionCode);
+
+// Used from the bindings
+inline void webDOMRaiseError(WebDOMExceptionCode ec)
+{
+ if (ec)
+ webRaiseDOMException(ec);
+}
+
+#endif
diff --git a/Source/WebCore/bindings/cpp/WebNativeEventListener.cpp b/Source/WebCore/bindings/cpp/WebNativeEventListener.cpp
new file mode 100644
index 0000000..b781eb7
--- /dev/null
+++ b/Source/WebCore/bindings/cpp/WebNativeEventListener.cpp
@@ -0,0 +1,53 @@
+/*
+ * Copyright (C) Research In Motion Limited 2010. All rights reserved.
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Library General Public
+ * License as published by the Free Software Foundation; either
+ * version 2 of the License, or (at your option) any later version.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Library General Public License for more details.
+ *
+ * You should have received a copy of the GNU Library General Public License
+ * along with this library; see the file COPYING.LIB. If not, write to
+ * the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
+ * Boston, MA 02110-1301, USA.
+ */
+
+#include "config.h"
+#include "WebNativeEventListener.h"
+
+#include "WebDOMEvent.h"
+
+WebNativeEventListener::WebNativeEventListener(WebUserEventListener* listener)
+ : WebCore::EventListener(CPPEventListenerType),
+ m_listener(listener)
+{
+ ASSERT(m_listener);
+ m_listener->ref();
+}
+
+WebNativeEventListener::~WebNativeEventListener()
+{
+ m_listener->deref();
+}
+
+void WebNativeEventListener::handleEvent(WebCore::ScriptExecutionContext*, WebCore::Event* event)
+{
+ m_listener->handleEvent(toWebKit(event));
+}
+
+bool WebNativeEventListener::reportError(WebCore::ScriptExecutionContext*, const WTF::String&, const WTF::String&, int)
+{
+ // FIXME: Implement error handling
+ return false;
+}
+
+bool WebNativeEventListener::operator==(const WebCore::EventListener& other)
+{
+ const WebNativeEventListener* ptrOther = cast(&other);
+ return ptrOther && m_listener == ptrOther->m_listener;
+}
diff --git a/Source/WebCore/bindings/cpp/WebNativeEventListener.h b/Source/WebCore/bindings/cpp/WebNativeEventListener.h
new file mode 100644
index 0000000..13b4f5b
--- /dev/null
+++ b/Source/WebCore/bindings/cpp/WebNativeEventListener.h
@@ -0,0 +1,54 @@
+/*
+ * Copyright (C) Research In Motion Limited 2010. All rights reserved.
+ * Copyright (C) 2001 Peter Kelly (pmk@post.com)
+ * Copyright (C) 2003, 2008, 2009 Apple Inc. All rights reserved.
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Library General Public
+ * License as published by the Free Software Foundation; either
+ * version 2 of the License, or (at your option) any later version.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Library General Public License for more details.
+ *
+ * You should have received a copy of the GNU Library General Public License
+ * along with this library; see the file COPYING.LIB. If not, write to
+ * the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
+ * Boston, MA 02110-1301, USA.
+ */
+
+#ifndef WebNativeEventListener_h
+#define WebNativeEventListener_h
+
+#include "EventListener.h"
+#include "WebDOMEventListener.h"
+
+class WebNativeEventListener : public WebCore::EventListener {
+public:
+ static PassRefPtr<WebNativeEventListener> create(WebUserEventListener* listener)
+ {
+ return adoptRef(new WebNativeEventListener(listener));
+ }
+
+ static const WebNativeEventListener* cast(const WebCore::EventListener* listener)
+ {
+ return listener->type() == CPPEventListenerType
+ ? static_cast<const WebNativeEventListener*>(listener)
+ : 0;
+ }
+
+ virtual ~WebNativeEventListener();
+ virtual bool operator==(const WebCore::EventListener& other);
+
+private:
+ virtual void handleEvent(WebCore::ScriptExecutionContext*, WebCore::Event*);
+ virtual bool reportError(WebCore::ScriptExecutionContext*, const WTF::String& message, const WTF::String& url, int lineNumber);
+
+protected:
+ WebNativeEventListener(WebUserEventListener*);
+ WebUserEventListener* m_listener;
+};
+
+#endif
diff --git a/Source/WebCore/bindings/cpp/WebNativeNodeFilterCondition.cpp b/Source/WebCore/bindings/cpp/WebNativeNodeFilterCondition.cpp
new file mode 100644
index 0000000..3d30810
--- /dev/null
+++ b/Source/WebCore/bindings/cpp/WebNativeNodeFilterCondition.cpp
@@ -0,0 +1,40 @@
+/*
+ * Copyright (C) Research In Motion Limited 2010. All rights reserved.
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 2 of the License, or (at your option) any later version.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
+ */
+
+#include "config.h"
+#include "WebNativeNodeFilterCondition.h"
+
+#include "WebDOMNode.h"
+
+WebNativeNodeFilterCondition::WebNativeNodeFilterCondition(WebUserNodeFilter* filter)
+ : WebCore::NodeFilterCondition()
+ , m_filter(filter)
+{
+ ASSERT(m_filter);
+ m_filter->ref();
+}
+
+WebNativeNodeFilterCondition::~WebNativeNodeFilterCondition()
+{
+ m_filter->deref();
+}
+
+short WebNativeNodeFilterCondition::acceptNode(WebCore::ScriptState*, WebCore::Node* node) const
+{
+ return m_filter->acceptNode(toWebKit(node));
+}
diff --git a/Source/WebCore/bindings/cpp/WebNativeNodeFilterCondition.h b/Source/WebCore/bindings/cpp/WebNativeNodeFilterCondition.h
new file mode 100644
index 0000000..33d2786
--- /dev/null
+++ b/Source/WebCore/bindings/cpp/WebNativeNodeFilterCondition.h
@@ -0,0 +1,43 @@
+/*
+ * Copyright (C) Research In Motion Limited 2010. All rights reserved.
+ * Copyright (C) 2001 Peter Kelly (pmk@post.com)
+ * Copyright (C) 2003, 2008, 2009 Apple Inc. All rights reserved.
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 2 of the License, or (at your option) any later version.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
+ */
+
+#ifndef WebNativeNodeFilterCondition_h
+#define WebNativeNodeFilterCondition_h
+
+#include "NodeFilter.h"
+#include "WebDOMNodeFilter.h"
+
+class WebNativeNodeFilterCondition : public WebCore::NodeFilterCondition {
+public:
+ static PassRefPtr<WebNativeNodeFilterCondition> create(WebUserNodeFilter* filter)
+ {
+ return adoptRef(new WebNativeNodeFilterCondition(filter));
+ }
+
+ virtual ~WebNativeNodeFilterCondition();
+
+ virtual short acceptNode(WebCore::ScriptState*, WebCore::Node*) const;
+
+protected:
+ WebNativeNodeFilterCondition(WebUserNodeFilter*);
+ WebUserNodeFilter* m_filter;
+};
+
+#endif