diff options
Diffstat (limited to 'Source/WebKit2')
73 files changed, 1411 insertions, 587 deletions
diff --git a/Source/WebKit2/CMakeLists.txt b/Source/WebKit2/CMakeLists.txt index 235af260c..b6bfc7c6f 100644 --- a/Source/WebKit2/CMakeLists.txt +++ b/Source/WebKit2/CMakeLists.txt @@ -127,6 +127,7 @@ SET(WebKit2_SOURCES Platform/CoreIPC/MessageDecoder.cpp Platform/CoreIPC/MessageEncoder.cpp Platform/CoreIPC/MessageReceiverMap.cpp + Platform/CoreIPC/StringReference.cpp PluginProcess/PluginControllerProxy.cpp PluginProcess/PluginCreationParameters.cpp diff --git a/Source/WebKit2/ChangeLog b/Source/WebKit2/ChangeLog index e34143e69..fd2f47ef0 100644 --- a/Source/WebKit2/ChangeLog +++ b/Source/WebKit2/ChangeLog @@ -1,3 +1,495 @@ +2012-10-23 Christophe Dumez <christophe.dumez@intel.com> + + [EFL][WK2] Make page load client a C++ class + https://bugs.webkit.org/show_bug.cgi?id=100081 + + Reviewed by Kenneth Rohde Christiansen. + + Make page load client a C++ class and move it + up to UIProcess/efl since it is not really part + of the public API. + + * PlatformEfl.cmake: + * UIProcess/API/efl/ewk_view.cpp: + (Ewk_View_Private_Data): + (_ewk_view_initialize): + * UIProcess/API/efl/ewk_view_loader_client_private.h: Removed. + * UIProcess/efl/PageLoadClientEfl.cpp: Renamed from Source/WebKit2/UIProcess/API/efl/ewk_view_loader_client.cpp. + (WebKit): + (WebKit::toPageLoadClientEfl): + (WebKit::PageLoadClientEfl::didReceiveTitleForFrame): + (WebKit::PageLoadClientEfl::didReceiveIntentForFrame): + (WebKit::PageLoadClientEfl::registerIntentServiceForFrame): + (WebKit::PageLoadClientEfl::didChangeProgress): + (WebKit::PageLoadClientEfl::didFinishLoadForFrame): + (WebKit::PageLoadClientEfl::didFailLoadWithErrorForFrame): + (WebKit::PageLoadClientEfl::didStartProvisionalLoadForFrame): + (WebKit::PageLoadClientEfl::didReceiveServerRedirectForProvisionalLoadForFrame): + (WebKit::PageLoadClientEfl::didFailProvisionalLoadWithErrorForFrame): + (WebKit::PageLoadClientEfl::didChangeBackForwardList): + (WebKit::PageLoadClientEfl::didSameDocumentNavigationForFrame): + (WebKit::PageLoadClientEfl::PageLoadClientEfl): + * UIProcess/efl/PageLoadClientEfl.h: Added. + (WebKit): + (PageLoadClientEfl): + (WebKit::PageLoadClientEfl::create): + (WebKit::PageLoadClientEfl::view): + +2012-10-22 Anders Carlsson <andersca@apple.com> + + Handle ArgumentCoder template specializations that take the ArgumentEncoder as a reference + https://bugs.webkit.org/show_bug.cgi?id=100056 + + Reviewed by Andreas Kling. + + Use template magic to make it possible to have ArgumentCoder specializations where the encode + function takes the ArgumentEncoder object as a reference instead of as a pointer. Also, add an + operator<< to ArgumentEncoder and change the string related ArgumentCoder specializations over to taking + the encoder as a reference and using stream operators. + + * Platform/CoreIPC/ArgumentCoders.cpp: + (CoreIPC::::encode): + * Platform/CoreIPC/ArgumentCoders.h: + * Platform/CoreIPC/ArgumentEncoder.h: + (ArgumentEncoder): + (UsesDeprecatedEncodeFunction): + (NoType): + (CoreIPC::ArgumentEncoder::encode): + (CoreIPC::ArgumentEncoder::operator<<): + +2012-10-22 Anders Carlsson <andersca@apple.com> + + More Argument coder cleanup + https://bugs.webkit.org/show_bug.cgi?id=100022 + + Reviewed by Andreas Kling. + + Remove the ArgumentDecoder::decode overload that takes a const reference - if the call to decode ends up creating a temporary + we'll encode into it and then destroy it. Since this decode overload was mostly used with the CoreIPC::Out functions, remove them + (and CoreIPC::In) as well. Clean up a couple of ArgumentCoders as well. + + * Platform/CoreIPC/ArgumentCoders.h: + * Platform/CoreIPC/ArgumentDecoder.h: + * Platform/CoreIPC/Arguments.h: + * Platform/CoreIPC/Connection.h: + (Connection): + * Platform/mac/SharedMemoryMac.cpp: + (WebKit::SharedMemory::Handle::decode): + * Shared/PrintInfo.cpp: + (WebKit::PrintInfo::encode): + (WebKit::PrintInfo::decode): + * Shared/WebContextMenuItemData.cpp: + (WebKit::WebContextMenuItemData::encode): + (WebKit::WebContextMenuItemData::decode): + * Shared/WebEvent.cpp: + (WebKit::WebEvent::encode): + (WebKit::WebEvent::decode): + * Shared/WebGeolocationPosition.cpp: + (WebKit::WebGeolocationPosition::Data::encode): + (WebKit::WebGeolocationPosition::Data::decode): + * Shared/WebMouseEvent.cpp: + (WebKit::WebMouseEvent::encode): + (WebKit::WebMouseEvent::decode): + * Shared/WebPopupItem.cpp: + (WebKit::WebPopupItem::encode): + (WebKit::WebPopupItem::decode): + * UIProcess/WebConnectionToWebProcess.cpp: + (WebKit::WebConnectionToWebProcess::decodeMessageBody): + * UIProcess/WebContext.cpp: + (WebKit::WebContext::didReceiveMessage): + (WebKit::WebContext::didReceiveSyncMessage): + * WebProcess/InjectedBundle/InjectedBundle.cpp: + (WebKit::InjectedBundle::postMessage): + (WebKit::InjectedBundle::postSynchronousMessage): + * WebProcess/WebConnectionToUIProcess.cpp: + (WebKit::WebConnectionToUIProcess::decodeMessageBody): + * WebProcess/WebPage/WebPage.cpp: + (WebKit::WebPage::postInjectedBundleMessage): + * WebProcess/WebProcess.cpp: + (WebKit::WebProcess::postInjectedBundleMessage): + +2012-10-22 Anders Carlsson <andersca@apple.com> + + Remove MessageReceiverMap::deprecatedAddMessageReceiver + https://bugs.webkit.org/show_bug.cgi?id=100012 + + Reviewed by Andreas Kling. + + Get rid of MessageReceiverMap::deprecatedAddMessageReceiver and make callers use addMessageReceiver instead. + Also, remove the message receiver map inside Connection and add a message receiver map to WebProcess instead. + + * Platform/CoreIPC/Connection.cpp: + (CoreIPC::Connection::dispatchMessage): + * Platform/CoreIPC/Connection.h: + (Connection): + * Platform/CoreIPC/MessageReceiverMap.cpp: + (CoreIPC::MessageReceiverMap::invalidate): + (CoreIPC::MessageReceiverMap::dispatchMessage): + (CoreIPC::MessageReceiverMap::dispatchSyncMessage): + * Platform/CoreIPC/MessageReceiverMap.h: + (MessageReceiverMap): + * UIProcess/Notifications/WebNotificationManagerProxy.cpp: + (WebKit::WebNotificationManagerProxy::WebNotificationManagerProxy): + * UIProcess/WebApplicationCacheManagerProxy.cpp: + (WebKit::WebApplicationCacheManagerProxy::WebApplicationCacheManagerProxy): + * UIProcess/WebContext.cpp: + * UIProcess/WebContext.h: + (WebContext): + * UIProcess/WebCookieManagerProxy.cpp: + (WebKit::WebCookieManagerProxy::WebCookieManagerProxy): + * UIProcess/WebDatabaseManagerProxy.cpp: + (WebKit::WebDatabaseManagerProxy::WebDatabaseManagerProxy): + * UIProcess/WebGeolocationManagerProxy.cpp: + (WebKit::WebGeolocationManagerProxy::WebGeolocationManagerProxy): + * UIProcess/WebIconDatabase.cpp: + (WebKit::WebIconDatabase::WebIconDatabase): + * UIProcess/WebKeyValueStorageManagerProxy.cpp: + (WebKit::WebKeyValueStorageManagerProxy::WebKeyValueStorageManagerProxy): + * UIProcess/WebMediaCacheManagerProxy.cpp: + (WebKit::WebMediaCacheManagerProxy::WebMediaCacheManagerProxy): + * UIProcess/WebResourceCacheManagerProxy.cpp: + (WebKit::WebResourceCacheManagerProxy::WebResourceCacheManagerProxy): + * WebProcess/Authentication/AuthenticationManager.cpp: + (WebKit::AuthenticationManager::AuthenticationManager): + * WebProcess/Geolocation/WebGeolocationManager.cpp: + (WebKit::WebGeolocationManager::WebGeolocationManager): + (WebKit::WebGeolocationManager::registerWebPage): + * WebProcess/Geolocation/WebGeolocationManager.h: + (WebGeolocationManager): + * WebProcess/WebProcess.cpp: + (WebKit::WebProcess::addMessageReceiver): + (WebKit): + (WebKit::WebProcess::didReceiveSyncMessage): + (WebKit::WebProcess::didReceiveMessage): + * WebProcess/WebProcess.h: + (WebProcess): + +2012-10-22 Sudarsana Nagineni <sudarsana.nagineni@intel.com> + + [EFL][WK2] ewk_view_color_picker_color_set() is leaking + https://bugs.webkit.org/show_bug.cgi?id=100007 + + Reviewed by Kenneth Rohde Christiansen. + + Fix a leak in ewk_view_color_picker_color_set() by adopting WKStringRef + returned by WKStringCreateWithUTF8CString(). + + * UIProcess/API/efl/ewk_view.cpp: + (ewk_view_color_picker_color_set): + +2012-10-22 Christophe Dumez <christophe.dumez@intel.com> + + [EFL][WK2] Make the resource load client a C++ class + https://bugs.webkit.org/show_bug.cgi?id=99982 + + Reviewed by Kenneth Rohde Christiansen. + + Create a C++ class for the resource load client and + move the id <-> resource mapping from the Ewk_View + to ResourceLoadClientEfl for better a cleaner + separation. + + The resource load client code was also moved out of + UIProcess/API/efl to UIProcess/efl since this is not + part of the WK2 EFL API. + + * PlatformEfl.cmake: + * UIProcess/API/efl/ewk_view.cpp: + (Ewk_View_Private_Data): + (_ewk_view_initialize): + (ewk_view_wkpage_get): + (ewk_view_resource_load_initiated): + (ewk_view_resource_load_response): + (ewk_view_resource_load_failed): + (ewk_view_resource_load_finished): + (ewk_view_resource_request_sent): + (ewk_view_load_provisional_started): + * UIProcess/API/efl/ewk_view_private.h: + * UIProcess/API/efl/ewk_view_resource_load_client.cpp: Removed. + * UIProcess/API/efl/ewk_view_resource_load_client_private.h: Removed. + * UIProcess/efl/ResourceLoadClientEfl.cpp: Added. + (WebKit): + (WebKit::toResourceLoadClientEfl): + (WebKit::ResourceLoadClientEfl::didInitiateLoadForResource): + (WebKit::ResourceLoadClientEfl::didSendRequestForResource): + (WebKit::ResourceLoadClientEfl::didReceiveResponseForResource): + (WebKit::ResourceLoadClientEfl::didFinishLoadForResource): + (WebKit::ResourceLoadClientEfl::didFailLoadForResource): + (WebKit::ResourceLoadClientEfl::onViewProvisionalLoadStarted): + (WebKit::ResourceLoadClientEfl::ResourceLoadClientEfl): + (WebKit::ResourceLoadClientEfl::~ResourceLoadClientEfl): + * UIProcess/efl/ResourceLoadClientEfl.h: Added. + (WebKit): + (ResourceLoadClientEfl): + (WebKit::ResourceLoadClientEfl::create): + +2012-10-22 Anders Carlsson <andersca@apple.com> + + [WK2] Regression(r131990): plugins/npruntime/remove-property.html started failing + https://bugs.webkit.org/show_bug.cgi?id=99977 + + Reviewed by Alexey Proskuryakov. + + Remove int32_t casts - the ArgumentDecoder::decode overload that takes a const int would cause + a temporary to be created which the number was then decoded into. + + * Shared/Plugins/NPIdentifierData.cpp: + (WebKit::NPIdentifierData::encode): + (WebKit::NPIdentifierData::decode): + +2012-10-22 Anders Carlsson <andersca@apple.com> + + Don't use CStrings for message receiver names and message names + https://bugs.webkit.org/show_bug.cgi?id=99853 + + Reviewed by Andreas Kling. + + Re-land this with a fix to MessageReceiverMap::dispatchSyncMessage to look in the new global message receivers map. + + Introduce StringReference which is similar to DataReference except it holds a pointer to + length of a char * + and can be created from a string literal. Use this in place of CString in MessageEncoder/MessageDecoder and + make MessageReceiverMap use a HashMap from StringReferences to MessageReceivers for global message receivers. + + * CMakeLists.txt: + * GNUmakefile.list.am: + * Platform/CoreIPC/Connection.cpp: + (CoreIPC::Connection::createSyncMessageEncoder): + (CoreIPC::Connection::dispatchSyncMessage): + * Platform/CoreIPC/Connection.h: + (Connection): + (CoreIPC::Connection::deprecatedSendSync): + (CoreIPC::Connection::deprecatedSend): + * Platform/CoreIPC/MessageDecoder.cpp: + (CoreIPC::MessageDecoder::MessageDecoder): + * Platform/CoreIPC/MessageDecoder.h: + (CoreIPC::MessageDecoder::messageReceiverName): + (CoreIPC::MessageDecoder::messageName): + (MessageDecoder): + * Platform/CoreIPC/MessageEncoder.cpp: + (CoreIPC::MessageEncoder::create): + (CoreIPC::MessageEncoder::MessageEncoder): + * Platform/CoreIPC/MessageEncoder.h: + (CoreIPC): + (MessageEncoder): + * Platform/CoreIPC/MessageReceiverMap.cpp: + (CoreIPC::MessageReceiverMap::addMessageReceiver): + (CoreIPC): + (CoreIPC::MessageReceiverMap::dispatchMessage): + * Platform/CoreIPC/MessageReceiverMap.h: + (MessageReceiverMap): + * Platform/CoreIPC/StringReference.cpp: Added. + (CoreIPC): + (CoreIPC::StringReference::encode): + (CoreIPC::StringReference::decode): + (CoreIPC::StringReference::Hash::hash): + * Platform/CoreIPC/StringReference.h: Added. + (CoreIPC): + (StringReference): + (CoreIPC::StringReference::StringReference): + (CoreIPC::StringReference::isEmpty): + (CoreIPC::StringReference::size): + (CoreIPC::StringReference::data): + (CoreIPC::StringReference::operator==): + (Hash): + (CoreIPC::StringReference::Hash::equal): + (WTF): + * Platform/CoreIPC/mac/ConnectionMac.cpp: + (CoreIPC::Connection::open): + * Scripts/webkit2/messages.py: + (message_to_struct_declaration): + (forward_declarations_and_headers): + (generate_messages_header): + * Scripts/webkit2/messages_unittest.py: + * Shared/CoreIPCSupport/WebContextMessageKinds.h: + * Target.pri: + * UIProcess/WebContext.cpp: + (WebKit::WebContext::WebContext): + (WebKit::WebContext::addMessageReceiver): + (WebKit): + * UIProcess/WebContext.h: + (WebContext): + * UIProcess/WebProcessProxy.h: + (WebKit::WebProcessProxy::deprecatedSend): + (WebKit::WebProcessProxy::send): + * WebKit2.xcodeproj/project.pbxproj: + * win/WebKit2.vcproj: + +2012-10-22 Sheriff Bot <webkit.review.bot@gmail.com> + + Unreviewed, rolling out r132072. + http://trac.webkit.org/changeset/132072 + https://bugs.webkit.org/show_bug.cgi?id=100011 + + Made most of the tests crash on the WK2 bot. (Requested by + rakuco on #webkit). + + * UIProcess/API/efl/PageClientImpl.cpp: + (WebKit::PageClientImpl::handleDownloadRequest): + * UIProcess/API/efl/ewk_context.cpp: + (Ewk_Context): + (Ewk_Context::Ewk_Context): + (ewk_context_ref): + (ewk_context_unref): + (ewk_context_cookie_manager_get): + (ewk_context_favicon_database_get): + (ewk_context_WKContext_get): + (ewk_context_new_from_WKContext): + (ewk_context_download_job_add): + (ewk_context_download_job_get): + (ewk_context_download_job_remove): + (ewk_context_request_manager_get): + (ewk_context_url_scheme_request_received): + (ewk_context_default_get): + (ewk_context_new): + (ewk_context_new_with_injected_bundle_path): + (ewk_context_url_scheme_register): + (ewk_context_vibration_client_callbacks_set): + (ewk_context_history_callbacks_set): + (ewk_context_history_client_get): + (ewk_context_visited_link_add): + (ewk_context_cache_model_set): + (ewk_context_cache_model_get): + * UIProcess/API/efl/ewk_context_download_client.cpp: + (decideDestinationWithSuggestedFilename): + (didReceiveResponse): + (didCreateDestination): + (didReceiveData): + (didFail): + (didCancel): + (didFinish): + (ewk_context_download_client_attach): + * UIProcess/API/efl/ewk_context_history_client.cpp: + (getEwkHistoryDelegate): + (didNavigateWithNavigationData): + (didPerformClientRedirect): + (didPerformServerRedirect): + (didUpdateHistoryTitle): + (populateVisitedLinks): + (ewk_context_history_client_attach): + * UIProcess/API/efl/ewk_context_private.h: + * UIProcess/API/efl/ewk_context_request_manager_client.cpp: + (didReceiveURIRequest): + (ewk_context_request_manager_client_attach): + * UIProcess/API/efl/ewk_view.cpp: + (Ewk_View_Private_Data): + (Ewk_View_Private_Data::Ewk_View_Private_Data): + (Ewk_View_Private_Data::~Ewk_View_Private_Data): + (_ewk_view_priv_del): + (_ewk_view_initialize): + (ewk_view_base_add): + (ewk_view_add_with_context): + (ewk_view_context_get): + (ewk_view_update_icon): + +2012-10-22 Darin Adler <darin@apple.com> + + * UIProcess/API/mac/WKView.mm: + (-[WKView view:stringForToolTip:point:userData:]): Fix build. Forgot to save file + before committing. + +2012-10-22 Darin Adler <darin@apple.com> + + REGRESSION (r131686): Crash in NSToolTipManager mouseEnteredToolTip + <rdar://problem/12527528> and https://bugs.webkit.org/show_bug.cgi?id=99792 + + Roll out the tool tip part of r131686 since it still seems to be causing trouble. + + * UIProcess/API/mac/WKView.mm: + (-[WKView view:stringForToolTip:point:userData:]): Added this method back. + (-[WKView _wk_toolTipChangedFrom:to:]): Use self as owner again, eliminating the + separate WKToolTipDelegate object. + +2012-10-22 Christophe Dumez <christophe.dumez@intel.com> + + [EFL][WK2] Memory leak in Ewk_Form_Submission_Request::fieldValue() + https://bugs.webkit.org/show_bug.cgi?id=99993 + + Reviewed by Kenneth Rohde Christiansen. + + Adopt the WKStringRef returned by toCopiedAPI() in + Ewk_Form_Submission_Request::fieldValue() to avoid + a memory leak. + + * UIProcess/API/efl/ewk_form_submission_request.cpp: + (Ewk_Form_Submission_Request::fieldValue): + +2012-10-22 Mikhail Pozdnyakov <mikhail.pozdnyakov@intel.com> + + [EFL][WK2] Refactor Ewk_Context + https://bugs.webkit.org/show_bug.cgi?id=99594 + + Reviewed by Kenneth Rohde Christiansen. + + Ewk_Context is now encapsulated to a C++ class inherited from WTF::RefCounted. + + * UIProcess/API/efl/PageClientImpl.cpp: + (WebKit::PageClientImpl::handleDownloadRequest): + * UIProcess/API/efl/ewk_context.cpp: + (Ewk_Context::Ewk_Context): + (Ewk_Context::~Ewk_Context): + (Ewk_Context::create): + (Ewk_Context::defaultContext): + (Ewk_Context::cookieManager): + (Ewk_Context::faviconDatabase): + (Ewk_Context::registerURLScheme): + (Ewk_Context::vibrationProvider): + (Ewk_Context::addVisitedLink): + (Ewk_Context::setCacheModel): + (Ewk_Context::cacheModel): + (ewk_context_ref): + (ewk_context_unref): + (ewk_context_cookie_manager_get): + (ewk_context_favicon_database_get): + (Ewk_Context::wkContext): + (Ewk_Context::addDownloadJob): + (Ewk_Context::downloadJob): + (Ewk_Context::removeDownloadJob): + (Ewk_Context::requestManager): + (Ewk_Context::urlSchemeRequestReceived): + (ewk_context_default_get): + (ewk_context_new): + (ewk_context_new_with_injected_bundle_path): + (ewk_context_url_scheme_register): + (ewk_context_vibration_client_callbacks_set): + (ewk_context_history_callbacks_set): + (ewk_context_visited_link_add): + (ewk_context_cache_model_set): + (ewk_context_cache_model_get): + * UIProcess/API/efl/ewk_context_download_client.cpp: + (decideDestinationWithSuggestedFilename): + (didReceiveResponse): + (didCreateDestination): + (didReceiveData): + (didFail): + (didCancel): + (didFinish): + (ewk_context_download_client_attach): + * UIProcess/API/efl/ewk_context_history_client.cpp: + (getEwkHistoryClient): + (didNavigateWithNavigationData): + (didPerformClientRedirect): + (didPerformServerRedirect): + (didUpdateHistoryTitle): + (populateVisitedLinks): + (ewk_context_history_client_attach): + * UIProcess/API/efl/ewk_context_private.h: + (Ewk_Context): + (Ewk_Context::create): + (Ewk_Context::historyClient): + * UIProcess/API/efl/ewk_context_request_manager_client.cpp: + (didReceiveURIRequest): + (ewk_context_request_manager_client_attach): + * UIProcess/API/efl/ewk_view.cpp: + (Ewk_View_Private_Data): + (Ewk_View_Private_Data::Ewk_View_Private_Data): + (Ewk_View_Private_Data::~Ewk_View_Private_Data): + (_ewk_view_priv_del): + (_ewk_view_initialize): + (ewk_view_base_add): + (ewk_view_add_with_context): + (ewk_view_context_get): + (ewk_view_update_icon): + 2012-10-22 Simon Hausmann <simon.hausmann@digia.com> [Qt] Fix build without QtWidgets diff --git a/Source/WebKit2/GNUmakefile.list.am b/Source/WebKit2/GNUmakefile.list.am index 4cf80f965..416cf26c5 100644 --- a/Source/WebKit2/GNUmakefile.list.am +++ b/Source/WebKit2/GNUmakefile.list.am @@ -266,6 +266,8 @@ webkit2_sources += \ Source/WebKit2/Platform/CoreIPC/MessageReceiverMap.cpp \ Source/WebKit2/Platform/CoreIPC/MessageReceiverMap.h \ Source/WebKit2/Platform/CoreIPC/MessageSender.h \ + Source/WebKit2/Platform/CoreIPC/StringReference.cpp \ + Source/WebKit2/Platform/CoreIPC/StringReference.h \ Source/WebKit2/Platform/CoreIPC/unix/AttachmentUnix.cpp \ Source/WebKit2/Platform/CoreIPC/unix/ConnectionUnix.cpp \ Source/WebKit2/Platform/gtk/LoggingGtk.cpp \ @@ -1234,6 +1236,8 @@ webkit2_plugin_process_sources += \ Source/WebKit2/Platform/CoreIPC/MessageReceiverMap.cpp \ Source/WebKit2/Platform/CoreIPC/MessageReceiverMap.h \ Source/WebKit2/Platform/CoreIPC/MessageSender.h \ + Source/WebKit2/Platform/CoreIPC/StringReference.cpp \ + Source/WebKit2/Platform/CoreIPC/StringReference.h \ Source/WebKit2/Platform/CoreIPC/unix/AttachmentUnix.cpp \ Source/WebKit2/Platform/CoreIPC/unix/ConnectionUnix.cpp \ Source/WebKit2/Platform/Module.cpp \ diff --git a/Source/WebKit2/Platform/CoreIPC/ArgumentCoders.cpp b/Source/WebKit2/Platform/CoreIPC/ArgumentCoders.cpp index f0c17d38e..7153c2748 100644 --- a/Source/WebKit2/Platform/CoreIPC/ArgumentCoders.cpp +++ b/Source/WebKit2/Platform/CoreIPC/ArgumentCoders.cpp @@ -26,14 +26,15 @@ #include "config.h" #include "ArgumentCoders.h" +#include "DataReference.h" #include <wtf/text/CString.h> #include <wtf/text/WTFString.h> namespace CoreIPC { -void ArgumentCoder<AtomicString>::encode(ArgumentEncoder* encoder, const AtomicString& atomicString) +void ArgumentCoder<AtomicString>::encode(ArgumentEncoder& encoder, const AtomicString& atomicString) { - encoder->encode(atomicString.string()); + encoder << atomicString.string(); } bool ArgumentCoder<AtomicString>::decode(ArgumentDecoder* decoder, AtomicString& atomicString) @@ -46,17 +47,16 @@ bool ArgumentCoder<AtomicString>::decode(ArgumentDecoder* decoder, AtomicString& return true; } -void ArgumentCoder<CString>::encode(ArgumentEncoder* encoder, const CString& string) +void ArgumentCoder<CString>::encode(ArgumentEncoder& encoder, const CString& string) { // Special case the null string. if (string.isNull()) { - encoder->encode(std::numeric_limits<uint32_t>::max()); + encoder << std::numeric_limits<uint32_t>::max(); return; } uint32_t length = string.length(); - encoder->encode(length); - encoder->encodeFixedLengthData(reinterpret_cast<const uint8_t*>(string.data()), length, 1); + encoder << length << CoreIPC::DataReference(reinterpret_cast<const uint8_t*>(string.data()), length); } bool ArgumentCoder<CString>::decode(ArgumentDecoder* decoder, CString& result) @@ -87,22 +87,23 @@ bool ArgumentCoder<CString>::decode(ArgumentDecoder* decoder, CString& result) } -void ArgumentCoder<String>::encode(ArgumentEncoder* encoder, const String& string) +void ArgumentCoder<String>::encode(ArgumentEncoder& encoder, const String& string) { // Special case the null string. if (string.isNull()) { - encoder->encode(std::numeric_limits<uint32_t>::max()); + encoder << std::numeric_limits<uint32_t>::max(); return; } uint32_t length = string.length(); - encoder->encode(length); bool is8Bit = string.is8Bit(); - encoder->encode(is8Bit); + + encoder << length << is8Bit; + if (is8Bit) - encoder->encodeFixedLengthData(reinterpret_cast<const uint8_t*>(string.characters8()), length * sizeof(LChar), __alignof(LChar)); + encoder.encodeFixedLengthData(reinterpret_cast<const uint8_t*>(string.characters8()), length * sizeof(LChar), __alignof(LChar)); else - encoder->encodeFixedLengthData(reinterpret_cast<const uint8_t*>(string.characters16()), length * sizeof(UChar), __alignof(UChar)); + encoder.encodeFixedLengthData(reinterpret_cast<const uint8_t*>(string.characters16()), length * sizeof(UChar), __alignof(UChar)); } template <typename CharacterType> diff --git a/Source/WebKit2/Platform/CoreIPC/ArgumentCoders.h b/Source/WebKit2/Platform/CoreIPC/ArgumentCoders.h index f16d7c92f..339cd2d1e 100644 --- a/Source/WebKit2/Platform/CoreIPC/ArgumentCoders.h +++ b/Source/WebKit2/Platform/CoreIPC/ArgumentCoders.h @@ -197,20 +197,20 @@ template<typename KeyArg, typename MappedArg, typename HashArg, typename KeyTrai }; template<> struct ArgumentCoder<AtomicString> { - static void encode(ArgumentEncoder*, const AtomicString&); + static void encode(ArgumentEncoder&, const AtomicString&); static bool decode(ArgumentDecoder*, AtomicString&); }; template<> struct ArgumentCoder<CString> { - static void encode(ArgumentEncoder*, const CString&); + static void encode(ArgumentEncoder&, const CString&); static bool decode(ArgumentDecoder*, CString&); }; template<> struct ArgumentCoder<String> { - static void encode(ArgumentEncoder*, const String&); + static void encode(ArgumentEncoder&, const String&); static bool decode(ArgumentDecoder*, String&); }; } // namespace CoreIPC -#endif // SimpleArgumentCoder_h +#endif // ArgumentCoders_h diff --git a/Source/WebKit2/Platform/CoreIPC/ArgumentDecoder.h b/Source/WebKit2/Platform/CoreIPC/ArgumentDecoder.h index 3c81eb377..c1d4b6e05 100644 --- a/Source/WebKit2/Platform/CoreIPC/ArgumentDecoder.h +++ b/Source/WebKit2/Platform/CoreIPC/ArgumentDecoder.h @@ -90,13 +90,6 @@ public: return ArgumentCoder<T>::decode(this, t); } - // This overload exists so we can pass temporaries to decode. In the Star Trek future, it - // can take an rvalue reference instead. - template<typename T> bool decode(const T& t) - { - return decode(const_cast<T&>(t)); - } - bool removeAttachment(Attachment&); #ifndef NDEBUG diff --git a/Source/WebKit2/Platform/CoreIPC/ArgumentEncoder.h b/Source/WebKit2/Platform/CoreIPC/ArgumentEncoder.h index 54780134a..5fa006fd3 100644 --- a/Source/WebKit2/Platform/CoreIPC/ArgumentEncoder.h +++ b/Source/WebKit2/Platform/CoreIPC/ArgumentEncoder.h @@ -60,13 +60,44 @@ public: encode(static_cast<uint64_t>(t)); } + + template<bool B, typename T = void> + struct EnableIf { }; + + template<typename T> + struct EnableIf<true, T> { typedef T Type; }; - // Generic type encode function. - template<typename T> void encode(const T& t) + template<typename T> class UsesDeprecatedEncodeFunction { + typedef char YesType; + struct NoType { + char padding[8]; + }; + + static YesType checkEncode(void (*)(ArgumentEncoder*, const T&)); + static NoType checkEncode(...); + + public: + static const bool value = sizeof(checkEncode(ArgumentCoder<T>::encode)) == sizeof(YesType); + }; + + // FIXME: This is the function that gets chosen if the argument coder takes the ArgumentEncoder as a pointer. + // This is the deprecated form - get rid of it. + template<typename T> void encode(const T& t, typename EnableIf<UsesDeprecatedEncodeFunction<T>::value>::Type* = 0) { ArgumentCoder<T>::encode(this, t); } + template<typename T> void encode(const T& t, typename EnableIf<!UsesDeprecatedEncodeFunction<T>::value>::Type* = 0) + { + ArgumentCoder<T>::encode(*this, t); + } + + template<typename T> ArgumentEncoder& operator<<(const T& t) + { + encode(t); + return *this; + } + uint8_t* buffer() const { return m_buffer; } size_t bufferSize() const { return m_bufferSize; } diff --git a/Source/WebKit2/Platform/CoreIPC/Arguments.h b/Source/WebKit2/Platform/CoreIPC/Arguments.h index 5bd75502c..1d4c5dc4e 100644 --- a/Source/WebKit2/Platform/CoreIPC/Arguments.h +++ b/Source/WebKit2/Platform/CoreIPC/Arguments.h @@ -45,16 +45,6 @@ struct Arguments0 { } }; -inline Arguments0 In() -{ - return Arguments0(); -} - -inline Arguments0 Out() -{ - return Arguments0(); -} - template<typename T1> struct Arguments1 { typedef Arguments1<typename WTF::RemoveConst<typename WTF::RemoveReference<T1>::Type>::Type> ValueType; @@ -80,16 +70,6 @@ template<typename T1> struct Arguments1 { T1 argument1; }; -template<typename T1> Arguments1<const T1&> In(const T1& t1) -{ - return Arguments1<const T1&>(t1); -} - -template<typename T1> Arguments1<T1&> Out(T1& t1) -{ - return Arguments1<T1&>(t1); -} - template<typename T1, typename T2> struct Arguments2 : Arguments1<T1> { typedef Arguments2<typename WTF::RemoveConst<typename WTF::RemoveReference<T1>::Type>::Type, typename WTF::RemoveConst<typename WTF::RemoveReference<T2>::Type>::Type> ValueType; @@ -121,16 +101,6 @@ template<typename T1, typename T2> struct Arguments2 : Arguments1<T1> { T2 argument2; }; -template<typename T1, typename T2> Arguments2<const T1&, const T2&> In(const T1& t1, const T2& t2) -{ - return Arguments2<const T1&, const T2&>(t1, t2); -} - -template<typename T1, typename T2> Arguments2<T1&, T2&> Out(T1& t1, T2& t2) -{ - return Arguments2<T1&, T2&>(t1, t2); -} - template<typename T1, typename T2, typename T3> struct Arguments3 : Arguments2<T1, T2> { typedef Arguments3<typename WTF::RemoveConst<typename WTF::RemoveReference<T1>::Type>::Type, typename WTF::RemoveConst<typename WTF::RemoveReference<T2>::Type>::Type, @@ -163,16 +133,6 @@ template<typename T1, typename T2, typename T3> struct Arguments3 : Arguments2<T T3 argument3; }; -template<typename T1, typename T2, typename T3> Arguments3<const T1&, const T2&, const T3&> In(const T1& t1, const T2& t2, const T3 &t3) -{ - return Arguments3<const T1&, const T2&, const T3&>(t1, t2, t3); -} - -template<typename T1, typename T2, typename T3> Arguments3<T1&, T2&, T3&> Out(T1& t1, T2& t2, T3& t3) -{ - return Arguments3<T1&, T2&, T3&>(t1, t2, t3); -} - template<typename T1, typename T2, typename T3, typename T4> struct Arguments4 : Arguments3<T1, T2, T3> { typedef Arguments4<typename WTF::RemoveConst<typename WTF::RemoveReference<T1>::Type>::Type, typename WTF::RemoveConst<typename WTF::RemoveReference<T2>::Type>::Type, @@ -206,16 +166,6 @@ template<typename T1, typename T2, typename T3, typename T4> struct Arguments4 : T4 argument4; }; -template<typename T1, typename T2, typename T3, typename T4> Arguments4<const T1&, const T2&, const T3&, const T4&> In(const T1& t1, const T2& t2, const T3 &t3, const T4& t4) -{ - return Arguments4<const T1&, const T2&, const T3&, const T4&>(t1, t2, t3, t4); -} - -template<typename T1, typename T2, typename T3, typename T4> Arguments4<T1&, T2&, T3&, T4&> Out(T1& t1, T2& t2, T3& t3, T4& t4) -{ - return Arguments4<T1&, T2&, T3&, T4&>(t1, t2, t3, t4); -} - template<typename T1, typename T2, typename T3, typename T4, typename T5> struct Arguments5 : Arguments4<T1, T2, T3, T4> { typedef Arguments5<typename WTF::RemoveConst<typename WTF::RemoveReference<T1>::Type>::Type, typename WTF::RemoveConst<typename WTF::RemoveReference<T2>::Type>::Type, @@ -250,16 +200,6 @@ template<typename T1, typename T2, typename T3, typename T4, typename T5> struct T5 argument5; }; -template<typename T1, typename T2, typename T3, typename T4, typename T5> Arguments5<const T1&, const T2&, const T3&, const T4&, const T5&> In(const T1& t1, const T2& t2, const T3 &t3, const T4& t4, const T5& t5) -{ - return Arguments5<const T1&, const T2&, const T3&, const T4&, const T5&>(t1, t2, t3, t4, t5); -} - -template<typename T1, typename T2, typename T3, typename T4, typename T5> Arguments5<T1&, T2&, T3&, T4&, T5&> Out(T1& t1, T2& t2, T3& t3, T4& t4, T5& t5) -{ - return Arguments5<T1&, T2&, T3&, T4&, T5&>(t1, t2, t3, t4, t5); -} - template<typename T1, typename T2, typename T3, typename T4, typename T5, typename T6> struct Arguments6 : Arguments5<T1, T2, T3, T4, T5> { typedef Arguments6<typename WTF::RemoveConst<typename WTF::RemoveReference<T1>::Type>::Type, typename WTF::RemoveConst<typename WTF::RemoveReference<T2>::Type>::Type, @@ -295,16 +235,6 @@ template<typename T1, typename T2, typename T3, typename T4, typename T5, typena T6 argument6; }; -template<typename T1, typename T2, typename T3, typename T4, typename T5, typename T6> Arguments6<const T1&, const T2&, const T3&, const T4&, const T5&, const T6&> In(const T1& t1, const T2& t2, const T3 &t3, const T4& t4, const T5& t5, const T6& t6) -{ - return Arguments6<const T1&, const T2&, const T3&, const T4&, const T5&, const T6&>(t1, t2, t3, t4, t5, t6); -} - -template<typename T1, typename T2, typename T3, typename T4, typename T5, typename T6> Arguments6<T1&, T2&, T3&, T4&, T5&, T6&> Out(T1& t1, T2& t2, T3& t3, T4& t4, T5& t5, T6& t6) -{ - return Arguments6<T1&, T2&, T3&, T4&, T5&, T6&>(t1, t2, t3, t4, t5, t6); -} - template<typename T1, typename T2, typename T3, typename T4, typename T5, typename T6, typename T7> struct Arguments7 : Arguments6<T1, T2, T3, T4, T5, T6> { typedef Arguments7<typename WTF::RemoveConst<typename WTF::RemoveReference<T1>::Type>::Type, typename WTF::RemoveConst<typename WTF::RemoveReference<T2>::Type>::Type, @@ -341,16 +271,6 @@ template<typename T1, typename T2, typename T3, typename T4, typename T5, typena T7 argument7; }; -template<typename T1, typename T2, typename T3, typename T4, typename T5, typename T6, typename T7> Arguments7<const T1&, const T2&, const T3&, const T4&, const T5&, const T6&, const T7&> In(const T1& t1, const T2& t2, const T3 &t3, const T4& t4, const T5& t5, const T6& t6, const T7& t7) -{ - return Arguments7<const T1&, const T2&, const T3&, const T4&, const T5&, const T6&, const T7&>(t1, t2, t3, t4, t5, t6, t7); -} - -template<typename T1, typename T2, typename T3, typename T4, typename T5, typename T6, typename T7> Arguments7<T1&, T2&, T3&, T4&, T5&, T6&, T7&> Out(T1& t1, T2& t2, T3& t3, T4& t4, T5& t5, T6& t6, T7& t7) -{ - return Arguments7<T1&, T2&, T3&, T4&, T5&, T6&, T7&>(t1, t2, t3, t4, t5, t6, t7); -} - template<typename T1, typename T2, typename T3, typename T4, typename T5, typename T6, typename T7, typename T8> struct Arguments8 : Arguments7<T1, T2, T3, T4, T5, T6, T7> { typedef Arguments8<typename WTF::RemoveConst<typename WTF::RemoveReference<T1>::Type>::Type, typename WTF::RemoveConst<typename WTF::RemoveReference<T2>::Type>::Type, @@ -386,16 +306,6 @@ template<typename T1, typename T2, typename T3, typename T4, typename T5, typena T8 argument8; }; -template<typename T1, typename T2, typename T3, typename T4, typename T5, typename T6, typename T7, typename T8> Arguments8<const T1&, const T2&, const T3&, const T4&, const T5&, const T6&, const T7&, const T8&> In(const T1& t1, const T2& t2, const T3 &t3, const T4& t4, const T5& t5, const T6& t6, const T7& t7, const T8& t8) -{ - return Arguments8<const T1&, const T2&, const T3&, const T4&, const T5&, const T6&, const T7&, const T8&>(t1, t2, t3, t4, t5, t6, t7, t8); -} - -template<typename T1, typename T2, typename T3, typename T4, typename T5, typename T6, typename T7, typename T8> Arguments8<T1&, T2&, T3&, T4&, T5&, T6&, T7&, T8&> Out(T1& t1, T2& t2, T3& t3, T4& t4, T5& t5, T6& t6, T7& t7, T8& t8) -{ - return Arguments8<T1&, T2&, T3&, T4&, T5&, T6&, T7&, T8&>(t1, t2, t3, t4, t5, t6, t7, t8); -} - template<typename T1, typename T2, typename T3, typename T4, typename T5, typename T6, typename T7, typename T8, typename T9, typename T10> struct Arguments10 : Arguments8<T1, T2, T3, T4, T5, T6, T7, T8> { typedef Arguments10<typename WTF::RemoveConst<typename WTF::RemoveReference<T1>::Type>::Type, typename WTF::RemoveConst<typename WTF::RemoveReference<T2>::Type>::Type, @@ -437,16 +347,6 @@ template<typename T1, typename T2, typename T3, typename T4, typename T5, typena T10 argument10; }; -template<typename T1, typename T2, typename T3, typename T4, typename T5, typename T6, typename T7, typename T8, typename T9, typename T10> Arguments10<const T1&, const T2&, const T3&, const T4&, const T5&, const T6&, const T7&, const T8&, const T9&, const T10&> In(const T1& t1, const T2& t2, const T3 &t3, const T4& t4, const T5& t5, const T6& t6, const T7& t7, const T8& t8, const T9& t9, const T10& t10) -{ - return Arguments10<const T1&, const T2&, const T3&, const T4&, const T5&, const T6&, const T7&, const T8&, const T9&, const T10&>(t1, t2, t3, t4, t5, t6, t7, t8, t9, t10); -} - -template<typename T1, typename T2, typename T3, typename T4, typename T5, typename T6, typename T7, typename T8, typename T9, typename T10> Arguments10<T1&, T2&, T3&, T4&, T5&, T6&, T7&, T8&, T9&, T10&> Out(T1& t1, T2& t2, T3& t3, T4& t4, T5& t5, T6& t6, T7& t7, T8& t8, T9& t9, T10& t10) -{ - return Arguments10<T1&, T2&, T3&, T4&, T5&, T6&, T7&, T8&, T9&, T10&>(t1, t2, t3, t4, t5, t6, t7, t8, t9, t10); -} - } // namespace CoreIPC #endif // Arguments_h diff --git a/Source/WebKit2/Platform/CoreIPC/Connection.cpp b/Source/WebKit2/Platform/CoreIPC/Connection.cpp index b9f8fcfdc..934583417 100644 --- a/Source/WebKit2/Platform/CoreIPC/Connection.cpp +++ b/Source/WebKit2/Platform/CoreIPC/Connection.cpp @@ -283,7 +283,7 @@ void Connection::markCurrentlyDispatchedMessageAsInvalid() m_didReceiveInvalidMessage = true; } -PassOwnPtr<MessageEncoder> Connection::createSyncMessageEncoder(const CString& messageReceiverName, const CString& messageName, uint64_t destinationID, uint64_t& syncRequestID) +PassOwnPtr<MessageEncoder> Connection::createSyncMessageEncoder(const StringReference messageReceiverName, const StringReference messageName, uint64_t destinationID, uint64_t& syncRequestID) { OwnPtr<MessageEncoder> encoder = MessageEncoder::create(messageReceiverName, messageName, destinationID); @@ -626,7 +626,7 @@ void Connection::dispatchSyncMessage(MessageID messageID, MessageDecoder& decode return; } - OwnPtr<MessageEncoder> replyEncoder = MessageEncoder::create("", "", syncRequestID); + OwnPtr<MessageEncoder> replyEncoder = MessageEncoder::create("IPC", "", syncRequestID); // Hand off both the decoder and encoder to the client. m_client->didReceiveSyncMessage(this, messageID, decoder, replyEncoder); @@ -656,10 +656,6 @@ void Connection::enqueueIncomingMessage(IncomingMessage& incomingMessage) void Connection::dispatchMessage(MessageID messageID, MessageDecoder& decoder) { - // Try the message receiver map first. - if (m_messageReceiverMap.dispatchMessage(this, messageID, decoder)) - return; - m_client->didReceiveMessage(this, messageID, decoder); } diff --git a/Source/WebKit2/Platform/CoreIPC/Connection.h b/Source/WebKit2/Platform/CoreIPC/Connection.h index fb42d9e72..4a7a3a818 100644 --- a/Source/WebKit2/Platform/CoreIPC/Connection.h +++ b/Source/WebKit2/Platform/CoreIPC/Connection.h @@ -32,7 +32,6 @@ #include "MessageDecoder.h" #include "MessageEncoder.h" #include "MessageReceiver.h" -#include "MessageReceiverMap.h" #include "WorkQueue.h" #include <wtf/PassRefPtr.h> #include <wtf/OwnPtr.h> @@ -174,11 +173,6 @@ public: void addQueueClient(QueueClient*); void removeQueueClient(QueueClient*); - void deprecatedAddMessageReceiver(MessageClass messageClass, MessageReceiver* messageReceiver) - { - m_messageReceiverMap.deprecatedAddMessageReceiver(messageClass, messageReceiver); - } - bool open(); void invalidate(); void markCurrentlyDispatchedMessageAsInvalid(); @@ -191,8 +185,9 @@ public: template<typename T> bool sendSync(const T& message, const typename T::Reply& reply, uint64_t destinationID, double timeout = NoTimeout, unsigned syncSendFlags = 0); template<typename T> bool waitForAndDispatchImmediately(uint64_t destinationID, double timeout); - PassOwnPtr<MessageEncoder> createSyncMessageEncoder(const CString& messageReceiverName, const CString& messageName, uint64_t destinationID, uint64_t& syncRequestID); + PassOwnPtr<MessageEncoder> createSyncMessageEncoder(StringReference messageReceiverName, StringReference messageName, uint64_t destinationID, uint64_t& syncRequestID); bool sendMessage(MessageID, PassOwnPtr<MessageEncoder>, unsigned messageSendFlags = 0); + PassOwnPtr<MessageDecoder> sendSyncMessage(MessageID, uint64_t syncRequestID, PassOwnPtr<MessageEncoder>, double timeout, unsigned syncSendFlags = 0); bool sendSyncReply(PassOwnPtr<MessageEncoder>); // FIXME: These variants of send, sendSync and waitFor are all deprecated. @@ -254,7 +249,6 @@ private: PassOwnPtr<MessageDecoder> waitForMessage(MessageID, uint64_t destinationID, double timeout); - PassOwnPtr<MessageDecoder> sendSyncMessage(MessageID, uint64_t syncRequestID, PassOwnPtr<MessageEncoder>, double timeout, unsigned syncSendFlags = 0); PassOwnPtr<MessageDecoder> waitForSyncReply(uint64_t syncRequestID, double timeout, unsigned syncSendFlags); // Called on the connection work queue. @@ -305,8 +299,6 @@ private: Mutex m_incomingMessagesLock; Deque<IncomingMessage> m_incomingMessages; - MessageReceiverMap m_messageReceiverMap; - // Outgoing messages. Mutex m_outgoingMessagesLock; Deque<OutgoingMessage> m_outgoingMessages; @@ -450,7 +442,7 @@ template<typename E, typename T, typename U> inline bool Connection::deprecatedSendSync(E messageID, uint64_t destinationID, const T& arguments, const U& reply, double timeout) { uint64_t syncRequestID = 0; - OwnPtr<MessageEncoder> encoder = createSyncMessageEncoder("", "", destinationID, syncRequestID); + OwnPtr<MessageEncoder> encoder = createSyncMessageEncoder(CoreIPC::MessageKindTraits<E>::messageReceiverName(), "", destinationID, syncRequestID); // Encode the input arguments. encoder->encode(arguments); @@ -467,7 +459,7 @@ inline bool Connection::deprecatedSendSync(E messageID, uint64_t destinationID, template<typename E, typename T> bool Connection::deprecatedSend(E messageID, uint64_t destinationID, const T& arguments) { - OwnPtr<MessageEncoder> encoder = MessageEncoder::create("", "", destinationID); + OwnPtr<MessageEncoder> encoder = MessageEncoder::create(CoreIPC::MessageKindTraits<E>::messageReceiverName(), "", destinationID); encoder->encode(arguments); return sendMessage(MessageID(messageID), encoder.release()); diff --git a/Source/WebKit2/Platform/CoreIPC/MessageDecoder.cpp b/Source/WebKit2/Platform/CoreIPC/MessageDecoder.cpp index e0aef3525..416cf1edb 100644 --- a/Source/WebKit2/Platform/CoreIPC/MessageDecoder.cpp +++ b/Source/WebKit2/Platform/CoreIPC/MessageDecoder.cpp @@ -28,7 +28,7 @@ #include "ArgumentCoders.h" #include "DataReference.h" -#include <wtf/text/CString.h> +#include "StringReference.h" namespace CoreIPC { @@ -50,12 +50,10 @@ MessageDecoder::~MessageDecoder() MessageDecoder::MessageDecoder(const DataReference& buffer, Deque<Attachment>& attachments) : ArgumentDecoder(buffer.data(), buffer.size(), attachments) { - CString messageReceiverName; - if (!decode(messageReceiverName)) + if (!decode(m_messageReceiverName)) return; - CString messageName; - if (!decode(messageName)) + if (!decode(m_messageName)) return; decodeUInt64(m_destinationID); diff --git a/Source/WebKit2/Platform/CoreIPC/MessageDecoder.h b/Source/WebKit2/Platform/CoreIPC/MessageDecoder.h index 848c9b4b9..9707a6ee0 100644 --- a/Source/WebKit2/Platform/CoreIPC/MessageDecoder.h +++ b/Source/WebKit2/Platform/CoreIPC/MessageDecoder.h @@ -27,6 +27,7 @@ #define MessageDecoder_h #include "ArgumentDecoder.h" +#include "StringReference.h" namespace CoreIPC { @@ -38,8 +39,14 @@ public: static PassOwnPtr<MessageDecoder> create(const DataReference& buffer, Deque<Attachment>&); virtual ~MessageDecoder(); + StringReference messageReceiverName() const { return m_messageReceiverName; } + StringReference messageName() const { return m_messageName; } + private: MessageDecoder(const DataReference& buffer, Deque<Attachment>&); + + StringReference m_messageReceiverName; + StringReference m_messageName; }; } // namespace CoreIPC diff --git a/Source/WebKit2/Platform/CoreIPC/MessageEncoder.cpp b/Source/WebKit2/Platform/CoreIPC/MessageEncoder.cpp index 53858b6eb..fbed562dc 100644 --- a/Source/WebKit2/Platform/CoreIPC/MessageEncoder.cpp +++ b/Source/WebKit2/Platform/CoreIPC/MessageEncoder.cpp @@ -27,16 +27,19 @@ #include "MessageEncoder.h" #include "ArgumentCoders.h" +#include "StringReference.h" namespace CoreIPC { -PassOwnPtr<MessageEncoder> MessageEncoder::create(const CString& messageReceiverName, const CString& messageName, uint64_t destinationID) +PassOwnPtr<MessageEncoder> MessageEncoder::create(StringReference messageReceiverName, StringReference messageName, uint64_t destinationID) { return adoptPtr(new MessageEncoder(messageReceiverName, messageName, destinationID)); } -MessageEncoder::MessageEncoder(const CString& messageReceiverName, const CString& messageName, uint64_t destinationID) +MessageEncoder::MessageEncoder(StringReference messageReceiverName, StringReference messageName, uint64_t destinationID) { + ASSERT(!messageReceiverName.isEmpty()); + encode(messageReceiverName); encode(messageName); encode(destinationID); diff --git a/Source/WebKit2/Platform/CoreIPC/MessageEncoder.h b/Source/WebKit2/Platform/CoreIPC/MessageEncoder.h index 2a87850b9..029929245 100644 --- a/Source/WebKit2/Platform/CoreIPC/MessageEncoder.h +++ b/Source/WebKit2/Platform/CoreIPC/MessageEncoder.h @@ -31,13 +31,15 @@ namespace CoreIPC { +class StringReference; + class MessageEncoder : public ArgumentEncoder { public: - static PassOwnPtr<MessageEncoder> create(const CString& messageReceiverName, const CString& messageName, uint64_t destinationID); + static PassOwnPtr<MessageEncoder> create(StringReference messageReceiverName, StringReference messageName, uint64_t destinationID); virtual ~MessageEncoder(); private: - MessageEncoder(const CString& messageReceiverName, const CString& messageName, uint64_t destinationID); + MessageEncoder(StringReference messageReceiverName, StringReference messageName, uint64_t destinationID); }; diff --git a/Source/WebKit2/Platform/CoreIPC/MessageReceiverMap.cpp b/Source/WebKit2/Platform/CoreIPC/MessageReceiverMap.cpp index 50ab296ec..f123b3dda 100644 --- a/Source/WebKit2/Platform/CoreIPC/MessageReceiverMap.cpp +++ b/Source/WebKit2/Platform/CoreIPC/MessageReceiverMap.cpp @@ -26,6 +26,7 @@ #include "config.h" #include "MessageReceiverMap.h" +#include "MessageDecoder.h" #include "MessageReceiver.h" namespace CoreIPC { @@ -38,20 +39,20 @@ MessageReceiverMap::~MessageReceiverMap() { } -void MessageReceiverMap::deprecatedAddMessageReceiver(MessageClass messageClass, MessageReceiver* messageReceiver) +void MessageReceiverMap::addMessageReceiver(StringReference messageReceiverName, MessageReceiver* messageReceiver) { - ASSERT(!m_deprecatedGlobalMessageReceivers.contains(messageClass)); - m_deprecatedGlobalMessageReceivers.set(messageClass, messageReceiver); + ASSERT(!m_globalMessageReceivers.contains(messageReceiverName)); + m_globalMessageReceivers.set(messageReceiverName, messageReceiver); } void MessageReceiverMap::invalidate() { - m_deprecatedGlobalMessageReceivers.clear(); + m_globalMessageReceivers.clear(); } bool MessageReceiverMap::dispatchMessage(Connection* connection, MessageID messageID, MessageDecoder& decoder) { - if (MessageReceiver* messageReceiver = m_deprecatedGlobalMessageReceivers.get(messageID.messageClass())) { + if (MessageReceiver* messageReceiver = m_globalMessageReceivers.get(decoder.messageReceiverName())) { messageReceiver->didReceiveMessage(connection, messageID, decoder); return true; } @@ -61,7 +62,7 @@ bool MessageReceiverMap::dispatchMessage(Connection* connection, MessageID messa bool MessageReceiverMap::dispatchSyncMessage(Connection* connection, MessageID messageID, MessageDecoder& decoder, OwnPtr<MessageEncoder>& replyEncoder) { - if (MessageReceiver* messageReceiver = m_deprecatedGlobalMessageReceivers.get(messageID.messageClass())) { + if (MessageReceiver* messageReceiver = m_globalMessageReceivers.get(decoder.messageReceiverName())) { messageReceiver->didReceiveSyncMessage(connection, messageID, decoder, replyEncoder); return true; } diff --git a/Source/WebKit2/Platform/CoreIPC/MessageReceiverMap.h b/Source/WebKit2/Platform/CoreIPC/MessageReceiverMap.h index c9240e416..3844ef1b5 100644 --- a/Source/WebKit2/Platform/CoreIPC/MessageReceiverMap.h +++ b/Source/WebKit2/Platform/CoreIPC/MessageReceiverMap.h @@ -27,6 +27,7 @@ #define MessageReceiverMap_h #include "MessageID.h" +#include "StringReference.h" #include <wtf/HashMap.h> #include <wtf/text/CString.h> @@ -42,8 +43,7 @@ public: MessageReceiverMap(); ~MessageReceiverMap(); - // FIXME: Stop using this deprecated function and get rid of it. - void deprecatedAddMessageReceiver(MessageClass, MessageReceiver*); + void addMessageReceiver(StringReference messageReceiverName, MessageReceiver*); void invalidate(); @@ -52,7 +52,7 @@ public: private: // Message receivers that don't require a destination ID. - HashMap<unsigned, MessageReceiver*> m_deprecatedGlobalMessageReceivers; + HashMap<StringReference, MessageReceiver*> m_globalMessageReceivers; }; }; diff --git a/Source/WebKit2/UIProcess/API/efl/ewk_view_loader_client_private.h b/Source/WebKit2/Platform/CoreIPC/StringReference.cpp index 615c019fc..56e8c1a37 100644 --- a/Source/WebKit2/UIProcess/API/efl/ewk_view_loader_client_private.h +++ b/Source/WebKit2/Platform/CoreIPC/StringReference.cpp @@ -1,5 +1,5 @@ /* - * Copyright (C) 2012 Intel Corporation. All rights reserved. + * Copyright (C) 2012 Apple Inc. All rights reserved. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions @@ -23,12 +23,36 @@ * THE POSSIBILITY OF SUCH DAMAGE. */ -#ifndef ewk_view_loader_client_private_h -#define ewk_view_loader_client_private_h +#include "config.h" +#include "StringReference.h" -#include <Evas.h> -#include <WebKit2/WKBase.h> +#include "ArgumentDecoder.h" +#include "ArgumentEncoder.h" +#include "DataReference.h" +#include <wtf/StringHasher.h> -void ewk_view_loader_client_attach(WKPageRef pageRef, Evas_Object* ewkView); +namespace CoreIPC { -#endif // ewk_view_loader_client_private_h +void StringReference::encode(ArgumentEncoder* encoder) const +{ + encoder->encodeVariableLengthByteArray(DataReference(reinterpret_cast<const uint8_t*>(m_data), m_size)); +} + +bool StringReference::decode(ArgumentDecoder* decoder, StringReference& result) +{ + DataReference dataReference; + if (!decoder->decodeVariableLengthByteArray(dataReference)) + return false; + + result.m_data = reinterpret_cast<const char*>(dataReference.data()); + result.m_size = dataReference.size(); + + return true; +} + +unsigned StringReference::Hash::hash(const StringReference& a) +{ + return StringHasher::computeHash(reinterpret_cast<const unsigned char*>(a.data()), a.size()); +} + +} // namespace CoreIPC diff --git a/Source/WebKit2/Platform/CoreIPC/StringReference.h b/Source/WebKit2/Platform/CoreIPC/StringReference.h new file mode 100644 index 000000000..ed482e53f --- /dev/null +++ b/Source/WebKit2/Platform/CoreIPC/StringReference.h @@ -0,0 +1,98 @@ +/* + * Copyright (C) 2012 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 StringReference_h +#define StringReference_h + +#include <wtf/HashTraits.h> + +namespace CoreIPC { + +class ArgumentEncoder; +class ArgumentDecoder; + +class StringReference { +public: + StringReference() + : m_data(0) + , m_size(0) + { + } + + StringReference(const char* data, size_t size) + : m_data(data) + , m_size(size) + { + } + + template<size_t length> + StringReference(const char (&string)[length]) + : m_data(string) + , m_size(length - 1) + { + } + + bool isEmpty() const { return !m_size; } + + size_t size() const { return m_size; } + const char* data() const { return m_data; } + + friend bool operator==(const StringReference& a, const StringReference& b) + { + return a.m_size == b.m_size && !memcmp(a.m_data, b.m_data, a.m_size); + } + + void encode(ArgumentEncoder*) const; + static bool decode(ArgumentDecoder*, StringReference&); + + struct Hash { + static unsigned hash(const StringReference& a); + static bool equal(const StringReference& a, const StringReference& b) { return a == b; } + static const bool safeToCompareToEmptyOrDeleted = true; + }; + +private: + const char* m_data; + size_t m_size; +}; + +} // namespace CoreIPC + +namespace WTF { +template<typename T> struct DefaultHash; + +template<> struct DefaultHash<CoreIPC::StringReference> { + typedef CoreIPC::StringReference::Hash Hash; +}; + +template<> struct HashTraits<CoreIPC::StringReference> : GenericHashTraits<CoreIPC::StringReference> { + static const bool emptyValueIsZero = 0; + static void constructDeletedValue(CoreIPC::StringReference& stringReference) { stringReference = CoreIPC::StringReference(0, std::numeric_limits<size_t>::max()); } + static bool isDeletedValue(const CoreIPC::StringReference& stringReference) { return stringReference.size() == std::numeric_limits<size_t>::max(); } +}; + +} // namespace WTF + +#endif // StringReference_h diff --git a/Source/WebKit2/Platform/CoreIPC/mac/ConnectionMac.cpp b/Source/WebKit2/Platform/CoreIPC/mac/ConnectionMac.cpp index c13b23ba5..17d8ecbc8 100644 --- a/Source/WebKit2/Platform/CoreIPC/mac/ConnectionMac.cpp +++ b/Source/WebKit2/Platform/CoreIPC/mac/ConnectionMac.cpp @@ -112,7 +112,7 @@ bool Connection::open() m_isConnected = true; // Send the initialize message, which contains a send right for the server to use. - OwnPtr<MessageEncoder> encoder = MessageEncoder::create("", "", 0); + OwnPtr<MessageEncoder> encoder = MessageEncoder::create("IPC", "", 0); encoder->encode(MachPort(m_receivePort, MACH_MSG_TYPE_MAKE_SEND)); sendMessage(MessageID(CoreIPCMessage::InitializeConnection), encoder.release()); @@ -131,7 +131,7 @@ bool Connection::open() if (m_exceptionPort) { m_connectionQueue.registerMachPortEventHandler(m_exceptionPort, WorkQueue::MachPortDataAvailable, bind(&Connection::exceptionSourceEventHandler, this)); - OwnPtr<MessageEncoder> encoder = MessageEncoder::create("", "", 0); + OwnPtr<MessageEncoder> encoder = MessageEncoder::create("IPC", "", 0); encoder->encode(MachPort(m_exceptionPort, MACH_MSG_TYPE_MAKE_SEND)); sendMessage(MessageID(CoreIPCMessage::SetExceptionPort), encoder.release()); diff --git a/Source/WebKit2/Platform/mac/SharedMemoryMac.cpp b/Source/WebKit2/Platform/mac/SharedMemoryMac.cpp index 338192240..4019a8d85 100644 --- a/Source/WebKit2/Platform/mac/SharedMemoryMac.cpp +++ b/Source/WebKit2/Platform/mac/SharedMemoryMac.cpp @@ -72,7 +72,7 @@ bool SharedMemory::Handle::decode(CoreIPC::ArgumentDecoder* decoder, Handle& han return false; CoreIPC::MachPort machPort; - if (!decoder->decode(CoreIPC::Out(machPort))) + if (!decoder->decode(machPort)) return false; handle.m_size = size; diff --git a/Source/WebKit2/PlatformEfl.cmake b/Source/WebKit2/PlatformEfl.cmake index 519adfb47..3b062ae11 100644 --- a/Source/WebKit2/PlatformEfl.cmake +++ b/Source/WebKit2/PlatformEfl.cmake @@ -73,13 +73,13 @@ LIST(APPEND WebKit2_SOURCES UIProcess/API/efl/ewk_view.cpp UIProcess/API/efl/ewk_view_find_client.cpp UIProcess/API/efl/ewk_view_form_client.cpp - UIProcess/API/efl/ewk_view_loader_client.cpp UIProcess/API/efl/ewk_view_policy_client.cpp - UIProcess/API/efl/ewk_view_resource_load_client.cpp UIProcess/API/efl/ewk_view_ui_client.cpp UIProcess/cairo/BackingStoreCairo.cpp + UIProcess/efl/PageLoadClientEfl.cpp + UIProcess/efl/ResourceLoadClientEfl.cpp UIProcess/efl/TextCheckerEfl.cpp UIProcess/efl/WebContextEfl.cpp UIProcess/efl/WebFullScreenManagerProxyEfl.cpp diff --git a/Source/WebKit2/Scripts/webkit2/messages.py b/Source/WebKit2/Scripts/webkit2/messages.py index 4584a8531..f1cd50389 100644 --- a/Source/WebKit2/Scripts/webkit2/messages.py +++ b/Source/WebKit2/Scripts/webkit2/messages.py @@ -129,8 +129,8 @@ def message_to_struct_declaration(message): result.append('struct %s : %s' % (message.name, base_class(message))) result.append(' {\n') result.append(' static const Kind messageID = %s;\n' % message.id()) - result.append(' static const char* receiverName() { return messageReceiverName(); }\n') - result.append(' static const char* name() { return "%s"; }\n' % message.name) + result.append(' static CoreIPC::StringReference receiverName() { return messageReceiverName(); }\n') + result.append(' static CoreIPC::StringReference name() { return CoreIPC::StringReference("%s"); }\n' % message.name) result.append('\n') if message.reply_parameters != None: if message.has_attribute(DELAYED_ATTRIBUTE): @@ -229,6 +229,7 @@ def forward_declarations_and_headers(receiver): '"Arguments.h"', '"MessageEncoder.h"', '"MessageID.h"', + '"StringReference.h"', ]) for message in receiver.messages: @@ -284,9 +285,9 @@ def generate_messages_header(file): result.append('namespace Messages {\nnamespace %s {\n' % receiver.name) result.append('\n') - result.append('static inline const char* messageReceiverName()\n') + result.append('static inline CoreIPC::StringReference messageReceiverName()\n') result.append('{\n') - result.append(' return "%s";\n' % receiver.name) + result.append(' return CoreIPC::StringReference("%s");\n' % receiver.name) result.append('}\n') result.append('\n') diff --git a/Source/WebKit2/Scripts/webkit2/messages_unittest.py b/Source/WebKit2/Scripts/webkit2/messages_unittest.py index e8d190d45..f4fa1eee8 100644 --- a/Source/WebKit2/Scripts/webkit2/messages_unittest.py +++ b/Source/WebKit2/Scripts/webkit2/messages_unittest.py @@ -318,6 +318,7 @@ _expected_header = """/* #include "MessageEncoder.h" #include "MessageID.h" #include "Plugin.h" +#include "StringReference.h" #include <WebCore/KeyboardEvent.h> #include <WebCore/PluginData.h> #include <wtf/ThreadSafeRefCounted.h> @@ -341,9 +342,9 @@ namespace WebKit { namespace Messages { namespace WebPage { -static inline const char* messageReceiverName() +static inline CoreIPC::StringReference messageReceiverName() { - return "WebPage"; + return CoreIPC::StringReference("WebPage"); } enum Kind { @@ -379,8 +380,8 @@ enum Kind { struct LoadURL : CoreIPC::Arguments1<const WTF::String&> { static const Kind messageID = LoadURLID; - static const char* receiverName() { return messageReceiverName(); } - static const char* name() { return "LoadURL"; } + static CoreIPC::StringReference receiverName() { return messageReceiverName(); } + static CoreIPC::StringReference name() { return CoreIPC::StringReference("LoadURL"); } typedef CoreIPC::Arguments1<const WTF::String&> DecodeType; explicit LoadURL(const WTF::String& url) @@ -392,8 +393,8 @@ struct LoadURL : CoreIPC::Arguments1<const WTF::String&> { #if ENABLE(TOUCH_EVENTS) struct TouchEvent : CoreIPC::Arguments1<const WebKit::WebTouchEvent&> { static const Kind messageID = TouchEventID; - static const char* receiverName() { return messageReceiverName(); } - static const char* name() { return "TouchEvent"; } + static CoreIPC::StringReference receiverName() { return messageReceiverName(); } + static CoreIPC::StringReference name() { return CoreIPC::StringReference("TouchEvent"); } typedef CoreIPC::Arguments1<const WebKit::WebTouchEvent&> DecodeType; explicit TouchEvent(const WebKit::WebTouchEvent& event) @@ -405,8 +406,8 @@ struct TouchEvent : CoreIPC::Arguments1<const WebKit::WebTouchEvent&> { struct DidReceivePolicyDecision : CoreIPC::Arguments3<uint64_t, uint64_t, uint32_t> { static const Kind messageID = DidReceivePolicyDecisionID; - static const char* receiverName() { return messageReceiverName(); } - static const char* name() { return "DidReceivePolicyDecision"; } + static CoreIPC::StringReference receiverName() { return messageReceiverName(); } + static CoreIPC::StringReference name() { return CoreIPC::StringReference("DidReceivePolicyDecision"); } typedef CoreIPC::Arguments3<uint64_t, uint64_t, uint32_t> DecodeType; DidReceivePolicyDecision(uint64_t frameID, uint64_t listenerID, uint32_t policyAction) @@ -417,16 +418,16 @@ struct DidReceivePolicyDecision : CoreIPC::Arguments3<uint64_t, uint64_t, uint32 struct Close : CoreIPC::Arguments0 { static const Kind messageID = CloseID; - static const char* receiverName() { return messageReceiverName(); } - static const char* name() { return "Close"; } + static CoreIPC::StringReference receiverName() { return messageReceiverName(); } + static CoreIPC::StringReference name() { return CoreIPC::StringReference("Close"); } typedef CoreIPC::Arguments0 DecodeType; }; struct PreferencesDidChange : CoreIPC::Arguments1<const WebKit::WebPreferencesStore&> { static const Kind messageID = PreferencesDidChangeID; - static const char* receiverName() { return messageReceiverName(); } - static const char* name() { return "PreferencesDidChange"; } + static CoreIPC::StringReference receiverName() { return messageReceiverName(); } + static CoreIPC::StringReference name() { return CoreIPC::StringReference("PreferencesDidChange"); } typedef CoreIPC::Arguments1<const WebKit::WebPreferencesStore&> DecodeType; explicit PreferencesDidChange(const WebKit::WebPreferencesStore& store) @@ -437,8 +438,8 @@ struct PreferencesDidChange : CoreIPC::Arguments1<const WebKit::WebPreferencesSt struct SendDoubleAndFloat : CoreIPC::Arguments2<double, float> { static const Kind messageID = SendDoubleAndFloatID; - static const char* receiverName() { return messageReceiverName(); } - static const char* name() { return "SendDoubleAndFloat"; } + static CoreIPC::StringReference receiverName() { return messageReceiverName(); } + static CoreIPC::StringReference name() { return CoreIPC::StringReference("SendDoubleAndFloat"); } typedef CoreIPC::Arguments2<double, float> DecodeType; SendDoubleAndFloat(double d, float f) @@ -449,8 +450,8 @@ struct SendDoubleAndFloat : CoreIPC::Arguments2<double, float> { struct SendInts : CoreIPC::Arguments2<const Vector<uint64_t>&, const Vector<Vector<uint64_t> >&> { static const Kind messageID = SendIntsID; - static const char* receiverName() { return messageReceiverName(); } - static const char* name() { return "SendInts"; } + static CoreIPC::StringReference receiverName() { return messageReceiverName(); } + static CoreIPC::StringReference name() { return CoreIPC::StringReference("SendInts"); } typedef CoreIPC::Arguments2<const Vector<uint64_t>&, const Vector<Vector<uint64_t> >&> DecodeType; SendInts(const Vector<uint64_t>& ints, const Vector<Vector<uint64_t> >& intVectors) @@ -461,8 +462,8 @@ struct SendInts : CoreIPC::Arguments2<const Vector<uint64_t>&, const Vector<Vect struct CreatePlugin : CoreIPC::Arguments2<uint64_t, const WebKit::Plugin::Parameters&> { static const Kind messageID = CreatePluginID; - static const char* receiverName() { return messageReceiverName(); } - static const char* name() { return "CreatePlugin"; } + static CoreIPC::StringReference receiverName() { return messageReceiverName(); } + static CoreIPC::StringReference name() { return CoreIPC::StringReference("CreatePlugin"); } typedef CoreIPC::Arguments1<bool&> Reply; typedef CoreIPC::Arguments2<uint64_t, const WebKit::Plugin::Parameters&> DecodeType; @@ -474,8 +475,8 @@ struct CreatePlugin : CoreIPC::Arguments2<uint64_t, const WebKit::Plugin::Parame struct RunJavaScriptAlert : CoreIPC::Arguments2<uint64_t, const WTF::String&> { static const Kind messageID = RunJavaScriptAlertID; - static const char* receiverName() { return messageReceiverName(); } - static const char* name() { return "RunJavaScriptAlert"; } + static CoreIPC::StringReference receiverName() { return messageReceiverName(); } + static CoreIPC::StringReference name() { return CoreIPC::StringReference("RunJavaScriptAlert"); } typedef CoreIPC::Arguments0 Reply; typedef CoreIPC::Arguments2<uint64_t, const WTF::String&> DecodeType; @@ -487,8 +488,8 @@ struct RunJavaScriptAlert : CoreIPC::Arguments2<uint64_t, const WTF::String&> { struct GetPlugins : CoreIPC::Arguments1<bool> { static const Kind messageID = GetPluginsID; - static const char* receiverName() { return messageReceiverName(); } - static const char* name() { return "GetPlugins"; } + static CoreIPC::StringReference receiverName() { return messageReceiverName(); } + static CoreIPC::StringReference name() { return CoreIPC::StringReference("GetPlugins"); } typedef CoreIPC::Arguments1<Vector<WebCore::PluginInfo>&> Reply; typedef CoreIPC::Arguments1<bool> DecodeType; @@ -500,8 +501,8 @@ struct GetPlugins : CoreIPC::Arguments1<bool> { struct GetPluginProcessConnection : CoreIPC::Arguments1<const WTF::String&> { static const Kind messageID = GetPluginProcessConnectionID; - static const char* receiverName() { return messageReceiverName(); } - static const char* name() { return "GetPluginProcessConnection"; } + static CoreIPC::StringReference receiverName() { return messageReceiverName(); } + static CoreIPC::StringReference name() { return CoreIPC::StringReference("GetPluginProcessConnection"); } struct DelayedReply : public ThreadSafeRefCounted<DelayedReply> { DelayedReply(PassRefPtr<CoreIPC::Connection>, PassOwnPtr<CoreIPC::MessageEncoder>); @@ -524,8 +525,8 @@ struct GetPluginProcessConnection : CoreIPC::Arguments1<const WTF::String&> { struct TestMultipleAttributes : CoreIPC::Arguments0 { static const Kind messageID = TestMultipleAttributesID; - static const char* receiverName() { return messageReceiverName(); } - static const char* name() { return "TestMultipleAttributes"; } + static CoreIPC::StringReference receiverName() { return messageReceiverName(); } + static CoreIPC::StringReference name() { return CoreIPC::StringReference("TestMultipleAttributes"); } struct DelayedReply : public ThreadSafeRefCounted<DelayedReply> { DelayedReply(PassRefPtr<CoreIPC::Connection>, PassOwnPtr<CoreIPC::MessageEncoder>); @@ -544,8 +545,8 @@ struct TestMultipleAttributes : CoreIPC::Arguments0 { struct TestConnectionQueue : CoreIPC::Arguments1<uint64_t> { static const Kind messageID = TestConnectionQueueID; - static const char* receiverName() { return messageReceiverName(); } - static const char* name() { return "TestConnectionQueue"; } + static CoreIPC::StringReference receiverName() { return messageReceiverName(); } + static CoreIPC::StringReference name() { return CoreIPC::StringReference("TestConnectionQueue"); } typedef CoreIPC::Arguments1<uint64_t> DecodeType; explicit TestConnectionQueue(uint64_t pluginID) @@ -556,8 +557,8 @@ struct TestConnectionQueue : CoreIPC::Arguments1<uint64_t> { struct TestParameterAttributes : CoreIPC::Arguments3<uint64_t, double, double> { static const Kind messageID = TestParameterAttributesID; - static const char* receiverName() { return messageReceiverName(); } - static const char* name() { return "TestParameterAttributes"; } + static CoreIPC::StringReference receiverName() { return messageReceiverName(); } + static CoreIPC::StringReference name() { return CoreIPC::StringReference("TestParameterAttributes"); } typedef CoreIPC::Arguments3<uint64_t, double, double> DecodeType; TestParameterAttributes(uint64_t foo, double bar, double baz) @@ -569,8 +570,8 @@ struct TestParameterAttributes : CoreIPC::Arguments3<uint64_t, double, double> { #if PLATFORM(MAC) struct DidCreateWebProcessConnection : CoreIPC::Arguments1<const CoreIPC::MachPort&> { static const Kind messageID = DidCreateWebProcessConnectionID; - static const char* receiverName() { return messageReceiverName(); } - static const char* name() { return "DidCreateWebProcessConnection"; } + static CoreIPC::StringReference receiverName() { return messageReceiverName(); } + static CoreIPC::StringReference name() { return CoreIPC::StringReference("DidCreateWebProcessConnection"); } typedef CoreIPC::Arguments1<const CoreIPC::MachPort&> DecodeType; explicit DidCreateWebProcessConnection(const CoreIPC::MachPort& connectionIdentifier) @@ -583,8 +584,8 @@ struct DidCreateWebProcessConnection : CoreIPC::Arguments1<const CoreIPC::MachPo #if PLATFORM(MAC) struct InterpretKeyEvent : CoreIPC::Arguments1<uint32_t> { static const Kind messageID = InterpretKeyEventID; - static const char* receiverName() { return messageReceiverName(); } - static const char* name() { return "InterpretKeyEvent"; } + static CoreIPC::StringReference receiverName() { return messageReceiverName(); } + static CoreIPC::StringReference name() { return CoreIPC::StringReference("InterpretKeyEvent"); } typedef CoreIPC::Arguments1<Vector<WebCore::KeypressCommand>&> Reply; typedef CoreIPC::Arguments1<uint32_t> DecodeType; @@ -598,8 +599,8 @@ struct InterpretKeyEvent : CoreIPC::Arguments1<uint32_t> { #if ENABLE(DEPRECATED_FEATURE) struct DeprecatedOperation : CoreIPC::Arguments1<const CoreIPC::DummyType&> { static const Kind messageID = DeprecatedOperationID; - static const char* receiverName() { return messageReceiverName(); } - static const char* name() { return "DeprecatedOperation"; } + static CoreIPC::StringReference receiverName() { return messageReceiverName(); } + static CoreIPC::StringReference name() { return CoreIPC::StringReference("DeprecatedOperation"); } typedef CoreIPC::Arguments1<const CoreIPC::DummyType&> DecodeType; explicit DeprecatedOperation(const CoreIPC::DummyType& dummy) @@ -612,8 +613,8 @@ struct DeprecatedOperation : CoreIPC::Arguments1<const CoreIPC::DummyType&> { #if ENABLE(EXPERIMENTAL_FEATURE) struct ExperimentalOperation : CoreIPC::Arguments1<const CoreIPC::DummyType&> { static const Kind messageID = ExperimentalOperationID; - static const char* receiverName() { return messageReceiverName(); } - static const char* name() { return "ExperimentalOperation"; } + static CoreIPC::StringReference receiverName() { return messageReceiverName(); } + static CoreIPC::StringReference name() { return CoreIPC::StringReference("ExperimentalOperation"); } typedef CoreIPC::Arguments1<const CoreIPC::DummyType&> DecodeType; explicit ExperimentalOperation(const CoreIPC::DummyType& dummy) diff --git a/Source/WebKit2/Shared/CoreIPCSupport/WebContextMessageKinds.h b/Source/WebKit2/Shared/CoreIPCSupport/WebContextMessageKinds.h index e8194b587..631d053eb 100644 --- a/Source/WebKit2/Shared/CoreIPCSupport/WebContextMessageKinds.h +++ b/Source/WebKit2/Shared/CoreIPCSupport/WebContextMessageKinds.h @@ -29,6 +29,7 @@ // Messages sent from the injected bundle to the WebContext. #include "MessageID.h" +#include "StringReference.h" namespace WebContextLegacyMessage { @@ -43,6 +44,10 @@ namespace CoreIPC { template<> struct MessageKindTraits<WebContextLegacyMessage::Kind> { static const MessageClass messageClass = MessageClassWebContextLegacy; + static StringReference messageReceiverName() + { + return StringReference("WebContextLegacyMessage"); + } }; } diff --git a/Source/WebKit2/Shared/Plugins/NPIdentifierData.cpp b/Source/WebKit2/Shared/Plugins/NPIdentifierData.cpp index 747172504..ff2bef140 100644 --- a/Source/WebKit2/Shared/Plugins/NPIdentifierData.cpp +++ b/Source/WebKit2/Shared/Plugins/NPIdentifierData.cpp @@ -73,7 +73,7 @@ void NPIdentifierData::encode(CoreIPC::ArgumentEncoder* encoder) const if (m_isString) encoder->encode(m_string); else - encoder->encode(static_cast<int32_t>(m_number)); + encoder->encode(m_number); } bool NPIdentifierData::decode(CoreIPC::ArgumentDecoder* decoder, NPIdentifierData& result) @@ -84,7 +84,7 @@ bool NPIdentifierData::decode(CoreIPC::ArgumentDecoder* decoder, NPIdentifierDat if (result.m_isString) return decoder->decode(result.m_string); - return decoder->decode(static_cast<int32_t>(result.m_number)); + return decoder->decode(result.m_number); } } // namespace WebKit diff --git a/Source/WebKit2/Shared/PrintInfo.cpp b/Source/WebKit2/Shared/PrintInfo.cpp index ce11935ad..107884a07 100644 --- a/Source/WebKit2/Shared/PrintInfo.cpp +++ b/Source/WebKit2/Shared/PrintInfo.cpp @@ -45,7 +45,10 @@ PrintInfo::PrintInfo() void PrintInfo::encode(CoreIPC::ArgumentEncoder* encoder) const { - encoder->encode(CoreIPC::In(pageSetupScaleFactor, availablePaperWidth, availablePaperHeight)); + encoder->encode(pageSetupScaleFactor); + encoder->encode(availablePaperWidth); + encoder->encode(availablePaperHeight); + #if PLATFORM(GTK) CoreIPC::encode(encoder, printSettings.get()); CoreIPC::encode(encoder, pageSetup.get()); @@ -54,7 +57,11 @@ void PrintInfo::encode(CoreIPC::ArgumentEncoder* encoder) const bool PrintInfo::decode(CoreIPC::ArgumentDecoder* decoder, PrintInfo& info) { - if (!decoder->decode(CoreIPC::Out(info.pageSetupScaleFactor, info.availablePaperWidth, info.availablePaperHeight))) + if (!decoder->decode(info.pageSetupScaleFactor)) + return false; + if (!decoder->decode(info.availablePaperWidth)) + return false; + if (!decoder->decode(info.availablePaperHeight)) return false; #if PLATFORM(GTK) diff --git a/Source/WebKit2/Shared/WebBatteryStatus.cpp b/Source/WebKit2/Shared/WebBatteryStatus.cpp index c8d806da9..30a5e59a1 100644 --- a/Source/WebKit2/Shared/WebBatteryStatus.cpp +++ b/Source/WebKit2/Shared/WebBatteryStatus.cpp @@ -47,12 +47,24 @@ WebBatteryStatus::~WebBatteryStatus() void WebBatteryStatus::Data::encode(CoreIPC::ArgumentEncoder* encoder) const { - encoder->encode(CoreIPC::In(isCharging, chargingTime, dischargingTime, level)); + encoder->encode(isCharging); + encoder->encode(chargingTime); + encoder->encode(dischargingTime); + encoder->encode(level); } -bool WebBatteryStatus::Data::decode(CoreIPC::ArgumentDecoder* decoder, Data& data) +bool WebBatteryStatus::Data::decode(CoreIPC::ArgumentDecoder* decoder, Data& result) { - return decoder->decode(CoreIPC::Out(data.isCharging, data.chargingTime, data.dischargingTime, data.level)); + if (!decoder->decode(result.isCharging)) + return false; + if (!decoder->decode(result.chargingTime)) + return false; + if (!decoder->decode(result.dischargingTime)) + return false; + if (!decoder->decode(result.level)) + return false; + + return true; } } // namespace WebKit diff --git a/Source/WebKit2/Shared/WebContextMenuItemData.cpp b/Source/WebKit2/Shared/WebContextMenuItemData.cpp index 1eb1c495b..901ce9c47 100644 --- a/Source/WebKit2/Shared/WebContextMenuItemData.cpp +++ b/Source/WebKit2/Shared/WebContextMenuItemData.cpp @@ -106,29 +106,48 @@ void WebContextMenuItemData::setUserData(APIObject* userData) void WebContextMenuItemData::encode(CoreIPC::ArgumentEncoder* encoder) const { - encoder->encode(CoreIPC::In(static_cast<uint32_t>(m_type), static_cast<uint32_t>(m_action), m_title, m_checked, m_enabled, m_submenu)); + encoder->encodeEnum(m_type); + encoder->encodeEnum(m_action); + encoder->encode(m_title); + encoder->encode(m_checked); + encoder->encode(m_enabled); + encoder->encode(m_submenu); } bool WebContextMenuItemData::decode(CoreIPC::ArgumentDecoder* decoder, WebContextMenuItemData& item) { - uint32_t type; - uint32_t action; + WebCore::ContextMenuItemType type; + if (!decoder->decodeEnum(type)) + return false; + + WebCore::ContextMenuAction action; + if (!decoder->decodeEnum(action)) + return false; + String title; + if (!decoder->decode(title)) + return false; + bool checked; + if (!decoder->decode(checked)) + return false; + bool enabled; - Vector<WebContextMenuItemData> submenu; + if (!decoder->decode(enabled)) + return false; - if (!decoder->decode(CoreIPC::Out(type, action, title, checked, enabled, submenu))) + Vector<WebContextMenuItemData> submenu; + if (!decoder->decode(submenu)) return false; switch (type) { case WebCore::ActionType: case WebCore::SeparatorType: case WebCore::CheckableActionType: - item = WebContextMenuItemData(static_cast<WebCore::ContextMenuItemType>(type), static_cast<WebCore::ContextMenuAction>(action), title, enabled, checked); + item = WebContextMenuItemData(type, action, title, enabled, checked); break; case WebCore::SubmenuType: - item = WebContextMenuItemData(static_cast<WebCore::ContextMenuAction>(action), title, enabled, submenu); + item = WebContextMenuItemData(action, title, enabled, submenu); break; default: ASSERT_NOT_REACHED(); diff --git a/Source/WebKit2/Shared/WebEvent.cpp b/Source/WebKit2/Shared/WebEvent.cpp index 8edc3fd35..70bffa2c1 100644 --- a/Source/WebKit2/Shared/WebEvent.cpp +++ b/Source/WebKit2/Shared/WebEvent.cpp @@ -48,12 +48,20 @@ WebEvent::WebEvent(Type type, Modifiers modifiers, double timestamp) void WebEvent::encode(CoreIPC::ArgumentEncoder* encoder) const { - encoder->encode(CoreIPC::In(m_type, m_modifiers, m_timestamp)); + encoder->encode(m_type); + encoder->encode(m_modifiers); + encoder->encode(m_timestamp); } -bool WebEvent::decode(CoreIPC::ArgumentDecoder* decoder, WebEvent& t) +bool WebEvent::decode(CoreIPC::ArgumentDecoder* decoder, WebEvent& result) { - return decoder->decode(CoreIPC::Out(t.m_type, t.m_modifiers, t.m_timestamp)); + if (!decoder->decode(result.m_type)) + return false; + if (!decoder->decode(result.m_modifiers)) + return false; + if (!decoder->decode(result.m_timestamp)) + return false; + return true; } } // namespace WebKit diff --git a/Source/WebKit2/Shared/WebGeolocationPosition.cpp b/Source/WebKit2/Shared/WebGeolocationPosition.cpp index c9e36fa37..77d524cf4 100644 --- a/Source/WebKit2/Shared/WebGeolocationPosition.cpp +++ b/Source/WebKit2/Shared/WebGeolocationPosition.cpp @@ -53,15 +53,12 @@ WebGeolocationPosition::~WebGeolocationPosition() void WebGeolocationPosition::Data::encode(CoreIPC::ArgumentEncoder* encoder) const { - encoder->encode(CoreIPC::In(timestamp, latitude, longitude, accuracy, canProvideAltitude, altitude, canProvideAltitudeAccuracy, altitudeAccuracy, canProvideHeading, heading)); - encoder->encode(CoreIPC::In(canProvideSpeed, speed)); + CoreIPC::SimpleArgumentCoder<WebGeolocationPosition::Data>::encode(encoder, *this); } bool WebGeolocationPosition::Data::decode(CoreIPC::ArgumentDecoder* decoder, Data& data) { - if (!decoder->decode(CoreIPC::Out(data.timestamp, data.latitude, data.longitude, data.accuracy, data.canProvideAltitude, data.altitude, data.canProvideAltitudeAccuracy, data.altitudeAccuracy, data.canProvideHeading, data.heading))) - return false; - return decoder->decode(CoreIPC::Out(data.canProvideSpeed, data.speed)); + return CoreIPC::SimpleArgumentCoder<WebGeolocationPosition::Data>::decode(decoder, data); } } // namespace WebKit diff --git a/Source/WebKit2/Shared/WebMouseEvent.cpp b/Source/WebKit2/Shared/WebMouseEvent.cpp index 7aa7dff23..32e6ac1f3 100644 --- a/Source/WebKit2/Shared/WebMouseEvent.cpp +++ b/Source/WebKit2/Shared/WebMouseEvent.cpp @@ -82,25 +82,44 @@ void WebMouseEvent::encode(CoreIPC::ArgumentEncoder* encoder) const { WebEvent::encode(encoder); + encoder->encode(m_button); + encoder->encode(m_position); + encoder->encode(m_globalPosition); + encoder->encode(m_deltaX); + encoder->encode(m_deltaY); + encoder->encode(m_deltaZ); + encoder->encode(m_clickCount); + #if PLATFORM(WIN) - // Include m_didActivateWebView on Windows. - encoder->encode(CoreIPC::In(m_button, m_position, m_globalPosition, m_deltaX, m_deltaY, m_deltaZ, m_clickCount, m_didActivateWebView)); -#else - encoder->encode(CoreIPC::In(m_button, m_position, m_globalPosition, m_deltaX, m_deltaY, m_deltaZ, m_clickCount)); + encoder->encode(m_didActivateWebView); #endif } -bool WebMouseEvent::decode(CoreIPC::ArgumentDecoder* decoder, WebMouseEvent& t) +bool WebMouseEvent::decode(CoreIPC::ArgumentDecoder* decoder, WebMouseEvent& result) { - if (!WebEvent::decode(decoder, t)) + if (!WebEvent::decode(decoder, result)) return false; + if (!decoder->decode(result.m_button)) + return false; + if (!decoder->decode(result.m_position)) + return false; + if (!decoder->decode(result.m_globalPosition)) + return false; + if (!decoder->decode(result.m_deltaX)) + return false; + if (!decoder->decode(result.m_deltaY)) + return false; + if (!decoder->decode(result.m_deltaZ)) + return false; + if (!decoder->decode(result.m_clickCount)) + return false; #if PLATFORM(WIN) - // Include m_didActivateWebView on Windows. - return decoder->decode(CoreIPC::Out(t.m_button, t.m_position, t.m_globalPosition, t.m_deltaX, t.m_deltaY, t.m_deltaZ, t.m_clickCount, t.m_didActivateWebView)); -#else - return decoder->decode(CoreIPC::Out(t.m_button, t.m_position, t.m_globalPosition, t.m_deltaX, t.m_deltaY, t.m_deltaZ, t.m_clickCount)); + if (!decoder->decode(result.m_didActivateWebView)) + return false; #endif + + return true; } bool WebMouseEvent::isMouseEventType(Type type) diff --git a/Source/WebKit2/Shared/WebNetworkInfo.cpp b/Source/WebKit2/Shared/WebNetworkInfo.cpp index cc31bdccb..a2852341a 100644 --- a/Source/WebKit2/Shared/WebNetworkInfo.cpp +++ b/Source/WebKit2/Shared/WebNetworkInfo.cpp @@ -45,12 +45,18 @@ WebNetworkInfo::~WebNetworkInfo() void WebNetworkInfo::Data::encode(CoreIPC::ArgumentEncoder* encoder) const { - encoder->encode(CoreIPC::In(bandwidth, metered)); + encoder->encode(bandwidth); + encoder->encode(metered); } -bool WebNetworkInfo::Data::decode(CoreIPC::ArgumentDecoder* decoder, Data& data) +bool WebNetworkInfo::Data::decode(CoreIPC::ArgumentDecoder* decoder, Data& result) { - return decoder->decode(CoreIPC::Out(data.bandwidth, data.metered)); + if (!decoder->decode(result.bandwidth)) + return false; + if (!decoder->decode(result.metered)) + return false; + + return true; } } // namespace WebKit diff --git a/Source/WebKit2/Shared/WebPlatformTouchPoint.cpp b/Source/WebKit2/Shared/WebPlatformTouchPoint.cpp index d86fc7aef..39026e0f5 100644 --- a/Source/WebKit2/Shared/WebPlatformTouchPoint.cpp +++ b/Source/WebKit2/Shared/WebPlatformTouchPoint.cpp @@ -59,12 +59,33 @@ WebPlatformTouchPoint::WebPlatformTouchPoint(unsigned id, TouchPointState state, void WebPlatformTouchPoint::encode(CoreIPC::ArgumentEncoder* encoder) const { - encoder->encode(CoreIPC::In(m_id, m_state, m_screenPosition, m_position, m_radius, m_rotationAngle, m_force)); + encoder->encode(m_id); + encoder->encode(m_state); + encoder->encode(m_screenPosition); + encoder->encode(m_position); + encoder->encode(m_radius); + encoder->encode(m_rotationAngle); + encoder->encode(m_force); } -bool WebPlatformTouchPoint::decode(CoreIPC::ArgumentDecoder* decoder, WebPlatformTouchPoint& t) +bool WebPlatformTouchPoint::decode(CoreIPC::ArgumentDecoder* decoder, WebPlatformTouchPoint& result) { - return decoder->decode(CoreIPC::Out(t.m_id, t.m_state, t.m_screenPosition, t.m_position, t.m_radius, t.m_rotationAngle, t.m_force)); + if (!decoder->decode(result.m_id)) + return false; + if (!decoder->decode(result.m_state)) + return false; + if (!decoder->decode(result.m_screenPosition)) + return false; + if (!decoder->decode(result.m_position)) + return false; + if (!decoder->decode(result.m_radius)) + return false; + if (!decoder->decode(result.m_rotationAngle)) + return false; + if (!decoder->decode(result.m_force)) + return false; + + return true; } } // namespace WebKit diff --git a/Source/WebKit2/Shared/WebPopupItem.cpp b/Source/WebKit2/Shared/WebPopupItem.cpp index c215f3568..07a29e416 100644 --- a/Source/WebKit2/Shared/WebPopupItem.cpp +++ b/Source/WebKit2/Shared/WebPopupItem.cpp @@ -68,29 +68,56 @@ WebPopupItem::WebPopupItem(Type type, const String& text, TextDirection textDire void WebPopupItem::encode(CoreIPC::ArgumentEncoder* encoder) const { - encoder->encode(CoreIPC::In(static_cast<uint32_t>(m_type), m_text, static_cast<uint64_t>(m_textDirection), m_hasTextDirectionOverride, m_toolTip, m_accessibilityText, m_isEnabled, m_isLabel)); - encoder->encode(CoreIPC::In(m_isSelected)); + encoder->encodeEnum(m_type); + encoder->encode(m_text); + encoder->encodeEnum(m_textDirection); + encoder->encode(m_hasTextDirectionOverride); + encoder->encode(m_toolTip); + encoder->encode(m_accessibilityText); + encoder->encode(m_isEnabled); + encoder->encode(m_isLabel); + encoder->encode(m_isSelected); } bool WebPopupItem::decode(CoreIPC::ArgumentDecoder* decoder, WebPopupItem& item) { - uint32_t type; + Type type; + if (!decoder->decodeEnum(type)) + return false; + String text; - uint64_t textDirection; + if (!decoder->decode(text)) + return false; + + TextDirection textDirection; + if (!decoder->decodeEnum(textDirection)) + return false; + bool hasTextDirectionOverride; + if (!decoder->decode(hasTextDirectionOverride)) + return false; + String toolTip; + if (!decoder->decode(toolTip)) + return false; + String accessibilityText; + if (!decoder->decode(accessibilityText)) + return false; + bool isEnabled; - bool isLabel; - bool isSelected; + if (!decoder->decode(isEnabled)) + return false; - if (!decoder->decode(CoreIPC::Out(type, text, textDirection, hasTextDirectionOverride, toolTip, accessibilityText, isEnabled, isLabel))) + bool isLabel; + if (!decoder->decode(isLabel)) return false; - if (!decoder->decode(CoreIPC::Out(isSelected))) + bool isSelected; + if (!decoder->decode(isSelected)) return false; - item = WebPopupItem(static_cast<Type>(type), text, static_cast<TextDirection>(textDirection), hasTextDirectionOverride, toolTip, accessibilityText, isEnabled, isLabel, isSelected); + item = WebPopupItem(type, text, textDirection, hasTextDirectionOverride, toolTip, accessibilityText, isEnabled, isLabel, isSelected); return true; } diff --git a/Source/WebKit2/Shared/WebTouchEvent.cpp b/Source/WebKit2/Shared/WebTouchEvent.cpp index 05d7cd254..7213c78db 100644 --- a/Source/WebKit2/Shared/WebTouchEvent.cpp +++ b/Source/WebKit2/Shared/WebTouchEvent.cpp @@ -44,15 +44,18 @@ void WebTouchEvent::encode(CoreIPC::ArgumentEncoder* encoder) const { WebEvent::encode(encoder); - encoder->encode(CoreIPC::In(m_touchPoints)); + encoder->encode(m_touchPoints); } -bool WebTouchEvent::decode(CoreIPC::ArgumentDecoder* decoder, WebTouchEvent& t) +bool WebTouchEvent::decode(CoreIPC::ArgumentDecoder* decoder, WebTouchEvent& result) { - if (!WebEvent::decode(decoder, t)) + if (!WebEvent::decode(decoder, result)) return false; - return decoder->decode(CoreIPC::Out(t.m_touchPoints)); + if (!decoder->decode(result.m_touchPoints)) + return false; + + return true; } bool WebTouchEvent::isTouchEventType(Type type) diff --git a/Source/WebKit2/Target.pri b/Source/WebKit2/Target.pri index 6c99c85b6..aa23748d2 100644 --- a/Source/WebKit2/Target.pri +++ b/Source/WebKit2/Target.pri @@ -31,6 +31,7 @@ HEADERS += \ Platform/CoreIPC/MessageReceiver.h \ Platform/CoreIPC/MessageReceiverMap.h \ Platform/CoreIPC/MessageSender.h \ + Platform/CoreIPC/StringReference.h \ Platform/Logging.h \ Platform/Module.h \ Platform/PlatformProcessIdentifier.h \ @@ -392,6 +393,7 @@ SOURCES += \ Platform/CoreIPC/MessageDecoder.cpp \ Platform/CoreIPC/MessageEncoder.cpp \ Platform/CoreIPC/MessageReceiverMap.cpp \ + Platform/CoreIPC/StringReference.cpp \ Platform/Logging.cpp \ Platform/Module.cpp \ Platform/WorkQueue.cpp \ diff --git a/Source/WebKit2/UIProcess/API/efl/ewk_form_submission_request.cpp b/Source/WebKit2/UIProcess/API/efl/ewk_form_submission_request.cpp index 76de21a4f..cecad7652 100644 --- a/Source/WebKit2/UIProcess/API/efl/ewk_form_submission_request.cpp +++ b/Source/WebKit2/UIProcess/API/efl/ewk_form_submission_request.cpp @@ -51,7 +51,7 @@ Ewk_Form_Submission_Request::~Ewk_Form_Submission_Request() String Ewk_Form_Submission_Request::fieldValue(const String& fieldName) const { ASSERT(fieldName); - WKRetainPtr<WKStringRef> wkFieldName = toCopiedAPI(fieldName); + WKRetainPtr<WKStringRef> wkFieldName = adoptWK(toCopiedAPI(fieldName)); WKStringRef wkValue = static_cast<WKStringRef>(WKDictionaryGetItemForKey(m_wkValues.get(), wkFieldName.get())); return wkValue ? toImpl(wkValue)->string() : String(); diff --git a/Source/WebKit2/UIProcess/API/efl/ewk_view.cpp b/Source/WebKit2/UIProcess/API/efl/ewk_view.cpp index d8608aa48..fc955ec82 100644 --- a/Source/WebKit2/UIProcess/API/efl/ewk_view.cpp +++ b/Source/WebKit2/UIProcess/API/efl/ewk_view.cpp @@ -25,7 +25,9 @@ #include "NativeWebMouseEvent.h" #include "NativeWebWheelEvent.h" #include "PageClientImpl.h" +#include "PageLoadClientEfl.h" #include "RefPtrEfl.h" +#include "ResourceLoadClientEfl.h" #include "WKAPICast.h" #include "WKColorPickerResultListener.h" #include "WKEinaSharedString.h" @@ -51,10 +53,8 @@ #include "ewk_settings_private.h" #include "ewk_view_find_client_private.h" #include "ewk_view_form_client_private.h" -#include "ewk_view_loader_client_private.h" #include "ewk_view_policy_client_private.h" #include "ewk_view_private.h" -#include "ewk_view_resource_load_client_private.h" #include "ewk_view_ui_client_private.h" #include <Ecore_Evas.h> #include <Edje.h> @@ -86,7 +86,6 @@ static const char EWK_VIEW_TYPE_STR[] = "EWK2_View"; static const int defaultCursorSize = 16; -typedef HashMap< uint64_t, RefPtr<Ewk_Resource> > LoadingResourcesMap; static void _ewk_view_on_favicon_changed(const char* pageURL, void* eventInfo); typedef HashMap<const WebPageProxy*, const Evas_Object*> PageViewMap; @@ -119,6 +118,8 @@ struct Ewk_View_Private_Data { OwnPtr<PageViewportControllerClientEfl> pageViewportControllerClient; #endif RefPtr<WebPageProxy> pageProxy; + OwnPtr<PageLoadClientEfl> pageLoadClient; + OwnPtr<ResourceLoadClientEfl> resourceLoadClient; WKEinaSharedString url; WKEinaSharedString title; @@ -127,7 +128,6 @@ struct Ewk_View_Private_Data { WKEinaSharedString cursorGroup; WKEinaSharedString faviconURL; RefPtr<Evas_Object> cursorObject; - LoadingResourcesMap loadingResourcesMap; OwnPtr<Ewk_Back_Forward_List> backForwardList; OwnPtr<Ewk_Settings> settings; bool areMouseEventsEnabled; @@ -828,17 +828,18 @@ static void _ewk_view_initialize(Evas_Object* ewkView, Ewk_Context* context, WKP priv->pageViewportControllerClient = PageViewportControllerClientEfl::create(ewkView); #endif + // Initialize page clients. WKPageRef wkPage = toAPI(priv->pageProxy.get()); ewk_view_find_client_attach(wkPage, ewkView); ewk_view_form_client_attach(wkPage, ewkView); - ewk_view_loader_client_attach(wkPage, ewkView); ewk_view_policy_client_attach(wkPage, ewkView); - ewk_view_resource_load_client_attach(wkPage, ewkView); ewk_view_ui_client_attach(wkPage, ewkView); #if ENABLE(FULLSCREEN_API) priv->pageProxy->fullScreenManager()->setWebView(ewkView); ewk_settings_fullscreen_enabled_set(priv->settings.get(), true); #endif + priv->pageLoadClient = PageLoadClientEfl::create(ewkView); + priv->resourceLoadClient = ResourceLoadClientEfl::create(ewkView); /* Listen for favicon changes */ Ewk_Favicon_Database* iconDatabase = ewk_context_favicon_database_get(priv->context); @@ -1015,20 +1016,26 @@ Ewk_Settings* ewk_view_settings_get(const Evas_Object* ewkView) /** * @internal + * Retrieves the internal WKPage for this view. + */ +WKPageRef ewk_view_wkpage_get(const Evas_Object* ewkView) +{ + EWK_VIEW_SD_GET_OR_RETURN(ewkView, smartData, 0); + EWK_VIEW_PRIV_GET_OR_RETURN(smartData, priv, 0); + + return toAPI(priv->pageProxy.get()); +} + +/** + * @internal * Load was initiated for a resource in the view. * * Emits signal: "resource,request,new" with pointer to resource request. */ -void ewk_view_resource_load_initiated(Evas_Object* ewkView, uint64_t resourceIdentifier, Ewk_Resource* resource, Ewk_Url_Request* request) +void ewk_view_resource_load_initiated(Evas_Object* ewkView, Ewk_Resource* resource, Ewk_Url_Request* request) { - EWK_VIEW_SD_GET_OR_RETURN(ewkView, smartData); - EWK_VIEW_PRIV_GET_OR_RETURN(smartData, priv); - Ewk_Resource_Request resourceRequest = {resource, request, 0}; - // Keep the resource internally to reuse it later. - priv->loadingResourcesMap.add(resourceIdentifier, resource); - evas_object_smart_callback_call(ewkView, "resource,request,new", &resourceRequest); } @@ -1038,16 +1045,9 @@ void ewk_view_resource_load_initiated(Evas_Object* ewkView, uint64_t resourceIde * * Emits signal: "resource,request,response" with pointer to resource response. */ -void ewk_view_resource_load_response(Evas_Object* ewkView, uint64_t resourceIdentifier, Ewk_Url_Response* response) +void ewk_view_resource_load_response(Evas_Object* ewkView, Ewk_Resource* resource, Ewk_Url_Response* response) { - EWK_VIEW_SD_GET_OR_RETURN(ewkView, smartData); - EWK_VIEW_PRIV_GET_OR_RETURN(smartData, priv); - - if (!priv->loadingResourcesMap.contains(resourceIdentifier)) - return; - - RefPtr<Ewk_Resource> resource = priv->loadingResourcesMap.get(resourceIdentifier); - Ewk_Resource_Load_Response resourceLoadResponse = {resource.get(), response}; + Ewk_Resource_Load_Response resourceLoadResponse = {resource, response}; evas_object_smart_callback_call(ewkView, "resource,request,response", &resourceLoadResponse); } @@ -1057,16 +1057,9 @@ void ewk_view_resource_load_response(Evas_Object* ewkView, uint64_t resourceIden * * Emits signal: "resource,request,finished" with pointer to the resource load error. */ -void ewk_view_resource_load_failed(Evas_Object* ewkView, uint64_t resourceIdentifier, Ewk_Error* error) +void ewk_view_resource_load_failed(Evas_Object* ewkView, Ewk_Resource* resource, Ewk_Error* error) { - EWK_VIEW_SD_GET_OR_RETURN(ewkView, smartData); - EWK_VIEW_PRIV_GET_OR_RETURN(smartData, priv); - - if (!priv->loadingResourcesMap.contains(resourceIdentifier)) - return; - - RefPtr<Ewk_Resource> resource = priv->loadingResourcesMap.get(resourceIdentifier); - Ewk_Resource_Load_Error resourceLoadError = {resource.get(), error}; + Ewk_Resource_Load_Error resourceLoadError = {resource, error}; evas_object_smart_callback_call(ewkView, "resource,request,failed", &resourceLoadError); } @@ -1076,16 +1069,9 @@ void ewk_view_resource_load_failed(Evas_Object* ewkView, uint64_t resourceIdenti * * Emits signal: "resource,request,finished" with pointer to the resource. */ -void ewk_view_resource_load_finished(Evas_Object* ewkView, uint64_t resourceIdentifier) +void ewk_view_resource_load_finished(Evas_Object* ewkView, Ewk_Resource* resource) { - EWK_VIEW_SD_GET_OR_RETURN(ewkView, smartData); - EWK_VIEW_PRIV_GET_OR_RETURN(smartData, priv); - - if (!priv->loadingResourcesMap.contains(resourceIdentifier)) - return; - - RefPtr<Ewk_Resource> resource = priv->loadingResourcesMap.take(resourceIdentifier); - evas_object_smart_callback_call(ewkView, "resource,request,finished", resource.get()); + evas_object_smart_callback_call(ewkView, "resource,request,finished", resource); } /** @@ -1094,17 +1080,9 @@ void ewk_view_resource_load_finished(Evas_Object* ewkView, uint64_t resourceIden * * Emits signal: "resource,request,sent" with pointer to resource request and possible redirect response. */ -void ewk_view_resource_request_sent(Evas_Object* ewkView, uint64_t resourceIdentifier, Ewk_Url_Request* request, Ewk_Url_Response* redirectResponse) +void ewk_view_resource_request_sent(Evas_Object* ewkView, Ewk_Resource* resource, Ewk_Url_Request* request, Ewk_Url_Response* redirectResponse) { - EWK_VIEW_SD_GET_OR_RETURN(ewkView, smartData); - EWK_VIEW_PRIV_GET_OR_RETURN(smartData, priv); - - if (!priv->loadingResourcesMap.contains(resourceIdentifier)) - return; - - RefPtr<Ewk_Resource> resource = priv->loadingResourcesMap.get(resourceIdentifier); - Ewk_Resource_Request resourceRequest = {resource.get(), request, redirectResponse}; - + Ewk_Resource_Request resourceRequest = {resource, request, redirectResponse}; evas_object_smart_callback_call(ewkView, "resource,request,sent", &resourceRequest); } @@ -1538,13 +1516,6 @@ void ewk_view_load_provisional_redirect(Evas_Object* ewkView) */ void ewk_view_load_provisional_started(Evas_Object* ewkView) { - EWK_VIEW_SD_GET_OR_RETURN(ewkView, smartData); - EWK_VIEW_PRIV_GET_OR_RETURN(smartData, priv); - - // The main frame started provisional load, we should clear - // the loadingResources HashMap to start clean. - priv->loadingResourcesMap.clear(); - ewk_view_url_update(ewkView); evas_object_smart_callback_call(ewkView, "load,provisional,started", 0); } @@ -1942,8 +1913,8 @@ Eina_Bool ewk_view_color_picker_color_set(Evas_Object* ewkView, int r, int g, in EINA_SAFETY_ON_NULL_RETURN_VAL(priv->colorPickerResultListener, false); WebCore::Color color = WebCore::Color(r, g, b, a); - const WKStringRef colorString = WKStringCreateWithUTF8CString(color.serialized().utf8().data()); - WKColorPickerResultListenerSetColor(priv->colorPickerResultListener.get(), colorString); + WKRetainPtr<WKStringRef> colorString(AdoptWK, WKStringCreateWithUTF8CString(color.serialized().utf8().data())); + WKColorPickerResultListenerSetColor(priv->colorPickerResultListener.get(), colorString.get()); priv->colorPickerResultListener.clear(); return true; diff --git a/Source/WebKit2/UIProcess/API/efl/ewk_view_private.h b/Source/WebKit2/UIProcess/API/efl/ewk_view_private.h index 61c7bd41a..2066f9eff 100644 --- a/Source/WebKit2/UIProcess/API/efl/ewk_view_private.h +++ b/Source/WebKit2/UIProcess/API/efl/ewk_view_private.h @@ -77,17 +77,19 @@ void ewk_view_page_close(Evas_Object* ewkView); WKPageRef ewk_view_page_create(Evas_Object* ewkView); void ewk_view_title_changed(Evas_Object* ewkView, const char* title); void ewk_view_tooltip_text_set(Evas_Object* ewkView, const char* text); -void ewk_view_resource_load_failed(Evas_Object* ewkView, uint64_t resourceIdentifier, Ewk_Error* error); -void ewk_view_resource_load_finished(Evas_Object* ewkView, uint64_t resourceIdentifier); -void ewk_view_resource_load_initiated(Evas_Object* ewkView, uint64_t resourceIdentifier, Ewk_Resource* resource, Ewk_Url_Request* request); -void ewk_view_resource_load_response(Evas_Object* ewkView, uint64_t resourceIdentifier, Ewk_Url_Response* response); -void ewk_view_resource_request_sent(Evas_Object* ewkView, uint64_t resourceIdentifier, Ewk_Url_Request* request, Ewk_Url_Response* redirectResponse); +void ewk_view_resource_load_failed(Evas_Object* ewkView, Ewk_Resource* resource, Ewk_Error* error); +void ewk_view_resource_load_finished(Evas_Object* ewkView, Ewk_Resource* resource); +void ewk_view_resource_load_initiated(Evas_Object* ewkView, Ewk_Resource* resource, Ewk_Url_Request* request); +void ewk_view_resource_load_response(Evas_Object* ewkView, Ewk_Resource* resource, Ewk_Url_Response* response); +void ewk_view_resource_request_sent(Evas_Object* ewkView, Ewk_Resource* resource, Ewk_Url_Request* request, Ewk_Url_Response* redirectResponse); void ewk_view_text_found(Evas_Object* ewkView, unsigned int matchCount); void ewk_view_url_update(Evas_Object* ewkView); void ewk_view_contents_size_changed(const Evas_Object* ewkView, const WebCore::IntSize&); void ewk_view_back_forward_list_changed(Evas_Object* ewkView); void ewk_view_update_icon(Evas_Object* ewkView); +WKPageRef ewk_view_wkpage_get(const Evas_Object* ewkView); + Evas_Object* ewk_view_base_add(Evas* canvas, WKContextRef, WKPageGroupRef); #if ENABLE(WEB_INTENTS) diff --git a/Source/WebKit2/UIProcess/API/efl/ewk_view_resource_load_client.cpp b/Source/WebKit2/UIProcess/API/efl/ewk_view_resource_load_client.cpp deleted file mode 100644 index ce62539d3..000000000 --- a/Source/WebKit2/UIProcess/API/efl/ewk_view_resource_load_client.cpp +++ /dev/null @@ -1,103 +0,0 @@ -/* - * Copyright (C) 2012 Intel Corporation. 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. - */ - -#include "config.h" - -#include "WKAPICast.h" -#include "WKFrame.h" -#include "WKPage.h" -#include "WKRetainPtr.h" -#include "WKURL.h" -#include "WKURLRequest.h" -#include "WKURLResponse.h" -#include "ewk_error_private.h" -#include "ewk_resource.h" -#include "ewk_resource_private.h" -#include "ewk_url_request.h" -#include "ewk_url_request_private.h" -#include "ewk_url_response.h" -#include "ewk_url_response_private.h" -#include "ewk_view_private.h" -#include "ewk_view_resource_load_client_private.h" -#include <wtf/OwnPtr.h> -#include <wtf/text/CString.h> - -using namespace WebCore; -using namespace WebKit; - -static inline Evas_Object* toEwkView(const void* clientInfo) -{ - return static_cast<Evas_Object*>(const_cast<void*>(clientInfo)); -} - -static void didInitiateLoadForResource(WKPageRef, WKFrameRef wkFrame, uint64_t resourceIdentifier, WKURLRequestRef wkRequest, bool pageIsProvisionallyLoading, const void* clientInfo) -{ - bool isMainResource = (WKFrameIsMainFrame(wkFrame) && pageIsProvisionallyLoading); - WKRetainPtr<WKURLRef> wkUrl(AdoptWK, WKURLRequestCopyURL(wkRequest)); - - RefPtr<Ewk_Resource> resource = Ewk_Resource::create(wkUrl.get(), isMainResource); - RefPtr<Ewk_Url_Request> request = Ewk_Url_Request::create(wkRequest); - ewk_view_resource_load_initiated(toEwkView(clientInfo), resourceIdentifier, resource.get(), request.get()); -} - -static void didSendRequestForResource(WKPageRef, WKFrameRef, uint64_t resourceIdentifier, WKURLRequestRef wkRequest, WKURLResponseRef wkRedirectResponse, const void* clientInfo) -{ - RefPtr<Ewk_Url_Request> request = Ewk_Url_Request::create(wkRequest); - RefPtr<Ewk_Url_Response> redirectResponse = Ewk_Url_Response::create(wkRedirectResponse); - ewk_view_resource_request_sent(toEwkView(clientInfo), resourceIdentifier, request.get(), redirectResponse.get()); -} - -static void didReceiveResponseForResource(WKPageRef, WKFrameRef, uint64_t resourceIdentifier, WKURLResponseRef wkResponse, const void* clientInfo) -{ - RefPtr<Ewk_Url_Response> response = Ewk_Url_Response::create(wkResponse); - ewk_view_resource_load_response(toEwkView(clientInfo), resourceIdentifier, response.get()); -} - -static void didFinishLoadForResource(WKPageRef, WKFrameRef, uint64_t resourceIdentifier, const void* clientInfo) -{ - ewk_view_resource_load_finished(toEwkView(clientInfo), resourceIdentifier); -} - -static void didFailLoadForResource(WKPageRef, WKFrameRef, uint64_t resourceIdentifier, WKErrorRef wkError, const void* clientInfo) -{ - OwnPtr<Ewk_Error> ewkError = Ewk_Error::create(wkError); - ewk_view_resource_load_failed(toEwkView(clientInfo), resourceIdentifier, ewkError.get()); - ewk_view_resource_load_finished(toEwkView(clientInfo), resourceIdentifier); -} - -void ewk_view_resource_load_client_attach(WKPageRef pageRef, Evas_Object* ewkView) -{ - WKPageResourceLoadClient wkResourceLoadClient; - memset(&wkResourceLoadClient, 0, sizeof(WKPageResourceLoadClient)); - wkResourceLoadClient.version = kWKPageResourceLoadClientCurrentVersion; - wkResourceLoadClient.clientInfo = ewkView; - wkResourceLoadClient.didInitiateLoadForResource = didInitiateLoadForResource; - wkResourceLoadClient.didSendRequestForResource = didSendRequestForResource; - wkResourceLoadClient.didReceiveResponseForResource = didReceiveResponseForResource; - wkResourceLoadClient.didFinishLoadForResource = didFinishLoadForResource; - wkResourceLoadClient.didFailLoadForResource = didFailLoadForResource; - - WKPageSetPageResourceLoadClient(pageRef, &wkResourceLoadClient); -} diff --git a/Source/WebKit2/UIProcess/API/efl/ewk_view_resource_load_client_private.h b/Source/WebKit2/UIProcess/API/efl/ewk_view_resource_load_client_private.h deleted file mode 100644 index 1f404b920..000000000 --- a/Source/WebKit2/UIProcess/API/efl/ewk_view_resource_load_client_private.h +++ /dev/null @@ -1,34 +0,0 @@ -/* - * Copyright (C) 2012 Intel Corporation. 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 ewk_view_resource_load_client_private_h -#define ewk_view_resource_load_client_private_h - -#include <Evas.h> -#include <WebKit2/WKBase.h> - -void ewk_view_resource_load_client_attach(WKPageRef pageRef, Evas_Object* ewkView); - -#endif // ewk_view_resource_load_client_private_h diff --git a/Source/WebKit2/UIProcess/API/mac/WKView.mm b/Source/WebKit2/UIProcess/API/mac/WKView.mm index cd2de8d25..ac037fb30 100644 --- a/Source/WebKit2/UIProcess/API/mac/WKView.mm +++ b/Source/WebKit2/UIProcess/API/mac/WKView.mm @@ -26,11 +26,6 @@ #import "config.h" #import "WKView.h" -#if USE(DICTATION_ALTERNATIVES) -#import <AppKit/NSTextAlternatives.h> -#import <AppKit/NSAttributedString.h> -#endif - #import "AttributedString.h" #import "ColorSpaceData.h" #import "DataReference.h" @@ -90,6 +85,10 @@ #import <wtf/RefPtr.h> #import <wtf/RetainPtr.h> +#if USE(DICTATION_ALTERNATIVES) +#import <AppKit/NSTextAlternatives.h> +#endif + @interface NSApplication (WKNSApplicationDetails) - (void)speakString:(NSString *)string; - (void)_setCurrentEvent:(NSEvent *)event; @@ -139,12 +138,6 @@ struct WKViewInterpretKeyEventsParameters { - (void)_wk_setPluginComplexTextInputState:(PluginComplexTextInputState)pluginComplexTextInputState; @end -@interface WKToolTipDelegate : NSObject { - RefPtr<WebPageProxy> _page; -} -- (id)initWithPage:(WebPageProxy *)page; -@end - @interface WKViewData : NSObject { @public OwnPtr<PageClientImpl> _pageClient; @@ -217,7 +210,6 @@ struct WKViewInterpretKeyEventsParameters { String _promisedFilename; String _promisedURL; - RetainPtr<WKToolTipDelegate> _toolTipDelegate; RetainPtr<NSMutableArray> _observers; } @@ -2520,6 +2512,11 @@ static void drawPageBackground(CGContextRef context, WebPageProxy* page, const I [_data->_trackingRectOwner mouseEntered:fakeEvent]; } +- (NSString *)view:(NSView *)view stringForToolTip:(NSToolTipTag)tag point:(NSPoint)point userData:(void *)data +{ + return nsStringFromWebCoreString(_data->_page->toolTip()); +} + - (void)_wk_toolTipChangedFrom:(NSString *)oldToolTip to:(NSString *)newToolTip { if (oldToolTip) @@ -2529,9 +2526,7 @@ static void drawPageBackground(CGContextRef context, WebPageProxy* page, const I // See radar 3500217 for why we remove all tooltips rather than just the single one we created. [self removeAllToolTips]; NSRect wideOpenRect = NSMakeRect(-100000, -100000, 200000, 200000); - if (!_data->_toolTipDelegate) - _data->_toolTipDelegate = adoptNS([[WKToolTipDelegate alloc] initWithPage:_data->_page.get()]); - _data->_lastToolTipTag = [self addToolTipRect:wideOpenRect owner:_data->_toolTipDelegate.get() userData:NULL]; + _data->_lastToolTipTag = [self addToolTipRect:wideOpenRect owner:self userData:NULL]; [self _wk_sendToolTipMouseEntered]; } } @@ -3198,21 +3193,3 @@ static NSString *pathWithUniqueFilenameForPath(NSString *path) } @end - -@implementation WKToolTipDelegate - -- (id)initWithPage:(WebPageProxy *)page -{ - self = [super init]; - if (!self) - return nil; - _page = page; - return self; -} - -- (NSString *)view:(NSView *)view stringForToolTip:(NSToolTipTag)tag point:(NSPoint)point userData:(void *)data -{ - return nsStringFromWebCoreString(_page->toolTip()); -} - -@end diff --git a/Source/WebKit2/UIProcess/Notifications/WebNotificationManagerProxy.cpp b/Source/WebKit2/UIProcess/Notifications/WebNotificationManagerProxy.cpp index 08009b9da..9dfe29b00 100644 --- a/Source/WebKit2/UIProcess/Notifications/WebNotificationManagerProxy.cpp +++ b/Source/WebKit2/UIProcess/Notifications/WebNotificationManagerProxy.cpp @@ -31,6 +31,7 @@ #include "WebContext.h" #include "WebNotification.h" #include "WebNotificationManagerMessages.h" +#include "WebNotificationManagerProxyMessages.h" #include "WebPageProxy.h" #include "WebSecurityOrigin.h" @@ -47,7 +48,7 @@ PassRefPtr<WebNotificationManagerProxy> WebNotificationManagerProxy::create(WebC WebNotificationManagerProxy::WebNotificationManagerProxy(WebContext* context) : m_context(context) { - m_context->deprecatedAddMessageReceiver(CoreIPC::MessageClassWebNotificationManagerProxy, this); + m_context->addMessageReceiver(Messages::WebNotificationManagerProxy::messageReceiverName(), this); } void WebNotificationManagerProxy::invalidate() diff --git a/Source/WebKit2/UIProcess/WebApplicationCacheManagerProxy.cpp b/Source/WebKit2/UIProcess/WebApplicationCacheManagerProxy.cpp index de668ab0e..474f06dac 100644 --- a/Source/WebKit2/UIProcess/WebApplicationCacheManagerProxy.cpp +++ b/Source/WebKit2/UIProcess/WebApplicationCacheManagerProxy.cpp @@ -28,6 +28,7 @@ #include "SecurityOriginData.h" #include "WebApplicationCacheManagerMessages.h" +#include "WebApplicationCacheManagerProxyMessages.h" #include "WebContext.h" #include "WebSecurityOrigin.h" @@ -41,7 +42,7 @@ PassRefPtr<WebApplicationCacheManagerProxy> WebApplicationCacheManagerProxy::cre WebApplicationCacheManagerProxy::WebApplicationCacheManagerProxy(WebContext* context) : m_webContext(context) { - m_webContext->deprecatedAddMessageReceiver(CoreIPC::MessageClassWebApplicationCacheManagerProxy, this); + m_webContext->addMessageReceiver(Messages::WebApplicationCacheManagerProxy::messageReceiverName(), this); } WebApplicationCacheManagerProxy::~WebApplicationCacheManagerProxy() diff --git a/Source/WebKit2/UIProcess/WebBatteryManagerProxy.cpp b/Source/WebKit2/UIProcess/WebBatteryManagerProxy.cpp index 44b5aca0a..01eb98052 100644 --- a/Source/WebKit2/UIProcess/WebBatteryManagerProxy.cpp +++ b/Source/WebKit2/UIProcess/WebBatteryManagerProxy.cpp @@ -29,6 +29,7 @@ #if ENABLE(BATTERY_STATUS) #include "WebBatteryManagerMessages.h" +#include "WebBatteryManagerProxyMessages.h" #include "WebContext.h" namespace WebKit { @@ -42,7 +43,7 @@ WebBatteryManagerProxy::WebBatteryManagerProxy(WebContext* context) : m_isUpdating(false) , m_context(context) { - m_context->deprecatedAddMessageReceiver(CoreIPC::MessageClassWebBatteryManagerProxy, this); + m_context->addMessageReceiver(Messages::WebBatteryManagerProxy::messageReceiverName(), this); } WebBatteryManagerProxy::~WebBatteryManagerProxy() diff --git a/Source/WebKit2/UIProcess/WebConnectionToWebProcess.cpp b/Source/WebKit2/UIProcess/WebConnectionToWebProcess.cpp index ff43b3411..6202608bd 100644 --- a/Source/WebKit2/UIProcess/WebConnectionToWebProcess.cpp +++ b/Source/WebKit2/UIProcess/WebConnectionToWebProcess.cpp @@ -59,7 +59,9 @@ void WebConnectionToWebProcess::encodeMessageBody(CoreIPC::ArgumentEncoder& enco bool WebConnectionToWebProcess::decodeMessageBody(CoreIPC::ArgumentDecoder& decoder, RefPtr<APIObject>& messageBody) { - if (!decoder.decode(WebContextUserMessageDecoder(messageBody, m_process))) + WebContextUserMessageDecoder messageBodyDecoder(messageBody, m_process); + + if (!decoder.decode(messageBodyDecoder)) return false; return true; diff --git a/Source/WebKit2/UIProcess/WebContext.cpp b/Source/WebKit2/UIProcess/WebContext.cpp index 76cb514b9..56a017c6f 100644 --- a/Source/WebKit2/UIProcess/WebContext.cpp +++ b/Source/WebKit2/UIProcess/WebContext.cpp @@ -27,6 +27,7 @@ #include "WebContext.h" #include "DownloadProxy.h" +#include "DownloadProxyMessages.h" #include "ImmutableArray.h" #include "Logging.h" #include "MutableDictionary.h" @@ -36,6 +37,7 @@ #include "WKContextPrivate.h" #include "WebApplicationCacheManagerProxy.h" #include "WebContextMessageKinds.h" +#include "WebContextMessages.h" #include "WebContextUserMessageCoders.h" #include "WebCookieManagerProxy.h" #include "WebCoreArgumentCoders.h" @@ -133,9 +135,9 @@ WebContext::WebContext(ProcessModel processModel, const String& injectedBundlePa , m_usesNetworkProcess(false) #endif { - deprecatedAddMessageReceiver(CoreIPC::MessageClassWebContext, this); - deprecatedAddMessageReceiver(CoreIPC::MessageClassDownloadProxy, this); - deprecatedAddMessageReceiver(CoreIPC::MessageClassWebContextLegacy, this); + addMessageReceiver(Messages::WebContext::messageReceiverName(), this); + addMessageReceiver(Messages::DownloadProxy::messageReceiverName(), this); + addMessageReceiver(CoreIPC::MessageKindTraits<WebContextLegacyMessage::Kind>::messageReceiverName(), this); // NOTE: These sub-objects must be initialized after m_messageReceiverMap.. m_applicationCacheManagerProxy = WebApplicationCacheManagerProxy::create(this); @@ -783,9 +785,9 @@ HashSet<String, CaseFoldingHash> WebContext::pdfAndPostScriptMIMETypes() return mimeTypes; } -void WebContext::deprecatedAddMessageReceiver(CoreIPC::MessageClass messageClass, CoreIPC::MessageReceiver* messageReceiver) +void WebContext::addMessageReceiver(CoreIPC::StringReference messageReceiverName, CoreIPC::MessageReceiver* messageReceiver) { - m_messageReceiverMap.deprecatedAddMessageReceiver(messageClass, messageReceiver); + m_messageReceiverMap.addMessageReceiver(messageReceiverName, messageReceiver); } bool WebContext::dispatchMessage(CoreIPC::Connection* connection, CoreIPC::MessageID messageID, CoreIPC::MessageDecoder& decoder) @@ -816,10 +818,12 @@ void WebContext::didReceiveMessage(CoreIPC::Connection* connection, CoreIPC::Mes case WebContextLegacyMessage::PostMessage: { String messageName; RefPtr<APIObject> messageBody; - WebContextUserMessageDecoder messageDecoder(messageBody, WebProcessProxy::fromConnection(connection)); - if (!decoder.decode(CoreIPC::Out(messageName, messageDecoder))) + WebContextUserMessageDecoder messageBodyDecoder(messageBody, WebProcessProxy::fromConnection(connection)); + if (!decoder.decode(messageName)) return; - + if (!decoder.decode(messageBodyDecoder)) + return; + didReceiveMessageFromInjectedBundle(messageName, messageBody.get()); return; } @@ -849,13 +853,15 @@ void WebContext::didReceiveSyncMessage(CoreIPC::Connection* connection, CoreIPC: String messageName; RefPtr<APIObject> messageBody; - WebContextUserMessageDecoder messageDecoder(messageBody, WebProcessProxy::fromConnection(connection)); - if (!decoder.decode(CoreIPC::Out(messageName, messageDecoder))) + WebContextUserMessageDecoder messageBodyDecoder(messageBody, WebProcessProxy::fromConnection(connection)); + if (!decoder.decode(messageName)) + return; + if (!decoder.decode(messageBodyDecoder)) return; RefPtr<APIObject> returnData; didReceiveSynchronousMessageFromInjectedBundle(messageName, messageBody.get(), returnData); - replyEncoder->encode(CoreIPC::In(WebContextUserMessageEncoder(returnData.get()))); + replyEncoder->encode(WebContextUserMessageEncoder(returnData.get())); return; } case WebContextLegacyMessage::PostMessage: diff --git a/Source/WebKit2/UIProcess/WebContext.h b/Source/WebKit2/UIProcess/WebContext.h index e3f6a69db..93dc68e70 100644 --- a/Source/WebKit2/UIProcess/WebContext.h +++ b/Source/WebKit2/UIProcess/WebContext.h @@ -86,7 +86,7 @@ public: static const Vector<WebContext*>& allContexts(); - void deprecatedAddMessageReceiver(CoreIPC::MessageClass, CoreIPC::MessageReceiver*); + void addMessageReceiver(CoreIPC::StringReference messageReceiverName, CoreIPC::MessageReceiver*); bool dispatchMessage(CoreIPC::Connection*, CoreIPC::MessageID, CoreIPC::MessageDecoder&); bool dispatchSyncMessage(CoreIPC::Connection*, CoreIPC::MessageID, CoreIPC::MessageDecoder&, OwnPtr<CoreIPC::MessageEncoder>&); diff --git a/Source/WebKit2/UIProcess/WebCookieManagerProxy.cpp b/Source/WebKit2/UIProcess/WebCookieManagerProxy.cpp index 6f876cfcc..b63c80c7e 100644 --- a/Source/WebKit2/UIProcess/WebCookieManagerProxy.cpp +++ b/Source/WebKit2/UIProcess/WebCookieManagerProxy.cpp @@ -27,8 +27,9 @@ #include "WebCookieManagerProxy.h" #include "SecurityOriginData.h" -#include "WebCookieManagerMessages.h" #include "WebContext.h" +#include "WebCookieManagerMessages.h" +#include "WebCookieManagerProxyMessages.h" #include "WebSecurityOrigin.h" namespace WebKit { @@ -41,7 +42,7 @@ PassRefPtr<WebCookieManagerProxy> WebCookieManagerProxy::create(WebContext* cont WebCookieManagerProxy::WebCookieManagerProxy(WebContext* context) : m_webContext(context) { - m_webContext->deprecatedAddMessageReceiver(CoreIPC::MessageClassWebCookieManagerProxy, this); + m_webContext->addMessageReceiver(Messages::WebCookieManagerProxy::messageReceiverName(), this); } WebCookieManagerProxy::~WebCookieManagerProxy() diff --git a/Source/WebKit2/UIProcess/WebDatabaseManagerProxy.cpp b/Source/WebKit2/UIProcess/WebDatabaseManagerProxy.cpp index 8f24028cb..116fd56e6 100644 --- a/Source/WebKit2/UIProcess/WebDatabaseManagerProxy.cpp +++ b/Source/WebKit2/UIProcess/WebDatabaseManagerProxy.cpp @@ -30,8 +30,9 @@ #include "ImmutableArray.h" #include "ImmutableDictionary.h" -#include "WebDatabaseManagerMessages.h" #include "WebContext.h" +#include "WebDatabaseManagerMessages.h" +#include "WebDatabaseManagerProxyMessages.h" #include "WebSecurityOrigin.h" using namespace WebCore; @@ -94,7 +95,7 @@ PassRefPtr<WebDatabaseManagerProxy> WebDatabaseManagerProxy::create(WebContext* WebDatabaseManagerProxy::WebDatabaseManagerProxy(WebContext* webContext) : m_webContext(webContext) { - m_webContext->deprecatedAddMessageReceiver(CoreIPC::MessageClassWebDatabaseManagerProxy, this); + m_webContext->addMessageReceiver(Messages::WebDatabaseManagerProxy::messageReceiverName(), this); } WebDatabaseManagerProxy::~WebDatabaseManagerProxy() diff --git a/Source/WebKit2/UIProcess/WebGeolocationManagerProxy.cpp b/Source/WebKit2/UIProcess/WebGeolocationManagerProxy.cpp index 6cccd849c..74b90797f 100644 --- a/Source/WebKit2/UIProcess/WebGeolocationManagerProxy.cpp +++ b/Source/WebKit2/UIProcess/WebGeolocationManagerProxy.cpp @@ -28,6 +28,7 @@ #include "WebContext.h" #include "WebGeolocationManagerMessages.h" +#include "WebGeolocationManagerProxyMessages.h" namespace WebKit { @@ -40,7 +41,7 @@ WebGeolocationManagerProxy::WebGeolocationManagerProxy(WebContext* context) : m_isUpdating(false) , m_context(context) { - m_context->deprecatedAddMessageReceiver(CoreIPC::MessageClassWebGeolocationManagerProxy, this); + m_context->addMessageReceiver(Messages::WebGeolocationManagerProxy::messageReceiverName(), this); } WebGeolocationManagerProxy::~WebGeolocationManagerProxy() diff --git a/Source/WebKit2/UIProcess/WebIconDatabase.cpp b/Source/WebKit2/UIProcess/WebIconDatabase.cpp index 1092b9ac5..40158f4a0 100644 --- a/Source/WebKit2/UIProcess/WebIconDatabase.cpp +++ b/Source/WebKit2/UIProcess/WebIconDatabase.cpp @@ -29,6 +29,7 @@ #include "DataReference.h" #include "Logging.h" #include "WebContext.h" +#include "WebIconDatabaseMessages.h" #include "WebIconDatabaseProxyMessages.h" #include <WebCore/FileSystem.h> #include <WebCore/IconDatabase.h> @@ -54,7 +55,7 @@ WebIconDatabase::WebIconDatabase(WebContext* context) , m_urlImportCompleted(false) , m_databaseCleanupDisabled(false) { - m_webContext->deprecatedAddMessageReceiver(CoreIPC::MessageClassWebIconDatabase, this); + m_webContext->addMessageReceiver(Messages::WebIconDatabase::messageReceiverName(), this); } void WebIconDatabase::invalidate() diff --git a/Source/WebKit2/UIProcess/WebKeyValueStorageManagerProxy.cpp b/Source/WebKit2/UIProcess/WebKeyValueStorageManagerProxy.cpp index 5c3088d98..43f69a445 100644 --- a/Source/WebKit2/UIProcess/WebKeyValueStorageManagerProxy.cpp +++ b/Source/WebKit2/UIProcess/WebKeyValueStorageManagerProxy.cpp @@ -27,8 +27,9 @@ #include "WebKeyValueStorageManagerProxy.h" #include "SecurityOriginData.h" -#include "WebKeyValueStorageManagerMessages.h" #include "WebContext.h" +#include "WebKeyValueStorageManagerMessages.h" +#include "WebKeyValueStorageManagerProxyMessages.h" #include "WebSecurityOrigin.h" namespace WebKit { @@ -41,7 +42,7 @@ PassRefPtr<WebKeyValueStorageManagerProxy> WebKeyValueStorageManagerProxy::creat WebKeyValueStorageManagerProxy::WebKeyValueStorageManagerProxy(WebContext* context) : m_webContext(context) { - m_webContext->deprecatedAddMessageReceiver(CoreIPC::MessageClassWebKeyValueStorageManagerProxy, this); + m_webContext->addMessageReceiver(Messages::WebKeyValueStorageManagerProxy::messageReceiverName(), this); } WebKeyValueStorageManagerProxy::~WebKeyValueStorageManagerProxy() diff --git a/Source/WebKit2/UIProcess/WebMediaCacheManagerProxy.cpp b/Source/WebKit2/UIProcess/WebMediaCacheManagerProxy.cpp index 39cf73a89..b0f9bd196 100644 --- a/Source/WebKit2/UIProcess/WebMediaCacheManagerProxy.cpp +++ b/Source/WebKit2/UIProcess/WebMediaCacheManagerProxy.cpp @@ -28,6 +28,7 @@ #include "WebContext.h" #include "WebMediaCacheManagerMessages.h" +#include "WebMediaCacheManagerProxyMessages.h" #include "WebSecurityOrigin.h" namespace WebKit { @@ -40,7 +41,7 @@ PassRefPtr<WebMediaCacheManagerProxy> WebMediaCacheManagerProxy::create(WebConte WebMediaCacheManagerProxy::WebMediaCacheManagerProxy(WebContext* context) : m_webContext(context) { - m_webContext->deprecatedAddMessageReceiver(CoreIPC::MessageClassWebMediaCacheManagerProxy, this); + m_webContext->addMessageReceiver(Messages::WebMediaCacheManagerProxy::messageReceiverName(), this); } WebMediaCacheManagerProxy::~WebMediaCacheManagerProxy() diff --git a/Source/WebKit2/UIProcess/WebNetworkInfoManagerProxy.cpp b/Source/WebKit2/UIProcess/WebNetworkInfoManagerProxy.cpp index 7f30a5340..4173463f4 100644 --- a/Source/WebKit2/UIProcess/WebNetworkInfoManagerProxy.cpp +++ b/Source/WebKit2/UIProcess/WebNetworkInfoManagerProxy.cpp @@ -31,6 +31,7 @@ #include "WebContext.h" #include "WebNetworkInfo.h" #include "WebNetworkInfoManagerMessages.h" +#include "WebNetworkInfoManagerProxyMessages.h" namespace WebKit { @@ -43,7 +44,7 @@ WebNetworkInfoManagerProxy::WebNetworkInfoManagerProxy(WebContext* context) : m_isUpdating(false) , m_context(context) { - m_context->deprecatedAddMessageReceiver(CoreIPC::MessageClassWebNetworkInfoManagerProxy, this); + m_context->addMessageReceiver(Messages::WebNetworkInfoManagerProxy::messageReceiverName(), this); } WebNetworkInfoManagerProxy::~WebNetworkInfoManagerProxy() diff --git a/Source/WebKit2/UIProcess/WebProcessProxy.h b/Source/WebKit2/UIProcess/WebProcessProxy.h index 29dc5498f..afa5bd4b2 100644 --- a/Source/WebKit2/UIProcess/WebProcessProxy.h +++ b/Source/WebKit2/UIProcess/WebProcessProxy.h @@ -221,7 +221,7 @@ private: template<typename E, typename T> bool WebProcessProxy::deprecatedSend(E messageID, uint64_t destinationID, const T& arguments) { - OwnPtr<CoreIPC::MessageEncoder> encoder = CoreIPC::MessageEncoder::create("", "", destinationID); + OwnPtr<CoreIPC::MessageEncoder> encoder = CoreIPC::MessageEncoder::create(CoreIPC::MessageKindTraits<E>::messageReceiverName(), "", destinationID); encoder->encode(arguments); return sendMessage(CoreIPC::MessageID(messageID), encoder.release(), 0); @@ -230,7 +230,7 @@ bool WebProcessProxy::deprecatedSend(E messageID, uint64_t destinationID, const template<typename T> bool WebProcessProxy::send(const T& message, uint64_t destinationID, unsigned messageSendFlags) { - OwnPtr<CoreIPC::MessageEncoder> encoder = CoreIPC::MessageEncoder::create("", "", destinationID); + OwnPtr<CoreIPC::MessageEncoder> encoder = CoreIPC::MessageEncoder::create(T::receiverName(), "", destinationID); encoder->encode(message); return sendMessage(CoreIPC::MessageID(T::messageID), encoder.release(), messageSendFlags); diff --git a/Source/WebKit2/UIProcess/WebResourceCacheManagerProxy.cpp b/Source/WebKit2/UIProcess/WebResourceCacheManagerProxy.cpp index fcb056db0..22a41a12d 100644 --- a/Source/WebKit2/UIProcess/WebResourceCacheManagerProxy.cpp +++ b/Source/WebKit2/UIProcess/WebResourceCacheManagerProxy.cpp @@ -31,6 +31,7 @@ #include "SecurityOriginData.h" #include "WebContext.h" #include "WebResourceCacheManagerMessages.h" +#include "WebResourceCacheManagerProxyMessages.h" #include "WebSecurityOrigin.h" using namespace WebCore; @@ -45,7 +46,7 @@ PassRefPtr<WebResourceCacheManagerProxy> WebResourceCacheManagerProxy::create(We WebResourceCacheManagerProxy::WebResourceCacheManagerProxy(WebContext* webContext) : m_webContext(webContext) { - m_webContext->deprecatedAddMessageReceiver(CoreIPC::MessageClassWebResourceCacheManagerProxy, this); + m_webContext->addMessageReceiver(Messages::WebResourceCacheManagerProxy::messageReceiverName(), this); } WebResourceCacheManagerProxy::~WebResourceCacheManagerProxy() diff --git a/Source/WebKit2/UIProcess/WebVibrationProxy.cpp b/Source/WebKit2/UIProcess/WebVibrationProxy.cpp index 6b0717c18..4a645d543 100644 --- a/Source/WebKit2/UIProcess/WebVibrationProxy.cpp +++ b/Source/WebKit2/UIProcess/WebVibrationProxy.cpp @@ -29,6 +29,7 @@ #if ENABLE(VIBRATION) #include "WebContext.h" +#include "WebVibrationProxyMessages.h" namespace WebKit { @@ -40,7 +41,7 @@ PassRefPtr<WebVibrationProxy> WebVibrationProxy::create(WebContext* context) WebVibrationProxy::WebVibrationProxy(WebContext* context) : m_context(context) { - m_context->deprecatedAddMessageReceiver(CoreIPC::MessageClassWebVibrationProxy, this); + m_context->addMessageReceiver(Messages::WebVibrationProxy::messageReceiverName(), this); } WebVibrationProxy::~WebVibrationProxy() diff --git a/Source/WebKit2/UIProcess/API/efl/ewk_view_loader_client.cpp b/Source/WebKit2/UIProcess/efl/PageLoadClientEfl.cpp index 0d6d5a347..2425b157d 100644 --- a/Source/WebKit2/UIProcess/API/efl/ewk_view_loader_client.cpp +++ b/Source/WebKit2/UIProcess/efl/PageLoadClientEfl.cpp @@ -24,106 +24,107 @@ */ #include "config.h" -#include "ewk_view.h" +#include "PageLoadClientEfl.h" #include "WKFrame.h" +#include "WKPage.h" #include "ewk_back_forward_list_private.h" #include "ewk_error_private.h" -#include "ewk_intent.h" #include "ewk_intent_private.h" -#include "ewk_intent_service.h" #include "ewk_intent_service_private.h" -#include "ewk_view_loader_client_private.h" -#include "ewk_view_private.h" -#include <wtf/OwnPtr.h> -#include <wtf/text/CString.h> +#include "ewk_view.h" -using namespace WebKit; +namespace WebKit { -static void didReceiveTitleForFrame(WKPageRef, WKStringRef title, WKFrameRef frame, WKTypeRef, const void* clientInfo) +static inline PageLoadClientEfl* toPageLoadClientEfl(const void* clientInfo) +{ + return static_cast<PageLoadClientEfl*>(const_cast<void*>(clientInfo)); +} + +void PageLoadClientEfl::didReceiveTitleForFrame(WKPageRef, WKStringRef title, WKFrameRef frame, WKTypeRef, const void* clientInfo) { if (!WKFrameIsMainFrame(frame)) return; - Evas_Object* ewkView = static_cast<Evas_Object*>(const_cast<void*>(clientInfo)); + Evas_Object* ewkView = toPageLoadClientEfl(clientInfo)->view(); ewk_view_title_changed(ewkView, toImpl(title)->string().utf8().data()); } #if ENABLE(WEB_INTENTS) -static void didReceiveIntentForFrame(WKPageRef, WKFrameRef, WKIntentDataRef intent, WKTypeRef, const void* clientInfo) +void PageLoadClientEfl::didReceiveIntentForFrame(WKPageRef, WKFrameRef, WKIntentDataRef intent, WKTypeRef, const void* clientInfo) { - Evas_Object* ewkView = static_cast<Evas_Object*>(const_cast<void*>(clientInfo)); + Evas_Object* ewkView = toPageLoadClientEfl(clientInfo)->view(); RefPtr<Ewk_Intent> ewkIntent = Ewk_Intent::create(intent); ewk_view_intent_request_new(ewkView, ewkIntent.get()); } #endif #if ENABLE(WEB_INTENTS_TAG) -static void registerIntentServiceForFrame(WKPageRef, WKFrameRef, WKIntentServiceInfoRef serviceInfo, WKTypeRef, const void *clientInfo) +void PageLoadClientEfl::registerIntentServiceForFrame(WKPageRef, WKFrameRef, WKIntentServiceInfoRef serviceInfo, WKTypeRef, const void* clientInfo) { - Evas_Object* ewkView = static_cast<Evas_Object*>(const_cast<void*>(clientInfo)); + Evas_Object* ewkView = toPageLoadClientEfl(clientInfo)->view(); RefPtr<Ewk_Intent_Service> ewkIntentService = Ewk_Intent_Service::create(serviceInfo); ewk_view_intent_service_register(ewkView, ewkIntentService.get()); } #endif -static void didChangeProgress(WKPageRef page, const void* clientInfo) +void PageLoadClientEfl::didChangeProgress(WKPageRef page, const void* clientInfo) { - Evas_Object* ewkView = static_cast<Evas_Object*>(const_cast<void*>(clientInfo)); + Evas_Object* ewkView = toPageLoadClientEfl(clientInfo)->view(); ewk_view_load_progress_changed(ewkView, WKPageGetEstimatedProgress(page)); } -static void didFinishLoadForFrame(WKPageRef, WKFrameRef frame, WKTypeRef /*userData*/, const void *clientInfo) +void PageLoadClientEfl::didFinishLoadForFrame(WKPageRef, WKFrameRef frame, WKTypeRef /*userData*/, const void* clientInfo) { if (!WKFrameIsMainFrame(frame)) return; - Evas_Object* ewkView = static_cast<Evas_Object*>(const_cast<void*>(clientInfo)); + Evas_Object* ewkView = toPageLoadClientEfl(clientInfo)->view(); ewk_view_load_finished(ewkView); } -static void didFailLoadWithErrorForFrame(WKPageRef, WKFrameRef frame, WKErrorRef error, WKTypeRef, const void *clientInfo) +void PageLoadClientEfl::didFailLoadWithErrorForFrame(WKPageRef, WKFrameRef frame, WKErrorRef error, WKTypeRef, const void* clientInfo) { if (!WKFrameIsMainFrame(frame)) return; - Evas_Object* ewkView = static_cast<Evas_Object*>(const_cast<void*>(clientInfo)); + Evas_Object* ewkView = toPageLoadClientEfl(clientInfo)->view(); OwnPtr<Ewk_Error> ewkError = Ewk_Error::create(error); ewk_view_load_error(ewkView, ewkError.get()); ewk_view_load_finished(ewkView); } -static void didStartProvisionalLoadForFrame(WKPageRef, WKFrameRef frame, WKTypeRef /*userData*/, const void* clientInfo) +void PageLoadClientEfl::didStartProvisionalLoadForFrame(WKPageRef, WKFrameRef frame, WKTypeRef /*userData*/, const void* clientInfo) { if (!WKFrameIsMainFrame(frame)) return; - Evas_Object* ewkView = static_cast<Evas_Object*>(const_cast<void*>(clientInfo)); + Evas_Object* ewkView = toPageLoadClientEfl(clientInfo)->view(); ewk_view_load_provisional_started(ewkView); } -static void didReceiveServerRedirectForProvisionalLoadForFrame(WKPageRef, WKFrameRef frame, WKTypeRef /*userData*/, const void* clientInfo) +void PageLoadClientEfl::didReceiveServerRedirectForProvisionalLoadForFrame(WKPageRef, WKFrameRef frame, WKTypeRef /*userData*/, const void* clientInfo) { if (!WKFrameIsMainFrame(frame)) return; - Evas_Object* ewkView = static_cast<Evas_Object*>(const_cast<void*>(clientInfo)); + Evas_Object* ewkView = toPageLoadClientEfl(clientInfo)->view(); ewk_view_load_provisional_redirect(ewkView); } -static void didFailProvisionalLoadWithErrorForFrame(WKPageRef, WKFrameRef frame, WKErrorRef error, WKTypeRef, const void* clientInfo) +void PageLoadClientEfl::didFailProvisionalLoadWithErrorForFrame(WKPageRef, WKFrameRef frame, WKErrorRef error, WKTypeRef, const void* clientInfo) { if (!WKFrameIsMainFrame(frame)) return; - Evas_Object* ewkView = static_cast<Evas_Object*>(const_cast<void*>(clientInfo)); + Evas_Object* ewkView = toPageLoadClientEfl(clientInfo)->view(); OwnPtr<Ewk_Error> ewkError = Ewk_Error::create(error); ewk_view_load_provisional_failed(ewkView, ewkError.get()); } -static void didChangeBackForwardList(WKPageRef, WKBackForwardListItemRef addedItem, WKArrayRef removedItems, const void* clientInfo) +void PageLoadClientEfl::didChangeBackForwardList(WKPageRef, WKBackForwardListItemRef addedItem, WKArrayRef removedItems, const void* clientInfo) { - Evas_Object* ewkView = static_cast<Evas_Object*>(const_cast<void*>(clientInfo)); + Evas_Object* ewkView = toPageLoadClientEfl(clientInfo)->view(); ASSERT(ewkView); Ewk_Back_Forward_List* list = ewk_view_back_forward_list_get(ewkView); @@ -133,21 +134,25 @@ static void didChangeBackForwardList(WKPageRef, WKBackForwardListItemRef addedIt ewk_view_back_forward_list_changed(ewkView); } -static void didSameDocumentNavigationForFrame(WKPageRef, WKFrameRef frame, WKSameDocumentNavigationType, WKTypeRef, const void* clientInfo) +void PageLoadClientEfl::didSameDocumentNavigationForFrame(WKPageRef, WKFrameRef frame, WKSameDocumentNavigationType, WKTypeRef, const void* clientInfo) { if (!WKFrameIsMainFrame(frame)) return; - Evas_Object* ewkView = static_cast<Evas_Object*>(const_cast<void*>(clientInfo)); + Evas_Object* ewkView = toPageLoadClientEfl(clientInfo)->view(); ewk_view_url_update(ewkView); } -void ewk_view_loader_client_attach(WKPageRef pageRef, Evas_Object* ewkView) +PageLoadClientEfl::PageLoadClientEfl(Evas_Object* view) + : m_view(view) { + WKPageRef pageRef = ewk_view_wkpage_get(m_view); + ASSERT(pageRef); + WKPageLoaderClient loadClient; memset(&loadClient, 0, sizeof(WKPageLoaderClient)); loadClient.version = kWKPageLoaderClientCurrentVersion; - loadClient.clientInfo = ewkView; + loadClient.clientInfo = this; loadClient.didReceiveTitleForFrame = didReceiveTitleForFrame; #if ENABLE(WEB_INTENTS) loadClient.didReceiveIntentForFrame = didReceiveIntentForFrame; @@ -167,3 +172,5 @@ void ewk_view_loader_client_attach(WKPageRef pageRef, Evas_Object* ewkView) loadClient.didSameDocumentNavigationForFrame = didSameDocumentNavigationForFrame; WKPageSetPageLoaderClient(pageRef, &loadClient); } + +} // namespace WebKit diff --git a/Source/WebKit2/UIProcess/efl/PageLoadClientEfl.h b/Source/WebKit2/UIProcess/efl/PageLoadClientEfl.h new file mode 100644 index 000000000..68cc17d6a --- /dev/null +++ b/Source/WebKit2/UIProcess/efl/PageLoadClientEfl.h @@ -0,0 +1,67 @@ +/* + * Copyright (C) 2012 Intel Corporation. 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 PageLoadClientEfl_h +#define PageLoadClientEfl_h + +#include "ewk_view_private.h" +#include <wtf/PassOwnPtr.h> + +namespace WebKit { + +class PageLoadClientEfl { +public: + static PassOwnPtr<PageLoadClientEfl> create(Evas_Object* view) + { + return adoptPtr(new PageLoadClientEfl(view)); + } + +private: + explicit PageLoadClientEfl(Evas_Object* view); + + inline Evas_Object* view() const { return m_view; } + + static void didReceiveTitleForFrame(WKPageRef, WKStringRef title, WKFrameRef, WKTypeRef, const void* clientInfo); +#if ENABLE(WEB_INTENTS) + static void didReceiveIntentForFrame(WKPageRef, WKFrameRef, WKIntentDataRef, WKTypeRef, const void* clientInfo); +#endif +#if ENABLE(WEB_INTENTS_TAG) + static void registerIntentServiceForFrame(WKPageRef, WKFrameRef, WKIntentServiceInfoRef, WKTypeRef, const void* clientInfo); +#endif + static void didChangeProgress(WKPageRef, const void* clientInfo); + static void didFinishLoadForFrame(WKPageRef, WKFrameRef, WKTypeRef userData, const void* clientInfo); + static void didFailLoadWithErrorForFrame(WKPageRef, WKFrameRef, WKErrorRef, WKTypeRef userData, const void* clientInfo); + static void didStartProvisionalLoadForFrame(WKPageRef, WKFrameRef, WKTypeRef userData, const void* clientInfo); + static void didReceiveServerRedirectForProvisionalLoadForFrame(WKPageRef, WKFrameRef, WKTypeRef userData, const void* clientInfo); + static void didFailProvisionalLoadWithErrorForFrame(WKPageRef, WKFrameRef, WKErrorRef, WKTypeRef userData, const void* clientInfo); + static void didChangeBackForwardList(WKPageRef, WKBackForwardListItemRef addedItem, WKArrayRef removedItems, const void* clientInfo); + static void didSameDocumentNavigationForFrame(WKPageRef, WKFrameRef, WKSameDocumentNavigationType, WKTypeRef, const void* clientInfo); + + Evas_Object* m_view; +}; + +} // namespace WebKit + +#endif // PageLoadClientEfl_h diff --git a/Source/WebKit2/UIProcess/efl/ResourceLoadClientEfl.cpp b/Source/WebKit2/UIProcess/efl/ResourceLoadClientEfl.cpp new file mode 100644 index 000000000..6539cce36 --- /dev/null +++ b/Source/WebKit2/UIProcess/efl/ResourceLoadClientEfl.cpp @@ -0,0 +1,149 @@ +/* + * Copyright (C) 2012 Intel Corporation. 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. + */ + +#include "config.h" +#include "ResourceLoadClientEfl.h" + +#include "WKAPICast.h" +#include "WKFrame.h" +#include "WKPage.h" +#include "WKRetainPtr.h" +#include "ewk_error_private.h" +#include "ewk_url_request_private.h" +#include "ewk_url_response_private.h" + +using namespace WebCore; + +namespace WebKit { + +static inline ResourceLoadClientEfl* toResourceLoadClientEfl(const void* clientInfo) +{ + return static_cast<ResourceLoadClientEfl*>(const_cast<void*>(clientInfo)); +} + +void ResourceLoadClientEfl::didInitiateLoadForResource(WKPageRef, WKFrameRef wkFrame, uint64_t resourceIdentifier, WKURLRequestRef wkRequest, bool pageIsProvisionallyLoading, const void* clientInfo) +{ + ResourceLoadClientEfl* resourceLoadClient = toResourceLoadClientEfl(clientInfo); + bool isMainResource = (WKFrameIsMainFrame(wkFrame) && pageIsProvisionallyLoading); + WKRetainPtr<WKURLRef> wkUrl(AdoptWK, WKURLRequestCopyURL(wkRequest)); + + RefPtr<Ewk_Resource> resource = Ewk_Resource::create(wkUrl.get(), isMainResource); + + // Keep the resource internally to reuse it later. + resourceLoadClient->m_loadingResourcesMap.add(resourceIdentifier, resource); + + RefPtr<Ewk_Url_Request> request = Ewk_Url_Request::create(wkRequest); + ewk_view_resource_load_initiated(resourceLoadClient->m_view, resource.get(), request.get()); +} + +void ResourceLoadClientEfl::didSendRequestForResource(WKPageRef, WKFrameRef, uint64_t resourceIdentifier, WKURLRequestRef wkRequest, WKURLResponseRef wkRedirectResponse, const void* clientInfo) +{ + ResourceLoadClientEfl* resourceLoadClient = toResourceLoadClientEfl(clientInfo); + + RefPtr<Ewk_Resource> resource = resourceLoadClient->m_loadingResourcesMap.get(resourceIdentifier); + // Only process if we know about this resource. + if (!resource) + return; + + RefPtr<Ewk_Url_Request> request = Ewk_Url_Request::create(wkRequest); + RefPtr<Ewk_Url_Response> redirectResponse = Ewk_Url_Response::create(wkRedirectResponse); + ewk_view_resource_request_sent(resourceLoadClient->m_view, resource.get(), request.get(), redirectResponse.get()); +} + +void ResourceLoadClientEfl::didReceiveResponseForResource(WKPageRef, WKFrameRef, uint64_t resourceIdentifier, WKURLResponseRef wkResponse, const void* clientInfo) +{ + ResourceLoadClientEfl* resourceLoadClient = toResourceLoadClientEfl(clientInfo); + + RefPtr<Ewk_Resource> resource = resourceLoadClient->m_loadingResourcesMap.get(resourceIdentifier); + // Only process if we know about this resource. + if (!resource) + return; + + RefPtr<Ewk_Url_Response> response = Ewk_Url_Response::create(wkResponse); + ewk_view_resource_load_response(resourceLoadClient->m_view, resource.get(), response.get()); +} + +void ResourceLoadClientEfl::didFinishLoadForResource(WKPageRef, WKFrameRef, uint64_t resourceIdentifier, const void* clientInfo) +{ + ResourceLoadClientEfl* resourceLoadClient = toResourceLoadClientEfl(clientInfo); + + RefPtr<Ewk_Resource> resource = resourceLoadClient->m_loadingResourcesMap.get(resourceIdentifier); + // Only process if we know about this resource. + if (!resource) + return; + + ewk_view_resource_load_finished(resourceLoadClient->m_view, resource.get()); +} + +void ResourceLoadClientEfl::didFailLoadForResource(WKPageRef, WKFrameRef, uint64_t resourceIdentifier, WKErrorRef wkError, const void* clientInfo) +{ + ResourceLoadClientEfl* resourceLoadClient = toResourceLoadClientEfl(clientInfo); + + RefPtr<Ewk_Resource> resource = resourceLoadClient->m_loadingResourcesMap.take(resourceIdentifier); + // Only process if we know about this resource. + if (!resource) + return; + + OwnPtr<Ewk_Error> ewkError = Ewk_Error::create(wkError); + ewk_view_resource_load_failed(resourceLoadClient->m_view, resource.get(), ewkError.get()); + ewk_view_resource_load_finished(resourceLoadClient->m_view, resource.get()); +} + +void ResourceLoadClientEfl::onViewProvisionalLoadStarted(void* userData, Evas_Object*, void*) +{ + ResourceLoadClientEfl* resourceLoadClient = toResourceLoadClientEfl(userData); + + // The view started a new load, clear internal resource map. + resourceLoadClient->m_loadingResourcesMap.clear(); +} + +ResourceLoadClientEfl::ResourceLoadClientEfl(Evas_Object* view) + : m_view(view) +{ + // Listen for "load,provisional,started" on the view to clear internal resources map. + evas_object_smart_callback_add(m_view, "load,provisional,started", onViewProvisionalLoadStarted, this); + + WKPageRef pageRef = ewk_view_wkpage_get(m_view); + ASSERT(pageRef); + + WKPageResourceLoadClient wkResourceLoadClient; + memset(&wkResourceLoadClient, 0, sizeof(WKPageResourceLoadClient)); + wkResourceLoadClient.version = kWKPageResourceLoadClientCurrentVersion; + wkResourceLoadClient.clientInfo = this; + wkResourceLoadClient.didInitiateLoadForResource = didInitiateLoadForResource; + wkResourceLoadClient.didSendRequestForResource = didSendRequestForResource; + wkResourceLoadClient.didReceiveResponseForResource = didReceiveResponseForResource; + wkResourceLoadClient.didFinishLoadForResource = didFinishLoadForResource; + wkResourceLoadClient.didFailLoadForResource = didFailLoadForResource; + + WKPageSetPageResourceLoadClient(pageRef, &wkResourceLoadClient); +} + +ResourceLoadClientEfl::~ResourceLoadClientEfl() +{ + evas_object_smart_callback_del(m_view, "load,provisional,started", onViewProvisionalLoadStarted); +} + +} // namespace WebKit diff --git a/Source/WebKit2/UIProcess/efl/ResourceLoadClientEfl.h b/Source/WebKit2/UIProcess/efl/ResourceLoadClientEfl.h new file mode 100644 index 000000000..58f52b4b7 --- /dev/null +++ b/Source/WebKit2/UIProcess/efl/ResourceLoadClientEfl.h @@ -0,0 +1,62 @@ +/* + * Copyright (C) 2012 Intel Corporation. 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 ResourceLoadClientEfl_h +#define ResourceLoadClientEfl_h + +#include "ewk_resource_private.h" +#include "ewk_view_private.h" +#include <wtf/HashMap.h> +#include <wtf/PassOwnPtr.h> + +namespace WebKit { + +class ResourceLoadClientEfl { +public: + ~ResourceLoadClientEfl(); + + static PassOwnPtr<ResourceLoadClientEfl> create(Evas_Object* view) + { + return adoptPtr(new ResourceLoadClientEfl(view)); + } + +private: + explicit ResourceLoadClientEfl(Evas_Object* view); + + static void didInitiateLoadForResource(WKPageRef, WKFrameRef, uint64_t resourceIdentifier, WKURLRequestRef, bool pageIsProvisionallyLoading, const void* clientInfo); + static void didSendRequestForResource(WKPageRef, WKFrameRef, uint64_t resourceIdentifier, WKURLRequestRef, WKURLResponseRef, const void* clientInfo); + static void didReceiveResponseForResource(WKPageRef, WKFrameRef, uint64_t resourceIdentifier, WKURLResponseRef, const void* clientInfo); + static void didFinishLoadForResource(WKPageRef, WKFrameRef, uint64_t resourceIdentifier, const void* clientInfo); + static void didFailLoadForResource(WKPageRef, WKFrameRef, uint64_t resourceIdentifier, WKErrorRef, const void* clientInfo); + + static void onViewProvisionalLoadStarted(void* userData, Evas_Object* view, void* clientInfo); + + Evas_Object* m_view; + HashMap< uint64_t, RefPtr<Ewk_Resource> > m_loadingResourcesMap; +}; + +} // namespace WebKit + +#endif // ResourceLoadClientEfl_h diff --git a/Source/WebKit2/UIProcess/soup/WebSoupRequestManagerProxy.cpp b/Source/WebKit2/UIProcess/soup/WebSoupRequestManagerProxy.cpp index 679be2bed..33698cd7c 100644 --- a/Source/WebKit2/UIProcess/soup/WebSoupRequestManagerProxy.cpp +++ b/Source/WebKit2/UIProcess/soup/WebSoupRequestManagerProxy.cpp @@ -23,6 +23,7 @@ #include "WebContext.h" #include "WebData.h" #include "WebSoupRequestManagerMessages.h" +#include "WebSoupRequestManagerProxyMessages.h" namespace WebKit { @@ -35,7 +36,7 @@ WebSoupRequestManagerProxy::WebSoupRequestManagerProxy(WebContext* context) : m_webContext(context) , m_loadFailed(false) { - m_webContext->deprecatedAddMessageReceiver(CoreIPC::MessageClassWebSoupRequestManagerProxy, this); + m_webContext->addMessageReceiver(Messages::WebSoupRequestManagerProxy::messageReceiverName(), this); } WebSoupRequestManagerProxy::~WebSoupRequestManagerProxy() diff --git a/Source/WebKit2/WebKit2.xcodeproj/project.pbxproj b/Source/WebKit2/WebKit2.xcodeproj/project.pbxproj index 6c87cde72..9b5ac7bcc 100644 --- a/Source/WebKit2/WebKit2.xcodeproj/project.pbxproj +++ b/Source/WebKit2/WebKit2.xcodeproj/project.pbxproj @@ -70,6 +70,8 @@ 1A0F29E3120B44420053D1B9 /* VisitedLinkProvider.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 1A0F29E1120B44420053D1B9 /* VisitedLinkProvider.cpp */; }; 1A0F29E4120B44420053D1B9 /* VisitedLinkProvider.h in Headers */ = {isa = PBXBuildFile; fileRef = 1A0F29E2120B44420053D1B9 /* VisitedLinkProvider.h */; }; 1A119A95127B796200A9ECB1 /* MessageSender.h in Headers */ = {isa = PBXBuildFile; fileRef = 1A119A94127B796200A9ECB1 /* MessageSender.h */; }; + 1A13BEB31635A9C800F19C03 /* StringReference.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 1A13BEB11635A9C800F19C03 /* StringReference.cpp */; }; + 1A13BEB41635A9C800F19C03 /* StringReference.h in Headers */ = {isa = PBXBuildFile; fileRef = 1A13BEB21635A9C800F19C03 /* StringReference.h */; }; 1A17977F137EE82C00F97D45 /* PluginCreationParameters.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 1A17977D137EE82C00F97D45 /* PluginCreationParameters.cpp */; }; 1A179780137EE82C00F97D45 /* PluginCreationParameters.h in Headers */ = {isa = PBXBuildFile; fileRef = 1A17977E137EE82C00F97D45 /* PluginCreationParameters.h */; }; 1A186EEA12EF7618008E5F37 /* LayerTreeHost.h in Headers */ = {isa = PBXBuildFile; fileRef = 1A186EE812EF7618008E5F37 /* LayerTreeHost.h */; }; @@ -1200,6 +1202,8 @@ 1A0F29E1120B44420053D1B9 /* VisitedLinkProvider.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = VisitedLinkProvider.cpp; sourceTree = "<group>"; }; 1A0F29E2120B44420053D1B9 /* VisitedLinkProvider.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = VisitedLinkProvider.h; sourceTree = "<group>"; }; 1A119A94127B796200A9ECB1 /* MessageSender.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = MessageSender.h; sourceTree = "<group>"; }; + 1A13BEB11635A9C800F19C03 /* StringReference.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = StringReference.cpp; sourceTree = "<group>"; }; + 1A13BEB21635A9C800F19C03 /* StringReference.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = StringReference.h; sourceTree = "<group>"; }; 1A17977D137EE82C00F97D45 /* PluginCreationParameters.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = PluginCreationParameters.cpp; sourceTree = "<group>"; }; 1A17977E137EE82C00F97D45 /* PluginCreationParameters.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = PluginCreationParameters.h; sourceTree = "<group>"; }; 1A186EE812EF7618008E5F37 /* LayerTreeHost.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = LayerTreeHost.h; sourceTree = "<group>"; }; @@ -2820,6 +2824,8 @@ 1A3EED0C161A535300AEB4F5 /* MessageReceiverMap.cpp */, 1A3EED0D161A535300AEB4F5 /* MessageReceiverMap.h */, 1A119A94127B796200A9ECB1 /* MessageSender.h */, + 1A13BEB11635A9C800F19C03 /* StringReference.cpp */, + 1A13BEB21635A9C800F19C03 /* StringReference.h */, ); path = CoreIPC; sourceTree = "<group>"; @@ -4736,6 +4742,7 @@ 5105B0DE162F7E9D00E27709 /* NetworkProcessManager.h in Headers */, 513A163D163088F6005D7D22 /* NetworkProcessProxyMessages.h in Headers */, 513A164D1630A9BF005D7D22 /* NetworkConnectionToWebProcess.h in Headers */, + 1A13BEB41635A9C800F19C03 /* StringReference.h in Headers */, ); runOnlyForDeploymentPostprocessing = 0; }; @@ -5686,6 +5693,7 @@ 513A163C163088F6005D7D22 /* NetworkProcessProxyMessageReceiver.cpp in Sources */, 513A164C1630A9BF005D7D22 /* NetworkConnectionToWebProcess.cpp in Sources */, 5183DDEC1630BDFC008BE5C7 /* NetworkProcessConnection.cpp in Sources */, + 1A13BEB31635A9C800F19C03 /* StringReference.cpp in Sources */, ); runOnlyForDeploymentPostprocessing = 0; }; diff --git a/Source/WebKit2/WebProcess/Authentication/AuthenticationManager.cpp b/Source/WebKit2/WebProcess/Authentication/AuthenticationManager.cpp index f5d8e62f4..3850e644a 100644 --- a/Source/WebKit2/WebProcess/Authentication/AuthenticationManager.cpp +++ b/Source/WebKit2/WebProcess/Authentication/AuthenticationManager.cpp @@ -26,6 +26,7 @@ #include "config.h" #include "AuthenticationManager.h" +#include "AuthenticationManagerMessages.h" #include "Download.h" #include "DownloadProxyMessages.h" #include "MessageID.h" @@ -55,7 +56,7 @@ AuthenticationManager& AuthenticationManager::shared() AuthenticationManager::AuthenticationManager() { - WebProcess::shared().connection()->deprecatedAddMessageReceiver(CoreIPC::MessageClassAuthenticationManager, this); + WebProcess::shared().addMessageReceiver(Messages::AuthenticationManager::messageReceiverName(), this); } void AuthenticationManager::didReceiveMessage(CoreIPC::Connection* connection, CoreIPC::MessageID messageID, CoreIPC::MessageDecoder& decoder) diff --git a/Source/WebKit2/WebProcess/Geolocation/WebGeolocationManager.cpp b/Source/WebKit2/WebProcess/Geolocation/WebGeolocationManager.cpp index 4bd627c2f..46b846b4a 100644 --- a/Source/WebKit2/WebProcess/Geolocation/WebGeolocationManager.cpp +++ b/Source/WebKit2/WebProcess/Geolocation/WebGeolocationManager.cpp @@ -26,6 +26,7 @@ #include "config.h" #include "WebGeolocationManager.h" +#include "WebGeolocationManagerMessages.h" #include "WebGeolocationManagerProxyMessages.h" #include "WebPage.h" #include "WebProcess.h" @@ -41,8 +42,8 @@ namespace WebKit { WebGeolocationManager::WebGeolocationManager(WebProcess* process) : m_process(process) - , m_didAddMessageReceiver(false) { + m_process->addMessageReceiver(Messages::WebGeolocationManager::messageReceiverName(), this); } WebGeolocationManager::~WebGeolocationManager() @@ -56,11 +57,6 @@ void WebGeolocationManager::didReceiveMessage(CoreIPC::Connection* connection, C void WebGeolocationManager::registerWebPage(WebPage* page) { - if (!m_didAddMessageReceiver) { - m_process->connection()->deprecatedAddMessageReceiver(CoreIPC::MessageClassWebGeolocationManager, this); - m_didAddMessageReceiver = true; - } - bool wasEmpty = m_pageSet.isEmpty(); m_pageSet.add(page); diff --git a/Source/WebKit2/WebProcess/Geolocation/WebGeolocationManager.h b/Source/WebKit2/WebProcess/Geolocation/WebGeolocationManager.h index 6e245570d..6f5d83fe2 100644 --- a/Source/WebKit2/WebProcess/Geolocation/WebGeolocationManager.h +++ b/Source/WebKit2/WebProcess/Geolocation/WebGeolocationManager.h @@ -64,7 +64,6 @@ private: void didFailToDeterminePosition(const String& errorMessage); WebProcess* m_process; - bool m_didAddMessageReceiver; HashSet<WebPage*> m_pageSet; }; diff --git a/Source/WebKit2/WebProcess/InjectedBundle/InjectedBundle.cpp b/Source/WebKit2/WebProcess/InjectedBundle/InjectedBundle.cpp index 458b1c169..4d0aa56a3 100644 --- a/Source/WebKit2/WebProcess/InjectedBundle/InjectedBundle.cpp +++ b/Source/WebKit2/WebProcess/InjectedBundle/InjectedBundle.cpp @@ -93,20 +93,27 @@ void InjectedBundle::initializeClient(WKBundleClient* client) void InjectedBundle::postMessage(const String& messageName, APIObject* messageBody) { - WebProcess::shared().connection()->deprecatedSend(WebContextLegacyMessage::PostMessage, 0, CoreIPC::In(messageName, InjectedBundleUserMessageEncoder(messageBody))); + OwnPtr<CoreIPC::MessageEncoder> encoder = CoreIPC::MessageEncoder::create(CoreIPC::MessageKindTraits<WebContextLegacyMessage::Kind>::messageReceiverName(), "", 0); + encoder->encode(messageName); + encoder->encode(InjectedBundleUserMessageEncoder(messageBody)); + + WebProcess::shared().connection()->sendMessage(CoreIPC::MessageID(WebContextLegacyMessage::PostMessage), encoder.release()); } void InjectedBundle::postSynchronousMessage(const String& messageName, APIObject* messageBody, RefPtr<APIObject>& returnData) { - RefPtr<APIObject> returnDataTmp; - InjectedBundleUserMessageDecoder messageDecoder(returnDataTmp); - - bool succeeded = WebProcess::shared().connection()->deprecatedSendSync(WebContextLegacyMessage::PostSynchronousMessage, 0, CoreIPC::In(messageName, InjectedBundleUserMessageEncoder(messageBody)), CoreIPC::Out(messageDecoder)); + InjectedBundleUserMessageDecoder messageDecoder(returnData); - if (!succeeded) - return; + uint64_t syncRequestID; + OwnPtr<CoreIPC::MessageEncoder> encoder = WebProcess::shared().connection()->createSyncMessageEncoder(CoreIPC::MessageKindTraits<WebContextLegacyMessage::Kind>::messageReceiverName(), "", 0, syncRequestID); + encoder->encode(messageName); + encoder->encode(InjectedBundleUserMessageEncoder(messageBody)); - returnData = returnDataTmp; + OwnPtr<CoreIPC::MessageDecoder> replyDecoder = WebProcess::shared().connection()->sendSyncMessage(CoreIPC::MessageID(WebContextLegacyMessage::PostSynchronousMessage), syncRequestID, encoder.release(), CoreIPC::Connection::NoTimeout); + if (!replyDecoder || !replyDecoder->decode(messageDecoder)) { + returnData = nullptr; + return; + } } WebConnection* InjectedBundle::webConnectionToUIProcess() const diff --git a/Source/WebKit2/WebProcess/WebConnectionToUIProcess.cpp b/Source/WebKit2/WebProcess/WebConnectionToUIProcess.cpp index e39ba39d2..538007d4f 100644 --- a/Source/WebKit2/WebProcess/WebConnectionToUIProcess.cpp +++ b/Source/WebKit2/WebProcess/WebConnectionToUIProcess.cpp @@ -56,10 +56,8 @@ void WebConnectionToUIProcess::encodeMessageBody(CoreIPC::ArgumentEncoder& encod bool WebConnectionToUIProcess::decodeMessageBody(CoreIPC::ArgumentDecoder& decoder, RefPtr<APIObject>& messageBody) { - if (!decoder.decode(InjectedBundleUserMessageDecoder(messageBody))) - return false; - - return true; + InjectedBundleUserMessageDecoder messageBodyDecoder(messageBody); + return decoder.decode(messageBodyDecoder); } // CoreIPC::Connection::Client diff --git a/Source/WebKit2/WebProcess/WebPage/WebPage.cpp b/Source/WebKit2/WebProcess/WebPage/WebPage.cpp index 1afe3e324..3d8583d8d 100644 --- a/Source/WebKit2/WebProcess/WebPage/WebPage.cpp +++ b/Source/WebKit2/WebProcess/WebPage/WebPage.cpp @@ -1222,7 +1222,8 @@ void WebPage::postInjectedBundleMessage(const String& messageName, CoreIPC::Mess return; RefPtr<APIObject> messageBody; - if (!decoder.decode(InjectedBundleUserMessageDecoder(messageBody))) + InjectedBundleUserMessageDecoder messageBodyDecoder(messageBody); + if (!decoder.decode(messageBodyDecoder)) return; injectedBundle->didReceiveMessageToPage(this, messageName, messageBody.get()); diff --git a/Source/WebKit2/WebProcess/WebProcess.cpp b/Source/WebKit2/WebProcess/WebProcess.cpp index 43e7d7021..33be75989 100644 --- a/Source/WebKit2/WebProcess/WebProcess.cpp +++ b/Source/WebKit2/WebProcess/WebProcess.cpp @@ -194,6 +194,11 @@ void WebProcess::initialize(CoreIPC::Connection::Identifier serverIdentifier, Ru startRandomCrashThreadIfRequested(); } +void WebProcess::addMessageReceiver(CoreIPC::StringReference messageReceiverName, CoreIPC::MessageReceiver* messageReceiver) +{ + m_messageReceiverMap.addMessageReceiver(messageReceiverName, messageReceiver); +} + void WebProcess::initializeWebProcess(const WebProcessCreationParameters& parameters, CoreIPC::MessageDecoder& decoder) { ASSERT(m_pageMap.isEmpty()); @@ -645,7 +650,10 @@ void WebProcess::terminate() } void WebProcess::didReceiveSyncMessage(CoreIPC::Connection* connection, CoreIPC::MessageID messageID, CoreIPC::MessageDecoder& decoder, OwnPtr<CoreIPC::MessageEncoder>& replyEncoder) -{ +{ + if (m_messageReceiverMap.dispatchSyncMessage(connection, messageID, decoder, replyEncoder)) + return; + uint64_t pageID = decoder.destinationID(); if (!pageID) return; @@ -659,6 +667,9 @@ void WebProcess::didReceiveSyncMessage(CoreIPC::Connection* connection, CoreIPC: void WebProcess::didReceiveMessage(CoreIPC::Connection* connection, CoreIPC::MessageID messageID, CoreIPC::MessageDecoder& decoder) { + if (m_messageReceiverMap.dispatchMessage(connection, messageID, decoder)) + return; + if (messageID.is<CoreIPC::MessageClassWebProcess>()) { didReceiveWebProcessMessage(connection, messageID, decoder); return; @@ -1056,7 +1067,8 @@ void WebProcess::postInjectedBundleMessage(const CoreIPC::DataReference& message return; RefPtr<APIObject> messageBody; - if (!decoder->decode(InjectedBundleUserMessageDecoder(messageBody))) + InjectedBundleUserMessageDecoder messageBodyDecoder(messageBody); + if (!decoder->decode(messageBodyDecoder)) return; injectedBundle->didReceiveMessage(messageName, messageBody.get()); diff --git a/Source/WebKit2/WebProcess/WebProcess.h b/Source/WebKit2/WebProcess/WebProcess.h index ac6455250..88b5f5799 100644 --- a/Source/WebKit2/WebProcess/WebProcess.h +++ b/Source/WebKit2/WebProcess/WebProcess.h @@ -30,6 +30,7 @@ #include "ChildProcess.h" #include "DrawingArea.h" #include "EventDispatcher.h" +#include "MessageReceiverMap.h" #include "PluginInfoStore.h" #include "ResourceCachesToClear.h" #include "SandboxExtension.h" @@ -113,6 +114,8 @@ public: CoreIPC::Connection* connection() const { return m_connection->connection(); } WebCore::RunLoop* runLoop() const { return m_runLoop; } + void addMessageReceiver(CoreIPC::StringReference messageReceiverName, CoreIPC::MessageReceiver*); + WebConnectionToUIProcess* webConnectionToUIProcess() const { return m_connection.get(); } WebPage* webPage(uint64_t pageID) const; @@ -292,6 +295,7 @@ private: #endif RefPtr<WebConnectionToUIProcess> m_connection; + CoreIPC::MessageReceiverMap m_messageReceiverMap; HashMap<uint64_t, RefPtr<WebPage> > m_pageMap; HashMap<uint64_t, RefPtr<WebPageGroupProxy> > m_pageGroupMap; diff --git a/Source/WebKit2/win/WebKit2.vcproj b/Source/WebKit2/win/WebKit2.vcproj index 6397b4412..064ae8516 100755 --- a/Source/WebKit2/win/WebKit2.vcproj +++ b/Source/WebKit2/win/WebKit2.vcproj @@ -4129,6 +4129,14 @@ RelativePath="..\Platform\CoreIPC\MessageSender.h"
>
</File>
+ <File
+ RelativePath="..\Platform\CoreIPC\StringReference.cpp"
+ >
+ </File>
+ <File
+ RelativePath="..\Platform\CoreIPC\StringReference.h"
+ >
+ </File>
<Filter
Name="win"
>
|
