[SCM] WebKit Debian packaging branch, debian/experimental, updated. upstream/1.3.3-9427-gc2be6fc
weinig at apple.com
weinig at apple.com
Wed Dec 22 11:36:47 UTC 2010
The following commit has been merged in the debian/experimental branch:
commit a4da0e5d5633951789e3d1444fa00b366b19cce9
Author: weinig at apple.com <weinig at apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Date: Fri Jul 30 22:27:53 2010 +0000
Patch for https://bugs.webkit.org/show_bug.cgi?id=43274
Add first pass of structured message passing.
Reviewed by Anders Carlsson.
WebKit2:
- Only supports passing messages from the UIProcess -> InjectedBundle
- Only supports passing Strings, Arrays, and WebPage references (NOTE: There
currently isn't a way to make an array).
- Changed ImmutableArray to operate on APIObjects instead of void*'s and
removed the retain/release abstraction.
* Platform/CoreIPC/MessageID.h:
(CoreIPC::):
* Shared/CoreIPCSupport/InjectedBundleMessageKinds.h: Added.
(InjectedBundleMessage::):
(CoreIPC::):
* Shared/CoreIPCSupport/WebProcessMessageKinds.h:
(WebProcessMessage::):
* Shared/ImmutableArray.cpp:
(WebKit::ImmutableArray::ImmutableArray):
(WebKit::ImmutableArray::~ImmutableArray):
* Shared/ImmutableArray.h:
(WebKit::ImmutableArray::create):
(WebKit::ImmutableArray::adopt):
(WebKit::ImmutableArray::at):
* UIProcess/API/C/WKBase.h:
* UIProcess/API/C/WKContext.cpp:
(WKContextPostMessageToInjectedBundle):
* UIProcess/API/C/WKContext.h:
* UIProcess/API/C/WKType.cpp:
(WKGetTypeID):
* UIProcess/API/C/WebKit2.h:
* UIProcess/WebBackForwardList.cpp:
(WebKit::WebBackForwardList::backListAsImmutableArrayWithLimit):
(WebKit::WebBackForwardList::forwardListAsImmutableArrayWithLimit):
* UIProcess/WebContext.cpp:
(WebKit::WebContext::postMessageToInjectedBundle):
(WebKit::WebContext::didReceiveMessageFromInjectedBundle):
* UIProcess/WebContext.h:
* WebKit2.xcodeproj/project.pbxproj:
* WebProcess/InjectedBundle/API/c/WKBundle.h:
* WebProcess/InjectedBundle/InjectedBundle.cpp:
(WebKit::InjectedBundle::didReceiveMessage):
* WebProcess/InjectedBundle/InjectedBundle.h:
* WebProcess/WebPage/WebFrame.cpp:
(WebKit::WebFrame::childFrames):
* WebProcess/WebProcess.cpp:
(WebKit::WebProcess::didReceiveMessage):
* WebProcess/WebProcess.h:
* win/WebKit2.vcproj:
WebKitTools:
Update Minibrowser and WebKitTestRunner to work with the new post message
function.
* MiniBrowser/mac/AppDelegate.m:
(didRecieveMessageFromInjectedBundle):
(-[BrowserAppDelegate init]):
* MiniBrowser/mac/MiniBrowser_Prefix.pch:
* MiniBrowser/mac/WebBundle/WebBundleMain.m:
(didStartProvisionalLoadForFrame):
(didReceiveServerRedirectForProvisionalLoadForFrame):
(didFailProvisionalLoadWithErrorForFrame):
(didCommitLoadForFrame):
(didFinishLoadForFrame):
(didFailLoadWithErrorForFrame):
(didReceiveTitleForFrame):
(didClearWindowForFrame):
(didCreatePage):
(willDestroyPage):
(didRecieveMessage):
(WKBundleInitialize):
* WebKitTestRunner/InjectedBundle/InjectedBundle.cpp:
(WTR::InjectedBundle::_didReceiveMessage):
(WTR::InjectedBundle::didReceiveMessage):
* WebKitTestRunner/InjectedBundle/InjectedBundle.h:
* WebKitTestRunner/TestInvocation.cpp:
(WTR::TestInvocation::invoke):
* WebKitTestRunner/WebKitTestRunner.xcodeproj/project.pbxproj:
git-svn-id: http://svn.webkit.org/repository/webkit/trunk@64380 268f45cc-cd09-0410-ab3c-d52691b4dbfc
diff --git a/WebKit2/ChangeLog b/WebKit2/ChangeLog
index af2df8d..eed64fd 100644
--- a/WebKit2/ChangeLog
+++ b/WebKit2/ChangeLog
@@ -1,3 +1,56 @@
+2010-07-29 Sam Weinig <sam at webkit.org>
+
+ Reviewed by Anders Carlsson.
+
+ Patch for https://bugs.webkit.org/show_bug.cgi?id=43274
+ Add first pass of structured message passing.
+
+ - Only supports passing messages from the UIProcess -> InjectedBundle
+ - Only supports passing Strings, Arrays, and WebPage references (NOTE: There
+ currently isn't a way to make an array).
+ - Changed ImmutableArray to operate on APIObjects instead of void*'s and
+ removed the retain/release abstraction.
+
+ * Platform/CoreIPC/MessageID.h:
+ (CoreIPC::):
+ * Shared/CoreIPCSupport/InjectedBundleMessageKinds.h: Added.
+ (InjectedBundleMessage::):
+ (CoreIPC::):
+ * Shared/CoreIPCSupport/WebProcessMessageKinds.h:
+ (WebProcessMessage::):
+ * Shared/ImmutableArray.cpp:
+ (WebKit::ImmutableArray::ImmutableArray):
+ (WebKit::ImmutableArray::~ImmutableArray):
+ * Shared/ImmutableArray.h:
+ (WebKit::ImmutableArray::create):
+ (WebKit::ImmutableArray::adopt):
+ (WebKit::ImmutableArray::at):
+ * UIProcess/API/C/WKBase.h:
+ * UIProcess/API/C/WKContext.cpp:
+ (WKContextPostMessageToInjectedBundle):
+ * UIProcess/API/C/WKContext.h:
+ * UIProcess/API/C/WKType.cpp:
+ (WKGetTypeID):
+ * UIProcess/API/C/WebKit2.h:
+ * UIProcess/WebBackForwardList.cpp:
+ (WebKit::WebBackForwardList::backListAsImmutableArrayWithLimit):
+ (WebKit::WebBackForwardList::forwardListAsImmutableArrayWithLimit):
+ * UIProcess/WebContext.cpp:
+ (WebKit::WebContext::postMessageToInjectedBundle):
+ (WebKit::WebContext::didReceiveMessageFromInjectedBundle):
+ * UIProcess/WebContext.h:
+ * WebKit2.xcodeproj/project.pbxproj:
+ * WebProcess/InjectedBundle/API/c/WKBundle.h:
+ * WebProcess/InjectedBundle/InjectedBundle.cpp:
+ (WebKit::InjectedBundle::didReceiveMessage):
+ * WebProcess/InjectedBundle/InjectedBundle.h:
+ * WebProcess/WebPage/WebFrame.cpp:
+ (WebKit::WebFrame::childFrames):
+ * WebProcess/WebProcess.cpp:
+ (WebKit::WebProcess::didReceiveMessage):
+ * WebProcess/WebProcess.h:
+ * win/WebKit2.vcproj:
+
2010-07-30 Anders Carlsson <andersca at apple.com>
Reviewed by Sam Weinig.
diff --git a/WebKit2/Platform/CoreIPC/MessageID.h b/WebKit2/Platform/CoreIPC/MessageID.h
index 3e4bd26..e314670 100644
--- a/WebKit2/Platform/CoreIPC/MessageID.h
+++ b/WebKit2/Platform/CoreIPC/MessageID.h
@@ -36,6 +36,7 @@ enum MessageClass {
// Messages sent by the UI process to the web process.
MessageClassWebProcess,
+ MessageClassInjectedBundle,
MessageClassWebPage,
MessageClassDrawingArea,
diff --git a/WebKit2/Shared/CoreIPCSupport/InjectedBundleMessageKinds.h b/WebKit2/Shared/CoreIPCSupport/InjectedBundleMessageKinds.h
new file mode 100644
index 0000000..1ddf0bf
--- /dev/null
+++ b/WebKit2/Shared/CoreIPCSupport/InjectedBundleMessageKinds.h
@@ -0,0 +1,49 @@
+/*
+ * Copyright (C) 2010 Apple 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:
+ * 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 INC. 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 INC. 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 InjectedBundleMessageKinds_h
+#define InjectedBundleMessageKinds_h
+
+// Messages sent from WebKit to the injected bundle.
+
+#include "MessageID.h"
+
+namespace InjectedBundleMessage {
+
+enum Kind {
+ PostMessage
+};
+
+}
+
+namespace CoreIPC {
+
+template<> struct MessageKindTraits<InjectedBundleMessage::Kind> {
+ static const MessageClass messageClass = MessageClassInjectedBundle;
+};
+
+}
+
+#endif // InjectedBundleMessageKinds_h
diff --git a/WebKit2/Shared/CoreIPCSupport/WebProcessMessageKinds.h b/WebKit2/Shared/CoreIPCSupport/WebProcessMessageKinds.h
index e3f1e4d..6128270 100644
--- a/WebKit2/Shared/CoreIPCSupport/WebProcessMessageKinds.h
+++ b/WebKit2/Shared/CoreIPCSupport/WebProcessMessageKinds.h
@@ -37,7 +37,6 @@ enum Kind {
SetApplicationCacheDirectory,
SetShouldTrackVisitedLinks,
Create,
- PostMessage,
RegisterURLSchemeAsEmptyDocument,
#if PLATFORM(MAC)
SetupAcceleratedCompositingPort
diff --git a/WebKit2/Shared/ImmutableArray.cpp b/WebKit2/Shared/ImmutableArray.cpp
index 6f1a636..049e4c1 100644
--- a/WebKit2/Shared/ImmutableArray.cpp
+++ b/WebKit2/Shared/ImmutableArray.cpp
@@ -31,23 +31,20 @@ ImmutableArray::ImmutableArray()
: m_entries(0)
, m_size(0)
{
- memset(&m_callbacks, 0, sizeof(m_callbacks));
}
-ImmutableArray::ImmutableArray(const void** entries, size_t size, const ImmutableArrayCallbacks* callbacks)
- : m_entries(new void*[size])
+ImmutableArray::ImmutableArray(APIObject** entries, size_t size)
+ : m_entries(new APIObject*[size])
, m_size(size)
- , m_callbacks(*callbacks)
{
memcpy(m_entries, entries, m_size);
for (size_t i = 0; i < m_size; ++i)
- m_callbacks.ref(m_entries[i]);
+ m_entries[i]->ref();
}
-ImmutableArray::ImmutableArray(void** entries, size_t size, const ImmutableArrayCallbacks* callbacks, AdoptTag)
+ImmutableArray::ImmutableArray(APIObject** entries, size_t size, AdoptTag)
: m_entries(entries)
, m_size(size)
- , m_callbacks(*callbacks)
{
}
@@ -57,7 +54,7 @@ ImmutableArray::~ImmutableArray()
return;
for (size_t i = 0; i < m_size; ++i)
- m_callbacks.deref(m_entries[i]);
+ m_entries[i]->deref();
delete [] m_entries;
}
diff --git a/WebKit2/Shared/ImmutableArray.h b/WebKit2/Shared/ImmutableArray.h
index 536e0ab..ec429c7 100644
--- a/WebKit2/Shared/ImmutableArray.h
+++ b/WebKit2/Shared/ImmutableArray.h
@@ -35,41 +35,33 @@ namespace WebKit {
class ImmutableArray : public APIObject {
public:
- struct ImmutableArrayCallbacks {
- typedef void (*ImmutableArrayCallback)(const void*);
- ImmutableArrayCallback ref;
- ImmutableArrayCallback deref;
- };
-
static PassRefPtr<ImmutableArray> create()
{
return adoptRef(new ImmutableArray);
}
-
- static PassRefPtr<ImmutableArray> create(const void** entries, size_t size, const ImmutableArrayCallbacks* callbacks)
+ static PassRefPtr<ImmutableArray> create(APIObject** entries, size_t size)
{
- return adoptRef(new ImmutableArray(entries, size, callbacks));
+ return adoptRef(new ImmutableArray(entries, size));
}
- static PassRefPtr<ImmutableArray> adopt(void** entries, size_t size, const ImmutableArrayCallbacks* callbacks)
+ static PassRefPtr<ImmutableArray> adopt(APIObject** entries, size_t size)
{
- return adoptRef(new ImmutableArray(entries, size, callbacks, Adopt));
+ return adoptRef(new ImmutableArray(entries, size, Adopt));
}
~ImmutableArray();
- const void* at(size_t i) { ASSERT(i < m_size); return m_entries[i]; }
+ APIObject* at(size_t i) { ASSERT(i < m_size); return m_entries[i]; }
size_t size() { return m_size; }
private:
ImmutableArray();
- ImmutableArray(const void** entries, size_t size, const ImmutableArrayCallbacks*);
+ ImmutableArray(APIObject** entries, size_t size);
enum AdoptTag { Adopt };
- ImmutableArray(void** entries, size_t size, const ImmutableArrayCallbacks*, AdoptTag);
+ ImmutableArray(APIObject** entries, size_t size, AdoptTag);
virtual Type type() const { return TypeArray; }
- void** m_entries;
+ APIObject** m_entries;
size_t m_size;
- ImmutableArrayCallbacks m_callbacks;
};
} // namespace WebKit
diff --git a/WebKit2/UIProcess/API/C/WKBase.h b/WebKit2/UIProcess/API/C/WKBase.h
index 46e5430..7444ff8 100644
--- a/WebKit2/UIProcess/API/C/WKBase.h
+++ b/WebKit2/UIProcess/API/C/WKBase.h
@@ -33,8 +33,8 @@
#endif
typedef uint32_t WKTypeID;
+typedef void* WKTypeRef;
-typedef struct OpaqueWKTypeRef* WKTypeRef;
typedef struct OpaqueWKArrayRef* WKArrayRef;
typedef struct OpaqueWKBackForwardListItemRef* WKBackForwardListItemRef;
typedef struct OpaqueWKBackForwardListRef* WKBackForwardListRef;
diff --git a/WebKit2/UIProcess/API/C/WKContext.cpp b/WebKit2/UIProcess/API/C/WKContext.cpp
index 720aee7..75ded03 100644
--- a/WebKit2/UIProcess/API/C/WKContext.cpp
+++ b/WebKit2/UIProcess/API/C/WKContext.cpp
@@ -84,9 +84,9 @@ void WKContextSetHistoryClient(WKContextRef contextRef, const WKContextHistoryCl
toWK(contextRef)->initializeHistoryClient(wkClient);
}
-void WKContextPostMessageToInjectedBundle(WKContextRef contextRef, WKStringRef messageRef)
+void WKContextPostMessageToInjectedBundle(WKContextRef contextRef, WKStringRef messageNameRef, WKTypeRef messageBodyRef)
{
- toWK(contextRef)->postMessageToInjectedBundle(toWK(messageRef)->string());
+ toWK(contextRef)->postMessageToInjectedBundle(toWK(messageNameRef)->string(), toWK(messageBodyRef));
}
void WKContextGetStatistics(WKContextRef contextRef, WKContextStatistics* statistics)
diff --git a/WebKit2/UIProcess/API/C/WKContext.h b/WebKit2/UIProcess/API/C/WKContext.h
index 9bd02bc..3232d47 100644
--- a/WebKit2/UIProcess/API/C/WKContext.h
+++ b/WebKit2/UIProcess/API/C/WKContext.h
@@ -72,7 +72,7 @@ WK_EXPORT WKPreferencesRef WKContextGetPreferences(WKContextRef context);
WK_EXPORT void WKContextSetHistoryClient(WKContextRef context, const WKContextHistoryClient* client);
WK_EXPORT void WKContextSetInjectedBundleClient(WKContextRef context, const WKContextInjectedBundleClient* client);
-WK_EXPORT void WKContextPostMessageToInjectedBundle(WKContextRef context, WKStringRef message);
+WK_EXPORT void WKContextPostMessageToInjectedBundle(WKContextRef context, WKStringRef messageName, WKTypeRef messageBody);
WK_EXPORT WKContextRef WKContextRetain(WKContextRef context);
WK_EXPORT void WKContextRelease(WKContextRef context);
diff --git a/WebKit2/UIProcess/API/C/WKType.cpp b/WebKit2/UIProcess/API/C/WKType.cpp
index 919fa3f..a53a735 100644
--- a/WebKit2/UIProcess/API/C/WKType.cpp
+++ b/WebKit2/UIProcess/API/C/WKType.cpp
@@ -32,5 +32,5 @@ using namespace WebKit;
WKTypeID WKGetTypeID(WKTypeRef typeRef)
{
- return toRef(toWK(typeRef)->type());
+ return toRef(static_cast<APIObject*>(typeRef)->type());
}
diff --git a/WebKit2/UIProcess/API/C/WebKit2.h b/WebKit2/UIProcess/API/C/WebKit2.h
index 8af8a9c..8a881ad 100644
--- a/WebKit2/UIProcess/API/C/WebKit2.h
+++ b/WebKit2/UIProcess/API/C/WebKit2.h
@@ -27,6 +27,7 @@
#define WebKit2_h
#include <WebKit2/WKBase.h>
+#include <WebKit2/WKType.h>
#include <WebKit2/WKBackForwardList.h>
#include <WebKit2/WKBackForwardListItem.h>
#include <WebKit2/WKContext.h>
diff --git a/WebKit2/UIProcess/WebBackForwardList.cpp b/WebKit2/UIProcess/WebBackForwardList.cpp
index 3d82fd4..637a91b 100644
--- a/WebKit2/UIProcess/WebBackForwardList.cpp
+++ b/WebKit2/UIProcess/WebBackForwardList.cpp
@@ -166,36 +166,20 @@ BackForwardListItemVector WebBackForwardList::forwardListWithLimit(unsigned limi
return list;
}
-// ImmutableArray::ImmutableArrayCallback [for WebBackForwardListItem] callbacks
-
-static void webBackForwardListItemRef(const void* item)
-{
- static_cast<WebBackForwardListItem*>(const_cast<void*>(item))->ref();
-}
-
-static void webBackForwardListItemDeref(const void* item)
-{
- static_cast<WebBackForwardListItem*>(const_cast<void*>(item))->deref();
-}
-
PassRefPtr<ImmutableArray> WebBackForwardList::backListAsImmutableArrayWithLimit(unsigned limit)
{
unsigned size = std::min(static_cast<unsigned>(backListCount()), limit);
if (!size)
return ImmutableArray::create();
- void** array = new void*[size];
+ APIObject** array = new APIObject*[size];
for (unsigned i = std::max<int>(m_current - limit, 0), j = 0; i < m_current; ++i, ++j) {
- WebBackForwardListItem* item = m_entries[i].get();
+ APIObject* item = m_entries[i].get();
item->ref();
array[j] = item;
}
- ImmutableArray::ImmutableArrayCallbacks callbacks = {
- webBackForwardListItemRef,
- webBackForwardListItemDeref
- };
- return ImmutableArray::adopt(array, size, &callbacks);
+ return ImmutableArray::adopt(array, size);
}
PassRefPtr<ImmutableArray> WebBackForwardList::forwardListAsImmutableArrayWithLimit(unsigned limit)
@@ -204,19 +188,15 @@ PassRefPtr<ImmutableArray> WebBackForwardList::forwardListAsImmutableArrayWithLi
if (!size)
return ImmutableArray::create();
- void** array = new void*[size];
+ APIObject** array = new APIObject*[size];
unsigned last = std::min(m_current + limit, static_cast<unsigned>(m_entries.size() - 1));
for (unsigned i = m_current + 1, j = 0; i <= last; ++i, ++j) {
- WebBackForwardListItem* item = m_entries[i].get();
+ APIObject* item = m_entries[i].get();
item->ref();
array[j] = item;
}
- ImmutableArray::ImmutableArrayCallbacks callbacks = {
- webBackForwardListItemRef,
- webBackForwardListItemDeref
- };
- return ImmutableArray::adopt(array, size, &callbacks);
+ return ImmutableArray::adopt(array, size);
}
} // namespace WebKit
diff --git a/WebKit2/UIProcess/WebContext.cpp b/WebKit2/UIProcess/WebContext.cpp
index b7b03a0..254e75b 100644
--- a/WebKit2/UIProcess/WebContext.cpp
+++ b/WebKit2/UIProcess/WebContext.cpp
@@ -25,6 +25,8 @@
#include "WebContext.h"
+#include "ImmutableArray.h"
+#include "InjectedBundleMessageKinds.h"
#include "RunLoop.h"
#include "WebCoreArgumentCoders.h"
#include "WebPageNamespace.h"
@@ -165,19 +167,70 @@ void WebContext::preferencesDidChange()
}
}
-// InjectedBundle client
+namespace {
+
+// Encodes postMessage messages from the UIProcess -> InjectedBundle
+
+// - Array -> Array
+// - String -> String
+// - Page -> BundlePage
+
+class PostMessageEncoder {
+public:
+ PostMessageEncoder(APIObject* root)
+ : m_root(root)
+ {
+ }
+
+ void encode(CoreIPC::ArgumentEncoder& encoder) const
+ {
+ APIObject::Type type = m_root->type();
+ encoder.encode(static_cast<uint32_t>(type));
+ switch (type) {
+ case APIObject::TypeArray: {
+ ImmutableArray* array = static_cast<ImmutableArray*>(m_root);
+ encoder.encode(static_cast<uint64_t>(array->size()));
+ for (size_t i = 0; i < array->size(); ++i)
+ encoder.encode(PostMessageEncoder(array->at(i)));
+ break;
+ }
+ case APIObject::TypeString: {
+ WebString* string = static_cast<WebString*>(m_root);
+ encoder.encode(string->string());
+ break;
+ }
+ case APIObject::TypePage: {
+ WebPageProxy* page = static_cast<WebPageProxy*>(m_root);
+ encoder.encode(page->pageID());
+ break;
+ }
+ default:
+ ASSERT_NOT_REACHED();
+ break;
+ }
+ }
+
+private:
+ APIObject* m_root;
+};
-void WebContext::didReceiveMessageFromInjectedBundle(const String& message)
-{
- m_injectedBundleClient.didReceiveMessageFromInjectedBundle(this, message);
}
-void WebContext::postMessageToInjectedBundle(const String& message)
+void WebContext::postMessageToInjectedBundle(const String& messageName, APIObject* messageBody)
{
if (!m_process)
return;
- m_process->send(WebProcessMessage::PostMessage, 0, CoreIPC::In(message));
+ // FIXME: We should consider returning false from this function if the messageBody cannot
+ // be encoded.
+ m_process->send(InjectedBundleMessage::PostMessage, 0, CoreIPC::In(messageName, PostMessageEncoder(messageBody)));
+}
+
+// InjectedBundle client
+
+void WebContext::didReceiveMessageFromInjectedBundle(const String& message)
+{
+ m_injectedBundleClient.didReceiveMessageFromInjectedBundle(this, message);
}
// HistoryClient
diff --git a/WebKit2/UIProcess/WebContext.h b/WebKit2/UIProcess/WebContext.h
index f72560c..f93a35b 100644
--- a/WebKit2/UIProcess/WebContext.h
+++ b/WebKit2/UIProcess/WebContext.h
@@ -78,9 +78,10 @@ public:
const WebCore::String& injectedBundlePath() const { return m_injectedBundlePath; }
+ void postMessageToInjectedBundle(const WebCore::String&, APIObject*);
+
// InjectedBundle client
void didReceiveMessageFromInjectedBundle(const WebCore::String&);
- void postMessageToInjectedBundle(const WebCore::String&);
// History client
void didNavigateWithNavigationData(WebFrameProxy*, const WebNavigationDataStore&);
diff --git a/WebKit2/WebKit2.xcodeproj/project.pbxproj b/WebKit2/WebKit2.xcodeproj/project.pbxproj
index 5ba4533..a1c873c 100644
--- a/WebKit2/WebKit2.xcodeproj/project.pbxproj
+++ b/WebKit2/WebKit2.xcodeproj/project.pbxproj
@@ -213,6 +213,7 @@
BCA8C6B011E3C08700812FB7 /* InjectedBundlePageUIClient.h in Headers */ = {isa = PBXBuildFile; fileRef = BCA8C6AE11E3C08700812FB7 /* InjectedBundlePageUIClient.h */; };
BCA8C9DC11E4086500812FB7 /* WebBackForwardControllerClient.h in Headers */ = {isa = PBXBuildFile; fileRef = BCA8C9DA11E4086500812FB7 /* WebBackForwardControllerClient.h */; };
BCA8C9DD11E4086500812FB7 /* WebBackForwardControllerClient.cpp in Sources */ = {isa = PBXBuildFile; fileRef = BCA8C9DB11E4086500812FB7 /* WebBackForwardControllerClient.cpp */; };
+ BCB28CC0120233D9007D99BC /* InjectedBundleMessageKinds.h in Headers */ = {isa = PBXBuildFile; fileRef = BCB28CBF120233D9007D99BC /* InjectedBundleMessageKinds.h */; };
BCB63478116BF10600603215 /* WebKit2.h in Headers */ = {isa = PBXBuildFile; fileRef = BCB63477116BF10600603215 /* WebKit2.h */; settings = {ATTRIBUTES = (Public, ); }; };
BCB7346E11CEE3FF00EC5002 /* WebProcessProxyMessageKinds.h in Headers */ = {isa = PBXBuildFile; fileRef = BCB7346D11CEE3FF00EC5002 /* WebProcessProxyMessageKinds.h */; };
BCB9E2431120DACA00A137E0 /* WebContext.h in Headers */ = {isa = PBXBuildFile; fileRef = BCB9E2411120DACA00A137E0 /* WebContext.h */; };
@@ -244,7 +245,7 @@
BCD59800112B57BE00EC8C23 /* WebPreferences.cpp in Sources */ = {isa = PBXBuildFile; fileRef = BCD597FE112B57BE00EC8C23 /* WebPreferences.cpp */; };
BCD598AC112B7FDF00EC8C23 /* WebPreferencesStore.h in Headers */ = {isa = PBXBuildFile; fileRef = BCD598AA112B7FDF00EC8C23 /* WebPreferencesStore.h */; };
BCD598AD112B7FDF00EC8C23 /* WebPreferencesStore.cpp in Sources */ = {isa = PBXBuildFile; fileRef = BCD598AB112B7FDF00EC8C23 /* WebPreferencesStore.cpp */; };
- BCDB85821200EC57007254BE /* WKType.h in Headers */ = {isa = PBXBuildFile; fileRef = BCDB85801200EC57007254BE /* WKType.h */; };
+ BCDB85821200EC57007254BE /* WKType.h in Headers */ = {isa = PBXBuildFile; fileRef = BCDB85801200EC57007254BE /* WKType.h */; settings = {ATTRIBUTES = (Public, ); }; };
BCDB85831200EC57007254BE /* WKType.cpp in Sources */ = {isa = PBXBuildFile; fileRef = BCDB85811200EC57007254BE /* WKType.cpp */; };
BCDB86C11200FB97007254BE /* WebURL.h in Headers */ = {isa = PBXBuildFile; fileRef = BCDB86C01200FB97007254BE /* WebURL.h */; };
BCDE059B11CDA8AE00E41AF1 /* WebContextInjectedBundleClient.h in Headers */ = {isa = PBXBuildFile; fileRef = BCDE059911CDA8AE00E41AF1 /* WebContextInjectedBundleClient.h */; };
@@ -508,6 +509,7 @@
BCA8C6AE11E3C08700812FB7 /* InjectedBundlePageUIClient.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = InjectedBundlePageUIClient.h; sourceTree = "<group>"; };
BCA8C9DA11E4086500812FB7 /* WebBackForwardControllerClient.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = WebBackForwardControllerClient.h; sourceTree = "<group>"; };
BCA8C9DB11E4086500812FB7 /* WebBackForwardControllerClient.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = WebBackForwardControllerClient.cpp; sourceTree = "<group>"; };
+ BCB28CBF120233D9007D99BC /* InjectedBundleMessageKinds.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = InjectedBundleMessageKinds.h; sourceTree = "<group>"; };
BCB63477116BF10600603215 /* WebKit2.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = WebKit2.h; sourceTree = "<group>"; };
BCB7346D11CEE3FF00EC5002 /* WebProcessProxyMessageKinds.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = WebProcessProxyMessageKinds.h; sourceTree = "<group>"; };
BCB86F4B116AAACD00CE20B7 /* WebKit2.xcconfig */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.xcconfig; path = WebKit2.xcconfig; sourceTree = "<group>"; };
@@ -1040,6 +1042,7 @@
children = (
BC9E969B11457F3F00870E71 /* DrawingAreaMessageKinds.h */,
BC9E969911457EDE00870E71 /* DrawingAreaProxyMessageKinds.h */,
+ BCB28CBF120233D9007D99BC /* InjectedBundleMessageKinds.h */,
BC111B60112F638300337BAB /* WebPageMessageKinds.h */,
BC111B61112F638300337BAB /* WebPageProxyMessageKinds.h */,
BC111B62112F638300337BAB /* WebProcessMessageKinds.h */,
@@ -1317,6 +1320,7 @@
1AE49A4911FFA8CE0048B464 /* JSNPMethod.h in Headers */,
BCDB85821200EC57007254BE /* WKType.h in Headers */,
BCDB86C11200FB97007254BE /* WebURL.h in Headers */,
+ BCB28CC0120233D9007D99BC /* InjectedBundleMessageKinds.h in Headers */,
);
runOnlyForDeploymentPostprocessing = 0;
};
diff --git a/WebKit2/WebProcess/InjectedBundle/API/c/WKBundle.h b/WebKit2/WebProcess/InjectedBundle/API/c/WKBundle.h
index a94ed56..b8ab493 100644
--- a/WebKit2/WebProcess/InjectedBundle/API/c/WKBundle.h
+++ b/WebKit2/WebProcess/InjectedBundle/API/c/WKBundle.h
@@ -36,7 +36,7 @@ extern "C" {
// Client
typedef void (*WKBundleDidCreatePageCallback)(WKBundleRef bundle, WKBundlePageRef page, const void *clientInfo);
typedef void (*WKBundleWillDestroyPageCallback)(WKBundleRef bundle, WKBundlePageRef page, const void *clientInfo);
-typedef void (*WKBundleDidReceiveMessageCallback)(WKBundleRef bundle, WKStringRef message, const void *clientInfo);
+typedef void (*WKBundleDidReceiveMessageCallback)(WKBundleRef bundle, WKStringRef name, WKTypeRef messageBody, const void *clientInfo);
struct WKBundleClient {
int version;
diff --git a/WebKit2/WebProcess/InjectedBundle/InjectedBundle.cpp b/WebKit2/WebProcess/InjectedBundle/InjectedBundle.cpp
index 7f78f4b..b140d51 100644
--- a/WebKit2/WebProcess/InjectedBundle/InjectedBundle.cpp
+++ b/WebKit2/WebProcess/InjectedBundle/InjectedBundle.cpp
@@ -25,12 +25,17 @@
#include "InjectedBundle.h"
+#include "Arguments.h"
+#include "ImmutableArray.h"
+#include "InjectedBundleMessageKinds.h"
#include "WKAPICast.h"
#include "WKBundleAPICast.h"
#include "WebCoreArgumentCoders.h"
+#include "WebPage.h"
#include "WebProcess.h"
#include "WebProcessProxyMessageKinds.h"
#include <WebCore/PageGroup.h>
+#include <wtf/OwnArrayPtr.h>
using namespace WebCore;
@@ -82,10 +87,100 @@ void InjectedBundle::willDestroyPage(WebPage* page)
m_client.willDestroyPage(toRef(this), toRef(page), m_client.clientInfo);
}
-void InjectedBundle::didReceiveMessage(const WebCore::String& message)
+void InjectedBundle::didReceiveMessage(const WebCore::String& messageName, APIObject* messageBody)
{
if (m_client.didReceiveMessage)
- m_client.didReceiveMessage(toRef(this), toRef(message.impl()), m_client.clientInfo);
+ m_client.didReceiveMessage(toRef(this), toRef(messageName.impl()), toRef(messageBody), m_client.clientInfo);
+}
+
+namespace {
+
+// Decodes postMessage messages going from the UIProcess -> InjectedBundle
+
+// - Array -> Array
+// - String -> String
+// - Page -> BundlePage
+
+class PostMessageDecoder {
+public:
+ PostMessageDecoder(APIObject** root)
+ : m_root(root)
+ {
+ }
+
+ static bool decode(CoreIPC::ArgumentDecoder& decoder, PostMessageDecoder& coder)
+ {
+ uint32_t type;
+ if (!decoder.decode(type))
+ return false;
+
+ switch (type) {
+ case APIObject::TypeArray: {
+ uint64_t size;
+ if (!decoder.decode(size))
+ return false;
+
+ OwnArrayPtr<APIObject*> array;
+ array.set(new APIObject*[size]);
+
+ for (size_t i = 0; i < size; ++i) {
+ APIObject* element;
+ PostMessageDecoder messageCoder(&element);
+ if (!decoder.decode(messageCoder))
+ return false;
+ array[i] = element;
+ }
+
+ *(coder.m_root) = ImmutableArray::create(array.release(), size).leakRef();
+ break;
+ }
+ case APIObject::TypeString: {
+ String string;
+ if (!decoder.decode(string))
+ return false;
+ *(coder.m_root) = WebString::create(string).leakRef();
+ break;
+ }
+ case APIObject::TypePage: {
+ uint64_t pageID;
+ if (!decoder.decode(pageID))
+ return false;
+ *(coder.m_root) = WebProcess::shared().webPage(pageID);
+ break;
+ }
+ default:
+ return false;
+ }
+
+ return true;
+ }
+
+private:
+ APIObject** m_root;
+};
+
+}
+
+void InjectedBundle::didReceiveMessage(CoreIPC::Connection* connection, CoreIPC::MessageID messageID, CoreIPC::ArgumentDecoder& arguments)
+{
+ switch (messageID.get<InjectedBundleMessage::Kind>()) {
+ case InjectedBundleMessage::PostMessage: {
+ String messageName;
+ // FIXME: This should be a RefPtr<APIObject>
+ APIObject* messageBody = 0;
+ PostMessageDecoder messageCoder(&messageBody);
+ if (!arguments.decode(CoreIPC::Out(messageName, messageCoder)))
+ return;
+
+ didReceiveMessage(messageName, messageBody);
+
+ messageBody->deref();
+
+ return;
+ }
+ }
+
+ ASSERT_NOT_REACHED();
}
} // namespace WebKit
diff --git a/WebKit2/WebProcess/InjectedBundle/InjectedBundle.h b/WebKit2/WebProcess/InjectedBundle/InjectedBundle.h
index 8e0eecf..d281269 100644
--- a/WebKit2/WebProcess/InjectedBundle/InjectedBundle.h
+++ b/WebKit2/WebProcess/InjectedBundle/InjectedBundle.h
@@ -31,6 +31,12 @@
#include <WebCore/PlatformString.h>
#include <wtf/PassRefPtr.h>
+namespace CoreIPC {
+ class ArgumentDecoder;
+ class Connection;
+ class MessageID;
+}
+
namespace WebKit {
#if PLATFORM(MAC)
@@ -66,7 +72,9 @@ public:
// Callback hooks
void didCreatePage(WebPage*);
void willDestroyPage(WebPage*);
- void didReceiveMessage(const WebCore::String&);
+ void didReceiveMessage(const WebCore::String&, APIObject*);
+
+ void didReceiveMessage(CoreIPC::Connection*, CoreIPC::MessageID, CoreIPC::ArgumentDecoder&);
private:
InjectedBundle(const WebCore::String&);
diff --git a/WebKit2/WebProcess/WebPage/WebFrame.cpp b/WebKit2/WebProcess/WebPage/WebFrame.cpp
index 3ae6335..7d82a19 100644
--- a/WebKit2/WebProcess/WebPage/WebFrame.cpp
+++ b/WebKit2/WebProcess/WebPage/WebFrame.cpp
@@ -185,16 +185,6 @@ String WebFrame::url() const
return m_coreFrame->loader()->url().string();
}
-static void childFrameRef(const void* frame)
-{
- static_cast<WebFrame*>(const_cast<void*>(frame))->ref();
-}
-
-static void childFrameDeref(const void* frame)
-{
- static_cast<WebFrame*>(const_cast<void*>(frame))->deref();
-}
-
PassRefPtr<ImmutableArray> WebFrame::childFrames()
{
if (!m_coreFrame)
@@ -204,7 +194,7 @@ PassRefPtr<ImmutableArray> WebFrame::childFrames()
if (!size)
return ImmutableArray::create();
- void** array = new void*[size];
+ APIObject** array = new APIObject*[size];
unsigned i = 0;
for (Frame* child = m_coreFrame->tree()->firstChild(); child; child = child->tree()->nextSibling(), ++i) {
WebFrame* webFrame = static_cast<WebFrameLoaderClient*>(child->loader()->client())->webFrame();
@@ -212,11 +202,7 @@ PassRefPtr<ImmutableArray> WebFrame::childFrames()
array[i] = webFrame;
}
- ImmutableArray::ImmutableArrayCallbacks callbacks = {
- childFrameRef,
- childFrameDeref
- };
- return ImmutableArray::adopt(array, size, &callbacks);
+ return ImmutableArray::adopt(array, size);
}
unsigned WebFrame::numberOfActiveAnimations()
diff --git a/WebKit2/WebProcess/WebProcess.cpp b/WebKit2/WebProcess/WebProcess.cpp
index 1f8774a..1bf123b 100644
--- a/WebKit2/WebProcess/WebProcess.cpp
+++ b/WebKit2/WebProcess/WebProcess.cpp
@@ -26,9 +26,7 @@
#include "WebProcess.h"
#include "InjectedBundle.h"
-#if PLATFORM(MAC)
-#include "MachPort.h"
-#endif
+#include "InjectedBundleMessageKinds.h"
#include "RunLoop.h"
#include "WebCoreArgumentCoders.h"
#include "WebFrame.h"
@@ -41,6 +39,10 @@
#include <WebCore/SchemeRegistry.h>
#include <wtf/PassRefPtr.h>
+#if PLATFORM(MAC)
+#include "MachPort.h"
+#endif
+
#ifndef NDEBUG
#include <WebCore/Cache.h>
#include <WebCore/GCController.h>
@@ -103,14 +105,6 @@ void WebProcess::setApplicationCacheDirectory(const String& directory)
cacheStorage().setCacheDirectory(directory);
}
-void WebProcess::forwardMessageToInjectedBundle(const String& message)
-{
- if (!m_injectedBundle)
- return;
-
- m_injectedBundle->didReceiveMessage(message);
-}
-
void WebProcess::registerURLSchemeAsEmptyDocument(const WebCore::String& urlScheme)
{
SchemeRegistry::registerURLSchemeAsEmptyDocument(urlScheme);
@@ -218,14 +212,6 @@ void WebProcess::didReceiveMessage(CoreIPC::Connection* connection, CoreIPC::Mes
createWebPage(pageID, viewSize, store, static_cast<DrawingArea::Type>(drawingAreaType));
return;
}
- case WebProcessMessage::PostMessage: {
- String message;
- if (!arguments->decode(CoreIPC::Out(message)))
- return;
-
- forwardMessageToInjectedBundle(message);
- return;
- }
case WebProcessMessage::RegisterURLSchemeAsEmptyDocument: {
String message;
if (!arguments->decode(CoreIPC::Out(message)))
@@ -247,6 +233,13 @@ void WebProcess::didReceiveMessage(CoreIPC::Connection* connection, CoreIPC::Mes
}
}
+ if (messageID.is<CoreIPC::MessageClassInjectedBundle>()) {
+ if (!m_injectedBundle)
+ return;
+ m_injectedBundle->didReceiveMessage(connection, messageID, *arguments);
+ return;
+ }
+
uint64_t pageID = arguments->destinationID();
if (!pageID)
return;
diff --git a/WebKit2/WebProcess/WebProcess.h b/WebKit2/WebProcess/WebProcess.h
index 216c85f..ad182e9 100644
--- a/WebKit2/WebProcess/WebProcess.h
+++ b/WebKit2/WebProcess/WebProcess.h
@@ -72,7 +72,6 @@ private:
void loadInjectedBundle(const WebCore::String&);
#endif
void setApplicationCacheDirectory(const WebCore::String&);
- void forwardMessageToInjectedBundle(const WebCore::String&);
void registerURLSchemeAsEmptyDocument(const WebCore::String&);
// CoreIPC::Connection::Client
diff --git a/WebKit2/win/WebKit2.vcproj b/WebKit2/win/WebKit2.vcproj
index 6b075e6..a3842fd 100755
--- a/WebKit2/win/WebKit2.vcproj
+++ b/WebKit2/win/WebKit2.vcproj
@@ -448,6 +448,18 @@
Name="CoreIPCSupport"
>
<File
+ RelativePath="..\Shared\CoreIPCSupport\DrawingAreaMessageKinds.h"
+ >
+ </File>
+ <File
+ RelativePath="..\Shared\CoreIPCSupport\DrawingAreaProxyMessageKinds.h"
+ >
+ </File>
+ <File
+ RelativePath="..\Shared\CoreIPCSupport\InjectedBundleMessageKinds.h"
+ >
+ </File>
+ <File
RelativePath="..\Shared\CoreIPCSupport\WebPageMessageKinds.h"
>
</File>
diff --git a/WebKitTools/ChangeLog b/WebKitTools/ChangeLog
index 83ded22..fad40e2 100644
--- a/WebKitTools/ChangeLog
+++ b/WebKitTools/ChangeLog
@@ -1,3 +1,38 @@
+2010-07-30 Sam Weinig <sam at webkit.org>
+
+ Reviewed by Anders Carlsson.
+
+ Patch for https://bugs.webkit.org/show_bug.cgi?id=43274
+ Add first pass of structured message passing.
+
+ Update Minibrowser and WebKitTestRunner to work with the new post message
+ function.
+
+ * MiniBrowser/mac/AppDelegate.m:
+ (didRecieveMessageFromInjectedBundle):
+ (-[BrowserAppDelegate init]):
+ * MiniBrowser/mac/MiniBrowser_Prefix.pch:
+ * MiniBrowser/mac/WebBundle/WebBundleMain.m:
+ (didStartProvisionalLoadForFrame):
+ (didReceiveServerRedirectForProvisionalLoadForFrame):
+ (didFailProvisionalLoadWithErrorForFrame):
+ (didCommitLoadForFrame):
+ (didFinishLoadForFrame):
+ (didFailLoadWithErrorForFrame):
+ (didReceiveTitleForFrame):
+ (didClearWindowForFrame):
+ (didCreatePage):
+ (willDestroyPage):
+ (didRecieveMessage):
+ (WKBundleInitialize):
+ * WebKitTestRunner/InjectedBundle/InjectedBundle.cpp:
+ (WTR::InjectedBundle::_didReceiveMessage):
+ (WTR::InjectedBundle::didReceiveMessage):
+ * WebKitTestRunner/InjectedBundle/InjectedBundle.h:
+ * WebKitTestRunner/TestInvocation.cpp:
+ (WTR::TestInvocation::invoke):
+ * WebKitTestRunner/WebKitTestRunner.xcodeproj/project.pbxproj:
+
2010-07-30 Anders Carlsson <andersca at apple.com>
Try to fix the layout test failures.
diff --git a/WebKitTools/MiniBrowser/mac/AppDelegate.m b/WebKitTools/MiniBrowser/mac/AppDelegate.m
index ccbf176..834b063 100644
--- a/WebKitTools/MiniBrowser/mac/AppDelegate.m
+++ b/WebKitTools/MiniBrowser/mac/AppDelegate.m
@@ -36,15 +36,20 @@ static NSString *defaultURL = @"http://www.webkit.org/";
@implementation BrowserAppDelegate
-void _didRecieveMessageFromInjectedBundle(WKContextRef context, WKStringRef message, const void *clientInfo)
+void didRecieveMessageFromInjectedBundle(WKContextRef context, WKStringRef message, const void *clientInfo)
{
CFStringRef cfMessage = WKStringCopyCFString(0, message);
LOG(@"ContextInjectedBundleClient - didRecieveMessage - message: %@", cfMessage);
CFRelease(cfMessage);
- WKStringRef newMessage = WKStringCreateWithCFString(CFSTR("Roger that!"));
- WKContextPostMessageToInjectedBundle(context, newMessage);
- WKStringRelease(newMessage);
+ WKStringRef newMessageName = WKStringCreateWithCFString(CFSTR("Response"));
+ WKStringRef newMessageBody = WKStringCreateWithCFString(CFSTR("Roger that!"));
+
+ LOG(@"my info: %d", (int)WKGetTypeID(newMessageBody));
+
+ WKContextPostMessageToInjectedBundle(context, newMessageName, newMessageBody);
+
+ WKStringRelease(newMessageName);
}
#pragma mark History Client Callbacks
@@ -128,7 +133,7 @@ static void populateVisitedLinks(WKContextRef context, const void *clientInfo)
WKContextInjectedBundleClient bundleClient = {
0, /* version */
0, /* clientInfo */
- _didRecieveMessageFromInjectedBundle
+ didRecieveMessageFromInjectedBundle
};
WKContextSetInjectedBundleClient(processContext, &bundleClient);
WKContextSetHistoryClient(processContext, &historyClient);
diff --git a/WebKitTools/MiniBrowser/mac/MiniBrowser_Prefix.pch b/WebKitTools/MiniBrowser/mac/MiniBrowser_Prefix.pch
index cb8ceae..0670cf4 100644
--- a/WebKitTools/MiniBrowser/mac/MiniBrowser_Prefix.pch
+++ b/WebKitTools/MiniBrowser/mac/MiniBrowser_Prefix.pch
@@ -29,6 +29,8 @@
#import <WebKit2/WebKit2.h>
+#define ENABLE_LOGGING 1
+
#if ENABLE_LOGGING
#define LOG NSLog
#else
diff --git a/WebKitTools/MiniBrowser/mac/WebBundle/WebBundleMain.m b/WebKitTools/MiniBrowser/mac/WebBundle/WebBundleMain.m
index cd5ee00..055c2ae 100644
--- a/WebKitTools/MiniBrowser/mac/WebBundle/WebBundleMain.m
+++ b/WebKitTools/MiniBrowser/mac/WebBundle/WebBundleMain.m
@@ -37,41 +37,41 @@ static WKBundleRef globalBundle;
// WKBundlePageClient
-void _didStartProvisionalLoadForFrame(WKBundlePageRef page, WKBundleFrameRef frame, const void *clientInfo)
+void didStartProvisionalLoadForFrame(WKBundlePageRef page, WKBundleFrameRef frame, const void *clientInfo)
{
}
-void _didReceiveServerRedirectForProvisionalLoadForFrame(WKBundlePageRef page, WKBundleFrameRef frame, const void *clientInfo)
+void didReceiveServerRedirectForProvisionalLoadForFrame(WKBundlePageRef page, WKBundleFrameRef frame, const void *clientInfo)
{
}
-void _didFailProvisionalLoadWithErrorForFrame(WKBundlePageRef page, WKBundleFrameRef frame, const void *clientInfo)
+void didFailProvisionalLoadWithErrorForFrame(WKBundlePageRef page, WKBundleFrameRef frame, const void *clientInfo)
{
}
-void _didCommitLoadForFrame(WKBundlePageRef page, WKBundleFrameRef frame, const void *clientInfo)
+void didCommitLoadForFrame(WKBundlePageRef page, WKBundleFrameRef frame, const void *clientInfo)
{
}
-void _didFinishLoadForFrame(WKBundlePageRef page, WKBundleFrameRef frame, const void *clientInfo)
+void didFinishLoadForFrame(WKBundlePageRef page, WKBundleFrameRef frame, const void *clientInfo)
{
}
-void _didFailLoadWithErrorForFrame(WKBundlePageRef page, WKBundleFrameRef frame, const void *clientInfo)
+void didFailLoadWithErrorForFrame(WKBundlePageRef page, WKBundleFrameRef frame, const void *clientInfo)
{
}
-void _didReceiveTitleForFrame(WKBundlePageRef page, WKStringRef title, WKBundleFrameRef frame, const void *clientInfo)
+void didReceiveTitleForFrame(WKBundlePageRef page, WKStringRef title, WKBundleFrameRef frame, const void *clientInfo)
{
}
-void _didClearWindowForFrame(WKBundlePageRef page, WKBundleFrameRef frame, JSGlobalContextRef context, JSObjectRef window, const void *clientInfo)
+void didClearWindowForFrame(WKBundlePageRef page, WKBundleFrameRef frame, JSGlobalContextRef context, JSObjectRef window, const void *clientInfo)
{
WKURLRef wkURL = WKBundleFrameCopyURL(WKBundlePageGetMainFrame(page));
CFURLRef cfURL = WKURLCopyCFURL(0, wkURL);
WKURLRelease(wkURL);
- LOG(@"WKBundlePageClient - _didClearWindowForFrame %@", [(NSURL *)cfURL absoluteString]);
+ LOG(@"WKBundlePageClient - didClearWindowForFrame %@", [(NSURL *)cfURL absoluteString]);
CFRelease(cfURL);
WKStringRef message = WKStringCreateWithCFString(CFSTR("Window was cleared"));
@@ -82,35 +82,44 @@ void _didClearWindowForFrame(WKBundlePageRef page, WKBundleFrameRef frame, JSGlo
// WKBundleClient
-void _didCreatePage(WKBundleRef bundle, WKBundlePageRef page, const void* clientInfo)
+void didCreatePage(WKBundleRef bundle, WKBundlePageRef page, const void* clientInfo)
{
LOG(@"WKBundleClient - didCreatePage\n");
WKBundlePageLoaderClient client = {
0,
0,
- _didStartProvisionalLoadForFrame,
- _didReceiveServerRedirectForProvisionalLoadForFrame,
- _didFailProvisionalLoadWithErrorForFrame,
- _didCommitLoadForFrame,
- _didFinishLoadForFrame,
- _didFailLoadWithErrorForFrame,
- _didReceiveTitleForFrame,
- _didClearWindowForFrame
+ didStartProvisionalLoadForFrame,
+ didReceiveServerRedirectForProvisionalLoadForFrame,
+ didFailProvisionalLoadWithErrorForFrame,
+ didCommitLoadForFrame,
+ didFinishLoadForFrame,
+ didFailLoadWithErrorForFrame,
+ didReceiveTitleForFrame,
+ didClearWindowForFrame
};
WKBundlePageSetLoaderClient(page, &client);
}
-void _willDestroyPage(WKBundleRef bundle, WKBundlePageRef page, const void* clientInfo)
+void willDestroyPage(WKBundleRef bundle, WKBundlePageRef page, const void* clientInfo)
{
LOG(@"WKBundleClient - willDestroyPage\n");
}
-void _didRecieveMessage(WKBundleRef bundle, WKStringRef message, const void *clientInfo)
+void didRecieveMessage(WKBundleRef bundle, WKStringRef messageName, WKTypeRef messageBody, const void *clientInfo)
{
- CFStringRef cfMessage = WKStringCopyCFString(0, message);
- LOG(@"WKBundleClient - didRecieveMessage %@\n", cfMessage);
- CFRelease(cfMessage);
+ CFStringRef cfMessageName = WKStringCopyCFString(0, messageName);
+
+ WKTypeID typeID = WKGetTypeID(messageBody);
+ if (typeID == WKStringGetTypeID()) {
+ CFStringRef cfMessageBody = WKStringCopyCFString(0, (WKStringRef)messageBody);
+ LOG(@"WKBundleClient - didRecieveMessage %@ (Type=String) %@\n", cfMessageName, cfMessageBody);
+ CFRelease(cfMessageBody);
+ } else {
+ LOG(@"WKBundleClient - didRecieveMessage %@ (Type=Unhandeled)\n", cfMessageName);
+ }
+
+ CFRelease(cfMessageName);
}
void WKBundleInitialize(WKBundleRef bundle)
@@ -120,9 +129,9 @@ void WKBundleInitialize(WKBundleRef bundle)
WKBundleClient client = {
0,
0,
- _didCreatePage,
- _willDestroyPage,
- _didRecieveMessage
+ didCreatePage,
+ willDestroyPage,
+ didRecieveMessage
};
WKBundleSetClient(bundle, &client);
}
diff --git a/WebKitTools/WebKitTestRunner/InjectedBundle/InjectedBundle.cpp b/WebKitTools/WebKitTestRunner/InjectedBundle/InjectedBundle.cpp
index 0e99dde..150f6d1 100644
--- a/WebKitTools/WebKitTestRunner/InjectedBundle/InjectedBundle.cpp
+++ b/WebKitTools/WebKitTestRunner/InjectedBundle/InjectedBundle.cpp
@@ -58,9 +58,9 @@ void InjectedBundle::_willDestroyPage(WKBundleRef bundle, WKBundlePageRef page,
static_cast<InjectedBundle*>(const_cast<void*>(clientInfo))->willDestroyPage(page);
}
-void InjectedBundle::_didReceiveMessage(WKBundleRef bundle, WKStringRef message, const void *clientInfo)
+void InjectedBundle::_didReceiveMessage(WKBundleRef bundle, WKStringRef messageName, WKTypeRef messageBody, const void *clientInfo)
{
- static_cast<InjectedBundle*>(const_cast<void*>(clientInfo))->didReceiveMessage(message);
+ static_cast<InjectedBundle*>(const_cast<void*>(clientInfo))->didReceiveMessage(messageName, messageBody);
}
void InjectedBundle::initialize(WKBundleRef bundle)
@@ -99,9 +99,9 @@ void InjectedBundle::willDestroyPage(WKBundlePageRef page)
delete m_pages.take(page);
}
-void InjectedBundle::didReceiveMessage(WKStringRef message)
+void InjectedBundle::didReceiveMessage(WKStringRef messageName, WKTypeRef messageBody)
{
- CFStringRef cfMessage = WKStringCopyCFString(0, message);
+ CFStringRef cfMessage = WKStringCopyCFString(0, messageName);
if (CFEqual(cfMessage, CFSTR("BeginTest"))) {
WKRetainPtr<WKStringRef> ackMessage(AdoptWK, WKStringCreateWithCFString(CFSTR("BeginTestAck")));
WKBundlePostMessage(m_bundle, ackMessage.get());
diff --git a/WebKitTools/WebKitTestRunner/InjectedBundle/InjectedBundle.h b/WebKitTools/WebKitTestRunner/InjectedBundle/InjectedBundle.h
index 9bda922..28b56a7 100644
--- a/WebKitTools/WebKitTestRunner/InjectedBundle/InjectedBundle.h
+++ b/WebKitTools/WebKitTestRunner/InjectedBundle/InjectedBundle.h
@@ -60,11 +60,11 @@ private:
static void _didCreatePage(WKBundleRef bundle, WKBundlePageRef page, const void* clientInfo);
static void _willDestroyPage(WKBundleRef bundle, WKBundlePageRef page, const void* clientInfo);
- static void _didReceiveMessage(WKBundleRef bundle, WKStringRef message, const void *clientInfo);
+ static void _didReceiveMessage(WKBundleRef bundle, WKStringRef messageName, WKTypeRef messageBody, const void *clientInfo);
void didCreatePage(WKBundlePageRef page);
void willDestroyPage(WKBundlePageRef page);
- void didReceiveMessage(WKStringRef message);
+ void didReceiveMessage(WKStringRef messageName, WKTypeRef messageBody);
void reset();
diff --git a/WebKitTools/WebKitTestRunner/TestInvocation.cpp b/WebKitTools/WebKitTestRunner/TestInvocation.cpp
index b6e950f..539bb6e 100644
--- a/WebKitTools/WebKitTestRunner/TestInvocation.cpp
+++ b/WebKitTools/WebKitTestRunner/TestInvocation.cpp
@@ -108,8 +108,9 @@ void TestInvocation::invoke()
sizeWebViewForCurrentTest(m_pathOrURL);
resetPreferencesToConsistentValues();
- WKRetainPtr<WKStringRef> message(AdoptWK, WKStringCreateWithCFString(CFSTR("BeginTest")));
- WKContextPostMessageToInjectedBundle(TestController::shared().context(), message.get());
+ WKRetainPtr<WKStringRef> messageName(AdoptWK, WKStringCreateWithCFString(CFSTR("BeginTest")));
+ WKRetainPtr<WKStringRef> messageBody(AdoptWK, WKStringCreateWithCFString(CFSTR("")));
+ WKContextPostMessageToInjectedBundle(TestController::shared().context(), messageName.get(), messageBody.get());
runUntil(m_gotInitialResponse);
if (m_error) {
diff --git a/WebKitTools/WebKitTestRunner/WebKitTestRunner.xcodeproj/project.pbxproj b/WebKitTools/WebKitTestRunner/WebKitTestRunner.xcodeproj/project.pbxproj
index eccf330..23fe79b 100644
--- a/WebKitTools/WebKitTestRunner/WebKitTestRunner.xcodeproj/project.pbxproj
+++ b/WebKitTools/WebKitTestRunner/WebKitTestRunner.xcodeproj/project.pbxproj
@@ -108,7 +108,7 @@
BC952ED211F3C29F003398B4 /* LayoutTestController.idl */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text; path = LayoutTestController.idl; sourceTree = "<group>"; };
BC952ED311F3C318003398B4 /* CodeGeneratorTestRunner.pm */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.script.perl; path = CodeGeneratorTestRunner.pm; sourceTree = "<group>"; };
BC952F1D11F3C652003398B4 /* JSLayoutTestController.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; name = JSLayoutTestController.cpp; path = DerivedSources/WebKitTestRunner/JSLayoutTestController.cpp; sourceTree = BUILT_PRODUCTS_DIR; };
- BC952F1E11F3C652003398B4 /* JSLayoutTestController.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = JSLayoutTestController.h; path = DerivedSources/WebKitTestRunner/JSLayoutTestController.h; sourceTree = BUILT_PRODUCTS_DIR; };
+ BC952F1E11F3C652003398B4 /* JSLayoutTestController.h */ = {isa = PBXFileReference; fileEncoding = 4; name = JSLayoutTestController.h; path = DerivedSources/WebKitTestRunner/JSLayoutTestController.h; sourceTree = BUILT_PRODUCTS_DIR; };
BCC997A011D3C8F60017BCA2 /* InjectedBundle.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = InjectedBundle.cpp; sourceTree = "<group>"; };
BCC997A111D3C8F60017BCA2 /* InjectedBundle.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = InjectedBundle.h; sourceTree = "<group>"; };
BCC997A211D3C8F60017BCA2 /* InjectedBundlePage.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = InjectedBundlePage.cpp; sourceTree = "<group>"; };
--
WebKit Debian packaging
More information about the Pkg-webkit-commits
mailing list