diff options
author | Kristian Monsen <kristianm@google.com> | 2010-06-28 16:42:48 +0100 |
---|---|---|
committer | Kristian Monsen <kristianm@google.com> | 2010-07-02 10:29:56 +0100 |
commit | 06ea8e899e48f1f2f396b70e63fae369f2f23232 (patch) | |
tree | 20c1428cd05c76f32394ab354ea35ed99acd86d8 /WebCore/bindings/cpp | |
parent | 72aad67af14193199e29cdd5c4ddc095a8b9a8a8 (diff) | |
download | external_webkit-06ea8e899e48f1f2f396b70e63fae369f2f23232.zip external_webkit-06ea8e899e48f1f2f396b70e63fae369f2f23232.tar.gz external_webkit-06ea8e899e48f1f2f396b70e63fae369f2f23232.tar.bz2 |
Merge WebKit at r61871: Initial merge by git.
Change-Id: I6cff43abca9cc4782e088a469ad4f03f166a65d5
Diffstat (limited to 'WebCore/bindings/cpp')
-rw-r--r-- | WebCore/bindings/cpp/WebDOMDOMWindowCustom.cpp | 43 | ||||
-rw-r--r-- | WebCore/bindings/cpp/WebDOMEventTarget.cpp | 68 | ||||
-rw-r--r-- | WebCore/bindings/cpp/WebDOMEventTarget.h | 30 | ||||
-rw-r--r-- | WebCore/bindings/cpp/WebDOMHTMLCollectionCustom.cpp | 42 | ||||
-rw-r--r-- | WebCore/bindings/cpp/WebDOMHTMLOptionsCollectionCustom.cpp | 42 | ||||
-rw-r--r-- | WebCore/bindings/cpp/WebDOMNodeFilterCustom.cpp | 44 | ||||
-rw-r--r-- | WebCore/bindings/cpp/WebNativeNodeFilterCondition.cpp | 40 | ||||
-rw-r--r-- | WebCore/bindings/cpp/WebNativeNodeFilterCondition.h | 43 |
8 files changed, 338 insertions, 14 deletions
diff --git a/WebCore/bindings/cpp/WebDOMDOMWindowCustom.cpp b/WebCore/bindings/cpp/WebDOMDOMWindowCustom.cpp new file mode 100644 index 0000000..5dd9ec4 --- /dev/null +++ b/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/WebCore/bindings/cpp/WebDOMEventTarget.cpp b/WebCore/bindings/cpp/WebDOMEventTarget.cpp index 2eaef00..b24bc84 100644 --- a/WebCore/bindings/cpp/WebDOMEventTarget.cpp +++ b/WebCore/bindings/cpp/WebDOMEventTarget.cpp @@ -22,6 +22,7 @@ #include "WebDOMEventTarget.h" #include "DOMApplicationCache.h" +#include "DOMWindow.h" #include "DedicatedWorkerContext.h" #include "EventSource.h" #include "MessagePort.h" @@ -31,6 +32,7 @@ #include "SharedWorkerContext.h" #include "ThreadCheck.h" #include "WebDOMDOMApplicationCache.h" +#include "WebDOMDOMWindow.h" #include "WebDOMDedicatedWorkerContext.h" #include "WebDOMEventSource.h" #include "WebDOMMessagePort.h" @@ -88,6 +90,45 @@ 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(); @@ -95,6 +136,21 @@ WebCore::EventTarget* toWebCore(const WebDOMEventTarget& wrapper) 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); @@ -107,23 +163,11 @@ WebDOMEventTarget toWebKit(WebCore::EventTarget* value) 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); diff --git a/WebCore/bindings/cpp/WebDOMEventTarget.h b/WebCore/bindings/cpp/WebDOMEventTarget.h index f5360ca..d514372 100644 --- a/WebCore/bindings/cpp/WebDOMEventTarget.h +++ b/WebCore/bindings/cpp/WebDOMEventTarget.h @@ -26,6 +26,20 @@ 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(); @@ -35,8 +49,20 @@ public: WebCore::EventTarget* impl() const; - // FIXME: Add a possibility to check what kind of EventTarget we have, - // to be able to cast eg. a WebDOMEventTarget to a WebDOMNode + 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(); protected: struct WebDOMEventTargetPrivate; diff --git a/WebCore/bindings/cpp/WebDOMHTMLCollectionCustom.cpp b/WebCore/bindings/cpp/WebDOMHTMLCollectionCustom.cpp new file mode 100644 index 0000000..3f3378c --- /dev/null +++ b/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 "AtomicString.h" +#include "HTMLCollection.h" +#include "WebDOMNode.h" +#include <wtf/GetPtr.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/WebCore/bindings/cpp/WebDOMHTMLOptionsCollectionCustom.cpp b/WebCore/bindings/cpp/WebDOMHTMLOptionsCollectionCustom.cpp new file mode 100644 index 0000000..7e2eb25 --- /dev/null +++ b/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/WebCore/bindings/cpp/WebDOMNodeFilterCustom.cpp b/WebCore/bindings/cpp/WebDOMNodeFilterCustom.cpp new file mode 100644 index 0000000..565fa61 --- /dev/null +++ b/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/WebCore/bindings/cpp/WebNativeNodeFilterCondition.cpp b/WebCore/bindings/cpp/WebNativeNodeFilterCondition.cpp new file mode 100644 index 0000000..3d30810 --- /dev/null +++ b/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/WebCore/bindings/cpp/WebNativeNodeFilterCondition.h b/WebCore/bindings/cpp/WebNativeNodeFilterCondition.h new file mode 100644 index 0000000..33d2786 --- /dev/null +++ b/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 |