Diff
Modified: trunk/Source/WebKit/chromium/ChangeLog (98380 => 98381)
--- trunk/Source/WebKit/chromium/ChangeLog 2011-10-25 19:50:25 UTC (rev 98380)
+++ trunk/Source/WebKit/chromium/ChangeLog 2011-10-25 20:01:34 UTC (rev 98381)
@@ -1,3 +1,29 @@
+2011-10-25 Dave Michael <dmich...@chromium.org>
+
+ Make it possible to create and dispatch a message event through chromium API
+
+ Removed messageChannels parameter, since it's hard to get right and I don't need it. Changed message_data->messageData. Reordered includes.
+
+ https://bugs.webkit.org/show_bug.cgi?id=69962
+
+ Reviewed by David Levin.
+
+ * WebKit.gyp:
+ * public/WebDOMEvent.h:
+ * public/WebDOMMessageEvent.h: Added.
+ * public/WebDocument.h:
+ * public/WebNode.h:
+ * src/PlatformMessagePortChannel.cpp:
+ (WebCore::PlatformMessagePortChannel::hasPendingActivity):
+ * src/WebDOMEvent.cpp:
+ (WebKit::WebDOMEvent::operator WTF::PassRefPtr<WebCore::Event>):
+ * src/WebDOMMessageEvent.cpp: Added.
+ (WebKit::WebDOMMessageEvent::initMessageEvent):
+ * src/WebDocument.cpp:
+ (WebKit::WebDocument::createEvent):
+ * src/WebNode.cpp:
+ (WebKit::WebNode::dispatchEvent):
+
2011-10-25 Gene Girard <gir...@chromium.org>
Re-enable touch tests (from 66577)
Modified: trunk/Source/WebKit/chromium/WebKit.gyp (98380 => 98381)
--- trunk/Source/WebKit/chromium/WebKit.gyp 2011-10-25 19:50:25 UTC (rev 98380)
+++ trunk/Source/WebKit/chromium/WebKit.gyp 2011-10-25 20:01:34 UTC (rev 98381)
@@ -140,6 +140,7 @@
'public/WebCursorInfo.h',
'public/WebDOMEvent.h',
'public/WebDOMEventListener.h',
+ 'public/WebDOMMessageEvent.h',
'public/WebDOMMouseEvent.h',
'public/WebDOMMutationEvent.h',
'public/WebDOMStringList.h',
@@ -462,6 +463,7 @@
'src/WebDOMEventListener.cpp',
'src/WebDOMEventListenerPrivate.cpp',
'src/WebDOMEventListenerPrivate.h',
+ 'src/WebDOMMessageEvent.cpp',
'src/WebDOMMouseEvent.cpp',
'src/WebDOMMutationEvent.cpp',
'src/WebDOMStringList.cpp',
Modified: trunk/Source/WebKit/chromium/public/WebDOMEvent.h (98380 => 98381)
--- trunk/Source/WebKit/chromium/public/WebDOMEvent.h 2011-10-25 19:50:25 UTC (rev 98380)
+++ trunk/Source/WebKit/chromium/public/WebDOMEvent.h 2011-10-25 20:01:34 UTC (rev 98381)
@@ -95,6 +95,7 @@
#if WEBKIT_IMPLEMENTATION
WebDOMEvent(const WTF::PassRefPtr<WebCore::Event>&);
+ operator WTF::PassRefPtr<WebCore::Event>() const;
#endif
template<typename T> T to()
Added: trunk/Source/WebKit/chromium/public/WebDOMMessageEvent.h (0 => 98381)
--- trunk/Source/WebKit/chromium/public/WebDOMMessageEvent.h (rev 0)
+++ trunk/Source/WebKit/chromium/public/WebDOMMessageEvent.h 2011-10-25 20:01:34 UTC (rev 98381)
@@ -0,0 +1,53 @@
+/*
+ * Copyright (C) 2011 Google Inc. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions are
+ * met:
+ *
+ * * Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * * Redistributions in binary form must reproduce the above
+ * copyright notice, this list of conditions and the following disclaimer
+ * in the documentation and/or other materials provided with the
+ * distribution.
+ * * Neither the name of Google Inc. nor the names of its
+ * contributors may be used to endorse or promote products derived from
+ * this software without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+ * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
+ * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
+ * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+ * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+ * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+ * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+ * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+ * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+#ifndef WebDOMMessageEvent_h
+#define WebDOMMessageEvent_h
+
+#include "WebDOMEvent.h"
+#include "WebMessagePortChannel.h"
+
+#if WEBKIT_IMPLEMENTATION
+namespace WebCore { class Event; }
+#endif
+
+namespace WebKit {
+
+class WebFrame;
+class WebString;
+class WebSerializedScriptValue;
+
+class WebDOMMessageEvent : public WebDOMEvent {
+public:
+ WEBKIT_EXPORT void initMessageEvent(const WebString& type, bool canBubble, bool cancelable, const WebSerializedScriptValue& messageData, const WebString& origin, const WebFrame& sourceFrame, const WebString& lastEventId);
+};
+
+} // namespace WebKit
+
+#endif
Modified: trunk/Source/WebKit/chromium/public/WebDocument.h (98380 => 98381)
--- trunk/Source/WebKit/chromium/public/WebDocument.h 2011-10-25 19:50:25 UTC (rev 98380)
+++ trunk/Source/WebKit/chromium/public/WebDocument.h 2011-10-25 20:01:34 UTC (rev 98381)
@@ -103,6 +103,7 @@
WEBKIT_EXPORT WebDocumentType doctype() const;
WEBKIT_EXPORT void cancelFullScreen();
WEBKIT_EXPORT WebElement fullScreenElement() const;
+ WEBKIT_EXPORT WebDOMEvent createEvent(const WebString& eventType);
// Accessibility support. These methods should only be called on the
// top-level document, because one accessibility cache spans all of
Modified: trunk/Source/WebKit/chromium/public/WebNode.h (98380 => 98381)
--- trunk/Source/WebKit/chromium/public/WebNode.h 2011-10-25 19:50:25 UTC (rev 98380)
+++ trunk/Source/WebKit/chromium/public/WebNode.h 2011-10-25 20:01:34 UTC (rev 98381)
@@ -38,6 +38,7 @@
namespace WebCore { class Node; }
namespace WebKit {
+class WebDOMEvent;
class WebDOMEventListener;
class WebDOMEventListenerPrivate;
class WebDocument;
@@ -103,6 +104,7 @@
WEBKIT_EXPORT bool isElementNode() const;
WEBKIT_EXPORT void addEventListener(const WebString& eventType, WebDOMEventListener* listener, bool useCapture);
WEBKIT_EXPORT void removeEventListener(const WebString& eventType, WebDOMEventListener* listener, bool useCapture);
+ WEBKIT_EXPORT bool dispatchEvent(const WebDOMEvent&);
WEBKIT_EXPORT void simulateClick();
WEBKIT_EXPORT WebNodeList getElementsByTagName(const WebString&) const;
Modified: trunk/Source/WebKit/chromium/src/PlatformMessagePortChannel.cpp (98380 => 98381)
--- trunk/Source/WebKit/chromium/src/PlatformMessagePortChannel.cpp 2011-10-25 19:50:25 UTC (rev 98380)
+++ trunk/Source/WebKit/chromium/src/PlatformMessagePortChannel.cpp 2011-10-25 20:01:34 UTC (rev 98381)
@@ -236,7 +236,7 @@
bool PlatformMessagePortChannel::hasPendingActivity()
{
MutexLocker lock(m_mutex);
- return m_localPort;
+ return m_localPort && m_localPort->hasPendingActivity();
}
void PlatformMessagePortChannel::setEntangledChannel(PassRefPtr<PlatformMessagePortChannel> remote)
Modified: trunk/Source/WebKit/chromium/src/WebDOMEvent.cpp (98380 => 98381)
--- trunk/Source/WebKit/chromium/src/WebDOMEvent.cpp 2011-10-25 19:50:25 UTC (rev 98380)
+++ trunk/Source/WebKit/chromium/src/WebDOMEvent.cpp 2011-10-25 20:01:34 UTC (rev 98381)
@@ -69,6 +69,11 @@
{
}
+WebDOMEvent::operator WTF::PassRefPtr<WebCore::Event>() const
+{
+ return static_cast<WebCore::Event*>(m_private);
+}
+
WebString WebDOMEvent::type() const
{
ASSERT(m_private);
Added: trunk/Source/WebKit/chromium/src/WebDOMMessageEvent.cpp (0 => 98381)
--- trunk/Source/WebKit/chromium/src/WebDOMMessageEvent.cpp (rev 0)
+++ trunk/Source/WebKit/chromium/src/WebDOMMessageEvent.cpp 2011-10-25 20:01:34 UTC (rev 98381)
@@ -0,0 +1,61 @@
+/*
+ * Copyright (C) 2011 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 "WebDOMMessageEvent.h"
+
+#include "DOMWindow.h"
+#include "MessageEvent.h"
+#include "MessagePort.h"
+#include "PlatformMessagePortChannel.h"
+#include "SerializedScriptValue.h"
+#include "WebFrame.h"
+#include "WebFrameImpl.h"
+#include "WebSerializedScriptValue.h"
+#include "WebString.h"
+
+#if USE(V8)
+#include "V8Proxy.h"
+#endif
+
+using namespace WebCore;
+
+namespace WebKit {
+
+void WebDOMMessageEvent::initMessageEvent(const WebString& type, bool canBubble, bool cancelable, const WebSerializedScriptValue& messageData, const WebString& origin, const WebFrame& sourceFrame, const WebString& lastEventId)
+{
+ ASSERT(m_private);
+ ASSERT(isMessageEvent());
+ DOMWindow* window = static_cast<const WebFrameImpl&>(sourceFrame).frame()->domWindow();
+ OwnPtr<MessagePortArray> ports;
+ unwrap<MessageEvent>()->initMessageEvent(type, canBubble, cancelable, messageData, origin, lastEventId, window, ports.release());
+}
+
+} // namespace WebKit
Modified: trunk/Source/WebKit/chromium/src/WebDocument.cpp (98380 => 98381)
--- trunk/Source/WebKit/chromium/src/WebDocument.cpp 2011-10-25 19:50:25 UTC (rev 98380)
+++ trunk/Source/WebKit/chromium/src/WebDocument.cpp 2011-10-25 20:01:34 UTC (rev 98381)
@@ -46,6 +46,7 @@
#include "NodeList.h"
#include "SecurityOrigin.h"
#include "WebAccessibilityObject.h"
+#include "WebDOMEvent.h"
#include "WebDocumentType.h"
#include "WebElement.h"
#include "WebFormElement.h"
@@ -198,6 +199,15 @@
return WebElement(fullScreenElement);
}
+WebDOMEvent WebDocument::createEvent(const WebString& eventType)
+{
+ ExceptionCode ec = 0;
+ WebDOMEvent event(unwrap<Document>()->createEvent(eventType, ec));
+ if (!ec)
+ return WebDOMEvent();
+ return event;
+}
+
WebAccessibilityObject WebDocument::accessibilityObject() const
{
const Document* document = constUnwrap<Document>();
Modified: trunk/Source/WebKit/chromium/src/WebNode.cpp (98380 => 98381)
--- trunk/Source/WebKit/chromium/src/WebNode.cpp 2011-10-25 19:50:25 UTC (rev 98380)
+++ trunk/Source/WebKit/chromium/src/WebNode.cpp 2011-10-25 20:01:34 UTC (rev 98381)
@@ -184,6 +184,13 @@
// listenerWrapper is now deleted.
}
+bool WebNode::dispatchEvent(const WebDOMEvent& event)
+{
+ if (!event.isNull())
+ return m_private->dispatchEvent(event);
+ return false;
+}
+
void WebNode::simulateClick()
{
RefPtr<Event> noEvent;