diff options
Diffstat (limited to 'Source/WebKit2/WebProcess')
76 files changed, 1735 insertions, 233 deletions
diff --git a/Source/WebKit2/WebProcess/Downloads/soup/DownloadSoup.cpp b/Source/WebKit2/WebProcess/Downloads/soup/DownloadSoup.cpp index e43f7a4f7..2d96feeb7 100644 --- a/Source/WebKit2/WebProcess/Downloads/soup/DownloadSoup.cpp +++ b/Source/WebKit2/WebProcess/Downloads/soup/DownloadSoup.cpp @@ -132,8 +132,8 @@ public: void Download::start(WebPage* initiatingWebPage) { - ASSERT(m_downloadClient); - ASSERT(m_resourceHandle); + ASSERT(!m_downloadClient); + ASSERT(!m_resourceHandle); m_downloadClient = adoptPtr(new DownloadClient(this)); m_resourceHandle = ResourceHandle::create(0, m_request, m_downloadClient.get(), false, false); didStart(); @@ -141,8 +141,8 @@ void Download::start(WebPage* initiatingWebPage) void Download::startWithHandle(WebPage* initiatingPage, ResourceHandle* resourceHandle, const ResourceResponse&) { - ASSERT(m_downloadClient); - ASSERT(m_resourceHandle); + ASSERT(!m_downloadClient); + ASSERT(!m_resourceHandle); m_downloadClient = adoptPtr(new DownloadClient(this)); resourceHandle->setClient(m_downloadClient.get()); m_resourceHandle = resourceHandle; diff --git a/Source/WebKit2/WebProcess/InjectedBundle/API/c/WKBundle.cpp b/Source/WebKit2/WebProcess/InjectedBundle/API/c/WKBundle.cpp index d88281e1b..873931220 100644 --- a/Source/WebKit2/WebProcess/InjectedBundle/API/c/WKBundle.cpp +++ b/Source/WebKit2/WebProcess/InjectedBundle/API/c/WKBundle.cpp @@ -126,9 +126,9 @@ void WKBundleRemoveAllUserContent(WKBundleRef bundleRef, WKBundlePageGroupRef pa toImpl(bundleRef)->removeAllUserContent(toImpl(pageGroupRef)); } -void WKBundleOverrideXSSAuditorEnabledForTestRunner(WKBundleRef bundleRef, WKBundlePageGroupRef pageGroupRef, bool enabled) +void WKBundleOverrideBoolPreferenceForTestRunner(WKBundleRef bundleRef, WKBundlePageGroupRef pageGroupRef, WKStringRef preference, bool enabled) { - toImpl(bundleRef)->overrideXSSAuditorEnabledForTestRunner(toImpl(pageGroupRef), enabled); + toImpl(bundleRef)->overrideBoolPreferenceForTestRunner(toImpl(pageGroupRef), toImpl(preference)->string(), enabled); } void WKBundleSetAllowUniversalAccessFromFileURLs(WKBundleRef bundleRef, WKBundlePageGroupRef pageGroupRef, bool enabled) @@ -146,6 +146,11 @@ void WKBundleSetFrameFlatteningEnabled(WKBundleRef bundleRef, WKBundlePageGroupR toImpl(bundleRef)->setFrameFlatteningEnabled(toImpl(pageGroupRef), enabled); } +void WKBundleSetGeolocationPermission(WKBundleRef bundleRef, WKBundlePageGroupRef pageGroupRef, bool enabled) +{ + toImpl(bundleRef)->setGeoLocationPermission(toImpl(pageGroupRef), enabled); +} + void WKBundleSetJavaScriptCanAccessClipboard(WKBundleRef bundleRef, WKBundlePageGroupRef pageGroupRef, bool enabled) { toImpl(bundleRef)->setJavaScriptCanAccessClipboard(toImpl(pageGroupRef), enabled); @@ -156,6 +161,11 @@ void WKBundleSetPrivateBrowsingEnabled(WKBundleRef bundleRef, WKBundlePageGroupR toImpl(bundleRef)->setPrivateBrowsingEnabled(toImpl(pageGroupRef), enabled); } +void WKBundleSetPopupBlockingEnabled(WKBundleRef bundleRef, WKBundlePageGroupRef pageGroupRef, bool enabled) +{ + toImpl(bundleRef)->setPopupBlockingEnabled(toImpl(pageGroupRef), enabled); +} + void WKBundleSwitchNetworkLoaderToNewTestingSession(WKBundleRef bundleRef) { toImpl(bundleRef)->switchNetworkLoaderToNewTestingSession(); diff --git a/Source/WebKit2/WebProcess/InjectedBundle/API/c/WKBundleFrame.cpp b/Source/WebKit2/WebProcess/InjectedBundle/API/c/WKBundleFrame.cpp index df729bff5..f2d5cb42a 100644 --- a/Source/WebKit2/WebProcess/InjectedBundle/API/c/WKBundleFrame.cpp +++ b/Source/WebKit2/WebProcess/InjectedBundle/API/c/WKBundleFrame.cpp @@ -47,6 +47,11 @@ bool WKBundleFrameIsMainFrame(WKBundleFrameRef frameRef) return toImpl(frameRef)->isMainFrame(); } +WKBundleFrameRef WKBundleFrameGetParentFrame(WKBundleFrameRef frameRef) +{ + return toAPI(toImpl(frameRef)->parentFrame()); +} + WKURLRef WKBundleFrameCopyURL(WKBundleFrameRef frameRef) { return toCopiedURLAPI(toImpl(frameRef)->url()); diff --git a/Source/WebKit2/WebProcess/InjectedBundle/API/c/WKBundleFrame.h b/Source/WebKit2/WebProcess/InjectedBundle/API/c/WKBundleFrame.h index ce94badcb..8f2781a69 100644 --- a/Source/WebKit2/WebProcess/InjectedBundle/API/c/WKBundleFrame.h +++ b/Source/WebKit2/WebProcess/InjectedBundle/API/c/WKBundleFrame.h @@ -38,6 +38,7 @@ extern "C" { WK_EXPORT WKTypeID WKBundleFrameGetTypeID(); WK_EXPORT bool WKBundleFrameIsMainFrame(WKBundleFrameRef frame); +WK_EXPORT WKBundleFrameRef WKBundleFrameGetParentFrame(WKBundleFrameRef frame); WK_EXPORT WKArrayRef WKBundleFrameCopyChildFrames(WKBundleFrameRef frame); WK_EXPORT WKStringRef WKBundleFrameCopyName(WKBundleFrameRef frame); diff --git a/Source/WebKit2/WebProcess/InjectedBundle/API/c/WKBundlePage.cpp b/Source/WebKit2/WebProcess/InjectedBundle/API/c/WKBundlePage.cpp index 97347f2f9..3090c6e65 100644 --- a/Source/WebKit2/WebProcess/InjectedBundle/API/c/WKBundlePage.cpp +++ b/Source/WebKit2/WebProcess/InjectedBundle/API/c/WKBundlePage.cpp @@ -328,6 +328,11 @@ uint64_t WKBundlePageGetRenderTreeSize(WKBundlePageRef pageRef) return toImpl(pageRef)->renderTreeSize(); } +void WKBundlePageSetPaintedObjectsCounterThreshold(WKBundlePageRef page, uint64_t threshold) +{ + toImpl(page)->setPaintedObjectsCounterThreshold(threshold); +} + void WKBundlePageSetTracksRepaints(WKBundlePageRef pageRef, bool trackRepaints) { toImpl(pageRef)->setTracksRepaints(trackRepaints); diff --git a/Source/WebKit2/WebProcess/InjectedBundle/API/c/WKBundlePagePrivate.h b/Source/WebKit2/WebProcess/InjectedBundle/API/c/WKBundlePagePrivate.h index 73351b9fe..312331e77 100644 --- a/Source/WebKit2/WebProcess/InjectedBundle/API/c/WKBundlePagePrivate.h +++ b/Source/WebKit2/WebProcess/InjectedBundle/API/c/WKBundlePagePrivate.h @@ -55,6 +55,9 @@ WK_EXPORT void WKBundlePageSimulateMouseMotion(WKBundlePageRef page, WKPoint pos WK_EXPORT uint64_t WKBundlePageGetRenderTreeSize(WKBundlePageRef page); +// FIXME: This is temporary. Ultimately WebKit should choose the threshold itself. +WK_EXPORT void WKBundlePageSetPaintedObjectsCounterThreshold(WKBundlePageRef page, uint64_t threshold); + WK_EXPORT void WKBundlePageSetTracksRepaints(WKBundlePageRef page, bool trackRepaints); WK_EXPORT bool WKBundlePageIsTrackingRepaints(WKBundlePageRef page); WK_EXPORT void WKBundlePageResetTrackedRepaints(WKBundlePageRef page); diff --git a/Source/WebKit2/WebProcess/InjectedBundle/API/c/WKBundlePrivate.h b/Source/WebKit2/WebProcess/InjectedBundle/API/c/WKBundlePrivate.h index 95ca7ce7e..b371f56a5 100644 --- a/Source/WebKit2/WebProcess/InjectedBundle/API/c/WKBundlePrivate.h +++ b/Source/WebKit2/WebProcess/InjectedBundle/API/c/WKBundlePrivate.h @@ -64,12 +64,15 @@ WK_EXPORT void WKBundleRemoveUserStyleSheets(WKBundleRef bundle, WKBundlePageGro WK_EXPORT void WKBundleRemoveAllUserContent(WKBundleRef bundle, WKBundlePageGroupRef pageGroup); // Will make WebProcess ignore this preference until a preferences change notification, only for WebKitTestRunner use. -WK_EXPORT void WKBundleOverrideXSSAuditorEnabledForTestRunner(WKBundleRef bundle, WKBundlePageGroupRef pageGroup, bool enabled); +WK_EXPORT void WKBundleOverrideBoolPreferenceForTestRunner(WKBundleRef bundle, WKBundlePageGroupRef pageGroup, WKStringRef preference, bool enabled); + WK_EXPORT void WKBundleSetAllowUniversalAccessFromFileURLs(WKBundleRef bundle, WKBundlePageGroupRef pageGroup, bool enabled); WK_EXPORT void WKBundleSetAllowFileAccessFromFileURLs(WKBundleRef bundle, WKBundlePageGroupRef pageGroup, bool enabled); WK_EXPORT void WKBundleSetFrameFlatteningEnabled(WKBundleRef bundle, WKBundlePageGroupRef pageGroup, bool enabled); +WK_EXPORT void WKBundleSetGeolocationPermission(WKBundleRef bundle, WKBundlePageGroupRef pageGroup, bool enabled); WK_EXPORT void WKBundleSetJavaScriptCanAccessClipboard(WKBundleRef bundle, WKBundlePageGroupRef pageGroup, bool enabled); WK_EXPORT void WKBundleSetPrivateBrowsingEnabled(WKBundleRef bundle, WKBundlePageGroupRef pageGroup, bool enabled); +WK_EXPORT void WKBundleSetPopupBlockingEnabled(WKBundleRef bundle, WKBundlePageGroupRef pageGroup, bool enabled); WK_EXPORT void WKBundleSetAuthorAndUserStylesEnabled(WKBundleRef bundle, WKBundlePageGroupRef pageGroup, bool enabled); WK_EXPORT void WKBundleClearAllDatabases(WKBundleRef bundle); WK_EXPORT void WKBundleSetDatabaseQuota(WKBundleRef bundle, uint64_t); diff --git a/Source/WebKit2/WebProcess/InjectedBundle/InjectedBundle.cpp b/Source/WebKit2/WebProcess/InjectedBundle/InjectedBundle.cpp index b87151e42..f40a24a2e 100644 --- a/Source/WebKit2/WebProcess/InjectedBundle/InjectedBundle.cpp +++ b/Source/WebKit2/WebProcess/InjectedBundle/InjectedBundle.cpp @@ -31,6 +31,7 @@ #include "InjectedBundleMessageKinds.h" #include "InjectedBundleScriptWorld.h" #include "InjectedBundleUserMessageCoders.h" +#include "LayerTreeHost.h" #include "WKAPICast.h" #include "WKBundleAPICast.h" #include "WebApplicationCacheManager.h" @@ -46,6 +47,10 @@ #include <WebCore/Frame.h> #include <WebCore/FrameView.h> #include <WebCore/GCController.h> +#include <WebCore/GeolocationClient.h> +#include <WebCore/GeolocationClientMock.h> +#include <WebCore/GeolocationController.h> +#include <WebCore/GeolocationPosition.h> #include <WebCore/JSDOMWindow.h> #include <WebCore/Page.h> #include <WebCore/PageGroup.h> @@ -113,10 +118,52 @@ void InjectedBundle::removeAllVisitedLinks() PageGroup::removeAllVisitedLinks(); } +void InjectedBundle::overrideBoolPreferenceForTestRunner(WebPageGroupProxy* pageGroup, const String& preference, bool enabled) +{ + const HashSet<Page*>& pages = PageGroup::pageGroup(pageGroup->identifier())->pages(); + + // FIXME: Need an explicit way to set "WebKitTabToLinksPreferenceKey" directly in WebPage. + + // Map the names used in LayoutTests with the names used in WebCore::Settings and WebPreferencesStore. +#define FOR_EACH_OVERRIDE_BOOL_PREFERENCE(macro) \ + macro(WebKitAcceleratedCompositingEnabled, AcceleratedCompositingEnabled, acceleratedCompositingEnabled) \ + macro(WebKitCSSCustomFilterEnabled, CSSCustomFilterEnabled, cssCustomFilterEnabled) \ + macro(WebKitJavaEnabled, JavaEnabled, javaEnabled) \ + macro(WebKitJavaScriptEnabled, ScriptEnabled, javaScriptEnabled) \ + macro(WebKitLoadSiteIconsKey, LoadsSiteIconsIgnoringImageLoadingSetting, loadsSiteIconsIgnoringImageLoadingPreference) \ + macro(WebKitOfflineWebApplicationCacheEnabled, OfflineWebApplicationCacheEnabled, offlineWebApplicationCacheEnabled) \ + macro(WebKitPageCacheSupportsPluginsPreferenceKey, PageCacheSupportsPlugins, pageCacheSupportsPlugins) \ + macro(WebKitPluginsEnabled, PluginsEnabled, pluginsEnabled) \ + macro(WebKitUsesPageCachePreferenceKey, UsesPageCache, usesPageCache) \ + macro(WebKitWebAudioEnabled, WebAudioEnabled, webAudioEnabled) \ + macro(WebKitWebGLEnabled, WebGLEnabled, webGLEnabled) \ + macro(WebKitXSSAuditorEnabled, XSSAuditorEnabled, xssAuditorEnabled) + + if (preference == "WebKitAcceleratedCompositingEnabled") + enabled = enabled && LayerTreeHost::supportsAcceleratedCompositing(); + +#define OVERRIDE_PREFERENCE_AND_SET_IN_EXISTING_PAGES(TestRunnerName, SettingsName, WebPreferencesName) \ + if (preference == #TestRunnerName) { \ + WebPreferencesStore::overrideBoolValueForKey(WebPreferencesKey::WebPreferencesName##Key(), enabled); \ + for (HashSet<Page*>::iterator iter = pages.begin(); iter != pages.end(); ++iter) \ + (*iter)->settings()->set##SettingsName(enabled); \ + return; \ + } + + FOR_EACH_OVERRIDE_BOOL_PREFERENCE(OVERRIDE_PREFERENCE_AND_SET_IN_EXISTING_PAGES) + +#if ENABLE(WEB_SOCKETS) + OVERRIDE_PREFERENCE_AND_SET_IN_EXISTING_PAGES(WebKitHixie76WebSocketProtocolEnabled, UseHixie76WebSocketProtocol, hixie76WebSocketProtocolEnabled) +#endif + +#undef OVERRIDE_PREFERENCE_AND_SET_IN_EXISTING_PAGES +#undef FOR_EACH_OVERRIDE_BOOL_PREFERENCE +} + void InjectedBundle::overrideXSSAuditorEnabledForTestRunner(WebPageGroupProxy* pageGroup, bool enabled) { // Override the preference for all future pages. - WebPreferencesStore::overrideXSSAuditorEnabledForTestRunner(enabled); + WebPreferencesStore::overrideBoolValueForKey(WebPreferencesKey::xssAuditorEnabledKey(), enabled); // Change the setting for existing ones. const HashSet<Page*>& pages = PageGroup::pageGroup(pageGroup->identifier())->pages(); @@ -145,6 +192,15 @@ void InjectedBundle::setFrameFlatteningEnabled(WebPageGroupProxy* pageGroup, boo (*iter)->settings()->setFrameFlatteningEnabled(enabled); } +void InjectedBundle::setGeoLocationPermission(WebPageGroupProxy* pageGroup, bool enabled) +{ +#if ENABLE(CLIENT_BASED_GEOLOCATION) + const HashSet<Page*>& pages = PageGroup::pageGroup(pageGroup->identifier())->pages(); + for (HashSet<Page*>::iterator iter = pages.begin(); iter != pages.end(); ++iter) + static_cast<GeolocationClientMock*>((*iter)->geolocationController()->client())->setPermission(enabled); +#endif +} + void InjectedBundle::setJavaScriptCanAccessClipboard(WebPageGroupProxy* pageGroup, bool enabled) { const HashSet<Page*>& pages = PageGroup::pageGroup(pageGroup->identifier())->pages(); @@ -159,6 +215,14 @@ void InjectedBundle::setPrivateBrowsingEnabled(WebPageGroupProxy* pageGroup, boo (*iter)->settings()->setPrivateBrowsingEnabled(enabled); } +void InjectedBundle::setPopupBlockingEnabled(WebPageGroupProxy* pageGroup, bool enabled) +{ + const HashSet<Page*>& pages = PageGroup::pageGroup(pageGroup->identifier())->pages(); + HashSet<Page*>::const_iterator end = pages.end(); + for (HashSet<Page*>::const_iterator iter = pages.begin(); iter != end; ++iter) + (*iter)->settings()->setJavaScriptCanOpenWindowsAutomatically(!enabled); +} + void InjectedBundle::switchNetworkLoaderToNewTestingSession() { #if USE(CFURLSTORAGESESSIONS) diff --git a/Source/WebKit2/WebProcess/InjectedBundle/InjectedBundle.h b/Source/WebKit2/WebProcess/InjectedBundle/InjectedBundle.h index 6ff2cfa8e..d7498dff4 100644 --- a/Source/WebKit2/WebProcess/InjectedBundle/InjectedBundle.h +++ b/Source/WebKit2/WebProcess/InjectedBundle/InjectedBundle.h @@ -97,12 +97,15 @@ public: void setShouldTrackVisitedLinks(bool); void removeAllVisitedLinks(); void activateMacFontAscentHack(); + void overrideBoolPreferenceForTestRunner(WebPageGroupProxy*, const String& preference, bool enabled); void overrideXSSAuditorEnabledForTestRunner(WebPageGroupProxy* pageGroup, bool enabled); void setAllowUniversalAccessFromFileURLs(WebPageGroupProxy*, bool); void setAllowFileAccessFromFileURLs(WebPageGroupProxy*, bool); void setFrameFlatteningEnabled(WebPageGroupProxy*, bool); + void setGeoLocationPermission(WebPageGroupProxy*, bool); void setJavaScriptCanAccessClipboard(WebPageGroupProxy*, bool); void setPrivateBrowsingEnabled(WebPageGroupProxy*, bool); + void setPopupBlockingEnabled(WebPageGroupProxy*, bool); void switchNetworkLoaderToNewTestingSession(); void setAuthorAndUserStylesEnabled(WebPageGroupProxy*, bool); void addOriginAccessWhitelistEntry(const String&, const String&, const String&, bool); diff --git a/Source/WebKit2/WebProcess/InjectedBundle/InjectedBundleNavigationAction.cpp b/Source/WebKit2/WebProcess/InjectedBundle/InjectedBundleNavigationAction.cpp index 7a40ee6fb..428135481 100644 --- a/Source/WebKit2/WebProcess/InjectedBundle/InjectedBundleNavigationAction.cpp +++ b/Source/WebKit2/WebProcess/InjectedBundle/InjectedBundleNavigationAction.cpp @@ -86,10 +86,10 @@ PassRefPtr<InjectedBundleNavigationAction> InjectedBundleNavigationAction::creat } InjectedBundleNavigationAction::InjectedBundleNavigationAction(WebFrame* frame, const NavigationAction& navigationAction, PassRefPtr<FormState> prpFormState) + : m_navigationType(navigationAction.type()) + , m_modifiers(modifiersForNavigationAction(navigationAction)) + , m_mouseButton(WebMouseEvent::NoButton) { - m_navigationType = navigationAction.type(); - m_modifiers = modifiersForNavigationAction(navigationAction); - if (const MouseEvent* mouseEvent = mouseEventForNavigationAction(navigationAction)) { m_hitTestResult = InjectedBundleHitTestResult::create(frame->coreFrame()->eventHandler()->hitTestResultAtPoint(mouseEvent->absoluteLocation(), false)); m_mouseButton = mouseButtonForMouseEvent(mouseEvent); diff --git a/Source/WebKit2/WebProcess/Notifications/NotificationPermissionRequestManager.cpp b/Source/WebKit2/WebProcess/Notifications/NotificationPermissionRequestManager.cpp index 3eeaa5022..7d662f12d 100644 --- a/Source/WebKit2/WebProcess/Notifications/NotificationPermissionRequestManager.cpp +++ b/Source/WebKit2/WebProcess/Notifications/NotificationPermissionRequestManager.cpp @@ -32,8 +32,10 @@ #include "WebPageProxyMessages.h" #include "WebProcess.h" #include <WebCore/Notification.h> +#include <WebCore/Page.h> #include <WebCore/ScriptExecutionContext.h> #include <WebCore/SecurityOrigin.h> +#include <WebCore/Settings.h> using namespace WebCore; @@ -60,11 +62,14 @@ NotificationPermissionRequestManager::NotificationPermissionRequestManager(WebPa void NotificationPermissionRequestManager::startRequest(SecurityOrigin* origin, PassRefPtr<VoidCallback> callback) { #if ENABLE(NOTIFICATIONS) + if (permissionLevel(origin) != NotificationPresenter::PermissionNotAllowed) + return; + uint64_t requestID = generateRequestID(); m_originToIDMap.set(origin, requestID); m_idToOriginMap.set(requestID, origin); m_idToCallbackMap.set(requestID, callback); - m_page->send(Messages::WebPageProxy::RequestNotificationPermission(requestID, origin->databaseIdentifier())); + m_page->send(Messages::WebPageProxy::RequestNotificationPermission(requestID, origin->toString())); #else UNUSED_PARAM(origin); UNUSED_PARAM(callback); @@ -88,11 +93,10 @@ void NotificationPermissionRequestManager::cancelRequest(SecurityOrigin* origin) NotificationPresenter::Permission NotificationPermissionRequestManager::permissionLevel(SecurityOrigin* securityOrigin) { #if ENABLE(NOTIFICATIONS) - uint64_t permissionLevel; - WebProcess::shared().connection()->sendSync(Messages::WebNotificationManagerProxy::NotificationPermissionLevel(securityOrigin->databaseIdentifier()), - Messages::WebNotificationManagerProxy::NotificationPermissionLevel::Reply(permissionLevel), - 0); - return static_cast<NotificationPresenter::Permission>(permissionLevel); + if (!m_page->corePage()->settings()->notificationsEnabled()) + return NotificationPresenter::PermissionDenied; + + return WebProcess::shared().notificationManager().policyForOrigin(securityOrigin); #else UNUSED_PARAM(securityOrigin); return NotificationPresenter::PermissionDenied; diff --git a/Source/WebKit2/WebProcess/Notifications/WebNotificationManager.cpp b/Source/WebKit2/WebProcess/Notifications/WebNotificationManager.cpp index dfc30f5f3..0c865292d 100644 --- a/Source/WebKit2/WebProcess/Notifications/WebNotificationManager.cpp +++ b/Source/WebKit2/WebProcess/Notifications/WebNotificationManager.cpp @@ -34,8 +34,10 @@ #include "WebNotificationManagerProxyMessages.h" #include "WebPageProxyMessages.h" #include <WebCore/Notification.h> +#include <WebCore/Page.h> #include <WebCore/ScriptExecutionContext.h> #include <WebCore/SecurityOrigin.h> +#include <WebCore/Settings.h> #endif using namespace WebCore; @@ -64,17 +66,54 @@ void WebNotificationManager::didReceiveMessage(CoreIPC::Connection* connection, didReceiveWebNotificationManagerMessage(connection, messageID, arguments); } +void WebNotificationManager::initialize(const HashMap<String, bool>& permissions) +{ +#if ENABLE(NOTIFICATIONS) + m_permissionsMap = permissions; +#endif +} + +void WebNotificationManager::didUpdateNotificationDecision(const String& originString, bool allowed) +{ +#if ENABLE(NOTIFICATIONS) + m_permissionsMap.set(originString, allowed); +#endif +} + +void WebNotificationManager::didRemoveNotificationDecisions(const Vector<String>& originStrings) +{ +#if ENABLE(NOTIFICATIONS) + size_t count = originStrings.size(); + for (size_t i = 0; i < count; ++i) + m_permissionsMap.remove(originStrings[i]); +#endif +} + +NotificationPresenter::Permission WebNotificationManager::policyForOrigin(WebCore::SecurityOrigin *origin) const +{ +#if ENABLE(NOTIFICATIONS) + if (!origin) + return NotificationPresenter::PermissionNotAllowed; + + HashMap<String, bool>::const_iterator it = m_permissionsMap.find(origin->toString()); + if (it != m_permissionsMap.end()) + return it->second ? NotificationPresenter::PermissionAllowed : NotificationPresenter::PermissionDenied; +#endif + + return NotificationPresenter::PermissionNotAllowed; +} + bool WebNotificationManager::show(Notification* notification, WebPage* page) { #if ENABLE(NOTIFICATIONS) - if (!notification) + if (!notification || !page->corePage()->settings()->notificationsEnabled()) return true; uint64_t notificationID = generateNotificationID(); m_notificationMap.set(notification, notificationID); m_notificationIDMap.set(notificationID, notification); - m_process->connection()->send(Messages::WebPageProxy::ShowNotification(notification->contents().title, notification->contents().body, notification->scriptExecutionContext()->securityOrigin()->databaseIdentifier(), notificationID), page->pageID()); + m_process->connection()->send(Messages::WebPageProxy::ShowNotification(notification->contents().title, notification->contents().body, notification->scriptExecutionContext()->securityOrigin()->toString(), notificationID), page->pageID()); #endif return true; } @@ -82,7 +121,7 @@ bool WebNotificationManager::show(Notification* notification, WebPage* page) void WebNotificationManager::cancel(Notification* notification, WebPage* page) { #if ENABLE(NOTIFICATIONS) - if (!notification) + if (!notification || !page->corePage()->settings()->notificationsEnabled()) return; uint64_t notificationID = m_notificationMap.get(notification); diff --git a/Source/WebKit2/WebProcess/Notifications/WebNotificationManager.h b/Source/WebKit2/WebProcess/Notifications/WebNotificationManager.h index 3b32f0ade..61507394c 100644 --- a/Source/WebKit2/WebProcess/Notifications/WebNotificationManager.h +++ b/Source/WebKit2/WebProcess/Notifications/WebNotificationManager.h @@ -27,10 +27,12 @@ #define WebNotificationManager_h #include "MessageID.h" +#include <WebCore/NotificationPresenter.h> #include <wtf/HashMap.h> #include <wtf/Noncopyable.h> #include <wtf/RefPtr.h> #include <wtf/Vector.h> +#include <wtf/text/StringHash.h> namespace CoreIPC { class ArgumentDecoder; @@ -39,6 +41,7 @@ class Connection; namespace WebCore { class Notification; +class SecurityOrigin; } namespace WebKit { @@ -52,12 +55,17 @@ public: explicit WebNotificationManager(WebProcess*); ~WebNotificationManager(); + void initialize(const HashMap<String, bool>& permissions); + bool show(WebCore::Notification*, WebPage*); void cancel(WebCore::Notification*, WebPage*); // This callback comes from WebCore, not messaged from the UI process. void didDestroyNotification(WebCore::Notification*, WebPage*); void didReceiveMessage(CoreIPC::Connection*, CoreIPC::MessageID, CoreIPC::ArgumentDecoder*); + + // Looks in local cache for permission. If not found, returns DefaultDenied. + WebCore::NotificationPresenter::Permission policyForOrigin(WebCore::SecurityOrigin*) const; private: // Implemented in generated WebNotificationManagerMessageReceiver.cpp @@ -66,6 +74,8 @@ private: void didShowNotification(uint64_t notificationID); void didClickNotification(uint64_t notificationID); void didCloseNotifications(const Vector<uint64_t>& notificationIDs); + void didUpdateNotificationDecision(const String& originString, bool allowed); + void didRemoveNotificationDecisions(const Vector<String>& originStrings); WebProcess* m_process; @@ -75,6 +85,8 @@ private: typedef HashMap<uint64_t, RefPtr<WebCore::Notification> > NotificationIDMap; NotificationIDMap m_notificationIDMap; + + HashMap<String, bool> m_permissionsMap; #endif }; diff --git a/Source/WebKit2/WebProcess/Notifications/WebNotificationManager.messages.in b/Source/WebKit2/WebProcess/Notifications/WebNotificationManager.messages.in index 13d97ff7a..b88f26c9e 100644 --- a/Source/WebKit2/WebProcess/Notifications/WebNotificationManager.messages.in +++ b/Source/WebKit2/WebProcess/Notifications/WebNotificationManager.messages.in @@ -24,4 +24,6 @@ messages -> WebNotificationManager { DidShowNotification(uint64_t notificationID); DidClickNotification(uint64_t notificationID); DidCloseNotifications(Vector<uint64_t> notificationIDs); + DidUpdateNotificationDecision(WTF::String originString, bool allowed); + DidRemoveNotificationDecisions(Vector<WTF::String> originStrings); } diff --git a/Source/WebKit2/WebProcess/Plugins/Netscape/NPRuntimeObjectMap.cpp b/Source/WebKit2/WebProcess/Plugins/Netscape/NPRuntimeObjectMap.cpp index 5aadd13f4..b4657f95f 100644 --- a/Source/WebKit2/WebProcess/Plugins/Netscape/NPRuntimeObjectMap.cpp +++ b/Source/WebKit2/WebProcess/Plugins/Netscape/NPRuntimeObjectMap.cpp @@ -163,7 +163,7 @@ void NPRuntimeObjectMap::convertJSValueToNPVariant(ExecState* exec, JSValue valu } if (value.isString()) { - NPString npString = createNPString(value.toString(exec).utf8()); + NPString npString = createNPString(value.toString(exec)->value(exec).utf8()); STRINGN_TO_NPVARIANT(npString.UTF8Characters, npString.UTF8Length, variant); return; } diff --git a/Source/WebKit2/WebProcess/Plugins/Netscape/NPRuntimeObjectMap.h b/Source/WebKit2/WebProcess/Plugins/Netscape/NPRuntimeObjectMap.h index bef701bee..deffd5431 100644 --- a/Source/WebKit2/WebProcess/Plugins/Netscape/NPRuntimeObjectMap.h +++ b/Source/WebKit2/WebProcess/Plugins/Netscape/NPRuntimeObjectMap.h @@ -26,9 +26,7 @@ #ifndef NPJSObjectWrapperMap_h #define NPJSObjectWrapperMap_h - -#include "RunLoop.h" - +#include <WebCore/RunLoop.h> #include <heap/Weak.h> #include <wtf/Forward.h> #include <wtf/HashMap.h> @@ -98,7 +96,7 @@ private: HashMap<JSC::JSObject*, NPJSObject*> m_npJSObjects; HashMap<NPObject*, JSC::Weak<JSNPObject> > m_jsNPObjects; Vector<NPObject*> m_npObjectsToFinalize; - RunLoop::Timer<NPRuntimeObjectMap> m_finalizationTimer; + WebCore::RunLoop::Timer<NPRuntimeObjectMap> m_finalizationTimer; }; } // namespace WebKit diff --git a/Source/WebKit2/WebProcess/Plugins/Netscape/NetscapeBrowserFuncs.cpp b/Source/WebKit2/WebProcess/Plugins/Netscape/NetscapeBrowserFuncs.cpp index a8a806e01..e09ada40a 100644 --- a/Source/WebKit2/WebProcess/Plugins/Netscape/NetscapeBrowserFuncs.cpp +++ b/Source/WebKit2/WebProcess/Plugins/Netscape/NetscapeBrowserFuncs.cpp @@ -408,6 +408,9 @@ static const unsigned WKNVSupportsCompositingCoreAnimationPluginsBool = 74656; // Whether the browser expects a non-retained Core Animation layer. static const unsigned WKNVExpectsNonretainedLayer = 74657; +// Whether plug-in code is allowed to enter (arbitrary) sandbox for the process. +static const unsigned WKNVAllowedToEnterSandbox = 74658; + // The Core Animation render server port. static const unsigned WKNVCALayerRenderServerPort = 71879; @@ -495,6 +498,10 @@ static NPError NPN_GetValue(NPP npp, NPNVariable variable, void *value) break; } + case WKNVAllowedToEnterSandbox: + *(NPBool*)value = true; + break; + #ifndef NP_NO_QUICKDRAW case NPNVsupportsQuickDrawBool: // We don't support the QuickDraw drawing model. diff --git a/Source/WebKit2/WebProcess/Plugins/Netscape/NetscapePlugin.h b/Source/WebKit2/WebProcess/Plugins/Netscape/NetscapePlugin.h index 84541820c..adad2d015 100644 --- a/Source/WebKit2/WebProcess/Plugins/Netscape/NetscapePlugin.h +++ b/Source/WebKit2/WebProcess/Plugins/Netscape/NetscapePlugin.h @@ -28,10 +28,10 @@ #include "NetscapePluginModule.h" #include "Plugin.h" -#include "RunLoop.h" #include <WebCore/AffineTransform.h> #include <WebCore/GraphicsLayer.h> #include <WebCore/IntRect.h> +#include <WebCore/RunLoop.h> #include <wtf/HashMap.h> #include <wtf/text/CString.h> #include <wtf/text/StringHash.h> @@ -291,7 +291,7 @@ private: bool m_repeat; TimerFunc m_timerFunc; - RunLoop::Timer<Timer> m_timer; + WebCore::RunLoop::Timer<Timer> m_timer; }; typedef HashMap<unsigned, Timer*> TimerMap; TimerMap m_timers; @@ -332,7 +332,7 @@ private: // FIXME: It's a bit wasteful to have one null event timer per plug-in. // We should investigate having one per window. - RunLoop::Timer<NetscapePlugin> m_nullEventTimer; + WebCore::RunLoop::Timer<NetscapePlugin> m_nullEventTimer; NP_CGContext m_npCGContext; #endif #elif PLUGIN_ARCHITECTURE(WIN) diff --git a/Source/WebKit2/WebProcess/Plugins/Netscape/NetscapePluginStream.cpp b/Source/WebKit2/WebProcess/Plugins/Netscape/NetscapePluginStream.cpp index 23a83fe6d..5e496e306 100644 --- a/Source/WebKit2/WebProcess/Plugins/Netscape/NetscapePluginStream.cpp +++ b/Source/WebKit2/WebProcess/Plugins/Netscape/NetscapePluginStream.cpp @@ -28,6 +28,8 @@ #include "NetscapePlugin.h" #include <utility> +#include <wtf/PassOwnPtr.h> +#include <wtf/Vector.h> using namespace WebCore; using namespace std; diff --git a/Source/WebKit2/WebProcess/Plugins/Netscape/NetscapePluginStream.h b/Source/WebKit2/WebProcess/Plugins/Netscape/NetscapePluginStream.h index de26827fc..05873e4f4 100644 --- a/Source/WebKit2/WebProcess/Plugins/Netscape/NetscapePluginStream.h +++ b/Source/WebKit2/WebProcess/Plugins/Netscape/NetscapePluginStream.h @@ -26,8 +26,8 @@ #ifndef NetscapePluginStream_h #define NetscapePluginStream_h -#include "RunLoop.h" #include <WebCore/FileSystem.h> +#include <WebCore/RunLoop.h> #include <WebCore/npruntime_internal.h> #include <wtf/Forward.h> #include <wtf/PassRefPtr.h> @@ -36,7 +36,7 @@ #include <wtf/text/CString.h> namespace WebCore { - class KURL; +class KURL; } namespace WebKit { @@ -103,7 +103,7 @@ private: CString m_mimeType; CString m_headers; - RunLoop::Timer<NetscapePluginStream> m_deliveryDataTimer; + WebCore::RunLoop::Timer<NetscapePluginStream> m_deliveryDataTimer; OwnPtr< Vector<uint8_t> > m_deliveryData; bool m_stopStreamWhenDoneDelivering; }; diff --git a/Source/WebKit2/WebProcess/Plugins/PluginView.h b/Source/WebKit2/WebProcess/Plugins/PluginView.h index 9624ac954..cd6363a58 100644 --- a/Source/WebKit2/WebProcess/Plugins/PluginView.h +++ b/Source/WebKit2/WebProcess/Plugins/PluginView.h @@ -29,13 +29,12 @@ #include "NPRuntimeObjectMap.h" #include "Plugin.h" #include "PluginController.h" -#include "RunLoop.h" #include "WebFrame.h" - #include <WebCore/MediaCanStartListener.h> +#include <WebCore/PluginViewBase.h> #include <WebCore/ResourceError.h> #include <WebCore/ResourceResponse.h> -#include <WebCore/PluginViewBase.h> +#include <WebCore/RunLoop.h> #include <wtf/Deque.h> // FIXME: Eventually this should move to WebCore. @@ -180,7 +179,7 @@ private: // Pending URLRequests that the plug-in has made. Deque<RefPtr<URLRequest> > m_pendingURLRequests; - RunLoop::Timer<PluginView> m_pendingURLRequestsTimer; + WebCore::RunLoop::Timer<PluginView> m_pendingURLRequestsTimer; // Pending frame loads that the plug-in has made. typedef HashMap<RefPtr<WebFrame>, RefPtr<URLRequest> > FrameLoadMap; diff --git a/Source/WebKit2/WebProcess/WebConnectionToUIProcess.cpp b/Source/WebKit2/WebProcess/WebConnectionToUIProcess.cpp index 9a64add1c..5e7955d67 100644 --- a/Source/WebKit2/WebProcess/WebConnectionToUIProcess.cpp +++ b/Source/WebKit2/WebProcess/WebConnectionToUIProcess.cpp @@ -30,6 +30,8 @@ #include "WebConnectionMessageKinds.h" #include "WebProcess.h" +using namespace WebCore; + namespace WebKit { PassRefPtr<WebConnectionToUIProcess> WebConnectionToUIProcess::create(WebProcess* process, CoreIPC::Connection::Identifier connectionIdentifier, RunLoop* runLoop) diff --git a/Source/WebKit2/WebProcess/WebConnectionToUIProcess.h b/Source/WebKit2/WebProcess/WebConnectionToUIProcess.h index 1d9c96c80..42b9cd716 100644 --- a/Source/WebKit2/WebProcess/WebConnectionToUIProcess.h +++ b/Source/WebKit2/WebProcess/WebConnectionToUIProcess.h @@ -35,14 +35,14 @@ class WebProcess; class WebConnectionToUIProcess : public WebConnection, CoreIPC::Connection::Client { public: - static PassRefPtr<WebConnectionToUIProcess> create(WebProcess*, CoreIPC::Connection::Identifier, RunLoop*); + 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, RunLoop*); + WebConnectionToUIProcess(WebProcess*, CoreIPC::Connection::Identifier, WebCore::RunLoop*); // WebConnection virtual void postMessage(const String&, APIObject*); diff --git a/Source/WebKit2/WebProcess/WebCoreSupport/WebDragClient.h b/Source/WebKit2/WebProcess/WebCoreSupport/WebDragClient.h index f0109fddb..913eb6e56 100644 --- a/Source/WebKit2/WebProcess/WebCoreSupport/WebDragClient.h +++ b/Source/WebKit2/WebProcess/WebCoreSupport/WebDragClient.h @@ -29,13 +29,8 @@ #include <WebCore/DragClient.h> #if PLATFORM(MAC) -#ifdef __OBJC__ -@class WKPasteboardFilePromiseOwner; -@class WKPasteboardOwner; -#else -class WKPasteboardFilePromiseOwner; -class WKPasteboardOwner; -#endif +OBJC_CLASS WKPasteboardFilePromiseOwner; +OBJC_CLASS WKPasteboardOwner; #endif namespace WebKit { diff --git a/Source/WebKit2/WebProcess/WebCoreSupport/WebEditorClient.cpp b/Source/WebKit2/WebProcess/WebCoreSupport/WebEditorClient.cpp index 1e3986475..f22b26074 100644 --- a/Source/WebKit2/WebProcess/WebCoreSupport/WebEditorClient.cpp +++ b/Source/WebKit2/WebProcess/WebCoreSupport/WebEditorClient.cpp @@ -185,11 +185,6 @@ void WebEditorClient::respondToChangedSelection(Frame* frame) EditorState state = m_page->editorState(); -#if PLATFORM(QT) - if (Element* scope = frame->selection()->rootEditableElement()) - m_page->send(Messages::WebPageProxy::FocusEditableArea(state.microFocus, scope->getRect())); -#endif - m_page->send(Messages::WebPageProxy::EditorStateChanged(state)); #if PLATFORM(WIN) @@ -200,9 +195,11 @@ void WebEditorClient::respondToChangedSelection(Frame* frame) unsigned start; unsigned end; m_page->send(Messages::WebPageProxy::DidChangeCompositionSelection(frame->editor()->getCompositionSelection(start, end))); +#elif PLATFORM(GTK) + setSelectionPrimaryClipboardIfNeeded(frame); #endif } - + void WebEditorClient::didEndEditing() { DEFINE_STATIC_LOCAL(String, WebViewDidEndEditingNotification, ("WebViewDidEndEditingNotification")); @@ -279,7 +276,7 @@ void WebEditorClient::redo() m_page->sendSync(Messages::WebPageProxy::ExecuteUndoRedo(static_cast<uint32_t>(WebPageProxy::Redo)), Messages::WebPageProxy::ExecuteUndoRedo::Reply(result)); } -#if !PLATFORM(GTK) && !PLATFORM(MAC) +#if !PLATFORM(GTK) && !PLATFORM(MAC) && !PLATFORM(EFL) void WebEditorClient::handleKeyboardEvent(KeyboardEvent* event) { if (m_page->handleEditingKeyboardEvent(event)) diff --git a/Source/WebKit2/WebProcess/WebCoreSupport/WebEditorClient.h b/Source/WebKit2/WebProcess/WebCoreSupport/WebEditorClient.h index 666427598..8f262205b 100644 --- a/Source/WebKit2/WebProcess/WebCoreSupport/WebEditorClient.h +++ b/Source/WebKit2/WebProcess/WebCoreSupport/WebEditorClient.h @@ -121,6 +121,7 @@ private: #if PLATFORM(GTK) bool executePendingEditorCommands(WebCore::Frame*, Vector<WTF::String>, bool) OVERRIDE; void getEditorCommandsForKeyEvent(const WebCore::KeyboardEvent*, Vector<WTF::String>&) OVERRIDE; + void setSelectionPrimaryClipboardIfNeeded(WebCore::Frame*) OVERRIDE; #endif TextCheckerClient* textChecker() OVERRIDE { return this; } diff --git a/Source/WebKit2/WebProcess/WebCoreSupport/WebFrameLoaderClient.cpp b/Source/WebKit2/WebProcess/WebCoreSupport/WebFrameLoaderClient.cpp index 3d0e22205..5ddf23caa 100644 --- a/Source/WebKit2/WebProcess/WebCoreSupport/WebFrameLoaderClient.cpp +++ b/Source/WebKit2/WebProcess/WebCoreSupport/WebFrameLoaderClient.cpp @@ -552,6 +552,18 @@ void WebFrameLoaderClient::dispatchDidFirstVisuallyNonEmptyLayout() webPage->send(Messages::WebPageProxy::DidFirstVisuallyNonEmptyLayoutForFrame(m_frame->frameID(), InjectedBundleUserMessageEncoder(userData.get()))); } +void WebFrameLoaderClient::dispatchDidNewFirstVisuallyNonEmptyLayout() +{ + WebPage* webPage = m_frame->page(); + if (!webPage) + return; + + RefPtr<APIObject> userData; + + // Notify the UIProcess. + webPage->send(Messages::WebPageProxy::DidNewFirstVisuallyNonEmptyLayout(InjectedBundleUserMessageEncoder(userData.get()))); +} + void WebFrameLoaderClient::dispatchDidLayout() { WebPage* webPage = m_frame->page(); @@ -1372,6 +1384,11 @@ void WebFrameLoaderClient::dispatchDidClearWindowObjectInWorld(DOMWrapperWorld* return; webPage->injectedBundleLoaderClient().didClearWindowObjectForFrame(webPage, m_frame, world); + +#if PLATFORM(GTK) + // Ensure the accessibility hierarchy is updated. + webPage->updateAccessibilityTree(); +#endif } void WebFrameLoaderClient::documentElementAvailable() @@ -1439,12 +1456,6 @@ void WebFrameLoaderClient::didChangeScrollOffset() PassRefPtr<FrameNetworkingContext> WebFrameLoaderClient::createNetworkingContext() { RefPtr<WebFrameNetworkingContext> context = WebFrameNetworkingContext::create(m_frame); -#if PLATFORM(QT) - // We encapsulate the WebPage pointer as a property of the originating QObject. - QObject* originatingObject = context->originatingObject(); - ASSERT(originatingObject); - originatingObject->setProperty("PagePointer", QVariant::fromValue(static_cast<void*>(m_frame->page()))); -#endif return context.release(); } diff --git a/Source/WebKit2/WebProcess/WebCoreSupport/WebFrameLoaderClient.h b/Source/WebKit2/WebProcess/WebCoreSupport/WebFrameLoaderClient.h index fb783535e..a93ecee92 100644 --- a/Source/WebKit2/WebProcess/WebCoreSupport/WebFrameLoaderClient.h +++ b/Source/WebKit2/WebProcess/WebCoreSupport/WebFrameLoaderClient.h @@ -93,6 +93,7 @@ private: virtual void dispatchDidFirstLayout() OVERRIDE; virtual void dispatchDidFirstVisuallyNonEmptyLayout() OVERRIDE; + virtual void dispatchDidNewFirstVisuallyNonEmptyLayout() OVERRIDE; virtual void dispatchDidLayout() OVERRIDE; virtual WebCore::Frame* dispatchCreatePage(const WebCore::NavigationAction&) OVERRIDE; diff --git a/Source/WebKit2/WebProcess/WebCoreSupport/WebGraphicsLayer.cpp b/Source/WebKit2/WebProcess/WebCoreSupport/WebGraphicsLayer.cpp index 907d20c5c..14b86aea4 100644 --- a/Source/WebKit2/WebProcess/WebCoreSupport/WebGraphicsLayer.cpp +++ b/Source/WebKit2/WebProcess/WebCoreSupport/WebGraphicsLayer.cpp @@ -25,6 +25,7 @@ #include "Animation.h" #include "BackingStore.h" +#include "FloatQuad.h" #include "Frame.h" #include "FrameView.h" #include "GraphicsContext.h" @@ -41,8 +42,6 @@ using namespace WebKit; namespace WebCore { -static const float gTileDimension = 1024.0; - static HashMap<WebLayerID, WebGraphicsLayer*>& layerByIDMap() { static HashMap<WebLayerID, WebGraphicsLayer*> globalMap; @@ -70,8 +69,18 @@ void WebGraphicsLayer::notifyChange() client()->notifySyncRequired(this); } +void WebGraphicsLayer::notifyChangeRecursively() +{ + notifyChange(); + for (size_t i = 0; i < children().size(); ++i) + toWebGraphicsLayer(children()[i])->notifyChangeRecursively(); + if (replicaLayer()) + toWebGraphicsLayer(replicaLayer())->notifyChange(); +} + WebGraphicsLayer::WebGraphicsLayer(GraphicsLayerClient* client) : GraphicsLayer(client) + , m_maskTarget(0) , m_needsDisplay(false) , m_modified(true) , m_contentNeedsDisplay(false) @@ -107,7 +116,7 @@ bool WebGraphicsLayer::setChildren(const Vector<GraphicsLayer*>& children) return false; for (int i = 0; i < children.size(); ++i) { WebGraphicsLayer* child = toWebGraphicsLayer(children[i]); - child->setContentsScale(m_contentsScale); + child->setVisibleContentRectAndScale(m_pageVisibleRect, m_contentsScale); child->notifyChange(); } notifyChange(); @@ -117,7 +126,7 @@ bool WebGraphicsLayer::setChildren(const Vector<GraphicsLayer*>& children) void WebGraphicsLayer::addChild(GraphicsLayer* layer) { GraphicsLayer::addChild(layer); - toWebGraphicsLayer(layer)->setContentsScale(m_contentsScale); + toWebGraphicsLayer(layer)->setVisibleContentRectAndScale(m_pageVisibleRect, m_contentsScale); toWebGraphicsLayer(layer)->notifyChange(); notifyChange(); } @@ -125,7 +134,7 @@ void WebGraphicsLayer::addChild(GraphicsLayer* layer) void WebGraphicsLayer::addChildAtIndex(GraphicsLayer* layer, int index) { GraphicsLayer::addChildAtIndex(layer, index); - toWebGraphicsLayer(layer)->setContentsScale(m_contentsScale); + toWebGraphicsLayer(layer)->setVisibleContentRectAndScale(m_pageVisibleRect, m_contentsScale); toWebGraphicsLayer(layer)->notifyChange(); notifyChange(); } @@ -133,7 +142,7 @@ void WebGraphicsLayer::addChildAtIndex(GraphicsLayer* layer, int index) void WebGraphicsLayer::addChildAbove(GraphicsLayer* layer, GraphicsLayer* sibling) { GraphicsLayer::addChildAbove(layer, sibling); - toWebGraphicsLayer(layer)->setContentsScale(m_contentsScale); + toWebGraphicsLayer(layer)->setVisibleContentRectAndScale(m_pageVisibleRect, m_contentsScale); toWebGraphicsLayer(layer)->notifyChange(); notifyChange(); } @@ -141,7 +150,7 @@ void WebGraphicsLayer::addChildAbove(GraphicsLayer* layer, GraphicsLayer* siblin void WebGraphicsLayer::addChildBelow(GraphicsLayer* layer, GraphicsLayer* sibling) { GraphicsLayer::addChildBelow(layer, sibling); - toWebGraphicsLayer(layer)->setContentsScale(m_contentsScale); + toWebGraphicsLayer(layer)->setVisibleContentRectAndScale(m_pageVisibleRect, m_contentsScale); toWebGraphicsLayer(layer)->notifyChange(); notifyChange(); } @@ -153,7 +162,8 @@ bool WebGraphicsLayer::replaceChild(GraphicsLayer* oldChild, GraphicsLayer* newC return false; notifyChange(); toWebGraphicsLayer(oldChild)->notifyChange(); - toWebGraphicsLayer(newChild)->setContentsScale(m_contentsScale); + toWebGraphicsLayer(oldChild)->setLayerTreeTileClient(0); + toWebGraphicsLayer(newChild)->setVisibleContentRectAndScale(m_pageVisibleRect, m_contentsScale); toWebGraphicsLayer(newChild)->notifyChange(); return true; } @@ -165,6 +175,7 @@ void WebGraphicsLayer::removeFromParent() GraphicsLayer::removeFromParent(); notifyChange(); + setLayerTreeTileClient(0); } void WebGraphicsLayer::setPosition(const FloatPoint& p) @@ -173,7 +184,7 @@ void WebGraphicsLayer::setPosition(const FloatPoint& p) return; GraphicsLayer::setPosition(p); - notifyChange(); + notifyChangeRecursively(); } void WebGraphicsLayer::setAnchorPoint(const FloatPoint3D& p) @@ -182,7 +193,7 @@ void WebGraphicsLayer::setAnchorPoint(const FloatPoint3D& p) return; GraphicsLayer::setAnchorPoint(p); - notifyChange(); + notifyChangeRecursively(); } void WebGraphicsLayer::setSize(const FloatSize& size) @@ -192,7 +203,9 @@ void WebGraphicsLayer::setSize(const FloatSize& size) GraphicsLayer::setSize(size); setNeedsDisplay(); - notifyChange(); + if (maskLayer()) + maskLayer()->setSize(size); + notifyChangeRecursively(); } void WebGraphicsLayer::setTransform(const TransformationMatrix& t) @@ -201,7 +214,7 @@ void WebGraphicsLayer::setTransform(const TransformationMatrix& t) return; GraphicsLayer::setTransform(t); - notifyChange(); + notifyChangeRecursively(); } void WebGraphicsLayer::setChildrenTransform(const TransformationMatrix& t) @@ -210,7 +223,7 @@ void WebGraphicsLayer::setChildrenTransform(const TransformationMatrix& t) return; GraphicsLayer::setChildrenTransform(t); - notifyChange(); + notifyChangeRecursively(); } void WebGraphicsLayer::setPreserves3D(bool b) @@ -219,7 +232,7 @@ void WebGraphicsLayer::setPreserves3D(bool b) return; GraphicsLayer::setPreserves3D(b); - notifyChange(); + notifyChangeRecursively(); } void WebGraphicsLayer::setMasksToBounds(bool b) @@ -227,7 +240,7 @@ void WebGraphicsLayer::setMasksToBounds(bool b) if (masksToBounds() == b) return; GraphicsLayer::setMasksToBounds(b); - notifyChange(); + notifyChangeRecursively(); } void WebGraphicsLayer::setDrawsContent(bool b) @@ -294,9 +307,11 @@ bool WebGraphicsLayer::addAnimation(const KeyframeValueList& valueList, const In webAnimation.animation = Animation::create(anim); webAnimation.startTime = timeOffset; m_layerInfo.animations.append(webAnimation); + if (valueList.property() == AnimatedPropertyWebkitTransform) + m_transformAnimations.add(keyframesName); m_hasPendingAnimations = true; - notifyChange(); + notifyChangeRecursively(); return true; } @@ -317,6 +332,7 @@ void WebGraphicsLayer::removeAnimation(const String& animationName) webAnimation.name = animationName; webAnimation.operation = WebLayerAnimation::RemoveAnimation; m_layerInfo.animations.append(webAnimation); + m_transformAnimations.remove(animationName); notifyChange(); } @@ -354,14 +370,32 @@ void WebGraphicsLayer::setContentsToImage(Image* image) void WebGraphicsLayer::setMaskLayer(GraphicsLayer* layer) { + if (layer == maskLayer()) + return; + GraphicsLayer::setMaskLayer(layer); + + if (!layer) + return; + + layer->setSize(size()); + WebGraphicsLayer* webGraphicsLayer = toWebGraphicsLayer(layer); + webGraphicsLayer->setLayerTreeTileClient(layerTreeTileClient()); + webGraphicsLayer->setMaskTarget(this); + webGraphicsLayer->setVisibleContentRectAndScale(m_pageVisibleRect, m_contentsScale); + webGraphicsLayer->notifyChange(); notifyChange(); + } void WebGraphicsLayer::setReplicatedByLayer(GraphicsLayer* layer) { if (layer == replicaLayer()) return; + + if (layer) + toWebGraphicsLayer(layer)->setLayerTreeTileClient(layerTreeTileClient()); + GraphicsLayer::setReplicatedByLayer(layer); notifyChange(); } @@ -385,13 +419,16 @@ WebLayerID WebGraphicsLayer::id() const void WebGraphicsLayer::syncCompositingState(const FloatRect& rect) { + if (WebGraphicsLayer* mask = toWebGraphicsLayer(maskLayer())) + mask->syncCompositingStateForThisLayerOnly(); + + if (WebGraphicsLayer* replica = toWebGraphicsLayer(replicaLayer())) + replica->syncCompositingStateForThisLayerOnly(); + + syncCompositingStateForThisLayerOnly(); + for (size_t i = 0; i < children().size(); ++i) children()[i]->syncCompositingState(rect); - if (replicaLayer()) - replicaLayer()->syncCompositingState(rect); - if (maskLayer()) - maskLayer()->syncCompositingState(rect); - syncCompositingStateForThisLayerOnly(); } WebGraphicsLayer* toWebGraphicsLayer(GraphicsLayer* layer) @@ -409,16 +446,14 @@ void WebGraphicsLayer::syncCompositingStateForThisLayerOnly() if (!m_modified) return; + computeTransformedVisibleRect(); m_layerInfo.name = name(); m_layerInfo.anchorPoint = anchorPoint(); m_layerInfo.backfaceVisible = backfaceVisibility(); m_layerInfo.childrenTransform = childrenTransform(); m_layerInfo.contentsOpaque = contentsOpaque(); m_layerInfo.contentsRect = contentsRect(); - - // In the shadow layer tree we create in the UI process, layers with directly composited images are always considered to draw content. - // Otherwise, we'd have to check whether an layer with drawsContent==false has a directly composited image multiple times. - m_layerInfo.drawsContent = drawsContent() || m_image; + m_layerInfo.drawsContent = drawsContent(); m_layerInfo.mask = toWebLayerID(maskLayer()); m_layerInfo.masksToBounds = masksToBounds(); m_layerInfo.opacity = opacity(); @@ -452,24 +487,6 @@ void WebGraphicsLayer::tiledBackingStorePaintBegin() { } -void WebGraphicsLayer::setContentsScale(float scale) -{ - for (size_t i = 0; i < children().size(); ++i) { - WebGraphicsLayer* layer = toWebGraphicsLayer(this->children()[i]); - layer->setContentsScale(scale); - } - - m_contentsScale = scale; - if (m_mainBackingStore && m_mainBackingStore->contentsScale() == scale) - return; - - notifyChange(); - - m_previousBackingStore = m_mainBackingStore.release(); - m_mainBackingStore = adoptPtr(new TiledBackingStore(this, TiledBackingStoreRemoteTileBackend::create(this))); - m_mainBackingStore->setContentsScale(scale); -} - void WebGraphicsLayer::setRootLayer(bool isRoot) { m_layerInfo.isRootLayer = isRoot; @@ -481,11 +498,25 @@ void WebGraphicsLayer::setVisibleContentRectTrajectoryVector(const FloatPoint& t m_mainBackingStore->setVisibleRectTrajectoryVector(trajectoryVector); } -void WebGraphicsLayer::setVisibleContentRect(const IntRect& rect) +void WebGraphicsLayer::setVisibleContentRectAndScale(const IntRect& pageVisibleRect, float scale) { - m_visibleContentRect = rect; - notifyChange(); - m_mainBackingStore->adjustVisibleRect(); + if (m_pageVisibleRect == pageVisibleRect && m_contentsScale == scale) + return; + + m_pageVisibleRect = pageVisibleRect; + m_contentsScale = scale; + + if (!m_mainBackingStore || m_mainBackingStore->contentsScale() != scale) { + m_previousBackingStore = m_mainBackingStore.release(); + m_mainBackingStore = adoptPtr(new TiledBackingStore(this, TiledBackingStoreRemoteTileBackend::create(this))); + m_mainBackingStore->setContentsScale(scale); + } else + m_mainBackingStore->adjustVisibleRect(); + + if (maskLayer()) + toWebGraphicsLayer(maskLayer())->setVisibleContentRectAndScale(pageVisibleRect, scale); + for (size_t i = 0; i < children().size(); ++i) + toWebGraphicsLayer(children()[i])->setVisibleContentRectAndScale(pageVisibleRect, scale); } void WebGraphicsLayer::tiledBackingStorePaint(GraphicsContext* context, const IntRect& rect) @@ -511,14 +542,26 @@ bool WebGraphicsLayer::tiledBackingStoreUpdatesAllowed() const IntRect WebGraphicsLayer::tiledBackingStoreContentsRect() { - if (m_image) + if (!drawsContent()) return IntRect(); return IntRect(0, 0, size().width(), size().height()); } IntRect WebGraphicsLayer::tiledBackingStoreVisibleRect() { - return m_visibleContentRect; + // If this layer is part of an active transform animation, the visible rect might change, + // so we rather render the whole layer until some better optimization is available. + if (selfOrAncestorHasActiveTransformAnimations()) + return tiledBackingStoreContentsRect(); + + // Non-invertible layers are not visible. + if (!m_layerTransform.combined().isInvertible()) + return IntRect(); + + // Return a projection of the visible rect (surface coordinates) onto the layer's plane (layer coordinates). + // The resulting quad might be squewed and the visible rect is the bounding box of this quad, + // so it might spread further than the real visible area (and then even more amplified by the cover rect multiplier). + return m_layerTransform.combined().inverse().clampedBoundsOfProjectedQuad(FloatQuad(FloatRect(m_pageVisibleRect))); } Color WebGraphicsLayer::tiledBackingStoreBackgroundColor() const @@ -554,13 +597,23 @@ void WebGraphicsLayer::updateTileBuffersRecursively() WebGraphicsLayer* layer = toWebGraphicsLayer(this->children()[i]); layer->updateTileBuffersRecursively(); } + + if (WebGraphicsLayer* mask = toWebGraphicsLayer(maskLayer())) + mask->updateTileBuffersRecursively(); } WebLayerTreeTileClient* WebGraphicsLayer::layerTreeTileClient() const { if (m_layerTreeTileClient) return m_layerTreeTileClient; - WebGraphicsLayer* parent = toWebGraphicsLayer(this->parent()); + WebGraphicsLayer* parent; + if (this->replicatedLayer()) + parent = toWebGraphicsLayer(this->replicatedLayer()); + else if (this->maskTarget()) + parent = toWebGraphicsLayer(this->maskTarget()); + else + parent = toWebGraphicsLayer(this->parent()); + if (!parent) return 0; return parent->layerTreeTileClient(); @@ -589,6 +642,9 @@ void WebGraphicsLayer::purgeBackingStores() layer->purgeBackingStores(); } + if (WebGraphicsLayer* mask = toWebGraphicsLayer(maskLayer())) + mask->purgeBackingStores(); + if (m_mainBackingStore) m_mainBackingStore.clear(); @@ -605,6 +661,8 @@ void WebGraphicsLayer::recreateBackingStoreIfNeeded() WebGraphicsLayer* layer = toWebGraphicsLayer(this->children()[i]); layer->recreateBackingStoreIfNeeded(); } + if (WebGraphicsLayer* mask = toWebGraphicsLayer(maskLayer())) + mask->recreateBackingStoreIfNeeded(); if (!m_mainBackingStore) { m_mainBackingStore = adoptPtr(new TiledBackingStore(this, TiledBackingStoreRemoteTileBackend::create(this))); @@ -620,6 +678,10 @@ void WebGraphicsLayer::setLayerTreeTileClient(WebKit::WebLayerTreeTileClient* cl if (m_layerTreeTileClient == client) return; + if (WebGraphicsLayer* replica = toWebGraphicsLayer(replicaLayer())) + replica->setLayerTreeTileClient(client); + if (WebGraphicsLayer* mask = toWebGraphicsLayer(maskLayer())) + mask->setLayerTreeTileClient(client); for (size_t i = 0; i < children().size(); ++i) { WebGraphicsLayer* layer = toWebGraphicsLayer(this->children()[i]); layer->setLayerTreeTileClient(client); @@ -630,6 +692,20 @@ void WebGraphicsLayer::setLayerTreeTileClient(WebKit::WebLayerTreeTileClient* cl m_layerTreeTileClient->didDeleteLayer(id()); m_layerTreeTileClient = client; } + +void WebGraphicsLayer::computeTransformedVisibleRect() +{ + // FIXME: Consider transform animations in the visible rect calculation. + m_layerTransform.setLocalTransform(transform()); + m_layerTransform.setPosition(position()); + m_layerTransform.setAnchorPoint(anchorPoint()); + m_layerTransform.setSize(size()); + m_layerTransform.setFlattening(!preserves3D()); + m_layerTransform.setChildrenTransform(childrenTransform()); + m_layerTransform.combineTransforms(parent() ? toWebGraphicsLayer(parent())->m_layerTransform.combinedForChildren() : TransformationMatrix()); + // The combined transform will be used in tiledBackingStoreVisibleRect. + m_mainBackingStore->adjustVisibleRect(); +} #endif static PassOwnPtr<GraphicsLayer> createWebGraphicsLayer(GraphicsLayerClient* client) @@ -642,5 +718,16 @@ void WebGraphicsLayer::initFactory() GraphicsLayer::setGraphicsLayerFactory(createWebGraphicsLayer); } +bool WebGraphicsLayer::selfOrAncestorHasActiveTransformAnimations() const +{ + if (!m_transformAnimations.isEmpty()) + return true; + + if (parent()) + return toWebGraphicsLayer(parent())->selfOrAncestorHasActiveTransformAnimations(); + + return false; +} + } #endif diff --git a/Source/WebKit2/WebProcess/WebCoreSupport/WebGraphicsLayer.h b/Source/WebKit2/WebProcess/WebCoreSupport/WebGraphicsLayer.h index 361fcb286..0b50763b7 100644 --- a/Source/WebKit2/WebProcess/WebCoreSupport/WebGraphicsLayer.h +++ b/Source/WebKit2/WebProcess/WebCoreSupport/WebGraphicsLayer.h @@ -25,7 +25,7 @@ #include "GraphicsLayer.h" #include "Image.h" #include "IntSize.h" -#include "RunLoop.h" +#include "LayerTransform.h" #include "ShareableBitmap.h" #include "TiledBackingStore.h" #include "TiledBackingStoreClient.h" @@ -34,6 +34,8 @@ #include "UpdateInfo.h" #include "WebLayerTreeInfo.h" #include "WebProcess.h" +#include <WebCore/RunLoop.h> +#include <wtf/text/StringHash.h> #if USE(ACCELERATED_COMPOSITING) @@ -46,7 +48,7 @@ public: virtual void updateTile(WebLayerID, int tileID, const UpdateInfo&) = 0; virtual void removeTile(WebLayerID, int tileID) = 0; virtual bool layerTreeTileUpdatesAllowed() const = 0; - virtual int64_t adoptImageBackingStore(Image*) = 0; + virtual int64_t adoptImageBackingStore(WebCore::Image*) = 0; virtual void releaseImageBackingStore(int64_t) = 0; virtual void didSyncCompositingStateForLayer(const WebLayerInfo&) = 0; virtual void didDeleteLayer(WebLayerID) = 0; @@ -94,7 +96,7 @@ public: void setNeedsDisplay(); void setNeedsDisplayInRect(const FloatRect&); void setContentsNeedsDisplay(); - void setVisibleContentRect(const IntRect&); + void setVisibleContentRectAndScale(const IntRect&, float scale); void setVisibleContentRectTrajectoryVector(const FloatPoint&); virtual void syncCompositingState(const FloatRect&); virtual void syncCompositingStateForThisLayerOnly(); @@ -107,6 +109,9 @@ public: Image* image() { return m_image.get(); } void notifyAnimationStarted(double); + GraphicsLayer* maskTarget() const { return m_maskTarget; } + void setMaskTarget(GraphicsLayer* layer) { m_maskTarget = layer; } + static void initFactory(); #if USE(TILED_BACKING_STORE) @@ -129,7 +134,6 @@ public: bool isReadyForTileBufferSwap() const; void updateTileBuffersRecursively(); - void setContentsScale(float); void updateContentBuffers(); void purgeBackingStores(); void recreateBackingStoreIfNeeded(); @@ -137,10 +141,11 @@ public: private: WebKit::WebLayerInfo m_layerInfo; - WebKit::WebLayerTreeTileClient* m_layerTileClient; RefPtr<Image> m_image; + GraphicsLayer* m_maskTarget; FloatRect m_needsDisplayRect; - IntRect m_visibleContentRect; + IntRect m_pageVisibleRect; + LayerTransform m_layerTransform; bool m_needsDisplay : 1; bool m_modified : 1; bool m_contentNeedsDisplay : 1; @@ -148,8 +153,14 @@ private: bool m_inUpdateMode : 2; void notifyChange(); + void notifyChangeRecursively(); + HashSet<String> m_transformAnimations; + + bool selfOrAncestorHasActiveTransformAnimations() const; #if USE(TILED_BACKING_STORE) + void computeTransformedVisibleRect(); + WebKit::WebLayerTreeTileClient* m_layerTreeTileClient; OwnPtr<WebCore::TiledBackingStore> m_mainBackingStore; OwnPtr<WebCore::TiledBackingStore> m_previousBackingStore; diff --git a/Source/WebKit2/WebProcess/WebCoreSupport/gtk/WebEditorClientGtk.cpp b/Source/WebKit2/WebProcess/WebCoreSupport/gtk/WebEditorClientGtk.cpp index 964a395c9..f59e69700 100644 --- a/Source/WebKit2/WebProcess/WebCoreSupport/gtk/WebEditorClientGtk.cpp +++ b/Source/WebKit2/WebProcess/WebCoreSupport/gtk/WebEditorClientGtk.cpp @@ -25,7 +25,9 @@ #include "WebPage.h" #include "WebPageProxyMessages.h" #include "WebProcess.h" +#include <WebCore/DataObjectGtk.h> #include <WebCore/KeyboardEvent.h> +#include <WebCore/PasteboardHelper.h> #include <WebCore/NotImplemented.h> using namespace WebCore; @@ -127,4 +129,38 @@ void WebEditorClient::handleInputMethodKeydown(KeyboardEvent*) notImplemented(); } +#if PLATFORM(X11) +static Frame* frameSettingClipboard; +static void collapseSelection(GtkClipboard* clipboard, Frame* frame) +{ + if (frameSettingClipboard && frameSettingClipboard == frame) + return; + + // Collapse the selection without clearing it. + ASSERT(frame); + frame->selection()->setBase(frame->selection()->extent(), frame->selection()->affinity()); +} +#endif + +void WebEditorClient::setSelectionPrimaryClipboardIfNeeded(Frame* frame) +{ +#if PLATFORM(X11) + GtkClipboard* clipboard = PasteboardHelper::defaultPasteboardHelper()->getPrimarySelectionClipboard(frame); + DataObjectGtk* dataObject = DataObjectGtk::forClipboard(clipboard); + + if (!frame->selection()->isRange()) + return; + + dataObject->clearAll(); + dataObject->setRange(frame->selection()->toNormalizedRange()); + + frameSettingClipboard = frame; + GClosure* callback = g_cclosure_new(G_CALLBACK(collapseSelection), frame, 0); + g_closure_set_marshal(callback, g_cclosure_marshal_VOID__VOID); + PasteboardHelper::defaultPasteboardHelper()->writeClipboardContents(clipboard, PasteboardHelper::DoNotIncludeSmartPaste, callback); + frameSettingClipboard = 0; +#endif +} + + } diff --git a/Source/WebKit2/WebProcess/WebCoreSupport/mac/WebSystemInterface.mm b/Source/WebKit2/WebProcess/WebCoreSupport/mac/WebSystemInterface.mm index 29c4ac3ee..c40a68ab8 100644 --- a/Source/WebKit2/WebProcess/WebCoreSupport/mac/WebSystemInterface.mm +++ b/Source/WebKit2/WebProcess/WebCoreSupport/mac/WebSystemInterface.mm @@ -156,6 +156,7 @@ void InitWebCoreSystemInterface(void) #if !defined(BUILDING_ON_SNOW_LEOPARD) && !defined(BUILDING_ON_LION) INIT(GetMacOSXVersionString); + INIT(ExecutableWasLinkedOnOrBeforeLion); #endif }); diff --git a/Source/WebKit2/WebProcess/WebPage/DecoderAdapter.cpp b/Source/WebKit2/WebProcess/WebPage/DecoderAdapter.cpp index 7c93dae7f..19083d6ad 100644 --- a/Source/WebKit2/WebProcess/WebPage/DecoderAdapter.cpp +++ b/Source/WebKit2/WebProcess/WebPage/DecoderAdapter.cpp @@ -28,6 +28,7 @@ #include "DataReference.h" #include "WebCoreArgumentCoders.h" +#include <wtf/text/WTFString.h> namespace WebKit { @@ -83,7 +84,43 @@ bool DecoderAdapter::decodeDouble(double& value) bool DecoderAdapter::decodeString(String& value) { - return m_decoder.decode(value); + // This mimics the CoreIPC binary encoding of Strings prior to r88886. + // Whenever the CoreIPC binary encoding changes, we'll have to "undo" the changes here. + // FIXME: We shouldn't use the CoreIPC binary encoding format for history, + // and we should come up with a migration strategy so we can actually bump the version number + // without breaking encoding/decoding of the history tree. + + uint32_t length; + if (!m_decoder.decode(length)) + return false; + + if (length == std::numeric_limits<uint32_t>::max()) { + // This is the null string. + value = String(); + return true; + } + + uint64_t lengthInBytes; + if (!m_decoder.decode(lengthInBytes)) + return false; + + if (lengthInBytes % sizeof(UChar) || lengthInBytes / sizeof(UChar) != length) { + m_decoder.markInvalid(); + return false; + } + + if (!m_decoder.bufferIsLargeEnoughToContain<UChar>(length)) { + m_decoder.markInvalid(); + return false; + } + + UChar* buffer; + String string = String::createUninitialized(length, buffer); + if (!m_decoder.decodeFixedLengthData(reinterpret_cast<uint8_t*>(buffer), length * sizeof(UChar), __alignof(UChar))) + return false; + + value = string; + return true; } } diff --git a/Source/WebKit2/WebProcess/WebPage/DrawingAreaImpl.cpp b/Source/WebKit2/WebProcess/WebPage/DrawingAreaImpl.cpp index e281d3652..3ad27e7af 100644 --- a/Source/WebKit2/WebProcess/WebPage/DrawingAreaImpl.cpp +++ b/Source/WebKit2/WebProcess/WebPage/DrawingAreaImpl.cpp @@ -68,7 +68,7 @@ DrawingAreaImpl::DrawingAreaImpl(WebPage* webPage, const WebPageCreationParamete , m_displayTimer(WebProcess::shared().runLoop(), this, &DrawingAreaImpl::displayTimerFired) , m_exitCompositingTimer(WebProcess::shared().runLoop(), this, &DrawingAreaImpl::exitAcceleratedCompositingMode) { - if (webPage->corePage()->settings()->acceleratedDrawingEnabled()) + if (webPage->corePage()->settings()->acceleratedDrawingEnabled() || webPage->corePage()->settings()->forceCompositingMode()) m_alwaysUseCompositing = true; if (m_alwaysUseCompositing) diff --git a/Source/WebKit2/WebProcess/WebPage/DrawingAreaImpl.h b/Source/WebKit2/WebProcess/WebPage/DrawingAreaImpl.h index 0dabf603a..28c8ce68c 100644 --- a/Source/WebKit2/WebProcess/WebPage/DrawingAreaImpl.h +++ b/Source/WebKit2/WebProcess/WebPage/DrawingAreaImpl.h @@ -28,8 +28,8 @@ #include "DrawingArea.h" #include "LayerTreeHost.h" -#include "RunLoop.h" #include <WebCore/Region.h> +#include <WebCore/RunLoop.h> namespace WebCore { class GraphicsContext; @@ -131,8 +131,8 @@ private: bool m_isPaintingSuspended; bool m_alwaysUseCompositing; - RunLoop::Timer<DrawingAreaImpl> m_displayTimer; - RunLoop::Timer<DrawingAreaImpl> m_exitCompositingTimer; + WebCore::RunLoop::Timer<DrawingAreaImpl> m_displayTimer; + WebCore::RunLoop::Timer<DrawingAreaImpl> m_exitCompositingTimer; // The layer tree host that handles accelerated compositing. RefPtr<LayerTreeHost> m_layerTreeHost; diff --git a/Source/WebKit2/WebProcess/WebPage/EncoderAdapter.cpp b/Source/WebKit2/WebProcess/WebPage/EncoderAdapter.cpp index 547b68d73..1f0e13c71 100644 --- a/Source/WebKit2/WebProcess/WebPage/EncoderAdapter.cpp +++ b/Source/WebKit2/WebProcess/WebPage/EncoderAdapter.cpp @@ -28,6 +28,7 @@ #include "DataReference.h" #include "WebCoreArgumentCoders.h" +#include <wtf/text/WTFString.h> namespace WebKit { @@ -83,7 +84,24 @@ void EncoderAdapter::encodeDouble(double value) void EncoderAdapter::encodeString(const String& value) { - m_encoder->encode(value); + // This mimics the CoreIPC binary encoding of Strings prior to r88886. + // Whenever the CoreIPC binary encoding changes, we'll have to "undo" the changes here. + // FIXME: We shouldn't use the CoreIPC binary encoding format for history, + // and we should come up with a migration strategy so we can actually bump the version number + // without breaking encoding/decoding of the history tree. + + // Special case the null string. + if (value.isNull()) { + m_encoder->encodeUInt32(std::numeric_limits<uint32_t>::max()); + return; + } + + uint32_t length = value.length(); + m_encoder->encode(length); + + uint64_t lengthInBytes = length * sizeof(UChar); + m_encoder->encode(lengthInBytes); + m_encoder->encodeFixedLengthData(reinterpret_cast<const uint8_t*>(value.characters()), length * sizeof(UChar), __alignof(UChar)); } } diff --git a/Source/WebKit2/WebProcess/WebPage/EventDispatcher.cpp b/Source/WebKit2/WebProcess/WebPage/EventDispatcher.cpp index 1a91d8e3c..3c2e73eca 100644 --- a/Source/WebKit2/WebProcess/WebPage/EventDispatcher.cpp +++ b/Source/WebKit2/WebProcess/WebPage/EventDispatcher.cpp @@ -26,13 +26,13 @@ #include "config.h" #include "EventDispatcher.h" -#include "RunLoop.h" #include "WebEvent.h" #include "WebEventConversion.h" #include "WebPage.h" #include "WebPageProxyMessages.h" #include "WebProcess.h" #include <WebCore/Page.h> +#include <WebCore/RunLoop.h> #include <wtf/MainThread.h> #if ENABLE(THREADED_SCROLLING) diff --git a/Source/WebKit2/WebProcess/WebPage/FindController.cpp b/Source/WebKit2/WebProcess/WebPage/FindController.cpp index 9bdd80bb9..10cfdfc83 100644 --- a/Source/WebKit2/WebProcess/WebPage/FindController.cpp +++ b/Source/WebKit2/WebProcess/WebPage/FindController.cpp @@ -111,10 +111,12 @@ void FindController::findString(const String& string, FindOptions options, unsig shouldShowOverlay = options & FindOptionsShowOverlay; if (shouldShowOverlay) { + bool shouldShowHighlight = options & FindOptionsShowHighlight; + if (maxMatchCount == numeric_limits<unsigned>::max()) --maxMatchCount; - unsigned matchCount = m_webPage->corePage()->markAllMatchesForText(string, core(options), false, maxMatchCount + 1); + unsigned matchCount = m_webPage->corePage()->markAllMatchesForText(string, core(options), shouldShowHighlight, maxMatchCount + 1); // Check if we have more matches than allowed. if (matchCount > maxMatchCount) { diff --git a/Source/WebKit2/WebProcess/WebPage/LayerTreeHost.messages.in b/Source/WebKit2/WebProcess/WebPage/LayerTreeHost.messages.in index d2e9c384e..4ee1cc3b4 100644 --- a/Source/WebKit2/WebProcess/WebPage/LayerTreeHost.messages.in +++ b/Source/WebKit2/WebProcess/WebPage/LayerTreeHost.messages.in @@ -20,7 +20,6 @@ #if USE(TILED_BACKING_STORE) messages -> LayerTreeHost { - SetVisibleContentRectForLayer(int layerID, WebCore::IntRect visibleContentRect) SetVisibleContentRectTrajectoryVector(WebCore::FloatPoint trajectoryVectory) SetVisibleContentRectAndScale(WebCore::IntRect contentRect, float scale) RenderNextFrame() diff --git a/Source/WebKit2/WebProcess/WebPage/PageOverlay.h b/Source/WebKit2/WebProcess/WebPage/PageOverlay.h index 1f61cebe9..949767806 100644 --- a/Source/WebKit2/WebProcess/WebPage/PageOverlay.h +++ b/Source/WebKit2/WebProcess/WebPage/PageOverlay.h @@ -27,7 +27,7 @@ #define PageOverlay_h #include "APIObject.h" -#include "RunLoop.h" +#include <WebCore/RunLoop.h> #include <wtf/PassRefPtr.h> namespace WebCore { @@ -86,7 +86,7 @@ private: Client* m_client; WebPage* m_webPage; - RunLoop::Timer<PageOverlay> m_fadeAnimationTimer; + WebCore::RunLoop::Timer<PageOverlay> m_fadeAnimationTimer; double m_fadeAnimationStartTime; double m_fadeAnimationDuration; diff --git a/Source/WebKit2/WebProcess/WebPage/TapHighlightController.cpp b/Source/WebKit2/WebProcess/WebPage/TapHighlightController.cpp new file mode 100644 index 000000000..725324703 --- /dev/null +++ b/Source/WebKit2/WebProcess/WebPage/TapHighlightController.cpp @@ -0,0 +1,121 @@ +/* + * Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies) + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Library General Public + * License as published by the Free Software Foundation; either + * version 2 of the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Library General Public License for more details. + * + * You should have received a copy of the GNU Library General Public License + * along with this program; see the file COPYING.LIB. If not, write to + * the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, + * Boston, MA 02110-1301, USA. + * + */ + +#include "config.h" +#include "TapHighlightController.h" + +#if ENABLE(TOUCH_EVENTS) + +#include "ShareableBitmap.h" +#include "WKPage.h" +#include "WebCoreArgumentCoders.h" +#include "WebPage.h" +#include "WebPageProxyMessages.h" +#include "WebProcess.h" +#include <WebCore/FocusController.h> +#include <WebCore/Frame.h> +#include <WebCore/FrameView.h> +#include <WebCore/GestureTapHighlighter.h> +#include <WebCore/GraphicsContext.h> +#include <WebCore/Page.h> + +#include <WebCore/RenderObject.h> + +using namespace std; +using namespace WebCore; + +namespace WebKit { + +TapHighlightController::TapHighlightController(WebPage* webPage) + : m_webPage(webPage) + , m_overlay(0) +{ +} + +TapHighlightController::~TapHighlightController() +{ +} + +void TapHighlightController::highlight(Node* node) +{ + ASSERT(node); + + m_path = GestureTapHighlighter::pathForNodeHighlight(node); + m_color = node->renderer()->style()->tapHighlightColor(); + + if (!m_overlay) { + RefPtr<PageOverlay> overlay = PageOverlay::create(this); + m_overlay = overlay.get(); + m_webPage->installPageOverlay(overlay.release()); + } else + m_overlay->setNeedsDisplay(); +} + +void TapHighlightController::hideHighlight() +{ + if (m_overlay) + m_webPage->uninstallPageOverlay(m_overlay, /* fadeout */ true); +} + +void TapHighlightController::pageOverlayDestroyed(PageOverlay*) +{ +} + +void TapHighlightController::willMoveToWebPage(PageOverlay*, WebPage* webPage) +{ + if (webPage) + return; + + // The page overlay is moving away from the web page, reset it. + ASSERT(m_overlay); + m_overlay = 0; +} + +void TapHighlightController::didMoveToWebPage(PageOverlay*, WebPage*) +{ +} + +static Color highlightColor(Color baseColor, float fractionFadedIn) +{ + return Color(baseColor.red(), baseColor.green(), baseColor.blue(), int(baseColor.alpha() * fractionFadedIn)); +} + +void TapHighlightController::drawRect(PageOverlay* pageOverlay, GraphicsContext& context, const IntRect& dirtyRect) +{ + if (m_path.isEmpty()) + return; + + float fractionFadedIn = pageOverlay->fractionFadedIn(); + + { + GraphicsContextStateSaver stateSaver(context); + context.setFillColor(highlightColor(m_color, fractionFadedIn), ColorSpaceSRGB); + context.fillPath(m_path); + } +} + +bool TapHighlightController::mouseEvent(PageOverlay*, const WebMouseEvent&) +{ + return false; +} + +} // namespace WebKit + +#endif // ENABLE(TOUCH_EVENTS) diff --git a/Source/WebKit2/WebProcess/WebPage/TapHighlightController.h b/Source/WebKit2/WebProcess/WebPage/TapHighlightController.h new file mode 100644 index 000000000..cb20858c6 --- /dev/null +++ b/Source/WebKit2/WebProcess/WebPage/TapHighlightController.h @@ -0,0 +1,73 @@ +/* + * Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies) + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Library General Public + * License as published by the Free Software Foundation; either + * version 2 of the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Library General Public License for more details. + * + * You should have received a copy of the GNU Library General Public License + * along with this program; see the file COPYING.LIB. If not, write to + * the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, + * Boston, MA 02110-1301, USA. + * + */ + +#ifndef TapHighlightController_h +#define TapHighlightController_h + +#if ENABLE(TOUCH_EVENTS) + +#include "PageOverlay.h" +#include <WebCore/Color.h> +#include <WebCore/Path.h> +#include <wtf/Forward.h> +#include <wtf/Noncopyable.h> +#include <wtf/Vector.h> + +namespace WebCore { +class Frame; +class IntRect; +class Node; +} + +namespace WebKit { + +class WebPage; + +class TapHighlightController : private PageOverlay::Client { + WTF_MAKE_NONCOPYABLE(TapHighlightController); + +public: + explicit TapHighlightController(WebPage*); + virtual ~TapHighlightController(); + + void highlight(WebCore::Node*); + void hideHighlight(); + +private: + // PageOverlay::Client. + virtual void pageOverlayDestroyed(PageOverlay*); + virtual void willMoveToWebPage(PageOverlay*, WebPage*); + virtual void didMoveToWebPage(PageOverlay*, WebPage*); + virtual bool mouseEvent(PageOverlay*, const WebMouseEvent&); + virtual void drawRect(PageOverlay*, WebCore::GraphicsContext&, const WebCore::IntRect& dirtyRect); + +private: + WebPage* m_webPage; + PageOverlay* m_overlay; + + WebCore::Path m_path; + WebCore::Color m_color; +}; + +} // namespace WebKit + +#endif // ENABLE(TOUCH_EVENTS) + +#endif // TapHighlightController_h diff --git a/Source/WebKit2/WebProcess/WebPage/TiledBackingStoreRemoteTile.cpp b/Source/WebKit2/WebProcess/WebPage/TiledBackingStoreRemoteTile.cpp index 4140e7279..7cea0b426 100644 --- a/Source/WebKit2/WebProcess/WebPage/TiledBackingStoreRemoteTile.cpp +++ b/Source/WebKit2/WebProcess/WebPage/TiledBackingStoreRemoteTile.cpp @@ -88,6 +88,11 @@ Vector<IntRect> TiledBackingStoreRemoteTile::updateBackBuffer() OwnPtr<GraphicsContext> graphicsContext(bitmap->createGraphicsContext()); graphicsContext->drawImageBuffer(m_localBuffer.get(), ColorSpaceDeviceRGB, IntPoint(0, 0)); +#if PLATFORM(QT) + // Qt uses BGRA interally, we swizzle to RGBA for OpenGL. + bitmap->swizzleRGB(); +#endif + UpdateInfo updateInfo; updateInfo.updateRectBounds = m_rect; updateInfo.updateScaleFactor = m_tiledBackingStore->contentsScale(); diff --git a/Source/WebKit2/WebProcess/WebPage/WebFrame.cpp b/Source/WebKit2/WebProcess/WebPage/WebFrame.cpp index b32543eee..43f443829 100644 --- a/Source/WebKit2/WebProcess/WebPage/WebFrame.cpp +++ b/Source/WebKit2/WebProcess/WebPage/WebFrame.cpp @@ -357,6 +357,14 @@ String WebFrame::innerText() const return m_coreFrame->document()->documentElement()->innerText(); } +WebFrame* WebFrame::parentFrame() const +{ + if (!m_coreFrame || !m_coreFrame->ownerElement() || !m_coreFrame->ownerElement()->document()) + return 0; + + return static_cast<WebFrameLoaderClient*>(m_coreFrame->ownerElement()->document()->frame()->loader()->client())->webFrame(); +} + PassRefPtr<ImmutableArray> WebFrame::childFrames() { if (!m_coreFrame) diff --git a/Source/WebKit2/WebProcess/WebPage/WebFrame.h b/Source/WebKit2/WebProcess/WebPage/WebFrame.h index 29ced42de..29536c27a 100644 --- a/Source/WebKit2/WebProcess/WebPage/WebFrame.h +++ b/Source/WebKit2/WebProcess/WebPage/WebFrame.h @@ -86,6 +86,7 @@ public: String url() const; String innerText() const; bool isFrameSet() const; + WebFrame* parentFrame() const; PassRefPtr<ImmutableArray> childFrames(); JSValueRef computedStyleIncludingVisitedInfo(JSObjectRef element); JSGlobalContextRef jsContext(); diff --git a/Source/WebKit2/WebProcess/WebPage/WebPage.cpp b/Source/WebKit2/WebProcess/WebPage/WebPage.cpp index 660f6f99c..3b9a487e4 100644 --- a/Source/WebKit2/WebProcess/WebPage/WebPage.cpp +++ b/Source/WebKit2/WebProcess/WebPage/WebPage.cpp @@ -40,7 +40,6 @@ #include "PluginProxy.h" #include "PluginView.h" #include "PrintInfo.h" -#include "RunLoop.h" #include "SessionState.h" #include "ShareableBitmap.h" #include "WebBackForwardList.h" @@ -90,6 +89,7 @@ #include <WebCore/FrameLoaderTypes.h> #include <WebCore/FrameView.h> #include <WebCore/HTMLFormElement.h> +#include <WebCore/HTMLInputElement.h> #include <WebCore/HistoryItem.h> #include <WebCore/KeyboardEvent.h> #include <WebCore/MouseEvent.h> @@ -103,6 +103,7 @@ #include <WebCore/RenderView.h> #include <WebCore/ReplaceSelectionCommand.h> #include <WebCore/ResourceRequest.h> +#include <WebCore/RunLoop.h> #include <WebCore/SchemeRegistry.h> #include <WebCore/ScriptValue.h> #include <WebCore/SerializedScriptValue.h> @@ -133,7 +134,9 @@ #endif #if PLATFORM(GTK) +#include <gtk/gtk.h> #include "DataObjectGtk.h" +#include "WebPrintOperationGtk.h" #endif #ifndef NDEBUG @@ -188,9 +191,14 @@ WebPage::WebPage(uint64_t pageID, const WebPageCreationParameters& parameters) , m_keyboardEventBeingInterpreted(0) #elif PLATFORM(WIN) , m_nativeWindow(parameters.nativeWindow) +#elif PLATFORM(GTK) + , m_accessibilityObject(0) #endif , m_setCanStartMediaTimer(WebProcess::shared().runLoop(), this, &WebPage::setCanStartMediaTimerFired) , m_findController(this) +#if PLATFORM(QT) + , m_tapHighlightController(this) +#endif , m_geolocationPermissionRequestManager(this) , m_pageID(pageID) , m_canRunBeforeUnloadConfirmPanel(parameters.canRunBeforeUnloadConfirmPanel) @@ -253,6 +261,7 @@ WebPage::WebPage(uint64_t pageID, const WebPageCreationParameters& parameters) setDrawsTransparentBackground(parameters.drawsTransparentBackground); setPaginationMode(parameters.paginationMode); + setPaginationBehavesLikeColumns(parameters.paginationBehavesLikeColumns); setPageLength(parameters.pageLength); setGapBetweenPages(parameters.gapBetweenPages); @@ -270,6 +279,8 @@ WebPage::WebPage(uint64_t pageID, const WebPageCreationParameters& parameters) restoreSession(parameters.sessionState); m_drawingArea->setPaintingEnabled(true); + + setMediaVolume(parameters.mediaVolume); #ifndef NDEBUG webPageCounter.increment(); @@ -398,6 +409,32 @@ EditorState WebPage::editorState() const if (!scope) return result; + if (scope->hasTagName(HTMLNames::inputTag)) { + HTMLInputElement* input = static_cast<HTMLInputElement*>(scope); + if (input->isTelephoneField()) + result.inputMethodHints |= Qt::ImhDialableCharactersOnly; + else if (input->isNumberField()) + result.inputMethodHints |= Qt::ImhDigitsOnly; + else if (input->isEmailField()) { + result.inputMethodHints |= Qt::ImhEmailCharactersOnly; + result.inputMethodHints |= Qt::ImhNoAutoUppercase; + } else if (input->isURLField()) { + result.inputMethodHints |= Qt::ImhUrlCharactersOnly; + result.inputMethodHints |= Qt::ImhNoAutoUppercase; + } else if (input->isPasswordField()) { + // Set ImhHiddenText flag for password fields. The Qt platform + // is responsible for determining which widget will receive input + // method events for password fields. + result.inputMethodHints |= Qt::ImhHiddenText; + result.inputMethodHints |= Qt::ImhNoAutoUppercase; + result.inputMethodHints |= Qt::ImhNoPredictiveText; + result.inputMethodHints |= Qt::ImhSensitiveData; + } + } + + if (selectionRoot) + result.editorRect = frame->view()->contentsToWindow(selectionRoot->getRect()); + RefPtr<Range> range; if (result.hasComposition && (range = frame->editor()->compositionRange())) { frame->editor()->getCompositionSelection(result.anchorPosition, result.cursorPosition); @@ -415,7 +452,7 @@ EditorState WebPage::editorState() const } if (range) - result.microFocus = frame->view()->contentsToWindow(frame->editor()->firstRectForRange(range.get())); + result.cursorRect = frame->view()->contentsToWindow(frame->editor()->firstRectForRange(range.get())); // FIXME: We should only transfer innerText when it changes and do this on the UI side. if (result.isContentEditable && !result.isInPasswordField) { @@ -451,6 +488,13 @@ uint64_t WebPage::renderTreeSize() const return size; } +void WebPage::setPaintedObjectsCounterThreshold(uint64_t threshold) +{ + if (!m_page) + return; + m_page->setRelevantRepaintedObjectsCounterThreshold(threshold); +} + void WebPage::setTracksRepaints(bool trackRepaints) { if (FrameView* view = mainFrameView()) @@ -980,6 +1024,13 @@ void WebPage::setPaginationMode(uint32_t mode) m_page->setPagination(pagination); } +void WebPage::setPaginationBehavesLikeColumns(bool behavesLikeColumns) +{ + Page::Pagination pagination = m_page->pagination(); + pagination.behavesLikeColumns = behavesLikeColumns; + m_page->setPagination(pagination); +} + void WebPage::setPageLength(double pageLength) { Page::Pagination pagination = m_page->pagination(); @@ -1205,7 +1256,9 @@ static bool handleMouseEvent(const WebMouseEvent& mouseEvent, Page* page, bool o case PlatformEvent::MouseReleased: return frame->eventHandler()->handleMouseReleaseEvent(platformMouseEvent); case PlatformEvent::MouseMoved: - return frame->eventHandler()->mouseMoved(platformMouseEvent, onlyUpdateScrollbars); + if (onlyUpdateScrollbars) + return frame->eventHandler()->passMouseMovedEventToScrollbars(platformMouseEvent); + return frame->eventHandler()->mouseMoved(platformMouseEvent); default: ASSERT_NOT_REACHED(); return false; @@ -1391,6 +1444,27 @@ void WebPage::restoreSessionAndNavigateToCurrentItem(const SessionState& session } #if ENABLE(TOUCH_EVENTS) +#if PLATFORM(QT) +void WebPage::highlightPotentialActivation(const IntPoint& point) +{ + Node* activationNode = 0; + Frame* mainframe = m_page->mainFrame(); + + if (point != IntPoint::zero()) { + HitTestResult result = mainframe->eventHandler()->hitTestResultAtPoint(mainframe->view()->windowToContents(point), /*allowShadowContent*/ false, /*ignoreClipping*/ true); + activationNode = result.innerNode(); + + if (!activationNode->isFocusable()) + activationNode = activationNode->enclosingLinkEventParentOrSelf(); + } + + if (activationNode) + tapHighlightController().highlight(activationNode); + else + tapHighlightController().hideHighlight(); +} +#endif + static bool handleTouchEvent(const WebTouchEvent& touchEvent, Page* page) { Frame* frame = page->mainFrame(); @@ -1811,11 +1885,21 @@ void WebPage::updatePreferences(const WebPreferencesStore& store) settings->setCanvasUsesAcceleratedDrawing(store.getBoolValueForKey(WebPreferencesKey::canvasUsesAcceleratedDrawingKey()) && LayerTreeHost::supportsAcceleratedCompositing()); settings->setShowDebugBorders(store.getBoolValueForKey(WebPreferencesKey::compositingBordersVisibleKey())); settings->setShowRepaintCounter(store.getBoolValueForKey(WebPreferencesKey::compositingRepaintCountersVisibleKey())); + settings->setCSSCustomFilterEnabled(store.getBoolValueForKey(WebPreferencesKey::cssCustomFilterEnabledKey())); settings->setWebGLEnabled(store.getBoolValueForKey(WebPreferencesKey::webGLEnabledKey())); settings->setMediaPlaybackRequiresUserGesture(store.getBoolValueForKey(WebPreferencesKey::mediaPlaybackRequiresUserGestureKey())); settings->setMediaPlaybackAllowsInline(store.getBoolValueForKey(WebPreferencesKey::mediaPlaybackAllowsInlineKey())); settings->setMockScrollbarsEnabled(store.getBoolValueForKey(WebPreferencesKey::mockScrollbarsEnabledKey())); + // <rdar://problem/10697417>: It is necessary to force compositing when accelerate drawing + // is enabled on Mac so that scrollbars are always in their own layers. +#if PLATFORM(MAC) + if (settings->acceleratedDrawingEnabled()) + settings->setForceCompositingMode(LayerTreeHost::supportsAcceleratedCompositing()); + else +#endif + settings->setForceCompositingMode(store.getBoolValueForKey(WebPreferencesKey::forceCompositingModeKey()) && LayerTreeHost::supportsAcceleratedCompositing()); + #if ENABLE(SQL_DATABASE) AbstractDatabase::setIsAvailable(store.getBoolValueForKey(WebPreferencesKey::databasesEnabledKey())); #endif @@ -1849,6 +1933,10 @@ void WebPage::updatePreferences(const WebPreferencesStore& store) settings->setShouldDisplayTextDescriptions(store.getBoolValueForKey(WebPreferencesKey::shouldDisplayTextDescriptionsKey())); #endif +#if ENABLE(NOTIFICATIONS) + settings->setNotificationsEnabled(store.getBoolValueForKey(WebPreferencesKey::notificationsEnabledKey())); +#endif + platformPreferencesDidChange(store); } @@ -2608,14 +2696,24 @@ void WebPage::beginPrinting(uint64_t frameID, const PrintInfo& printInfo) if (!m_printContext) m_printContext = adoptPtr(new PrintContext(coreFrame)); + drawingArea()->setLayerTreeStateIsFrozen(true); m_printContext->begin(printInfo.availablePaperWidth, printInfo.availablePaperHeight); float fullPageHeight; m_printContext->computePageRects(FloatRect(0, 0, printInfo.availablePaperWidth, printInfo.availablePaperHeight), 0, 0, printInfo.pageSetupScaleFactor, fullPageHeight, true); + +#if PLATFORM(GTK) + if (!m_printOperation) + m_printOperation = WebPrintOperationGtk::create(this, printInfo); +#endif } void WebPage::endPrinting() { + drawingArea()->setLayerTreeStateIsFrozen(false); +#if PLATFORM(GTK) + m_printOperation = 0; +#endif m_printContext = nullptr; } @@ -2795,8 +2893,24 @@ void WebPage::drawPagesToPDF(uint64_t frameID, const PrintInfo& printInfo, uint3 send(Messages::WebPageProxy::DataCallback(CoreIPC::DataReference(CFDataGetBytePtr(pdfPageData.get()), CFDataGetLength(pdfPageData.get())), callbackID)); } +#elif PLATFORM(GTK) +void WebPage::drawPagesForPrinting(uint64_t frameID, const PrintInfo& printInfo, uint64_t callbackID) +{ + beginPrinting(frameID, printInfo); + if (m_printContext && m_printOperation) { + m_printOperation->startPrint(m_printContext.get(), callbackID); + return; + } + + send(Messages::WebPageProxy::VoidCallback(callbackID)); +} #endif +void WebPage::setMediaVolume(float volume) +{ + m_page->setMediaVolume(volume); +} + void WebPage::runModal() { if (m_isClosed) diff --git a/Source/WebKit2/WebProcess/WebPage/WebPage.h b/Source/WebKit2/WebProcess/WebPage/WebPage.h index 40072cfbf..09eef272a 100644 --- a/Source/WebKit2/WebProcess/WebPage/WebPage.h +++ b/Source/WebKit2/WebProcess/WebPage/WebPage.h @@ -41,6 +41,7 @@ #include "InjectedBundlePageResourceLoadClient.h" #include "InjectedBundlePageUIClient.h" #include "MessageSender.h" +#include "TapHighlightController.h" #include "Plugin.h" #include "SandboxExtension.h" #include "ShareableBitmap.h" @@ -70,6 +71,8 @@ #if PLATFORM(GTK) #include "ArgumentCodersGtk.h" +#include "WebPageAccessibilityObject.h" +#include "WebPrintOperationGtk.h" #endif #if ENABLE(TOUCH_EVENTS) @@ -249,6 +252,7 @@ public: String renderTreeExternalRepresentation() const; uint64_t renderTreeSize() const; + void setPaintedObjectsCounterThreshold(uint64_t); void setTracksRepaints(bool); bool isTrackingRepaints() const; @@ -275,6 +279,7 @@ public: void setFixedLayoutSize(const WebCore::IntSize&); void setPaginationMode(uint32_t /* WebCore::Page::Pagination::Mode */); + void setPaginationBehavesLikeColumns(bool); void setPageLength(double); void setGapBetweenPages(double); @@ -315,6 +320,10 @@ public: static const WebEvent* currentEvent(); FindController& findController() { return m_findController; } +#if PLATFORM(QT) + TapHighlightController& tapHighlightController() { return m_tapHighlightController; } +#endif + GeolocationPermissionRequestManager& geolocationPermissionRequestManager() { return m_geolocationPermissionRequestManager; } NotificationPermissionRequestManager* notificationPermissionRequestManager(); @@ -397,6 +406,9 @@ public: void gestureWillBegin(const WebCore::IntPoint&, bool& canBeginPanning); void gestureDidScroll(const WebCore::IntSize&); void gestureDidEnd(); + +#elif PLATFORM(GTK) + void updateAccessibilityTree(); #endif void setCompositionForTesting(const String& compositionString, uint64_t from, uint64_t length); @@ -436,8 +448,12 @@ public: #if PLATFORM(MAC) || PLATFORM(WIN) void drawRectToPDF(uint64_t frameID, const PrintInfo&, const WebCore::IntRect&, uint64_t callbackID); void drawPagesToPDF(uint64_t frameID, const PrintInfo&, uint32_t first, uint32_t count, uint64_t callbackID); +#elif PLATFORM(GTK) + void drawPagesForPrinting(uint64_t frameID, const PrintInfo&, uint64_t callbackID); #endif + void setMediaVolume(float); + bool mainFrameHasCustomRepresentation() const; void didChangeScrollOffsetForMainFrame(); @@ -538,6 +554,9 @@ private: #if ENABLE(TOUCH_EVENTS) void touchEvent(const WebTouchEvent&); void touchEventSyncForTesting(const WebTouchEvent&, bool& handled); +#if PLATFORM(QT) + void highlightPotentialActivation(const WebCore::IntPoint&); +#endif #endif void contextMenuHidden() { m_isShowingContextMenu = false; } @@ -596,9 +615,9 @@ private: void didChangeSelectedIndexForActivePopupMenu(int32_t newIndex); void setTextForActivePopupMenu(int32_t index); -#if PLATFORM(GTK) +#if PLATFORM(GTK) void failedToShowPopupMenu(); -#endif +#endif void didChooseFilesForOpenPanel(const Vector<String>&); void didCancelForOpenPanel(); @@ -675,9 +694,11 @@ private: HWND m_nativeWindow; RefPtr<WebCore::Node> m_gestureTargetNode; +#elif PLATFORM(GTK) + WebPageAccessibilityObject* m_accessibilityObject; #endif - RunLoop::Timer<WebPage> m_setCanStartMediaTimer; + WebCore::RunLoop::Timer<WebPage> m_setCanStartMediaTimer; HashMap<uint64_t, RefPtr<WebUndoStep> > m_undoStepMap; @@ -700,6 +721,9 @@ private: #endif FindController m_findController; +#if PLATFORM(QT) + TapHighlightController m_tapHighlightController; +#endif RefPtr<PageOverlay> m_pageOverlay; RefPtr<WebPage> m_underlayPage; @@ -717,6 +741,9 @@ private: RefPtr<NotificationPermissionRequestManager> m_notificationPermissionRequestManager; OwnPtr<WebCore::PrintContext> m_printContext; +#if PLATFORM(GTK) + RefPtr<WebPrintOperationGtk> m_printOperation; +#endif SandboxExtensionTracker m_sandboxExtensionTracker; uint64_t m_pageID; diff --git a/Source/WebKit2/WebProcess/WebPage/WebPage.messages.in b/Source/WebKit2/WebProcess/WebPage/WebPage.messages.in index 5a3bb450e..415460137 100644 --- a/Source/WebKit2/WebProcess/WebPage/WebPage.messages.in +++ b/Source/WebKit2/WebProcess/WebPage/WebPage.messages.in @@ -40,6 +40,9 @@ messages -> WebPage { #if ENABLE(TOUCH_EVENTS) TouchEvent(WebKit::WebTouchEvent event) TouchEventSyncForTesting(WebKit::WebTouchEvent event) -> (bool handled) +#if PLATFORM(QT) + HighlightPotentialActivation(WebCore::IntPoint point) +#endif #endif ContextMenuHidden() @@ -123,6 +126,7 @@ messages -> WebPage { SetFixedLayoutSize(WebCore::IntSize size) SetPaginationMode(uint32_t mode); + SetPaginationBehavesLikeColumns(bool behavesLikeColumns); SetPageLength(double pageLength); SetGapBetweenPages(double gap); @@ -187,6 +191,12 @@ messages -> WebPage { DrawRectToPDF(uint64_t frameID, WebKit::PrintInfo printInfo, WebCore::IntRect rect, uint64_t callbackID) DrawPagesToPDF(uint64_t frameID, WebKit::PrintInfo printInfo, uint32_t first, uint32_t count, uint64_t callbackID) #endif +#if PLATFORM(GTK) + DrawPagesForPrinting(uint64_t frameID, WebKit::PrintInfo printInfo, uint64_t callbackID) +#endif + + # Media + SetMediaVolume(float volume) SetMemoryCacheMessagesEnabled(bool memoryCacheMessagesEnabled) diff --git a/Source/WebKit2/WebProcess/WebPage/ca/LayerTreeHostCA.cpp b/Source/WebKit2/WebProcess/WebPage/ca/LayerTreeHostCA.cpp index 8b135fd06..87e9cedbe 100644 --- a/Source/WebKit2/WebProcess/WebPage/ca/LayerTreeHostCA.cpp +++ b/Source/WebKit2/WebProcess/WebPage/ca/LayerTreeHostCA.cpp @@ -203,12 +203,12 @@ void LayerTreeHostCA::paintContents(const GraphicsLayer* graphicsLayer, Graphics } } -bool LayerTreeHostCA::showDebugBorders() const +bool LayerTreeHostCA::showDebugBorders(const GraphicsLayer*) const { return m_webPage->corePage()->settings()->showDebugBorders(); } -bool LayerTreeHostCA::showRepaintCounter() const +bool LayerTreeHostCA::showRepaintCounter(const GraphicsLayer*) const { return m_webPage->corePage()->settings()->showRepaintCounter(); } diff --git a/Source/WebKit2/WebProcess/WebPage/ca/LayerTreeHostCA.h b/Source/WebKit2/WebProcess/WebPage/ca/LayerTreeHostCA.h index 0566e9733..64233347d 100644 --- a/Source/WebKit2/WebProcess/WebPage/ca/LayerTreeHostCA.h +++ b/Source/WebKit2/WebProcess/WebPage/ca/LayerTreeHostCA.h @@ -54,6 +54,7 @@ protected: // LayerTreeHostCA virtual void didPerformScheduledLayerFlush(); + virtual bool flushPendingLayerChanges(); bool m_layerFlushSchedulingEnabled; @@ -73,16 +74,14 @@ private: virtual void notifyAnimationStarted(const WebCore::GraphicsLayer*, double time); virtual void notifySyncRequired(const WebCore::GraphicsLayer*); virtual void paintContents(const WebCore::GraphicsLayer*, WebCore::GraphicsContext&, WebCore::GraphicsLayerPaintingPhase, const WebCore::IntRect& clipRect); - virtual bool showDebugBorders() const; - virtual bool showRepaintCounter() const; + virtual bool showDebugBorders(const WebCore::GraphicsLayer*) const; + virtual bool showRepaintCounter(const WebCore::GraphicsLayer*) const; virtual float deviceScaleFactor() const; virtual void didCommitChangesForLayer(const WebCore::GraphicsLayer*) const { } // LayerTreeHostCA virtual void platformInitialize(LayerTreeContext&) = 0; - bool flushPendingLayerChanges(); - void createPageOverlayLayer(); void destroyPageOverlayLayer(); diff --git a/Source/WebKit2/WebProcess/WebPage/ca/mac/LayerTreeHostCAMac.h b/Source/WebKit2/WebProcess/WebPage/ca/mac/LayerTreeHostCAMac.h index 06759e25d..153256b07 100644 --- a/Source/WebKit2/WebProcess/WebPage/ca/mac/LayerTreeHostCAMac.h +++ b/Source/WebKit2/WebProcess/WebPage/ca/mac/LayerTreeHostCAMac.h @@ -55,7 +55,9 @@ private: // LayerTreeHostCA virtual void platformInitialize(LayerTreeContext&); virtual void didPerformScheduledLayerFlush(); - + + virtual bool flushPendingLayerChanges(); + // LayerFlushSchedulerClient virtual bool flushLayers(); diff --git a/Source/WebKit2/WebProcess/WebPage/ca/mac/LayerTreeHostCAMac.mm b/Source/WebKit2/WebProcess/WebPage/ca/mac/LayerTreeHostCAMac.mm index 5ff8ad13b..d45837fd6 100644 --- a/Source/WebKit2/WebProcess/WebPage/ca/mac/LayerTreeHostCAMac.mm +++ b/Source/WebKit2/WebProcess/WebPage/ca/mac/LayerTreeHostCAMac.mm @@ -133,4 +133,12 @@ void LayerTreeHostCAMac::didPerformScheduledLayerFlush() LayerTreeHostCA::didPerformScheduledLayerFlush(); } +bool LayerTreeHostCAMac::flushPendingLayerChanges() +{ + if (m_layerFlushScheduler.isSuspended()) + return false; + + return LayerTreeHostCA::flushPendingLayerChanges(); +} + } // namespace WebKit diff --git a/Source/WebKit2/WebProcess/WebPage/gtk/WebPageAccessibilityObject.cpp b/Source/WebKit2/WebProcess/WebPage/gtk/WebPageAccessibilityObject.cpp new file mode 100644 index 000000000..223700032 --- /dev/null +++ b/Source/WebKit2/WebProcess/WebPage/gtk/WebPageAccessibilityObject.cpp @@ -0,0 +1,140 @@ +/* + * Copyright (C) 2012 Igalia S.L. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * + * THIS SOFTWARE IS PROVIDED BY APPLE INC. AND ITS CONTRIBUTORS ``AS IS'' + * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, + * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR + * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR ITS CONTRIBUTORS + * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR + * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF + * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS + * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN + * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) + * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF + * THE POSSIBILITY OF SUCH DAMAGE. + */ + +#include "config.h" +#include "WebPageAccessibilityObject.h" + +#include "WebPage.h" +#include <WebCore/AXObjectCache.h> +#include <WebCore/Frame.h> +#include <WebCore/Page.h> + +using namespace WebKit; +using namespace WebCore; + +G_DEFINE_TYPE(WebPageAccessibilityObject, web_page_accessibility_object, ATK_TYPE_PLUG) + +static AtkObject* accessibilityRootObjectWrapper(AtkObject* atkObject) +{ + if (!AXObjectCache::accessibilityEnabled()) + AXObjectCache::enableAccessibility(); + + WebPageAccessibilityObject* accessible = WEB_PAGE_ACCESSIBILITY_OBJECT(atkObject); + if (!accessible->m_page) + return 0; + + Page* page = accessible->m_page->corePage(); + if (!page) + return 0; + + Frame* core = page->mainFrame(); + if (!core || !core->document()) + return 0; + + AccessibilityObject* root = core->document()->axObjectCache()->rootObject(); + if (!root) + return 0; + + AtkObject* axRoot = root->wrapper(); + if (!axRoot || !ATK_IS_OBJECT(axRoot)) + return 0; + + return axRoot; +} + +static void webPageAccessibilityObjectInitialize(AtkObject* atkObject, gpointer data) +{ + if (ATK_OBJECT_CLASS(web_page_accessibility_object_parent_class)->initialize) + ATK_OBJECT_CLASS(web_page_accessibility_object_parent_class)->initialize(atkObject, data); + + WEB_PAGE_ACCESSIBILITY_OBJECT(atkObject)->m_page = reinterpret_cast<WebPage*>(data); + atk_object_set_role(atkObject, ATK_ROLE_FILLER); +} + +static gint webPageAccessibilityObjectGetIndexInParent(AtkObject *atkObject) +{ + // An AtkPlug is the only child an AtkSocket can have. + return 0; +} + +static gint webPageAccessibilityObjectGetNChildren(AtkObject* atkObject) +{ + AtkObject* rootObject = accessibilityRootObjectWrapper(atkObject); + if (!rootObject) + return 0; + + return 1; +} + +static AtkObject* webPageAccessibilityObjectRefChild(AtkObject* atkObject, gint index) +{ + // It's supposed to have either one child or zero. + if (index && index != 1) + return 0; + + AtkObject* rootObject = accessibilityRootObjectWrapper(atkObject); + if (!rootObject) + return 0; + + atk_object_set_parent(rootObject, atkObject); + g_object_ref(rootObject); + + return rootObject; +} + +static void web_page_accessibility_object_init(WebPageAccessibilityObject* accessible) +{ +} + +static void web_page_accessibility_object_class_init(WebPageAccessibilityObjectClass* klass) +{ + AtkObjectClass* atkObjectClass = ATK_OBJECT_CLASS(klass); + + // No need to implement get_parent() here since this is a subclass + // of AtkPlug and all the logic related to that function will be + // implemented by the ATK bridge. + atkObjectClass->initialize = webPageAccessibilityObjectInitialize; + atkObjectClass->get_index_in_parent = webPageAccessibilityObjectGetIndexInParent; + atkObjectClass->get_n_children = webPageAccessibilityObjectGetNChildren; + atkObjectClass->ref_child = webPageAccessibilityObjectRefChild; +} + +WebPageAccessibilityObject* webPageAccessibilityObjectNew(WebPage* page) +{ + AtkObject* object = ATK_OBJECT(g_object_new(WEB_TYPE_PAGE_ACCESSIBILITY_OBJECT, NULL)); + atk_object_initialize(object, page); + return WEB_PAGE_ACCESSIBILITY_OBJECT(object); +} + +void webPageAccessibilityObjectRefresh(WebPageAccessibilityObject* accessible) +{ + // We just need to ensure that there's a connection in the ATK + // world between this accessibility object and the AtkObject of + // the accessibility object for the root of the DOM tree. + AtkObject* rootObject = accessibilityRootObjectWrapper(ATK_OBJECT(accessible)); + if (!rootObject) + return; + atk_object_set_parent(rootObject, ATK_OBJECT(accessible)); +} diff --git a/Source/WebKit2/WebProcess/WebPage/gtk/WebPageAccessibilityObject.h b/Source/WebKit2/WebProcess/WebPage/gtk/WebPageAccessibilityObject.h new file mode 100644 index 000000000..1b79d9bb8 --- /dev/null +++ b/Source/WebKit2/WebProcess/WebPage/gtk/WebPageAccessibilityObject.h @@ -0,0 +1,64 @@ +/* + * Copyright (C) 2012 Igalia S.L. + * + * 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 WebPageAccessibilityObject_h +#define WebPageAccessibilityObject_h + +#include <atk/atk.h> + +namespace WebKit { +class WebPage; +} + +G_BEGIN_DECLS + +#define WEB_TYPE_PAGE_ACCESSIBILITY_OBJECT (web_page_accessibility_object_get_type()) +#define WEB_PAGE_ACCESSIBILITY_OBJECT(object) (G_TYPE_CHECK_INSTANCE_CAST((object), WEB_TYPE_PAGE_ACCESSIBILITY_OBJECT, WebPageAccessibilityObject)) +#define WEB_PAGE_ACCESSIBILITY_OBJECT_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST((klass), WEB_TYPE_PAGE_ACCESSIBILITY_OBJECT, WebPageAccessibilityObjectClass)) +#define WEB_IS_PAGE_ACCESSIBILITY_OBJECT(object) (G_TYPE_CHECK_INSTANCE_TYPE((object), WEB_TYPE_PAGE_ACCESSIBILITY_OBJECT)) +#define WEB_IS_PAGE_ACCESSIBILITY_OBJECT_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE((klass), WEB_TYPE_PAGE_ACCESSIBILITY_OBJECT)) +#define WEB_PAGE_ACCESSIBILITY_OBJECT_GET_CLASS(object) (G_TYPE_INSTANCE_GET_CLASS((object), WEB_TYPE_PAGE_ACCESSIBILITY_OBJECT, WebPageAccessibilityObjectClass)) + +typedef struct _WebPageAccessibilityObject WebPageAccessibilityObject; +typedef struct _WebPageAccessibilityObjectClass WebPageAccessibilityObjectClass; + +struct _WebPageAccessibilityObject { + AtkPlug parent; + WebKit::WebPage* m_page; +}; + +struct _WebPageAccessibilityObjectClass { + AtkPlugClass parentClass; +}; + +GType web_page_accessibility_object_get_type(); + +WebPageAccessibilityObject* webPageAccessibilityObjectNew(WebKit::WebPage*); + +void webPageAccessibilityObjectRefresh(WebPageAccessibilityObject*); + +G_END_DECLS + +#endif // WebPageAccessibilityObject_h diff --git a/Source/WebKit2/WebProcess/WebPage/gtk/WebPageGtk.cpp b/Source/WebKit2/WebProcess/WebPage/gtk/WebPageGtk.cpp index a25e1f7b3..2b2a9464e 100644 --- a/Source/WebKit2/WebProcess/WebPage/gtk/WebPageGtk.cpp +++ b/Source/WebKit2/WebProcess/WebPage/gtk/WebPageGtk.cpp @@ -30,6 +30,8 @@ #include "NotImplemented.h" #include "WebEvent.h" +#include "WebPageAccessibilityObject.h" +#include "WebPageProxyMessages.h" #include "WindowsKeyboardCodes.h" #include <WebCore/FocusController.h> #include <WebCore/Frame.h> @@ -37,6 +39,7 @@ #include <WebCore/Page.h> #include <WebCore/PlatformKeyboardEvent.h> #include <WebCore/Settings.h> +#include <wtf/gobject/GOwnPtr.h> using namespace WebCore; @@ -44,7 +47,21 @@ namespace WebKit { void WebPage::platformInitialize() { - notImplemented(); + // Create the accessible object (the plug) that will serve as the + // 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))); + send(Messages::WebPageProxy::BindAccessibilityTree(String(plugID.get()))); +} + +void WebPage::updateAccessibilityTree() +{ + if (!m_accessibilityObject) + return; + + webPageAccessibilityObjectRefresh(m_accessibilityObject); } void WebPage::platformPreferencesDidChange(const WebPreferencesStore&) diff --git a/Source/WebKit2/WebProcess/WebPage/gtk/WebPrintOperationGtk.cpp b/Source/WebKit2/WebProcess/WebPage/gtk/WebPrintOperationGtk.cpp new file mode 100644 index 000000000..704adf3ea --- /dev/null +++ b/Source/WebKit2/WebProcess/WebPage/gtk/WebPrintOperationGtk.cpp @@ -0,0 +1,389 @@ +/* + * Copyright (C) 2012 Igalia S.L. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * + * THIS SOFTWARE IS PROVIDED BY APPLE INC. AND ITS CONTRIBUTORS ``AS IS'' + * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, + * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR + * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR ITS CONTRIBUTORS + * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR + * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF + * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS + * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN + * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) + * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF + * THE POSSIBILITY OF SUCH DAMAGE. + */ + +#include "config.h" +#include "WebPrintOperationGtk.h" + +#include "WebPage.h" +#include "WebPageProxyMessages.h" +#include <WebCore/IntRect.h> +#include <WebCore/NotImplemented.h> +#include <WebCore/PlatformContextCairo.h> +#include <WebCore/PrintContext.h> +#include <gtk/gtk.h> +#include <wtf/Vector.h> +#include <wtf/gobject/GOwnPtr.h> + +#ifdef HAVE_GTK_UNIX_PRINTING +#include <cairo-pdf.h> +#include <cairo-ps.h> +#include <gtk/gtkunixprint.h> +#endif + +namespace WebKit { + +#ifdef HAVE_GTK_UNIX_PRINTING +class WebPrintOperationGtkUnix: public WebPrintOperationGtk { +public: + WebPrintOperationGtkUnix(WebPage* page, const PrintInfo& printInfo) + : WebPrintOperationGtk(page, printInfo) + , m_printJob(0) + { + } + + static gboolean enumeratePrintersFunction(GtkPrinter* printer, WebPrintOperationGtkUnix* printOperation) + { + GtkPrinter* selectedPrinter = 0; + const char* printerName = gtk_print_settings_get_printer(printOperation->printSettings()); + if (printerName) { + if (!strcmp(printerName, gtk_printer_get_name(printer))) + selectedPrinter = printer; + } else if (gtk_printer_is_default(printer)) + selectedPrinter = printer; + + if (!selectedPrinter) + return FALSE; + + static int jobNumber = 0; + const char* applicationName = g_get_application_name(); + GOwnPtr<char>jobName(g_strdup_printf("%s job #%d", applicationName ? applicationName : "WebKit", ++jobNumber)); + printOperation->m_printJob = adoptGRef(gtk_print_job_new(jobName.get(), selectedPrinter, + printOperation->printSettings(), + printOperation->pageSetup())); + return TRUE; + } + + static void enumeratePrintersFinished(WebPrintOperationGtkUnix* printOperation) + { + if (!printOperation->m_printJob) { + // FIXME: Printing error. + return; + } + + cairo_surface_t* surface = gtk_print_job_get_surface(printOperation->m_printJob.get(), 0); + if (!surface) { + // FIXME: Printing error. + return; + } + + int rangesCount; + printOperation->m_pageRanges = gtk_print_job_get_page_ranges(printOperation->m_printJob.get(), &rangesCount); + printOperation->m_pageRangesCount = rangesCount; + printOperation->m_pagesToPrint = gtk_print_job_get_pages(printOperation->m_printJob.get()); + printOperation->m_needsRotation = gtk_print_job_get_rotate(printOperation->m_printJob.get()); + + printOperation->print(surface, 72, 72); + } + + void startPrint(WebCore::PrintContext* printContext, uint64_t callbackID) + { + m_printContext = printContext; + m_callbackID = callbackID; + gtk_enumerate_printers(reinterpret_cast<GtkPrinterFunc>(enumeratePrintersFunction), this, + reinterpret_cast<GDestroyNotify>(enumeratePrintersFinished), FALSE); + } + + void startPage(cairo_t* cr) + { + GtkPaperSize* paperSize = gtk_page_setup_get_paper_size(m_pageSetup.get()); + double width = gtk_paper_size_get_width(paperSize, GTK_UNIT_POINTS); + double height = gtk_paper_size_get_height(paperSize, GTK_UNIT_POINTS); + + cairo_surface_t* surface = gtk_print_job_get_surface(m_printJob.get(), 0); + cairo_surface_type_t surfaceType = cairo_surface_get_type(surface); + if (surfaceType == CAIRO_SURFACE_TYPE_PS) { + cairo_ps_surface_set_size(surface, width, height); + cairo_ps_surface_dsc_begin_page_setup(surface); + + switch (gtk_page_setup_get_orientation(m_pageSetup.get())) { + case GTK_PAGE_ORIENTATION_PORTRAIT: + case GTK_PAGE_ORIENTATION_REVERSE_PORTRAIT: + cairo_ps_surface_dsc_comment(surface, "%%PageOrientation: Portrait"); + break; + case GTK_PAGE_ORIENTATION_LANDSCAPE: + case GTK_PAGE_ORIENTATION_REVERSE_LANDSCAPE: + cairo_ps_surface_dsc_comment(surface, "%%PageOrientation: Landscape"); + break; + } + } else if (surfaceType == CAIRO_SURFACE_TYPE_PDF) + cairo_pdf_surface_set_size(surface, width, height); + } + + void endPage(cairo_t* cr) + { + cairo_show_page(cr); + } + + static void printJobComplete(GtkPrintJob* printJob, WebPrintOperationGtkUnix* printOperation, const GError*) + { + printOperation->m_printJob = 0; + } + + static void printJobFinished(WebPrintOperationGtkUnix* printOperation) + { + printOperation->deref(); + } + + void endPrint() + { + cairo_surface_finish(gtk_print_job_get_surface(m_printJob.get(), 0)); + // Make sure the operation is alive until the job is sent. + ref(); + gtk_print_job_send(m_printJob.get(), reinterpret_cast<GtkPrintJobCompleteFunc>(printJobComplete), this, + reinterpret_cast<GDestroyNotify>(printJobFinished)); + } + + GRefPtr<GtkPrintJob> m_printJob; +}; +#endif + +#ifdef G_OS_WIN32 +class WebPrintOperationGtkWin32: public WebPrintOperationGtk { +public: + WebPrintOperationGtkWin32(WebPage* page, const PrintInfo& printInfo) + : WebPrintOperationGtk(page, printInfo) + { + } + + void startPrint(WebCore::PrintContext* printContext, uint64_t callbackID) + { + m_printContext = printContext; + m_callbackID = callbackID; + notImplemented(); + } + + void startPage(cairo_t* cr) + { + notImplemented(); + } + + void endPage(cairo_t* cr) + { + notImplemented(); + } + + void endPrint() + { + notImplemented(); + } +}; +#endif + +struct PrintPagesData { + PrintPagesData(WebPrintOperationGtk* printOperation) + : printOperation(printOperation) + , totalPrinted(-1) + , pageNumber(0) + , pagePosition(0) + , isDone(false) + { + if (printOperation->pagesToPrint() == GTK_PRINT_PAGES_RANGES) { + Vector<GtkPageRange> pageRanges; + GtkPageRange* ranges = printOperation->pageRanges(); + size_t rangesCount = printOperation->pageRangesCount(); + int pageCount = printOperation->pageCount(); + + pageRanges.reserveCapacity(rangesCount); + for (size_t i = 0; i < rangesCount; ++i) { + if (ranges[i].start >= 0 && ranges[i].start < pageCount && ranges[i].end >= 0 && ranges[i].end < pageCount) + pageRanges.append(ranges[i]); + else if (ranges[i].start >= 0 && ranges[i].start < pageCount && ranges[i].end >= pageCount) { + pageRanges.append(ranges[i]); + pageRanges.last().end = pageCount - 1; + } else if (ranges[i].end >= 0 && ranges[i].end < pageCount && ranges[i].start < 0) { + pageRanges.append(ranges[i]); + pageRanges.last().start = 0; + } + } + + for (size_t i = 0; i < pageRanges.size(); ++i) { + for (int j = pageRanges[i].start; j <= pageRanges[i].end; ++j) + pages.append(j); + } + + } else { + for (int i = 0; i < printOperation->pageCount(); ++i) + pages.append(i); + } + + pageNumber = pages[pagePosition]; + } + + void incrementPageSequence() + { + if (totalPrinted == -1) { + totalPrinted = 0; + return; + } + + pagePosition++; + if (pagePosition >= pages.size()) { + isDone = true; + return; + } + pageNumber = pages[pagePosition]; + totalPrinted++; + } + + RefPtr<WebPrintOperationGtk> printOperation; + + int totalPrinted; + size_t totalToPrint; + int pageNumber; + size_t pagePosition; + Vector<size_t> pages; + + bool isDone : 1; +}; + +PassRefPtr<WebPrintOperationGtk> WebPrintOperationGtk::create(WebPage* page, const PrintInfo& printInfo) +{ +#ifdef HAVE_GTK_UNIX_PRINTING + return adoptRef(new WebPrintOperationGtkUnix(page, printInfo)); +#endif +#ifdef G_OS_WIN32 + return adoptRef(new WebPrintOperationGtkWin32(page, printInfo)); +#endif +} + +WebPrintOperationGtk::WebPrintOperationGtk(WebPage* page, const PrintInfo& printInfo) + : m_webPage(page) + , m_printSettings(printInfo.printSettings.get()) + , m_pageSetup(printInfo.pageSetup.get()) + , m_printContext(0) + , m_callbackID(0) + , m_xDPI(1) + , m_yDPI(1) + , m_printPagesIdleId(0) + , m_pagesToPrint(GTK_PRINT_PAGES_ALL) + , m_pageRanges(0) + , m_pageRangesCount(0) + , m_needsRotation(false) +{ +} + +WebPrintOperationGtk::~WebPrintOperationGtk() +{ + if (m_printPagesIdleId) + g_source_remove(m_printPagesIdleId); +} + +int WebPrintOperationGtk::pageCount() const +{ + return m_printContext ? m_printContext->pageCount() : 0; +} + +void WebPrintOperationGtk::rotatePage() +{ + GtkPaperSize* paperSize = gtk_page_setup_get_paper_size(m_pageSetup.get()); + double width = gtk_paper_size_get_width(paperSize, GTK_UNIT_INCH) * m_xDPI; + double height = gtk_paper_size_get_height(paperSize, GTK_UNIT_INCH) * m_yDPI; + + cairo_matrix_t matrix; + switch (gtk_page_setup_get_orientation(m_pageSetup.get())) { + case GTK_PAGE_ORIENTATION_LANDSCAPE: + cairo_translate(m_cairoContext.get(), 0, height); + cairo_matrix_init(&matrix, 0, -1, 1, 0, 0, 0); + cairo_transform(m_cairoContext.get(), &matrix); + break; + case GTK_PAGE_ORIENTATION_REVERSE_PORTRAIT: + cairo_translate(m_cairoContext.get(), width, height); + cairo_matrix_init(&matrix, -1, 0, 0, -1, 0, 0); + cairo_transform(m_cairoContext.get(), &matrix); + break; + case GTK_PAGE_ORIENTATION_REVERSE_LANDSCAPE: + cairo_translate(m_cairoContext.get(), width, 0); + cairo_matrix_init(&matrix, 0, 1, -1, 0, 0, 0); + cairo_transform(m_cairoContext.get(), &matrix); + break; + case GTK_PAGE_ORIENTATION_PORTRAIT: + default: + break; + } +} + +void WebPrintOperationGtk::renderPage(int pageNumber) +{ + startPage(m_cairoContext.get()); + + if (m_needsRotation) + rotatePage(); + + double left = gtk_page_setup_get_left_margin(m_pageSetup.get(), GTK_UNIT_INCH); + double top = gtk_page_setup_get_top_margin(m_pageSetup.get(), GTK_UNIT_INCH); + cairo_translate(m_cairoContext.get(), left * m_xDPI, top * m_yDPI); + + double pageWidth = gtk_page_setup_get_page_width(m_pageSetup.get(), GTK_UNIT_INCH) * m_xDPI; + WebCore::PlatformContextCairo platformContext(m_cairoContext.get()); + WebCore::GraphicsContext graphicsContext(&platformContext); + m_printContext->spoolPage(graphicsContext, pageNumber, pageWidth); + + endPage(m_cairoContext.get()); +} + +gboolean WebPrintOperationGtk::printPagesIdle(gpointer userData) +{ + PrintPagesData* data = static_cast<PrintPagesData*>(userData); + + data->incrementPageSequence(); + if (data->isDone) + return FALSE; + + data->printOperation->renderPage(data->pageNumber); + return TRUE; +} + +void WebPrintOperationGtk::printPagesIdleDone(gpointer userData) +{ + PrintPagesData* data = static_cast<PrintPagesData*>(userData); + + data->printOperation->printDone(); + delete data; +} + +void WebPrintOperationGtk::printDone() +{ + m_printPagesIdleId = 0; + + endPrint(); + // Job is now sent to the printer, we can notify the UI process that we are done. + m_webPage->send(Messages::WebPageProxy::VoidCallback(m_callbackID)); + m_cairoContext = 0; +} + +void WebPrintOperationGtk::print(cairo_surface_t* surface, double xDPI, double yDPI) +{ + ASSERT(m_printContext); + + m_xDPI = xDPI; + m_yDPI = yDPI; + m_cairoContext = adoptRef(cairo_create(surface)); + + PrintPagesData* data = new PrintPagesData(this); + m_printPagesIdleId = gdk_threads_add_idle_full(G_PRIORITY_DEFAULT_IDLE + 10, printPagesIdle, + data, printPagesIdleDone); +} + +} diff --git a/Source/WebKit2/WebProcess/WebPage/gtk/WebPrintOperationGtk.h b/Source/WebKit2/WebProcess/WebPage/gtk/WebPrintOperationGtk.h new file mode 100644 index 000000000..b142c4f63 --- /dev/null +++ b/Source/WebKit2/WebProcess/WebPage/gtk/WebPrintOperationGtk.h @@ -0,0 +1,94 @@ +/* + * Copyright (C) 2012 Igalia S.L. + * + * 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 WebPrintOperationGtk_h +#define WebPrintOperationGtk_h + +#include "PrintInfo.h" +#include <WebCore/RefPtrCairo.h> +#include <wtf/PassRefPtr.h> +#include <wtf/RefCounted.h> +#include <wtf/gobject/GRefPtr.h> + +typedef struct _GtkPrintSettings GtkPrintSettings; +typedef struct _GtkPageSetup GtkPageSetup; +typedef struct _GtkPageRange GtkPageRange; + +namespace WebCore { +class PrintContext; +}; + +namespace WebKit { + +class WebPage; + +class WebPrintOperationGtk : public RefCounted<WebPrintOperationGtk> { +public: + static PassRefPtr<WebPrintOperationGtk> create(WebPage*, const PrintInfo&); + ~WebPrintOperationGtk(); + + GtkPrintSettings* printSettings() const { return m_printSettings.get(); } + GtkPageSetup* pageSetup() const { return m_pageSetup.get(); } + unsigned int pagesToPrint() const { return m_pagesToPrint; } + int pageCount() const; + GtkPageRange* pageRanges() const { return m_pageRanges; } + size_t pageRangesCount() const { return m_pageRangesCount; } + + virtual void startPrint(WebCore::PrintContext*, uint64_t callbackID) = 0; + +protected: + WebPrintOperationGtk(WebPage*, const PrintInfo&); + + virtual void startPage(cairo_t*) = 0; + virtual void endPage(cairo_t*) = 0; + virtual void endPrint() = 0; + + static gboolean printPagesIdle(gpointer); + static void printPagesIdleDone(gpointer); + + void print(cairo_surface_t*, double xDPI, double yDPI); + void renderPage(int pageNumber); + void rotatePage(); + void printDone(); + + WebPage* m_webPage; + GRefPtr<GtkPrintSettings> m_printSettings; + GRefPtr<GtkPageSetup> m_pageSetup; + WebCore::PrintContext* m_printContext; + uint64_t m_callbackID; + RefPtr<cairo_t> m_cairoContext; + double m_xDPI; + double m_yDPI; + + unsigned int m_printPagesIdleId; + unsigned int m_pagesToPrint; + GtkPageRange* m_pageRanges; + size_t m_pageRangesCount; + bool m_needsRotation; +}; + +} + +#endif // WebPrintOperationGtk_h diff --git a/Source/WebKit2/WebProcess/WebPage/mac/TiledCoreAnimationDrawingArea.h b/Source/WebKit2/WebProcess/WebPage/mac/TiledCoreAnimationDrawingArea.h index 92620bec2..2dd065493 100644 --- a/Source/WebKit2/WebProcess/WebPage/mac/TiledCoreAnimationDrawingArea.h +++ b/Source/WebKit2/WebProcess/WebPage/mac/TiledCoreAnimationDrawingArea.h @@ -50,6 +50,8 @@ private: virtual void setNeedsDisplay(const WebCore::IntRect&) OVERRIDE; virtual void scroll(const WebCore::IntRect& scrollRect, const WebCore::IntSize& scrollOffset) OVERRIDE; + virtual void setLayerTreeStateIsFrozen(bool) OVERRIDE; + virtual bool layerTreeStateIsFrozen() const OVERRIDE; virtual void setRootCompositingLayer(WebCore::GraphicsLayer*) OVERRIDE; virtual void scheduleCompositingLayerSync() OVERRIDE; @@ -59,10 +61,14 @@ private: // Message handlers. virtual void updateGeometry(const WebCore::IntSize& viewSize) OVERRIDE; + void setRootCompositingLayer(CALayer *); + + bool m_layerTreeStateIsFrozen; WebCore::LayerFlushScheduler m_layerFlushScheduler; - RetainPtr<WKCARemoteLayerClientRef> m_remoteLayerClient; + RetainPtr<WKCARemoteLayerClientRef> m_remoteLayerClient; RetainPtr<CALayer> m_rootLayer; + RetainPtr<CALayer> m_pendingRootCompositingLayer; }; } // namespace WebKit diff --git a/Source/WebKit2/WebProcess/WebPage/mac/TiledCoreAnimationDrawingArea.mm b/Source/WebKit2/WebProcess/WebPage/mac/TiledCoreAnimationDrawingArea.mm index a1da6bde5..4aca80c4b 100644 --- a/Source/WebKit2/WebProcess/WebPage/mac/TiledCoreAnimationDrawingArea.mm +++ b/Source/WebKit2/WebProcess/WebPage/mac/TiledCoreAnimationDrawingArea.mm @@ -55,6 +55,7 @@ PassOwnPtr<TiledCoreAnimationDrawingArea> TiledCoreAnimationDrawingArea::create( TiledCoreAnimationDrawingArea::TiledCoreAnimationDrawingArea(WebPage* webPage, const WebPageCreationParameters& parameters) : DrawingArea(DrawingAreaTypeTiledCoreAnimation, webPage) + , m_layerTreeStateIsFrozen(false) , m_layerFlushScheduler(this) { Page* page = webPage->corePage(); @@ -103,34 +104,58 @@ void TiledCoreAnimationDrawingArea::scroll(const IntRect& scrollRect, const IntS void TiledCoreAnimationDrawingArea::setRootCompositingLayer(GraphicsLayer* graphicsLayer) { - if (!graphicsLayer) { - m_rootLayer.get().sublayers = nil; + CALayer *rootCompositingLayer = graphicsLayer ? graphicsLayer->platformLayer() : nil; + + if (m_layerTreeStateIsFrozen) { + m_pendingRootCompositingLayer = rootCompositingLayer; return; } - m_rootLayer.get().sublayers = [NSArray arrayWithObject:graphicsLayer->platformLayer()]; + setRootCompositingLayer(rootCompositingLayer); +} + +void TiledCoreAnimationDrawingArea::setLayerTreeStateIsFrozen(bool layerTreeStateIsFrozen) +{ + if (m_layerTreeStateIsFrozen == layerTreeStateIsFrozen) + return; + + m_layerTreeStateIsFrozen = layerTreeStateIsFrozen; + if (m_layerTreeStateIsFrozen) + m_layerFlushScheduler.suspend(); + else + m_layerFlushScheduler.resume(); +} + +bool TiledCoreAnimationDrawingArea::layerTreeStateIsFrozen() const +{ + return m_layerTreeStateIsFrozen; } void TiledCoreAnimationDrawingArea::scheduleCompositingLayerSync() { m_layerFlushScheduler.schedule(); - // FIXME: Implement } bool TiledCoreAnimationDrawingArea::flushLayers() { + ASSERT(!m_layerTreeStateIsFrozen); + // This gets called outside of the normal event loop so wrap in an autorelease pool NSAutoreleasePool *pool = [[NSAutoreleasePool alloc] init]; m_webPage->layoutIfNeeded(); + if (m_pendingRootCompositingLayer) { + setRootCompositingLayer(m_pendingRootCompositingLayer.get()); + m_pendingRootCompositingLayer = nullptr; + } + bool returnValue = m_webPage->corePage()->mainFrame()->view()->syncCompositingStateIncludingSubframes(); [pool drain]; return returnValue; } - void TiledCoreAnimationDrawingArea::updateGeometry(const IntSize& viewSize) { m_webPage->setSize(viewSize); @@ -149,4 +174,19 @@ void TiledCoreAnimationDrawingArea::updateGeometry(const IntSize& viewSize) m_webPage->send(Messages::DrawingAreaProxy::DidUpdateGeometry()); } +void TiledCoreAnimationDrawingArea::setRootCompositingLayer(CALayer *layer) +{ + ASSERT(!m_layerTreeStateIsFrozen); + + [CATransaction begin]; + [CATransaction setDisableActions:YES]; + + if (!layer) + m_rootLayer.get().sublayers = nil; + else + m_rootLayer.get().sublayers = [NSArray arrayWithObject:layer]; + + [CATransaction commit]; +} + } // namespace WebKit diff --git a/Source/WebKit2/WebProcess/WebPage/qt/LayerTreeHostQt.cpp b/Source/WebKit2/WebProcess/WebPage/qt/LayerTreeHostQt.cpp index 341fb69e4..fc1e85b21 100644 --- a/Source/WebKit2/WebProcess/WebPage/qt/LayerTreeHostQt.cpp +++ b/Source/WebKit2/WebProcess/WebPage/qt/LayerTreeHostQt.cpp @@ -240,16 +240,16 @@ void LayerTreeHostQt::didDeleteLayer(WebLayerID id) void LayerTreeHostQt::performScheduledLayerFlush() { - m_webPage->layoutIfNeeded(); - - if (!m_isValid) - return; - #if USE(TILED_BACKING_STORE) if (m_isSuspended || m_waitingForUIProcess) return; #endif + m_webPage->layoutIfNeeded(); + + if (!m_isValid) + return; + m_shouldSyncFrame = false; flushPendingLayerChanges(); if (!m_shouldSyncFrame) @@ -261,6 +261,7 @@ void LayerTreeHostQt::performScheduledLayerFlush() } m_webPage->send(Messages::LayerTreeHostProxy::DidRenderFrame()); + m_waitingForUIProcess = true; if (!m_notifyAfterScheduledLayerFlush) return; @@ -320,6 +321,8 @@ int64_t LayerTreeHostQt::adoptImageBackingStore(Image* image) graphicsContext->drawImage(image, ColorSpaceDeviceRGB, IntPoint::zero()); } + // Qt uses BGRA internally, we swizzle to RGBA for OpenGL. + bitmap->swizzleRGB(); ShareableBitmap::Handle handle; bitmap->createHandle(handle); m_webPage->send(Messages::LayerTreeHostProxy::CreateDirectlyCompositedImage(key, handle)); @@ -368,12 +371,12 @@ void LayerTreeHostQt::paintContents(const WebCore::GraphicsLayer* graphicsLayer, } } -bool LayerTreeHostQt::showDebugBorders() const +bool LayerTreeHostQt::showDebugBorders(const WebCore::GraphicsLayer*) const { return m_webPage->corePage()->settings()->showDebugBorders(); } -bool LayerTreeHostQt::showRepaintCounter() const +bool LayerTreeHostQt::showRepaintCounter(const WebCore::GraphicsLayer*) const { return m_webPage->corePage()->settings()->showRepaintCounter(); } @@ -398,22 +401,12 @@ void LayerTreeHostQt::removeTile(WebLayerID layerID, int tileID) m_webPage->send(Messages::LayerTreeHostProxy::RemoveTileForLayer(layerID, tileID)); } -void LayerTreeHostQt::setVisibleContentRectForLayer(int layerID, const WebCore::IntRect& rect) -{ - WebGraphicsLayer* layer = WebGraphicsLayer::layerByID(layerID); - if (!layer) - return; - FloatRect visibleRect(rect); - layer->setVisibleContentRect(rect); -} - void LayerTreeHostQt::setVisibleContentRectAndScale(const IntRect& rect, float scale) { - WebGraphicsLayer* layer = toWebGraphicsLayer(m_rootLayer.get()); - if (!layer) - return; - layer->setContentsScale(scale); - toWebGraphicsLayer(m_nonCompositedContentLayer.get())->setVisibleContentRect(rect); + if (m_rootLayer) { + toWebGraphicsLayer(m_rootLayer.get())->setVisibleContentRectAndScale(rect, scale); + scheduleLayerFlush(); + } } void LayerTreeHostQt::setVisibleContentRectTrajectoryVector(const FloatPoint& trajectoryVector) diff --git a/Source/WebKit2/WebProcess/WebPage/qt/LayerTreeHostQt.h b/Source/WebKit2/WebProcess/WebPage/qt/LayerTreeHostQt.h index 8527c528b..07f04e88a 100644 --- a/Source/WebKit2/WebProcess/WebPage/qt/LayerTreeHostQt.h +++ b/Source/WebKit2/WebProcess/WebPage/qt/LayerTreeHostQt.h @@ -62,19 +62,18 @@ public: virtual void pauseRendering() { m_isSuspended = true; } virtual void resumeRendering() { m_isSuspended = false; scheduleLayerFlush(); } virtual void deviceScaleFactorDidChange() { } - virtual int64_t adoptImageBackingStore(Image*); + virtual int64_t adoptImageBackingStore(WebCore::Image*); virtual void releaseImageBackingStore(int64_t); #if USE(TILED_BACKING_STORE) virtual void createTile(WebLayerID, int tileID, const UpdateInfo&); virtual void updateTile(WebLayerID, int tileID, const UpdateInfo&); virtual void removeTile(WebLayerID, int tileID); - virtual void setVisibleContentRectForLayer(int layerID, const WebCore::IntRect&); virtual void renderNextFrame(); virtual void purgeBackingStores(); virtual bool layerTreeTileUpdatesAllowed() const; - virtual void setVisibleContentRectAndScale(const IntRect&, float scale); - virtual void setVisibleContentRectTrajectoryVector(const FloatPoint&); + virtual void setVisibleContentRectAndScale(const WebCore::IntRect&, float scale); + virtual void setVisibleContentRectTrajectoryVector(const WebCore::FloatPoint&); virtual void didSyncCompositingStateForLayer(const WebLayerInfo&); virtual void didDeleteLayer(WebLayerID); #endif @@ -87,8 +86,8 @@ private: virtual void notifyAnimationStarted(const WebCore::GraphicsLayer*, double time); virtual void notifySyncRequired(const WebCore::GraphicsLayer*); virtual void paintContents(const WebCore::GraphicsLayer*, WebCore::GraphicsContext&, WebCore::GraphicsLayerPaintingPhase, const WebCore::IntRect& clipRect); - virtual bool showDebugBorders() const; - virtual bool showRepaintCounter() const; + virtual bool showDebugBorders(const WebCore::GraphicsLayer*) const; + virtual bool showRepaintCounter(const WebCore::GraphicsLayer*) const; // LayerTreeHostQt void createPageOverlayLayer(); diff --git a/Source/WebKit2/WebProcess/WebPage/qt/WebPageQt.cpp b/Source/WebKit2/WebProcess/WebPage/qt/WebPageQt.cpp index 55080d03c..7180a8c88 100644 --- a/Source/WebKit2/WebProcess/WebPage/qt/WebPageQt.cpp +++ b/Source/WebKit2/WebProcess/WebPage/qt/WebPageQt.cpp @@ -90,10 +90,6 @@ namespace WebKit { void WebPage::platformInitialize() { - Settings* settings = m_page->settings(); - - // If accelerated compositing is enabled, we want to be in force-compositing mode, so that we don't switch between composited/non-composited state. - settings->setForceCompositingMode(true); } void WebPage::platformPreferencesDidChange(const WebPreferencesStore&) diff --git a/Source/WebKit2/WebProcess/WebProcess.cpp b/Source/WebKit2/WebProcess/WebProcess.cpp index 39b3bc8e5..d0981071f 100644 --- a/Source/WebKit2/WebProcess/WebProcess.cpp +++ b/Source/WebKit2/WebProcess/WebProcess.cpp @@ -31,7 +31,6 @@ #include "InjectedBundle.h" #include "InjectedBundleMessageKinds.h" #include "InjectedBundleUserMessageCoders.h" -#include "RunLoop.h" #include "SandboxExtension.h" #include "StatisticsData.h" #include "WebApplicationCacheManager.h" @@ -72,6 +71,7 @@ #include <WebCore/PageCache.h> #include <WebCore/PageGroup.h> #include <WebCore/ResourceHandle.h> +#include <WebCore/RunLoop.h> #include <WebCore/SchemeRegistry.h> #include <WebCore/SecurityOrigin.h> #include <WebCore/Settings.h> @@ -213,8 +213,8 @@ void WebProcess::initializeWebProcess(const WebProcessCreationParameters& parame setShouldTrackVisitedLinks(parameters.shouldTrackVisitedLinks); setCacheModel(static_cast<uint32_t>(parameters.cacheModel)); - if (!parameters.languageCode.isEmpty()) - overrideDefaultLanguage(parameters.languageCode); + if (!parameters.languages.isEmpty()) + overrideUserPreferredLanguages(parameters.languages); m_textCheckerState = parameters.textCheckerState; @@ -288,9 +288,9 @@ void WebProcess::setShouldUseFontSmoothing(bool useFontSmoothing) WebCore::Font::setShouldUseSmoothing(useFontSmoothing); } -void WebProcess::languageChanged(const String& language) const +void WebProcess::userPreferredLanguagesChanged(const Vector<String>& languages) const { - overrideDefaultLanguage(language); + overrideUserPreferredLanguages(languages); } void WebProcess::fullKeyboardAccessModeChanged(bool fullKeyboardAccessEnabled) diff --git a/Source/WebKit2/WebProcess/WebProcess.h b/Source/WebKit2/WebProcess/WebProcess.h index 1e50284c0..efa2e681a 100644 --- a/Source/WebKit2/WebProcess/WebProcess.h +++ b/Source/WebKit2/WebProcess/WebProcess.h @@ -82,10 +82,10 @@ class WebProcess : public ChildProcess, private CoreIPC::Connection::QueueClient public: static WebProcess& shared(); - void initialize(CoreIPC::Connection::Identifier, RunLoop*); + void initialize(CoreIPC::Connection::Identifier, WebCore::RunLoop*); CoreIPC::Connection* connection() const { return m_connection->connection(); } - RunLoop* runLoop() const { return m_runLoop; } + WebCore::RunLoop* runLoop() const { return m_runLoop; } WebConnectionToUIProcess* webConnectionToUIProcess() const { return m_connection.get(); } @@ -161,7 +161,7 @@ private: void setDefaultRequestTimeoutInterval(double); void setAlwaysUsesComplexTextCodePath(bool); void setShouldUseFontSmoothing(bool); - void languageChanged(const String&) const; + void userPreferredLanguagesChanged(const Vector<String>&) const; void fullKeyboardAccessModeChanged(bool fullKeyboardAccessEnabled); #if PLATFORM(WIN) void setShouldPaintNativeControls(bool); @@ -241,7 +241,7 @@ private: bool m_inDidClose; - RunLoop* m_runLoop; + WebCore::RunLoop* m_runLoop; // FIXME: The visited link table should not be per process. VisitedLinkTable m_visitedLinkTable; diff --git a/Source/WebKit2/WebProcess/WebProcess.messages.in b/Source/WebKit2/WebProcess/WebProcess.messages.in index 641cc7df1..3b6a1f7b0 100644 --- a/Source/WebKit2/WebProcess/WebProcess.messages.in +++ b/Source/WebKit2/WebProcess/WebProcess.messages.in @@ -41,7 +41,7 @@ messages -> WebProcess { SetDefaultRequestTimeoutInterval(double timeoutInterval) SetAlwaysUsesComplexTextCodePath(bool alwaysUseComplexText) SetShouldUseFontSmoothing(bool useFontSmoothing) - LanguageChanged(WTF::String language) + UserPreferredLanguagesChanged(Vector<WTF::String> languages) FullKeyboardAccessModeChanged(bool fullKeyboardAccessEnabled) #if PLATFORM(WIN) SetShouldPaintNativeControls(bool shouldPaintNativeControls) diff --git a/Source/WebKit2/WebProcess/efl/WebProcessMainEfl.cpp b/Source/WebKit2/WebProcess/efl/WebProcessMainEfl.cpp index f8b3cd240..83c5c3be2 100644 --- a/Source/WebKit2/WebProcess/efl/WebProcessMainEfl.cpp +++ b/Source/WebKit2/WebProcess/efl/WebProcessMainEfl.cpp @@ -29,12 +29,14 @@ #include "WKBase.h" #include <Ecore.h> #include <WebCore/ResourceHandle.h> -#include <WebKit2/RunLoop.h> +#include <WebCore/RunLoop.h> #include <WebKit2/WebProcess.h> #include <runtime/InitializeThreading.h> #include <unistd.h> #include <wtf/MainThread.h> +using namespace WebCore; + namespace WebKit { WK_EXPORT int WebProcessMainEfl(int argc, char* argv[]) @@ -54,6 +56,9 @@ WK_EXPORT int WebProcessMainEfl(int argc, char* argv[]) #if ENABLE(GLIB_SUPPORT) g_type_init(); + + if (!ecore_main_loop_glib_integrate()) + return 1; #endif JSC::initializeThreading(); diff --git a/Source/WebKit2/WebProcess/gtk/WebProcessMainGtk.cpp b/Source/WebKit2/WebProcess/gtk/WebProcessMainGtk.cpp index fb9698eda..18c506bcc 100644 --- a/Source/WebKit2/WebProcess/gtk/WebProcessMainGtk.cpp +++ b/Source/WebKit2/WebProcess/gtk/WebProcessMainGtk.cpp @@ -31,13 +31,15 @@ #include "WKBase.h" #include <WebCore/GtkAuthenticationDialog.h> #include <WebCore/ResourceHandle.h> -#include <WebKit2/RunLoop.h> +#include <WebCore/RunLoop.h> #include <WebKit2/WebProcess.h> #include <gtk/gtk.h> #include <runtime/InitializeThreading.h> #include <unistd.h> #include <wtf/MainThread.h> +using namespace WebCore; + namespace WebKit { WK_EXPORT int WebProcessMainGtk(int argc, char* argv[]) diff --git a/Source/WebKit2/WebProcess/mac/SecItemShimMethods.mm b/Source/WebKit2/WebProcess/mac/SecItemShimMethods.mm index c3575744f..467c3e01c 100644 --- a/Source/WebKit2/WebProcess/mac/SecItemShimMethods.mm +++ b/Source/WebKit2/WebProcess/mac/SecItemShimMethods.mm @@ -80,8 +80,9 @@ static OSStatus webSecItemAdd(CFDictionaryRef query, CFTypeRef* result) OwnPtr<SecItemResponseData> response = sendSeqItemRequest(SecItemRequestData::Add, query); if (!response) return errSecInteractionNotAllowed; - - *result = response->resultObject().leakRef(); + + if (result) + *result = response->resultObject().leakRef(); return response->resultCode(); } diff --git a/Source/WebKit2/WebProcess/mac/WebProcessMac.mm b/Source/WebKit2/WebProcess/mac/WebProcessMac.mm index 7d67e1e68..7d0d69c26 100644 --- a/Source/WebKit2/WebProcess/mac/WebProcessMac.mm +++ b/Source/WebKit2/WebProcess/mac/WebProcessMac.mm @@ -252,6 +252,10 @@ void WebProcess::platformInitializeWebProcess(const WebProcessCreationParameters WebInspector::setLocalizedStringsPath(parameters.webInspectorLocalizedStringsPath); m_compositingRenderServerPort = parameters.acceleratedCompositingPort.port(); + +#if ENABLE(NOTIFICATIONS) + m_notificationManager.initialize(parameters.notificationPermissions); +#endif // rdar://9118639 accessibilityFocusedUIElement in NSApplication defaults to use the keyWindow. Since there's // no window in WK2, NSApplication needs to use the focused page's focused element. diff --git a/Source/WebKit2/WebProcess/mac/WebProcessMainMac.mm b/Source/WebKit2/WebProcess/mac/WebProcessMainMac.mm index b5a3fe07d..4e2b15532 100644 --- a/Source/WebKit2/WebProcess/mac/WebProcessMainMac.mm +++ b/Source/WebKit2/WebProcess/mac/WebProcessMainMac.mm @@ -29,9 +29,9 @@ #import "CommandLine.h" #import "EnvironmentUtilities.h" #import "EnvironmentVariables.h" -#import "RunLoop.h" #import "WebProcess.h" #import "WebSystemInterface.h" +#import <WebCore/RunLoop.h> #import <WebKit2/WKView.h> #import <WebKitSystemInterface.h> #import <mach/mach_error.h> @@ -43,8 +43,8 @@ #import <stdio.h> #import <sysexits.h> #import <unistd.h> -#import <wtf/RetainPtr.h> #import <wtf/MainThread.h> +#import <wtf/RetainPtr.h> #import <wtf/text/CString.h> #import <wtf/text/StringBuilder.h> diff --git a/Source/WebKit2/WebProcess/qt/QtNetworkAccessManager.cpp b/Source/WebKit2/WebProcess/qt/QtNetworkAccessManager.cpp index 57b953fea..aa487563d 100644 --- a/Source/WebKit2/WebProcess/qt/QtNetworkAccessManager.cpp +++ b/Source/WebKit2/WebProcess/qt/QtNetworkAccessManager.cpp @@ -1,5 +1,6 @@ /* * Copyright (C) 2011 Zeno Albisser <zeno@webkit.org> + * Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies) * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions @@ -29,7 +30,9 @@ #include "SharedMemory.h" #include "WebFrameNetworkingContext.h" #include "WebPage.h" +#include "WebPageProxyMessages.h" #include "WebProcess.h" +#include <QAuthenticator> #include <QNetworkReply> #include <QNetworkRequest> @@ -39,12 +42,8 @@ QtNetworkAccessManager::QtNetworkAccessManager(WebProcess* webProcess) : QNetworkAccessManager() , m_webProcess(webProcess) { -} - -QtNetworkAccessManager::QtNetworkAccessManager(QObject* parent) - : QNetworkAccessManager(parent) - , m_webProcess(0) -{ + connect(this, SIGNAL(authenticationRequired(QNetworkReply*, QAuthenticator*)), SLOT(onAuthenticationRequired(QNetworkReply*, QAuthenticator*))); + connect(this, SIGNAL(sslErrors(QNetworkReply*, QList<QSslError>)), SLOT(onSslErrors(QNetworkReply*, QList<QSslError>))); } WebPage* QtNetworkAccessManager::obtainOriginatingWebPage(const QNetworkRequest& request) @@ -53,13 +52,8 @@ WebPage* QtNetworkAccessManager::obtainOriginatingWebPage(const QNetworkRequest& if (!originatingObject) return 0; - QVariant pagePtr = originatingObject->property("PagePointer"); - if (!pagePtr.isValid() || !pagePtr.canConvert<void*>()) - return 0; - - WebPage* webPage = static_cast<WebPage*>(pagePtr.value<void*>()); - Q_ASSERT(webPage); - return webPage; + qulonglong pageID = originatingObject->property("pageID").toULongLong(); + return m_webProcess->webPage(pageID); } QNetworkReply* QtNetworkAccessManager::createRequest(Operation operation, const QNetworkRequest& request, QIODevice* outData) @@ -79,6 +73,49 @@ void QtNetworkAccessManager::registerApplicationScheme(const WebPage* page, cons m_applicationSchemes.insert(page, scheme.toLower()); } +void QtNetworkAccessManager::onAuthenticationRequired(QNetworkReply* reply, QAuthenticator* authenticator) +{ + WebPage* webPage = obtainOriginatingWebPage(reply->request()); + + // FIXME: This check can go away once our Qt version is up-to-date. See: QTBUG-23512. + if (!webPage) + return; + + String hostname = reply->url().toString(QUrl::RemovePath | QUrl::RemoveQuery | QUrl::RemoveFragment | QUrl::StripTrailingSlash); + String realm = authenticator->realm(); + String prefilledUsername = authenticator->user(); + String username; + String password; + + if (webPage->sendSync( + Messages::WebPageProxy::AuthenticationRequiredRequest(hostname, realm, prefilledUsername), + Messages::WebPageProxy::AuthenticationRequiredRequest::Reply(username, password))) { + if (!username.isEmpty()) + authenticator->setUser(username); + if (!password.isEmpty()) + authenticator->setPassword(password); + } +} + +void QtNetworkAccessManager::onSslErrors(QNetworkReply* reply, const QList<QSslError>& qSslErrors) +{ + WebPage* webPage = obtainOriginatingWebPage(reply->request()); + + // FIXME: This check can go away once our Qt version is up-to-date. See: QTBUG-23512. + if (!webPage) + return; + + String hostname = reply->url().host(); + bool ignoreErrors = false; + + if (webPage->sendSync( + Messages::WebPageProxy::CertificateVerificationRequest(hostname), + Messages::WebPageProxy::CertificateVerificationRequest::Reply(ignoreErrors))) { + if (ignoreErrors) + reply->ignoreSslErrors(qSslErrors); + } +} + } #include "moc_QtNetworkAccessManager.cpp" diff --git a/Source/WebKit2/WebProcess/qt/QtNetworkAccessManager.h b/Source/WebKit2/WebProcess/qt/QtNetworkAccessManager.h index 8d9eb1d0e..846221eb7 100644 --- a/Source/WebKit2/WebProcess/qt/QtNetworkAccessManager.h +++ b/Source/WebKit2/WebProcess/qt/QtNetworkAccessManager.h @@ -1,5 +1,6 @@ /* * Copyright (C) 2011 Zeno Albisser <zeno@webkit.org> + * Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies) * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions @@ -38,15 +39,19 @@ class WebProcess; class QtNetworkAccessManager : public QNetworkAccessManager { Q_OBJECT public: - QtNetworkAccessManager(QObject* parent); QtNetworkAccessManager(WebProcess*); void registerApplicationScheme(const WebPage*, const QString& scheme); protected: virtual QNetworkReply* createRequest(Operation, const QNetworkRequest&, QIODevice* outgoingData = 0) OVERRIDE; - static WebPage* obtainOriginatingWebPage(const QNetworkRequest&); + +private Q_SLOTS: + void onAuthenticationRequired(QNetworkReply *, QAuthenticator *); + void onSslErrors(QNetworkReply*, const QList<QSslError>&); private: + WebPage* obtainOriginatingWebPage(const QNetworkRequest&); + QMultiHash<const WebPage*, QString> m_applicationSchemes; WebProcess* m_webProcess; diff --git a/Source/WebKit2/WebProcess/qt/QtNetworkReply.cpp b/Source/WebKit2/WebProcess/qt/QtNetworkReply.cpp index fd0f5cb7a..e65022cdf 100644 --- a/Source/WebKit2/WebProcess/qt/QtNetworkReply.cpp +++ b/Source/WebKit2/WebProcess/qt/QtNetworkReply.cpp @@ -45,11 +45,12 @@ QtNetworkReply::QtNetworkReply(const QNetworkRequest& req, QtNetworkAccessManage setOperation(QNetworkAccessManager::GetOperation); setUrl(req.url()); setOpenMode(QIODevice::ReadOnly); - setHeader(QNetworkRequest::ContentTypeHeader, QVariant(QString::fromLocal8Bit("text/html; charset=UTF-16"))); } void QtNetworkReply::setData(const SharedMemory::Handle& handle, qint64 dataSize) { + if (handle.isNull()) + return; m_sharedMemory = SharedMemory::create(handle, SharedMemory::ReadOnly); if (!m_sharedMemory) return; @@ -60,28 +61,17 @@ void QtNetworkReply::setData(const SharedMemory::Handle& handle, qint64 dataSize void QtNetworkReply::setReplyData(const QtNetworkReplyData& replyData) { - if (replyData.m_operation) - setOperation(replyData.m_operation); - if (!replyData.m_contentDisposition.isNull()) - setHeader(QNetworkRequest::ContentDispositionHeader, QString(replyData.m_contentDisposition)); - if (!replyData.m_contentType.isNull()) + if (!replyData.m_contentType.isEmpty()) setHeader(QNetworkRequest::ContentTypeHeader, QString(replyData.m_contentType)); - if (!replyData.m_location.isNull()) - setHeader(QNetworkRequest::LocationHeader, QString(replyData.m_location)); - if (replyData.m_lastModified) - setHeader(QNetworkRequest::LastModifiedHeader, QDateTime::fromMSecsSinceEpoch(replyData.m_lastModified)); - if (!replyData.m_cookie.isNull()) - setHeader(QNetworkRequest::SetCookieHeader, QVariant::fromValue(QNetworkCookie::parseCookies(QString(replyData.m_cookie).toAscii()))); - if (!replyData.m_userAgent.isNull()) - setHeader(QNetworkRequest::UserAgentHeader, QString(replyData.m_userAgent)); - if (!replyData.m_server.isNull()) - setHeader(QNetworkRequest::ServerHeader, QString(replyData.m_server)); setHeader(QNetworkRequest::ContentLengthHeader, QVariant::fromValue(replyData.m_contentLength)); setData(replyData.m_dataHandle, replyData.m_contentLength); } qint64 QtNetworkReply::readData(char* data, qint64 maxlen) { + if (!m_sharedMemory) + return 0; + qint64 bytesRead = maxlen < m_bytesAvailable ? maxlen : m_bytesAvailable; if (qMemCopy(data, static_cast<char*>(m_sharedMemory->data()) + m_sharedMemorySize - m_bytesAvailable, bytesRead)) { m_bytesAvailable -= bytesRead; @@ -95,11 +85,6 @@ qint64 QtNetworkReply::bytesAvailable() const return m_bytesAvailable + QNetworkReply::bytesAvailable(); } -void QtNetworkReply::setHeader(QNetworkRequest::KnownHeaders header, const QVariant &value) -{ - QNetworkReply::setHeader(header, value); -} - void QtNetworkReply::abort() { } void QtNetworkReply::close() { } void QtNetworkReply::setReadBufferSize(qint64 size) { } diff --git a/Source/WebKit2/WebProcess/qt/QtNetworkReply.h b/Source/WebKit2/WebProcess/qt/QtNetworkReply.h index 8ceb7926e..d32c82103 100644 --- a/Source/WebKit2/WebProcess/qt/QtNetworkReply.h +++ b/Source/WebKit2/WebProcess/qt/QtNetworkReply.h @@ -42,12 +42,12 @@ public: virtual qint64 readData(char *data, qint64 maxlen); virtual qint64 bytesAvailable() const; - void setHeader(QNetworkRequest::KnownHeaders, const QVariant &value); - void setData(const SharedMemory::Handle&, qint64 dataSize); void setReplyData(const QtNetworkReplyData&); void finalize(); protected: + void setData(const SharedMemory::Handle&, qint64 dataSize); + virtual void abort(); virtual void close(); virtual void setReadBufferSize(qint64); @@ -55,7 +55,6 @@ protected: private: qint64 m_bytesAvailable; - QByteArray m_buffer; RefPtr<SharedMemory> m_sharedMemory; qint64 m_sharedMemorySize; }; diff --git a/Source/WebKit2/WebProcess/qt/WebProcessMainQt.cpp b/Source/WebKit2/WebProcess/qt/WebProcessMainQt.cpp index c38e38241..91e7ae437 100644 --- a/Source/WebKit2/WebProcess/qt/WebProcessMainQt.cpp +++ b/Source/WebKit2/WebProcess/qt/WebProcessMainQt.cpp @@ -25,9 +25,10 @@ */ #include "config.h" -#include "RunLoop.h" -#include <runtime/InitializeThreading.h> + #include "WebProcess.h" +#include <WebCore/RunLoop.h> +#include <runtime/InitializeThreading.h> #include <wtf/MainThread.h> #include <QApplication> diff --git a/Source/WebKit2/WebProcess/win/WebProcessMainWin.cpp b/Source/WebKit2/WebProcess/win/WebProcessMainWin.cpp index 5edeefe5c..2a70685e4 100644 --- a/Source/WebKit2/WebProcess/win/WebProcessMainWin.cpp +++ b/Source/WebKit2/WebProcess/win/WebProcessMainWin.cpp @@ -27,14 +27,16 @@ #include "WebProcessMain.h" #include "CommandLine.h" -#include "RunLoop.h" #include "WebProcess.h" +#include <WebCore/RunLoop.h> #include <WebCore/SoftLinking.h> #include <runtime/InitializeThreading.h> #include <wtf/MainThread.h> #include <wtf/text/StringHash.h> #include <wtf/text/WTFString.h> +using namespace WebCore; + namespace WebKit { #if USE(SAFARI_THEME) |
