summaryrefslogtreecommitdiffstats
path: root/WebCore/bindings/cpp/WebDOMEventTarget.cpp
diff options
context:
space:
mode:
authorBen Murdoch <benm@google.com>2010-06-15 19:36:43 +0100
committerBen Murdoch <benm@google.com>2010-06-16 14:52:28 +0100
commit545e470e52f0ac6a3a072bf559c796b42c6066b6 (patch)
treec0c14763654d84d37577dde512c3d3b4699a9e86 /WebCore/bindings/cpp/WebDOMEventTarget.cpp
parent719298a66237d38ea5c05f1547123ad8aacbc237 (diff)
downloadexternal_webkit-545e470e52f0ac6a3a072bf559c796b42c6066b6.zip
external_webkit-545e470e52f0ac6a3a072bf559c796b42c6066b6.tar.gz
external_webkit-545e470e52f0ac6a3a072bf559c796b42c6066b6.tar.bz2
Merge webkit.org at r61121: Initial merge by git.
Change-Id: Icd6db395c62285be384d137164d95d7466c98760
Diffstat (limited to 'WebCore/bindings/cpp/WebDOMEventTarget.cpp')
-rw-r--r--WebCore/bindings/cpp/WebDOMEventTarget.cpp155
1 files changed, 155 insertions, 0 deletions
diff --git a/WebCore/bindings/cpp/WebDOMEventTarget.cpp b/WebCore/bindings/cpp/WebDOMEventTarget.cpp
new file mode 100644
index 0000000..2eaef00
--- /dev/null
+++ b/WebCore/bindings/cpp/WebDOMEventTarget.cpp
@@ -0,0 +1,155 @@
+/*
+ * 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 "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 "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;
+}
+
+WebCore::EventTarget* toWebCore(const WebDOMEventTarget& wrapper)
+{
+ return wrapper.impl();
+}
+
+WebDOMEventTarget toWebKit(WebCore::EventTarget* value)
+{
+#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 (WebCore::Node* node = value->toNode())
+ return toWebKit(node);
+
+ if (WebCore::XMLHttpRequest* xhr = value->toXMLHttpRequest())
+ return toWebKit(xhr);
+
+ if (WebCore::XMLHttpRequestUpload* upload = value->toXMLHttpRequestUpload())
+ return toWebKit(upload);
+
+#if ENABLE(OFFLINE_WEB_APPLICATIONS)
+ if (WebCore::DOMApplicationCache* cache = value->toDOMApplicationCache())
+ return toWebKit(cache);
+#endif
+
+ if (WebCore::MessagePort* messagePort = value->toMessagePort())
+ return toWebKit(messagePort);
+
+#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();
+}