diff options
Diffstat (limited to 'Source/WebKit2/WebProcess')
109 files changed, 3442 insertions, 781 deletions
diff --git a/Source/WebKit2/WebProcess/Authentication/AuthenticationManager.cpp b/Source/WebKit2/WebProcess/Authentication/AuthenticationManager.cpp index 44e8306e0..a6858ac28 100644 --- a/Source/WebKit2/WebProcess/Authentication/AuthenticationManager.cpp +++ b/Source/WebKit2/WebProcess/Authentication/AuthenticationManager.cpp @@ -55,6 +55,7 @@ AuthenticationManager& AuthenticationManager::shared() AuthenticationManager::AuthenticationManager() { + WebProcess::shared().connection()->addMessageReceiver(CoreIPC::MessageClassAuthenticationManager, this); } void AuthenticationManager::didReceiveMessage(CoreIPC::Connection* connection, CoreIPC::MessageID messageID, CoreIPC::ArgumentDecoder* arguments) diff --git a/Source/WebKit2/WebProcess/Authentication/AuthenticationManager.h b/Source/WebKit2/WebProcess/Authentication/AuthenticationManager.h index 192c91aef..93afe446b 100644 --- a/Source/WebKit2/WebProcess/Authentication/AuthenticationManager.h +++ b/Source/WebKit2/WebProcess/Authentication/AuthenticationManager.h @@ -26,6 +26,7 @@ #ifndef AuthenticationManager_h #define AuthenticationManager_h +#include "MessageReceiver.h" #include <wtf/HashMap.h> namespace CoreIPC { @@ -45,14 +46,12 @@ class Download; class PlatformCertificateInfo; class WebFrame; -class AuthenticationManager { +class AuthenticationManager : private CoreIPC::MessageReceiver { WTF_MAKE_NONCOPYABLE(AuthenticationManager); public: static AuthenticationManager& shared(); - void didReceiveMessage(CoreIPC::Connection*, CoreIPC::MessageID, CoreIPC::ArgumentDecoder*); - void didReceiveAuthenticationChallenge(WebFrame*, const WebCore::AuthenticationChallenge&); void didReceiveAuthenticationChallenge(Download*, const WebCore::AuthenticationChallenge&); @@ -63,6 +62,8 @@ public: private: AuthenticationManager(); + // CoreIPC::MessageReceiver + virtual void didReceiveMessage(CoreIPC::Connection*, CoreIPC::MessageID, CoreIPC::ArgumentDecoder*) OVERRIDE; void didReceiveAuthenticationManagerMessage(CoreIPC::Connection*, CoreIPC::MessageID, CoreIPC::ArgumentDecoder*); bool tryUsePlatformCertificateInfoForChallenge(const WebCore::AuthenticationChallenge&, const PlatformCertificateInfo&); diff --git a/Source/WebKit2/WebProcess/Downloads/soup/DownloadSoup.cpp b/Source/WebKit2/WebProcess/Downloads/soup/DownloadSoup.cpp index 38117ebb3..ab4b6eee4 100644 --- a/Source/WebKit2/WebProcess/Downloads/soup/DownloadSoup.cpp +++ b/Source/WebKit2/WebProcess/Downloads/soup/DownloadSoup.cpp @@ -49,9 +49,16 @@ class DownloadClient : public ResourceHandleClient { public: DownloadClient(Download* download) : m_download(download) + , m_handleResponseLaterID(0) { } + ~DownloadClient() + { + if (m_handleResponseLaterID) + g_source_remove(m_handleResponseLaterID); + } + void downloadFailed(const ResourceError& error) { m_download->didFail(error, CoreIPC::DataReference()); @@ -96,11 +103,20 @@ public: return; } + GRefPtr<GFileInfo> info = adoptGRef(g_file_info_new()); + g_file_info_set_attribute_string(info.get(), "metadata::download-uri", response.url().string().utf8().data()); + g_file_set_attributes_async(file.get(), info.get(), G_FILE_QUERY_INFO_NONE, G_PRIORITY_DEFAULT, 0, 0, 0); + m_download->didCreateDestination(destinationURI); } void didReceiveData(ResourceHandle*, const char* data, int length, int /*encodedDataLength*/) { + if (m_handleResponseLaterID) { + g_source_remove(m_handleResponseLaterID); + handleResponse(); + } + gsize bytesWritten; GOwnPtr<GError> error; g_output_stream_write_all(G_OUTPUT_STREAM(m_outputStream.get()), data, length, &bytesWritten, 0, &error.outPtr()); @@ -132,9 +148,35 @@ public: notImplemented(); } + void handleResponse() + { + m_handleResponseLaterID = 0; + didReceiveResponse(0, m_delayedResponse); + } + + static gboolean handleResponseLaterCallback(DownloadClient* downloadClient) + { + downloadClient->handleResponse(); + return FALSE; + } + + void handleResponseLater(const ResourceResponse& response) + { + ASSERT(!m_response); + ASSERT(!m_handleResponseLaterID); + + m_delayedResponse = response; + + // Call didReceiveResponse in an idle to make sure the download is added + // to the DownloadManager downloads map. + m_handleResponseLaterID = g_idle_add_full(G_PRIORITY_DEFAULT, reinterpret_cast<GSourceFunc>(handleResponseLaterCallback), this, 0); + } + Download* m_download; GRefPtr<GFileOutputStream> m_outputStream; GRefPtr<SoupMessage> m_response; + ResourceResponse m_delayedResponse; + unsigned m_handleResponseLaterID; }; void Download::start(WebPage*) @@ -146,7 +188,7 @@ void Download::start(WebPage*) didStart(); } -void Download::startWithHandle(WebPage*, ResourceHandle* resourceHandle, const ResourceResponse&) +void Download::startWithHandle(WebPage*, ResourceHandle* resourceHandle, const ResourceResponse& response) { ASSERT(!m_downloadClient); ASSERT(!m_resourceHandle); @@ -154,10 +196,7 @@ void Download::startWithHandle(WebPage*, ResourceHandle* resourceHandle, const R resourceHandle->setClient(m_downloadClient.get()); m_resourceHandle = resourceHandle; didStart(); - // If the handle already got a response, make sure the download client is notified. - ResourceHandleInternal* handleInternal = m_resourceHandle->getInternal(); - if (!handleInternal->m_response.isNull()) - m_downloadClient->didReceiveResponse(m_resourceHandle.get(), handleInternal->m_response); + static_cast<DownloadClient*>(m_downloadClient.get())->handleResponseLater(response); } void Download::cancel() diff --git a/Source/WebKit2/WebProcess/FullScreen/WebFullScreenManager.cpp b/Source/WebKit2/WebProcess/FullScreen/WebFullScreenManager.cpp index c5fc81a9e..1c7a78db0 100644 --- a/Source/WebKit2/WebProcess/FullScreen/WebFullScreenManager.cpp +++ b/Source/WebKit2/WebProcess/FullScreen/WebFullScreenManager.cpp @@ -52,7 +52,7 @@ static IntRect screenRectOfContents(Element* element) #if USE(ACCELERATED_COMPOSITING) if (element->renderer() && element->renderer()->hasLayer() && element->renderer()->enclosingLayer()->isComposited()) { FloatQuad contentsBox = static_cast<FloatRect>(element->renderer()->enclosingLayer()->backing()->contentsBox()); - contentsBox = element->renderer()->localToAbsoluteQuad(contentsBox); + contentsBox = element->renderer()->localToAbsoluteQuad(contentsBox, SnapOffsetForTransforms); return element->renderer()->view()->frameView()->contentsToScreen(contentsBox.enclosingBoundingBox()); } #endif diff --git a/Source/WebKit2/WebProcess/Geolocation/GeolocationPermissionRequestManager.cpp b/Source/WebKit2/WebProcess/Geolocation/GeolocationPermissionRequestManager.cpp index 7013fcdc6..0d110c53a 100644 --- a/Source/WebKit2/WebProcess/Geolocation/GeolocationPermissionRequestManager.cpp +++ b/Source/WebKit2/WebProcess/Geolocation/GeolocationPermissionRequestManager.cpp @@ -73,7 +73,7 @@ void GeolocationPermissionRequestManager::cancelRequestForGeolocation(Geolocatio if (it == m_geolocationToIDMap.end()) return; - uint64_t geolocationID = it->second; + uint64_t geolocationID = it->value; m_geolocationToIDMap.remove(it); m_idToGeolocationMap.remove(geolocationID); } @@ -84,7 +84,7 @@ void GeolocationPermissionRequestManager::didReceiveGeolocationPermissionDecisio if (it == m_idToGeolocationMap.end()) return; - Geolocation* geolocation = it->second; + Geolocation* geolocation = it->value; geolocation->setIsAllowed(allowed); m_idToGeolocationMap.remove(it); diff --git a/Source/WebKit2/WebProcess/Geolocation/WebGeolocationManager.cpp b/Source/WebKit2/WebProcess/Geolocation/WebGeolocationManager.cpp index f07c4060d..2aec5a727 100644 --- a/Source/WebKit2/WebProcess/Geolocation/WebGeolocationManager.cpp +++ b/Source/WebKit2/WebProcess/Geolocation/WebGeolocationManager.cpp @@ -41,6 +41,7 @@ namespace WebKit { WebGeolocationManager::WebGeolocationManager(WebProcess* process) : m_process(process) + , m_didAddMessageReceiver(false) { } @@ -55,6 +56,11 @@ void WebGeolocationManager::didReceiveMessage(CoreIPC::Connection* connection, C void WebGeolocationManager::registerWebPage(WebPage* page) { + if (!m_didAddMessageReceiver) { + m_process->connection()->addMessageReceiver(CoreIPC::MessageClassWebGeolocationManager, this); + m_didAddMessageReceiver = true; + } + bool wasEmpty = m_pageSet.isEmpty(); m_pageSet.add(page); @@ -74,7 +80,7 @@ void WebGeolocationManager::unregisterWebPage(WebPage* page) void WebGeolocationManager::didChangePosition(const WebGeolocationPosition::Data& data) { #if ENABLE(GEOLOCATION) - RefPtr<GeolocationPosition> position = GeolocationPosition::create(data.timestamp, data.latitude, data.longitude, data.accuracy); + RefPtr<GeolocationPosition> position = GeolocationPosition::create(data.timestamp, data.latitude, data.longitude, data.accuracy, data.canProvideAltitude, data.altitude, data.canProvideAltitudeAccuracy, data.altitudeAccuracy, data.canProvideHeading, data.heading, data.canProvideSpeed, data.speed); Vector<RefPtr<WebPage> > webPageCopy; copyToVector(m_pageSet, webPageCopy); diff --git a/Source/WebKit2/WebProcess/Geolocation/WebGeolocationManager.h b/Source/WebKit2/WebProcess/Geolocation/WebGeolocationManager.h index 5c3dfae93..8a1405d14 100644 --- a/Source/WebKit2/WebProcess/Geolocation/WebGeolocationManager.h +++ b/Source/WebKit2/WebProcess/Geolocation/WebGeolocationManager.h @@ -26,31 +26,23 @@ #ifndef WebGeolocationManager_h #define WebGeolocationManager_h -#include "MessageID.h" +#include "MessageReceiver.h" #include "WebGeolocationPosition.h" -#include <wtf/HashSet.h> +#include <wtf/Forward.h> #include <wtf/HashMap.h> +#include <wtf/HashSet.h> #include <wtf/Noncopyable.h> -namespace CoreIPC { -class ArgumentDecoder; -class Connection; -} - namespace WebCore { class Geolocation; } -namespace WTF { -class String; -} - namespace WebKit { class WebProcess; class WebPage; -class WebGeolocationManager { +class WebGeolocationManager : private CoreIPC::MessageReceiver { WTF_MAKE_NONCOPYABLE(WebGeolocationManager); public: explicit WebGeolocationManager(WebProcess*); @@ -61,16 +53,18 @@ public: void requestPermission(WebCore::Geolocation*); - void didReceiveMessage(CoreIPC::Connection*, CoreIPC::MessageID, CoreIPC::ArgumentDecoder*); - private: + // CoreIPC::MessageReceiver + virtual void didReceiveMessage(CoreIPC::Connection*, CoreIPC::MessageID, CoreIPC::ArgumentDecoder*) OVERRIDE; + // Implemented in generated WebGeolocationManagerMessageReceiver.cpp void didReceiveWebGeolocationManagerMessage(CoreIPC::Connection*, CoreIPC::MessageID, CoreIPC::ArgumentDecoder*); void didChangePosition(const WebGeolocationPosition::Data&); - void didFailToDeterminePosition(const WTF::String& errorMessage); + void didFailToDeterminePosition(const String& errorMessage); WebProcess* m_process; + bool m_didAddMessageReceiver; HashSet<WebPage*> m_pageSet; }; diff --git a/Source/WebKit2/WebProcess/InjectedBundle/API/c/WKBundle.cpp b/Source/WebKit2/WebProcess/InjectedBundle/API/c/WKBundle.cpp index 2085253ba..7210a9d9e 100644 --- a/Source/WebKit2/WebProcess/InjectedBundle/API/c/WKBundle.cpp +++ b/Source/WebKit2/WebProcess/InjectedBundle/API/c/WKBundle.cpp @@ -46,13 +46,13 @@ void WKBundleSetClient(WKBundleRef bundleRef, WKBundleClient * wkClient) void WKBundlePostMessage(WKBundleRef bundleRef, WKStringRef messageNameRef, WKTypeRef messageBodyRef) { - toImpl(bundleRef)->postMessage(toImpl(messageNameRef)->string(), toImpl(messageBodyRef)); + toImpl(bundleRef)->postMessage(toWTFString(messageNameRef), toImpl(messageBodyRef)); } void WKBundlePostSynchronousMessage(WKBundleRef bundleRef, WKStringRef messageNameRef, WKTypeRef messageBodyRef, WKTypeRef* returnDataRef) { RefPtr<APIObject> returnData; - toImpl(bundleRef)->postSynchronousMessage(toImpl(messageNameRef)->string(), toImpl(messageBodyRef), returnData); + toImpl(bundleRef)->postSynchronousMessage(toWTFString(messageNameRef), toImpl(messageBodyRef), returnData); if (returnDataRef) *returnDataRef = toAPI(returnData.release().leakRef()); } @@ -134,7 +134,7 @@ void WKBundleRemoveAllUserContent(WKBundleRef bundleRef, WKBundlePageGroupRef pa void WKBundleOverrideBoolPreferenceForTestRunner(WKBundleRef bundleRef, WKBundlePageGroupRef pageGroupRef, WKStringRef preference, bool enabled) { - toImpl(bundleRef)->overrideBoolPreferenceForTestRunner(toImpl(pageGroupRef), toImpl(preference)->string(), enabled); + toImpl(bundleRef)->overrideBoolPreferenceForTestRunner(toImpl(pageGroupRef), toWTFString(preference), enabled); } void WKBundleSetAllowUniversalAccessFromFileURLs(WKBundleRef bundleRef, WKBundlePageGroupRef pageGroupRef, bool enabled) @@ -194,12 +194,12 @@ void WKBundleSetSpatialNavigationEnabled(WKBundleRef bundleRef, WKBundlePageGrou void WKBundleAddOriginAccessWhitelistEntry(WKBundleRef bundleRef, WKStringRef sourceOrigin, WKStringRef destinationProtocol, WKStringRef destinationHost, bool allowDestinationSubdomains) { - toImpl(bundleRef)->addOriginAccessWhitelistEntry(toImpl(sourceOrigin)->string(), toImpl(destinationProtocol)->string(), toImpl(destinationHost)->string(), allowDestinationSubdomains); + toImpl(bundleRef)->addOriginAccessWhitelistEntry(toWTFString(sourceOrigin), toWTFString(destinationProtocol), toWTFString(destinationHost), allowDestinationSubdomains); } void WKBundleRemoveOriginAccessWhitelistEntry(WKBundleRef bundleRef, WKStringRef sourceOrigin, WKStringRef destinationProtocol, WKStringRef destinationHost, bool allowDestinationSubdomains) { - toImpl(bundleRef)->removeOriginAccessWhitelistEntry(toImpl(sourceOrigin)->string(), toImpl(destinationProtocol)->string(), toImpl(destinationHost)->string(), allowDestinationSubdomains); + toImpl(bundleRef)->removeOriginAccessWhitelistEntry(toWTFString(sourceOrigin), toWTFString(destinationProtocol), toWTFString(destinationHost), allowDestinationSubdomains); } void WKBundleResetOriginAccessWhitelists(WKBundleRef bundleRef) @@ -229,7 +229,7 @@ void WKBundleClearApplicationCache(WKBundleRef bundleRef) void WKBundleClearApplicationCacheForOrigin(WKBundleRef bundleRef, WKStringRef origin) { - toImpl(bundleRef)->clearApplicationCacheForOrigin(toImpl(origin)->string()); + toImpl(bundleRef)->clearApplicationCacheForOrigin(toWTFString(origin)); } void WKBundleSetAppCacheMaximumSize(WKBundleRef bundleRef, uint64_t size) @@ -239,17 +239,17 @@ void WKBundleSetAppCacheMaximumSize(WKBundleRef bundleRef, uint64_t size) uint64_t WKBundleGetAppCacheUsageForOrigin(WKBundleRef bundleRef, WKStringRef origin) { - return toImpl(bundleRef)->appCacheUsageForOrigin(toImpl(origin)->string()); + return toImpl(bundleRef)->appCacheUsageForOrigin(toWTFString(origin)); } void WKBundleSetApplicationCacheOriginQuota(WKBundleRef bundleRef, WKStringRef origin, uint64_t bytes) { - toImpl(bundleRef)->setApplicationCacheOriginQuota(toImpl(origin)->string(), bytes); + toImpl(bundleRef)->setApplicationCacheOriginQuota(toWTFString(origin), bytes); } void WKBundleResetApplicationCacheOriginQuota(WKBundleRef bundleRef, WKStringRef origin) { - toImpl(bundleRef)->resetApplicationCacheOriginQuota(toImpl(origin)->string()); + toImpl(bundleRef)->resetApplicationCacheOriginQuota(toWTFString(origin)); } WKArrayRef WKBundleCopyOriginsWithApplicationCache(WKBundleRef bundleRef) @@ -270,7 +270,7 @@ int WKBundleNumberOfPages(WKBundleRef bundleRef, WKBundleFrameRef frameRef, doub int WKBundlePageNumberForElementById(WKBundleRef bundleRef, WKBundleFrameRef frameRef, WKStringRef idRef, double pageWidthInPixels, double pageHeightInPixels) { - return toImpl(bundleRef)->pageNumberForElementById(toImpl(frameRef), toImpl(idRef)->string(), pageWidthInPixels, pageHeightInPixels); + return toImpl(bundleRef)->pageNumberForElementById(toImpl(frameRef), toWTFString(idRef), pageWidthInPixels, pageHeightInPixels); } WKStringRef WKBundlePageSizeAndMarginsInPixels(WKBundleRef bundleRef, WKBundleFrameRef frameRef, int pageIndex, int width, int height, int marginTop, int marginRight, int marginBottom, int marginLeft) @@ -301,12 +301,12 @@ size_t WKBundleGetWorkerThreadCount(WKBundleRef) void WKBundleSetUserStyleSheetLocation(WKBundleRef bundleRef, WKBundlePageGroupRef pageGroupRef, WKStringRef location) { - toImpl(bundleRef)->setUserStyleSheetLocation(toImpl(pageGroupRef), toImpl(location)->string()); + toImpl(bundleRef)->setUserStyleSheetLocation(toImpl(pageGroupRef), toWTFString(location)); } void WKBundleSetWebNotificationPermission(WKBundleRef bundleRef, WKBundlePageRef pageRef, WKStringRef originStringRef, bool allowed) { - toImpl(bundleRef)->setWebNotificationPermission(toImpl(pageRef), toImpl(originStringRef)->string(), allowed); + toImpl(bundleRef)->setWebNotificationPermission(toImpl(pageRef), toWTFString(originStringRef), allowed); } void WKBundleRemoveAllWebNotificationPermissions(WKBundleRef bundleRef, WKBundlePageRef pageRef) @@ -323,3 +323,13 @@ void WKBundleSetTabKeyCyclesThroughElements(WKBundleRef bundleRef, WKBundlePageR { toImpl(bundleRef)->setTabKeyCyclesThroughElements(toImpl(pageRef), enabled); } + +void WKBundleSetSerialLoadingEnabled(WKBundleRef bundleRef, bool enabled) +{ + toImpl(bundleRef)->setSerialLoadingEnabled(enabled); +} + +void WKBundleDispatchPendingLoadRequests(WKBundleRef bundleRef) +{ + toImpl(bundleRef)->dispatchPendingLoadRequests(); +} diff --git a/Source/WebKit2/WebProcess/InjectedBundle/API/c/WKBundleAPICast.h b/Source/WebKit2/WebProcess/InjectedBundle/API/c/WKBundleAPICast.h index 018ef7970..59c3570bd 100644 --- a/Source/WebKit2/WebProcess/InjectedBundle/API/c/WKBundleAPICast.h +++ b/Source/WebKit2/WebProcess/InjectedBundle/API/c/WKBundleAPICast.h @@ -32,8 +32,6 @@ #include "WKBundlePrivate.h" #include <WebCore/EditorInsertAction.h> #include <WebCore/TextAffinity.h> -#include <WebCore/UserContentTypes.h> -#include <WebCore/UserScriptTypes.h> namespace WebCore { class CSSStyleDeclaration; @@ -107,32 +105,6 @@ inline WKAffinityType toAPI(WebCore::EAffinity affinity) return kWKAffinityUpstream; } -inline WebCore::UserScriptInjectionTime toUserScriptInjectionTime(WKUserScriptInjectionTime wkInjectedTime) -{ - switch (wkInjectedTime) { - case kWKInjectAtDocumentStart: - return WebCore::InjectAtDocumentStart; - case kWKInjectAtDocumentEnd: - return WebCore::InjectAtDocumentEnd; - } - - ASSERT_NOT_REACHED(); - return WebCore::InjectAtDocumentStart; -} - -inline WebCore::UserContentInjectedFrames toUserContentInjectedFrames(WKUserContentInjectedFrames wkInjectedFrames) -{ - switch (wkInjectedFrames) { - case kWKInjectInAllFrames: - return WebCore::InjectInAllFrames; - case kWKInjectInTopFrameOnly: - return WebCore::InjectInTopFrameOnly; - } - - ASSERT_NOT_REACHED(); - return WebCore::InjectInAllFrames; -} - } // namespace WebKit #endif // WKBundleAPICast_h diff --git a/Source/WebKit2/WebProcess/InjectedBundle/API/c/WKBundleFrame.cpp b/Source/WebKit2/WebProcess/InjectedBundle/API/c/WKBundleFrame.cpp index 9a2b9fc00..fe6d79ed8 100644 --- a/Source/WebKit2/WebProcess/InjectedBundle/API/c/WKBundleFrame.cpp +++ b/Source/WebKit2/WebProcess/InjectedBundle/API/c/WKBundleFrame.cpp @@ -97,12 +97,12 @@ unsigned WKBundleFrameGetNumberOfActiveAnimations(WKBundleFrameRef frameRef) bool WKBundleFramePauseAnimationOnElementWithId(WKBundleFrameRef frameRef, WKStringRef animationName, WKStringRef elementID, double time) { - return toImpl(frameRef)->pauseAnimationOnElementWithId(toImpl(animationName)->string(), toImpl(elementID)->string(), time); + return toImpl(frameRef)->pauseAnimationOnElementWithId(toWTFString(animationName), toWTFString(elementID), time); } bool WKBundleFramePauseTransitionOnElementWithId(WKBundleFrameRef frameRef, WKStringRef propertyName, WKStringRef elementID, double time) { - return toImpl(frameRef)->pauseTransitionOnElementWithId(toImpl(propertyName)->string(), toImpl(elementID)->string(), time); + return toImpl(frameRef)->pauseTransitionOnElementWithId(toWTFString(propertyName), toWTFString(elementID), time); } void WKBundleFrameSuspendAnimations(WKBundleFrameRef frameRef) @@ -194,7 +194,7 @@ WKStringRef WKBundleFrameCopyLayerTreeAsText(WKBundleFrameRef frameRef) bool WKBundleFrameAllowsFollowingLink(WKBundleFrameRef frameRef, WKURLRef urlRef) { - return toImpl(frameRef)->allowsFollowingLink(WebCore::KURL(WebCore::KURL(), toImpl(urlRef)->string())); + return toImpl(frameRef)->allowsFollowingLink(WebCore::KURL(WebCore::KURL(), toWTFString(urlRef))); } WKRect WKBundleFrameGetContentBounds(WKBundleFrameRef frameRef) @@ -234,12 +234,12 @@ bool WKBundleFrameGetDocumentBackgroundColor(WKBundleFrameRef frameRef, double* WKStringRef WKBundleFrameCopySuggestedFilenameForResourceWithURL(WKBundleFrameRef frameRef, WKURLRef urlRef) { - return toCopiedAPI(toImpl(frameRef)->suggestedFilenameForResourceWithURL(WebCore::KURL(WebCore::KURL(), toImpl(urlRef)->string()))); + return toCopiedAPI(toImpl(frameRef)->suggestedFilenameForResourceWithURL(WebCore::KURL(WebCore::KURL(), toWTFString(urlRef)))); } WKStringRef WKBundleFrameCopyMIMETypeForResourceWithURL(WKBundleFrameRef frameRef, WKURLRef urlRef) { - return toCopiedAPI(toImpl(frameRef)->mimeTypeForResourceWithURL(WebCore::KURL(WebCore::KURL(), toImpl(urlRef)->string()))); + return toCopiedAPI(toImpl(frameRef)->mimeTypeForResourceWithURL(WebCore::KURL(WebCore::KURL(), toWTFString(urlRef)))); } bool WKBundleFrameContainsAnyFormElements(WKBundleFrameRef frameRef) @@ -249,7 +249,7 @@ bool WKBundleFrameContainsAnyFormElements(WKBundleFrameRef frameRef) void WKBundleFrameSetTextDirection(WKBundleFrameRef frameRef, WKStringRef directionRef) { - toImpl(frameRef)->setTextDirection(toImpl(directionRef)->string()); + toImpl(frameRef)->setTextDirection(toWTFString(directionRef)); } WKDataRef WKBundleFrameCopyWebArchive(WKBundleFrameRef frameRef) diff --git a/Source/WebKit2/WebProcess/InjectedBundle/API/c/WKBundleInspector.cpp b/Source/WebKit2/WebProcess/InjectedBundle/API/c/WKBundleInspector.cpp index ae69a5394..cc22499a0 100644 --- a/Source/WebKit2/WebProcess/InjectedBundle/API/c/WKBundleInspector.cpp +++ b/Source/WebKit2/WebProcess/InjectedBundle/API/c/WKBundleInspector.cpp @@ -52,7 +52,7 @@ void WKBundleInspectorClose(WKBundleInspectorRef inspectorRef) void WKBundleInspectorEvaluateScriptForTest(WKBundleInspectorRef inspectorRef, long callID, WKStringRef script) { - return toImpl(inspectorRef)->evaluateScriptForTest(callID, toImpl(script)->string()); + return toImpl(inspectorRef)->evaluateScriptForTest(callID, toWTFString(script)); } void WKBundleInspectorSetPageProfilingEnabled(WKBundleInspectorRef inspectorRef, bool enabled) diff --git a/Source/WebKit2/WebProcess/InjectedBundle/API/c/WKBundleIntent.cpp b/Source/WebKit2/WebProcess/InjectedBundle/API/c/WKBundleIntent.cpp index dc13c57fc..66bee90b0 100644 --- a/Source/WebKit2/WebProcess/InjectedBundle/API/c/WKBundleIntent.cpp +++ b/Source/WebKit2/WebProcess/InjectedBundle/API/c/WKBundleIntent.cpp @@ -64,7 +64,7 @@ WKBundleIntentRef WKBundleIntentCreate(WKDictionaryRef dictionaryRef) MessagePortArray dummyPorts; ExceptionCode ec; - RefPtr<Intent> coreIntent = Intent::create(toImpl(action)->string(), toImpl(type)->string(), data ? static_cast<SerializedScriptValue*>(toImpl(data)->internalRepresentation()) : 0, dummyPorts, ec); + RefPtr<Intent> coreIntent = Intent::create(toWTFString(action), toWTFString(type), data ? static_cast<SerializedScriptValue*>(toImpl(data)->internalRepresentation()) : 0, dummyPorts, ec); return toAPI(InjectedBundleIntent::create(coreIntent.get()).leakRef()); #else diff --git a/Source/WebKit2/WebProcess/InjectedBundle/API/c/WKBundlePage.cpp b/Source/WebKit2/WebProcess/InjectedBundle/API/c/WKBundlePage.cpp index 15088e7d6..53ddf6107 100644 --- a/Source/WebKit2/WebProcess/InjectedBundle/API/c/WKBundlePage.cpp +++ b/Source/WebKit2/WebProcess/InjectedBundle/API/c/WKBundlePage.cpp @@ -212,12 +212,12 @@ WKStringRef WKBundlePageCopyRenderTreeExternalRepresentation(WKBundlePageRef pag void WKBundlePageExecuteEditingCommand(WKBundlePageRef pageRef, WKStringRef name, WKStringRef argument) { - toImpl(pageRef)->executeEditingCommand(toImpl(name)->string(), toImpl(argument)->string()); + toImpl(pageRef)->executeEditingCommand(toWTFString(name), toWTFString(argument)); } bool WKBundlePageIsEditingCommandEnabled(WKBundlePageRef pageRef, WKStringRef name) { - return toImpl(pageRef)->isEditingCommandEnabled(toImpl(name)->string()); + return toImpl(pageRef)->isEditingCommandEnabled(toWTFString(name)); } void WKBundlePageClearMainFrameName(WKBundlePageRef pageRef) @@ -277,7 +277,7 @@ void WKBundlePageUninstallPageOverlay(WKBundlePageRef pageRef, WKBundlePageOverl bool WKBundlePageHasLocalDataForURL(WKBundlePageRef pageRef, WKURLRef urlRef) { - return toImpl(pageRef)->hasLocalDataForURL(WebCore::KURL(WebCore::KURL(), toImpl(urlRef)->string())); + return toImpl(pageRef)->hasLocalDataForURL(WebCore::KURL(WebCore::KURL(), toWTFString(urlRef))); } bool WKBundlePageCanHandleRequest(WKURLRequestRef requestRef) @@ -287,7 +287,7 @@ bool WKBundlePageCanHandleRequest(WKURLRequestRef requestRef) bool WKBundlePageFindString(WKBundlePageRef pageRef, WKStringRef target, WKFindOptions findOptions) { - return toImpl(pageRef)->findStringFromInjectedBundle(toImpl(target)->string(), toFindOptions(findOptions)); + return toImpl(pageRef)->findStringFromInjectedBundle(toWTFString(target), toFindOptions(findOptions)); } WKImageRef WKBundlePageCreateSnapshotWithOptions(WKBundlePageRef pageRef, WKRect rect, WKSnapshotOptions options) @@ -403,7 +403,7 @@ WKArrayRef WKBundlePageCopyTrackedRepaintRects(WKBundlePageRef pageRef) void WKBundlePageSetComposition(WKBundlePageRef pageRef, WKStringRef text, int from, int length) { - toImpl(pageRef)->setCompositionForTesting(toImpl(text)->string(), from, length); + toImpl(pageRef)->setCompositionForTesting(toWTFString(text), from, length); } bool WKBundlePageHasComposition(WKBundlePageRef pageRef) @@ -418,26 +418,12 @@ void WKBundlePageConfirmComposition(WKBundlePageRef pageRef) void WKBundlePageConfirmCompositionWithText(WKBundlePageRef pageRef, WKStringRef text) { - toImpl(pageRef)->confirmCompositionForTesting(toImpl(text)->string()); + toImpl(pageRef)->confirmCompositionForTesting(toWTFString(text)); } bool WKBundlePageCanShowMIMEType(WKBundlePageRef, WKStringRef mimeTypeRef) { - using WebCore::MIMETypeRegistry; + const String mimeType = toWTFString(mimeTypeRef); - const WTF::String mimeType = toImpl(mimeTypeRef)->string(); - - if (MIMETypeRegistry::isSupportedNonImageMIMEType(mimeType)) - return true; - - if (MIMETypeRegistry::isSupportedImageMIMEType(mimeType)) - return true; - - if (MIMETypeRegistry::isSupportedMediaMIMEType(mimeType)) - return true; - - if (mimeType.startsWith("text/", false)) - return !MIMETypeRegistry::isUnsupportedTextMIMEType(mimeType); - - return false; + return WebCore::MIMETypeRegistry::canShowMIMEType(mimeType); } diff --git a/Source/WebKit2/WebProcess/InjectedBundle/API/c/WKBundlePage.h b/Source/WebKit2/WebProcess/InjectedBundle/API/c/WKBundlePage.h index dce7cf862..c2b37894a 100644 --- a/Source/WebKit2/WebProcess/InjectedBundle/API/c/WKBundlePage.h +++ b/Source/WebKit2/WebProcess/InjectedBundle/API/c/WKBundlePage.h @@ -154,11 +154,13 @@ struct WKBundlePageLoaderClient { // Version 3 WKBundlePageDidReceiveIntentForFrameCallback didReceiveIntentForFrame; WKBundlePageRegisterIntentServiceForFrameCallback registerIntentServiceForFrame; + + // Version 4 WKBundlePageDidLayoutCallback didLayout; }; typedef struct WKBundlePageLoaderClient WKBundlePageLoaderClient; -enum { kWKBundlePageLoaderClientCurrentVersion = 3 }; +enum { kWKBundlePageLoaderClientCurrentVersion = 4 }; enum { WKBundlePagePolicyActionPassThrough, diff --git a/Source/WebKit2/WebProcess/InjectedBundle/API/c/WKBundlePrivate.h b/Source/WebKit2/WebProcess/InjectedBundle/API/c/WKBundlePrivate.h index f032c6222..369c4302f 100644 --- a/Source/WebKit2/WebProcess/InjectedBundle/API/c/WKBundlePrivate.h +++ b/Source/WebKit2/WebProcess/InjectedBundle/API/c/WKBundlePrivate.h @@ -36,18 +36,6 @@ extern "C" { #endif -enum WKUserScriptInjectionTime { - kWKInjectAtDocumentStart, - kWKInjectAtDocumentEnd -}; -typedef enum WKUserScriptInjectionTime WKUserScriptInjectionTime; - -enum WKUserContentInjectedFrames { - kWKInjectInAllFrames, - kWKInjectInTopFrameOnly -}; -typedef enum WKUserContentInjectedFrames WKUserContentInjectedFrames; - // TestRunner only SPI WK_EXPORT void WKBundleSetShouldTrackVisitedLinks(WKBundleRef bundle, bool shouldTrackVisitedLinks); WK_EXPORT void WKBundleSetAlwaysAcceptCookies(WKBundleRef bundle, bool); @@ -113,6 +101,8 @@ WK_EXPORT void WKBundleSetPageVisibilityState(WKBundleRef bundle, WKBundlePageRe WK_EXPORT size_t WKBundleGetWorkerThreadCount(WKBundleRef bundle); WK_EXPORT void WKBundleSetTabKeyCyclesThroughElements(WKBundleRef bundle, WKBundlePageRef page, bool enabled); +WK_EXPORT void WKBundleSetSerialLoadingEnabled(WKBundleRef bundle, bool enabled); +WK_EXPORT void WKBundleDispatchPendingLoadRequests(WKBundleRef bundle); #ifdef __cplusplus } diff --git a/Source/WebKit2/WebProcess/InjectedBundle/API/mac/WKDOMDocument.h b/Source/WebKit2/WebProcess/InjectedBundle/API/mac/WKDOMDocument.h new file mode 100644 index 000000000..4495055cb --- /dev/null +++ b/Source/WebKit2/WebProcess/InjectedBundle/API/mac/WKDOMDocument.h @@ -0,0 +1,44 @@ +/* + * 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. + */ + +#if defined(__LP64__) && defined(__clang__) + +#import <WebKit2/WKDOMNode.h> + +@class WKDOMElement; +@class WKDOMText; + +WK_EXPORT +@interface WKDOMDocument : WKDOMNode + +- (WKDOMElement *)createElement:(NSString *)tagName; +- (WKDOMText *)createTextNode:(NSString *)data; + +@property(readonly) WKDOMElement *body; + +@end + +#endif // defined(__LP64__) && defined(__clang__) + diff --git a/Source/WebKit2/WebProcess/InjectedBundle/API/mac/WKDOMDocument.mm b/Source/WebKit2/WebProcess/InjectedBundle/API/mac/WKDOMDocument.mm new file mode 100644 index 000000000..99f515021 --- /dev/null +++ b/Source/WebKit2/WebProcess/InjectedBundle/API/mac/WKDOMDocument.mm @@ -0,0 +1,64 @@ +/* + * 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. + */ + +#import "config.h" + +#if defined(__LP64__) && defined(__clang__) + +#import "WKDOMDocument.h" + +#import "WKDOMInternals.h" +#import <WebCore/Document.h> +#import <WebCore/HTMLElement.h> +#import <WebCore/Text.h> + +static inline WebCore::Document* toDocument(WebCore::Node* node) +{ + ASSERT(!node || node->isDocumentNode()); + return static_cast<WebCore::Document*>(node); +} + +@implementation WKDOMDocument + +- (WKDOMElement *)createElement:(NSString *)tagName +{ + // FIXME: Do something about the exception. + WebCore::ExceptionCode ec = 0; + return WebKit::toWKDOMElement(toDocument(_impl.get())->createElement(tagName, ec).get()); +} + +- (WKDOMText *)createTextNode:(NSString *)data +{ + return WebKit::toWKDOMText(toDocument(_impl.get())->createTextNode(data).get()); +} + +- (WKDOMElement *)body +{ + return WebKit::toWKDOMElement(toDocument(_impl.get())->body()); +} + +@end + +#endif // defined(__LP64__) && defined(__clang__) diff --git a/Source/WebKit2/WebProcess/InjectedBundle/API/mac/WKDOMElement.h b/Source/WebKit2/WebProcess/InjectedBundle/API/mac/WKDOMElement.h new file mode 100644 index 000000000..aa03cd4d9 --- /dev/null +++ b/Source/WebKit2/WebProcess/InjectedBundle/API/mac/WKDOMElement.h @@ -0,0 +1,41 @@ +/* + * 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. + */ + +#if defined(__LP64__) && defined(__clang__) + +#import <WebKit2/WKDOMNode.h> + +WK_EXPORT +@interface WKDOMElement : WKDOMNode + +- (BOOL)hasAttribute:(NSString *)attribute; +- (NSString *)getAttribute:(NSString *)attribute; +- (void)setAttribute:(NSString *)name value:(NSString *)value; + +@property(readonly) NSString *tagName; + +@end + +#endif // defined(__LP64__) && defined(__clang__) diff --git a/Source/WebKit2/WebProcess/InjectedBundle/API/mac/WKDOMElement.mm b/Source/WebKit2/WebProcess/InjectedBundle/API/mac/WKDOMElement.mm new file mode 100644 index 000000000..72cf5ab40 --- /dev/null +++ b/Source/WebKit2/WebProcess/InjectedBundle/API/mac/WKDOMElement.mm @@ -0,0 +1,61 @@ +/* + * 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. + */ + +#import "config.h" + +#if defined(__LP64__) && defined(__clang__) + +#import "WKDOMElement.h" + +#import "WKDOMInternals.h" +#import <WebCore/Element.h> + +@implementation WKDOMElement + +- (BOOL)hasAttribute:(NSString *)attribute +{ + return WebCore::toElement(_impl.get())->hasAttribute(attribute); +} + +- (NSString *)getAttribute:(NSString *)attribute +{ + return WebCore::toElement(_impl.get())->getAttribute(attribute); +} + +- (void)setAttribute:(NSString *)name value:(NSString *)value +{ + // FIXME: Do something about the exception. + WebCore::ExceptionCode ec; + WebCore::toElement(_impl.get())->setAttribute(name, value, ec); +} + +- (NSString *)tagName +{ + return WebCore::toElement(_impl.get())->tagName(); +} + +@end + +#endif // defined(__LP64__) && defined(__clang__) diff --git a/Source/WebKit2/WebProcess/InjectedBundle/API/mac/WKDOMInternals.h b/Source/WebKit2/WebProcess/InjectedBundle/API/mac/WKDOMInternals.h new file mode 100644 index 000000000..f33e454cd --- /dev/null +++ b/Source/WebKit2/WebProcess/InjectedBundle/API/mac/WKDOMInternals.h @@ -0,0 +1,116 @@ +/* + * 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. + */ + +#if defined(__LP64__) && defined(__clang__) + +#import "WKDOMNode.h" +#import "WKDOMRange.h" +#import <WebCore/Node.h> +#import <WebCore/Range.h> +#import <wtf/HashMap.h> + +namespace WebCore { +class Element; +class Document; +} + +@class WKDOMElement; +@class WKDOMDocument; +@class WKDOMText; + +@interface WKDOMNode () { +@public + RefPtr<WebCore::Node> _impl; +} + +- (id)_initWithImpl:(WebCore::Node*)impl; +@end + +@interface WKDOMRange () { +@public + RefPtr<WebCore::Range> _impl; +} + +- (id)_initWithImpl:(WebCore::Range*)impl; +@end + +namespace WebKit { + +template<typename WebCoreType, typename WKDOMType> +class DOMCache { +public: + DOMCache() + { + } + + void add(WebCoreType core, WKDOMType kit) + { + m_map.add(core, kit); + } + + WKDOMType get(WebCoreType core) + { + return m_map.get(core); + } + + void remove(WebCoreType core) + { + m_map.remove(core); + } + +private: + // This class should only ever be used as a singleton. + ~DOMCache() = delete; + + HashMap<WebCoreType, WKDOMType> m_map; +}; + +// -- Caches -- + +DOMCache<WebCore::Node*, WKDOMNode *>& WKDOMNodeCache(); +DOMCache<WebCore::Range*, WKDOMRange *>& WKDOMRangeCache(); + +// -- Node and classes derived from Node. -- + +WebCore::Node* toWebCoreNode(WKDOMNode *); +WKDOMNode *toWKDOMNode(WebCore::Node*); + +WebCore::Element* toWebCoreElement(WKDOMElement *); +WKDOMElement *toWKDOMElement(WebCore::Element*); + +WebCore::Document* toWebCoreDocument(WKDOMDocument *); +WKDOMDocument *toWKDOMDocument(WebCore::Document*); + +WebCore::Text* toWebCoreText(WKDOMText *); +WKDOMText *toWKDOMText(WebCore::Text*); + +// -- Range. -- + +WebCore::Range* toWebCoreRange(WKDOMRange *); +WKDOMRange *toWKDOMRange(WebCore::Range*); + +} // namespace WebKit + +#endif // defined(__LP64__) && defined(__clang__) diff --git a/Source/WebKit2/WebProcess/InjectedBundle/API/mac/WKDOMInternals.mm b/Source/WebKit2/WebProcess/InjectedBundle/API/mac/WKDOMInternals.mm new file mode 100644 index 000000000..ab9046613 --- /dev/null +++ b/Source/WebKit2/WebProcess/InjectedBundle/API/mac/WKDOMInternals.mm @@ -0,0 +1,170 @@ +/* + * 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. + */ + +#import "config.h" + +#if defined(__LP64__) && defined(__clang__) + +#import "WKDOMInternals.h" + +#import <WebCore/Document.h> +#import <WebCore/Element.h> +#import <WebCore/Node.h> +#import <WebCore/Range.h> +#import <WebCore/Text.h> + +// Classes to instantiate. +#import "WKDOMElement.h" +#import "WKDOMDocument.h" +#import "WKDOMText.h" + +namespace WebKit { + +template<typename WebCoreType, typename WKDOMType> +static WKDOMType toWKDOMType(WebCoreType impl, DOMCache<WebCoreType, WKDOMType>& cache); + +// -- Caches -- + +DOMCache<WebCore::Node*, WKDOMNode *>& WKDOMNodeCache() +{ + typedef DOMCache<WebCore::Node*, WKDOMNode *> Cache; + DEFINE_STATIC_LOCAL(Cache, cache, ()); + return cache; +} + +DOMCache<WebCore::Range*, WKDOMRange *>& WKDOMRangeCache() +{ + typedef DOMCache<WebCore::Range*, WKDOMRange *> Cache; + DEFINE_STATIC_LOCAL(Cache, cache, ()); + return cache; +} + +// -- Node and classes derived from Node. -- + +static Class WKDOMNodeClass(WebCore::Node* impl) +{ + switch (impl->nodeType()) { + case WebCore::Node::ELEMENT_NODE: + return [WKDOMElement class]; + case WebCore::Node::DOCUMENT_NODE: + return [WKDOMDocument class]; + case WebCore::Node::TEXT_NODE: + return [WKDOMText class]; + case WebCore::Node::ATTRIBUTE_NODE: + case WebCore::Node::CDATA_SECTION_NODE: + case WebCore::Node::ENTITY_REFERENCE_NODE: + case WebCore::Node::ENTITY_NODE: + case WebCore::Node::PROCESSING_INSTRUCTION_NODE: + case WebCore::Node::COMMENT_NODE: + case WebCore::Node::DOCUMENT_TYPE_NODE: + case WebCore::Node::DOCUMENT_FRAGMENT_NODE: + case WebCore::Node::NOTATION_NODE: + case WebCore::Node::XPATH_NAMESPACE_NODE: + break; + } + ASSERT_NOT_REACHED(); + return nil; +} + +static WKDOMNode *initWithImpl(WebCore::Node* impl) +{ + return [[WKDOMNodeClass(impl) alloc] _initWithImpl:impl]; +} + +WebCore::Node* toWebCoreNode(WKDOMNode *wrapper) +{ + return wrapper ? wrapper->_impl.get() : 0; +} + +WKDOMNode *toWKDOMNode(WebCore::Node* impl) +{ + return toWKDOMType<WebCore::Node*, WKDOMNode *>(impl, WKDOMNodeCache()); +} + +WebCore::Element* toWebCoreElement(WKDOMElement *wrapper) +{ + return wrapper ? reinterpret_cast<WebCore::Element*>(wrapper->_impl.get()) : 0; +} + +WKDOMElement *toWKDOMElement(WebCore::Element* impl) +{ + return static_cast<WKDOMElement*>(toWKDOMNode(static_cast<WebCore::Node*>(impl))); +} + +WebCore::Document* toWebCoreDocument(WKDOMDocument *wrapper) +{ + return wrapper ? reinterpret_cast<WebCore::Document*>(wrapper->_impl.get()) : 0; +} + +WKDOMDocument *toWKDOMDocument(WebCore::Document* impl) +{ + return static_cast<WKDOMDocument*>(toWKDOMNode(static_cast<WebCore::Node*>(impl))); +} + +WebCore::Text* toWebCoreText(WKDOMText *wrapper) +{ + return wrapper ? reinterpret_cast<WebCore::Text*>(wrapper->_impl.get()) : 0; +} + +WKDOMText *toWKDOMText(WebCore::Text* impl) +{ + return static_cast<WKDOMText*>(toWKDOMNode(static_cast<WebCore::Node*>(impl))); +} + +// -- Range. -- + +static WKDOMRange *initWithImpl(WebCore::Range* impl) +{ + return [[WKDOMRange alloc] _initWithImpl:impl]; +} + +WebCore::Range* toWebCoreRange(WKDOMRange * wrapper) +{ + return wrapper ? wrapper->_impl.get() : 0; +} + +WKDOMRange *toWKDOMRange(WebCore::Range* impl) +{ + return toWKDOMType<WebCore::Range*, WKDOMRange *>(impl, WKDOMRangeCache()); +} + +// -- Helpers -- + +template<typename WebCoreType, typename WKDOMType> +static WKDOMType toWKDOMType(WebCoreType impl, DOMCache<WebCoreType, WKDOMType>& cache) +{ + if (!impl) + return nil; + if (WKDOMType wrapper = cache.get(impl)) + return [[wrapper retain] autorelease]; + WKDOMType wrapper = initWithImpl(impl); + if (!wrapper) + return nil; + return [wrapper autorelease]; +} + +} // namespace WebKit + +#endif // defined(__LP64__) && defined(__clang__) diff --git a/Source/WebKit2/WebProcess/InjectedBundle/API/mac/WKDOMNode.h b/Source/WebKit2/WebProcess/InjectedBundle/API/mac/WKDOMNode.h new file mode 100644 index 000000000..c0e03937c --- /dev/null +++ b/Source/WebKit2/WebProcess/InjectedBundle/API/mac/WKDOMNode.h @@ -0,0 +1,48 @@ +/* + * 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. + */ + +#if defined(__LP64__) && defined(__clang__) + +#import <Foundation/Foundation.h> +#import <WebKit2/WKBase.h> + +@class WKDOMDocument; + +WK_EXPORT +@interface WKDOMNode : NSObject + +- (void)insertNode:(WKDOMNode *)node before:(WKDOMNode *)refNode; +- (void)appendChild:(WKDOMNode *)node; + +@property(readonly) WKDOMDocument *document; +@property(readonly) WKDOMNode *parentNode; +@property(readonly) WKDOMNode *firstChild; +@property(readonly) WKDOMNode *lastChild; +@property(readonly) WKDOMNode *previousSibling; +@property(readonly) WKDOMNode *nextSibling; + +@end + +#endif // defined(__LP64__) && defined(__clang__) diff --git a/Source/WebKit2/WebProcess/InjectedBundle/API/mac/WKDOMNode.mm b/Source/WebKit2/WebProcess/InjectedBundle/API/mac/WKDOMNode.mm new file mode 100644 index 000000000..4308ff3ab --- /dev/null +++ b/Source/WebKit2/WebProcess/InjectedBundle/API/mac/WKDOMNode.mm @@ -0,0 +1,100 @@ +/* + * 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. + */ + +#import "config.h" + +#if defined(__LP64__) && defined(__clang__) + +#import "WKDOMNode.h" + +#import "WKDOMInternals.h" + +@implementation WKDOMNode + +- (id)_initWithImpl:(WebCore::Node*)impl +{ + self = [super init]; + if (!self) + return nil; + + _impl = impl; + WebKit::WKDOMNodeCache().add(impl, self); + + return self; +} + +- (void)dealloc +{ + WebKit::WKDOMNodeCache().remove(_impl.get()); + [super dealloc]; +} + +- (void)insertNode:(WKDOMNode *)node before:(WKDOMNode *)refNode +{ + // FIXME: Do something about the exception. + WebCore::ExceptionCode ec; + _impl->insertBefore(WebKit::toWebCoreNode(node), WebKit::toWebCoreNode(refNode), ec); +} + +- (void)appendChild:(WKDOMNode *)node +{ + // FIXME: Do something about the exception. + WebCore::ExceptionCode ec; + _impl->appendChild(WebKit::toWebCoreNode(node), ec); +} + +- (WKDOMDocument *)document +{ + return WebKit::toWKDOMDocument(_impl->document()); +} + +- (WKDOMNode *)parentNode +{ + return WebKit::toWKDOMNode(_impl->parentNode()); +} + +- (WKDOMNode *)firstChild +{ + return WebKit::toWKDOMNode(_impl->firstChild()); +} + +- (WKDOMNode *)lastChild +{ + return WebKit::toWKDOMNode(_impl->lastChild()); +} + +- (WKDOMNode *)previousSibling +{ + return WebKit::toWKDOMNode(_impl->previousSibling()); +} + +- (WKDOMNode *)nextSibling +{ + return WebKit::toWKDOMNode(_impl->nextSibling()); +} + +@end + +#endif // defined(__LP64__) && defined(__clang__) diff --git a/Source/WebKit2/WebProcess/InjectedBundle/API/mac/WKDOMRange.h b/Source/WebKit2/WebProcess/InjectedBundle/API/mac/WKDOMRange.h new file mode 100644 index 000000000..64ed00ce2 --- /dev/null +++ b/Source/WebKit2/WebProcess/InjectedBundle/API/mac/WKDOMRange.h @@ -0,0 +1,53 @@ +/* + * 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. + */ + +#if defined(__LP64__) && defined(__clang__) + +#import <Foundation/Foundation.h> +#import <WebKit2/WKBase.h> + +@class WKDOMNode, WKDOMDocument; + +WK_EXPORT +@interface WKDOMRange : NSObject + +- (id)initWithDocument:(WKDOMDocument *)document; + +- (void)setStart:(WKDOMNode *)node offset:(int)offset; +- (void)setEnd:(WKDOMNode *)node offset:(int)offset; +- (void)collapse:(BOOL)toStart; +- (void)selectNode:(WKDOMNode *)node; +- (void)selectNodeContents:(WKDOMNode *)node; + +@property(readonly, retain) WKDOMNode *startContainer; +@property(readonly) NSInteger startOffset; +@property(readonly, retain) WKDOMNode *endContainer; +@property(readonly) NSInteger endOffset; +@property(readonly, copy) NSString *text; +@property(readonly) BOOL isCollapsed; + +@end + +#endif // defined(__LP64__) && defined(__clang__) diff --git a/Source/WebKit2/WebProcess/InjectedBundle/API/mac/WKDOMRange.mm b/Source/WebKit2/WebProcess/InjectedBundle/API/mac/WKDOMRange.mm new file mode 100644 index 000000000..1cc408408 --- /dev/null +++ b/Source/WebKit2/WebProcess/InjectedBundle/API/mac/WKDOMRange.mm @@ -0,0 +1,142 @@ +/* + * 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. + */ + +#import "config.h" + +#if defined(__LP64__) && defined(__clang__) + +#import "WKDOMRange.h" + +#import "WKDOMInternals.h" +#import <WebCore/Document.h> + +@implementation WKDOMRange + +- (id)_initWithImpl:(WebCore::Range*)impl +{ + self = [super init]; + if (!self) + return nil; + + _impl = impl; + WebKit::WKDOMRangeCache().add(impl, self); + + return self; +} + +- (id)initWithDocument:(WKDOMDocument *)document +{ + RefPtr<WebCore::Range> range = WebCore::Range::create(WebKit::toWebCoreDocument(document)); + self = [self _initWithImpl:range.get()]; + if (!self) + return nil; + + return self; +} + +- (void)dealloc +{ + WebKit::WKDOMRangeCache().remove(_impl.get()); + [super dealloc]; +} + +- (void)setStart:(WKDOMNode *)node offset:(int)offset +{ + // FIXME: Do something about the exception. + WebCore::ExceptionCode ec = 0; + _impl->setStart(WebKit::toWebCoreNode(node), offset, ec); +} + +- (void)setEnd:(WKDOMNode *)node offset:(int)offset +{ + // FIXME: Do something about the exception. + WebCore::ExceptionCode ec = 0; + _impl->setEnd(WebKit::toWebCoreNode(node), offset, ec); +} + +- (void)collapse:(BOOL)toStart +{ + // FIXME: Do something about the exception. + WebCore::ExceptionCode ec = 0; + _impl->collapse(toStart, ec); +} + +- (void)selectNode:(WKDOMNode *)node +{ + // FIXME: Do something about the exception. + WebCore::ExceptionCode ec = 0; + _impl->selectNode(WebKit::toWebCoreNode(node), ec); +} + +- (void)selectNodeContents:(WKDOMNode *)node +{ + // FIXME: Do something about the exception. + WebCore::ExceptionCode ec = 0; + _impl->selectNodeContents(WebKit::toWebCoreNode(node), ec); +} + +- (WKDOMNode *)startContainer +{ + // FIXME: Do something about the exception. + WebCore::ExceptionCode ec = 0; + return WebKit::toWKDOMNode(_impl->startContainer(ec)); +} + +- (NSInteger)startOffset +{ + // FIXME: Do something about the exception. + WebCore::ExceptionCode ec = 0; + return _impl->startOffset(ec); +} + +- (WKDOMNode *)endContainer +{ + // FIXME: Do something about the exception. + WebCore::ExceptionCode ec = 0; + return WebKit::toWKDOMNode(_impl->endContainer(ec)); +} + +- (NSInteger)endOffset +{ + // FIXME: Do something about the exception. + WebCore::ExceptionCode ec = 0; + return _impl->endOffset(ec); +} + +- (NSString *)text +{ + return _impl->text(); +} + +- (BOOL)isCollapsed +{ + // FIXME: Do something about the exception. + WebCore::ExceptionCode ec = 0; + return _impl->collapsed(ec); +} + +@end + +#endif // defined(__LP64__) && defined(__clang__) diff --git a/Source/WebKit2/WebProcess/InjectedBundle/API/mac/WKDOMText.h b/Source/WebKit2/WebProcess/InjectedBundle/API/mac/WKDOMText.h new file mode 100644 index 000000000..eb8552e3f --- /dev/null +++ b/Source/WebKit2/WebProcess/InjectedBundle/API/mac/WKDOMText.h @@ -0,0 +1,37 @@ +/* + * 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. + */ + +#if defined(__LP64__) && defined(__clang__) + +#import <WebKit2/WKDOMNode.h> + +WK_EXPORT +@interface WKDOMText : WKDOMNode + +@property(readonly) NSString *data; + +@end + +#endif // defined(__LP64__) && defined(__clang__) diff --git a/Source/WebKit2/WebProcess/InjectedBundle/API/mac/WKDOMText.mm b/Source/WebKit2/WebProcess/InjectedBundle/API/mac/WKDOMText.mm new file mode 100644 index 000000000..4f4f627ab --- /dev/null +++ b/Source/WebKit2/WebProcess/InjectedBundle/API/mac/WKDOMText.mm @@ -0,0 +1,43 @@ +/* + * 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. + */ + +#import "config.h" +#import "WKDOMText.h" + +#if defined(__LP64__) && defined(__clang__) + +#import "WKDOMInternals.h" +#import <WebCore/Text.h> + +@implementation WKDOMText + +- (NSString *)data +{ + return WebCore::toText(_impl.get())->data(); +} + +@end + +#endif // defined(__LP64__) && defined(__clang__) diff --git a/Source/WebKit2/WebProcess/InjectedBundle/API/mac/WKDOMTextIterator.h b/Source/WebKit2/WebProcess/InjectedBundle/API/mac/WKDOMTextIterator.h new file mode 100644 index 000000000..e34c18e44 --- /dev/null +++ b/Source/WebKit2/WebProcess/InjectedBundle/API/mac/WKDOMTextIterator.h @@ -0,0 +1,47 @@ +/* + * 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. + */ + +#if defined(__LP64__) && defined(__clang__) + +#import <Foundation/Foundation.h> +#import <WebKit2/WKBase.h> + +@class WKDOMRange; + +WK_EXPORT +@interface WKDOMTextIterator : NSObject + +- (id)initWithRange:(WKDOMRange *)range; + +- (void)advance; + +@property (readonly) BOOL atEnd; +@property (readonly) WKDOMRange *currentRange; +@property (readonly) NSUInteger currentTextLength; +@property (readonly) const unichar *currentTextPointer; + +@end + +#endif // defined(__LP64__) && defined(__clang__) diff --git a/Source/WebKit2/WebProcess/InjectedBundle/API/mac/WKDOMTextIterator.mm b/Source/WebKit2/WebProcess/InjectedBundle/API/mac/WKDOMTextIterator.mm new file mode 100644 index 000000000..0f9ae6191 --- /dev/null +++ b/Source/WebKit2/WebProcess/InjectedBundle/API/mac/WKDOMTextIterator.mm @@ -0,0 +1,83 @@ +/* + * 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. + */ + +#import "config.h" + +#if defined(__LP64__) && defined(__clang__) + +#import "WKDOMTextIterator.h" + +#import "WKDOMInternals.h" +#import "WKDOMRange.h" +#import <WebCore/TextIterator.h> +#import <wtf/OwnPtr.h> + +@interface WKDOMTextIterator () { +@public + OwnPtr<WebCore::TextIterator> _textIterator; +} +@end + +@implementation WKDOMTextIterator + +- (id)initWithRange:(WKDOMRange *)range +{ + self = [super init]; + if (!self) + return nil; + + _textIterator = adoptPtr(new WebCore::TextIterator(WebKit::toWebCoreRange(range))); + + return self; +} + +- (void)advance +{ + _textIterator->advance(); +} + +- (BOOL)atEnd +{ + return _textIterator->atEnd(); +} + +- (WKDOMRange *)currentRange +{ + return WebKit::toWKDOMRange(_textIterator->range().get()); +} + +- (const unichar *)currentTextPointer +{ + return _textIterator->characters(); +} + +- (NSUInteger)currentTextLength +{ + return _textIterator->length(); +} + +@end + +#endif // defined(__LP64__) && defined(__clang__) diff --git a/Source/WebKit2/WebProcess/InjectedBundle/API/mac/WKWebProcessPlugIn.h b/Source/WebKit2/WebProcess/InjectedBundle/API/mac/WKWebProcessPlugIn.h new file mode 100644 index 000000000..4a7cc50a6 --- /dev/null +++ b/Source/WebKit2/WebProcess/InjectedBundle/API/mac/WKWebProcessPlugIn.h @@ -0,0 +1,45 @@ +/* + * 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. + */ + +#if defined(__LP64__) && defined(__clang__) + +#import <Foundation/Foundation.h> +#import <WebKit2/WKBase.h> + +@class WKWebProcessPlugInController; +@class WKWebProcessPlugInBrowserContextController; + +@protocol WKWebProcessPlugIn <NSObject> +@optional +- (void)webProcessPlugInInitialize:(WKWebProcessPlugInController *)plugInController; +- (void)webProcessPlugIn:(WKWebProcessPlugInController *)plugInController didCreateBrowserContextController:(WKWebProcessPlugInBrowserContextController *)browserContextController; +- (void)webProcessPlugIn:(WKWebProcessPlugInController *)plugInController willDestroyBrowserContextController:(WKWebProcessPlugInBrowserContextController *)browserContextController; +@end + +WK_EXPORT +@interface WKWebProcessPlugInController : NSObject +@end + +#endif // defined(__LP64__) && defined(__clang__) diff --git a/Source/WebKit2/WebProcess/InjectedBundle/API/mac/WKWebProcessPlugIn.mm b/Source/WebKit2/WebProcess/InjectedBundle/API/mac/WKWebProcessPlugIn.mm new file mode 100644 index 000000000..d967ec29b --- /dev/null +++ b/Source/WebKit2/WebProcess/InjectedBundle/API/mac/WKWebProcessPlugIn.mm @@ -0,0 +1,129 @@ +/* + * 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. + */ + +#import "config.h" + +#if defined(__LP64__) && defined(__clang__) + +#import "WKWebProcessPlugIn.h" +#import "WKWebProcessPlugInInternal.h" + +#import "InjectedBundle.h" +#import "WKBundle.h" +#import "WKBundleAPICast.h" +#import "WKRetainPtr.h" +#import "WKWebProcessPlugInBrowserContextControllerInternal.h" +#import <wtf/RetainPtr.h> + +typedef HashMap<WKBundlePageRef, RetainPtr<WKWebProcessPlugInBrowserContextController *> > BundlePageWrapperCache; + +@interface WKWebProcessPlugInController () { + RetainPtr<id<WKWebProcessPlugIn> > _principalClassInstance; + WKRetainPtr<WKBundleRef> _bundleRef; + BundlePageWrapperCache _bundlePageWrapperCache; +} +@end + +@implementation WKWebProcessPlugInController (Internal) + +static void didCreatePage(WKBundleRef bundle, WKBundlePageRef page, const void* clientInfo) +{ + WKWebProcessPlugInController *plugInController = (WKWebProcessPlugInController *)clientInfo; + id<WKWebProcessPlugIn> principalClassInstance = plugInController->_principalClassInstance.get(); + + if ([principalClassInstance respondsToSelector:@selector(webProcessPlugIn:didCreateBrowserContextController:)]) { + ASSERT(!plugInController->_bundlePageWrapperCache.contains(page)); + + WKWebProcessPlugInBrowserContextController* browserContextController = [[WKWebProcessPlugInBrowserContextController alloc] _initWithBundlePageRef:page]; + plugInController->_bundlePageWrapperCache.set(page, browserContextController); + + [principalClassInstance webProcessPlugIn:plugInController didCreateBrowserContextController:browserContextController]; + } +} + +static void willDestroyPage(WKBundleRef bundle, WKBundlePageRef page, const void* clientInfo) +{ + WKWebProcessPlugInController *plugInController = (WKWebProcessPlugInController *)clientInfo; + id<WKWebProcessPlugIn> principalClassInstance = plugInController->_principalClassInstance.get(); + + // If we never added the bundle page to the cache, which can happen if webProcessPlugIn:didCreateBrowserContextController: is not implemented, + // there is no reason to call webProcessPlugIn:willDestroyBrowserContextController:, so don't. + BundlePageWrapperCache::iterator it = plugInController->_bundlePageWrapperCache.find(page); + if (it == plugInController->_bundlePageWrapperCache.end()) { + ASSERT(![principalClassInstance respondsToSelector:@selector(webProcessPlugIn:didCreateBrowserContextController:)]); + return; + } + + if ([principalClassInstance respondsToSelector:@selector(webProcessPlugIn:willDestroyBrowserContextController:)]) + [principalClassInstance webProcessPlugIn:plugInController willDestroyBrowserContextController:it->value.get()]; + + plugInController->_bundlePageWrapperCache.remove(it); +} + +static void setUpBundleClient(WKWebProcessPlugInController *plugInController, WKBundleRef bundleRef) +{ + WKBundleClient bundleClient; + memset(&bundleClient, 0, sizeof(bundleClient)); + + bundleClient.version = kWKBundleClientCurrentVersion; + bundleClient.clientInfo = plugInController; + bundleClient.didCreatePage = didCreatePage; + bundleClient.willDestroyPage = willDestroyPage; + + WKBundleSetClient(bundleRef, &bundleClient); +} + +static WKWebProcessPlugInController *sharedInstance; + ++ (WKWebProcessPlugInController *)_shared +{ + ASSERT_WITH_MESSAGE(sharedInstance, "+[WKWebProcessPlugIn _shared] called without first initializing it."); + return sharedInstance; +} + +- (id)_initWithPrincipalClassInstance:(id<WKWebProcessPlugIn>)principalClassInstance bundleRef:(WKBundleRef)bundleRef +{ + self = [super init]; + if (!self) + return nil; + + _principalClassInstance = principalClassInstance; + _bundleRef = bundleRef; + + ASSERT_WITH_MESSAGE(!sharedInstance, "WKWebProcessPlugInController initialized multiple times."); + sharedInstance = self; + + setUpBundleClient(self, bundleRef); + + return self; +} + +@end + +@implementation WKWebProcessPlugInController + +@end + +#endif // defined(__LP64__) && defined(__clang__) diff --git a/Source/WebKit2/WebProcess/InjectedBundle/API/mac/WKWebProcessPlugInBrowserContextController.h b/Source/WebKit2/WebProcess/InjectedBundle/API/mac/WKWebProcessPlugInBrowserContextController.h new file mode 100644 index 000000000..5a0db8d05 --- /dev/null +++ b/Source/WebKit2/WebProcess/InjectedBundle/API/mac/WKWebProcessPlugInBrowserContextController.h @@ -0,0 +1,40 @@ +/* + * 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. + */ + +#if defined(__LP64__) && defined(__clang__) + +#import <Foundation/Foundation.h> +#import <WebKit2/WKBase.h> + +@class WKDOMDocument; + +WK_EXPORT +@interface WKWebProcessPlugInBrowserContextController : NSObject + +@property(readonly) WKDOMDocument *mainFrameDocument; + +@end + +#endif // defined(__LP64__) && defined(__clang__) diff --git a/Source/WebKit2/WebProcess/InjectedBundle/API/mac/WKWebProcessPlugInBrowserContextController.mm b/Source/WebKit2/WebProcess/InjectedBundle/API/mac/WKWebProcessPlugInBrowserContextController.mm new file mode 100644 index 000000000..3d39be033 --- /dev/null +++ b/Source/WebKit2/WebProcess/InjectedBundle/API/mac/WKWebProcessPlugInBrowserContextController.mm @@ -0,0 +1,86 @@ +/* + * 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. + */ + +#import "config.h" + +#if defined(__LP64__) && defined(__clang__) + +#import "WKWebProcessPlugInBrowserContextController.h" +#import "WKWebProcessPlugInBrowserContextControllerInternal.h" +#import "WKWebProcessPlugInBrowserContextControllerPrivate.h" + +#import "WKBundleAPICast.h" +#import "WKBundlePage.h" +#import "WKBundlePagePrivate.h" +#import "WKDOMInternals.h" +#import "WKRetainPtr.h" +#import "WebPage.h" +#import <WebCore/Document.h> +#import <WebCore/Frame.h> + +@interface WKWebProcessPlugInBrowserContextController () { + // Underlying WKBundlePageRef. + WKRetainPtr<WKBundlePageRef> _bundlePageRef; +} +@end + +@implementation WKWebProcessPlugInBrowserContextController (Internal) + +- (id)_initWithBundlePageRef:(WKBundlePageRef)bundlePageRef +{ + self = [super init]; + if (!self) + return nil; + + _bundlePageRef = bundlePageRef; + + return self; +} + +@end + +@implementation WKWebProcessPlugInBrowserContextController + +- (WKDOMDocument *)mainFrameDocument +{ + WebCore::Frame* webCoreMainFrame = WebKit::toImpl(self._bundlePageRef)->mainFrame(); + if (!webCoreMainFrame) + return nil; + + return WebKit::toWKDOMDocument(webCoreMainFrame->document()); +} + +@end + +@implementation WKWebProcessPlugInBrowserContextController (Private) + +- (WKBundlePageRef)_bundlePageRef +{ + return _bundlePageRef.get(); +} + +@end + +#endif // defined(__LP64__) && defined(__clang__) diff --git a/Source/WebKit2/WebProcess/InjectedBundle/API/mac/WKWebProcessPlugInBrowserContextControllerInternal.h b/Source/WebKit2/WebProcess/InjectedBundle/API/mac/WKWebProcessPlugInBrowserContextControllerInternal.h new file mode 100644 index 000000000..62f06238a --- /dev/null +++ b/Source/WebKit2/WebProcess/InjectedBundle/API/mac/WKWebProcessPlugInBrowserContextControllerInternal.h @@ -0,0 +1,36 @@ +/* + * 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. + */ + +#if defined(__LP64__) && defined(__clang__) + +#import "WKWebProcessPlugInBrowserContextController.h" + +@interface WKWebProcessPlugInBrowserContextController (Internal) + +- (id)_initWithBundlePageRef:(WKBundlePageRef)bundlePageRef; + +@end + +#endif // defined(__LP64__) && defined(__clang__) diff --git a/Source/WebKit2/WebProcess/InjectedBundle/API/mac/WKWebProcessPlugInBrowserContextControllerPrivate.h b/Source/WebKit2/WebProcess/InjectedBundle/API/mac/WKWebProcessPlugInBrowserContextControllerPrivate.h new file mode 100644 index 000000000..59aac108c --- /dev/null +++ b/Source/WebKit2/WebProcess/InjectedBundle/API/mac/WKWebProcessPlugInBrowserContextControllerPrivate.h @@ -0,0 +1,36 @@ +/* + * 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. + */ + +#if defined(__LP64__) && defined(__clang__) + +#import <WebKit2/WKWebProcessPlugInBrowserContextController.h> + +@interface WKWebProcessPlugInBrowserContextController (Private) + +@property(readonly) WKBundlePageRef _bundlePageRef; + +@end + +#endif // defined(__LP64__) && defined(__clang__) diff --git a/Source/WebKit2/WebProcess/InjectedBundle/API/mac/WKWebProcessPlugInInternal.h b/Source/WebKit2/WebProcess/InjectedBundle/API/mac/WKWebProcessPlugInInternal.h new file mode 100644 index 000000000..58b3cc3f7 --- /dev/null +++ b/Source/WebKit2/WebProcess/InjectedBundle/API/mac/WKWebProcessPlugInInternal.h @@ -0,0 +1,37 @@ +/* + * 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. + */ + +#if defined(__LP64__) && defined(__clang__) + +#import "WKWebProcessPlugIn.h" + +@interface WKWebProcessPlugInController (Internal) + ++ (WKWebProcessPlugInController *)_shared; +- (id)_initWithPrincipalClassInstance:(id<WKWebProcessPlugIn>)principalClassInstance bundleRef:(WKBundleRef)bundleRef; + +@end + +#endif // defined(__LP64__) && defined(__clang__) diff --git a/Source/WebKit2/WebProcess/InjectedBundle/DOM/InjectedBundleNodeHandle.cpp b/Source/WebKit2/WebProcess/InjectedBundle/DOM/InjectedBundleNodeHandle.cpp index 0c4295e61..77e03093d 100644 --- a/Source/WebKit2/WebProcess/InjectedBundle/DOM/InjectedBundleNodeHandle.cpp +++ b/Source/WebKit2/WebProcess/InjectedBundle/DOM/InjectedBundleNodeHandle.cpp @@ -69,10 +69,10 @@ PassRefPtr<InjectedBundleNodeHandle> InjectedBundleNodeHandle::getOrCreate(Node* DOMHandleCache::AddResult result = domHandleCache().add(node, 0); if (!result.isNewEntry) - return PassRefPtr<InjectedBundleNodeHandle>(result.iterator->second); + return PassRefPtr<InjectedBundleNodeHandle>(result.iterator->value); RefPtr<InjectedBundleNodeHandle> nodeHandle = InjectedBundleNodeHandle::create(node); - result.iterator->second = nodeHandle.get(); + result.iterator->value = nodeHandle.get(); return nodeHandle.release(); } diff --git a/Source/WebKit2/WebProcess/InjectedBundle/DOM/InjectedBundleRangeHandle.cpp b/Source/WebKit2/WebProcess/InjectedBundle/DOM/InjectedBundleRangeHandle.cpp index 1b74f0124..d6000ab91 100644 --- a/Source/WebKit2/WebProcess/InjectedBundle/DOM/InjectedBundleRangeHandle.cpp +++ b/Source/WebKit2/WebProcess/InjectedBundle/DOM/InjectedBundleRangeHandle.cpp @@ -48,10 +48,10 @@ PassRefPtr<InjectedBundleRangeHandle> InjectedBundleRangeHandle::getOrCreate(Ran DOMHandleCache::AddResult result = domHandleCache().add(range, 0); if (!result.isNewEntry) - return PassRefPtr<InjectedBundleRangeHandle>(result.iterator->second); + return PassRefPtr<InjectedBundleRangeHandle>(result.iterator->value); RefPtr<InjectedBundleRangeHandle> rangeHandle = InjectedBundleRangeHandle::create(range); - result.iterator->second = rangeHandle.get(); + result.iterator->value = rangeHandle.get(); return rangeHandle.release(); } diff --git a/Source/WebKit2/WebProcess/InjectedBundle/InjectedBundle.cpp b/Source/WebKit2/WebProcess/InjectedBundle/InjectedBundle.cpp index 44d9a10ab..458b1c169 100644 --- a/Source/WebKit2/WebProcess/InjectedBundle/InjectedBundle.cpp +++ b/Source/WebKit2/WebProcess/InjectedBundle/InjectedBundle.cpp @@ -28,7 +28,6 @@ #include "Arguments.h" #include "ImmutableArray.h" -#include "InjectedBundleMessageKinds.h" #include "InjectedBundleScriptWorld.h" #include "InjectedBundleUserMessageCoders.h" #include "LayerTreeHost.h" @@ -61,6 +60,7 @@ #include <WebCore/PageVisibilityState.h> #include <WebCore/PrintContext.h> #include <WebCore/ResourceHandle.h> +#include <WebCore/ResourceLoadScheduler.h> #include <WebCore/ScriptController.h> #include <WebCore/SecurityOrigin.h> #include <WebCore/SecurityPolicy.h> @@ -426,23 +426,24 @@ bool InjectedBundle::isProcessingUserGesture() return ScriptController::processingUserGesture(); } -static PassOwnPtr<Vector<String> > toStringVector(ImmutableArray* patterns) +static Vector<String> toStringVector(ImmutableArray* patterns) { + Vector<String> patternsVector; + if (!patterns) - return nullptr; + return patternsVector; - size_t size = patterns->size(); + size_t size = patterns->size(); if (!size) - return nullptr; + return patternsVector; - OwnPtr<Vector<String> > patternsVector = adoptPtr(new Vector<String>); - patternsVector->reserveInitialCapacity(size); + patternsVector.reserveInitialCapacity(size); for (size_t i = 0; i < size; ++i) { WebString* entry = patterns->at<WebString>(i); if (entry) - patternsVector->uncheckedAppend(entry->string()); + patternsVector.uncheckedAppend(entry->string()); } - return patternsVector.release(); + return patternsVector; } void InjectedBundle::addUserScript(WebPageGroupProxy* pageGroup, InjectedBundleScriptWorld* scriptWorld, const String& source, const String& url, ImmutableArray* whitelist, ImmutableArray* blacklist, WebCore::UserScriptInjectionTime injectionTime, WebCore::UserContentInjectedFrames injectedFrames) @@ -540,46 +541,9 @@ void InjectedBundle::didReceiveMessageToPage(WebPage* page, const String& messag m_client.didReceiveMessageToPage(this, page, messageName, messageBody); } -void InjectedBundle::didReceiveMessage(CoreIPC::Connection*, CoreIPC::MessageID messageID, CoreIPC::ArgumentDecoder* arguments) -{ - switch (messageID.get<InjectedBundleMessage::Kind>()) { - case InjectedBundleMessage::PostMessage: { - String messageName; - RefPtr<APIObject> messageBody; - InjectedBundleUserMessageDecoder messageDecoder(messageBody); - if (!arguments->decode(CoreIPC::Out(messageName, messageDecoder))) - return; - - didReceiveMessage(messageName, messageBody.get()); - return; - } - - case InjectedBundleMessage::PostMessageToPage: { - uint64_t pageID = arguments->destinationID(); - if (!pageID) - return; - - WebPage* page = WebProcess::shared().webPage(pageID); - if (!page) - return; - - String messageName; - RefPtr<APIObject> messageBody; - InjectedBundleUserMessageDecoder messageDecoder(messageBody); - if (!arguments->decode(CoreIPC::Out(messageName, messageDecoder))) - return; - - didReceiveMessageToPage(page, messageName, messageBody.get()); - return; - } - } - - ASSERT_NOT_REACHED(); -} - void InjectedBundle::setPageVisibilityState(WebPage* page, int state, bool isInitialState) { -#if ENABLE(PAGE_VISIBILITY_API) +#if ENABLE(PAGE_VISIBILITY_API) || ENABLE(HIDDEN_PAGE_DOM_TIMER_THROTTLING) page->corePage()->setVisibilityState(static_cast<PageVisibilityState>(state), isInitialState); #endif } @@ -646,4 +610,14 @@ void InjectedBundle::setTabKeyCyclesThroughElements(WebPage* page, bool enabled) page->corePage()->setTabKeyCyclesThroughElements(enabled); } +void InjectedBundle::setSerialLoadingEnabled(bool enabled) +{ + resourceLoadScheduler()->setSerialLoadingEnabled(enabled); +} + +void InjectedBundle::dispatchPendingLoadRequests() +{ + resourceLoadScheduler()->servePendingRequests(); +} + } // namespace WebKit diff --git a/Source/WebKit2/WebProcess/InjectedBundle/InjectedBundle.h b/Source/WebKit2/WebProcess/InjectedBundle/InjectedBundle.h index 1197256d5..754b13320 100644 --- a/Source/WebKit2/WebProcess/InjectedBundle/InjectedBundle.h +++ b/Source/WebKit2/WebProcess/InjectedBundle/InjectedBundle.h @@ -47,6 +47,10 @@ typedef struct _GModule GModule; #include <Eina.h> #endif +#if PLATFORM(MAC) +OBJC_CLASS NSBundle; +#endif + namespace CoreIPC { class ArgumentDecoder; class Connection; @@ -56,7 +60,7 @@ namespace CoreIPC { namespace WebKit { #if PLATFORM(MAC) -typedef CFBundleRef PlatformBundle; +typedef NSBundle *PlatformBundle; #elif PLATFORM(WIN) typedef HMODULE PlatformBundle; #elif PLATFORM(QT) @@ -164,8 +168,6 @@ public: void didReceiveMessage(const String&, APIObject*); void didReceiveMessageToPage(WebPage*, const String&, APIObject*); - void didReceiveMessage(CoreIPC::Connection*, CoreIPC::MessageID, CoreIPC::ArgumentDecoder*); - static void reportException(JSContextRef, JSValueRef exception); static bool isProcessingUserGesture(); @@ -175,6 +177,8 @@ public: static size_t workerThreadCount(); void setTabKeyCyclesThroughElements(WebPage*, bool enabled); + void setSerialLoadingEnabled(bool); + void dispatchPendingLoadRequests(); private: explicit InjectedBundle(const String&); diff --git a/Source/WebKit2/WebProcess/InjectedBundle/InjectedBundleIntent.cpp b/Source/WebKit2/WebProcess/InjectedBundle/InjectedBundleIntent.cpp index 92de61c6c..d8ac3a25d 100644 --- a/Source/WebKit2/WebProcess/InjectedBundle/InjectedBundleIntent.cpp +++ b/Source/WebKit2/WebProcess/InjectedBundle/InjectedBundleIntent.cpp @@ -79,7 +79,7 @@ PassRefPtr<ImmutableDictionary> InjectedBundleIntent::extras() const ImmutableDictionary::MapType wkExtras; HashMap<String, String>::const_iterator end = extras.end(); for (HashMap<String, String>::const_iterator it = extras.begin(); it != end; ++it) - wkExtras.set(it->first, WebString::create(it->second)); + wkExtras.set(it->key, WebString::create(it->value)); return ImmutableDictionary::adopt(wkExtras); } diff --git a/Source/WebKit2/WebProcess/InjectedBundle/mac/InjectedBundleMac.cpp b/Source/WebKit2/WebProcess/InjectedBundle/mac/InjectedBundleMac.mm index cb59192a9..de5eaf7de 100644 --- a/Source/WebKit2/WebProcess/InjectedBundle/mac/InjectedBundleMac.cpp +++ b/Source/WebKit2/WebProcess/InjectedBundle/mac/InjectedBundleMac.mm @@ -23,18 +23,25 @@ * THE POSSIBILITY OF SUCH DAMAGE. */ -#include "config.h" -#include "InjectedBundle.h" +#import "config.h" +#import "InjectedBundle.h" -#include "WKBundleAPICast.h" -#include "WKBundleInitialize.h" -#include <stdio.h> -#include <wtf/RetainPtr.h> -#include <wtf/text/CString.h> -#include <wtf/text/WTFString.h> +#import "WKBundleAPICast.h" +#import "WKBundleInitialize.h" +#import "WKWebProcessPlugInInternal.h" + +#import <Foundation/NSBundle.h> +#import <stdio.h> +#import <wtf/RetainPtr.h> +#import <wtf/text/CString.h> +#import <wtf/text/WTFString.h> using namespace WebCore; +@interface NSBundle (WKAppDetails) +- (CFBundleRef)_cfBundle; +@end + namespace WebKit { bool InjectedBundle::load(APIObject* initializationUserData) @@ -60,25 +67,53 @@ bool InjectedBundle::load(APIObject* initializationUserData) return false; } - m_platformBundle = CFBundleCreate(0, bundleURL.get()); + m_platformBundle = [[NSBundle alloc] initWithURL:(NSURL *)bundleURL.get()]; if (!m_platformBundle) { WTFLogAlways("InjectedBundle::load failed - Could not create the bundle.\n"); return false; } - if (!CFBundleLoadExecutable(m_platformBundle)) { + if (![m_platformBundle load]) { WTFLogAlways("InjectedBundle::load failed - Could not load the executable from the bundle.\n"); return false; } - WKBundleInitializeFunctionPtr initializeFunction = reinterpret_cast<WKBundleInitializeFunctionPtr>(CFBundleGetFunctionPointerForName(m_platformBundle, CFSTR("WKBundleInitialize"))); - if (!initializeFunction) { - WTFLogAlways("InjectedBundle::load failed - Could not find the initialize function in the bundle executable.\n"); + // First check to see if the bundle has a WKBundleInitialize function. + WKBundleInitializeFunctionPtr initializeFunction = reinterpret_cast<WKBundleInitializeFunctionPtr>(CFBundleGetFunctionPointerForName([m_platformBundle _cfBundle], CFSTR("WKBundleInitialize"))); + if (initializeFunction) { + initializeFunction(toAPI(this), toAPI(initializationUserData)); + return true; + } + +#if defined(__LP64__) && defined(__clang__) + // Otherwise, look to see if the bundle has a principal class + Class principalClass = [m_platformBundle principalClass]; + if (!principalClass) { + WTFLogAlways("InjectedBundle::load failed - No initialize function or principal class found in the bundle executable.\n"); + return false; + } + + if (![principalClass conformsToProtocol:@protocol(WKWebProcessPlugIn)]) { + WTFLogAlways("InjectedBundle::load failed - Principal class does not conform to the WKWebProcessPlugIn protocol.\n"); + return false; + } + + id<WKWebProcessPlugIn> instance = (id<WKWebProcessPlugIn>)[[principalClass alloc] init]; + if (!instance) { + WTFLogAlways("InjectedBundle::load failed - Could not initialize an instance of the principal class.\n"); return false; } - initializeFunction(toAPI(this), toAPI(initializationUserData)); + // Create the shared WKWebProcessPlugInController. + [[WKWebProcessPlugInController alloc] _initWithPrincipalClassInstance:instance bundleRef:toAPI(this)]; + + if ([instance respondsToSelector:@selector(webProcessPlugInInitialize:)]) + [instance webProcessPlugInInitialize:[WKWebProcessPlugInController _shared]]; + return true; +#else + return false; +#endif } void InjectedBundle::activateMacFontAscentHack() diff --git a/Source/WebKit2/WebProcess/Notifications/NotificationPermissionRequestManager.cpp b/Source/WebKit2/WebProcess/Notifications/NotificationPermissionRequestManager.cpp index 44b97eb4e..c7788ae0f 100644 --- a/Source/WebKit2/WebProcess/Notifications/NotificationPermissionRequestManager.cpp +++ b/Source/WebKit2/WebProcess/Notifications/NotificationPermissionRequestManager.cpp @@ -84,7 +84,8 @@ void NotificationPermissionRequestManager::startRequest(SecurityOrigin* origin, { NotificationClient::Permission permission = permissionLevel(origin); if (permission != NotificationClient::PermissionNotAllowed) { - callback->handleEvent(); + if (callback) + callback->handleEvent(); return; } diff --git a/Source/WebKit2/WebProcess/Notifications/WebNotificationManager.cpp b/Source/WebKit2/WebProcess/Notifications/WebNotificationManager.cpp index 5ac2cdc3e..7b68912fe 100644 --- a/Source/WebKit2/WebProcess/Notifications/WebNotificationManager.cpp +++ b/Source/WebKit2/WebProcess/Notifications/WebNotificationManager.cpp @@ -107,7 +107,7 @@ NotificationClient::Permission WebNotificationManager::policyForOrigin(WebCore:: ASSERT(!origin->isUnique()); HashMap<String, bool>::const_iterator it = m_permissionsMap.find(origin->toRawString()); if (it != m_permissionsMap.end()) - return it->second ? NotificationClient::PermissionAllowed : NotificationClient::PermissionDenied; + return it->value ? NotificationClient::PermissionAllowed : NotificationClient::PermissionDenied; #else UNUSED_PARAM(origin); #endif @@ -145,7 +145,7 @@ bool WebNotificationManager::show(Notification* notification, WebPage* page) m_notificationIDMap.set(notificationID, notification); NotificationContextMap::iterator it = m_notificationContextMap.add(notification->scriptExecutionContext(), Vector<uint64_t>()).iterator; - it->second.append(notificationID); + it->value.append(notificationID); #if ENABLE(NOTIFICATIONS) m_process->connection()->send(Messages::WebPageProxy::ShowNotification(notification->title(), notification->body(), notification->iconURL().string(), notification->tag(), notification->lang(), notification->dir(), notification->scriptExecutionContext()->securityOrigin()->toString(), notificationID), page->pageID()); @@ -184,7 +184,7 @@ void WebNotificationManager::clearNotifications(WebCore::ScriptExecutionContext* if (it == m_notificationContextMap.end()) return; - Vector<uint64_t>& notificationIDs = it->second; + Vector<uint64_t>& notificationIDs = it->value; m_process->connection()->send(Messages::WebNotificationManagerProxy::ClearNotifications(notificationIDs), page->pageID()); size_t count = notificationIDs.size(); for (size_t i = 0; i < count; ++i) { @@ -281,10 +281,10 @@ void WebNotificationManager::removeNotificationFromContextMap(uint64_t notificat // This is a helper function for managing the hash maps. NotificationContextMap::iterator it = m_notificationContextMap.find(notification->scriptExecutionContext()); ASSERT(it != m_notificationContextMap.end()); - size_t index = it->second.find(notificationID); + size_t index = it->value.find(notificationID); ASSERT(index != notFound); - it->second.remove(index); - if (it->second.isEmpty()) + it->value.remove(index); + if (it->value.isEmpty()) m_notificationContextMap.remove(it); } #endif diff --git a/Source/WebKit2/WebProcess/Plugins/Netscape/JSNPObject.cpp b/Source/WebKit2/WebProcess/Plugins/Netscape/JSNPObject.cpp index 56e1a1097..51fb15d8e 100644 --- a/Source/WebKit2/WebProcess/Plugins/Netscape/JSNPObject.cpp +++ b/Source/WebKit2/WebProcess/Plugins/Netscape/JSNPObject.cpp @@ -54,10 +54,10 @@ static NPIdentifier npIdentifierFromIdentifier(PropertyName propertyName) return static_cast<NPIdentifier>(IdentifierRep::get(name.utf8().data())); } -const ClassInfo JSNPObject::s_info = { "NPObject", &JSNonFinalObject::s_info, 0, 0, CREATE_METHOD_TABLE(JSNPObject) }; +const ClassInfo JSNPObject::s_info = { "NPObject", &Base::s_info, 0, 0, CREATE_METHOD_TABLE(JSNPObject) }; JSNPObject::JSNPObject(JSGlobalObject* globalObject, Structure* structure, NPRuntimeObjectMap* objectMap, NPObject* npObject) - : JSNonFinalObject(globalObject->globalData(), structure) + : JSDestructibleObject(globalObject->globalData(), structure) , m_objectMap(objectMap) , m_npObject(npObject) { @@ -404,7 +404,7 @@ bool JSNPObject::deleteProperty(ExecState* exec, NPIdentifier propertyName) return true; } -void JSNPObject::getOwnPropertyNames(JSObject* object, ExecState* exec, PropertyNameArray& propertyNameArray, EnumerationMode mode) +void JSNPObject::getOwnPropertyNames(JSObject* object, ExecState* exec, PropertyNameArray& propertyNameArray, EnumerationMode) { JSNPObject* thisObject = jsCast<JSNPObject*>(object); ASSERT_GC_OBJECT_INHERITS(thisObject, &s_info); diff --git a/Source/WebKit2/WebProcess/Plugins/Netscape/JSNPObject.h b/Source/WebKit2/WebProcess/Plugins/Netscape/JSNPObject.h index 5723baa92..662d6c637 100644 --- a/Source/WebKit2/WebProcess/Plugins/Netscape/JSNPObject.h +++ b/Source/WebKit2/WebProcess/Plugins/Netscape/JSNPObject.h @@ -41,9 +41,9 @@ class NPRuntimeObjectMap; // JSNPObject is a JSObject that wraps an NPObject. -class JSNPObject : public JSC::JSNonFinalObject { +class JSNPObject : public JSC::JSDestructibleObject { public: - typedef JSC::JSNonFinalObject Base; + typedef JSC::JSDestructibleObject Base; static JSNPObject* create(JSC::JSGlobalObject* globalObject, NPRuntimeObjectMap* objectMap, NPObject* npObject) { diff --git a/Source/WebKit2/WebProcess/Plugins/Netscape/NPRuntimeObjectMap.cpp b/Source/WebKit2/WebProcess/Plugins/Netscape/NPRuntimeObjectMap.cpp index 9dcd91669..fca8909d6 100644 --- a/Source/WebKit2/WebProcess/Plugins/Netscape/NPRuntimeObjectMap.cpp +++ b/Source/WebKit2/WebProcess/Plugins/Netscape/NPRuntimeObjectMap.cpp @@ -212,7 +212,7 @@ void NPRuntimeObjectMap::invalidate() Vector<NPObject*> objects; for (HashMap<NPObject*, JSC::Weak<JSNPObject> >::iterator ptr = m_jsNPObjects.begin(), end = m_jsNPObjects.end(); ptr != end; ++ptr) { - JSNPObject* jsNPObject = ptr->second.get(); + JSNPObject* jsNPObject = ptr->value.get(); if (!jsNPObject) // Skip zombies. continue; objects.append(jsNPObject->leakNPObject()); diff --git a/Source/WebKit2/WebProcess/Plugins/Netscape/NetscapeBrowserFuncs.cpp b/Source/WebKit2/WebProcess/Plugins/Netscape/NetscapeBrowserFuncs.cpp index 3a428e63a..27b10e726 100644 --- a/Source/WebKit2/WebProcess/Plugins/Netscape/NetscapeBrowserFuncs.cpp +++ b/Source/WebKit2/WebProcess/Plugins/Netscape/NetscapeBrowserFuncs.cpp @@ -306,19 +306,19 @@ static NPError NPN_PostURL(NPP npp, const char* url, const char* target, uint32_ return NPERR_NO_ERROR; } -static NPError NPN_RequestRead(NPStream* stream, NPByteRange* rangeList) +static NPError NPN_RequestRead(NPStream*, NPByteRange*) { notImplemented(); return NPERR_GENERIC_ERROR; } -static NPError NPN_NewStream(NPP instance, NPMIMEType type, const char* target, NPStream** stream) +static NPError NPN_NewStream(NPP, NPMIMEType, const char*, NPStream**) { notImplemented(); return NPERR_GENERIC_ERROR; } -static int32_t NPN_Write(NPP instance, NPStream* stream, int32_t len, void* buffer) +static int32_t NPN_Write(NPP, NPStream*, int32_t, void*) { notImplemented(); return -1; @@ -358,12 +358,12 @@ static void NPN_MemFree(void* ptr) npnMemFree(ptr); } -static uint32_t NPN_MemFlush(uint32_t size) +static uint32_t NPN_MemFlush(uint32_t) { return 0; } -static void NPN_ReloadPlugins(NPBool reloadPages) +static void NPN_ReloadPlugins(NPBool) { notImplemented(); } @@ -374,7 +374,7 @@ static JRIEnv* NPN_GetJavaEnv(void) return 0; } -static jref NPN_GetJavaPeer(NPP instance) +static jref NPN_GetJavaPeer(NPP) { notImplemented(); return 0; @@ -612,14 +612,14 @@ static void NPN_InvalidateRect(NPP npp, NPRect* invalidRect) plugin->invalidate(invalidRect); } -static void NPN_InvalidateRegion(NPP npp, NPRegion invalidRegion) +static void NPN_InvalidateRegion(NPP npp, NPRegion) { // FIXME: We could at least figure out the bounding rectangle of the invalid region. RefPtr<NetscapePlugin> plugin = NetscapePlugin::fromNPP(npp); plugin->invalidate(0); } -static void NPN_ForceRedraw(NPP instance) +static void NPN_ForceRedraw(NPP) { notImplemented(); } diff --git a/Source/WebKit2/WebProcess/Plugins/Netscape/NetscapePlugin.cpp b/Source/WebKit2/WebProcess/Plugins/Netscape/NetscapePlugin.cpp index d67ac9511..374eb4414 100644 --- a/Source/WebKit2/WebProcess/Plugins/Netscape/NetscapePlugin.cpp +++ b/Source/WebKit2/WebProcess/Plugins/Netscape/NetscapePlugin.cpp @@ -198,8 +198,8 @@ NPError NetscapePlugin::destroyStream(NPStream* stream, NPReason reason) NetscapePluginStream* pluginStream = 0; for (StreamsMap::const_iterator it = m_streams.begin(), end = m_streams.end(); it != end; ++it) { - if (it->second->npStream() == stream) { - pluginStream = it->second.get(); + if (it->value->npStream() == stream) { + pluginStream = it->value.get(); break; } } @@ -768,8 +768,8 @@ void NetscapePlugin::frameDidFinishLoading(uint64_t requestID) if (it == m_pendingURLNotifications.end()) return; - String url = it->second.first; - void* notificationData = it->second.second; + String url = it->value.first; + void* notificationData = it->value.second; m_pendingURLNotifications.remove(it); @@ -784,8 +784,8 @@ void NetscapePlugin::frameDidFail(uint64_t requestID, bool wasCancelled) if (it == m_pendingURLNotifications.end()) return; - String url = it->second.first; - void* notificationData = it->second.second; + String url = it->value.first; + void* notificationData = it->value.second; m_pendingURLNotifications.remove(it); @@ -913,6 +913,21 @@ bool NetscapePlugin::handleKeyboardEvent(const WebKeyboardEvent& keyboardEvent) return platformHandleKeyboardEvent(keyboardEvent); } +bool NetscapePlugin::handleEditingCommand(const String& /* commandName */, const String& /* argument */) +{ + return false; +} + +bool NetscapePlugin::isEditingCommandEnabled(const String& /* commandName */) +{ + return false; +} + +bool NetscapePlugin::handlesPageScaleFactor() +{ + return false; +} + void NetscapePlugin::setFocus(bool hasFocus) { ASSERT(m_isStarted); @@ -943,6 +958,8 @@ void NetscapePlugin::contentsScaleFactorChanged(float scaleFactor) #if PLUGIN_ARCHITECTURE(MAC) double contentsScaleFactor = scaleFactor; NPP_SetValue(NPNVcontentsScaleFactor, &contentsScaleFactor); +#else + UNUSED_PARAM(scaleFactor); #endif } diff --git a/Source/WebKit2/WebProcess/Plugins/Netscape/NetscapePlugin.h b/Source/WebKit2/WebProcess/Plugins/Netscape/NetscapePlugin.h index 61e2bb798..1f6168aad 100644 --- a/Source/WebKit2/WebProcess/Plugins/Netscape/NetscapePlugin.h +++ b/Source/WebKit2/WebProcess/Plugins/Netscape/NetscapePlugin.h @@ -203,6 +203,12 @@ private: virtual bool handleContextMenuEvent(const WebMouseEvent&); virtual bool handleKeyboardEvent(const WebKeyboardEvent&); virtual void setFocus(bool); + + virtual bool handleEditingCommand(const String& commandName, const String& argument) OVERRIDE; + virtual bool isEditingCommandEnabled(const String&) OVERRIDE; + + virtual bool handlesPageScaleFactor() OVERRIDE; + virtual NPObject* pluginScriptableNPObject(); #if PLATFORM(MAC) diff --git a/Source/WebKit2/WebProcess/Plugins/Netscape/mac/NetscapeSandboxFunctions.mm b/Source/WebKit2/WebProcess/Plugins/Netscape/mac/NetscapeSandboxFunctions.mm index 07cd2e708..e9474495a 100644 --- a/Source/WebKit2/WebProcess/Plugins/Netscape/mac/NetscapeSandboxFunctions.mm +++ b/Source/WebKit2/WebProcess/Plugins/Netscape/mac/NetscapeSandboxFunctions.mm @@ -109,6 +109,10 @@ NPError enterSandbox(const char* sandboxProfile, const char* readOnlyPaths[], co exit(EX_NOPERM); } setenv("TMPDIR", temporaryDirectory, 1); + if (chdir(temporaryDirectory) == -1) { + WTFLogAlways("PluginProcess: couldn't change working directory to temporary path: %s, errno %d\n", temporaryDirectory, errno); + exit(EX_OSERR); + } #endif diff --git a/Source/WebKit2/WebProcess/Plugins/Netscape/gtk/PluginProxyGtk.cpp b/Source/WebKit2/WebProcess/Plugins/Netscape/unix/PluginProxyUnix.cpp index 996af20ca..996af20ca 100644 --- a/Source/WebKit2/WebProcess/Plugins/Netscape/gtk/PluginProxyGtk.cpp +++ b/Source/WebKit2/WebProcess/Plugins/Netscape/unix/PluginProxyUnix.cpp diff --git a/Source/WebKit2/WebProcess/Plugins/Netscape/x11/NetscapePluginX11.cpp b/Source/WebKit2/WebProcess/Plugins/Netscape/x11/NetscapePluginX11.cpp index 5c9e67872..30a0e86cd 100644 --- a/Source/WebKit2/WebProcess/Plugins/Netscape/x11/NetscapePluginX11.cpp +++ b/Source/WebKit2/WebProcess/Plugins/Netscape/x11/NetscapePluginX11.cpp @@ -37,15 +37,20 @@ #if PLATFORM(QT) #include <WebCore/QtX11ImageConversion.h> #elif PLATFORM(GTK) -#include "PlatformContextCairo.h" -#include "RefPtrCairo.h" -#include <cairo-xlib.h> #include <gtk/gtk.h> #ifndef GTK_API_VERSION_2 #include <gtk/gtkx.h> #endif #include <gdk/gdkx.h> #include <WebCore/GtkVersioning.h> +#elif PLATFORM(EFL) && defined(HAVE_ECORE_X) +#include <Ecore_X.h> +#endif + +#if USE(CAIRO) && !PLATFORM(WIN_CAIRO) +#include "PlatformContextCairo.h" +#include "RefPtrCairo.h" +#include <cairo/cairo-xlib.h> #endif using namespace WebCore; @@ -84,6 +89,8 @@ static Display* getPluginDisplay() // Since we're a gdk/gtk app, we'll (probably?) have the same X connection as any gdk-based // plugins, so we can return that. We might want to add other implementations here later. return GDK_DISPLAY_XDISPLAY(gdk_display_get_default()); +#elif PLATFORM(EFL) && defined(HAVE_ECORE_X) + return static_cast<Display*>(ecore_x_display_get()); #else return 0; #endif @@ -95,6 +102,8 @@ static inline int x11Screen() return XDefaultScreen(NetscapePlugin::x11HostDisplay()); #elif PLATFORM(GTK) return gdk_screen_get_number(gdk_screen_get_default()); +#elif PLATFORM(EFL) && defined(HAVE_ECORE_X) + return ecore_x_screen_index_get(ecore_x_default_screen_get()); #else return 0; #endif @@ -106,6 +115,8 @@ static inline int displayDepth() return XDefaultDepth(NetscapePlugin::x11HostDisplay(), x11Screen()); #elif PLATFORM(GTK) return gdk_visual_get_depth(gdk_screen_get_system_visual(gdk_screen_get_default())); +#elif PLATFORM(EFL) && defined(HAVE_ECORE_X) + return ecore_x_default_depth_get(NetscapePlugin::x11HostDisplay(), ecore_x_default_screen_get()); #else return 0; #endif @@ -117,6 +128,8 @@ static inline unsigned long rootWindowID() return XDefaultRootWindow(NetscapePlugin::x11HostDisplay()); #elif PLATFORM(GTK) return GDK_ROOT_WINDOW(); +#elif PLATFORM(EFL) && defined(HAVE_ECORE_X) + return ecore_x_window_root_first_get(); #else return 0; #endif @@ -144,6 +157,8 @@ Display* NetscapePlugin::x11HostDisplay() return dedicatedDisplay; #elif PLATFORM(GTK) return GDK_DISPLAY_XDISPLAY(gdk_display_get_default()); +#elif PLATFORM(EFL) && defined(HAVE_ECORE_X) + return static_cast<Display*>(ecore_x_display_get()); #else return 0; #endif @@ -188,6 +203,8 @@ bool NetscapePlugin::platformPostInitializeWindowed(bool needsXEmbed, uint64_t w callbackStruct->visual = GDK_VISUAL_XVISUAL(gdk_window_get_visual(window)); callbackStruct->depth = gdk_visual_get_depth(gdk_window_get_visual(window)); callbackStruct->colormap = XCreateColormap(display, GDK_ROOT_WINDOW(), callbackStruct->visual, AllocNone); +#else + UNUSED_PARAM(windowID); #endif XFlush(display); @@ -357,7 +374,7 @@ void NetscapePlugin::platformPaint(GraphicsContext* context, const IntRect& dirt painter->drawImage(QPoint(exposedRect.x(), exposedRect.y()), qimageFromXImage(xImage), exposedRect); XDestroyImage(xImage); -#elif PLATFORM(GTK) +#elif PLATFORM(GTK) || (PLATFORM(EFL) && USE(CAIRO)) RefPtr<cairo_surface_t> drawableSurface = adoptRef(cairo_xlib_surface_create(m_pluginDisplay, m_drawable, static_cast<NPSetWindowCallbackStruct*>(m_npWindow.ws_info)->visual, diff --git a/Source/WebKit2/WebProcess/Plugins/PDF/PDFPlugin.h b/Source/WebKit2/WebProcess/Plugins/PDF/PDFPlugin.h new file mode 100644 index 000000000..cd58d8721 --- /dev/null +++ b/Source/WebKit2/WebProcess/Plugins/PDF/PDFPlugin.h @@ -0,0 +1,104 @@ +/* + * Copyright (C) 2011, 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 PDFPlugin_h +#define PDFPlugin_h + +#if ENABLE(PDFKIT_PLUGIN) + +#include "Plugin.h" +#include "SimplePDFPlugin.h" +#include <WebCore/AffineTransform.h> +#include <WebCore/ScrollableArea.h> +#include <wtf/RetainPtr.h> + +typedef const struct OpaqueJSContext* JSContextRef; +typedef struct OpaqueJSValue* JSObjectRef; +typedef const struct OpaqueJSValue* JSValueRef; + +OBJC_CLASS PDFLayerController; +OBJC_CLASS WKPDFLayerControllerDelegate; + +namespace WebCore { +struct PluginInfo; +} + +namespace WebKit { + +class PluginView; +class WebFrame; + +class PDFPlugin : public SimplePDFPlugin { +public: + static PassRefPtr<PDFPlugin> create(WebFrame*); + ~PDFPlugin(); + + void paintControlForLayerInContext(CALayer *, CGContextRef); + + using ScrollableArea::notifyScrollPositionChanged; + +private: + explicit PDFPlugin(WebFrame*); + + virtual void updateScrollbars() OVERRIDE; + virtual PassRefPtr<WebCore::Scrollbar> createScrollbar(WebCore::ScrollbarOrientation) OVERRIDE; + virtual void destroyScrollbar(WebCore::ScrollbarOrientation) OVERRIDE; + virtual void pdfDocumentDidLoad() OVERRIDE; + virtual void calculateSizes() OVERRIDE; + + virtual void destroy() OVERRIDE; + virtual void paint(WebCore::GraphicsContext*, const WebCore::IntRect& dirtyRectInWindowCoordinates) OVERRIDE; + virtual PassRefPtr<ShareableBitmap> snapshot() OVERRIDE; + virtual PlatformLayer* pluginLayer() OVERRIDE; + virtual void geometryDidChange(const WebCore::IntSize& pluginSize, const WebCore::IntRect& clipRect, const WebCore::AffineTransform& pluginToRootViewTransform) OVERRIDE; + virtual bool handleMouseEvent(const WebMouseEvent&) OVERRIDE; + virtual bool handleKeyboardEvent(const WebKeyboardEvent&) OVERRIDE; + virtual bool handleEditingCommand(const String& commandName, const String& argument) OVERRIDE; + virtual bool isEditingCommandEnabled(const String&) OVERRIDE; + virtual bool handlesPageScaleFactor() OVERRIDE { return true; } + + // ScrollableArea functions. + virtual void setScrollOffset(const WebCore::IntPoint&) OVERRIDE; + virtual void invalidateScrollbarRect(WebCore::Scrollbar*, const WebCore::IntRect&) OVERRIDE; + virtual void invalidateScrollCornerRect(const WebCore::IntRect&) OVERRIDE; + + RetainPtr<CALayer> m_containerLayer; + RetainPtr<CALayer> m_contentLayer; + RetainPtr<CALayer> m_horizontalScrollbarLayer; + RetainPtr<CALayer> m_verticalScrollbarLayer; + RetainPtr<CALayer> m_scrollCornerLayer; + RetainPtr<PDFLayerController> m_pdfLayerController; + + WebCore::AffineTransform m_rootViewToPluginTransform; + WebCore::IntPoint m_lastMousePoint; + + RetainPtr<WKPDFLayerControllerDelegate> m_pdfLayerControllerDelegate; +}; + +} // namespace WebKit + +#endif // ENABLE(PDFKIT_PLUGIN) + +#endif // PDFPlugin_h diff --git a/Source/WebKit2/WebProcess/Plugins/PDF/PDFPlugin.mm b/Source/WebKit2/WebProcess/Plugins/PDF/PDFPlugin.mm new file mode 100644 index 000000000..c5a3469cd --- /dev/null +++ b/Source/WebKit2/WebProcess/Plugins/PDF/PDFPlugin.mm @@ -0,0 +1,582 @@ +/* + * Copyright (C) 2009, 2011, 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. + */ + +#if ENABLE(PDFKIT_PLUGIN) + +#import "config.h" +#import "PDFPlugin.h" + +#import "PDFKitImports.h" +#import "PluginView.h" +#import "ShareableBitmap.h" +#import "WebEvent.h" +#import "WebEventConversion.h" +#import <PDFKit/PDFKit.h> +#import <QuartzCore/QuartzCore.h> +#import <WebCore/ArchiveResource.h> +#import <WebCore/Chrome.h> +#import <WebCore/DocumentLoader.h> +#import <WebCore/FocusController.h> +#import <WebCore/Frame.h> +#import <WebCore/FrameView.h> +#import <WebCore/GraphicsContext.h> +#import <WebCore/HTTPHeaderMap.h> +#import <WebCore/LocalizedStrings.h> +#import <WebCore/Page.h> +#import <WebCore/Pasteboard.h> +#import <WebCore/PluginData.h> +#import <WebCore/RenderBoxModelObject.h> +#import <WebCore/ScrollAnimator.h> +#import <WebCore/ScrollbarTheme.h> + +@protocol PDFLayerControllerDelegate <NSObject> + +- (void)updateScrollPosition:(CGPoint)newPosition; +- (void)writeItemsToPasteboard:(NSArray *)items withTypes:(NSArray *)types; +- (void)showDefinitionForAttributedString:(NSAttributedString *)string atPoint:(CGPoint)point; +- (void)performWebSearch:(NSString *)string; +- (void)openWithPreview; +- (void)saveToPDF; + +@end + +@interface PDFLayerController : NSObject +@end + +@interface PDFLayerController (Details) + +@property (retain) CALayer *parentLayer; +@property (retain) PDFDocument *document; +@property (retain) id<PDFLayerControllerDelegate> delegate; + +- (void)setFrameSize:(CGSize)size; + +- (void)setDisplayMode:(int)mode; +- (void)setDisplaysPageBreaks:(BOOL)pageBreaks; + +- (CGFloat)tileScaleFactor; +- (void)setTileScaleFactor:(CGFloat)scaleFactor; + +- (CGSize)contentSize; +- (CGSize)contentSizeRespectingZoom; + +- (void)snapshotInContext:(CGContextRef)context; + +- (void)magnifyWithMagnification:(CGFloat)magnification atPoint:(CGPoint)point immediately:(BOOL)immediately; + +- (CGPoint)scrollPosition; +- (void)setScrollPosition:(CGPoint)newPosition; +- (void)scrollWithDelta:(CGSize)delta; + +- (void)mouseDown:(NSEvent *)event; +- (void)mouseMoved:(NSEvent *)event; +- (void)mouseUp:(NSEvent *)event; +- (void)mouseDragged:(NSEvent *)event; +- (void)mouseEntered:(NSEvent *)event; +- (void)mouseExited:(NSEvent *)event; + +- (NSArray *)findString:(NSString *)string caseSensitive:(BOOL)isCaseSensitive highlightMatches:(BOOL)shouldHighlightMatches; + +- (id)currentSelection; +- (void)copySelection; +- (void)selectAll; + +- (bool)keyDown:(NSEvent *)event; + +- (void)setHUDEnabled:(BOOL)enabled; +- (BOOL)hudEnabled; + +@end + +using namespace WebCore; + +@interface WKPDFPluginScrollbarLayer : CALayer +{ + WebKit::PDFPlugin* _pdfPlugin; +} + +@property (assign) WebKit::PDFPlugin* pdfPlugin; + +@end + +@implementation WKPDFPluginScrollbarLayer + +@synthesize pdfPlugin=_pdfPlugin; + +- (id)initWithPDFPlugin:(WebKit::PDFPlugin *)plugin +{ + if (!(self = [super init])) + return nil; + + _pdfPlugin = plugin; + + return self; +} + +- (id<CAAction>)actionForKey:(NSString *)key +{ + return nil; +} + +- (void)drawInContext:(CGContextRef)ctx +{ + _pdfPlugin->paintControlForLayerInContext(self, ctx); +} + +@end + +@interface WKPDFLayerControllerDelegate : NSObject<PDFLayerControllerDelegate> +{ + WebKit::PDFPlugin* _pdfPlugin; +} + +@property (assign) WebKit::PDFPlugin* pdfPlugin; + +@end + +@implementation WKPDFLayerControllerDelegate + +@synthesize pdfPlugin=_pdfPlugin; + +- (id)initWithPDFPlugin:(WebKit::PDFPlugin *)plugin +{ + if (!(self = [super init])) + return nil; + + _pdfPlugin = plugin; + + return self; +} + +- (void)updateScrollPosition:(CGPoint)newPosition +{ + _pdfPlugin->notifyScrollPositionChanged(IntPoint(newPosition)); +} + +- (void)writeItemsToPasteboard:(NSArray *)items withTypes:(NSArray *)types +{ + // FIXME: Handle types other than plain text. + + for (NSUInteger i = 0, count = items.count; i < count; ++i) { + NSString *type = [types objectAtIndex:i]; + if ([type isEqualToString:NSStringPboardType] || [type isEqualToString:NSPasteboardTypeString]) { + RetainPtr<NSString> plainTextString(AdoptNS, [[NSString alloc] initWithData:[items objectAtIndex:i] encoding:NSUTF8StringEncoding]); + Pasteboard::generalPasteboard()->writePlainText(plainTextString.get(), Pasteboard::CannotSmartReplace); + } + } +} + +- (void)showDefinitionForAttributedString:(NSAttributedString *)string atPoint:(CGPoint)point +{ + // FIXME: Implement. +} + +- (void)performWebSearch:(NSString *)string +{ + // FIXME: Implement. +} + +- (void)openWithPreview +{ + // FIXME: Implement. +} + +- (void)saveToPDF +{ + // FIXME: Implement. +} + +@end + +namespace WebKit { + +PassRefPtr<PDFPlugin> PDFPlugin::create(WebFrame* frame) +{ + return adoptRef(new PDFPlugin(frame)); +} + +PDFPlugin::PDFPlugin(WebFrame* frame) + : SimplePDFPlugin(frame) + , m_containerLayer(AdoptNS, [[CALayer alloc] init]) + , m_contentLayer(AdoptNS, [[CALayer alloc] init]) + , m_scrollCornerLayer(AdoptNS, [[WKPDFPluginScrollbarLayer alloc] initWithPDFPlugin:this]) + , m_pdfLayerController(AdoptNS, [[pdfLayerControllerClass() alloc] init]) + , m_pdfLayerControllerDelegate(AdoptNS, [[WKPDFLayerControllerDelegate alloc] initWithPDFPlugin:this]) +{ + m_pdfLayerController.get().delegate = m_pdfLayerControllerDelegate.get(); + m_pdfLayerController.get().parentLayer = m_contentLayer.get(); + + [m_containerLayer.get() addSublayer:m_contentLayer.get()]; + [m_containerLayer.get() addSublayer:m_scrollCornerLayer.get()]; +} + +PDFPlugin::~PDFPlugin() +{ +} + +void PDFPlugin::updateScrollbars() +{ + SimplePDFPlugin::updateScrollbars(); + + if (m_verticalScrollbarLayer) { + m_verticalScrollbarLayer.get().frame = verticalScrollbar()->frameRect(); + [m_verticalScrollbarLayer.get() setNeedsDisplay]; + } + + if (m_horizontalScrollbarLayer) { + m_horizontalScrollbarLayer.get().frame = horizontalScrollbar()->frameRect(); + [m_horizontalScrollbarLayer.get() setNeedsDisplay]; + } + + if (m_scrollCornerLayer) { + m_scrollCornerLayer.get().frame = scrollCornerRect(); + [m_scrollCornerLayer.get() setNeedsDisplay]; + } +} + +PassRefPtr<Scrollbar> PDFPlugin::createScrollbar(ScrollbarOrientation orientation) +{ + RefPtr<Scrollbar> widget = Scrollbar::createNativeScrollbar(this, orientation, RegularScrollbar); + if (orientation == HorizontalScrollbar) { + m_horizontalScrollbarLayer.adoptNS([[WKPDFPluginScrollbarLayer alloc] initWithPDFPlugin:this]); + [m_containerLayer.get() addSublayer:m_horizontalScrollbarLayer.get()]; + + didAddHorizontalScrollbar(widget.get()); + } else { + m_verticalScrollbarLayer.adoptNS([[WKPDFPluginScrollbarLayer alloc] initWithPDFPlugin:this]); + [m_containerLayer.get() addSublayer:m_verticalScrollbarLayer.get()]; + + didAddVerticalScrollbar(widget.get()); + } + pluginView()->frame()->view()->addChild(widget.get()); + return widget.release(); +} + +void PDFPlugin::destroyScrollbar(ScrollbarOrientation orientation) +{ + SimplePDFPlugin::destroyScrollbar(orientation); + + if (orientation == HorizontalScrollbar) { + [m_horizontalScrollbarLayer.get() removeFromSuperlayer]; + m_horizontalScrollbarLayer = 0; + } else { + [m_verticalScrollbarLayer.get() removeFromSuperlayer]; + m_verticalScrollbarLayer = 0; + } +} + +void PDFPlugin::pdfDocumentDidLoad() +{ + addArchiveResource(); + + RetainPtr<PDFDocument> document(AdoptNS, [[pdfDocumentClass() alloc] initWithData:(NSData *)data().get()]); + + setPDFDocument(document); + + [m_pdfLayerController.get() setFrameSize:size()]; + m_pdfLayerController.get().document = document.get(); + + pluginView()->setPageScaleFactor([m_pdfLayerController.get() tileScaleFactor], IntPoint()); + + calculateSizes(); + updateScrollbars(); + + controller()->invalidate(IntRect(IntPoint(), size())); + + runScriptsInPDFDocument(); +} + +void PDFPlugin::calculateSizes() +{ + // FIXME: This should come straight from PDFKit. + computePageBoxes(); + + setPDFDocumentSize(IntSize([m_pdfLayerController.get() contentSizeRespectingZoom])); +} + +void PDFPlugin::destroy() +{ + m_pdfLayerController.get().delegate = 0; + + if (webFrame()) { + if (FrameView* frameView = webFrame()->coreFrame()->view()) + frameView->removeScrollableArea(this); + } + + destroyScrollbar(HorizontalScrollbar); + destroyScrollbar(VerticalScrollbar); + + [m_scrollCornerLayer.get() removeFromSuperlayer]; + [m_contentLayer.get() removeFromSuperlayer]; +} + +void PDFPlugin::paint(GraphicsContext* graphicsContext, const IntRect& dirtyRect) +{ +} + +void PDFPlugin::paintControlForLayerInContext(CALayer *layer, CGContextRef context) +{ + GraphicsContext graphicsContext(context); + GraphicsContextStateSaver stateSaver(graphicsContext); + + graphicsContext.setIsCALayerContext(true); + + if (layer == m_scrollCornerLayer) { + IntRect scrollCornerRect = this->scrollCornerRect(); + graphicsContext.translate(-scrollCornerRect.x(), -scrollCornerRect.y()); + ScrollbarTheme::theme()->paintScrollCorner(0, &graphicsContext, scrollCornerRect); + return; + } + + Scrollbar* scrollbar = 0; + + if (layer == m_verticalScrollbarLayer) + scrollbar = verticalScrollbar(); + else if (layer == m_horizontalScrollbarLayer) + scrollbar = horizontalScrollbar(); + + if (!scrollbar) + return; + + graphicsContext.translate(-scrollbar->x(), -scrollbar->y()); + scrollbar->paint(&graphicsContext, scrollbar->frameRect()); +} + +PassRefPtr<ShareableBitmap> PDFPlugin::snapshot() +{ + if (size().isEmpty()) + return 0; + + // FIXME: Support non-1 page/deviceScaleFactor. + IntSize backingStoreSize = size(); + + RefPtr<ShareableBitmap> bitmap = ShareableBitmap::createShareable(backingStoreSize, ShareableBitmap::SupportsAlpha); + OwnPtr<GraphicsContext> context = bitmap->createGraphicsContext(); + + context->scale(FloatSize(1, -1)); + context->translate(0, -size().height()); + + [m_pdfLayerController.get() snapshotInContext:context->platformContext()]; + + return bitmap.release(); +} + +PlatformLayer* PDFPlugin::pluginLayer() +{ + return m_containerLayer.get(); +} + +void PDFPlugin::geometryDidChange(const IntSize& pluginSize, const IntRect&, const AffineTransform& pluginToRootViewTransform) +{ + if (size() == pluginSize && pluginView()->pageScaleFactor() == [m_pdfLayerController.get() tileScaleFactor]) + return; + + setSize(pluginSize); + m_rootViewToPluginTransform = pluginToRootViewTransform.inverse(); + [m_pdfLayerController.get() setFrameSize:pluginSize]; + + [CATransaction begin]; + [CATransaction setDisableActions:YES]; + CATransform3D transform = CATransform3DMakeScale(1, -1, 1); + + CGFloat magnification = pluginView()->pageScaleFactor() - [m_pdfLayerController.get() tileScaleFactor]; + + // FIXME: Instead of m_lastMousePoint, we should use the zoom origin from PluginView::setPageScaleFactor. + [m_pdfLayerController.get() magnifyWithMagnification:magnification atPoint:m_lastMousePoint immediately:YES]; + [m_contentLayer.get() setSublayerTransform:CATransform3DTranslate(transform, 0, -pluginSize.height(), 0)]; + [CATransaction commit]; + + calculateSizes(); + updateScrollbars(); +} + +static NSUInteger modifierFlagsFromWebEvent(const WebEvent& event) +{ + return (event.shiftKey() ? NSShiftKeyMask : 0) + | (event.controlKey() ? NSControlKeyMask : 0) + | (event.altKey() ? NSAlternateKeyMask : 0) + | (event.metaKey() ? NSCommandKeyMask : 0); +} + +static NSEventType eventTypeFromWebEvent(const WebEvent& event, bool mouseButtonIsDown) +{ + switch (event.type()) { + case WebEvent::KeyDown: + return NSKeyDown; + case WebEvent::KeyUp: + return NSKeyUp; + + case WebEvent::MouseDown: + switch (static_cast<const WebMouseEvent&>(event).button()) { + case WebMouseEvent::LeftButton: + return NSLeftMouseDown; + case WebMouseEvent::RightButton: + return NSRightMouseDown; + default: + return 0; + } + break; + case WebEvent::MouseUp: + switch (static_cast<const WebMouseEvent&>(event).button()) { + case WebMouseEvent::LeftButton: + return NSLeftMouseUp; + case WebMouseEvent::RightButton: + return NSRightMouseUp; + default: + return 0; + } + break; + case WebEvent::MouseMove: + if (mouseButtonIsDown) { + switch (static_cast<const WebMouseEvent&>(event).button()) { + case WebMouseEvent::LeftButton: + return NSLeftMouseDragged; + case WebMouseEvent::RightButton: + return NSRightMouseDragged; + default: + return 0; + } + } else + return NSMouseMoved; + break; + + default: + return 0; + } +} + +bool PDFPlugin::handleMouseEvent(const WebMouseEvent& event) +{ + static bool mouseButtonIsDown; + + IntPoint mousePosition = event.position(); + + // FIXME: Forward mouse events to the appropriate scrollbar. + if (IntRect(m_verticalScrollbarLayer.get().frame).contains(mousePosition) + || IntRect(m_horizontalScrollbarLayer.get().frame).contains(mousePosition) + || IntRect(m_scrollCornerLayer.get().frame).contains(mousePosition)) + return false; + + IntPoint positionInPDFView(mousePosition); + positionInPDFView = m_rootViewToPluginTransform.mapPoint(positionInPDFView); + positionInPDFView.setY(size().height() - positionInPDFView.y()); + + m_lastMousePoint = positionInPDFView; + + NSEventType eventType = eventTypeFromWebEvent(event, mouseButtonIsDown); + + if (!eventType) + return false; + + NSUInteger modifierFlags = modifierFlagsFromWebEvent(event); + + NSEvent *fakeEvent = [NSEvent mouseEventWithType:eventType location:positionInPDFView modifierFlags:modifierFlags timestamp:0 windowNumber:0 context:nil eventNumber:0 clickCount:event.clickCount() pressure:0]; + + switch (event.type()) { + case WebEvent::MouseMove: + if (mouseButtonIsDown) + [m_pdfLayerController.get() mouseDragged:fakeEvent]; + else + [m_pdfLayerController.get() mouseMoved:fakeEvent]; + mouseMovedInContentArea(); + return true; + case WebEvent::MouseDown: { + mouseButtonIsDown = true; + [m_pdfLayerController.get() mouseDown:fakeEvent]; + return true; + } + case WebEvent::MouseUp: { + [m_pdfLayerController.get() mouseUp:fakeEvent]; + mouseButtonIsDown = false; + PlatformMouseEvent platformEvent = platform(event); + return true; + } + default: + break; + } + + return false; +} + +bool PDFPlugin::handleKeyboardEvent(const WebKeyboardEvent& event) +{ + NSEventType eventType = eventTypeFromWebEvent(event, false); + NSUInteger modifierFlags = modifierFlagsFromWebEvent(event); + + NSEvent *fakeEvent = [NSEvent keyEventWithType:eventType location:NSZeroPoint modifierFlags:modifierFlags timestamp:0 windowNumber:0 context:0 characters:event.text() charactersIgnoringModifiers:event.unmodifiedText() isARepeat:event.isAutoRepeat() keyCode:event.nativeVirtualKeyCode()]; + + switch (event.type()) { + case WebEvent::KeyDown: + return [m_pdfLayerController.get() keyDown:fakeEvent]; + default: + return false; + } + + return false; +} + +bool PDFPlugin::handleEditingCommand(const String& commandName, const String& argument) +{ + if (commandName == "copy") + [m_pdfLayerController.get() copySelection]; + else if (commandName == "selectAll") + [m_pdfLayerController.get() selectAll]; + + return true; +} + +bool PDFPlugin::isEditingCommandEnabled(const String& commandName) +{ + if (commandName == "copy") + return [m_pdfLayerController.get() currentSelection]; + + if (commandName == "selectAll") + return true; + + return false; +} + +void PDFPlugin::setScrollOffset(const IntPoint& offset) +{ + SimplePDFPlugin::setScrollOffset(offset); + [m_pdfLayerController.get() setScrollPosition:offset]; +} + +void PDFPlugin::invalidateScrollbarRect(Scrollbar* scrollbar, const IntRect& rect) +{ + if (scrollbar == horizontalScrollbar()) + [m_horizontalScrollbarLayer.get() setNeedsDisplay]; + else if (scrollbar == verticalScrollbar()) + [m_verticalScrollbarLayer.get() setNeedsDisplay]; +} + +void PDFPlugin::invalidateScrollCornerRect(const IntRect& rect) +{ + [m_scrollCornerLayer.get() setNeedsDisplay]; +} + +} // namespace WebKit + +#endif // ENABLE(PDFKIT_PLUGIN) diff --git a/Source/WebKit2/WebProcess/Plugins/PDF/BuiltInPDFView.h b/Source/WebKit2/WebProcess/Plugins/PDF/SimplePDFPlugin.h index 1c8829d2b..6b8a93e04 100644 --- a/Source/WebKit2/WebProcess/Plugins/PDF/BuiltInPDFView.h +++ b/Source/WebKit2/WebProcess/Plugins/PDF/SimplePDFPlugin.h @@ -23,8 +23,8 @@ * THE POSSIBILITY OF SUCH DAMAGE. */ -#ifndef BuiltInPDFView_h -#define BuiltInPDFView_h +#ifndef SimplePDFPlugin_h +#define SimplePDFPlugin_h #include "Plugin.h" #include <WebCore/ScrollableArea.h> @@ -35,7 +35,7 @@ typedef struct OpaqueJSValue* JSObjectRef; typedef const struct OpaqueJSValue* JSValueRef; namespace WebCore { - struct PluginInfo; +struct PluginInfo; } namespace WebKit { @@ -43,32 +43,48 @@ namespace WebKit { class PluginView; class WebFrame; -class BuiltInPDFView : public Plugin, private WebCore::ScrollableArea { +class SimplePDFPlugin : public Plugin, protected WebCore::ScrollableArea { public: - static PassRefPtr<BuiltInPDFView> create(WebFrame*); - ~BuiltInPDFView(); + static PassRefPtr<SimplePDFPlugin> create(WebFrame*); + ~SimplePDFPlugin(); static WebCore::PluginInfo pluginInfo(); // In-process PDFViews don't support asynchronous initialization. virtual bool isBeingAsynchronouslyInitialized() const { return false; } -private: - explicit BuiltInPDFView(WebFrame*); +protected: + explicit SimplePDFPlugin(WebFrame*); + + WebFrame* webFrame() const { return m_frame; } + + WebCore::IntSize size() const { return m_size; } + void setSize(WebCore::IntSize size) { m_size = size; } + + RetainPtr<PDFDocument> pdfDocument() const { return m_pdfDocument; } + void setPDFDocument(RetainPtr<PDFDocument> document) { m_pdfDocument = document; } + + WebCore::IntSize pdfDocumentSize() const { return m_pdfDocumentSize; } + void setPDFDocumentSize(WebCore::IntSize size) { m_pdfDocumentSize = size; } + + RetainPtr<CFMutableDataRef> data() const { return m_data; } // Regular plug-ins don't need access to view, but we add scrollbars to embedding FrameView for proper event handling. PluginView* pluginView(); const PluginView* pluginView() const; - void updateScrollbars(); - PassRefPtr<WebCore::Scrollbar> createScrollbar(WebCore::ScrollbarOrientation); - void destroyScrollbar(WebCore::ScrollbarOrientation); - void addArchiveResource(); - void pdfDocumentDidLoad(); - void calculateSizes(); + virtual void updateScrollbars(); + virtual PassRefPtr<WebCore::Scrollbar> createScrollbar(WebCore::ScrollbarOrientation); + virtual void destroyScrollbar(WebCore::ScrollbarOrientation); + virtual void addArchiveResource(); + virtual void pdfDocumentDidLoad(); + virtual void computePageBoxes(); + virtual void calculateSizes(); void paintBackground(WebCore::GraphicsContext*, const WebCore::IntRect& dirtyRect); void paintContent(WebCore::GraphicsContext*, const WebCore::IntRect& dirtyRect); void paintControls(WebCore::GraphicsContext*, const WebCore::IntRect& dirtyRect); + + void runScriptsInPDFDocument(); // Plug-in methods virtual bool initialize(const Parameters&); @@ -143,18 +159,27 @@ private: virtual bool scrollbarsCanBeActive() const OVERRIDE; virtual bool shouldSuspendScrollAnimations() const OVERRIDE { return false; } // If we return true, ScrollAnimatorMac will keep cycling a timer forever, waiting for a good time to animate. virtual void scrollbarStyleChanged(int newStyle, bool forceUpdate) OVERRIDE; - // FIXME: Implement the other conversion functions; this one is enough to get scrollbar hit testing working. + + virtual WebCore::IntRect convertFromScrollbarToContainingView(const WebCore::Scrollbar*, const WebCore::IntRect& scrollbarRect) const OVERRIDE; + virtual WebCore::IntRect convertFromContainingViewToScrollbar(const WebCore::Scrollbar*, const WebCore::IntRect& parentRect) const OVERRIDE; + virtual WebCore::IntPoint convertFromScrollbarToContainingView(const WebCore::Scrollbar*, const WebCore::IntPoint& scrollbarPoint) const OVERRIDE; virtual WebCore::IntPoint convertFromContainingViewToScrollbar(const WebCore::Scrollbar*, const WebCore::IntPoint& parentPoint) const OVERRIDE; + + virtual bool isEditingCommandEnabled(const String&) OVERRIDE; + virtual bool handleEditingCommand(const String&, const String&) OVERRIDE; + virtual bool handlesPageScaleFactor() OVERRIDE; + +private: JSObjectRef makeJSPDFDoc(JSContextRef); static JSValueRef jsPDFDocPrint(JSContextRef, JSObjectRef function, JSObjectRef thisObject, size_t argumentCount, const JSValueRef arguments[], JSValueRef* exception); - WebCore::IntSize m_pluginSize; + WebCore::IntSize m_size; WebCore::KURL m_sourceURL; String m_suggestedFilename; - RetainPtr<CFMutableDataRef> m_dataBuffer; + RetainPtr<CFMutableDataRef> m_data; RetainPtr<PDFDocument> m_pdfDocument; Vector<WebCore::IntRect> m_pageBoxes; @@ -170,4 +195,4 @@ private: } // namespace WebKit -#endif // BuiltInPDFView_h +#endif // SimplePDFPlugin_h diff --git a/Source/WebKit2/WebProcess/Plugins/PDF/BuiltInPDFView.mm b/Source/WebKit2/WebProcess/Plugins/PDF/SimplePDFPlugin.mm index 8dcaea96c..98a73b2b1 100644 --- a/Source/WebKit2/WebProcess/Plugins/PDF/BuiltInPDFView.mm +++ b/Source/WebKit2/WebProcess/Plugins/PDF/SimplePDFPlugin.mm @@ -24,7 +24,7 @@ */ #import "config.h" -#import "BuiltInPDFView.h" +#import "SimplePDFPlugin.h" #import "PDFKitImports.h" #import "PluginView.h" @@ -156,21 +156,21 @@ const int shadowOffsetX = 0; const int shadowOffsetY = -2; const int shadowSize = 7; -PassRefPtr<BuiltInPDFView> BuiltInPDFView::create(WebFrame* frame) +PassRefPtr<SimplePDFPlugin> SimplePDFPlugin::create(WebFrame* frame) { - return adoptRef(new BuiltInPDFView(frame)); + return adoptRef(new SimplePDFPlugin(frame)); } -BuiltInPDFView::BuiltInPDFView(WebFrame* frame) +SimplePDFPlugin::SimplePDFPlugin(WebFrame* frame) : m_frame(frame) { } -BuiltInPDFView::~BuiltInPDFView() +SimplePDFPlugin::~SimplePDFPlugin() { } -PluginInfo BuiltInPDFView::pluginInfo() +PluginInfo SimplePDFPlugin::pluginInfo() { PluginInfo info; info.name = builtInPDFPluginName(); @@ -184,30 +184,30 @@ PluginInfo BuiltInPDFView::pluginInfo() return info; } -PluginView* BuiltInPDFView::pluginView() +PluginView* SimplePDFPlugin::pluginView() { return static_cast<PluginView*>(controller()); } -const PluginView* BuiltInPDFView::pluginView() const +const PluginView* SimplePDFPlugin::pluginView() const { return static_cast<const PluginView*>(controller()); } -void BuiltInPDFView::updateScrollbars() +void SimplePDFPlugin::updateScrollbars() { bool hadScrollbars = m_horizontalScrollbar || m_verticalScrollbar; if (m_horizontalScrollbar) { - if (m_pluginSize.width() >= m_pdfDocumentSize.width()) + if (m_size.width() >= m_pdfDocumentSize.width()) destroyScrollbar(HorizontalScrollbar); - } else if (m_pluginSize.width() < m_pdfDocumentSize.width()) + } else if (m_size.width() < m_pdfDocumentSize.width()) m_horizontalScrollbar = createScrollbar(HorizontalScrollbar); if (m_verticalScrollbar) { - if (m_pluginSize.height() >= m_pdfDocumentSize.height()) + if (m_size.height() >= m_pdfDocumentSize.height()) destroyScrollbar(VerticalScrollbar); - } else if (m_pluginSize.height() < m_pdfDocumentSize.height()) + } else if (m_size.height() < m_pdfDocumentSize.height()) m_verticalScrollbar = createScrollbar(VerticalScrollbar); int horizontalScrollbarHeight = (m_horizontalScrollbar && !m_horizontalScrollbar->isOverlayScrollbar()) ? m_horizontalScrollbar->height() : 0; @@ -217,16 +217,16 @@ void BuiltInPDFView::updateScrollbars() if (m_horizontalScrollbar) { m_horizontalScrollbar->setSteps(Scrollbar::pixelsPerLineStep(), pageStep); - m_horizontalScrollbar->setProportion(m_pluginSize.width() - verticalScrollbarWidth, m_pdfDocumentSize.width()); - IntRect scrollbarRect(pluginView()->x(), pluginView()->y() + m_pluginSize.height() - m_horizontalScrollbar->height(), m_pluginSize.width(), m_horizontalScrollbar->height()); + m_horizontalScrollbar->setProportion(m_size.width() - verticalScrollbarWidth, m_pdfDocumentSize.width()); + IntRect scrollbarRect(pluginView()->x(), pluginView()->y() + m_size.height() - m_horizontalScrollbar->height(), m_size.width(), m_horizontalScrollbar->height()); if (m_verticalScrollbar) scrollbarRect.contract(m_verticalScrollbar->width(), 0); m_horizontalScrollbar->setFrameRect(scrollbarRect); } if (m_verticalScrollbar) { m_verticalScrollbar->setSteps(Scrollbar::pixelsPerLineStep(), pageStep); - m_verticalScrollbar->setProportion(m_pluginSize.height() - horizontalScrollbarHeight, m_pdfDocumentSize.height()); - IntRect scrollbarRect(IntRect(pluginView()->x() + m_pluginSize.width() - m_verticalScrollbar->width(), pluginView()->y(), m_verticalScrollbar->width(), m_pluginSize.height())); + m_verticalScrollbar->setProportion(m_size.height() - horizontalScrollbarHeight, m_pdfDocumentSize.height()); + IntRect scrollbarRect(IntRect(pluginView()->x() + m_size.width() - m_verticalScrollbar->width(), pluginView()->y(), m_verticalScrollbar->width(), m_size.height())); if (m_horizontalScrollbar) scrollbarRect.contract(0, m_horizontalScrollbar->height()); m_verticalScrollbar->setFrameRect(scrollbarRect); @@ -247,7 +247,7 @@ void BuiltInPDFView::updateScrollbars() } } -PassRefPtr<Scrollbar> BuiltInPDFView::createScrollbar(ScrollbarOrientation orientation) +PassRefPtr<Scrollbar> SimplePDFPlugin::createScrollbar(ScrollbarOrientation orientation) { RefPtr<Scrollbar> widget = Scrollbar::createNativeScrollbar(this, orientation, RegularScrollbar); if (orientation == HorizontalScrollbar) @@ -258,7 +258,7 @@ PassRefPtr<Scrollbar> BuiltInPDFView::createScrollbar(ScrollbarOrientation orien return widget.release(); } -void BuiltInPDFView::destroyScrollbar(ScrollbarOrientation orientation) +void SimplePDFPlugin::destroyScrollbar(ScrollbarOrientation orientation) { RefPtr<Scrollbar>& scrollbar = orientation == HorizontalScrollbar ? m_horizontalScrollbar : m_verticalScrollbar; if (!scrollbar) @@ -274,7 +274,7 @@ void BuiltInPDFView::destroyScrollbar(ScrollbarOrientation orientation) scrollbar = 0; } -void BuiltInPDFView::addArchiveResource() +void SimplePDFPlugin::addArchiveResource() { // FIXME: It's a hack to force add a resource to DocumentLoader. PDF documents should just be fetched as CachedResources. @@ -284,21 +284,81 @@ void BuiltInPDFView::addArchiveResource() synthesizedResponse.setURL(m_sourceURL); // Needs to match the HitTestResult::absolutePDFURL. synthesizedResponse.setMimeType("application/pdf"); - RefPtr<ArchiveResource> resource = ArchiveResource::create(SharedBuffer::wrapCFData(m_dataBuffer.get()), m_sourceURL, "application/pdf", String(), String(), synthesizedResponse); + RefPtr<ArchiveResource> resource = ArchiveResource::create(SharedBuffer::wrapCFData(m_data.get()), m_sourceURL, "application/pdf", String(), String(), synthesizedResponse); pluginView()->frame()->document()->loader()->addArchiveResource(resource.release()); } -void BuiltInPDFView::pdfDocumentDidLoad() +static void jsPDFDocInitialize(JSContextRef ctx, JSObjectRef object) +{ + SimplePDFPlugin* pdfView = static_cast<SimplePDFPlugin*>(JSObjectGetPrivate(object)); + pdfView->ref(); +} + +static void jsPDFDocFinalize(JSObjectRef object) +{ + SimplePDFPlugin* pdfView = static_cast<SimplePDFPlugin*>(JSObjectGetPrivate(object)); + pdfView->deref(); +} + +JSValueRef SimplePDFPlugin::jsPDFDocPrint(JSContextRef ctx, JSObjectRef function, JSObjectRef thisObject, size_t argumentCount, const JSValueRef arguments[], JSValueRef* exception) +{ + SimplePDFPlugin* pdfView = static_cast<SimplePDFPlugin*>(JSObjectGetPrivate(thisObject)); + + WebFrame* frame = pdfView->m_frame; + if (!frame) + return JSValueMakeUndefined(ctx); + + Frame* coreFrame = frame->coreFrame(); + if (!coreFrame) + return JSValueMakeUndefined(ctx); + + Page* page = coreFrame->page(); + if (!page) + return JSValueMakeUndefined(ctx); + + page->chrome()->print(coreFrame); + + return JSValueMakeUndefined(ctx); +} + +JSObjectRef SimplePDFPlugin::makeJSPDFDoc(JSContextRef ctx) +{ + static JSStaticFunction jsPDFDocStaticFunctions[] = { + { "print", jsPDFDocPrint, kJSPropertyAttributeReadOnly | kJSPropertyAttributeDontDelete }, + { 0, 0, 0 }, + }; + + static JSClassDefinition jsPDFDocClassDefinition = { + 0, + kJSClassAttributeNone, + "Doc", + 0, + 0, + jsPDFDocStaticFunctions, + jsPDFDocInitialize, jsPDFDocFinalize, 0, 0, 0, 0, 0, 0, 0, 0, 0 + }; + + static JSClassRef jsPDFDocClass = JSClassCreate(&jsPDFDocClassDefinition); + + return JSObjectMake(ctx, jsPDFDocClass, this); +} + +void SimplePDFPlugin::pdfDocumentDidLoad() { addArchiveResource(); - m_pdfDocument.adoptNS([[pdfDocumentClass() alloc] initWithData:(NSData *)m_dataBuffer.get()]); + m_pdfDocument.adoptNS([[pdfDocumentClass() alloc] initWithData:(NSData *)m_data.get()]); calculateSizes(); updateScrollbars(); - controller()->invalidate(IntRect(0, 0, m_pluginSize.width(), m_pluginSize.height())); + controller()->invalidate(IntRect(0, 0, m_size.width(), m_size.height())); + runScriptsInPDFDocument(); +} + +void SimplePDFPlugin::runScriptsInPDFDocument() +{ Vector<RetainPtr<CFStringRef> > scripts; getAllScriptsInPDFDocument([m_pdfDocument.get() documentRef], scripts); @@ -317,8 +377,22 @@ void BuiltInPDFView::pdfDocumentDidLoad() JSGlobalContextRelease(ctx); } + +void SimplePDFPlugin::computePageBoxes() +{ + size_t pageCount = CGPDFDocumentGetNumberOfPages([m_pdfDocument.get() documentRef]); + for (size_t i = 0; i < pageCount; ++i) { + CGPDFPageRef pdfPage = CGPDFDocumentGetPage([m_pdfDocument.get() documentRef], i + 1); + ASSERT(pdfPage); + + CGRect box = CGPDFPageGetBoxRect(pdfPage, kCGPDFCropBox); + if (CGRectIsEmpty(box)) + box = CGPDFPageGetBoxRect(pdfPage, kCGPDFMediaBox); + m_pageBoxes.append(IntRect(box)); + } +} -void BuiltInPDFView::calculateSizes() +void SimplePDFPlugin::calculateSizes() { size_t pageCount = CGPDFDocumentGetNumberOfPages([m_pdfDocument.get() documentRef]); for (size_t i = 0; i < pageCount; ++i) { @@ -335,7 +409,7 @@ void BuiltInPDFView::calculateSizes() m_pdfDocumentSize.expand(0, gutterHeight * (m_pageBoxes.size() - 1)); } -bool BuiltInPDFView::initialize(const Parameters& parameters) +bool SimplePDFPlugin::initialize(const Parameters& parameters) { // Load the src URL if needed. m_sourceURL = parameters.url; @@ -346,7 +420,7 @@ bool BuiltInPDFView::initialize(const Parameters& parameters) return true; } -void BuiltInPDFView::destroy() +void SimplePDFPlugin::destroy() { if (m_frame) { if (FrameView* frameView = m_frame->coreFrame()->view()) @@ -357,7 +431,7 @@ void BuiltInPDFView::destroy() destroyScrollbar(VerticalScrollbar); } -void BuiltInPDFView::paint(GraphicsContext* graphicsContext, const IntRect& dirtyRect) +void SimplePDFPlugin::paint(GraphicsContext* graphicsContext, const IntRect& dirtyRect) { contentAreaWillPaint(); @@ -370,14 +444,14 @@ void BuiltInPDFView::paint(GraphicsContext* graphicsContext, const IntRect& dirt paintControls(graphicsContext, dirtyRect); } -void BuiltInPDFView::paintBackground(GraphicsContext* graphicsContext, const IntRect& dirtyRect) +void SimplePDFPlugin::paintBackground(GraphicsContext* graphicsContext, const IntRect& dirtyRect) { GraphicsContextStateSaver stateSaver(*graphicsContext); graphicsContext->setFillColor(Color::gray, ColorSpaceDeviceRGB); graphicsContext->fillRect(dirtyRect); } -void BuiltInPDFView::paintContent(GraphicsContext* graphicsContext, const IntRect& dirtyRect) +void SimplePDFPlugin::paintContent(GraphicsContext* graphicsContext, const IntRect& dirtyRect) { GraphicsContextStateSaver stateSaver(*graphicsContext); CGContextRef context = graphicsContext->platformContext(); @@ -397,8 +471,8 @@ void BuiltInPDFView::paintContent(GraphicsContext* graphicsContext, const IntRec int pageTop = 0; for (size_t i = 0; i < m_pageBoxes.size(); ++i) { IntRect pageBox = m_pageBoxes[i]; - float extraOffsetForCenteringX = max(roundf((m_pluginSize.width() - pageBox.width()) / 2.0f), 0.0f); - float extraOffsetForCenteringY = (m_pageBoxes.size() == 1) ? max(roundf((m_pluginSize.height() - pageBox.height() + shadowOffsetY) / 2.0f), 0.0f) : 0; + float extraOffsetForCenteringX = max(roundf((m_size.width() - pageBox.width()) / 2.0f), 0.0f); + float extraOffsetForCenteringY = (m_pageBoxes.size() == 1) ? max(roundf((m_size.height() - pageBox.height() + shadowOffsetY) / 2.0f), 0.0f) : 0; if (pageTop > contentRect.maxY()) break; @@ -422,7 +496,7 @@ void BuiltInPDFView::paintContent(GraphicsContext* graphicsContext, const IntRec } } -void BuiltInPDFView::paintControls(GraphicsContext* graphicsContext, const IntRect& dirtyRect) +void SimplePDFPlugin::paintControls(GraphicsContext* graphicsContext, const IntRect& dirtyRect) { { GraphicsContextStateSaver stateSaver(*graphicsContext); @@ -441,7 +515,7 @@ void BuiltInPDFView::paintControls(GraphicsContext* graphicsContext, const IntRe ScrollbarTheme::theme()->paintScrollCorner(0, graphicsContext, dirtyCornerRect); } -void BuiltInPDFView::updateControlTints(GraphicsContext* graphicsContext) +void SimplePDFPlugin::updateControlTints(GraphicsContext* graphicsContext) { ASSERT(graphicsContext->updatingControlTints()); @@ -452,116 +526,116 @@ void BuiltInPDFView::updateControlTints(GraphicsContext* graphicsContext) invalidateScrollCorner(scrollCornerRect()); } -PassRefPtr<ShareableBitmap> BuiltInPDFView::snapshot() +PassRefPtr<ShareableBitmap> SimplePDFPlugin::snapshot() { return 0; } #if PLATFORM(MAC) -PlatformLayer* BuiltInPDFView::pluginLayer() +PlatformLayer* SimplePDFPlugin::pluginLayer() { return 0; } #endif -bool BuiltInPDFView::isTransparent() +bool SimplePDFPlugin::isTransparent() { // This should never be called from the web process. ASSERT_NOT_REACHED(); return false; } -bool BuiltInPDFView::wantsWheelEvents() +bool SimplePDFPlugin::wantsWheelEvents() { return true; } -void BuiltInPDFView::geometryDidChange(const IntSize& pluginSize, const IntRect& clipRect, const AffineTransform& pluginToRootViewTransform) +void SimplePDFPlugin::geometryDidChange(const IntSize& size, const IntRect& clipRect, const AffineTransform& pluginToRootViewTransform) { - if (m_pluginSize == pluginSize) { + if (m_size == size) { // Nothing to do. return; } - m_pluginSize = pluginSize; + m_size = size; updateScrollbars(); } -void BuiltInPDFView::visibilityDidChange() +void SimplePDFPlugin::visibilityDidChange() { } -void BuiltInPDFView::frameDidFinishLoading(uint64_t) +void SimplePDFPlugin::frameDidFinishLoading(uint64_t) { ASSERT_NOT_REACHED(); } -void BuiltInPDFView::frameDidFail(uint64_t, bool) +void SimplePDFPlugin::frameDidFail(uint64_t, bool) { ASSERT_NOT_REACHED(); } -void BuiltInPDFView::didEvaluateJavaScript(uint64_t, const WTF::String&) +void SimplePDFPlugin::didEvaluateJavaScript(uint64_t, const WTF::String&) { ASSERT_NOT_REACHED(); } -void BuiltInPDFView::streamDidReceiveResponse(uint64_t streamID, const KURL&, uint32_t, uint32_t, const String&, const String&, const String& suggestedFilename) +void SimplePDFPlugin::streamDidReceiveResponse(uint64_t streamID, const KURL&, uint32_t, uint32_t, const String&, const String&, const String& suggestedFilename) { ASSERT_UNUSED(streamID, streamID == pdfDocumentRequestID); m_suggestedFilename = suggestedFilename; } -void BuiltInPDFView::streamDidReceiveData(uint64_t streamID, const char* bytes, int length) +void SimplePDFPlugin::streamDidReceiveData(uint64_t streamID, const char* bytes, int length) { ASSERT_UNUSED(streamID, streamID == pdfDocumentRequestID); - if (!m_dataBuffer) - m_dataBuffer.adoptCF(CFDataCreateMutable(0, 0)); + if (!m_data) + m_data.adoptCF(CFDataCreateMutable(0, 0)); - CFDataAppendBytes(m_dataBuffer.get(), reinterpret_cast<const UInt8*>(bytes), length); + CFDataAppendBytes(m_data.get(), reinterpret_cast<const UInt8*>(bytes), length); } -void BuiltInPDFView::streamDidFinishLoading(uint64_t streamID) +void SimplePDFPlugin::streamDidFinishLoading(uint64_t streamID) { ASSERT_UNUSED(streamID, streamID == pdfDocumentRequestID); pdfDocumentDidLoad(); } -void BuiltInPDFView::streamDidFail(uint64_t streamID, bool wasCancelled) +void SimplePDFPlugin::streamDidFail(uint64_t streamID, bool wasCancelled) { ASSERT_UNUSED(streamID, streamID == pdfDocumentRequestID); - m_dataBuffer.clear(); + m_data.clear(); } -void BuiltInPDFView::manualStreamDidReceiveResponse(const KURL& responseURL, uint32_t streamLength, uint32_t lastModifiedTime, const String& mimeType, const String& headers, const String& suggestedFilename) +void SimplePDFPlugin::manualStreamDidReceiveResponse(const KURL& responseURL, uint32_t streamLength, uint32_t lastModifiedTime, const String& mimeType, const String& headers, const String& suggestedFilename) { m_suggestedFilename = suggestedFilename; } -void BuiltInPDFView::manualStreamDidReceiveData(const char* bytes, int length) +void SimplePDFPlugin::manualStreamDidReceiveData(const char* bytes, int length) { - if (!m_dataBuffer) - m_dataBuffer.adoptCF(CFDataCreateMutable(0, 0)); + if (!m_data) + m_data.adoptCF(CFDataCreateMutable(0, 0)); - CFDataAppendBytes(m_dataBuffer.get(), reinterpret_cast<const UInt8*>(bytes), length); + CFDataAppendBytes(m_data.get(), reinterpret_cast<const UInt8*>(bytes), length); } -void BuiltInPDFView::manualStreamDidFinishLoading() +void SimplePDFPlugin::manualStreamDidFinishLoading() { pdfDocumentDidLoad(); } -void BuiltInPDFView::manualStreamDidFail(bool) +void SimplePDFPlugin::manualStreamDidFail(bool) { - m_dataBuffer.clear(); + m_data.clear(); } -bool BuiltInPDFView::handleMouseEvent(const WebMouseEvent& event) +bool SimplePDFPlugin::handleMouseEvent(const WebMouseEvent& event) { switch (event.type()) { case WebEvent::MouseMove: @@ -589,106 +663,106 @@ bool BuiltInPDFView::handleMouseEvent(const WebMouseEvent& event) return false; } -bool BuiltInPDFView::handleWheelEvent(const WebWheelEvent& event) +bool SimplePDFPlugin::handleWheelEvent(const WebWheelEvent& event) { PlatformWheelEvent platformEvent = platform(event); return ScrollableArea::handleWheelEvent(platformEvent); } -bool BuiltInPDFView::handleMouseEnterEvent(const WebMouseEvent&) +bool SimplePDFPlugin::handleMouseEnterEvent(const WebMouseEvent&) { mouseEnteredContentArea(); return false; } -bool BuiltInPDFView::handleMouseLeaveEvent(const WebMouseEvent&) +bool SimplePDFPlugin::handleMouseLeaveEvent(const WebMouseEvent&) { mouseExitedContentArea(); return false; } -bool BuiltInPDFView::handleContextMenuEvent(const WebMouseEvent&) +bool SimplePDFPlugin::handleContextMenuEvent(const WebMouseEvent&) { // Use default WebKit context menu. return false; } -bool BuiltInPDFView::handleKeyboardEvent(const WebKeyboardEvent&) +bool SimplePDFPlugin::handleKeyboardEvent(const WebKeyboardEvent&) { return false; } -void BuiltInPDFView::setFocus(bool hasFocus) +void SimplePDFPlugin::setFocus(bool hasFocus) { } -NPObject* BuiltInPDFView::pluginScriptableNPObject() +NPObject* SimplePDFPlugin::pluginScriptableNPObject() { return 0; } #if PLATFORM(MAC) -void BuiltInPDFView::windowFocusChanged(bool) +void SimplePDFPlugin::windowFocusChanged(bool) { } -void BuiltInPDFView::windowAndViewFramesChanged(const WebCore::IntRect& windowFrameInScreenCoordinates, const WebCore::IntRect& viewFrameInWindowCoordinates) +void SimplePDFPlugin::windowAndViewFramesChanged(const WebCore::IntRect& windowFrameInScreenCoordinates, const WebCore::IntRect& viewFrameInWindowCoordinates) { } -void BuiltInPDFView::windowVisibilityChanged(bool) +void SimplePDFPlugin::windowVisibilityChanged(bool) { } -void BuiltInPDFView::contentsScaleFactorChanged(float) +void SimplePDFPlugin::contentsScaleFactorChanged(float) { } -uint64_t BuiltInPDFView::pluginComplexTextInputIdentifier() const +uint64_t SimplePDFPlugin::pluginComplexTextInputIdentifier() const { return 0; } -void BuiltInPDFView::sendComplexTextInput(const String&) +void SimplePDFPlugin::sendComplexTextInput(const String&) { } -void BuiltInPDFView::setLayerHostingMode(LayerHostingMode) +void SimplePDFPlugin::setLayerHostingMode(LayerHostingMode) { } #endif -void BuiltInPDFView::storageBlockingStateChanged(bool) +void SimplePDFPlugin::storageBlockingStateChanged(bool) { } -void BuiltInPDFView::privateBrowsingStateChanged(bool) +void SimplePDFPlugin::privateBrowsingStateChanged(bool) { } -bool BuiltInPDFView::getFormValue(String&) +bool SimplePDFPlugin::getFormValue(String&) { return false; } -bool BuiltInPDFView::handleScroll(ScrollDirection direction, ScrollGranularity granularity) +bool SimplePDFPlugin::handleScroll(ScrollDirection direction, ScrollGranularity granularity) { return scroll(direction, granularity); } -Scrollbar* BuiltInPDFView::horizontalScrollbar() +Scrollbar* SimplePDFPlugin::horizontalScrollbar() { return m_horizontalScrollbar.get(); } -Scrollbar* BuiltInPDFView::verticalScrollbar() +Scrollbar* SimplePDFPlugin::verticalScrollbar() { return m_verticalScrollbar.get(); } -IntRect BuiltInPDFView::scrollCornerRect() const +IntRect SimplePDFPlugin::scrollCornerRect() const { if (!m_horizontalScrollbar || !m_verticalScrollbar) return IntRect(); @@ -699,31 +773,31 @@ IntRect BuiltInPDFView::scrollCornerRect() const return IntRect(pluginView()->width() - m_verticalScrollbar->width(), pluginView()->height() - m_horizontalScrollbar->height(), m_verticalScrollbar->width(), m_horizontalScrollbar->height()); } -ScrollableArea* BuiltInPDFView::enclosingScrollableArea() const +ScrollableArea* SimplePDFPlugin::enclosingScrollableArea() const { // FIXME: Walk up the frame tree and look for a scrollable parent frame or RenderLayer. return 0; } -IntRect BuiltInPDFView::scrollableAreaBoundingBox() const +IntRect SimplePDFPlugin::scrollableAreaBoundingBox() const { return pluginView()->frameRect(); } -void BuiltInPDFView::setScrollOffset(const IntPoint& offset) +void SimplePDFPlugin::setScrollOffset(const IntPoint& offset) { m_scrollOffset = IntSize(offset.x(), offset.y()); // FIXME: It would be better for performance to blit parts that remain visible. - controller()->invalidate(IntRect(0, 0, m_pluginSize.width(), m_pluginSize.height())); + controller()->invalidate(IntRect(0, 0, m_size.width(), m_size.height())); } -int BuiltInPDFView::scrollSize(ScrollbarOrientation orientation) const +int SimplePDFPlugin::scrollSize(ScrollbarOrientation orientation) const { Scrollbar* scrollbar = ((orientation == HorizontalScrollbar) ? m_horizontalScrollbar : m_verticalScrollbar).get(); return scrollbar ? (scrollbar->totalSize() - scrollbar->visibleSize()) : 0; } -bool BuiltInPDFView::isActive() const +bool SimplePDFPlugin::isActive() const { if (Frame* coreFrame = m_frame->coreFrame()) { if (Page* page = coreFrame->page()) @@ -733,7 +807,7 @@ bool BuiltInPDFView::isActive() const return false; } -void BuiltInPDFView::invalidateScrollbarRect(Scrollbar* scrollbar, const IntRect& rect) +void SimplePDFPlugin::invalidateScrollbarRect(Scrollbar* scrollbar, const IntRect& rect) { IntRect dirtyRect = rect; dirtyRect.moveBy(scrollbar->location()); @@ -741,17 +815,17 @@ void BuiltInPDFView::invalidateScrollbarRect(Scrollbar* scrollbar, const IntRect controller()->invalidate(dirtyRect); } -void BuiltInPDFView::invalidateScrollCornerRect(const IntRect& rect) +void SimplePDFPlugin::invalidateScrollCornerRect(const IntRect& rect) { controller()->invalidate(rect); } -bool BuiltInPDFView::isScrollCornerVisible() const +bool SimplePDFPlugin::isScrollCornerVisible() const { return false; } -int BuiltInPDFView::scrollPosition(Scrollbar* scrollbar) const +int SimplePDFPlugin::scrollPosition(Scrollbar* scrollbar) const { if (scrollbar->orientation() == HorizontalScrollbar) return m_scrollOffset.width(); @@ -761,47 +835,47 @@ int BuiltInPDFView::scrollPosition(Scrollbar* scrollbar) const return 0; } -IntPoint BuiltInPDFView::scrollPosition() const +IntPoint SimplePDFPlugin::scrollPosition() const { return IntPoint(m_scrollOffset.width(), m_scrollOffset.height()); } -IntPoint BuiltInPDFView::minimumScrollPosition() const +IntPoint SimplePDFPlugin::minimumScrollPosition() const { return IntPoint(0, 0); } -IntPoint BuiltInPDFView::maximumScrollPosition() const +IntPoint SimplePDFPlugin::maximumScrollPosition() const { int horizontalScrollbarHeight = (m_horizontalScrollbar && !m_horizontalScrollbar->isOverlayScrollbar()) ? m_horizontalScrollbar->height() : 0; int verticalScrollbarWidth = (m_verticalScrollbar && !m_verticalScrollbar->isOverlayScrollbar()) ? m_verticalScrollbar->width() : 0; - IntPoint maximumOffset(m_pdfDocumentSize.width() - m_pluginSize.width() + verticalScrollbarWidth, m_pdfDocumentSize.height() - m_pluginSize.height() + horizontalScrollbarHeight); + IntPoint maximumOffset(m_pdfDocumentSize.width() - m_size.width() + verticalScrollbarWidth, m_pdfDocumentSize.height() - m_size.height() + horizontalScrollbarHeight); maximumOffset.clampNegativeToZero(); return maximumOffset; } -int BuiltInPDFView::visibleHeight() const +int SimplePDFPlugin::visibleHeight() const { - return m_pluginSize.height(); + return m_size.height(); } -int BuiltInPDFView::visibleWidth() const +int SimplePDFPlugin::visibleWidth() const { - return m_pluginSize.width(); + return m_size.width(); } -IntSize BuiltInPDFView::contentsSize() const +IntSize SimplePDFPlugin::contentsSize() const { return m_pdfDocumentSize; } -bool BuiltInPDFView::scrollbarsCanBeActive() const +bool SimplePDFPlugin::scrollbarsCanBeActive() const { return !pluginView()->frame()->document()->inPageCache(); } -void BuiltInPDFView::scrollbarStyleChanged(int, bool forceUpdate) +void SimplePDFPlugin::scrollbarStyleChanged(int, bool forceUpdate) { if (!forceUpdate) return; @@ -816,67 +890,51 @@ void BuiltInPDFView::scrollbarStyleChanged(int, bool forceUpdate) ScrollableArea::contentsResized(); } -IntPoint BuiltInPDFView::convertFromContainingViewToScrollbar(const Scrollbar* scrollbar, const IntPoint& parentPoint) const +IntRect SimplePDFPlugin::convertFromScrollbarToContainingView(const Scrollbar* scrollbar, const IntRect& scrollbarRect) const { - IntPoint point = pluginView()->frame()->view()->convertToRenderer(pluginView()->renderer(), parentPoint); - point.move(pluginView()->location() - scrollbar->location()); - - return point; + IntRect rect = scrollbarRect; + rect.move(scrollbar->location() - pluginView()->location()); + + return pluginView()->frame()->view()->convertFromRenderer(pluginView()->renderer(), rect); } -static void jsPDFDocInitialize(JSContextRef ctx, JSObjectRef object) +IntRect SimplePDFPlugin::convertFromContainingViewToScrollbar(const Scrollbar* scrollbar, const IntRect& parentRect) const { - BuiltInPDFView* pdfView = static_cast<BuiltInPDFView*>(JSObjectGetPrivate(object)); - pdfView->ref(); + IntRect rect = pluginView()->frame()->view()->convertToRenderer(pluginView()->renderer(), parentRect); + rect.move(pluginView()->location() - scrollbar->location()); + + return rect; } -static void jsPDFDocFinalize(JSObjectRef object) +IntPoint SimplePDFPlugin::convertFromScrollbarToContainingView(const Scrollbar* scrollbar, const IntPoint& scrollbarPoint) const { - BuiltInPDFView* pdfView = static_cast<BuiltInPDFView*>(JSObjectGetPrivate(object)); - pdfView->deref(); + IntPoint point = scrollbarPoint; + point.move(scrollbar->location() - pluginView()->location()); + + return pluginView()->frame()->view()->convertFromRenderer(pluginView()->renderer(), point); } -JSValueRef BuiltInPDFView::jsPDFDocPrint(JSContextRef ctx, JSObjectRef function, JSObjectRef thisObject, size_t argumentCount, const JSValueRef arguments[], JSValueRef* exception) +IntPoint SimplePDFPlugin::convertFromContainingViewToScrollbar(const Scrollbar* scrollbar, const IntPoint& parentPoint) const { - BuiltInPDFView* pdfView = static_cast<BuiltInPDFView*>(JSObjectGetPrivate(thisObject)); - - WebFrame* frame = pdfView->m_frame; - if (!frame) - return JSValueMakeUndefined(ctx); - - Frame* coreFrame = frame->coreFrame(); - if (!coreFrame) - return JSValueMakeUndefined(ctx); - - Page* page = coreFrame->page(); - if (!page) - return JSValueMakeUndefined(ctx); - - page->chrome()->print(coreFrame); - - return JSValueMakeUndefined(ctx); + IntPoint point = pluginView()->frame()->view()->convertToRenderer(pluginView()->renderer(), parentPoint); + point.move(pluginView()->location() - scrollbar->location()); + + return point; } -JSObjectRef BuiltInPDFView::makeJSPDFDoc(JSContextRef ctx) +bool SimplePDFPlugin::isEditingCommandEnabled(const String&) { - static JSStaticFunction jsPDFDocStaticFunctions[] = { - { "print", jsPDFDocPrint, kJSPropertyAttributeReadOnly | kJSPropertyAttributeDontDelete }, - { 0, 0, 0 }, - }; - - static JSClassDefinition jsPDFDocClassDefinition = { - 0, - kJSClassAttributeNone, - "Doc", - 0, - 0, - jsPDFDocStaticFunctions, - jsPDFDocInitialize, jsPDFDocFinalize, 0, 0, 0, 0, 0, 0, 0, 0, 0 - }; - - static JSClassRef jsPDFDocClass = JSClassCreate(&jsPDFDocClassDefinition); + return false; +} - return JSObjectMake(ctx, jsPDFDocClass, this); +bool SimplePDFPlugin::handleEditingCommand(const String&, const String&) +{ + return false; +} + +bool SimplePDFPlugin::handlesPageScaleFactor() +{ + return false; } } // namespace WebKit diff --git a/Source/WebKit2/WebProcess/Plugins/Plugin.h b/Source/WebKit2/WebProcess/Plugins/Plugin.h index d197a6765..98f8770c1 100644 --- a/Source/WebKit2/WebProcess/Plugins/Plugin.h +++ b/Source/WebKit2/WebProcess/Plugins/Plugin.h @@ -188,6 +188,15 @@ public: // Tells the plug-in to handle the passed in keyboard event. The plug-in should return true if it processed the event. virtual bool handleKeyboardEvent(const WebKeyboardEvent&) = 0; + // Tells the plug-in to handle the passed in editing command. The plug-in should return true if it executed the command. + virtual bool handleEditingCommand(const String& commandName, const String& argument) = 0; + + // Ask the plug-in whether it will be able to handle the given editing command. + virtual bool isEditingCommandEnabled(const String&) = 0; + + // Ask the plug-in whether it wants to override full-page zoom. + virtual bool handlesPageScaleFactor() = 0; + // Tells the plug-in about focus changes. virtual void setFocus(bool) = 0; diff --git a/Source/WebKit2/WebProcess/Plugins/PluginProcessConnection.cpp b/Source/WebKit2/WebProcess/Plugins/PluginProcessConnection.cpp index 3fe4d0b6c..fdb7e5e1f 100644 --- a/Source/WebKit2/WebProcess/Plugins/PluginProcessConnection.cpp +++ b/Source/WebKit2/WebProcess/Plugins/PluginProcessConnection.cpp @@ -41,37 +41,6 @@ using namespace WebCore; namespace WebKit { -// The timeout, in seconds, when sending sync messages to the plug-in. -static const double syncMessageTimeout = 45; - -static double defaultSyncMessageTimeout(const String& pluginPath) -{ - // FIXME: We should key this off something other than the path. - - // We don't want a message timeout for the AppleConnect plug-in. - if (pathGetFileName(pluginPath) == "AppleConnect.plugin") - return CoreIPC::Connection::NoTimeout; - - // We don't want a message timeout for the Microsoft SharePoint plug-in - // since it can spin a nested run loop in response to an NPN_Invoke, making it seem like - // the plug-in process is hung. See <rdar://problem/9536303>. - // FIXME: Instead of changing the default sync message timeout, CoreIPC could send an - // asynchronous message which the other process would have to reply to on the main thread. - // This way we could check if the plug-in process is actually hung or not. - if (pathGetFileName(pluginPath) == "SharePointBrowserPlugin.plugin") - return CoreIPC::Connection::NoTimeout; - - // We don't want a message timeout for the BankID plug-in since it can spin a nested - // run loop when it's waiting for a reply to an AppleEvent. - if (pathGetFileName(pluginPath) == "PersonalPlugin.bundle") - return CoreIPC::Connection::NoTimeout; - - if (WebProcess::shared().disablePluginProcessMessageTimeout()) - return CoreIPC::Connection::NoTimeout; - - return syncMessageTimeout; -} - PluginProcessConnection::PluginProcessConnection(PluginProcessConnectionManager* pluginProcessConnectionManager, const String& pluginPath, CoreIPC::Connection::Identifier connectionIdentifier, bool supportsAsynchronousPluginInitialization) : m_pluginProcessConnectionManager(pluginProcessConnectionManager) , m_pluginPath(pluginPath) @@ -79,7 +48,6 @@ PluginProcessConnection::PluginProcessConnection(PluginProcessConnectionManager* { m_connection = CoreIPC::Connection::createClientConnection(connectionIdentifier, this, WebProcess::shared().runLoop()); - m_connection->setDefaultSyncMessageTimeout(defaultSyncMessageTimeout(m_pluginPath)); m_npRemoteObjectMap = NPRemoteObjectMap::create(m_connection.get()); m_connection->open(); @@ -165,11 +133,6 @@ void PluginProcessConnection::didReceiveInvalidMessage(CoreIPC::Connection*, Cor { } -void PluginProcessConnection::syncMessageSendTimedOut(CoreIPC::Connection*) -{ - WebProcess::shared().connection()->send(Messages::WebProcessProxy::PluginSyncMessageSendTimedOut(m_pluginPath), 0); -} - void PluginProcessConnection::setException(const String& exceptionString) { NPRuntimeObjectMap::setGlobalException(exceptionString); diff --git a/Source/WebKit2/WebProcess/Plugins/PluginProcessConnection.h b/Source/WebKit2/WebProcess/Plugins/PluginProcessConnection.h index bc866d10c..b9bf81c71 100644 --- a/Source/WebKit2/WebProcess/Plugins/PluginProcessConnection.h +++ b/Source/WebKit2/WebProcess/Plugins/PluginProcessConnection.h @@ -68,7 +68,6 @@ private: virtual void didReceiveSyncMessage(CoreIPC::Connection*, CoreIPC::MessageID, CoreIPC::ArgumentDecoder*, OwnPtr<CoreIPC::ArgumentEncoder>&); virtual void didClose(CoreIPC::Connection*); virtual void didReceiveInvalidMessage(CoreIPC::Connection*, CoreIPC::MessageID); - virtual void syncMessageSendTimedOut(CoreIPC::Connection*); // Message handlers. void didReceiveSyncPluginProcessConnectionMessage(CoreIPC::Connection*, CoreIPC::MessageID, CoreIPC::ArgumentDecoder*, OwnPtr<CoreIPC::ArgumentEncoder>&); diff --git a/Source/WebKit2/WebProcess/Plugins/PluginProxy.cpp b/Source/WebKit2/WebProcess/Plugins/PluginProxy.cpp index 9c30a5ef4..98f333963 100644 --- a/Source/WebKit2/WebProcess/Plugins/PluginProxy.cpp +++ b/Source/WebKit2/WebProcess/Plugins/PluginProxy.cpp @@ -403,6 +403,33 @@ void PluginProxy::setFocus(bool hasFocus) m_connection->connection()->send(Messages::PluginControllerProxy::SetFocus(hasFocus), m_pluginInstanceID); } +bool PluginProxy::handleEditingCommand(const String& commandName, const String& argument) +{ + bool handled = false; + if (!m_connection->connection()->sendSync(Messages::PluginControllerProxy::HandleEditingCommand(commandName, argument), Messages::PluginControllerProxy::HandleEditingCommand::Reply(handled), m_pluginInstanceID)) + return false; + + return handled; +} + +bool PluginProxy::isEditingCommandEnabled(const String& commandName) +{ + bool enabled = false; + if (!m_connection->connection()->sendSync(Messages::PluginControllerProxy::IsEditingCommandEnabled(commandName), Messages::PluginControllerProxy::IsEditingCommandEnabled::Reply(enabled), m_pluginInstanceID)) + return false; + + return enabled; +} + +bool PluginProxy::handlesPageScaleFactor() +{ + bool handled = false; + if (!m_connection->connection()->sendSync(Messages::PluginControllerProxy::HandlesPageScaleFactor(), Messages::PluginControllerProxy::HandlesPageScaleFactor::Reply(handled), m_pluginInstanceID)) + return false; + + return handled; +} + NPObject* PluginProxy::pluginScriptableNPObject() { // Sending the synchronous Messages::PluginControllerProxy::GetPluginScriptableNPObject message can cause us to dispatch an @@ -447,7 +474,7 @@ void PluginProxy::sendComplexTextInput(const String& textInput) } #endif -void PluginProxy::contentsScaleFactorChanged(float scaleFactor) +void PluginProxy::contentsScaleFactorChanged(float) { geometryDidChange(); } diff --git a/Source/WebKit2/WebProcess/Plugins/PluginProxy.h b/Source/WebKit2/WebProcess/Plugins/PluginProxy.h index 7a36c1afd..02fa1ab57 100644 --- a/Source/WebKit2/WebProcess/Plugins/PluginProxy.h +++ b/Source/WebKit2/WebProcess/Plugins/PluginProxy.h @@ -101,6 +101,11 @@ private: virtual bool handleContextMenuEvent(const WebMouseEvent&); virtual bool handleKeyboardEvent(const WebKeyboardEvent&); virtual void setFocus(bool); + virtual bool handleEditingCommand(const String& commandName, const String& argument) OVERRIDE; + virtual bool isEditingCommandEnabled(const String& commandName) OVERRIDE; + + virtual bool handlesPageScaleFactor(); + virtual NPObject* pluginScriptableNPObject(); #if PLATFORM(MAC) virtual void windowFocusChanged(bool); diff --git a/Source/WebKit2/WebProcess/Plugins/PluginView.cpp b/Source/WebKit2/WebProcess/Plugins/PluginView.cpp index e2a6e1f05..d0a5e1e2c 100644 --- a/Source/WebKit2/WebProcess/Plugins/PluginView.cpp +++ b/Source/WebKit2/WebProcess/Plugins/PluginView.cpp @@ -1,5 +1,5 @@ /* - * Copyright (C) 2010 Apple Inc. All rights reserved. + * Copyright (C) 2010, 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 @@ -67,6 +67,8 @@ using namespace WebCore; namespace WebKit { +static const double pluginSnapshotTimerDelay = 3; + class PluginView::URLRequest : public RefCounted<URLRequest> { public: static PassRefPtr<PluginView::URLRequest> create(uint64_t requestID, const FrameLoadRequest& request, bool allowPopups) @@ -170,9 +172,9 @@ static String buildHTTPHeaders(const ResourceResponse& response, long long& expe HTTPHeaderMap::const_iterator end = response.httpHeaderFields().end(); for (HTTPHeaderMap::const_iterator it = response.httpHeaderFields().begin(); it != end; ++it) { - stringBuilder.append(it->first.characters(), it->first.length()); + stringBuilder.append(it->key.characters(), it->key.length()); stringBuilder.append(separator.characters(), separator.length()); - stringBuilder.append(it->second.characters(), it->second.length()); + stringBuilder.append(it->value.characters(), it->value.length()); stringBuilder.append('\n'); } @@ -268,6 +270,8 @@ PluginView::PluginView(PassRefPtr<HTMLPlugInElement> pluginElement, PassRefPtr<P , m_npRuntimeObjectMap(this) #endif , m_manualStreamState(StreamStateInitial) + , m_pluginSnapshotTimer(this, &PluginView::pluginSnapshotTimerFired, pluginSnapshotTimerDelay) + , m_pageScaleFactor(1) { m_webPage->addPluginView(this); } @@ -282,9 +286,18 @@ PluginView::~PluginView() if (m_isWaitingUntilMediaCanStart) m_pluginElement->document()->removeMediaCanStartListener(this); + destroyPluginAndReset(); + + // Null out the plug-in element explicitly so we'll crash earlier if we try to use + // the plug-in view after it's been destroyed. + m_pluginElement = nullptr; +} + +void PluginView::destroyPluginAndReset() +{ // Cancel all pending frame loads. for (FrameLoadMap::iterator it = m_pendingFrameLoads.begin(), end = m_pendingFrameLoads.end(); it != end; ++it) - it->first->setLoadListener(0); + it->key->setLoadListener(0); if (m_plugin) { m_isBeingDestroyed = true; @@ -302,10 +315,26 @@ PluginView::~PluginView() #endif cancelAllStreams(); +} - // Null out the plug-in element explicitly so we'll crash earlier if we try to use - // the plug-in view after it's been destroyed. - m_pluginElement = nullptr; +void PluginView::recreateAndInitialize(PassRefPtr<Plugin> plugin) +{ + if (m_plugin) { + if (m_pluginSnapshotTimer.isActive()) + m_pluginSnapshotTimer.stop(); + destroyPluginAndReset(); + } + + // Reset member variables to initial values. + m_plugin = plugin; + m_isInitialized = false; + m_isWaitingForSynchronousInitialization = false; + m_isWaitingUntilMediaCanStart = false; + m_isBeingDestroyed = false; + m_manualStreamState = StreamStateInitial; + m_transientPaintingSnapshot = nullptr; + + initializePlugin(); } Frame* PluginView::frame() const @@ -399,6 +428,18 @@ void PluginView::pageScaleFactorDidChange() viewGeometryDidChange(); } +void PluginView::setPageScaleFactor(double scaleFactor, IntPoint) +{ + m_pageScaleFactor = scaleFactor; + m_webPage->send(Messages::WebPageProxy::PageScaleFactorDidChange(scaleFactor)); + pageScaleFactorDidChange(); +} + +double PluginView::pageScaleFactor() +{ + return m_pageScaleFactor; +} + void PluginView::webPageDestroyed() { m_webPage = 0; @@ -513,7 +554,9 @@ void PluginView::didInitializePlugin() redeliverManualStream(); #if PLATFORM(MAC) - if (m_plugin->pluginLayer()) { + if (m_pluginElement->displayState() < HTMLPlugInElement::Playing) + m_pluginSnapshotTimer.restart(); + else if (m_plugin->pluginLayer()) { if (frame()) { frame()->view()->enterCompositingMode(); m_pluginElement->setNeedsStyleRecalc(SyntheticStyleChange); @@ -643,7 +686,7 @@ void PluginView::setFrameRect(const WebCore::IntRect& rect) void PluginView::paint(GraphicsContext* context, const IntRect& /*dirtyRect*/) { - if (!m_plugin || !m_isInitialized) + if (!m_plugin || !m_isInitialized || m_pluginElement->displayState() < HTMLPlugInElement::Playing) return; if (context->paintingDisabled()) { @@ -658,8 +701,8 @@ void PluginView::paint(GraphicsContext* context, const IntRect& /*dirtyRect*/) if (paintRect.isEmpty()) return; - if (m_snapshot) { - m_snapshot->paint(*context, contentsScaleFactor(), frameRect().location(), m_snapshot->bounds()); + if (m_transientPaintingSnapshot) { + m_transientPaintingSnapshot->paint(*context, contentsScaleFactor(), frameRect().location(), m_transientPaintingSnapshot->bounds()); return; } @@ -730,16 +773,26 @@ void PluginView::handleEvent(Event* event) if (didHandleEvent) event->setDefaultHandled(); } + +bool PluginView::handleEditingCommand(const String& commandName, const String& argument) +{ + return m_plugin->handleEditingCommand(commandName, argument); +} + +bool PluginView::isEditingCommandEnabled(const String& commandName) +{ + return m_plugin->isEditingCommandEnabled(commandName); +} void PluginView::notifyWidget(WidgetNotification notification) { switch (notification) { case WillPaintFlattened: if (m_plugin && m_isInitialized) - m_snapshot = m_plugin->snapshot(); + m_transientPaintingSnapshot = m_plugin->snapshot(); break; case DidPaintFlattened: - m_snapshot = nullptr; + m_transientPaintingSnapshot = nullptr; break; } } @@ -1021,6 +1074,9 @@ void PluginView::invalidateRect(const IntRect& dirtyRect) return; #endif + if (m_pluginElement->displayState() < HTMLPlugInElement::Playing) + return; + RenderBoxModelObject* renderer = toRenderBoxModelObject(m_pluginElement->renderer()); if (!renderer) return; @@ -1176,6 +1232,8 @@ bool PluginView::isAcceleratedCompositingEnabled() if (!settings) return false; + if (m_pluginElement->displayState() < HTMLPlugInElement::Playing) + return false; return settings->acceleratedCompositingEnabled(); } @@ -1364,4 +1422,19 @@ void PluginView::windowedPluginGeometryDidChange(const WebCore::IntRect& frameRe } #endif +void PluginView::pluginSnapshotTimerFired(DeferrableOneShotTimer<PluginView>* timer) +{ + ASSERT_UNUSED(timer, timer == &m_pluginSnapshotTimer); + ASSERT(m_plugin); + + // Snapshot might be 0 if plugin size is 0x0. + RefPtr<ShareableBitmap> snapshot = m_plugin->snapshot(); + RefPtr<Image> snapshotImage; + if (snapshot) + snapshotImage = snapshot->createImage(); + m_pluginElement->updateSnapshot(snapshotImage.release()); + destroyPluginAndReset(); + m_plugin = 0; +} + } // namespace WebKit diff --git a/Source/WebKit2/WebProcess/Plugins/PluginView.h b/Source/WebKit2/WebProcess/Plugins/PluginView.h index 9cc257a98..0d0dfa344 100644 --- a/Source/WebKit2/WebProcess/Plugins/PluginView.h +++ b/Source/WebKit2/WebProcess/Plugins/PluginView.h @@ -1,5 +1,5 @@ /* - * Copyright (C) 2010 Apple Inc. All rights reserved. + * Copyright (C) 2010, 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 @@ -30,11 +30,13 @@ #include "Plugin.h" #include "PluginController.h" #include "WebFrame.h" +#include <WebCore/Image.h> #include <WebCore/MediaCanStartListener.h> #include <WebCore/PluginViewBase.h> #include <WebCore/ResourceError.h> #include <WebCore/ResourceResponse.h> #include <WebCore/RunLoop.h> +#include <WebCore/Timer.h> #include <wtf/Deque.h> // FIXME: Eventually this should move to WebCore. @@ -51,6 +53,8 @@ class PluginView : public WebCore::PluginViewBase, public PluginController, priv public: static PassRefPtr<PluginView> create(PassRefPtr<WebCore::HTMLPlugInElement>, PassRefPtr<Plugin>, const Plugin::Parameters&); + void recreateAndInitialize(PassRefPtr<Plugin>); + WebCore::Frame* frame() const; bool isBeingDestroyed() const { return m_isBeingDestroyed; } @@ -70,12 +74,22 @@ public: RetainPtr<PDFDocument> pdfDocumentForPrinting() const { return m_plugin->pdfDocumentForPrinting(); } #endif + WebCore::HTMLPlugInElement* pluginElement() const { return m_pluginElement.get(); } + const Plugin::Parameters& initialParameters() const { return m_parameters; } + // FIXME: Remove this; nobody should have to know about the plug-in view's renderer except the plug-in view itself. WebCore::RenderBoxModelObject* renderer() const; + + void setPageScaleFactor(double scaleFactor, WebCore::IntPoint origin); + double pageScaleFactor(); + bool handlesPageScaleFactor() { return m_plugin->handlesPageScaleFactor(); } void pageScaleFactorDidChange(); void webPageDestroyed(); + virtual bool handleEditingCommand(const String& commandName, const String& argument); + virtual bool isEditingCommandEnabled(const String& commandName); + private: PluginView(PassRefPtr<WebCore::HTMLPlugInElement>, PassRefPtr<Plugin>, const Plugin::Parameters& parameters); virtual ~PluginView(); @@ -104,6 +118,8 @@ private: void redeliverManualStream(); + void pluginSnapshotTimerFired(WebCore::DeferrableOneShotTimer<PluginView>*); + // WebCore::PluginViewBase #if PLATFORM(MAC) virtual PlatformLayer* platformLayer() const; @@ -177,6 +193,7 @@ private: virtual void didInitializePlugin(); virtual void didFailToInitializePlugin(); + void destroyPluginAndReset(); // WebFrame::LoadListener virtual void didFinishLoad(WebFrame*); @@ -222,7 +239,12 @@ private: WebCore::ResourceError m_manualStreamError; RefPtr<WebCore::SharedBuffer> m_manualStreamData; - RefPtr<ShareableBitmap> m_snapshot; + // This snapshot is used to avoid side effects should the plugin run JS during painting. + RefPtr<ShareableBitmap> m_transientPaintingSnapshot; + // This timer is used when plugin snapshotting is enabled, to capture a plugin placeholder. + WebCore::DeferrableOneShotTimer<PluginView> m_pluginSnapshotTimer; + + double m_pageScaleFactor; }; } // namespace WebKit diff --git a/Source/WebKit2/WebProcess/WebConnectionToUIProcess.cpp b/Source/WebKit2/WebProcess/WebConnectionToUIProcess.cpp index 5e7955d67..5e152ee98 100644 --- a/Source/WebKit2/WebProcess/WebConnectionToUIProcess.cpp +++ b/Source/WebKit2/WebProcess/WebConnectionToUIProcess.cpp @@ -40,47 +40,34 @@ PassRefPtr<WebConnectionToUIProcess> WebConnectionToUIProcess::create(WebProcess } WebConnectionToUIProcess::WebConnectionToUIProcess(WebProcess* process, CoreIPC::Connection::Identifier connectionIdentifier, RunLoop* runLoop) - : m_process(process) - , m_connection(CoreIPC::Connection::createClientConnection(connectionIdentifier, this, runLoop)) + : WebConnection(CoreIPC::Connection::createClientConnection(connectionIdentifier, this, runLoop)) + , m_process(process) { m_connection->setDidCloseOnConnectionWorkQueueCallback(ChildProcess::didCloseOnConnectionWorkQueue); m_connection->setShouldExitOnSyncMessageSendFailure(true); } -void WebConnectionToUIProcess::invalidate() +// WebConnection + +void WebConnectionToUIProcess::encodeMessageBody(CoreIPC::ArgumentEncoder* argumentEncoder, APIObject* messageBody) { - m_connection->invalidate(); - m_connection = nullptr; - m_process = 0; + argumentEncoder->encode(InjectedBundleUserMessageEncoder(messageBody)); } -// WebConnection - -void WebConnectionToUIProcess::postMessage(const String& messageName, APIObject* messageBody) +bool WebConnectionToUIProcess::decodeMessageBody(CoreIPC::ArgumentDecoder* argumentDecoder, RefPtr<APIObject>& messageBody) { - if (!m_process) - return; + if (!argumentDecoder->decode(InjectedBundleUserMessageDecoder(messageBody))) + return false; - m_connection->deprecatedSend(WebConnectionLegacyMessage::PostMessage, 0, CoreIPC::In(messageName, InjectedBundleUserMessageEncoder(messageBody))); + return true; } // CoreIPC::Connection::Client void WebConnectionToUIProcess::didReceiveMessage(CoreIPC::Connection* connection, CoreIPC::MessageID messageID, CoreIPC::ArgumentDecoder* arguments) { - if (messageID.is<CoreIPC::MessageClassWebConnectionLegacy>()) { - switch (messageID.get<WebConnectionLegacyMessage::Kind>()) { - case WebConnectionLegacyMessage::PostMessage: { - String messageName; - RefPtr<APIObject> messageBody; - InjectedBundleUserMessageDecoder messageDecoder(messageBody); - if (!arguments->decode(CoreIPC::Out(messageName, messageDecoder))) - return; - - forwardDidReceiveMessageToClient(messageName, messageBody.get()); - return; - } - } + if (messageID.is<CoreIPC::MessageClassWebConnection>()) { + didReceiveWebConnectionMessage(connection, messageID, arguments); return; } @@ -102,11 +89,6 @@ void WebConnectionToUIProcess::didReceiveInvalidMessage(CoreIPC::Connection* con m_process->didReceiveInvalidMessage(connection, messageID); } -void WebConnectionToUIProcess::syncMessageSendTimedOut(CoreIPC::Connection* connection) -{ - m_process->syncMessageSendTimedOut(connection); -} - #if PLATFORM(WIN) Vector<HWND> WebConnectionToUIProcess::windowsToReceiveSentMessagesWhileWaitingForSyncReply() { diff --git a/Source/WebKit2/WebProcess/WebConnectionToUIProcess.h b/Source/WebKit2/WebProcess/WebConnectionToUIProcess.h index 42b9cd716..cdff4ac27 100644 --- a/Source/WebKit2/WebProcess/WebConnectionToUIProcess.h +++ b/Source/WebKit2/WebProcess/WebConnectionToUIProcess.h @@ -37,28 +37,23 @@ class WebConnectionToUIProcess : public WebConnection, CoreIPC::Connection::Clie public: static PassRefPtr<WebConnectionToUIProcess> create(WebProcess*, CoreIPC::Connection::Identifier, WebCore::RunLoop*); - CoreIPC::Connection* connection() { return m_connection.get(); } - - void invalidate(); - private: WebConnectionToUIProcess(WebProcess*, CoreIPC::Connection::Identifier, WebCore::RunLoop*); // WebConnection - virtual void postMessage(const String&, APIObject*); + virtual void encodeMessageBody(CoreIPC::ArgumentEncoder*, APIObject*) OVERRIDE; + virtual bool decodeMessageBody(CoreIPC::ArgumentDecoder*, RefPtr<APIObject>&) OVERRIDE; // CoreIPC::Connection::Client virtual void didReceiveMessage(CoreIPC::Connection*, CoreIPC::MessageID, CoreIPC::ArgumentDecoder*); virtual void didReceiveSyncMessage(CoreIPC::Connection*, CoreIPC::MessageID, CoreIPC::ArgumentDecoder*, OwnPtr<CoreIPC::ArgumentEncoder>&); virtual void didClose(CoreIPC::Connection*); virtual void didReceiveInvalidMessage(CoreIPC::Connection*, CoreIPC::MessageID); - virtual void syncMessageSendTimedOut(CoreIPC::Connection*); #if PLATFORM(WIN) virtual Vector<HWND> windowsToReceiveSentMessagesWhileWaitingForSyncReply(); #endif WebProcess* m_process; - RefPtr<CoreIPC::Connection> m_connection; }; } // namespace WebKit diff --git a/Source/WebKit2/WebProcess/WebCoreSupport/WebChromeClient.cpp b/Source/WebKit2/WebProcess/WebCoreSupport/WebChromeClient.cpp index dbcab8dbf..ac3daa908 100644 --- a/Source/WebKit2/WebProcess/WebCoreSupport/WebChromeClient.cpp +++ b/Source/WebKit2/WebProcess/WebCoreSupport/WebChromeClient.cpp @@ -314,7 +314,7 @@ void WebChromeClient::runJavaScriptAlert(Frame* frame, const String& alertText) m_page->injectedBundleUIClient().willRunJavaScriptAlert(m_page, alertText, webFrame); unsigned syncSendFlags = (WebCore::AXObjectCache::accessibilityEnabled()) ? CoreIPC::SpinRunLoopWhileWaitingForReply : 0; - WebProcess::shared().connection()->sendSync(Messages::WebPageProxy::RunJavaScriptAlert(webFrame->frameID(), alertText), Messages::WebPageProxy::RunJavaScriptAlert::Reply(), m_page->pageID(), CoreIPC::Connection::DefaultTimeout, syncSendFlags); + WebProcess::shared().connection()->sendSync(Messages::WebPageProxy::RunJavaScriptAlert(webFrame->frameID(), alertText), Messages::WebPageProxy::RunJavaScriptAlert::Reply(), m_page->pageID(), CoreIPC::Connection::NoTimeout, syncSendFlags); } bool WebChromeClient::runJavaScriptConfirm(Frame* frame, const String& message) @@ -326,7 +326,7 @@ bool WebChromeClient::runJavaScriptConfirm(Frame* frame, const String& message) unsigned syncSendFlags = (WebCore::AXObjectCache::accessibilityEnabled()) ? CoreIPC::SpinRunLoopWhileWaitingForReply : 0; bool result = false; - if (!WebProcess::shared().connection()->sendSync(Messages::WebPageProxy::RunJavaScriptConfirm(webFrame->frameID(), message), Messages::WebPageProxy::RunJavaScriptConfirm::Reply(result), m_page->pageID(), CoreIPC::Connection::DefaultTimeout, syncSendFlags)) + if (!WebProcess::shared().connection()->sendSync(Messages::WebPageProxy::RunJavaScriptConfirm(webFrame->frameID(), message), Messages::WebPageProxy::RunJavaScriptConfirm::Reply(result), m_page->pageID(), CoreIPC::Connection::NoTimeout, syncSendFlags)) return false; return result; @@ -340,7 +340,7 @@ bool WebChromeClient::runJavaScriptPrompt(Frame* frame, const String& message, c m_page->injectedBundleUIClient().willRunJavaScriptPrompt(m_page, message, defaultValue, webFrame); unsigned syncSendFlags = (WebCore::AXObjectCache::accessibilityEnabled()) ? CoreIPC::SpinRunLoopWhileWaitingForReply : 0; - if (!WebProcess::shared().connection()->sendSync(Messages::WebPageProxy::RunJavaScriptPrompt(webFrame->frameID(), message, defaultValue), Messages::WebPageProxy::RunJavaScriptPrompt::Reply(result), m_page->pageID(), CoreIPC::Connection::DefaultTimeout, syncSendFlags)) + if (!WebProcess::shared().connection()->sendSync(Messages::WebPageProxy::RunJavaScriptPrompt(webFrame->frameID(), message, defaultValue), Messages::WebPageProxy::RunJavaScriptPrompt::Reply(result), m_page->pageID(), CoreIPC::Connection::NoTimeout, syncSendFlags)) return false; return !result.isNull(); @@ -562,7 +562,7 @@ void WebChromeClient::reachedApplicationCacheOriginQuota(SecurityOrigin* origin, } #if ENABLE(DASHBOARD_SUPPORT) -void WebChromeClient::dashboardRegionsChanged() +void WebChromeClient::annotatedRegionsChanged() { notImplemented(); } @@ -691,6 +691,11 @@ PassRefPtr<WebCore::SearchPopupMenu> WebChromeClient::createSearchPopupMenu(WebC } #if USE(ACCELERATED_COMPOSITING) +GraphicsLayerFactory* WebChromeClient::graphicsLayerFactory() const +{ + return m_page->drawingArea()->graphicsLayerFactory(); +} + void WebChromeClient::attachRootGraphicsLayer(Frame*, GraphicsLayer* layer) { if (layer) @@ -704,10 +709,10 @@ void WebChromeClient::setNeedsOneShotDrawingSynchronization() notImplemented(); } -void WebChromeClient::scheduleCompositingLayerSync() +void WebChromeClient::scheduleCompositingLayerFlush() { if (m_page->drawingArea()) - m_page->drawingArea()->scheduleCompositingLayerSync(); + m_page->drawingArea()->scheduleCompositingLayerFlush(); } #endif diff --git a/Source/WebKit2/WebProcess/WebCoreSupport/WebChromeClient.h b/Source/WebKit2/WebProcess/WebCoreSupport/WebChromeClient.h index f40d4b174..1e62f7abd 100644 --- a/Source/WebKit2/WebProcess/WebCoreSupport/WebChromeClient.h +++ b/Source/WebKit2/WebProcess/WebCoreSupport/WebChromeClient.h @@ -139,7 +139,7 @@ private: virtual void reachedApplicationCacheOriginQuota(WebCore::SecurityOrigin*, int64_t spaceNeeded) OVERRIDE; #if ENABLE(DASHBOARD_SUPPORT) - virtual void dashboardRegionsChanged() OVERRIDE; + virtual void annotatedRegionsChanged() OVERRIDE; #endif virtual void populateVisitedLinks() OVERRIDE; @@ -177,9 +177,10 @@ private: virtual PassRefPtr<WebCore::SearchPopupMenu> createSearchPopupMenu(WebCore::PopupMenuClient*) const OVERRIDE; #if USE(ACCELERATED_COMPOSITING) + virtual WebCore::GraphicsLayerFactory* graphicsLayerFactory() const OVERRIDE; virtual void attachRootGraphicsLayer(WebCore::Frame*, WebCore::GraphicsLayer*) OVERRIDE; virtual void setNeedsOneShotDrawingSynchronization() OVERRIDE; - virtual void scheduleCompositingLayerSync() OVERRIDE; + virtual void scheduleCompositingLayerFlush() OVERRIDE; virtual CompositingTriggerFlags allowedCompositingTriggers() const { diff --git a/Source/WebKit2/WebProcess/WebCoreSupport/WebFrameLoaderClient.cpp b/Source/WebKit2/WebProcess/WebCoreSupport/WebFrameLoaderClient.cpp index e13908e63..c29463f46 100644 --- a/Source/WebKit2/WebProcess/WebCoreSupport/WebFrameLoaderClient.cpp +++ b/Source/WebKit2/WebProcess/WebCoreSupport/WebFrameLoaderClient.cpp @@ -1,5 +1,5 @@ /* - * Copyright (C) 2010, 2011 Apple Inc. All rights reserved. + * Copyright (C) 2010, 2011, 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 @@ -44,6 +44,7 @@ #include "WebFrame.h" #include "WebFrameNetworkingContext.h" #include "WebFullScreenManager.h" +#include "WebIconDatabaseMessages.h" #include "WebNavigationDataStore.h" #include "WebPage.h" #include "WebPageProxyMessages.h" @@ -67,6 +68,7 @@ #include <WebCore/Page.h> #include <WebCore/PluginData.h> #include <WebCore/ProgressTracker.h> +#include <WebCore/ResourceBuffer.h> #include <WebCore/ResourceError.h> #include <WebCore/Settings.h> #include <WebCore/UIEventWithKeyState.h> @@ -91,6 +93,7 @@ namespace WebKit { WebFrameLoaderClient::WebFrameLoaderClient(WebFrame* frame) : m_frame(frame) , m_hasSentResponseToPluginView(false) + , m_didCompletePageTransitionAlready(false) , m_frameHasCustomRepresentation(false) , m_frameCameFromPageCache(false) { @@ -393,7 +396,7 @@ void WebFrameLoaderClient::dispatchWillClose() void WebFrameLoaderClient::dispatchDidReceiveIcon() { - notImplemented(); + WebProcess::shared().connection()->send(Messages::WebIconDatabase::DidReceiveIconForPageURL(m_frame->url()), 0); } void WebFrameLoaderClient::dispatchDidStartProvisionalLoad() @@ -562,8 +565,10 @@ void WebFrameLoaderClient::dispatchDidLayout(LayoutMilestones milestones) webPage->send(Messages::WebPageProxy::DidFirstLayoutForFrame(m_frame->frameID(), InjectedBundleUserMessageEncoder(userData.get()))); if (m_frame == m_frame->page()->mainWebFrame()) { - if (!webPage->corePage()->settings()->suppressesIncrementalRendering()) - webPage->drawingArea()->setLayerTreeStateIsFrozen(false); + if (!webPage->corePage()->settings()->suppressesIncrementalRendering() && !m_didCompletePageTransitionAlready) { + webPage->didCompletePageTransition(); + m_didCompletePageTransitionAlready = true; + } } #if USE(TILED_BACKING_STORE) @@ -894,7 +899,7 @@ void WebFrameLoaderClient::finishedLoading(DocumentLoader* loader) if (!webPage) return; - RefPtr<SharedBuffer> mainResourceData = loader->mainResourceData(); + RefPtr<ResourceBuffer> mainResourceData = loader->mainResourceData(); CoreIPC::DataReference dataReference(reinterpret_cast<const uint8_t*>(mainResourceData ? mainResourceData->data() : 0), mainResourceData ? mainResourceData->size() : 0); webPage->send(Messages::WebPageProxy::DidFinishLoadingDataForCustomRepresentation(loader->response().suggestedFilename(), dataReference)); @@ -1120,12 +1125,15 @@ String WebFrameLoaderClient::generatedMIMETypeForURLScheme(const String& /*URLSc void WebFrameLoaderClient::frameLoadCompleted() { + // Note: Can be called multiple times. WebPage* webPage = m_frame->page(); if (!webPage) return; - if (m_frame == m_frame->page()->mainWebFrame()) - webPage->drawingArea()->setLayerTreeStateIsFrozen(false); + if (m_frame == m_frame->page()->mainWebFrame() && !m_didCompletePageTransitionAlready) { + webPage->didCompletePageTransition(); + m_didCompletePageTransitionAlready = true; + } } void WebFrameLoaderClient::saveViewStateToItem(HistoryItem*) @@ -1138,10 +1146,9 @@ void WebFrameLoaderClient::restoreViewState() // Inform the UI process of the scale factor. double scaleFactor = m_frame->coreFrame()->loader()->history()->currentItem()->pageScaleFactor(); - // A scale factor of 0.0 means the history item actually has the "default scale factor" of 1.0. - if (!scaleFactor) - scaleFactor = 1.0; - m_frame->page()->send(Messages::WebPageProxy::PageScaleFactorDidChange(scaleFactor)); + // A scale factor of 0 means the history item has the default scale factor, thus we do not need to update it. + if (scaleFactor) + m_frame->page()->send(Messages::WebPageProxy::PageScaleFactorDidChange(scaleFactor)); // FIXME: This should not be necessary. WebCore should be correctly invalidating // the view on restores from the back/forward cache. @@ -1155,8 +1162,10 @@ void WebFrameLoaderClient::provisionalLoadStarted() if (!webPage) return; - if (m_frame == m_frame->page()->mainWebFrame()) - webPage->drawingArea()->setLayerTreeStateIsFrozen(true); + if (m_frame == m_frame->page()->mainWebFrame()) { + webPage->didStartPageTransition(); + m_didCompletePageTransitionAlready = false; + } } void WebFrameLoaderClient::didFinishLoad() @@ -1206,7 +1215,7 @@ void WebFrameLoaderClient::transitionToCommittedFromCachedFrame(CachedFrame*) bool isMainFrame = webPage->mainWebFrame() == m_frame; const ResourceResponse& response = m_frame->coreFrame()->loader()->documentLoader()->response(); - m_frameHasCustomRepresentation = isMainFrame && WebProcess::shared().shouldUseCustomRepresentationForResponse(response); + m_frameHasCustomRepresentation = isMainFrame && webPage->shouldUseCustomRepresentationForResponse(response); m_frameCameFromPageCache = true; } @@ -1220,7 +1229,7 @@ void WebFrameLoaderClient::transitionToCommittedForNewPage() IntRect currentVisibleContentBounds = m_frame->visibleContentBounds(); const ResourceResponse& response = m_frame->coreFrame()->loader()->documentLoader()->response(); - m_frameHasCustomRepresentation = isMainFrame && WebProcess::shared().shouldUseCustomRepresentationForResponse(response); + m_frameHasCustomRepresentation = isMainFrame && webPage->shouldUseCustomRepresentationForResponse(response); m_frameCameFromPageCache = false; m_frame->coreFrame()->createView(webPage->size(), backgroundColor, /* transparent */ false, IntSize(), shouldUseFixedLayout); @@ -1344,6 +1353,16 @@ PassRefPtr<Widget> WebFrameLoaderClient::createPlugin(const IntSize&, HTMLPlugIn return PluginView::create(pluginElement, plugin.release(), parameters); } +void WebFrameLoaderClient::recreatePlugin(Widget* widget) +{ + ASSERT(widget && widget->isPluginViewBase()); + ASSERT(m_frame->page()); + + PluginView* pluginView = static_cast<PluginView*>(widget); + RefPtr<Plugin> plugin = m_frame->page()->createPlugin(m_frame, pluginView->pluginElement(), pluginView->initialParameters()); + pluginView->recreateAndInitialize(plugin.release()); +} + void WebFrameLoaderClient::redirectDataToPlugin(Widget* pluginWidget) { m_pluginView = static_cast<PluginView*>(pluginWidget); @@ -1515,10 +1534,6 @@ RemoteAXObjectRef WebFrameLoaderClient::accessibilityRemoteObject() return m_frame->page()->accessibilityRemoteObject(); } -#if ENABLE(MAC_JAVA_BRIDGE) -jobject WebFrameLoaderClient::javaApplet(NSView*) { return 0; } -#endif - NSCachedURLResponse* WebFrameLoaderClient::willCacheResponse(DocumentLoader*, unsigned long identifier, NSCachedURLResponse* response) const { WebPage* webPage = m_frame->page(); diff --git a/Source/WebKit2/WebProcess/WebCoreSupport/WebFrameLoaderClient.h b/Source/WebKit2/WebProcess/WebCoreSupport/WebFrameLoaderClient.h index 213a2fea0..56e121f52 100644 --- a/Source/WebKit2/WebProcess/WebCoreSupport/WebFrameLoaderClient.h +++ b/Source/WebKit2/WebProcess/WebCoreSupport/WebFrameLoaderClient.h @@ -1,5 +1,5 @@ /* - * Copyright (C) 2010, 2011 Apple Inc. All rights reserved. + * Copyright (C) 2010, 2011, 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 @@ -188,6 +188,7 @@ private: const String& referrer, bool allowsScrolling, int marginWidth, int marginHeight) OVERRIDE; virtual PassRefPtr<WebCore::Widget> createPlugin(const WebCore::IntSize&, WebCore::HTMLPlugInElement*, const WebCore::KURL&, const Vector<String>&, const Vector<String>&, const String&, bool loadManually) OVERRIDE; + virtual void recreatePlugin(WebCore::Widget*) OVERRIDE; virtual void redirectDataToPlugin(WebCore::Widget* pluginWidget) OVERRIDE; virtual PassRefPtr<WebCore::Widget> createJavaAppletWidget(const WebCore::IntSize&, WebCore::HTMLAppletElement*, const WebCore::KURL& baseURL, const Vector<String>& paramNames, const Vector<String>& paramValues) OVERRIDE; @@ -216,9 +217,6 @@ private: #if PLATFORM(MAC) virtual RemoteAXObjectRef accessibilityRemoteObject() OVERRIDE; -#if ENABLE(MAC_JAVA_BRIDGE) - virtual jobject javaApplet(NSView*) OVERRIDE; -#endif virtual NSCachedURLResponse* willCacheResponse(WebCore::DocumentLoader*, unsigned long identifier, NSCachedURLResponse*) const OVERRIDE; #endif #if PLATFORM(WIN) && USE(CFNETWORK) @@ -244,6 +242,7 @@ private: WebFrame* m_frame; RefPtr<PluginView> m_pluginView; bool m_hasSentResponseToPluginView; + bool m_didCompletePageTransitionAlready; bool m_frameHasCustomRepresentation; bool m_frameCameFromPageCache; }; diff --git a/Source/WebKit2/WebProcess/WebCoreSupport/mac/WebSystemInterface.mm b/Source/WebKit2/WebProcess/WebCoreSupport/mac/WebSystemInterface.mm index 1897675dc..aef59ca86 100644 --- a/Source/WebKit2/WebProcess/WebCoreSupport/mac/WebSystemInterface.mm +++ b/Source/WebKit2/WebProcess/WebCoreSupport/mac/WebSystemInterface.mm @@ -44,6 +44,12 @@ void InitWebCoreSystemInterface(void) INIT(CGContextGetShouldSmoothFonts); INIT(CGPatternCreateWithImageAndTransform); INIT(CGContextResetClip); +#if __MAC_OS_X_VERSION_MIN_REQUIRED >= 1080 + INIT(CGContextDrawsWithCorrectShadowOffsets); +#endif +#if __MAC_OS_X_VERSION_MIN_REQUIRED >= 1090 + INIT(CTFontTransformGlyphs); +#endif INIT(CopyCONNECTProxyResponse); INIT(CopyNSURLResponseStatusLine); INIT(CreateCTLineWithUniCharProvider); diff --git a/Source/WebKit2/WebProcess/WebCoreSupport/qt/WebDragClientQt.cpp b/Source/WebKit2/WebProcess/WebCoreSupport/qt/WebDragClientQt.cpp index d9e6d1d13..bbdb635b3 100644 --- a/Source/WebKit2/WebProcess/WebCoreSupport/qt/WebDragClientQt.cpp +++ b/Source/WebKit2/WebProcess/WebCoreSupport/qt/WebDragClientQt.cpp @@ -38,15 +38,15 @@ using namespace WebCore; namespace WebKit { -static PassRefPtr<ShareableBitmap> convertQImageToShareableBitmap(QImage* image) +static PassRefPtr<ShareableBitmap> convertQPixmapToShareableBitmap(QPixmap* pixmap) { - if (!image) + if (!pixmap) return 0; - RefPtr<ShareableBitmap> bitmap = ShareableBitmap::createShareable(IntSize(image->size()), ShareableBitmap::SupportsAlpha); + RefPtr<ShareableBitmap> bitmap = ShareableBitmap::createShareable(IntSize(pixmap->size()), ShareableBitmap::SupportsAlpha); OwnPtr<GraphicsContext> graphicsContext = bitmap->createGraphicsContext(); - graphicsContext->platformContext()->drawImage(0, 0, *image); + graphicsContext->platformContext()->drawPixmap(0, 0, *pixmap); return bitmap.release(); } @@ -57,7 +57,7 @@ void WebDragClient::startDrag(DragImageRef dragImage, const IntPoint& clientPosi static_cast<ClipboardQt*>(clipboard)->invalidateWritableData(); DragData dragData(clipboardData, clientPosition, globalPosition, dragOperationMask); - RefPtr<ShareableBitmap> bitmap = convertQImageToShareableBitmap(dragImage); + RefPtr<ShareableBitmap> bitmap = convertQPixmapToShareableBitmap(dragImage); ShareableBitmap::Handle handle; if (bitmap && !bitmap->createHandle(handle)) return; diff --git a/Source/WebKit2/WebProcess/WebCoreSupport/soup/WebFrameNetworkingContext.cpp b/Source/WebKit2/WebProcess/WebCoreSupport/soup/WebFrameNetworkingContext.cpp index 876de80a6..6e7b593bc 100644 --- a/Source/WebKit2/WebProcess/WebCoreSupport/soup/WebFrameNetworkingContext.cpp +++ b/Source/WebKit2/WebProcess/WebCoreSupport/soup/WebFrameNetworkingContext.cpp @@ -26,16 +26,31 @@ #include "config.h" #include "WebFrameNetworkingContext.h" +#include "WebFrame.h" +#include "WebPage.h" #include <WebCore/ResourceHandle.h> using namespace WebCore; namespace WebKit { +WebFrameNetworkingContext::WebFrameNetworkingContext(WebFrame* frame) + : FrameNetworkingContext(frame->coreFrame()) + , m_initiatingPageID(0) +{ + if (WebPage* page = frame->page()) + m_initiatingPageID = page->pageID(); +} + SoupSession* WebFrameNetworkingContext::soupSession() const { return ResourceHandle::defaultSession(); } +uint64_t WebFrameNetworkingContext::initiatingPageID() const +{ + return m_initiatingPageID; +} + } diff --git a/Source/WebKit2/WebProcess/WebCoreSupport/soup/WebFrameNetworkingContext.h b/Source/WebKit2/WebProcess/WebCoreSupport/soup/WebFrameNetworkingContext.h index 2a42d38d3..a06a69252 100644 --- a/Source/WebKit2/WebProcess/WebCoreSupport/soup/WebFrameNetworkingContext.h +++ b/Source/WebKit2/WebProcess/WebCoreSupport/soup/WebFrameNetworkingContext.h @@ -28,12 +28,12 @@ #ifndef WebFrameNetworkingContext_h #define WebFrameNetworkingContext_h -#include "WebFrame.h" - #include <WebCore/FrameNetworkingContext.h> namespace WebKit { +class WebFrame; + class WebFrameNetworkingContext : public WebCore::FrameNetworkingContext { public: static PassRefPtr<WebFrameNetworkingContext> create(WebFrame* frame) @@ -42,12 +42,12 @@ public: } private: - WebFrameNetworkingContext(WebFrame* frame) - : WebCore::FrameNetworkingContext(frame->coreFrame()) - { - } + WebFrameNetworkingContext(WebFrame*); virtual SoupSession* soupSession() const; + virtual uint64_t initiatingPageID() const; + + uint64_t m_initiatingPageID; }; } diff --git a/Source/WebKit2/WebProcess/WebKitMain.cpp b/Source/WebKit2/WebProcess/WebKitMain.cpp index 03a8cb5c5..706dad256 100644 --- a/Source/WebKit2/WebProcess/WebKitMain.cpp +++ b/Source/WebKit2/WebProcess/WebKitMain.cpp @@ -31,6 +31,14 @@ #include "WebProcessMain.h" #include <wtf/text/CString.h> +#if ENABLE(NETWORK_PROCESS) +#include "NetworkProcessMain.h" +#endif + +#if ENABLE(SHARED_WORKER_PROCESS) +#include "SharedWorkerProcessMain.h" +#endif + #if PLATFORM(MAC) #include <objc/objc-auto.h> #elif PLATFORM(WIN) @@ -54,6 +62,16 @@ static int WebKitMain(const CommandLine& commandLine) #else break; #endif + case ProcessLauncher::NetworkProcess: +#if ENABLE(NETWORK_PROCESS) + return NetworkProcessMain(commandLine); +#else + break; +#endif +#if ENABLE(SHARED_WORKER_PROCESS) + case ProcessLauncher::SharedWorkerProcess: + return SharedWorkerProcessMain(commandLine); +#endif } return EXIT_FAILURE; diff --git a/Source/WebKit2/WebProcess/WebPage/CoordinatedGraphics/CoordinatedGraphicsLayer.cpp b/Source/WebKit2/WebProcess/WebPage/CoordinatedGraphics/CoordinatedGraphicsLayer.cpp index f2afdb5fb..9798f3f05 100644 --- a/Source/WebKit2/WebProcess/WebPage/CoordinatedGraphics/CoordinatedGraphicsLayer.cpp +++ b/Source/WebKit2/WebProcess/WebPage/CoordinatedGraphics/CoordinatedGraphicsLayer.cpp @@ -53,7 +53,7 @@ CoordinatedGraphicsLayer* CoordinatedGraphicsLayer::layerByID(WebKit::WebLayerID HashMap<WebLayerID, CoordinatedGraphicsLayer*>::iterator it = table.find(id); if (it == table.end()) return 0; - return it->second; + return it->value; } static WebLayerID toWebLayerID(GraphicsLayer* layer) @@ -65,21 +65,21 @@ void CoordinatedGraphicsLayer::didChangeLayerState() { m_shouldSyncLayerState = true; if (client()) - client()->notifySyncRequired(this); + client()->notifyFlushRequired(this); } void CoordinatedGraphicsLayer::didChangeAnimatedProperties() { m_shouldSyncAnimatedProperties = true; if (client()) - client()->notifySyncRequired(this); + client()->notifyFlushRequired(this); } void CoordinatedGraphicsLayer::didChangeChildren() { m_shouldSyncChildren = true; if (client()) - client()->notifySyncRequired(this); + client()->notifyFlushRequired(this); } #if ENABLE(CSS_FILTERS) @@ -87,7 +87,7 @@ void CoordinatedGraphicsLayer::didChangeFilters() { m_shouldSyncFilters = true; if (client()) - client()->notifySyncRequired(this); + client()->notifyFlushRequired(this); } #endif @@ -340,7 +340,7 @@ void CoordinatedGraphicsLayer::setContentsNeedsDisplay() setContentsToImage(image.get()); m_canvasNeedsDisplay = true; if (client()) - client()->notifySyncRequired(this); + client()->notifyFlushRequired(this); } void CoordinatedGraphicsLayer::setContentsToCanvas(PlatformLayer* platformLayer) @@ -348,7 +348,7 @@ void CoordinatedGraphicsLayer::setContentsToCanvas(PlatformLayer* platformLayer) m_canvasPlatformLayer = platformLayer; m_canvasNeedsDisplay = true; if (client()) - client()->notifySyncRequired(this); + client()->notifyFlushRequired(this); } #if ENABLE(CSS_FILTERS) @@ -433,20 +433,20 @@ WebLayerID CoordinatedGraphicsLayer::id() const return m_id; } -void CoordinatedGraphicsLayer::syncCompositingState(const FloatRect& rect) +void CoordinatedGraphicsLayer::flushCompositingState(const FloatRect& rect) { if (CoordinatedGraphicsLayer* mask = toCoordinatedGraphicsLayer(maskLayer())) - mask->syncCompositingStateForThisLayerOnly(); + mask->flushCompositingStateForThisLayerOnly(); if (CoordinatedGraphicsLayer* replica = toCoordinatedGraphicsLayer(replicaLayer())) - replica->syncCompositingStateForThisLayerOnly(); + replica->flushCompositingStateForThisLayerOnly(); m_CoordinatedGraphicsLayerClient->syncFixedLayers(); - syncCompositingStateForThisLayerOnly(); + flushCompositingStateForThisLayerOnly(); for (size_t i = 0; i < children().size(); ++i) - children()[i]->syncCompositingState(rect); + children()[i]->flushCompositingState(rect); } CoordinatedGraphicsLayer* toCoordinatedGraphicsLayer(GraphicsLayer* layer) @@ -530,7 +530,7 @@ void CoordinatedGraphicsLayer::syncCanvas() #if USE(GRAPHICS_SURFACE) uint32_t frontBuffer = m_canvasPlatformLayer->copyToGraphicsSurface(); - uint64_t token = m_canvasPlatformLayer->graphicsSurfaceToken(); + GraphicsSurfaceToken token = m_canvasPlatformLayer->graphicsSurfaceToken(); m_CoordinatedGraphicsLayerClient->syncCanvas(m_id, IntSize(size().width(), size().height()), token, frontBuffer); #endif @@ -545,7 +545,7 @@ void CoordinatedGraphicsLayer::ensureImageBackingStore() m_layerInfo.imageBackingStoreID = m_CoordinatedGraphicsLayerClient->adoptImageBackingStore(m_image.get()); } -void CoordinatedGraphicsLayer::syncCompositingStateForThisLayerOnly() +void CoordinatedGraphicsLayer::flushCompositingStateForThisLayerOnly() { // The remote image might have been released by purgeBackingStores. ensureImageBackingStore(); diff --git a/Source/WebKit2/WebProcess/WebPage/CoordinatedGraphics/CoordinatedGraphicsLayer.h b/Source/WebKit2/WebProcess/WebPage/CoordinatedGraphics/CoordinatedGraphicsLayer.h index f4ea2fb92..049991070 100644 --- a/Source/WebKit2/WebProcess/WebPage/CoordinatedGraphics/CoordinatedGraphicsLayer.h +++ b/Source/WebKit2/WebProcess/WebPage/CoordinatedGraphics/CoordinatedGraphicsLayer.h @@ -1,4 +1,4 @@ - /* +/* Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies) This library is free software; you can redistribute it and/or @@ -26,6 +26,7 @@ #include "GraphicsLayer.h" #include "GraphicsLayerAnimation.h" #include "GraphicsLayerTransform.h" +#include "GraphicsSurface.h" #include "Image.h" #include "IntSize.h" #include "ShareableBitmap.h" @@ -61,8 +62,8 @@ public: #if ENABLE(CSS_FILTERS) virtual void syncLayerFilters(WebLayerID, const WebCore::FilterOperations&) = 0; #endif -#if PLATFORM(QT) - virtual void syncCanvas(WebLayerID, const WebCore::IntSize& canvasSize, uint64_t graphicsSurfaceToken, uint32_t frontBuffer) = 0; +#if USE(GRAPHICS_SURFACE) + virtual void syncCanvas(WebLayerID, const WebCore::IntSize& canvasSize, const WebCore::GraphicsSurfaceToken&, uint32_t frontBuffer) = 0; #endif virtual void setLayerAnimatedOpacity(WebLayerID, float) = 0; @@ -115,8 +116,8 @@ public: void setContentsNeedsDisplay(); void setContentsScale(float); void setVisibleContentRectTrajectoryVector(const FloatPoint&); - virtual void syncCompositingState(const FloatRect&); - virtual void syncCompositingStateForThisLayerOnly(); + virtual void flushCompositingState(const FloatRect&); + virtual void flushCompositingStateForThisLayerOnly(); #if ENABLE(CSS_FILTERS) bool setFilters(const FilterOperations&); #endif @@ -133,6 +134,7 @@ public: GraphicsLayer* maskTarget() const { return m_maskTarget; } void setMaskTarget(GraphicsLayer* layer) { m_maskTarget = layer; } + IntRect coverRect() const { return m_mainBackingStore ? m_mainBackingStore->mapToContents(m_mainBackingStore->coverRect()) : IntRect(); } static void initFactory(); diff --git a/Source/WebKit2/WebProcess/WebPage/CoordinatedGraphics/LayerTreeCoordinator.cpp b/Source/WebKit2/WebProcess/WebPage/CoordinatedGraphics/LayerTreeCoordinator.cpp index d979ad71c..416cf00e0 100644 --- a/Source/WebKit2/WebProcess/WebPage/CoordinatedGraphics/LayerTreeCoordinator.cpp +++ b/Source/WebKit2/WebProcess/WebPage/CoordinatedGraphics/LayerTreeCoordinator.cpp @@ -83,7 +83,7 @@ LayerTreeCoordinator::LayerTreeCoordinator(WebPage* webPage) , m_forceRepaintAsyncCallbackID(0) { // Create a root layer. - m_rootLayer = GraphicsLayer::create(this); + m_rootLayer = GraphicsLayer::create(this, this); CoordinatedGraphicsLayer* webRootLayer = toCoordinatedGraphicsLayer(m_rootLayer.get()); webRootLayer->setRootLayer(true); #ifndef NDEBUG @@ -93,7 +93,7 @@ LayerTreeCoordinator::LayerTreeCoordinator(WebPage* webPage) m_rootLayer->setSize(m_webPage->size()); m_layerTreeContext.webLayerID = toCoordinatedGraphicsLayer(webRootLayer)->id(); - m_nonCompositedContentLayer = GraphicsLayer::create(this); + m_nonCompositedContentLayer = GraphicsLayer::create(this, this); toCoordinatedGraphicsLayer(m_rootLayer.get())->setCoordinatedGraphicsLayerClient(this); #ifndef NDEBUG m_nonCompositedContentLayer->setName("LayerTreeCoordinator non-composited content"); @@ -258,12 +258,12 @@ bool LayerTreeCoordinator::flushPendingLayerChanges() m_webPage->send(Messages::LayerTreeCoordinatorProxy::DeleteCompositingLayer(m_detachedLayers[i])); m_detachedLayers.clear(); - bool didSync = m_webPage->corePage()->mainFrame()->view()->syncCompositingStateIncludingSubframes(); - m_nonCompositedContentLayer->syncCompositingStateForThisLayerOnly(); + bool didSync = m_webPage->corePage()->mainFrame()->view()->flushCompositingStateIncludingSubframes(); + m_nonCompositedContentLayer->flushCompositingStateForThisLayerOnly(); if (m_pageOverlayLayer) - m_pageOverlayLayer->syncCompositingStateForThisLayerOnly(); + m_pageOverlayLayer->flushCompositingStateForThisLayerOnly(); - m_rootLayer->syncCompositingStateForThisLayerOnly(); + m_rootLayer->flushCompositingStateForThisLayerOnly(); if (m_shouldSyncRootLayer) { m_webPage->send(Messages::LayerTreeCoordinatorProxy::SetRootCompositingLayer(toCoordinatedGraphicsLayer(m_rootLayer.get())->id())); @@ -272,7 +272,10 @@ bool LayerTreeCoordinator::flushPendingLayerChanges() if (m_shouldSyncFrame) { didSync = true; - m_webPage->send(Messages::LayerTreeCoordinatorProxy::DidRenderFrame()); + + IntSize contentsSize = roundedIntSize(m_nonCompositedContentLayer->size()); + IntRect coveredRect = toCoordinatedGraphicsLayer(m_nonCompositedContentLayer.get())->coverRect(); + m_webPage->send(Messages::LayerTreeCoordinatorProxy::DidRenderFrame(contentsSize, coveredRect)); m_waitingForUIProcess = true; m_shouldSyncFrame = false; } @@ -302,11 +305,13 @@ void LayerTreeCoordinator::syncLayerChildren(WebLayerID id, const Vector<WebLaye m_webPage->send(Messages::LayerTreeCoordinatorProxy::SetCompositingLayerChildren(id, children)); } -void LayerTreeCoordinator::syncCanvas(WebLayerID id, const IntSize& canvasSize, uint64_t graphicsSurfaceToken, uint32_t frontBuffer) +#if USE(GRAPHICS_SURFACE) +void LayerTreeCoordinator::syncCanvas(WebLayerID id, const IntSize& canvasSize, const GraphicsSurfaceToken& token, uint32_t frontBuffer) { m_shouldSyncFrame = true; - m_webPage->send(Messages::LayerTreeCoordinatorProxy::SyncCanvas(id, canvasSize, graphicsSurfaceToken, frontBuffer)); + m_webPage->send(Messages::LayerTreeCoordinatorProxy::SyncCanvas(id, canvasSize, token, frontBuffer)); } +#endif #if ENABLE(CSS_FILTERS) void LayerTreeCoordinator::syncLayerFilters(WebLayerID id, const FilterOperations& filters) @@ -422,7 +427,7 @@ void LayerTreeCoordinator::createPageOverlayLayer() { ASSERT(!m_pageOverlayLayer); - m_pageOverlayLayer = GraphicsLayer::create(this); + m_pageOverlayLayer = GraphicsLayer::create(this, this); #ifndef NDEBUG m_pageOverlayLayer->setName("LayerTreeCoordinator page overlay content"); #endif @@ -448,18 +453,26 @@ int64_t LayerTreeCoordinator::adoptImageBackingStore(Image* image) int64_t key = 0; #if PLATFORM(QT) - QImage* nativeImage = image->nativeImageForCurrentFrame(); + QPixmap* nativeImage = image->nativeImageForCurrentFrame(); if (!nativeImage) return InvalidWebLayerID; key = nativeImage->cacheKey(); +#elif USE(CAIRO) + NativeImageCairo* nativeImage = image->nativeImageForCurrentFrame(); + if (!nativeImage) + return InvalidWebLayerID; + // This can be safely done since we own the reference. + // A corresponding cairo_surface_destroy() is ensured in releaseImageBackingStore(). + cairo_surface_t* cairoSurface = cairo_surface_reference(nativeImage->surface()); + key = reinterpret_cast<int64_t>(cairoSurface); #endif HashMap<int64_t, int>::iterator it = m_directlyCompositedImageRefCounts.find(key); if (it != m_directlyCompositedImageRefCounts.end()) { - ++(it->second); + ++(it->value); return key; } @@ -484,12 +497,17 @@ void LayerTreeCoordinator::releaseImageBackingStore(int64_t key) if (it == m_directlyCompositedImageRefCounts.end()) return; - it->second--; + it->value--; - if (it->second) + if (it->value) return; m_directlyCompositedImageRefCounts.remove(it); +#if USE(CAIRO) + // Complement the referencing in adoptImageBackingStore(). + cairo_surface_t* cairoSurface = reinterpret_cast<cairo_surface_t*>(key); + cairo_surface_destroy(cairoSurface); +#endif m_webPage->send(Messages::LayerTreeCoordinatorProxy::DestroyDirectlyCompositedImage(key)); } @@ -498,7 +516,7 @@ void LayerTreeCoordinator::notifyAnimationStarted(const WebCore::GraphicsLayer*, { } -void LayerTreeCoordinator::notifySyncRequired(const WebCore::GraphicsLayer*) +void LayerTreeCoordinator::notifyFlushRequired(const WebCore::GraphicsLayer*) { } @@ -527,6 +545,11 @@ bool LayerTreeCoordinator::showRepaintCounter(const WebCore::GraphicsLayer*) con return m_webPage->corePage()->settings()->showRepaintCounter(); } +PassOwnPtr<GraphicsLayer> LayerTreeCoordinator::createGraphicsLayer(GraphicsLayerClient* client) +{ + return adoptPtr(new CoordinatedGraphicsLayer(client)); +} + bool LayerTreeHost::supportsAcceleratedCompositing() { return true; @@ -596,6 +619,11 @@ void LayerTreeCoordinator::setVisibleContentsRect(const IntRect& rect, float sca m_shouldSendScrollPositionUpdate = true; } +GraphicsLayerFactory* LayerTreeCoordinator::graphicsLayerFactory() +{ + return this; +} + void LayerTreeCoordinator::scheduleAnimation() { scheduleLayerFlush(); diff --git a/Source/WebKit2/WebProcess/WebPage/CoordinatedGraphics/LayerTreeCoordinator.h b/Source/WebKit2/WebProcess/WebPage/CoordinatedGraphics/LayerTreeCoordinator.h index 6c61bb6b6..dbebd386a 100644 --- a/Source/WebKit2/WebProcess/WebPage/CoordinatedGraphics/LayerTreeCoordinator.h +++ b/Source/WebKit2/WebProcess/WebPage/CoordinatedGraphics/LayerTreeCoordinator.h @@ -28,6 +28,8 @@ #include "Timer.h" #include "UpdateAtlas.h" #include <WebCore/GraphicsLayerClient.h> +#include <WebCore/GraphicsLayerFactory.h> +#include <WebCore/GraphicsSurface.h> #include <wtf/OwnPtr.h> namespace WebKit { @@ -36,7 +38,8 @@ class UpdateInfo; class WebPage; class LayerTreeCoordinator : public LayerTreeHost, WebCore::GraphicsLayerClient - , public CoordinatedGraphicsLayerClient { + , public CoordinatedGraphicsLayerClient + , public WebCore::GraphicsLayerFactory { public: static PassRefPtr<LayerTreeCoordinator> create(WebPage*); virtual ~LayerTreeCoordinator(); @@ -77,6 +80,7 @@ public: virtual bool layerTreeTileUpdatesAllowed() const; virtual void setVisibleContentsRect(const WebCore::IntRect&, float scale, const WebCore::FloatPoint&); virtual void didReceiveLayerTreeCoordinatorMessage(CoreIPC::Connection*, CoreIPC::MessageID, CoreIPC::ArgumentDecoder*); + virtual WebCore::GraphicsLayerFactory* graphicsLayerFactory() OVERRIDE; virtual void syncLayerState(WebLayerID, const WebLayerInfo&); virtual void syncLayerChildren(WebLayerID, const Vector<WebLayerID>&); @@ -85,7 +89,9 @@ public: #if ENABLE(CSS_FILTERS) virtual void syncLayerFilters(WebLayerID, const WebCore::FilterOperations&); #endif - virtual void syncCanvas(WebLayerID, const WebCore::IntSize& canvasSize, uint64_t graphicsSurfaceToken, uint32_t frontBuffer) OVERRIDE; +#if USE(GRAPHICS_SURFACE) + virtual void syncCanvas(WebLayerID, const WebCore::IntSize& canvasSize, const WebCore::GraphicsSurfaceToken&, uint32_t frontBuffer) OVERRIDE; +#endif virtual void attachLayer(WebCore::CoordinatedGraphicsLayer*); virtual void detachLayer(WebCore::CoordinatedGraphicsLayer*); virtual void syncFixedLayers(); @@ -99,11 +105,14 @@ protected: private: // GraphicsLayerClient virtual void notifyAnimationStarted(const WebCore::GraphicsLayer*, double time); - virtual void notifySyncRequired(const WebCore::GraphicsLayer*); + virtual void notifyFlushRequired(const WebCore::GraphicsLayer*); virtual void paintContents(const WebCore::GraphicsLayer*, WebCore::GraphicsContext&, WebCore::GraphicsLayerPaintingPhase, const WebCore::IntRect& clipRect); virtual bool showDebugBorders(const WebCore::GraphicsLayer*) const; virtual bool showRepaintCounter(const WebCore::GraphicsLayer*) const; + // GraphicsLayerFactory + virtual PassOwnPtr<WebCore::GraphicsLayer> createGraphicsLayer(WebCore::GraphicsLayerClient*) OVERRIDE; + // LayerTreeCoordinator void createPageOverlayLayer(); void destroyPageOverlayLayer(); diff --git a/Source/WebKit2/WebProcess/WebPage/DrawingArea.h b/Source/WebKit2/WebProcess/WebPage/DrawingArea.h index 6178e85bb..ca476179e 100644 --- a/Source/WebKit2/WebProcess/WebPage/DrawingArea.h +++ b/Source/WebKit2/WebProcess/WebPage/DrawingArea.h @@ -41,6 +41,7 @@ namespace CoreIPC { namespace WebCore { class GraphicsLayer; + class GraphicsLayerFactory; } namespace WebKit { @@ -87,8 +88,9 @@ public: virtual void updatePreferences(const WebPreferencesStore&) { } #if USE(ACCELERATED_COMPOSITING) + virtual WebCore::GraphicsLayerFactory* graphicsLayerFactory() { return 0; } virtual void setRootCompositingLayer(WebCore::GraphicsLayer*) = 0; - virtual void scheduleCompositingLayerSync() = 0; + virtual void scheduleCompositingLayerFlush() = 0; #endif #if USE(COORDINATED_GRAPHICS) diff --git a/Source/WebKit2/WebProcess/WebPage/DrawingAreaImpl.cpp b/Source/WebKit2/WebProcess/WebPage/DrawingAreaImpl.cpp index 2299bc3ea..d6cef142f 100644 --- a/Source/WebKit2/WebProcess/WebPage/DrawingAreaImpl.cpp +++ b/Source/WebKit2/WebProcess/WebPage/DrawingAreaImpl.cpp @@ -70,7 +70,11 @@ DrawingAreaImpl::DrawingAreaImpl(WebPage* webPage, const WebPageCreationParamete { if (webPage->corePage()->settings()->acceleratedDrawingEnabled() || webPage->corePage()->settings()->forceCompositingMode()) m_alwaysUseCompositing = true; - + +#if USE(COORDINATED_GRAPHICS) + m_alwaysUseCompositing = true; +#endif + if (m_alwaysUseCompositing) enterAcceleratedCompositingMode(0); } @@ -303,6 +307,14 @@ void DrawingAreaImpl::layerHostDidFlushLayers() #endif } +GraphicsLayerFactory* DrawingAreaImpl::graphicsLayerFactory() +{ + if (m_layerTreeHost) + return m_layerTreeHost->graphicsLayerFactory(); + + return 0; +} + void DrawingAreaImpl::setRootCompositingLayer(GraphicsLayer* graphicsLayer) { // FIXME: Instead of using nested if statements, we should keep a compositing state @@ -343,7 +355,7 @@ void DrawingAreaImpl::setRootCompositingLayer(GraphicsLayer* graphicsLayer) } } -void DrawingAreaImpl::scheduleCompositingLayerSync() +void DrawingAreaImpl::scheduleCompositingLayerFlush() { if (!m_layerTreeHost) return; diff --git a/Source/WebKit2/WebProcess/WebPage/DrawingAreaImpl.h b/Source/WebKit2/WebProcess/WebPage/DrawingAreaImpl.h index ffe3112c0..8babe0108 100644 --- a/Source/WebKit2/WebProcess/WebPage/DrawingAreaImpl.h +++ b/Source/WebKit2/WebProcess/WebPage/DrawingAreaImpl.h @@ -68,8 +68,9 @@ private: virtual void setPaintingEnabled(bool); virtual void updatePreferences(const WebPreferencesStore&) OVERRIDE; - virtual void setRootCompositingLayer(WebCore::GraphicsLayer*); - virtual void scheduleCompositingLayerSync(); + virtual WebCore::GraphicsLayerFactory* graphicsLayerFactory() OVERRIDE; + virtual void setRootCompositingLayer(WebCore::GraphicsLayer*) OVERRIDE; + virtual void scheduleCompositingLayerFlush() OVERRIDE; #if PLATFORM(WIN) virtual void scheduleChildWindowGeometryUpdate(const WindowGeometry&); diff --git a/Source/WebKit2/WebProcess/WebPage/LayerTreeHost.h b/Source/WebKit2/WebProcess/WebPage/LayerTreeHost.h index 8d3bb94ac..0e686b66f 100644 --- a/Source/WebKit2/WebProcess/WebPage/LayerTreeHost.h +++ b/Source/WebKit2/WebProcess/WebPage/LayerTreeHost.h @@ -41,6 +41,7 @@ class FloatPoint; class IntRect; class IntSize; class GraphicsLayer; +class GraphicsLayerFactory; #if PLATFORM(WIN) && USE(AVFOUNDATION) struct GraphicsDeviceAdapter; @@ -86,6 +87,8 @@ public: virtual void pauseRendering() { } virtual void resumeRendering() { } + virtual WebCore::GraphicsLayerFactory* graphicsLayerFactory() { return 0; } + #if USE(COORDINATED_GRAPHICS) virtual void setVisibleContentsRect(const WebCore::IntRect&, float scale, const WebCore::FloatPoint&) { } virtual void setVisibleContentsRectForLayer(int layerID, const WebCore::IntRect&) { } diff --git a/Source/WebKit2/WebProcess/WebPage/WebBackForwardListProxy.cpp b/Source/WebKit2/WebProcess/WebPage/WebBackForwardListProxy.cpp index 4ca4e5fdb..be82a197a 100644 --- a/Source/WebKit2/WebProcess/WebPage/WebBackForwardListProxy.cpp +++ b/Source/WebKit2/WebProcess/WebPage/WebBackForwardListProxy.cpp @@ -130,9 +130,9 @@ void WebBackForwardListProxy::removeItem(uint64_t itemID) if (it == idToHistoryItemMap().end()) return; - WebCore::pageCache()->remove(it->second.get()); + WebCore::pageCache()->remove(it->value.get()); - historyItemToIDMap().remove(it->second); + historyItemToIDMap().remove(it->value); idToHistoryItemMap().remove(it); } diff --git a/Source/WebKit2/WebProcess/WebPage/WebFrame.cpp b/Source/WebKit2/WebProcess/WebPage/WebFrame.cpp index d04f4db7f..8ae9ef028 100644 --- a/Source/WebKit2/WebProcess/WebPage/WebFrame.cpp +++ b/Source/WebKit2/WebProcess/WebPage/WebFrame.cpp @@ -54,6 +54,7 @@ #include <WebCore/JSRange.h> #include <WebCore/Page.h> #include <WebCore/RenderTreeAsText.h> +#include <WebCore/ResourceBuffer.h> #include <WebCore/SecurityOrigin.h> #include <WebCore/TextIterator.h> #include <WebCore/TextResourceDecoder.h> @@ -296,7 +297,7 @@ String WebFrame::source() const DocumentLoader* documentLoader = m_coreFrame->loader()->activeDocumentLoader(); if (!documentLoader) return String(); - RefPtr<SharedBuffer> mainResourceData = documentLoader->mainResourceData(); + RefPtr<ResourceBuffer> mainResourceData = documentLoader->mainResourceData(); if (!mainResourceData) return String(); return decoder->encoding().decode(mainResourceData->data(), mainResourceData->size()); @@ -513,7 +514,7 @@ String WebFrame::layerTreeAsText() const if (!m_coreFrame) return ""; - return m_coreFrame->layerTreeAsText(); + return m_coreFrame->layerTreeAsText(0); } unsigned WebFrame::pendingUnloadCount() const diff --git a/Source/WebKit2/WebProcess/WebPage/WebPage.cpp b/Source/WebKit2/WebProcess/WebPage/WebPage.cpp index 61e82b5d9..e82e65c06 100644 --- a/Source/WebKit2/WebProcess/WebPage/WebPage.cpp +++ b/Source/WebKit2/WebProcess/WebPage/WebPage.cpp @@ -1,5 +1,5 @@ /* - * Copyright (C) 2010, 2011 Apple Inc. All rights reserved. + * Copyright (C) 2010, 2011, 2012 Apple Inc. All rights reserved. * Copyright (C) 2012 Intel Corporation. All rights reserved. * * Redistribution and use in source and binary forms, with or without @@ -33,6 +33,7 @@ #include "DrawingArea.h" #include "InjectedBundle.h" #include "InjectedBundleBackForwardList.h" +#include "InjectedBundleUserMessageCoders.h" #include "LayerTreeHost.h" #include "MessageID.h" #include "NetscapePlugin.h" @@ -104,7 +105,9 @@ #include <WebCore/RenderLayer.h> #include <WebCore/RenderTreeAsText.h> #include <WebCore/RenderView.h> +#include <WebCore/ResourceBuffer.h> #include <WebCore/ResourceRequest.h> +#include <WebCore/ResourceResponse.h> #include <WebCore/RunLoop.h> #include <WebCore/SchemeRegistry.h> #include <WebCore/ScriptValue.h> @@ -148,7 +151,10 @@ #endif #if PLATFORM(MAC) -#include "BuiltInPDFView.h" +#include "SimplePDFPlugin.h" +#if ENABLE(PDFKIT_PLUGIN) +#include "PDFPlugin.h" +#endif #endif #if PLATFORM(QT) @@ -217,6 +223,7 @@ WebPage::WebPage(uint64_t pageID, const WebPageCreationParameters& parameters) , m_artificialPluginInitializationDelayEnabled(false) , m_scrollingPerformanceLoggingEnabled(false) #if PLATFORM(MAC) + , m_pdfPluginEnabled(false) , m_windowIsVisible(false) , m_isSmartInsertDeleteEnabled(parameters.isSmartInsertDeleteEnabled) , m_layerHostingMode(parameters.layerHostingMode) @@ -245,6 +252,8 @@ WebPage::WebPage(uint64_t pageID, const WebPageCreationParameters& parameters) , m_isRunningModal(false) , m_cachedMainFrameIsPinnedToLeftSide(false) , m_cachedMainFrameIsPinnedToRightSide(false) + , m_cachedMainFrameIsPinnedToTopSide(false) + , m_cachedMainFrameIsPinnedToBottomSide(false) , m_canShortCircuitHorizontalWheelEvents(false) , m_numWheelEventHandlers(0) , m_cachedPageCount(0) @@ -464,8 +473,13 @@ PassRefPtr<Plugin> WebPage::createPlugin(WebFrame* frame, HTMLPlugInElement* plu if (pluginPath.isNull()) { #if PLATFORM(MAC) if (parameters.mimeType == "application/pdf" - || (parameters.mimeType.isEmpty() && parameters.url.path().lower().endsWith(".pdf"))) - return BuiltInPDFView::create(frame); + || (parameters.mimeType.isEmpty() && parameters.url.path().lower().endsWith(".pdf"))) { +#if ENABLE(PDFKIT_PLUGIN) + if (pdfPluginEnabled()) + return PDFPlugin::create(frame); +#endif + return SimplePDFPlugin::create(frame); + } #else UNUSED_PARAM(frame); #endif @@ -616,11 +630,27 @@ PassRefPtr<ImmutableArray> WebPage::trackedRepaintRects() return ImmutableArray::adopt(vector); } +static PluginView* pluginViewForFrame(Frame* frame) +{ + if (!frame->document()->isPluginDocument()) + return 0; + + PluginDocument* pluginDocument = static_cast<PluginDocument*>(frame->document()); + PluginView* pluginView = static_cast<PluginView*>(pluginDocument->pluginWidget()); + return pluginView; +} + void WebPage::executeEditingCommand(const String& commandName, const String& argument) { Frame* frame = m_page->focusController()->focusedOrMainFrame(); if (!frame) return; + + if (PluginView* pluginView = pluginViewForFrame(frame)) { + pluginView->handleEditingCommand(commandName, argument); + return; + } + frame->editor()->command(commandName).execute(argument); } @@ -629,6 +659,9 @@ bool WebPage::isEditingCommandEnabled(const String& commandName) Frame* frame = m_page->focusController()->focusedOrMainFrame(); if (!frame) return false; + + if (PluginView* pluginView = pluginViewForFrame(frame)) + return pluginView->isEditingCommandEnabled(commandName); Editor::Command command = frame->editor()->command(commandName); return command.isSupported() && command.isEnabled(); @@ -1069,6 +1102,12 @@ void WebPage::windowScreenDidChange(uint64_t displayID) void WebPage::scalePage(double scale, const IntPoint& origin) { + PluginView* pluginView = pluginViewForFrame(m_page->mainFrame()); + if (pluginView && pluginView->handlesPageScaleFactor()) { + pluginView->setPageScaleFactor(scale, origin); + return; + } + m_page->setPageScaleFactor(scale, origin); for (HashSet<PluginView*>::const_iterator it = m_pluginViews.begin(), end = m_pluginViews.end(); it != end; ++it) @@ -1079,6 +1118,10 @@ void WebPage::scalePage(double scale, const IntPoint& origin) double WebPage::pageScaleFactor() const { + PluginView* pluginView = pluginViewForFrame(m_page->mainFrame()); + if (pluginView && pluginView->handlesPageScaleFactor()) + return pluginView->pageScaleFactor(); + return m_page->pageScaleFactor(); } @@ -1172,6 +1215,19 @@ void WebPage::setGapBetweenPages(double gap) m_page->setPagination(pagination); } +void WebPage::postInjectedBundleMessage(const String& messageName, CoreIPC::ArgumentDecoder* argumentDecoder) +{ + InjectedBundle* injectedBundle = WebProcess::shared().injectedBundle(); + if (!injectedBundle) + return; + + RefPtr<APIObject> messageBody; + if (!argumentDecoder->decode(InjectedBundleUserMessageDecoder(messageBody))) + return; + + injectedBundle->didReceiveMessageToPage(this, messageName, messageBody.get()); +} + void WebPage::installPageOverlay(PassRefPtr<PageOverlay> pageOverlay) { bool shouldFadeIn = true; @@ -1257,6 +1313,12 @@ PassRefPtr<WebImage> WebPage::scaledSnapshotWithOptions(const IntRect& rect, dou frameView->paintContentsForSnapshot(graphicsContext.get(), rect, shouldPaintSelection, coordinateSpace); + if (options & SnapshotOptionsPaintSelectionRectangle) { + FloatRect selectionRectangle = m_mainFrame->coreFrame()->selection()->bounds(); + graphicsContext->setStrokeColor(Color(0xFF, 0, 0), ColorSpaceDeviceRGB); + graphicsContext->strokeRect(selectionRectangle, 1); + } + return snapshot.release(); } @@ -1364,21 +1426,11 @@ static bool handleMouseEvent(const WebMouseEvent& mouseEvent, WebPage* page, boo if (isContextClick(platformMouseEvent)) handled = handleContextMenuEvent(platformMouseEvent, page); #endif -#if PLATFORM(GTK) - bool gtkMouseButtonPressHandled = page->handleMousePressedEvent(platformMouseEvent); - handled = handled || gtkMouseButtonPressHandled; -#endif - - return handled; - } - case PlatformEvent::MouseReleased: { - bool handled = frame->eventHandler()->handleMouseReleaseEvent(platformMouseEvent); -#if PLATFORM(QT) - if (!handled) - handled = page->handleMouseReleaseEvent(platformMouseEvent); -#endif return handled; } + case PlatformEvent::MouseReleased: + return frame->eventHandler()->handleMouseReleaseEvent(platformMouseEvent); + case PlatformEvent::MouseMoved: if (onlyUpdateScrollbars) return frame->eventHandler()->passMouseMovedEventToScrollbars(platformMouseEvent); @@ -1520,9 +1572,13 @@ void WebPage::validateCommand(const String& commandName, uint64_t callbackID) int32_t state = 0; Frame* frame = m_page->focusController()->focusedOrMainFrame(); if (frame) { - Editor::Command command = frame->editor()->command(commandName); - state = command.state(); - isEnabled = command.isSupported() && command.isEnabled(); + if (PluginView* pluginView = pluginViewForFrame(frame)) + isEnabled = pluginView->isEditingCommandEnabled(commandName); + else { + Editor::Command command = frame->editor()->command(commandName); + state = command.state(); + isEnabled = command.isSupported() && command.isEnabled(); + } } send(Messages::WebPageProxy::ValidateCommandCallback(commandName, isEnabled, state, callbackID)); @@ -1790,6 +1846,22 @@ void WebPage::didReceivePolicyDecision(uint64_t frameID, uint64_t listenerID, ui frame->didReceivePolicyDecision(listenerID, static_cast<PolicyAction>(policyAction), downloadID); } +void WebPage::didStartPageTransition() +{ + m_drawingArea->setLayerTreeStateIsFrozen(true); +} + +void WebPage::didCompletePageTransition() +{ +#if PLATFORM(QT) + if (m_mainFrame->coreFrame()->view()->delegatesScrolling()) + // Wait until the UI process sent us the visible rect it wants rendered. + send(Messages::WebPageProxy::PageTransitionViewportReady()); + else +#endif + m_drawingArea->setLayerTreeStateIsFrozen(false); +} + void WebPage::show() { send(Messages::WebPageProxy::ShowPage()); @@ -1916,7 +1988,7 @@ void WebPage::getMainResourceDataOfFrame(uint64_t frameID, uint64_t callbackID) { CoreIPC::DataReference dataReference; - RefPtr<SharedBuffer> buffer; + RefPtr<ResourceBuffer> buffer; if (WebFrame* frame = WebProcess::shared().webFrame(frameID)) { if (DocumentLoader* loader = frame->coreFrame()->loader()->documentLoader()) { if ((buffer = loader->mainResourceData())) @@ -2025,6 +2097,10 @@ void WebPage::updatePreferences(const WebPreferencesStore& store) m_scrollingPerformanceLoggingEnabled = store.getBoolValueForKey(WebPreferencesKey::scrollingPerformanceLoggingEnabledKey()); +#if PLATFORM(MAC) + m_pdfPluginEnabled = store.getBoolValueForKey(WebPreferencesKey::pdfPluginEnabledKey()); +#endif + // FIXME: This should be generated from macro expansion for all preferences, // but we currently don't match the naming of WebCore exactly so we are // handrolling the boolean and integer preferences until that is fixed. @@ -2139,11 +2215,14 @@ void WebPage::updatePreferences(const WebPreferencesStore& store) settings->setShouldRespectImageOrientation(store.getBoolValueForKey(WebPreferencesKey::shouldRespectImageOrientationKey())); settings->setStorageBlockingPolicy(static_cast<SecurityOrigin::StorageBlockingPolicy>(store.getUInt32ValueForKey(WebPreferencesKey::storageBlockingPolicyKey()))); + settings->setCookieEnabled(store.getBoolValueForKey(WebPreferencesKey::cookieEnabledKey())); settings->setDiagnosticLoggingEnabled(store.getBoolValueForKey(WebPreferencesKey::diagnosticLoggingEnabledKey())); settings->setScrollingPerformanceLoggingEnabled(m_scrollingPerformanceLoggingEnabled); + settings->setPlugInSnapshottingEnabled(store.getBoolValueForKey(WebPreferencesKey::plugInSnapshottingEnabledKey())); + platformPreferencesDidChange(store); if (m_drawingArea) @@ -2610,12 +2689,16 @@ void WebPage::didChangeScrollOffsetForMainFrame() bool isPinnedToLeftSide = (scrollPosition.x() <= minimumScrollPosition.x()); bool isPinnedToRightSide = (scrollPosition.x() >= maximumScrollPosition.x()); + bool isPinnedToTopSide = (scrollPosition.y() <= minimumScrollPosition.y()); + bool isPinnedToBottomSide = (scrollPosition.y() >= maximumScrollPosition.y()); - if (isPinnedToLeftSide != m_cachedMainFrameIsPinnedToLeftSide || isPinnedToRightSide != m_cachedMainFrameIsPinnedToRightSide) { - send(Messages::WebPageProxy::DidChangeScrollOffsetPinningForMainFrame(isPinnedToLeftSide, isPinnedToRightSide)); + if (isPinnedToLeftSide != m_cachedMainFrameIsPinnedToLeftSide || isPinnedToRightSide != m_cachedMainFrameIsPinnedToRightSide || isPinnedToTopSide != m_cachedMainFrameIsPinnedToTopSide || isPinnedToBottomSide != m_cachedMainFrameIsPinnedToBottomSide) { + send(Messages::WebPageProxy::DidChangeScrollOffsetPinningForMainFrame(isPinnedToLeftSide, isPinnedToRightSide, isPinnedToTopSide, isPinnedToBottomSide)); m_cachedMainFrameIsPinnedToLeftSide = isPinnedToLeftSide; m_cachedMainFrameIsPinnedToRightSide = isPinnedToRightSide; + m_cachedMainFrameIsPinnedToTopSide = isPinnedToTopSide; + m_cachedMainFrameIsPinnedToBottomSide = isPinnedToBottomSide; } } @@ -3178,6 +3261,13 @@ bool WebPage::canHandleRequest(const WebCore::ResourceRequest& request) return platformCanHandleRequest(request); } +#if USE(TILED_BACKING_STORE) +void WebPage::commitPageTransitionViewport() +{ + m_drawingArea->setLayerTreeStateIsFrozen(false); +} +#endif + #if PLATFORM(MAC) && __MAC_OS_X_VERSION_MIN_REQUIRED >= 1070 void WebPage::handleAlternativeTextUIResult(const String& result) { @@ -3307,7 +3397,7 @@ FrameView* WebPage::mainFrameView() const return 0; } -#if ENABLE(PAGE_VISIBILITY_API) +#if ENABLE(PAGE_VISIBILITY_API) || ENABLE(HIDDEN_PAGE_DOM_TIMER_THROTTLING) void WebPage::setVisibilityState(int visibilityState, bool isInitialState) { if (!m_page) @@ -3315,6 +3405,7 @@ void WebPage::setVisibilityState(int visibilityState, bool isInitialState) WebCore::PageVisibilityState state = static_cast<WebCore::PageVisibilityState>(visibilityState); +#if ENABLE(PAGE_VISIBILITY_API) if (m_visibilityState == state) return; @@ -3334,6 +3425,11 @@ void WebPage::setVisibilityState(int visibilityState, bool isInitialState) if (view) view->hide(); } +#endif + +#if ENABLE(HIDDEN_PAGE_DOM_TIMER_THROTTLING) && !ENABLE(PAGE_VISIBILITY_API) + m_page->setVisibilityState(state, isInitialState); +#endif } #endif @@ -3348,4 +3444,24 @@ void WebPage::setScrollingPerformanceLoggingEnabled(bool enabled) frameView->setScrollingPerformanceLoggingEnabled(enabled); } +static bool canPluginHandleResponse(const ResourceResponse& response) +{ + String pluginPath; + bool blocked; + + if (!WebProcess::shared().connection()->sendSync(Messages::WebProcessProxy::GetPluginPath(response.mimeType(), response.url().string()), Messages::WebProcessProxy::GetPluginPath::Reply(pluginPath, blocked), 0)) + return false; + + return !blocked && !pluginPath.isEmpty(); +} + +bool WebPage::shouldUseCustomRepresentationForResponse(const ResourceResponse& response) const +{ + if (!m_mimeTypesWithCustomRepresentations.contains(response.mimeType())) + return false; + + // If a plug-in exists that claims to support this response, it should take precedence over the custom representation. + return !canPluginHandleResponse(response); +} + } // namespace WebKit diff --git a/Source/WebKit2/WebProcess/WebPage/WebPage.h b/Source/WebKit2/WebProcess/WebPage/WebPage.h index fadd3bd7f..0a5f2bbb7 100644 --- a/Source/WebKit2/WebProcess/WebPage/WebPage.h +++ b/Source/WebKit2/WebProcess/WebPage/WebPage.h @@ -113,6 +113,7 @@ namespace WebCore { class Page; class PrintContext; class Range; + class ResourceResponse; class ResourceRequest; class SharedBuffer; class VisibleSelection; @@ -213,6 +214,8 @@ public: bool handleEditingKeyboardEvent(WebCore::KeyboardEvent*); #endif + void didStartPageTransition(); + void didCompletePageTransition(); void show(); String userAgent() const { return m_userAgent; } WebCore::IntRect windowResizerRect() const; @@ -317,6 +320,8 @@ public: void setPageLength(double); void setGapBetweenPages(double); + void postInjectedBundleMessage(const String& messageName, CoreIPC::ArgumentDecoder*); + bool drawsBackground() const { return m_drawsBackground; } bool drawsTransparentBackground() const { return m_drawsTransparentBackground; } @@ -415,6 +420,10 @@ public: void setThemePath(const String&); #endif +#if USE(TILED_BACKING_STORE) + void commitPageTransitionViewport(); +#endif + #if PLATFORM(QT) void setComposition(const String& text, Vector<WebCore::CompositionUnderline> underlines, uint64_t selectionStart, uint64_t selectionEnd, uint64_t replacementRangeStart, uint64_t replacementRangeEnd); void confirmComposition(const String& text, int64_t selectionStart, int64_t selectionLength); @@ -457,17 +466,11 @@ public: #elif PLATFORM(GTK) void updateAccessibilityTree(); - bool handleMousePressedEvent(const WebCore::PlatformMouseEvent&); #if USE(TEXTURE_MAPPER_GL) void setAcceleratedCompositingWindowId(int64_t nativeWindowHandle); - void invalidateWidget(); #endif #endif -#if PLATFORM(QT) - bool handleMouseReleaseEvent(const WebCore::PlatformMouseEvent&); -#endif - void setCompositionForTesting(const String& compositionString, uint64_t from, uint64_t length); bool hasCompositionForTesting(); void confirmCompositionForTesting(const String& compositionString); @@ -571,7 +574,7 @@ public: bool willGoToBackForwardItemCallbackEnabled() const { return m_willGoToBackForwardItemCallbackEnabled; } -#if ENABLE(PAGE_VISIBILITY_API) +#if ENABLE(PAGE_VISIBILITY_API) || ENABLE(HIDDEN_PAGE_DOM_TIMER_THROTTLING) void setVisibilityState(int visibilityState, bool isInitialState); #endif @@ -579,6 +582,8 @@ public: uint64_t nativeWindowHandle() { return m_nativeWindowHandle; } #endif + bool shouldUseCustomRepresentationForResponse(const WebCore::ResourceResponse&) const; + bool asynchronousPluginInitializationEnabled() const { return m_asynchronousPluginInitializationEnabled; } void setAsynchronousPluginInitializationEnabled(bool enabled) { m_asynchronousPluginInitializationEnabled = enabled; } bool asynchronousPluginInitializationEnabledForAllPlugins() const { return m_asynchronousPluginInitializationEnabledForAllPlugins; } @@ -591,6 +596,15 @@ public: bool scrollingPerformanceLoggingEnabled() const { return m_scrollingPerformanceLoggingEnabled; } void setScrollingPerformanceLoggingEnabled(bool); +#if PLATFORM(MAC) + bool pdfPluginEnabled() const { return m_pdfPluginEnabled; } + void setPDFPluginEnabled(bool enabled) { m_pdfPluginEnabled = enabled; } +#endif + +#if PLATFORM(MAC) + static HashSet<String, CaseFoldingHash> pdfAndPostScriptMIMETypes(); +#endif + private: WebPage(uint64_t pageID, const WebPageCreationParameters&); @@ -794,6 +808,8 @@ private: bool m_scrollingPerformanceLoggingEnabled; #if PLATFORM(MAC) + bool m_pdfPluginEnabled; + // Whether the containing window is visible or not. bool m_windowIsVisible; @@ -822,7 +838,7 @@ private: RefPtr<WebCore::Node> m_gestureTargetNode; #elif PLATFORM(GTK) - WebPageAccessibilityObject* m_accessibilityObject; + GRefPtr<WebPageAccessibilityObject> m_accessibilityObject; #if USE(TEXTURE_MAPPER_GL) // Our view's window in the UI process. @@ -900,6 +916,8 @@ private: bool m_cachedMainFrameIsPinnedToLeftSide; bool m_cachedMainFrameIsPinnedToRightSide; + bool m_cachedMainFrameIsPinnedToTopSide; + bool m_cachedMainFrameIsPinnedToBottomSide; bool m_canShortCircuitHorizontalWheelEvents; unsigned m_numWheelEventHandlers; @@ -921,6 +939,8 @@ private: WebCore::PageVisibilityState m_visibilityState; #endif WebInspectorClient* m_inspectorClient; + + HashSet<String, CaseFoldingHash> m_mimeTypesWithCustomRepresentations; }; } // namespace WebKit diff --git a/Source/WebKit2/WebProcess/WebPage/WebPage.messages.in b/Source/WebKit2/WebProcess/WebPage/WebPage.messages.in index f113fc24e..e891890ac 100644 --- a/Source/WebKit2/WebProcess/WebPage/WebPage.messages.in +++ b/Source/WebKit2/WebProcess/WebPage/WebPage.messages.in @@ -46,8 +46,8 @@ messages -> WebPage { #endif #if ENABLE(INPUT_TYPE_COLOR) - DidEndColorChooser(); - DidChooseColor(WebCore::Color color); + DidEndColorChooser() + DidChooseColor(WebCore::Color color) #endif #if ENABLE(CONTEXT_MENUS) @@ -62,7 +62,7 @@ messages -> WebPage { GoToBackForwardItem(uint64_t backForwardItemID) TryRestoreScrollPosition() LoadHTMLString(WTF::String htmlString, WTF::String baseURL) - LoadAlternateHTMLString(WTF::String htmlString, WTF::String baseURL, WTF::String unreachableURL); + LoadAlternateHTMLString(WTF::String htmlString, WTF::String baseURL, WTF::String unreachableURL) LoadPlainTextString(WTF::String string) LoadWebArchiveData(CoreIPC::DataReference webArchiveData) LoadURL(WTF::String url, WebKit::SandboxExtension::Handle sandboxExtensionHandle) @@ -142,10 +142,12 @@ messages -> WebPage { ListenForLayoutMilestones(uint32_t milestones) SetSuppressScrollbarAnimations(bool suppressAnimations) - SetPaginationMode(uint32_t mode); - SetPaginationBehavesLikeColumns(bool behavesLikeColumns); - SetPageLength(double pageLength); - SetGapBetweenPages(double gap); + SetPaginationMode(uint32_t mode) + SetPaginationBehavesLikeColumns(bool behavesLikeColumns) + SetPageLength(double pageLength) + SetGapBetweenPages(double gap) + + PostInjectedBundleMessage(WTF::String messageName, WebKit::WebContextUserMessageEncoder messageBody) Variadic # Find. FindString(WTF::String string, uint32_t findOptions, unsigned maxMatchCount) @@ -167,19 +169,19 @@ messages -> WebPage { #endif # Popup menu. - DidChangeSelectedIndexForActivePopupMenu(int32_t newIndex); - SetTextForActivePopupMenu(int32_t index); -#if PLATFORM(GTK) - FailedToShowPopupMenu(); + DidChangeSelectedIndexForActivePopupMenu(int32_t newIndex) + SetTextForActivePopupMenu(int32_t index) +#if PLATFORM(GTK) + FailedToShowPopupMenu() #endif #if PLATFORM(QT) - HidePopupMenu(); - SelectedIndex(int32_t newIndex); + HidePopupMenu() + SelectedIndex(int32_t newIndex) #endif #if ENABLE(CONTEXT_MENUS) # Context menu. - DidSelectItemFromActiveContextMenu(WebKit::WebContextMenuItemData menuItem); + DidSelectItemFromActiveContextMenu(WebKit::WebContextMenuItemData menuItem) #endif # Open panel. @@ -193,11 +195,11 @@ messages -> WebPage { AdvanceToNextMisspelling(bool startBeforeSelection) ChangeSpellingToWord(WTF::String word) #if USE(APPKIT) - UppercaseWord(); - LowercaseWord(); - CapitalizeWord(); + UppercaseWord() + LowercaseWord() + CapitalizeWord() - SetSmartInsertDeleteEnabled(bool isSmartInsertDeleteEnabled); + SetSmartInsertDeleteEnabled(bool isSmartInsertDeleteEnabled) #endif #if ENABLE(GEOLOCATION) @@ -212,7 +214,7 @@ messages -> WebPage { # Printing. BeginPrinting(uint64_t frameID, WebKit::PrintInfo printInfo) - EndPrinting(); + EndPrinting() ComputePagesForPrinting(uint64_t frameID, WebKit::PrintInfo printInfo, uint64_t callbackID) #if PLATFORM(MAC) || PLATFORM(WIN) DrawRectToPDF(uint64_t frameID, WebKit::PrintInfo printInfo, WebCore::IntRect rect, uint64_t callbackID) @@ -236,13 +238,17 @@ messages -> WebPage { # Web Intents #if ENABLE(WEB_INTENTS) - DeliverIntentToFrame(uint64_t frameID, WebKit::IntentData intentData); + DeliverIntentToFrame(uint64_t frameID, WebKit::IntentData intentData) #endif #if PLATFORM(EFL) SetThemePath(WTF::String themePath) #endif +#if USE(TILED_BACKING_STORE) + CommitPageTransitionViewport() +#endif + #if PLATFORM(QT) SetComposition(WTF::String text, WTF::Vector<WebCore::CompositionUnderline> underlines, uint64_t selectionStart, uint64_t selectionEnd, uint64_t replacementRangeStart, uint64_t replacementRangeEnd) ConfirmComposition(WTF::String text, int64_t selectionStart, int64_t selectionLength) @@ -294,8 +300,8 @@ messages -> WebPage { HandleAlternativeTextUIResult(String result) #endif -#if ENABLE(PAGE_VISIBILITY_API) - SetVisibilityState(int visibilityState, bool isInitialState); +#if ENABLE(PAGE_VISIBILITY_API) || ENABLE(HIDDEN_PAGE_DOM_TIMER_THROTTLING) + SetVisibilityState(int visibilityState, bool isInitialState) #endif #if PLATFORM(GTK) && USE(TEXTURE_MAPPER_GL) diff --git a/Source/WebKit2/WebProcess/WebPage/WebPageGroupProxy.cpp b/Source/WebKit2/WebProcess/WebPage/WebPageGroupProxy.cpp index 3bd20c8a6..f59fbbaf5 100644 --- a/Source/WebKit2/WebProcess/WebPage/WebPageGroupProxy.cpp +++ b/Source/WebKit2/WebProcess/WebPage/WebPageGroupProxy.cpp @@ -28,6 +28,8 @@ #include "WebProcess.h" #include "InjectedBundle.h" +#include <WebCore/DOMWrapperWorld.h> +#include <WebCore/PageGroup.h> namespace WebKit { @@ -44,5 +46,45 @@ PassRefPtr<WebPageGroupProxy> WebPageGroupProxy::create(const WebPageGroupData& WebPageGroupProxy::~WebPageGroupProxy() { } + +void WebPageGroupProxy::didReceiveMessage(CoreIPC::Connection* connection, CoreIPC::MessageID messageID, CoreIPC::ArgumentDecoder* arguments) +{ + didReceiveWebPageGroupProxyMessage(connection, messageID, arguments); +} + +WebPageGroupProxy::WebPageGroupProxy(const WebPageGroupData& data) + : m_data(data) + , m_pageGroup(WebCore::PageGroup::pageGroup(m_data.identifer)) +{ + for (size_t i = 0; i < data.userStyleSheets.size(); ++i) + addUserStyleSheet(data.userStyleSheets[i]); + for (size_t i = 0; i < data.userScripts.size(); ++i) + addUserScript(data.userScripts[i]); +} + +void WebPageGroupProxy::addUserStyleSheet(const WebCore::UserStyleSheet& userStyleSheet) +{ + m_pageGroup->addUserStyleSheetToWorld(WebCore::mainThreadNormalWorld(), userStyleSheet.source(), userStyleSheet.url(), userStyleSheet.whitelist(), userStyleSheet.blacklist(), userStyleSheet.injectedFrames(), userStyleSheet.level()); +} + +void WebPageGroupProxy::addUserScript(const WebCore::UserScript& userScript) +{ + m_pageGroup->addUserScriptToWorld(WebCore::mainThreadNormalWorld(), userScript.source(), userScript.url(), userScript.whitelist(), userScript.blacklist(), userScript.injectionTime(), userScript.injectedFrames()); +} + +void WebPageGroupProxy::removeAllUserStyleSheets() +{ + m_pageGroup->removeUserStyleSheetsFromWorld(WebCore::mainThreadNormalWorld()); +} + +void WebPageGroupProxy::removeAllUserScripts() +{ + m_pageGroup->removeUserScriptsFromWorld(WebCore::mainThreadNormalWorld()); +} + +void WebPageGroupProxy::removeAllUserContent() +{ + m_pageGroup->removeAllUserContent(); +} } // namespace WebKit diff --git a/Source/WebKit2/WebProcess/WebPage/WebPageGroupProxy.h b/Source/WebKit2/WebProcess/WebPage/WebPageGroupProxy.h index 91e6c5cfd..cbb079421 100644 --- a/Source/WebKit2/WebProcess/WebPage/WebPageGroupProxy.h +++ b/Source/WebKit2/WebProcess/WebPage/WebPageGroupProxy.h @@ -30,6 +30,16 @@ #include "WebPageGroupData.h" #include <wtf/PassRefPtr.h> +namespace CoreIPC { +class ArgumentDecoder; +class Connection; +class MessageID; +} + +namespace WebCore { +class PageGroup; +} + namespace WebKit { class WebPageGroupProxy : public APIObject { @@ -43,16 +53,24 @@ public: uint64_t pageGroupID() const { return m_data.pageGroupID; } bool isVisibleToInjectedBundle() const { return m_data.visibleToInjectedBundle; } bool isVisibleToHistoryClient() const { return m_data.visibleToHistoryClient; } + + void didReceiveMessage(CoreIPC::Connection*, CoreIPC::MessageID, CoreIPC::ArgumentDecoder*); private: - WebPageGroupProxy(const WebPageGroupData& data) - : m_data(data) - { - } + WebPageGroupProxy(const WebPageGroupData&); virtual Type type() const { return APIType; } + + void didReceiveWebPageGroupProxyMessage(CoreIPC::Connection*, CoreIPC::MessageID, CoreIPC::ArgumentDecoder*); + + void addUserStyleSheet(const WebCore::UserStyleSheet&); + void addUserScript(const WebCore::UserScript&); + void removeAllUserStyleSheets(); + void removeAllUserScripts(); + void removeAllUserContent(); WebPageGroupData m_data; + WebCore::PageGroup* m_pageGroup; }; } // namespace WebKit diff --git a/Source/WebKit2/WebProcess/WebPage/WebPageGroupProxy.messages.in b/Source/WebKit2/WebProcess/WebPage/WebPageGroupProxy.messages.in new file mode 100644 index 000000000..8ba527a3d --- /dev/null +++ b/Source/WebKit2/WebProcess/WebPage/WebPageGroupProxy.messages.in @@ -0,0 +1,29 @@ +# 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. + +messages -> WebPageGroupProxy { + AddUserStyleSheet(WebCore::UserStyleSheet userStyleSheet); + AddUserScript(WebCore::UserScript userScript); + RemoveAllUserStyleSheets(); + RemoveAllUserScripts(); + RemoveAllUserContent(); +} diff --git a/Source/WebKit2/WebProcess/WebPage/ca/LayerTreeHostCA.cpp b/Source/WebKit2/WebProcess/WebPage/ca/LayerTreeHostCA.cpp index de3a2e38e..0872f4355 100644 --- a/Source/WebKit2/WebProcess/WebPage/ca/LayerTreeHostCA.cpp +++ b/Source/WebKit2/WebProcess/WebPage/ca/LayerTreeHostCA.cpp @@ -51,7 +51,7 @@ LayerTreeHostCA::LayerTreeHostCA(WebPage* webPage) void LayerTreeHostCA::initialize() { // Create a root layer. - m_rootLayer = GraphicsLayer::create(this); + m_rootLayer = GraphicsLayer::create(graphicsLayerFactory(), this); #ifndef NDEBUG m_rootLayer->setName("LayerTreeHost root layer"); #endif @@ -59,7 +59,7 @@ void LayerTreeHostCA::initialize() m_rootLayer->setSize(m_webPage->size()); static_cast<GraphicsLayerCA*>(m_rootLayer.get())->platformCALayer()->setGeometryFlipped(true); - m_nonCompositedContentLayer = GraphicsLayer::create(this); + m_nonCompositedContentLayer = GraphicsLayer::create(graphicsLayerFactory(), this); static_cast<GraphicsLayerCA*>(m_nonCompositedContentLayer.get())->setAllowTiledLayer(false); #ifndef NDEBUG m_nonCompositedContentLayer->setName("LayerTreeHost non-composited content"); @@ -186,7 +186,7 @@ void LayerTreeHostCA::notifyAnimationStarted(const WebCore::GraphicsLayer*, doub { } -void LayerTreeHostCA::notifySyncRequired(const WebCore::GraphicsLayer*) +void LayerTreeHostCA::notifyFlushRequired(const WebCore::GraphicsLayer*) { } @@ -245,19 +245,19 @@ void LayerTreeHostCA::didPerformScheduledLayerFlush() bool LayerTreeHostCA::flushPendingLayerChanges() { - m_rootLayer->syncCompositingStateForThisLayerOnly(); - m_nonCompositedContentLayer->syncCompositingStateForThisLayerOnly(); + m_rootLayer->flushCompositingStateForThisLayerOnly(); + m_nonCompositedContentLayer->flushCompositingStateForThisLayerOnly(); if (m_pageOverlayLayer) - m_pageOverlayLayer->syncCompositingStateForThisLayerOnly(); + m_pageOverlayLayer->flushCompositingStateForThisLayerOnly(); - return m_webPage->corePage()->mainFrame()->view()->syncCompositingStateIncludingSubframes(); + return m_webPage->corePage()->mainFrame()->view()->flushCompositingStateIncludingSubframes(); } void LayerTreeHostCA::createPageOverlayLayer() { ASSERT(!m_pageOverlayLayer); - m_pageOverlayLayer = GraphicsLayer::create(this); + m_pageOverlayLayer = GraphicsLayer::create(graphicsLayerFactory(), this); #ifndef NDEBUG m_pageOverlayLayer->setName("LayerTreeHost page overlay content"); #endif diff --git a/Source/WebKit2/WebProcess/WebPage/ca/LayerTreeHostCA.h b/Source/WebKit2/WebProcess/WebPage/ca/LayerTreeHostCA.h index 92ae72674..9cb8ca6a5 100644 --- a/Source/WebKit2/WebProcess/WebPage/ca/LayerTreeHostCA.h +++ b/Source/WebKit2/WebProcess/WebPage/ca/LayerTreeHostCA.h @@ -74,7 +74,7 @@ private: // GraphicsLayerClient virtual void notifyAnimationStarted(const WebCore::GraphicsLayer*, double time); - virtual void notifySyncRequired(const WebCore::GraphicsLayer*); + virtual void notifyFlushRequired(const WebCore::GraphicsLayer*); virtual void paintContents(const WebCore::GraphicsLayer*, WebCore::GraphicsContext&, WebCore::GraphicsLayerPaintingPhase, const WebCore::IntRect& clipRect); virtual bool showDebugBorders(const WebCore::GraphicsLayer*) const; virtual bool showRepaintCounter(const WebCore::GraphicsLayer*) const; diff --git a/Source/WebKit2/WebProcess/WebPage/gtk/LayerTreeHostGtk.cpp b/Source/WebKit2/WebProcess/WebPage/gtk/LayerTreeHostGtk.cpp index 098a4c716..af2ae89bf 100644 --- a/Source/WebKit2/WebProcess/WebPage/gtk/LayerTreeHostGtk.cpp +++ b/Source/WebKit2/WebProcess/WebPage/gtk/LayerTreeHostGtk.cpp @@ -36,7 +36,7 @@ #include <GL/gl.h> #include <WebCore/Frame.h> #include <WebCore/FrameView.h> -#include <WebCore/GLContextGLX.h> +#include <WebCore/GLContext.h> #include <WebCore/Page.h> #include <WebCore/Settings.h> @@ -84,12 +84,12 @@ GLContext* LayerTreeHostGtk::glContext() void LayerTreeHostGtk::initialize() { - m_rootLayer = GraphicsLayer::create(this); + m_rootLayer = GraphicsLayer::create(graphicsLayerFactory(), this); m_rootLayer->setDrawsContent(false); m_rootLayer->setSize(m_webPage->size()); // The non-composited contents are a child of the root layer. - m_nonCompositedContentLayer = GraphicsLayer::create(this); + m_nonCompositedContentLayer = GraphicsLayer::create(graphicsLayerFactory(), this); m_nonCompositedContentLayer->setDrawsContent(true); m_nonCompositedContentLayer->setContentsOpaque(m_webPage->drawsBackground() && !m_webPage->drawsTransparentBackground()); m_nonCompositedContentLayer->setSize(m_webPage->size()); @@ -241,7 +241,7 @@ void LayerTreeHostGtk::notifyAnimationStarted(const WebCore::GraphicsLayer*, dou { } -void LayerTreeHostGtk::notifySyncRequired(const WebCore::GraphicsLayer*) +void LayerTreeHostGtk::notifyFlushRequired(const WebCore::GraphicsLayer*) { } @@ -287,12 +287,12 @@ void LayerTreeHostGtk::layerFlushTimerFired() bool LayerTreeHostGtk::flushPendingLayerChanges() { - m_rootLayer->syncCompositingStateForThisLayerOnly(); - m_nonCompositedContentLayer->syncCompositingStateForThisLayerOnly(); + m_rootLayer->flushCompositingStateForThisLayerOnly(); + m_nonCompositedContentLayer->flushCompositingStateForThisLayerOnly(); if (m_pageOverlayLayer) - m_pageOverlayLayer->syncCompositingStateForThisLayerOnly(); + m_pageOverlayLayer->flushCompositingStateForThisLayerOnly(); - return m_webPage->corePage()->mainFrame()->view()->syncCompositingStateIncludingSubframes(); + return m_webPage->corePage()->mainFrame()->view()->flushCompositingStateIncludingSubframes(); } void LayerTreeHostGtk::compositeLayersToContext(CompositePurpose purpose) @@ -317,7 +317,6 @@ void LayerTreeHostGtk::compositeLayersToContext(CompositePurpose purpose) m_textureMapper->endPainting(); context->swapBuffers(); - m_webPage->invalidateWidget(); } void LayerTreeHostGtk::flushAndRenderLayers() @@ -351,7 +350,7 @@ void LayerTreeHostGtk::createPageOverlayLayer() { ASSERT(!m_pageOverlayLayer); - m_pageOverlayLayer = GraphicsLayer::create(this); + m_pageOverlayLayer = GraphicsLayer::create(graphicsLayerFactory(), this); #ifndef NDEBUG m_pageOverlayLayer->setName("LayerTreeHost page overlay content"); #endif diff --git a/Source/WebKit2/WebProcess/WebPage/gtk/LayerTreeHostGtk.h b/Source/WebKit2/WebProcess/WebPage/gtk/LayerTreeHostGtk.h index d9a816c2e..61b9fa671 100644 --- a/Source/WebKit2/WebProcess/WebPage/gtk/LayerTreeHostGtk.h +++ b/Source/WebKit2/WebProcess/WebPage/gtk/LayerTreeHostGtk.h @@ -75,7 +75,7 @@ private: // GraphicsLayerClient virtual void notifyAnimationStarted(const WebCore::GraphicsLayer*, double time); - virtual void notifySyncRequired(const WebCore::GraphicsLayer*); + virtual void notifyFlushRequired(const WebCore::GraphicsLayer*); virtual void paintContents(const WebCore::GraphicsLayer*, WebCore::GraphicsContext&, WebCore::GraphicsLayerPaintingPhase, const WebCore::IntRect& clipRect); virtual bool showDebugBorders(const WebCore::GraphicsLayer*) const; virtual bool showRepaintCounter(const WebCore::GraphicsLayer*) const; diff --git a/Source/WebKit2/WebProcess/WebPage/gtk/WebPageGtk.cpp b/Source/WebKit2/WebProcess/WebPage/gtk/WebPageGtk.cpp index d9dde81a2..8b0db6ecc 100644 --- a/Source/WebKit2/WebProcess/WebPage/gtk/WebPageGtk.cpp +++ b/Source/WebKit2/WebProcess/WebPage/gtk/WebPageGtk.cpp @@ -52,8 +52,8 @@ void WebPage::platformInitialize() // entry point to the Web process, and send a message to the UI // process to connect the two worlds through the accessibility // object there specifically placed for that purpose (the socket). - m_accessibilityObject = webPageAccessibilityObjectNew(this); - GOwnPtr<gchar> plugID(atk_plug_get_id(ATK_PLUG(m_accessibilityObject))); + m_accessibilityObject = adoptGRef(webPageAccessibilityObjectNew(this)); + GOwnPtr<gchar> plugID(atk_plug_get_id(ATK_PLUG(m_accessibilityObject.get()))); send(Messages::WebPageProxy::BindAccessibilityTree(String(plugID.get()))); #if USE(TEXTURE_MAPPER_GL) @@ -66,7 +66,7 @@ void WebPage::updateAccessibilityTree() if (!m_accessibilityObject) return; - webPageAccessibilityObjectRefresh(m_accessibilityObject); + webPageAccessibilityObjectRefresh(m_accessibilityObject.get()); } void WebPage::platformPreferencesDidChange(const WebPreferencesStore&) @@ -160,36 +160,6 @@ void WebPage::setAcceleratedCompositingWindowId(int64_t nativeWindowHandle) { m_nativeWindowHandle = nativeWindowHandle; } - -void WebPage::invalidateWidget() -{ - send(Messages::WebPageProxy::InvalidateWidget()); -} -#endif - -bool WebPage::handleMousePressedEvent(const PlatformMouseEvent& platformMouseEvent) -{ - bool returnValue = false; - if (platformMouseEvent.button() != WebCore::MiddleButton) - return returnValue; - -#if PLATFORM(X11) - Frame* frame = m_page->focusController()->focusedOrMainFrame(); - if (!frame) - return returnValue; - - PasteboardHelper* pasteboardHelper = PasteboardHelper::defaultPasteboardHelper(); - bool wasUsingPrimary = pasteboardHelper->usePrimarySelectionClipboard(); - pasteboardHelper->setUsePrimarySelectionClipboard(true); - - Editor* editor = frame->editor(); - returnValue = editor->canPaste() || editor->canDHTMLPaste(); - editor->paste(); - - pasteboardHelper->setUsePrimarySelectionClipboard(wasUsingPrimary); #endif - return returnValue; -} - } // namespace WebKit diff --git a/Source/WebKit2/WebProcess/WebPage/gtk/WebPrintOperationGtk.cpp b/Source/WebKit2/WebProcess/WebPage/gtk/WebPrintOperationGtk.cpp index 29f89324e..0f07d74bc 100644 --- a/Source/WebKit2/WebProcess/WebPage/gtk/WebPrintOperationGtk.cpp +++ b/Source/WebKit2/WebProcess/WebPage/gtk/WebPrintOperationGtk.cpp @@ -697,6 +697,7 @@ void WebPrintOperationGtk::print(cairo_surface_t* surface, double xDPI, double y OwnPtr<PrintPagesData> data = adoptPtr(new PrintPagesData(this)); if (!data->isValid) { + cairo_surface_finish(surface); printDone(invalidPageRangeToPrint(m_printContext)); return; } diff --git a/Source/WebKit2/WebProcess/WebPage/gtk/WebPrintOperationGtk.h b/Source/WebKit2/WebProcess/WebPage/gtk/WebPrintOperationGtk.h index 3d1f1086d..39593052e 100644 --- a/Source/WebKit2/WebProcess/WebPage/gtk/WebPrintOperationGtk.h +++ b/Source/WebKit2/WebProcess/WebPage/gtk/WebPrintOperationGtk.h @@ -48,7 +48,7 @@ class WebPage; class WebPrintOperationGtk : public RefCounted<WebPrintOperationGtk> { public: static PassRefPtr<WebPrintOperationGtk> create(WebPage*, const PrintInfo&); - ~WebPrintOperationGtk(); + virtual ~WebPrintOperationGtk(); WebCore::PrintContext* printContext() const { return m_printContext; } GtkPrintSettings* printSettings() const { return m_printSettings.get(); } diff --git a/Source/WebKit2/WebProcess/WebPage/mac/TiledCoreAnimationDrawingArea.h b/Source/WebKit2/WebProcess/WebPage/mac/TiledCoreAnimationDrawingArea.h index 22599edad..f5048a985 100644 --- a/Source/WebKit2/WebProcess/WebPage/mac/TiledCoreAnimationDrawingArea.h +++ b/Source/WebKit2/WebProcess/WebPage/mac/TiledCoreAnimationDrawingArea.h @@ -59,7 +59,7 @@ private: virtual void setLayerTreeStateIsFrozen(bool) OVERRIDE; virtual bool layerTreeStateIsFrozen() const OVERRIDE; virtual void setRootCompositingLayer(WebCore::GraphicsLayer*) OVERRIDE; - virtual void scheduleCompositingLayerSync() OVERRIDE; + virtual void scheduleCompositingLayerFlush() OVERRIDE; virtual void didInstallPageOverlay() OVERRIDE; virtual void didUninstallPageOverlay() OVERRIDE; @@ -70,7 +70,7 @@ private: // WebCore::GraphicsLayerClient virtual void notifyAnimationStarted(const WebCore::GraphicsLayer*, double time) OVERRIDE; - virtual void notifySyncRequired(const WebCore::GraphicsLayer*) OVERRIDE; + virtual void notifyFlushRequired(const WebCore::GraphicsLayer*) OVERRIDE; virtual void paintContents(const WebCore::GraphicsLayer*, WebCore::GraphicsContext&, WebCore::GraphicsLayerPaintingPhase, const WebCore::IntRect& clipRect) OVERRIDE; virtual bool showDebugBorders(const WebCore::GraphicsLayer*) const OVERRIDE; virtual bool showRepaintCounter(const WebCore::GraphicsLayer*) const OVERRIDE; diff --git a/Source/WebKit2/WebProcess/WebPage/mac/TiledCoreAnimationDrawingArea.mm b/Source/WebKit2/WebProcess/WebPage/mac/TiledCoreAnimationDrawingArea.mm index 43f6440a8..fcd72cac9 100644 --- a/Source/WebKit2/WebProcess/WebPage/mac/TiledCoreAnimationDrawingArea.mm +++ b/Source/WebKit2/WebProcess/WebPage/mac/TiledCoreAnimationDrawingArea.mm @@ -43,7 +43,6 @@ #import <WebCore/GraphicsContext.h> #import <WebCore/GraphicsLayerCA.h> #import <WebCore/Page.h> -#import <WebCore/RenderLayerCompositor.h> #import <WebCore/RenderView.h> #import <WebCore/ScrollingCoordinator.h> #import <WebCore/ScrollingThread.h> @@ -174,7 +173,7 @@ bool TiledCoreAnimationDrawingArea::layerTreeStateIsFrozen() const return m_layerTreeStateIsFrozen; } -void TiledCoreAnimationDrawingArea::scheduleCompositingLayerSync() +void TiledCoreAnimationDrawingArea::scheduleCompositingLayerFlush() { m_layerFlushScheduler.schedule(); } @@ -184,7 +183,7 @@ void TiledCoreAnimationDrawingArea::didInstallPageOverlay() m_webPage->corePage()->scrollingCoordinator()->setForceMainThreadScrollLayerPositionUpdates(true); createPageOverlayLayer(); - scheduleCompositingLayerSync(); + scheduleCompositingLayerFlush(); } void TiledCoreAnimationDrawingArea::didUninstallPageOverlay() @@ -193,14 +192,14 @@ void TiledCoreAnimationDrawingArea::didUninstallPageOverlay() page->scrollingCoordinator()->setForceMainThreadScrollLayerPositionUpdates(false); destroyPageOverlayLayer(); - scheduleCompositingLayerSync(); + scheduleCompositingLayerFlush(); } void TiledCoreAnimationDrawingArea::setPageOverlayNeedsDisplay(const IntRect& rect) { ASSERT(m_pageOverlayLayer); m_pageOverlayLayer->setNeedsDisplayInRect(rect); - scheduleCompositingLayerSync(); + scheduleCompositingLayerFlush(); } void TiledCoreAnimationDrawingArea::updatePreferences(const WebPreferencesStore&) @@ -263,7 +262,7 @@ void TiledCoreAnimationDrawingArea::notifyAnimationStarted(const GraphicsLayer*, { } -void TiledCoreAnimationDrawingArea::notifySyncRequired(const GraphicsLayer*) +void TiledCoreAnimationDrawingArea::notifyFlushRequired(const GraphicsLayer*) { } @@ -305,10 +304,10 @@ bool TiledCoreAnimationDrawingArea::flushLayers() if (m_pageOverlayLayer) { m_pageOverlayLayer->setNeedsDisplay(); - m_pageOverlayLayer->syncCompositingStateForThisLayerOnly(); + m_pageOverlayLayer->flushCompositingStateForThisLayerOnly(); } - bool returnValue = m_webPage->corePage()->mainFrame()->view()->syncCompositingStateIncludingSubframes(); + bool returnValue = m_webPage->corePage()->mainFrame()->view()->flushCompositingStateIncludingSubframes(); [pool drain]; return returnValue; @@ -442,7 +441,7 @@ void TiledCoreAnimationDrawingArea::createPageOverlayLayer() { ASSERT(!m_pageOverlayLayer); - m_pageOverlayLayer = GraphicsLayer::create(this); + m_pageOverlayLayer = GraphicsLayer::create(graphicsLayerFactory(), this); #ifndef NDEBUG m_pageOverlayLayer->setName("page overlay content"); #endif diff --git a/Source/WebKit2/WebProcess/WebPage/mac/WebPageMac.mm b/Source/WebKit2/WebProcess/WebPage/mac/WebPageMac.mm index c2f016537..2acf85b0e 100644 --- a/Source/WebKit2/WebProcess/WebPage/mac/WebPageMac.mm +++ b/Source/WebKit2/WebProcess/WebPage/mac/WebPageMac.mm @@ -94,6 +94,14 @@ void WebPage::platformPreferencesDidChange(const WebPreferencesStore& store) { if (WebInspector* inspector = this->inspector()) inspector->setInspectorUsesWebKitUserInterface(store.getBoolValueForKey(WebPreferencesKey::inspectorUsesWebKitUserInterfaceKey())); + + BOOL omitPDFSupport = [[NSUserDefaults standardUserDefaults] boolForKey:@"WebKitOmitPDFSupport"]; + if (!pdfPluginEnabled() && !omitPDFSupport) { + // We want to use a PDF view in the UI process for PDF MIME types. + HashSet<String, CaseFoldingHash> mimeTypes = pdfAndPostScriptMIMETypes(); + for (HashSet<String, CaseFoldingHash>::iterator it = mimeTypes.begin(); it != mimeTypes.end(); ++it) + m_mimeTypesWithCustomRepresentations.add(*it); + } } typedef HashMap<String, String> SelectorNameMap; @@ -121,7 +129,7 @@ static String commandNameForSelectorName(const String& selectorName) static const SelectorNameMap* exceptionMap = createSelectorExceptionMap(); SelectorNameMap::const_iterator it = exceptionMap->find(selectorName); if (it != exceptionMap->end()) - return it->second; + return it->value; // Remove the trailing colon. // No need to capitalize the command name since Editor command names are not case sensitive. @@ -866,4 +874,16 @@ void WebPage::drawPagesToPDFFromPDFDocument(CGContextRef context, PDFDocument *p } } +// FIXME: This is not the ideal place for this function (and now it's duplicated here and in WebContextMac). +HashSet<String, CaseFoldingHash> WebPage::pdfAndPostScriptMIMETypes() +{ + HashSet<String, CaseFoldingHash> mimeTypes; + + mimeTypes.add("application/pdf"); + mimeTypes.add("application/postscript"); + mimeTypes.add("text/pdf"); + + return mimeTypes; +} + } // namespace WebKit diff --git a/Source/WebKit2/WebProcess/WebPage/qt/WebPageQt.cpp b/Source/WebKit2/WebProcess/WebPage/qt/WebPageQt.cpp index e3f6034df..721be4603 100644 --- a/Source/WebKit2/WebProcess/WebPage/qt/WebPageQt.cpp +++ b/Source/WebKit2/WebProcess/WebPage/qt/WebPageQt.cpp @@ -423,7 +423,7 @@ void WebPage::setUserScripts(const Vector<String>& scripts) PageGroup* pageGroup = PageGroup::pageGroup(this->pageGroup()->identifier()); pageGroup->removeUserScriptsFromWorld(mainThreadNormalWorld()); for (unsigned i = 0; i < scripts.size(); ++i) - pageGroup->addUserScriptToWorld(mainThreadNormalWorld(), scripts.at(i), KURL(), nullptr, nullptr, InjectAtDocumentEnd, InjectInTopFrameOnly); + pageGroup->addUserScriptToWorld(mainThreadNormalWorld(), scripts.at(i), KURL(), Vector<String>(), Vector<String>(), InjectAtDocumentEnd, InjectInTopFrameOnly); } void WebPage::selectedIndex(int32_t newIndex) @@ -440,21 +440,4 @@ void WebPage::hidePopupMenu() m_activePopupMenu = 0; } -bool WebPage::handleMouseReleaseEvent(const PlatformMouseEvent& platformMouseEvent) -{ -#ifndef QT_NO_CLIPBOARD - if (platformMouseEvent.button() != WebCore::MiddleButton) - return false; - - if (qApp->clipboard()->supportsSelection()) { - WebCore::Frame* focusFrame = m_page->focusController()->focusedOrMainFrame(); - if (focusFrame) { - focusFrame->editor()->command(AtomicString("PasteGlobalSelection")).execute(); - return true; - } - } -#endif - return false; -} - } // namespace WebKit diff --git a/Source/WebKit2/WebProcess/WebProcess.cpp b/Source/WebKit2/WebProcess/WebProcess.cpp index de1832459..6f67ed022 100644 --- a/Source/WebKit2/WebProcess/WebProcess.cpp +++ b/Source/WebKit2/WebProcess/WebProcess.cpp @@ -26,10 +26,8 @@ #include "config.h" #include "WebProcess.h" -#include "AuthenticationManager.h" #include "DownloadManager.h" #include "InjectedBundle.h" -#include "InjectedBundleMessageKinds.h" #include "InjectedBundleUserMessageCoders.h" #include "SandboxExtension.h" #include "StatisticsData.h" @@ -160,9 +158,6 @@ WebProcess::WebProcess() , m_notificationManager(this) #endif , m_iconDatabaseProxy(this) -#if ENABLE(PLUGIN_PROCESS) - , m_disablePluginProcessMessageTimeout(false) -#endif #if USE(SOUP) , m_soupRequestManager(this) #endif @@ -251,9 +246,6 @@ void WebProcess::initializeWebProcess(const WebProcessCreationParameters& parame setDefaultRequestTimeoutInterval(parameters.defaultRequestTimeoutInterval); - for (size_t i = 0; i < parameters.mimeTypesWithCustomRepresentation.size(); ++i) - m_mimeTypesWithCustomRepresentations.add(parameters.mimeTypesWithCustomRepresentation[i]); - if (parameters.shouldAlwaysUseComplexTextCodePath) setAlwaysUsesComplexTextCodePath(true); @@ -264,10 +256,6 @@ void WebProcess::initializeWebProcess(const WebProcessCreationParameters& parame WebCore::ResourceHandle::setPrivateBrowsingStorageSessionIdentifierBase(parameters.uiProcessBundleIdentifier); #endif -#if ENABLE(PLUGIN_PROCESS) - m_disablePluginProcessMessageTimeout = parameters.disablePluginProcessMessageTimeout; -#endif - setTerminationTimeout(parameters.terminationTimeout); } @@ -354,7 +342,7 @@ void WebProcess::visitedLinkStateChanged(const Vector<WebCore::LinkHash>& linkHa HashMap<uint64_t, RefPtr<WebPageGroupProxy> >::const_iterator it = m_pageGroupMap.begin(); HashMap<uint64_t, RefPtr<WebPageGroupProxy> >::const_iterator end = m_pageGroupMap.end(); for (; it != end; ++it) - Page::visitedStateChanged(PageGroup::pageGroup(it->second->identifier()), linkHashes[i]); + Page::visitedStateChanged(PageGroup::pageGroup(it->value->identifier()), linkHashes[i]); } pageCache()->markPagesForVistedLinkStyleRecalc(); @@ -366,7 +354,7 @@ void WebProcess::allVisitedLinkStateChanged() HashMap<uint64_t, RefPtr<WebPageGroupProxy> >::const_iterator it = m_pageGroupMap.begin(); HashMap<uint64_t, RefPtr<WebPageGroupProxy> >::const_iterator end = m_pageGroupMap.end(); for (; it != end; ++it) - Page::allVisitedStateChanged(PageGroup::pageGroup(it->second->identifier())); + Page::allVisitedStateChanged(PageGroup::pageGroup(it->value->identifier())); pageCache()->markPagesForVistedLinkStyleRecalc(); } @@ -542,7 +530,7 @@ WebPage* WebProcess::focusedWebPage() const { HashMap<uint64_t, RefPtr<WebPage> >::const_iterator end = m_pageMap.end(); for (HashMap<uint64_t, RefPtr<WebPage> >::const_iterator it = m_pageMap.begin(); it != end; ++it) { - WebPage* page = (*it).second.get(); + WebPage* page = (*it).value.get(); if (page->windowAndWebPageAreFocused()) return page; } @@ -560,14 +548,14 @@ void WebProcess::createWebPage(uint64_t pageID, const WebPageCreationParameters& // link) the WebPage gets created both in the synchronous handler and through the normal way. HashMap<uint64_t, RefPtr<WebPage> >::AddResult result = m_pageMap.add(pageID, 0); if (result.isNewEntry) { - ASSERT(!result.iterator->second); - result.iterator->second = WebPage::create(pageID, parameters); + ASSERT(!result.iterator->value); + result.iterator->value = WebPage::create(pageID, parameters); // Balanced by an enableTermination in removeWebPage. disableTermination(); } - ASSERT(result.iterator->second); + ASSERT(result.iterator->value); } void WebProcess::removeWebPage(uint64_t pageID) @@ -638,11 +626,6 @@ void WebProcess::didReceiveMessage(CoreIPC::Connection* connection, CoreIPC::Mes return; } - if (messageID.is<CoreIPC::MessageClassAuthenticationManager>()) { - AuthenticationManager::shared().didReceiveMessage(connection, messageID, arguments); - return; - } - if (messageID.is<CoreIPC::MessageClassWebApplicationCacheManager>()) { WebApplicationCacheManager::shared().didReceiveMessage(connection, messageID, arguments); return; @@ -660,11 +643,6 @@ void WebProcess::didReceiveMessage(CoreIPC::Connection* connection, CoreIPC::Mes } #endif - if (messageID.is<CoreIPC::MessageClassWebGeolocationManager>()) { - m_geolocationManager.didReceiveMessage(connection, messageID, arguments); - return; - } - #if ENABLE(BATTERY_STATUS) if (messageID.is<CoreIPC::MessageClassWebBatteryManager>()) { m_batteryManager.didReceiveMessage(connection, messageID, arguments); @@ -712,12 +690,17 @@ void WebProcess::didReceiveMessage(CoreIPC::Connection* connection, CoreIPC::Mes return; } #endif - - if (messageID.is<CoreIPC::MessageClassInjectedBundle>()) { - if (!m_injectedBundle) + + if (messageID.is<CoreIPC::MessageClassWebPageGroupProxy>()) { + uint64_t pageGroupID = arguments->destinationID(); + if (!pageGroupID) return; - m_injectedBundle->didReceiveMessage(connection, messageID, arguments); - return; + + WebPageGroupProxy* pageGroupProxy = webPageGroup(pageGroupID); + if (!pageGroupProxy) + return; + + pageGroupProxy->didReceiveMessage(connection, messageID, arguments); } uint64_t pageID = arguments->destinationID(); @@ -760,10 +743,6 @@ void WebProcess::didReceiveInvalidMessage(CoreIPC::Connection*, CoreIPC::Message // we'll let it slide. } -void WebProcess::syncMessageSendTimedOut(CoreIPC::Connection*) -{ -} - void WebProcess::didReceiveMessageOnConnectionWorkQueue(CoreIPC::Connection* connection, CoreIPC::MessageID messageID, CoreIPC::ArgumentDecoder* arguments, bool& didHandleMessage) { if (messageID.is<CoreIPC::MessageClassWebProcess>()) { @@ -804,11 +783,11 @@ WebPageGroupProxy* WebProcess::webPageGroup(const WebPageGroupData& pageGroupDat { HashMap<uint64_t, RefPtr<WebPageGroupProxy> >::AddResult result = m_pageGroupMap.add(pageGroupData.pageGroupID, 0); if (result.isNewEntry) { - ASSERT(!result.iterator->second); - result.iterator->second = WebPageGroupProxy::create(pageGroupData); + ASSERT(!result.iterator->value); + result.iterator->value = WebPageGroupProxy::create(pageGroupData); } - return result.iterator->second.get(); + return result.iterator->value.get(); } #if ENABLE(WEB_INTENTS) @@ -831,26 +810,6 @@ void WebProcess::removeMessagePortChannel(uint64_t channelID) } #endif -static bool canPluginHandleResponse(const ResourceResponse& response) -{ - String pluginPath; - bool blocked; - - if (!WebProcess::shared().connection()->sendSync(Messages::WebProcessProxy::GetPluginPath(response.mimeType(), response.url().string()), Messages::WebProcessProxy::GetPluginPath::Reply(pluginPath, blocked), 0)) - return false; - - return !blocked && !pluginPath.isEmpty(); -} - -bool WebProcess::shouldUseCustomRepresentationForResponse(const ResourceResponse& response) const -{ - if (!m_mimeTypesWithCustomRepresentations.contains(response.mimeType())) - return false; - - // If a plug-in exists that claims to support this response, it should take precedence over the custom representation. - return !canPluginHandleResponse(response); -} - void WebProcess::clearResourceCaches(ResourceCachesToClear resourceCachesToClear) { platformClearResourceCaches(resourceCachesToClear); @@ -934,7 +893,7 @@ static void fromCountedSetToHashMap(TypeCountSet* countedSet, HashMap<String, ui { TypeCountSet::const_iterator end = countedSet->end(); for (TypeCountSet::const_iterator it = countedSet->begin(); it != end; ++it) - map.set(it->first, it->second); + map.set(it->key, it->value); } static void getWebCoreMemoryCacheStatistics(Vector<HashMap<String, uint64_t> >& result) @@ -1046,6 +1005,25 @@ void WebProcess::setJavaScriptGarbageCollectorTimerEnabled(bool flag) gcController().setJavaScriptGarbageCollectorTimerEnabled(flag); } +void WebProcess::postInjectedBundleMessage(const CoreIPC::DataReference& messageData) +{ + InjectedBundle* injectedBundle = WebProcess::shared().injectedBundle(); + if (!injectedBundle) + return; + + CoreIPC::ArgumentDecoder messageDecoder(messageData.data(), messageData.size()); + + String messageName; + if (!messageDecoder.decode(messageName)) + return; + + RefPtr<APIObject> messageBody; + if (!messageDecoder.decode(InjectedBundleUserMessageDecoder(messageBody))) + return; + + injectedBundle->didReceiveMessage(messageName, messageBody.get()); +} + #if ENABLE(PLUGIN_PROCESS) void WebProcess::pluginProcessCrashed(CoreIPC::Connection*, const String& pluginPath) { @@ -1107,7 +1085,7 @@ void WebProcess::setTextCheckerState(const TextCheckerState& textCheckerState) HashMap<uint64_t, RefPtr<WebPage> >::iterator end = m_pageMap.end(); for (HashMap<uint64_t, RefPtr<WebPage> >::iterator it = m_pageMap.begin(); it != end; ++it) { - WebPage* page = (*it).second.get(); + WebPage* page = (*it).value.get(); if (continuousSpellCheckingTurnedOff) page->unmarkAllMisspellings(); if (grammarCheckingTurnedOff) diff --git a/Source/WebKit2/WebProcess/WebProcess.h b/Source/WebKit2/WebProcess/WebProcess.h index e34d15f29..eccbb8d60 100644 --- a/Source/WebKit2/WebProcess/WebProcess.h +++ b/Source/WebKit2/WebProcess/WebProcess.h @@ -150,14 +150,12 @@ public: #if PLATFORM(MAC) pid_t presenterApplicationPid() const { return m_presenterApplicationPid; } bool shouldForceScreenFontSubstitution() const { return m_shouldForceScreenFontSubstitution; } -#endif +#endif #if PLATFORM(QT) QNetworkAccessManager* networkAccessManager() { return m_networkAccessManager; } #endif - bool shouldUseCustomRepresentationForResponse(const WebCore::ResourceResponse&) const; - // Text Checking const TextCheckerState& textCheckerState() const { return m_textCheckerState; } @@ -182,7 +180,6 @@ public: #if ENABLE(PLUGIN_PROCESS) PluginProcessConnectionManager& pluginProcessConnectionManager() { return m_pluginProcessConnectionManager; } - bool disablePluginProcessMessageTimeout() const { return m_disablePluginProcessMessageTimeout; } #endif EventDispatcher& eventDispatcher() { return m_eventDispatcher; } @@ -251,6 +248,8 @@ private: void garbageCollectJavaScriptObjects(); void setJavaScriptGarbageCollectorTimerEnabled(bool flag); + void postInjectedBundleMessage(const CoreIPC::DataReference& messageData); + #if USE(SECURITY_FRAMEWORK) void secItemResponse(CoreIPC::Connection*, uint64_t requestID, const SecItemResponseData&); void secKeychainItemResponse(CoreIPC::Connection*, uint64_t requestID, const SecKeychainItemResponseData&); @@ -266,7 +265,6 @@ private: virtual void didReceiveSyncMessage(CoreIPC::Connection*, CoreIPC::MessageID, CoreIPC::ArgumentDecoder*, OwnPtr<CoreIPC::ArgumentEncoder>&); virtual void didClose(CoreIPC::Connection*); virtual void didReceiveInvalidMessage(CoreIPC::Connection*, CoreIPC::MessageID); - virtual void syncMessageSendTimedOut(CoreIPC::Connection*); #if PLATFORM(WIN) virtual Vector<HWND> windowsToReceiveSentMessagesWhileWaitingForSyncReply(); #endif @@ -320,8 +318,6 @@ private: HashMap<uint64_t, RefPtr<WebCore::PlatformMessagePortChannel> > m_messagePortChannels; #endif - HashSet<String, CaseFoldingHash> m_mimeTypesWithCustomRepresentations; - TextCheckerState m_textCheckerState; WebGeolocationManager m_geolocationManager; #if ENABLE(BATTERY_STATUS) @@ -339,7 +335,6 @@ private: #if ENABLE(PLUGIN_PROCESS) PluginProcessConnectionManager m_pluginProcessConnectionManager; - bool m_disablePluginProcessMessageTimeout; #endif #if USE(SOUP) diff --git a/Source/WebKit2/WebProcess/WebProcess.messages.in b/Source/WebKit2/WebProcess/WebProcess.messages.in index 336ff8bfa..d10a7b536 100644 --- a/Source/WebKit2/WebProcess/WebProcess.messages.in +++ b/Source/WebKit2/WebProcess/WebProcess.messages.in @@ -22,7 +22,7 @@ messages -> WebProcess { # Initialize the WebProcess. - InitializeWebProcess(WebKit::WebProcessCreationParameters processCreationParameters, WebKit::WebContextUserMessageEncoder initializationUserData) + InitializeWebProcess(WebKit::WebProcessCreationParameters processCreationParameters, WebKit::WebContextUserMessageEncoder initializationUserData) Variadic # Create a new page. CreateWebPage(uint64_t newPageID, WebKit::WebPageCreationParameters pageCreationParameters) @@ -56,7 +56,6 @@ messages -> WebProcess { #endif # Plug-ins. - #if !ENABLE(PLUGIN_PROCESS) GetSitesWithPluginData(Vector<WTF::String> pluginPaths, uint64_t callbackID) ClearPluginSiteData(Vector<WTF::String> pluginPaths, Vector<WTF::String> sites, uint64_t flags, uint64_t maxAgeInSeconds, uint64_t callbackID) @@ -87,6 +86,8 @@ messages -> WebProcess { GarbageCollectJavaScriptObjects() SetJavaScriptGarbageCollectorTimerEnabled(bool enable) + PostInjectedBundleMessage(CoreIPC::DataReference messageData); + #if USE(SECURITY_FRAMEWORK) SecItemResponse(uint64_t requestID, WebKit::SecItemResponseData response) DispatchOnConnectionQueue SecKeychainItemResponse(uint64_t requestID, WebKit::SecKeychainItemResponseData response) DispatchOnConnectionQueue diff --git a/Source/WebKit2/WebProcess/mac/WebProcessMac.mm b/Source/WebKit2/WebProcess/mac/WebProcessMac.mm index ff75ceba5..fcc42e964 100644 --- a/Source/WebKit2/WebProcess/mac/WebProcessMac.mm +++ b/Source/WebKit2/WebProcess/mac/WebProcessMac.mm @@ -33,6 +33,7 @@ #import "WebProcessCreationParameters.h" #import "WebProcessProxyMessages.h" #import <WebCore/FileSystem.h> +#import <WebCore/Font.h> #import <WebCore/LocalizedStrings.h> #import <WebCore/MemoryCache.h> #import <WebCore/PageCache.h> @@ -256,22 +257,23 @@ void WebProcess::platformInitializeWebProcess(const WebProcessCreationParameters SandboxExtension::consumePermanently(parameters.localStorageDirectoryExtensionHandle); SandboxExtension::consumePermanently(parameters.databaseDirectoryExtensionHandle); SandboxExtension::consumePermanently(parameters.applicationCacheDirectoryExtensionHandle); - SandboxExtension::consumePermanently(parameters.nsURLCachePathExtensionHandle); + SandboxExtension::consumePermanently(parameters.diskCacheDirectoryExtensionHandle); if (!parameters.parentProcessName.isNull()) { NSString *applicationName = [NSString stringWithFormat:WEB_UI_STRING("%@ Web Content", "Visible name of the web process. The argument is the application name."), (NSString *)parameters.parentProcessName]; WKSetVisibleApplicationName((CFStringRef)applicationName); } - if (!parameters.nsURLCachePath.isNull()) { + if (!parameters.diskCacheDirectory.isNull()) { NSUInteger cacheMemoryCapacity = parameters.nsURLCacheMemoryCapacity; NSUInteger cacheDiskCapacity = parameters.nsURLCacheDiskCapacity; - RetainPtr<NSURLCache> parentProcessURLCache(AdoptNS, [[NSURLCache alloc] initWithMemoryCapacity:cacheMemoryCapacity diskCapacity:cacheDiskCapacity diskPath:parameters.nsURLCachePath]); + RetainPtr<NSURLCache> parentProcessURLCache(AdoptNS, [[NSURLCache alloc] initWithMemoryCapacity:cacheMemoryCapacity diskCapacity:cacheDiskCapacity diskPath:parameters.diskCacheDirectory]); [NSURLCache setSharedURLCache:parentProcessURLCache.get()]; } m_shouldForceScreenFontSubstitution = parameters.shouldForceScreenFontSubstitution; + Font::setDefaultTypesettingFeatures(parameters.shouldEnableKerningAndLigaturesByDefault ? Kerning | Ligatures : 0); m_compositingRenderServerPort = parameters.acceleratedCompositingPort.port(); diff --git a/Source/WebKit2/WebProcess/mac/WebProcessMainMac.mm b/Source/WebKit2/WebProcess/mac/WebProcessMainMac.mm index 3a8dee7f7..46b1b300d 100644 --- a/Source/WebKit2/WebProcess/mac/WebProcessMainMac.mm +++ b/Source/WebKit2/WebProcess/mac/WebProcessMainMac.mm @@ -161,9 +161,10 @@ int WebProcessMain(const CommandLine& commandLine) #endif // __MAC_OS_X_VERSION_MIN_REQUIRED >= 1070 String localization = commandLine["localization"]; - RetainPtr<CFStringRef> cfLocalization(AdoptCF, CFStringCreateWithCharacters(0, reinterpret_cast<const UniChar*>(localization.characters()), localization.length())); - if (cfLocalization) + if (!localization.isEmpty()) { + RetainPtr<CFStringRef> cfLocalization(AdoptCF, CFStringCreateWithCharacters(0, reinterpret_cast<const UniChar*>(localization.characters()), localization.length())); WKSetDefaultLocalization(cfLocalization.get()); + } [pool drain]; diff --git a/Source/WebKit2/WebProcess/soup/WebSoupRequestManager.cpp b/Source/WebKit2/WebProcess/soup/WebSoupRequestManager.cpp index 6c5cad195..7406d685e 100644 --- a/Source/WebKit2/WebProcess/soup/WebSoupRequestManager.cpp +++ b/Source/WebKit2/WebProcess/soup/WebSoupRequestManager.cpp @@ -25,6 +25,7 @@ #include "WebErrors.h" #include "WebKitSoupRequestGeneric.h" #include "WebKitSoupRequestInputStream.h" +#include "WebPageProxyMessages.h" #include "WebProcess.h" #include "WebSoupRequestManagerProxyMessages.h" #include <WebCore/ResourceHandle.h> @@ -169,12 +170,14 @@ void WebSoupRequestManager::didReceiveURIRequestData(const CoreIPC::DataReferenc void WebSoupRequestManager::send(GSimpleAsyncResult* result, GCancellable* cancellable) { GRefPtr<WebKitSoupRequestGeneric> request = adoptGRef(WEBKIT_SOUP_REQUEST_GENERIC(g_async_result_get_source_object(G_ASYNC_RESULT(result)))); - SoupURI* uri = soup_request_get_uri(SOUP_REQUEST(request.get())); - GOwnPtr<char> uriString(soup_uri_to_string(uri, FALSE)); + SoupRequest* soupRequest = SOUP_REQUEST(request.get()); + GOwnPtr<char> uriString(soup_uri_to_string(soup_request_get_uri(soupRequest), FALSE)); uint64_t requestID = generateSoupRequestID(); m_requestMap.set(requestID, adoptPtr(new WebSoupRequestAsyncData(result, request.get(), cancellable))); - m_process->connection()->send(Messages::WebSoupRequestManagerProxy::DidReceiveURIRequest(String::fromUTF8(uriString.get()), requestID), 0); + + uint64_t initiaingPageID = WebCore::ResourceHandle::getSoupRequestInitiaingPageID(soupRequest); + m_process->connection()->send(Messages::WebPageProxy::DidReceiveURIRequest(String::fromUTF8(uriString.get()), requestID), initiaingPageID); } GInputStream* WebSoupRequestManager::finish(GSimpleAsyncResult* result) diff --git a/Source/WebKit2/WebProcess/win/WebProcessWin.cpp b/Source/WebKit2/WebProcess/win/WebProcessWin.cpp index 809aacb3a..f0c1955a5 100644 --- a/Source/WebKit2/WebProcess/win/WebProcessWin.cpp +++ b/Source/WebKit2/WebProcess/win/WebProcessWin.cpp @@ -148,7 +148,7 @@ void WebProcess::platformInitializeWebProcess(const WebProcessCreationParameters if (defaultStorageSession) return; - RetainPtr<CFStringRef> cachePath(AdoptCF, parameters.cfURLCachePath.createCFString()); + RetainPtr<CFStringRef> cachePath(AdoptCF, parameters.diskCacheDirectory.createCFString()); if (!cachePath) return; |